fmi-basel / gliberal-scMultipleX

Feature extraction and linking of multiplexing data.
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Handle np.float deprecation #104

Closed jluethi closed 1 month ago

jluethi commented 5 months ago

Some of the measurement code still uses the deprecated np.float. This now leads to the following error in minor_major axis ratio measurements:

  File "/path/to/FRACTAL_TASK_DIR/.fractal/scmultiplex0.5.0/venv/lib64/python3.9/site-packages/scmultiplex/features/feature_wrapper.py", line 113, in get_regionprops_measurements
    morphology_measurements = get_morphology_measurements(
  File "/path/to/FRACTAL_TASK_DIR/.fractal/scmultiplex0.5.0/venv/lib64/python3.9/site-packages/scmultiplex/features/feature_wrapper.py", line 198, in get_morphology_measurements
    morphology_measurements["minmajAxisRatio"] = minor_major_axis_ratio(
  File "/path/to/FRACTAL_TASK_DIR/.fractal/scmultiplex0.5.0/venv/lib64/python3.9/site-packages/scmultiplex/features/FeatureFunctions.py", line 123, in minor_major_axis_ratio
    return np.float('NaN')
  File "/path/to/FRACTAL_TASK_DIR/.fractal/scmultiplex0.5.0/venv/lib64/python3.9/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` 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

We should check where np.float is used and test whether everything works as expected with just float or whether the np.float64 is necessary.

jluethi commented 5 months ago

There are multiple instances of np.float32 / np.float64 being used in the code. But also twice just np.float: https://github.com/fmi-basel/gliberal-scMultipleX/blob/83e94dfa04f187969f7a0ee024220123f967669b/src/scmultiplex/platymatch/platymatch/estimate_transform/apply_transform.py#L28

https://github.com/fmi-basel/gliberal-scMultipleX/blob/83e94dfa04f187969f7a0ee024220123f967669b/src/scmultiplex/features/FeatureFunctions.py#L123

jluethi commented 5 months ago

Support for np.float was dropped in numpy==1.24.0

(I provisionally changed the numpy verison in the 0.5.0 Fractal task on the FMI setup to 1.23.5 to avoid this deprecation until we've fixed it)