Skip to content

Commit

Permalink
Merge pull request #8058 from asi1024/fix-dst
Browse files Browse the repository at this point in the history
Fix `cupyx.scipy.fft.{dst,dstn}` in type 2/3
  • Loading branch information
takagi committed Jan 5, 2024
2 parents 60242bb + 69ee93d commit c093300
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions cupyx/scipy/fft/_realtransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ def _dct_or_dst_type2(
x *= tmp # broadcasting
x = cupy.real(x)

if dst:
slrev = [slice(None)] * x.ndim
slrev[axis] = slice(None, None, -1)
x = x[tuple(slrev)]

if norm == 'ortho':
sl0 = [slice(None)] * x.ndim
sl0[axis] = slice(1)
x[tuple(sl0)] *= math.sqrt(2) * 0.5

if dst:
slrev = [slice(None)] * x.ndim
slrev[axis] = slice(None, None, -1)
x = x[tuple(slrev)]
return x


Expand Down Expand Up @@ -315,6 +315,9 @@ def _dct_or_dst_type3(
sl0[axis] = slice(1)

if dst:
slrev = [slice(None)] * x.ndim
slrev[axis] = slice(None, None, -1)
x = x[tuple(slrev)]
if norm == 'ortho':
float_dtype = cupy.promote_types(x.dtype, cupy.float32)
if x.dtype != float_dtype:
Expand All @@ -323,9 +326,6 @@ def _dct_or_dst_type3(
x = x.copy()
x[tuple(sl0)] *= math.sqrt(2)
sl0_scale = 0.5
slrev = [slice(None)] * x.ndim
slrev[axis] = slice(None, None, -1)
x = x[tuple(slrev)]

# scale by exponentials and normalization factor
tmp = _exp_factor_dct3(x, n, axis, dtype, norm_factor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
)
)
@testing.with_requires('scipy>=1.4')
@testing.with_requires('scipy>1.11')
class TestDctDst:

def _run_transform(self, dct_func, xp, dtype):
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_dct_backend(self, xp, dtype):
)
)
)
@testing.with_requires('scipy>=1.4')
@testing.with_requires('scipy>1.11')
class TestDctnDstn():

def _run_transform(self, dct_func, xp, dtype):
Expand Down

0 comments on commit c093300

Please sign in to comment.