gammasim/simtools

Address numpy warnings in unit tests.

Closed this issue · 4 comments

See e.g. output at the integration test here:

 /__w/simtools/simtools/simtools/psf_analysis.py:365: DeprecationWarning: numpy.core is deprecated and has been renamed to numpy._core. The numpy._core namespace contains private NumPy internals and its use is discouraged, as NumPy internals can change without warning in any release. In practice, most real-world usage of numpy.core is to access functionality in the public NumPy API. If that is the case, use the public NumPy API. If not, you are using NumPy internals. If you would still like to access an internal attribute, use numpy._core.records.
    return np.core.records.fromarrays(np.c_[x_pos_data, y_pos_data].T, dtype=d_type)

tests/integration_tests/test_ray_tracing.py::test_integral_curve
  /__w/simtools/simtools/simtools/psf_analysis.py:430: DeprecationWarning: numpy.core is deprecated and has been renamed to numpy._core. The numpy._core namespace contains private NumPy internals and its use is discouraged, as NumPy internals can change without warning in any release. In practice, most real-world usage of numpy.core is to access functionality in the public NumPy API. If that is the case, use the public NumPy API. If not, you are using NumPy internals. If you would still like to access an internal attribute, use numpy._core.records.
    return np.core.records.fromarrays(np.c_[radius_all, intensity].T, dtype=d_type)

I've changed the title as unit tests fail with the newest numpy installation (2.02):

FAILED tests/unit_tests/simtel/test_simulator_light_emission.py::test_plot_simtel_ctapipe - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms.py
ERROR tests/unit_tests/io_operations/test_hdf5_handler.py
ERROR tests/unit_tests/simtel/test_simtel_io_histograms.py
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_kernel_plot_2d_photons - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_plot_2ds - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_kernel_plot_1d_photons - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_plot_1ds - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_plot_event_headers - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...
ERROR tests/unit_tests/corsika/test_corsika_histograms_visualize.py::test_save_figs_to_pdf - ImportError: cannot import name 'VisibleDeprecationWarning' from 'numpy' (/Users/maierg/micromamba/envs/simtools-dev/lib/python3.11/site-packages/numpy/__init...

Related ctapipe issue: cta-observatory/ctapipe#2621

Note that I made a mistake and warnings and errors are not connected with each other. Sorry for the mixup in one issue.

Note that the import errors has been solved. This was an issue of not getting the right package version when updating a conda environemnt.