hpc4cmb / toast

Time Ordered Astrophysics Scalable Tools
Other
44 stars 39 forks source link

fix np.bool to np.bool_ #668

Closed ickc closed 1 year ago

ickc commented 1 year ago

command used: find -iname '*.py' -exec sed -i -E 's/np\.bool([^_])/bool\1/g' {} +

This is fixing a failure in TOAST test "test_binned (toast.tests.binned.BinnedTest)" with the following error with newer versions of Numpy:

AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here. 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

keskitalo commented 1 year ago

I would prefer replacing np.bool->bool but this branch will soon be obsolete so I don't mind the proposed solution.

tskisner commented 1 year ago

Since this is just running a regex on the source, can you replace np.bool_ with just bool? The main development branch (toast3) already has this change. The current master branch is in a legacy maintenance mode. It will become the 2.x branch and the toast3 branch will become the main branch and the new default. This is just waiting on the documentation PR (and the current flurry of other PRs).

ickc commented 1 year ago

Thanks! I just changed it to bool.