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

Tests fail because np.int and np.float were deprecated #32

Open
wisbar opened this issue Dec 17, 2023 · 2 comments
Open

Tests fail because np.int and np.float were deprecated #32

wisbar opened this issue Dec 17, 2023 · 2 comments

Comments

@wisbar
Copy link

wisbar commented Dec 17, 2023

Hello,

Running the tests in tests/ produces a few errors like the following:

======================================================================
ERROR: _ErrorHolder
----------------------------------------------------------------------
Traceback (most recent call last):
  File "at3d\AT3D\tests\test_derivatives.py", line 838, in setUpClass
    solvers, Sensordict,cloud_poly_tables,final_step,rte_grid = cloud_solar(mie_mono_table,ext,veff,reff,ssalb,solarmu,surfacealb,ground_temperature,
  File "at3d\AT3D\tests\test_derivatives.py", line 726, in cloud_solar
    Sensordict.get_measurements(solvers, maxiter=200, n_jobs=4, verbose=False)
  File "at3d\at3d\at3d\containers.py", line 226, in get_measurements
    keys, ray_start_end, pixel_start_end = at3d.parallel.subdivide_raytrace_jobs(rte_sensors, n_jobs)
  File "at3d\at3d\at3d\parallel.py", line 142, in subdivide_raytrace_jobs
    render_jobs[key] = max(np.ceil(render_job/ray_count * n_jobs * job_factor).astype(np.int), 1)
  File "miniconda3\envs\at3d\lib\site-packages\numpy\__init__.py", line 338, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

======================================================================

For both np.int and np.float, that were deprecated since numpy 1.20.0 (see https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations ).

Changing all references to python's built-in int and float solves the errors, but while being previously aliased by np.int and np.float, perhaps a lower level revision of the dtypes is necessary to make sure they are numerically appropriate?

I'm using conda 23.9.0, python 3.10.13, and numpy 1.26.2 (can't install version 1.21.2 from the requirements in python 3.10).

Thank you

@JRLoveridge
Copy link
Member

Thanks for raising this issue.

There is currently a commit to fix this issue in the develop branch, but I haven't had the time to start/merge a pull request into the main branch. I believe that everything that requires a specific precision uses the specific numpy types (e.g. np.int8/np.float32) so it should be fine to use python's built in types for np.int and np.float to resolve this issue.

As far as I'm aware, this should not be an issue on numpy 1.21.2, I have not updated to a newer numpy version as there are some installation issues that I have yet to overcome.
Could you describe the issue that you encountered when installing from requirements in python 3.10?

@wisbar
Copy link
Author

wisbar commented Dec 18, 2023

Thanks for the quick reply. I'm sorry I missed the fix in the develop branch, that surely invalidates this issue.

As for the numpy installation, I had relied on a SO thread that maybe wasn't completely correct. According to the official release notes there should be support for python 3.10.

The problem turns out to be mainly due to my specific Windows MinGW setup with an older gcc version (gcc (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 8.1.0), which proved to be the simplest way for me to install gfortran.

For the record, the error when trying to install numpy 1.21.2 with pip is:

     Thread model: posix
      gcc version 8.1.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project)
      Traceback (most recent call last):
        File "C:\...\miniconda3\envs\at3d\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\...\miniconda3\envs\at3d\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "C:\...\miniconda3\envs\at3d\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\build_meta.py", line 211, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\build_meta.py", line 197, in _build_with_temp_dir
          self.run_setup()
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\build_meta.py", line 248, in run_setup
          super(_BuildMetaLegacyBackend,
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 448, in <module>
          setup_package()
        File "setup.py", line 440, in setup_package
          setup(**metadata)
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\core.py", line 169, in setup
          return old_setup(**new_attr)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\__init__.py", line 165, in setup
          return distutils.core.setup(**attrs)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
          dist.run_commands()
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\build.py", line 61, in run
          old_build.run(self)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\build_src.py", line 144, in run
          self.build_sources()
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\build_src.py", line 155, in build_sources
          self.build_library_sources(*libname_info)
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\build_src.py", line 288, in build_library_sources
          sources = self.generate_sources(sources, (lib_name, build_info))
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\build_src.py", line 378, in generate_sources
          source = func(extension, build_dir)
        File "numpy\core\setup.py", line 661, in get_mathlib_info
          st = config_cmd.try_link('int main(void) { return 0;}')
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 243, in try_link
          self._link(body, headers, include_dirs,
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\config.py", line 163, in _link
          return self._wrap_method(old_config._link, lang,
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\config.py", line 98, in _wrap_method
          ret = mth(*((self,)+args))
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 137, in _link
          (src, obj) = self._compile(body, headers, include_dirs, lang)
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\config.py", line 106, in _compile
          src, obj = self._wrap_method(old_config._compile, lang,
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\command\config.py", line 98, in _wrap_method
          ret = mth(*((self,)+args))
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile
          self.compiler.compile([src], include_dirs=include_dirs)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 401, in compile
          self.spawn(args)
        File "C:\...\AppData\Local\Temp\pip-build-env-3fndgjgp\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 505, in spawn
          return super().spawn(cmd, env=env)
        File "C:\...\AppData\Local\Temp\pip-install-9bpgkqww\numpy_f539f5cf82944019a92e5445835562b8\numpy\distutils\ccompiler.py", line 88, in <lambda>
          m = lambda self, *args, **kw: func(self, *args, **kw)
      TypeError: CCompiler_spawn() got an unexpected keyword argument 'env'
      [end of output]

Thanks
Bar

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