summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2023-04-12 12:14:33 +0200
committerSebastian Berg <sebastianb@nvidia.com>2023-04-12 12:26:48 +0200
commit569f7bc692aab41014ddc683c06e84e1bc276305 (patch)
tree7e1b490fe442d71fb9bcf01eb797bfebcaac16d6 /numpy/core
parent868a53b6725da70d408eb60b93a6f248cdd4b880 (diff)
downloadnumpy-569f7bc692aab41014ddc683c06e84e1bc276305.tar.gz
MAINT: Move module to be `np.dtypes` and add release note
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/__init__.py4
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src4
-rw-r--r--numpy/core/src/multiarray/dtypemeta.c4
-rw-r--r--numpy/core/tests/test_dtype.py10
4 files changed, 11 insertions, 11 deletions
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py
index 5193a694c..08e717363 100644
--- a/numpy/core/__init__.py
+++ b/numpy/core/__init__.py
@@ -143,11 +143,11 @@ def _DType_reconstruct(scalar_type):
def _DType_reduce(DType):
# As types/classes, most DTypes can simply be pickled by their name:
- if not DType._legacy or DType.__module__ == "numpy.types":
+ if not DType._legacy or DType.__module__ == "numpy.dtypes":
return DType.__name__
# However, user defined legacy dtypes (like rational) do not end up in
- # `numpy.types` as module and do not have a public class at all.
+ # `numpy.dtypes` as module and do not have a public class at all.
# For these, we pickle them by reconstructing them from the scalar type:
scalar_type = DType.type
return _DType_reconstruct, (scalar_type,)
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index 537234358..b84625c77 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -4658,9 +4658,9 @@ set_typeinfo(PyObject *dict)
*/
if (dtypemeta_wrap_legacy_descriptor(
_builtin_descrs[NPY_@NAME@],
- "numpy.types." NPY_@NAME@_Name "DType",
+ "numpy.dtypes." NPY_@NAME@_Name "DType",
#ifdef NPY_@NAME@_alias
- "numpy.types." NPY_@NAME@_Alias "DType"
+ "numpy.dtypes." NPY_@NAME@_Alias "DType"
#else
NULL
#endif
diff --git a/numpy/core/src/multiarray/dtypemeta.c b/numpy/core/src/multiarray/dtypemeta.c
index 2abbf394e..2052f17fd 100644
--- a/numpy/core/src/multiarray/dtypemeta.c
+++ b/numpy/core/src/multiarray/dtypemeta.c
@@ -791,7 +791,7 @@ dtypemeta_wrap_legacy_descriptor(PyArray_Descr *descr,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_base = &PyArrayDescr_Type,
.tp_new = (newfunc)legacy_dtype_default_new,
- .tp_doc = (
+ .tp_doc = (
"DType class corresponding to the scalar type and dtype of "
"the same name.\n\n"
"Please see `numpy.dtype` for the typical way to create\n"
@@ -895,7 +895,7 @@ dtypemeta_wrap_legacy_descriptor(PyArray_Descr *descr,
/* And it to the types submodule if it is a builtin dtype */
if (!PyTypeNum_ISUSERDEF(descr->type_num)) {
static PyObject *add_dtype_helper = NULL;
- npy_cache_import("numpy.types", "_add_dtype_helper", &add_dtype_helper);
+ npy_cache_import("numpy.dtypes", "_add_dtype_helper", &add_dtype_helper);
if (add_dtype_helper == NULL) {
return -1;
}
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 107b70835..57831f46f 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -7,7 +7,7 @@ import types
from typing import Any
import numpy as np
-import numpy.types
+import numpy.dtypes
from numpy.core._rational_tests import rational
from numpy.core._multiarray_tests import create_custom_field_dtype
from numpy.testing import (
@@ -1572,9 +1572,9 @@ class TestDTypeClasses:
dt_name += "c"
sc_name = dtype.type.__name__
assert dt_name == sc_name.strip("_")
- assert type(dtype).__module__ == "numpy.types"
+ assert type(dtype).__module__ == "numpy.dtypes"
- assert getattr(numpy.types, type(dtype).__name__) is type(dtype)
+ assert getattr(numpy.dtypes, type(dtype).__name__) is type(dtype)
else:
assert type(dtype).__name__ == "dtype[rational]"
assert type(dtype).__module__ == "numpy"
@@ -1616,7 +1616,7 @@ class TestDTypeClasses:
@pytest.mark.parametrize("int_", ["UInt", "Int"])
@pytest.mark.parametrize("size", [8, 16, 32, 64])
def test_integer_alias_names(self, int_, size):
- DType = getattr(numpy.types, f"{int_}{size}DType")
+ DType = getattr(numpy.dtypes, f"{int_}{size}DType")
sctype = getattr(numpy, f"{int_.lower()}{size}")
assert DType.type is sctype
assert DType.__name__.lower().removesuffix("dtype") == sctype.__name__
@@ -1625,7 +1625,7 @@ class TestDTypeClasses:
["Half", "Float", "Double", "CFloat", "CDouble"])
def test_float_alias_names(self, name):
with pytest.raises(AttributeError):
- getattr(numpy.types, name + "DType") is numpy.types.Float16DType
+ getattr(numpy.dtypes, name + "DType") is numpy.dtypes.Float16DType
class TestFromCTypes: