From 4c949c6e5a18c9432468180e27a9079206ef2ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20And=C3=A9n?= Date: Mon, 27 Jan 2025 16:57:02 +0100 Subject: [PATCH] Remove conversion for real dtypes (#606) * py+cuda: remove conversions for real dtypes * cu+py: convert warning check to error check For real dtypes in cufinufft. * py: remove conversions for real dtypes * py: convert warning check to error check For real dtypes in finufft. --- python/cufinufft/cufinufft/_plan.py | 12 ------------ python/cufinufft/tests/test_error_checks.py | 6 ++---- python/finufft/finufft/_interfaces.py | 12 ------------ python/finufft/test/test_finufft_plan.py | 6 ++++++ 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/python/cufinufft/cufinufft/_plan.py b/python/cufinufft/cufinufft/_plan.py index 882d77f59..76eb63471 100644 --- a/python/cufinufft/cufinufft/_plan.py +++ b/python/cufinufft/cufinufft/_plan.py @@ -85,18 +85,6 @@ def __init__(self, nufft_type, n_modes, n_trans=1, eps=1e-6, isign=None, # Setup type bound methods self.dtype = np.dtype(dtype) - if self.dtype == np.float64: - warnings.warn("Real dtypes are currently deprecated and will be " - "removed in version 2.3. Converting to complex128.", - DeprecationWarning) - self.dtype = np.complex128 - - if self.dtype == np.float32: - warnings.warn("Real dtypes are currently deprecated and will be " - "removed in version 2.3. Converting to complex64.", - DeprecationWarning) - self.dtype = np.complex64 - if self.dtype == np.complex128: self._make_plan = _make_plan self._setpts = _set_pts diff --git a/python/cufinufft/tests/test_error_checks.py b/python/cufinufft/tests/test_error_checks.py index 6a9a6b4aa..8c0d49c78 100644 --- a/python/cufinufft/tests/test_error_checks.py +++ b/python/cufinufft/tests/test_error_checks.py @@ -147,10 +147,8 @@ def test_dtype_errors(): with pytest.raises(TypeError, match="Expected complex64 or complex128") as err: Plan(1, (8, 8), dtype="uint8") - -def test_dtype_warnings(): - with pytest.warns(DeprecationWarning, match="Converting to complex64") as record: + with pytest.raises(TypeError, match="Expected complex64 or complex128") as err: Plan(1, (8, 8), dtype="float32") - with pytest.warns(DeprecationWarning, match="Converting to complex128") as record: + with pytest.raises(TypeError, match="Expected complex64 or complex128") as err: Plan(1, (8, 8), dtype="float64") diff --git a/python/finufft/finufft/_interfaces.py b/python/finufft/finufft/_interfaces.py index 8c83f65db..bd6c17564 100644 --- a/python/finufft/finufft/_interfaces.py +++ b/python/finufft/finufft/_interfaces.py @@ -103,18 +103,6 @@ def __init__(self,nufft_type,n_modes_or_dim,n_trans=1,eps=1e-6,isign=None,dtype= dtype = np.dtype(dtype) - if dtype == np.float64: - warnings.warn("Real dtypes are currently deprecated and will be " - "removed in version 2.3. Converting to complex128.", - DeprecationWarning) - dtype = np.complex128 - - if dtype == np.float32: - warnings.warn("Real dtypes are currently deprecated and will be " - "removed in version 2.3. Converting to complex64.", - DeprecationWarning) - dtype = np.complex64 - is_single = is_single_dtype(dtype) # construct plan based on precision type and eps default value diff --git a/python/finufft/test/test_finufft_plan.py b/python/finufft/test/test_finufft_plan.py index 4d8a57ee2..952a79753 100644 --- a/python/finufft/test/test_finufft_plan.py +++ b/python/finufft/test/test_finufft_plan.py @@ -91,6 +91,12 @@ def test_finufft_plan_errors(): with pytest.raises(RuntimeError, match="must be single or double"): Plan(1, (8, 8), dtype="uint32") + with pytest.raises(RuntimeError, match="must be single or double"): + Plan(1, (8, 8), dtype="float32") + + with pytest.raises(RuntimeError, match="must be single or double"): + Plan(1, (8, 8), dtype="float64") + with pytest.warns(Warning, match="finufft_opts does not have"): Plan(1, (8, 8), foo="bar")