Created
June 9, 2023 20:15
-
-
Save a-recknagel/a3c769dd2bd0b5be3eb2bb7601436ce8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def plot(scenario: Scenario): | |
print(scenario.data) | |
class Scenario: | |
def __init__( | |
self, | |
some_modifier=2 | |
data=None | |
): | |
self.some_modifier = some_modifier | |
if data is None: | |
self.data = np.array([1, 2, 3, 4]) | |
else: | |
self.data = data | |
@classmethod | |
def run_scenario(cls, base: scenario) -> Scenario: | |
return cls(data=self.data * self.some_modifier) | |
if __name__ == '__main__': | |
unsolved = Scenario() | |
plot(unsolved) | |
solved = Scenario.run_scenario(unsolved) | |
plot(solved) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment