summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/cygwin.yml2
-rw-r--r--doc/source/reference/c-api/array.rst10
-rw-r--r--doc/source/reference/c-api/types-and-structures.rst23
-rw-r--r--numpy/__init__.py10
-rw-r--r--numpy/core/meson.build6
-rw-r--r--numpy/core/tests/test_deprecations.py9
-rw-r--r--numpy/lib/__init__.py19
-rw-r--r--numpy/meson.build1
8 files changed, 57 insertions, 23 deletions
diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml
index 397d457f9..bc806e20a 100644
--- a/.github/workflows/cygwin.yml
+++ b/.github/workflows/cygwin.yml
@@ -25,7 +25,7 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Install Cygwin
- uses: cygwin/cygwin-install-action@f5e0f048310c425e84bc789f493a828c6dc80a25 # v3
+ uses: cygwin/cygwin-install-action@006ad0b0946ca6d0a3ea2d4437677fa767392401 # v4
with:
platform: x86_64
install-dir: 'C:\tools\cygwin'
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index ed6d6fb6b..c135fc6eb 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -3351,7 +3351,7 @@ Memory management
.. c:function:: int PyArray_ResolveWritebackIfCopy(PyArrayObject* obj)
- If ``obj.flags`` has :c:data:`NPY_ARRAY_WRITEBACKIFCOPY`, this function
+ If ``obj->flags`` has :c:data:`NPY_ARRAY_WRITEBACKIFCOPY`, this function
clears the flags, `DECREF` s
`obj->base` and makes it writeable, and sets ``obj->base`` to NULL. It then
copies ``obj->data`` to `obj->base->data`, and returns the error state of
@@ -3581,13 +3581,13 @@ Miscellaneous Macros
Returns the reference count of any Python object.
-.. c:function:: void PyArray_DiscardWritebackIfCopy(PyObject* obj)
+.. c:function:: void PyArray_DiscardWritebackIfCopy(PyArrayObject* obj)
- If ``obj.flags`` has :c:data:`NPY_ARRAY_WRITEBACKIFCOPY`, this function
+ If ``obj->flags`` has :c:data:`NPY_ARRAY_WRITEBACKIFCOPY`, this function
clears the flags, `DECREF` s
`obj->base` and makes it writeable, and sets ``obj->base`` to NULL. In
- contrast to :c:func:`PyArray_DiscardWritebackIfCopy` it makes no attempt
- to copy the data from `obj->base` This undoes
+ contrast to :c:func:`PyArray_ResolveWritebackIfCopy` it makes no attempt
+ to copy the data from `obj->base`. This undoes
:c:func:`PyArray_SetWritebackIfCopyBase`. Usually this is called after an
error when you are finished with ``obj``, just before ``Py_DECREF(obj)``.
It may be called multiple times, or with ``NULL`` input.
diff --git a/doc/source/reference/c-api/types-and-structures.rst b/doc/source/reference/c-api/types-and-structures.rst
index 2bcc61108..1fe7c0e93 100644
--- a/doc/source/reference/c-api/types-and-structures.rst
+++ b/doc/source/reference/c-api/types-and-structures.rst
@@ -997,10 +997,14 @@ PyUFunc_Type and PyUFuncObject
.. c:member:: npy_uint32 *core_dim_flags
- For each distinct core dimension, a set of ``UFUNC_CORE_DIM*`` flags
+ For each distinct core dimension, a set of flags (
+ :c:macro:`UFUNC_CORE_DIM_CAN_IGNORE` and
+ :c:macro:`UFUNC_CORE_DIM_SIZE_INFERRED`)
-..
- dedented to allow internal linking, pending a refactoring
+ .. c:member:: PyObject *identity_value
+
+ Identity for reduction, when :c:member:`PyUFuncObject.identity`
+ is equal to :c:data:`PyUFunc_IdentityValue`.
.. c:macro:: UFUNC_CORE_DIM_CAN_IGNORE
@@ -1011,11 +1015,6 @@ PyUFunc_Type and PyUFuncObject
if the dim size will be determined from the operands
and not from a :ref:`frozen <frozen>` signature
- .. c:member:: PyObject *identity_value
-
- Identity for reduction, when :c:member:`PyUFuncObject.identity`
- is equal to :c:data:`PyUFunc_IdentityValue`.
-
PyArrayIter_Type and PyArrayIterObject
--------------------------------------
@@ -1483,8 +1482,12 @@ for completeness and assistance in understanding the code.
Advanced indexing is handled with this Python type. It is simply a
loose wrapper around the C-structure containing the variables
- needed for advanced array indexing. The associated C-structure,
- ``PyArrayMapIterObject``, is useful if you are trying to
+ needed for advanced array indexing.
+
+.. c:type:: PyArrayMapIterObject
+
+ The C-structure associated with :c:var:`PyArrayMapIter_Type`.
+ This structure is useful if you are trying to
understand the advanced-index mapping code. It is defined in the
``arrayobject.h`` header. This type is not exposed to Python and
could be replaced with a C-structure. As a Python type it takes
diff --git a/numpy/__init__.py b/numpy/__init__.py
index 1880ceace..83b42092f 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -215,7 +215,14 @@ else:
__deprecated_attrs__.update({
n: (alias, _msg.format(n=n, an=an)) for n, alias, an in _type_info})
- del _msg, _type_info
+ import math
+
+ __deprecated_attrs__['math'] = (math,
+ "`np.math` is a deprecated alias for the standard library `math` "
+ "module (Deprecated Numpy 1.25). Replace usages of `np.math` with "
+ "`math`")
+
+ del math, _msg, _type_info
from .core import abs
# now that numpy modules are imported, can initialize limits
@@ -272,6 +279,7 @@ else:
# Warn for expired attributes, and return a dummy function
# that always raises an exception.
import warnings
+ import math
try:
msg = __expired_functions__[attr]
except KeyError:
diff --git a/numpy/core/meson.build b/numpy/core/meson.build
index 9aaa5ed87..e968fb336 100644
--- a/numpy/core/meson.build
+++ b/numpy/core/meson.build
@@ -112,7 +112,7 @@ cdata.set('NPY_SIZEOF_PY_LONG_LONG',
if cc.has_header('complex.h')
cdata.set10('HAVE_COMPLEX_H', true)
cdata.set10('NPY_USE_C99_COMPLEX', true)
- if cc.get_id() == 'msvc'
+ if cc.get_argument_syntax() == 'msvc'
complex_types_to_check = [
['NPY_HAVE_COMPLEX_FLOAT', 'NPY_SIZEOF_COMPLEX_FLOAT', '_Fcomplex', 'float'],
['NPY_HAVE_COMPLEX_DOUBLE', 'NPY_SIZEOF_COMPLEX_DOUBLE', '_Dcomplex', 'double'],
@@ -261,7 +261,7 @@ else
# function is not available in CI. For the latter there is a fallback path,
# but that is broken because we don't have the exact long double
# representation checks.
- if cc.get_id() != 'msvc'
+ if cc.get_argument_syntax() != 'msvc'
cdata.set10('HAVE_STRTOLD_L', false)
endif
endif
@@ -568,7 +568,7 @@ c_args_common = [
cpp_args_common = c_args_common + [
'-D__STDC_VERSION__=0', # for compatibility with C headers
]
-if cc.get_id() != 'msvc'
+if cc.get_argument_syntax() != 'msvc'
cpp_args_common += [
'-fno-exceptions', # no exception support
'-fno-rtti', # no runtime type information
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 96ae4b2a8..b92a20a12 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -922,3 +922,12 @@ class TestFromnumeric(_DeprecationTestCase):
# 2023-03-02, 1.25.0
def test_alltrue(self):
self.assert_deprecated(lambda: np.alltrue(np.array([True, False])))
+
+
+class TestMathAlias(_DeprecationTestCase):
+ # Deprecated in Numpy 1.25, 2023-04-06
+ def test_deprecated_np_math(self):
+ self.assert_deprecated(lambda: np.math)
+
+ def test_deprecated_np_lib_math(self):
+ self.assert_deprecated(lambda: np.lib.math)
diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py
index 58166d4b1..d3cc9fee4 100644
--- a/numpy/lib/__init__.py
+++ b/numpy/lib/__init__.py
@@ -11,7 +11,6 @@ Most contains basic functions that are used by several submodules and are
useful to have in the main name-space.
"""
-import math
from numpy.version import version as __version__
@@ -58,7 +57,7 @@ from .arraypad import *
from ._version import *
from numpy.core._multiarray_umath import tracemalloc_domain
-__all__ = ['emath', 'math', 'tracemalloc_domain', 'Arrayterator']
+__all__ = ['emath', 'tracemalloc_domain', 'Arrayterator']
__all__ += type_check.__all__
__all__ += index_tricks.__all__
__all__ += function_base.__all__
@@ -77,3 +76,19 @@ __all__ += histograms.__all__
from numpy._pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
+
+def __getattr__(attr):
+ # Warn for reprecated attributes
+ import math
+ import warnings
+
+ if attr == 'math':
+ warnings.warn(
+ "`np.lib.math` is a deprecated alias for the standard library "
+ "`math` module (Deprecated Numpy 1.25). Replace usages of "
+ "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2)
+ return math
+ else:
+ raise AttributeError("module {!r} has no attribute "
+ "{!r}".format(__name__, attr))
+
diff --git a/numpy/meson.build b/numpy/meson.build
index cc5a79bb2..3c0adf6d0 100644
--- a/numpy/meson.build
+++ b/numpy/meson.build
@@ -10,7 +10,6 @@ endif
# Platform detection
is_windows = host_machine.system() == 'windows'
is_mingw = is_windows and cc.get_id() == 'gcc'
-is_msvc = is_windows and cc.get_id() == 'msvc'
if is_windows
# For mingw-w64, link statically against the UCRT.