Skip to content

Commit 17ff086

Browse files
authored
Support new numpy (#1215)
* Drop upper bound on numpy version * Update changelog
1 parent 603fe60 commit 17ff086

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

doc/progress.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Changelog
99
0.13.1
1010
~~~~~~
1111

12-
* Add new contributions here.
12+
* FIX #1198: Support numpy 1.24 and higher.
1313

1414

1515
0.13.0

openml/extensions/sklearn/extension.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,14 +1252,16 @@ def _check_dependencies(self, dependencies: str, strict_version: bool = True) ->
12521252
def _serialize_type(self, o: Any) -> "OrderedDict[str, str]":
12531253
mapping = {
12541254
float: "float",
1255-
np.float: "np.float", # type: ignore
12561255
np.float32: "np.float32",
12571256
np.float64: "np.float64",
12581257
int: "int",
1259-
np.int: "np.int", # type: ignore
12601258
np.int32: "np.int32",
12611259
np.int64: "np.int64",
12621260
}
1261+
if LooseVersion(np.__version__) < "1.24":
1262+
mapping[np.float] = "np.float"
1263+
mapping[np.int] = "np.int"
1264+
12631265
ret = OrderedDict() # type: 'OrderedDict[str, str]'
12641266
ret["oml-python:serialized_object"] = "type"
12651267
ret["value"] = mapping[o]
@@ -1268,14 +1270,16 @@ def _serialize_type(self, o: Any) -> "OrderedDict[str, str]":
12681270
def _deserialize_type(self, o: str) -> Any:
12691271
mapping = {
12701272
"float": float,
1271-
"np.float": np.float, # type: ignore
12721273
"np.float32": np.float32,
12731274
"np.float64": np.float64,
12741275
"int": int,
1275-
"np.int": np.int, # type: ignore
12761276
"np.int32": np.int32,
12771277
"np.int64": np.int64,
12781278
}
1279+
if LooseVersion(np.__version__) < "1.24":
1280+
mapping["np.float"] = np.float
1281+
mapping["np.int"] = np.int
1282+
12791283
return mapping[o]
12801284

12811285
def _serialize_rv_frozen(self, o: Any) -> "OrderedDict[str, Union[str, Dict]]":

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"python-dateutil", # Installed through pandas anyway.
5454
"pandas>=1.0.0",
5555
"scipy>=0.13.3",
56-
"numpy>=1.6.2,<1.24",
56+
"numpy>=1.6.2",
5757
"minio",
5858
"pyarrow",
5959
],

tests/test_extensions/test_sklearn_extension/test_sklearn_extension.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,10 @@ def test_serialize_strings_as_pipeline_steps(self):
952952
self.assertEqual(extracted_info[2]["drop"].name, "drop")
953953

954954
def test_serialize_type(self):
955-
supported_types = [float, np.float, np.float32, np.float64, int, np.int, np.int32, np.int64]
955+
supported_types = [float, np.float32, np.float64, int, np.int32, np.int64]
956+
if LooseVersion(np.__version__) < "1.24":
957+
supported_types.append(np.float)
958+
supported_types.append(np.int)
956959

957960
for supported_type in supported_types:
958961
serialized = self.extension.model_to_flow(supported_type)

0 commit comments

Comments
 (0)