diff --git a/setup.py b/setup.py index 36d5735..4060a1b 100644 --- a/setup.py +++ b/setup.py @@ -11,15 +11,15 @@ install_requires=[ "autograd", "dataclasses; python_version<'3.7'", - "gym", - "mesa", + "gym==0.23.0", + "mesa<=0.8.7", "numpy", "networkx", "pandas", - "pyomo", "py_mini_racer", + "pyomo", "scipy", - "sklearn", + "scikit-learn", "statsmodels", "tqdm", ], @@ -29,5 +29,5 @@ "Operating System :: MacOS", "Operating System :: POSIX", ], - python_requires=">=3.6", + python_requires=">=3.8.10, <=3.10.11", ) diff --git a/tests/test_dynamics.py b/tests/test_dynamics.py index 7bbbef5..4146c61 100644 --- a/tests/test_dynamics.py +++ b/tests/test_dynamics.py @@ -40,6 +40,7 @@ class State(wn.dynamics.BaseState): state1: float = 0 state2: float = 1 state3: float = 3 + num_features: np.ndarray = dataclasses.field(default_factory=lambda: np.array([])) assert State.num_variables() == 3 assert State.variable_names() == ["state1", "state2", "state3"] diff --git a/whynot/causal_graphs.py b/whynot/causal_graphs.py index 1c008ec..44917cb 100644 --- a/whynot/causal_graphs.py +++ b/whynot/causal_graphs.py @@ -14,7 +14,7 @@ # Allow tracing to use ints and bools (since we only care about the forward # pass and not derivatives). -for type_ in [bool, np.bool, np.bool_, int, np.int32, np.int64]: +for type_ in [bool, np.bool_, np.bool_, int, np.int32, np.int64]: ArrayBox.register(type_) diff --git a/whynot/simulators/credit/simulator.py b/whynot/simulators/credit/simulator.py index c32eccd..82c7aeb 100644 --- a/whynot/simulators/credit/simulator.py +++ b/whynot/simulators/credit/simulator.py @@ -25,10 +25,11 @@ class State(BaseState): """State of the Credit model.""" #: Matrix of agent features (e.g. https://www.kaggle.com/c/GiveMeSomeCredit/data) - features: np.ndarray = CreditData.features + features: np.ndarray = dataclasses.field(default_factory=lambda: np.array([])) + # features: np.ndarray = CreditData.features #: Vector indicating whether or not the agent experiences financial distress - labels: np.ndarray = CreditData.labels + labels: np.ndarray = dataclasses.field(default_factory=lambda: np.array([])) def values(self): """Return the state as a dictionary of numpy arrays.""" @@ -49,13 +50,13 @@ class Config(BaseConfig): # Dynamics parameters #: Subset of the features that can be manipulated by the agent - changeable_features: np.ndarray = np.array([0, 5, 7]) + changeable_features: np.ndarray = dataclasses.field(default_factory=lambda: np.array([0, 5, 7])) #: Model how much the agent adapt her features in response to a classifier epsilon: float = 0.1 #: Parameters for logistic regression classifier used by the institution - theta: np.ndarray = np.ones((11, 1)) + theta: np.ndarray = dataclasses.field(default_factory=lambda: np.ones((11, 1))) #: L2 penalty on the logistic regression loss l2_penalty: float = 0.0 @@ -64,7 +65,7 @@ class Config(BaseConfig): memory: bool = False #: State systems resets to if no memory. - base_state: Any = State() + base_state: Any = dataclasses.field(default_factory=lambda: State()) # Simulator book-keeping #: Start time of the simulator