Skip to content

Commit

Permalink
Remove use of deprecated numpy aliases of builtin types (#308)
Browse files Browse the repository at this point in the history
* Remove use of deprecated numpy aliases of builtin types

* Update use of numpy.float and numpy.int in test_schema_io.py
  • Loading branch information
oliverholworthy authored May 2, 2023
1 parent a7023fd commit 066d362
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions merlin/dtypes/mappings/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
mn.datetime64us: [np.dtype("datetime64[us]")],
mn.datetime64ns: [np.dtype("datetime64[ns]")],
# Miscellaneous
mn.string: [np.dtype("str"), np.str],
mn.object_: [np.dtype("O"), np.object],
mn.boolean: [np.dtype("bool"), np.bool],
mn.string: [np.dtype("str"), str],
mn.object_: [np.dtype("O"), object],
mn.boolean: [np.dtype("bool"), bool],
}
_dtype_registry.register("numpy", numpy_dtypes)
10 changes: 5 additions & 5 deletions tests/unit/schema/test_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ def test_column_schema_protobuf_domain_check(tmpdir):
"col1",
tags=[],
properties={"domain": {"min": 0, "max": 10}},
dtype=numpy.int,
dtype=int,
is_list=False,
)
schema2 = ColumnSchema(
"col2",
tags=[],
properties={"domain": {"min": 0.0, "max": 10.0}},
dtype=numpy.float,
dtype=float,
is_list=False,
)
saved_schema = Schema([schema1, schema2])
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_column_schema_set_protobuf(tmpdir, props1, props2, tags1, tags2, d_type

@pytest.mark.parametrize("properties", [{}, {"domain": {"min": 0, "max": 10}}])
@pytest.mark.parametrize("tags", [[], ["a", "b", "c"]])
@pytest.mark.parametrize("dtype", [numpy.float, numpy.int])
@pytest.mark.parametrize("dtype", [float, int])
@pytest.mark.parametrize("list_type", [True, False])
def test_schema_to_tensorflow_metadata(tmpdir, properties, tags, dtype, list_type):
# make sure we can round trip a schema to TensorflowMetadata without going to disk
Expand All @@ -187,7 +187,7 @@ def test_schema_to_tensorflow_metadata(tmpdir, properties, tags, dtype, list_typ
],
)
@pytest.mark.parametrize("tags", [[], ["a", "b", "c"]])
@pytest.mark.parametrize("dtype", [numpy.float, numpy.int])
@pytest.mark.parametrize("dtype", [float, int])
@pytest.mark.parametrize("list_type", [True, False])
def test_schema_to_tensorflow_metadata_json(tmpdir, properties, tags, dtype, list_type):
schema = Schema(
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_tensorflow_metadata_from_json():
def test_shapes_survive_round_trip(dim1, dim2, dim3):
dims = (dim1, dim2, dim3)

col_schema1 = ColumnSchema("col1", dtype=numpy.int, dims=dims)
col_schema1 = ColumnSchema("col1", dtype=int, dims=dims)

schema = Schema([col_schema1])
loaded_schema = TensorflowMetadata.from_merlin_schema(schema).to_merlin_schema()
Expand Down

0 comments on commit 066d362

Please sign in to comment.