Skip to content

Commit dd9c783

Browse files
Merge pull request #65 from IntelPython/bugfix/gh-64
Fixes #64
2 parents f7b2c68 + 0e8bd13 commit dd9c783

File tree

3 files changed

+129
-7
lines changed

3 files changed

+129
-7
lines changed

.github/workflows/conda-package.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Conda package
2+
3+
on: push
4+
5+
env:
6+
PACKAGE_NAME: mkl_fft
7+
MODULE_NAME: mkl_fft
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python: [3.8]
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set pkgs_dirs
21+
run: |
22+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
23+
- name: Cache conda packages
24+
uses: actions/cache@v2
25+
env:
26+
CACHE_NUMBER: 0 # Increase to reset cache
27+
with:
28+
path: ~/.conda/pkgs
29+
key:
30+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
31+
restore-keys: |
32+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
33+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
34+
35+
- name: Add conda to system path
36+
run: echo $CONDA/bin >> $GITHUB_PATH
37+
- name: Install conda-build
38+
run: conda install conda-build
39+
- name: Build conda package
40+
run: |
41+
CHANNELS="-c intel -c defaults --override-channels"
42+
VERSIONS="--python ${{ matrix.python }}"
43+
TEST="--no-test"
44+
45+
conda build \
46+
$TEST \
47+
$VERSIONS \
48+
$CHANNELS \
49+
conda-recipe
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v2
52+
with:
53+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
54+
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
55+
56+
test:
57+
needs: build
58+
runs-on: ${{ matrix.runner }}
59+
60+
strategy:
61+
matrix:
62+
python: [3.8]
63+
experimental: [false]
64+
runner: [ubuntu-latest]
65+
continue-on-error: ${{ matrix.experimental }}
66+
env:
67+
CHANNELS: -c intel -c defaults --override-channels
68+
69+
steps:
70+
- name: Download artifact
71+
uses: actions/download-artifact@v2
72+
with:
73+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
74+
- name: Add conda to system path
75+
run: echo $CONDA/bin >> $GITHUB_PATH
76+
- name: Install conda-build
77+
run: conda install conda-build
78+
- name: Create conda channel
79+
run: |
80+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
81+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
82+
conda index $GITHUB_WORKSPACE/channel
83+
# Test channel
84+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
85+
86+
- name: Collect dependencies
87+
run: |
88+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
89+
conda install $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
90+
- name: Set pkgs_dirs
91+
run: |
92+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
93+
- name: Cache conda packages
94+
uses: actions/cache@v2
95+
env:
96+
CACHE_NUMBER: 0 # Increase to reset cache
97+
with:
98+
path: ~/.conda/pkgs
99+
key:
100+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
101+
restore-keys: |
102+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
103+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
104+
105+
- name: Install mkl_fft
106+
run: |
107+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
108+
conda install $PACKAGE_NAME pytest python=${{ matrix.python }} $CHANNELS
109+
# Test installed packages
110+
conda list
111+
- name: Run tests
112+
run: |
113+
python -m pytest --pyargs $MODULE_NAME

mkl_fft/_pydfti.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def iter_complementary(x, axes, func, kwargs, result):
944944
size *= x_shape[ri]
945945
sub_shape.append(x_shape[ri])
946946
dual_ind.append(ri)
947-
947+
948948
for ind in range(size):
949949
m_ind = flat_to_multi(ind, sub_shape)
950950
for k1, k2 in zip(dual_ind, m_ind):
@@ -1077,7 +1077,7 @@ def _fftnd_impl(x, shape=None, axes=None, overwrite_x=False, direction=+1, doubl
10771077
if _direct:
10781078
return _direct_fftnd(x, overwrite_arg=overwrite_x, direction=direction, fsc=fsc)
10791079
else:
1080-
if (shape is None):
1080+
if (shape is None and x.dtype in [np.complex64, np.complex128, np.float32, np.float64]):
10811081
x = np.asarray(x)
10821082
res = np.empty(x.shape, dtype=_output_dtype(x.dtype))
10831083
return iter_complementary(

mkl_fft/tests/test_fftnd.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def test_matrix5(self):
113113
mkl_fft.fftn(y[i0, :, : , i3]),
114114
rtol=r_tol, atol=a_tol
115115
)
116-
117-
116+
117+
118118

119119

120120
class Test_Regressions(TestCase):
@@ -147,6 +147,16 @@ def test_rfftn_numpy(self):
147147
tr_rfft = np.transpose(mkl_fft.rfftn_numpy(x, axes=a), a)
148148
assert_allclose(rfft_tr, tr_rfft, rtol=r_tol, atol=a_tol)
149149

150+
def test_gh64(self):
151+
"""Test example from #64"""
152+
a = np.arange(12).reshape((3,4))
153+
x = a.astype(np.cdouble)
154+
# should executed successfully
155+
r1 = mkl_fft.fftn(a, shape=None, axes=(-2,-1))
156+
r2 = mkl_fft.fftn(x)
157+
r_tol, a_tol = _get_rtol_atol(x)
158+
assert_allclose(r1, r2, rtol=r_tol, atol=a_tol)
159+
150160

151161
class Test_Scales(TestCase):
152162
def setUp(self):
@@ -185,7 +195,7 @@ def test_scale_nd(self):
185195
X.flat[:] = np.cbrt(np.arange(0, X.size, dtype=X.dtype))
186196
f = mkl_fft.fftn(X)
187197
f_scale = mkl_fft.fftn(X, forward_scale=0.2)
188-
198+
189199
r_tol, a_tol = _get_rtol_atol(X)
190200
assert_allclose(f, 5*f_scale, rtol=r_tol, atol=a_tol)
191201

@@ -194,7 +204,6 @@ def test_scale_nd_axes(self):
194204
X.flat[:] = np.cbrt(np.arange(X.size, dtype=X.dtype))
195205
f = mkl_fft.fftn(X, axes=(0, 1, 2, 3))
196206
f_scale = mkl_fft.fftn(X, axes=(0, 1, 2, 3), forward_scale=0.2)
197-
207+
198208
r_tol, a_tol = _get_rtol_atol(X)
199209
assert_allclose(f, 5*f_scale, rtol=r_tol, atol=a_tol)
200-

0 commit comments

Comments
 (0)