Skip to content

Commit 0b9eeee

Browse files
committed
update available types for ldexp
1 parent 0950e40 commit 0b9eeee

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

.github/workflows/conda-package.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146

147147
strategy:
148148
matrix:
149-
python: ["3.9", "3.10", "3.11", "3.12"]
149+
python: ["3.11", "3.12"]
150150
env:
151151
conda-bld: C:\Miniconda\conda-bld\win-64\
152152
steps:
@@ -209,7 +209,7 @@ jobs:
209209
shell: cmd /C CALL {0}
210210
strategy:
211211
matrix:
212-
python: ["3.9", "3.10", "3.11", "3.12"]
212+
python: ["3.11", "3.12"]
213213
experimental: [false]
214214
runner: [windows-2019]
215215
continue-on-error: ${{ matrix.experimental }}
@@ -325,10 +325,13 @@ jobs:
325325
326326
- name: Smoke test
327327
shell: cmd /C CALL {0}
328-
run: >-
329-
conda activate mkl_umath_test && python -c "import mkl_umath, numpy as np; mkl_umath.use_in_numpy(); np.sin(np.linspace(0, 1, num=10**6));"
328+
run: |
329+
@ECHO ON
330+
conda activate mkl_umath_test
331+
python -c "import mkl_umath, numpy as np; mkl_umath.use_in_numpy(); np.sin(np.linspace(0, 1, num=10**6));"
330332
331333
- name: Run tests
332334
shell: cmd /C CALL {0}
333335
run: |
334-
conda activate mkl_umath_test && python -m pytest -v -s --pyargs ${{ env.PACKAGE_NAME }}
336+
conda activate mkl_umath_test
337+
python -m pytest -v -s --pyargs ${{ env.PACKAGE_NAME }}

mkl_umath/generate_umath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,9 @@ def english_upper(s):
768768
None,
769769
[
770770
TypeDescription('f', None, 'fi', 'f'),
771-
TypeDescription('f', FuncNameSuffix('long'), 'fl', 'f'),
771+
TypeDescription('f', FuncNameSuffix('int64'), 'f'+int64, 'f'),
772772
TypeDescription('d', None, 'di', 'd'),
773-
TypeDescription('d', FuncNameSuffix('long'), 'dl', 'd'),
773+
TypeDescription('d', FuncNameSuffix('int64'), 'd'+int64, 'd'),
774774
],
775775
),
776776
'frexp' :

mkl_umath/src/_patch.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def use_in_numpy():
147147
148148
Examples
149149
--------
150-
>>> import mkl_umath, numpy as np
150+
>>> import mkl_umath
151151
>>> mkl_umath.is_patched()
152152
# False
153153
@@ -171,7 +171,7 @@ def restore():
171171
172172
Examples
173173
--------
174-
>>> import mkl_umath, numpy as np
174+
>>> import mkl_umath
175175
>>> mkl_umath.is_patched()
176176
# False
177177
@@ -195,7 +195,7 @@ def is_patched():
195195
196196
Examples
197197
--------
198-
>>> import mkl_umath, numpy as np
198+
>>> import mkl_umath
199199
>>> mkl_umath.is_patched()
200200
# False
201201
@@ -221,7 +221,7 @@ class mkl_umath(ContextDecorator):
221221
222222
Examples
223223
--------
224-
>>> import mkl_umath, numpy as np
224+
>>> import mkl_umath
225225
>>> mkl_umath.is_patched()
226226
# False
227227

mkl_umath/src/mkl_umath_loops.c.src

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,16 +2191,16 @@ mkl_umath_@TYPE@_ldexp(char **args, const npy_intp *dimensions, const npy_intp *
21912191
}
21922192

21932193
void
2194-
mkl_umath_@TYPE@_ldexp_long(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func))
2194+
mkl_umath_@TYPE@_ldexp_int64(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func))
21952195
{
21962196
/*
21972197
* Additional loop to handle npy_long integer inputs (cf. #866, #1633).
21982198
* npy_long != npy_int on many 64-bit platforms, so we need this second loop
2199-
* to handle the default integer type.
2199+
* to handle the default (and larger) integer types.
22002200
*/
22012201
BINARY_LOOP {
22022202
const @type@ in1 = *(@type@ *)ip1;
2203-
const long in2 = *(long *)ip2;
2203+
const npy_int64 in2 = *(npy_int64 *)ip2;
22042204
if (((int)in2) == in2) {
22052205
/* Range OK */
22062206
*((@type@ *)op1) = ldexp@c@(in1, ((int)in2));

mkl_umath/src/mkl_umath_loops.h.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mkl_umath_@TYPE@_ldexp(char **args, const npy_intp *dimensions, const npy_intp *
273273

274274
MKL_UMATH_API
275275
void
276-
mkl_umath_@TYPE@_ldexp_long(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func));
276+
mkl_umath_@TYPE@_ldexp_int64(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func));
277277

278278
#define mkl_umath_@TYPE@_true_divide mkl_umath_@TYPE@_divide
279279

mkl_umath/tests/test_basic.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import pytest
2727
import numpy as np
2828
import mkl_umath._ufuncs as mu
29+
import mkl_umath._patch as mp
2930

3031
np.random.seed(42)
3132

@@ -43,7 +44,9 @@ def get_args(args_str):
4344
elif s == 'i':
4445
args.append(np.int_(np.random.randint(low=1, high=10)))
4546
elif s == 'l':
46-
args.append(np.dtype('long').type(np.random.randint(low=1, high=10)))
47+
args.append(np.int64(np.random.randint(low=1, high=10)))
48+
elif s == 'q':
49+
args.append(np.int64(np.random.randint(low=1, high=10)))
4750
else:
4851
raise ValueError("Unexpected type specified!")
4952
return tuple(args)
@@ -82,6 +85,12 @@ def test_umath(case):
8285

8386
assert np.allclose(mkl_res, np_res), f"Results for '{umath}': mkl_res: {mkl_res}, np_res: {np_res}"
8487

85-
def test_cases_count():
86-
print("Test cases count:", len(test_cases))
87-
assert len(test_cases) > 0, "No test cases found"
88+
def test_patch():
89+
mp.restore()
90+
assert not mp.is_patched()
91+
92+
mp.use_in_numpy() # Enable mkl_umath in Numpy
93+
assert mp.is_patched()
94+
95+
mp.restore() # Disable mkl_umath in Numpy
96+
assert not mp.is_patched()

0 commit comments

Comments
 (0)