laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

np_common_type changed #160

Closed gems-yc4923 closed 1 month ago

gems-yc4923 commented 2 months ago

Describe the bug AttributeError: np.find_common_type was removed in the NumPy 2.0 release. Use numpy.promote_types or numpy.result_type instead. To achieve semantics for the scalar_types argument, use numpy.result_type and pass the Python values 0, 0.0, or 0j.

To Reproduce Go to EMD.py, find the _common_dtype method and replace it with the following code:


@staticmethod
def _common_dtype(x: np.ndarray, y: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
    """Casts inputs (x, y) into a common numpy DTYPE."""
    dtype = np.promote_types(x.dtype, y.dtype)
    if x.dtype != dtype:
        x = x.astype(dtype)
    if y.dtype != dtype:
        y = y.astype(dtype)
    return x, y
laszukdawid commented 1 month ago

Thanks for letting me know. Updated. Would appreciate confirming.

gems-yc4923 commented 1 month ago

All good, works well. Thank you for your work