Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14 test failures for =nptyping-2.5.0 (Name "np.bool8" is not defined) #113

Open
TheChymera opened this issue Dec 1, 2023 · 1 comment
Open

Comments

@TheChymera
Copy link

Full build log: https://ppb.chymera.eu/2facbc.log

Example excerpt of failure:

__________________________________________ MyPyDataFrameTest.test_mypy_knows_of_dataframe_methods __________________________________________

self = <tests.pandas_.test_mypy_dataframe.MyPyDataFrameTest testMethod=test_mypy_knows_of_dataframe_methods>

    @skipUnless(7 < sys.version_info.minor, "MyPy does not work with DataFrame on 3.7")
    def test_mypy_knows_of_dataframe_methods(self):
        # If MyPy knows of some arbitrary DataFrame methods, we can assume that
        # code completion works.
        exit_code, stdout, stderr = check_mypy_on_code(
            """
            from typing import Any
            from nptyping import DataFrame


            df: DataFrame[Any]
            df.shape
            df.dtypes
            df.values
            df.boxplot
            df.filter
        """
        )

>       self.assertEqual(0, exit_code, stdout)
E       AssertionError: 0 != 1 : nptyping/typing_.pyi:50: error: Name "np.bool8" is not defined  [name-defined]
E       nptyping/typing_.pyi:52: error: Name "np.object0" is not defined  [name-defined]
E       nptyping/typing_.pyi:64: error: Name "np.int0" is not defined  [name-defined]
E       nptyping/typing_.pyi:77: error: Name "np.uint0" is not defined  [name-defined]
E       nptyping/typing_.pyi:104: error: Name "np.void0" is not defined  [name-defined]
E       nptyping/typing_.pyi:109: error: Name "np.bytes0" is not defined  [name-defined]
E       nptyping/typing_.pyi:111: error: Name "np.str0" is not defined  [name-defined]
E       /var/tmp/portage/dev-python/nptyping-2.5.0/temp/tmp40dzg4lh/test_file.py:5: error: "DataFrame" expects no type arguments, but 1 given  [type-arg]
E       Found 8 errors in 2 files (checked 1 source file)

exit_code  = 1
self       = <tests.pandas_.test_mypy_dataframe.MyPyDataFrameTest testMethod=test_mypy_knows_of_dataframe_methods>
stderr     = ''
stdout     = ('nptyping/typing_.pyi:50: error: Name "np.bool8" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:52: error: Name "np.object0" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:64: error: Name "np.int0" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:77: error: Name "np.uint0" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:104: error: Name "np.void0" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:109: error: Name "np.bytes0" is not defined  '
 '[name-defined]\n'
 'nptyping/typing_.pyi:111: error: Name "np.str0" is not defined  '
 '[name-defined]\n'
 '/var/tmp/portage/dev-python/nptyping-2.5.0/temp/tmp40dzg4lh/test_file.py:5: '
 'error: "DataFrame" expects no type arguments, but 1 given  [type-arg]\n'
 'Found 8 errors in 2 files (checked 1 source file)\n')

tests/pandas_/test_mypy_dataframe.py:61: AssertionError

Any ideas what's wrong here?
Is it a question of np.bool8 being deprecated in favour of np.bool_?

Apparently the package already uses both 🤔:

decohost /var/tmp/portage/dev-python/nptyping-2.5.0/work/nptyping-2.5.0 # rg np.bool
tests/test_mypy.py
121:            NDArray[Any, np.dtype[np.bool_]]

tests/test_ndarray.py
269:        self.assertIsInstance(np.array([True]), NDArray[Any, np.bool_])

nptyping/typing_.py
50:Bool = np.bool_
51:Bool8 = np.bool8

nptyping/typing_.pyi
49:Bool: TypeAlias = np.dtype[np.bool_]
50:Bool8: TypeAlias = np.dtype[np.bool8]
@stonier
Copy link

stonier commented Dec 7, 2023

I just ran into a large list of warnings as well.

Appears to be a few deprecations in Numpy v1.24:

Is it a question of np.bool8 being deprecated in favour of np.bool_

From what I can gather, numpy's dtype needs something not built-in internally, so that's what np.bool_ is for. From a user's point of view, I think we're supposed to be just using bool.

Some enlightening code:

>>> import numpy as np
np>>> np.bool
<type 'bool'>
>>> np.bool is bool
True
>>> np.bool_ is bool
False 
>>> np.ones(2, dtype=bool).dtype
dtype('bool')
>>> np.ones(2, dtype=np.bool_).dtype
dtype('bool')

nocarryr added a commit to nocarryr/lupy that referenced this issue Jun 16, 2024
Importing nptyping with numpy>=2.0.0 now raises exceptions
instead of warnings for deprecated dtypes.

ramonhagenaars/nptyping#114
ramonhagenaars/nptyping#113
ramonhagenaars/nptyping#102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants