diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29b..a8e5814b 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,5 @@ +- bump: minor + changes: + fixed: + - Bump numpy version + - Fix numpy record compatibility issue diff --git a/policyengine_core/parameters/helpers.py b/policyengine_core/parameters/helpers.py index b353c069..f729bb9f 100644 --- a/policyengine_core/parameters/helpers.py +++ b/policyengine_core/parameters/helpers.py @@ -9,7 +9,9 @@ def contains_nan(vector): - if numpy.issubdtype(vector.dtype, numpy.record): + if numpy.issubdtype(vector.dtype, numpy.record) or numpy.issubdtype( + vector.dtype, numpy.void + ): return any([contains_nan(vector[name]) for name in vector.dtype.names]) else: return numpy.isnan(vector).any() diff --git a/policyengine_core/parameters/vectorial_parameter_node_at_instant.py b/policyengine_core/parameters/vectorial_parameter_node_at_instant.py index 753d060a..e4914ed3 100644 --- a/policyengine_core/parameters/vectorial_parameter_node_at_instant.py +++ b/policyengine_core/parameters/vectorial_parameter_node_at_instant.py @@ -23,7 +23,7 @@ def build_from_node( node: "ParameterNode", ) -> "VectorialParameterNodeAtInstant": VectorialParameterNodeAtInstant.check_node_vectorisable(node) - subnodes_name = node._children.keys() + subnodes_name = sorted(node._children.keys()) # Recursively vectorize the children of the node vectorial_subnodes = tuple( [ @@ -227,7 +227,9 @@ def __getitem__(self, key: str) -> Any: ) # If the result is not a leaf, wrap the result in a vectorial node. - if numpy.issubdtype(result.dtype, numpy.record): + if numpy.issubdtype( + result.dtype, numpy.record + ) or numpy.issubdtype(result.dtype, numpy.void): return VectorialParameterNodeAtInstant( self._name, result.view(numpy.recarray), self._instant_str ) diff --git a/setup.py b/setup.py index b09b10fd..6c568c76 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ general_requirements = [ "pytest>=7,<8", - "numpy>=1.21,<1.22", + "numpy >=1.24.2, <1.25", "black", "linecheck<1", "yaml-changelog<1",