numexpr 2.13.1__tar.gz → 2.14.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {numexpr-2.13.1 → numexpr-2.14.0}/ANNOUNCE.rst +10 -14
  2. {numexpr-2.13.1 → numexpr-2.14.0}/MANIFEST.in +1 -1
  3. {numexpr-2.13.1 → numexpr-2.14.0}/PKG-INFO +2 -1
  4. {numexpr-2.13.1 → numexpr-2.14.0}/RELEASE_NOTES.rst +13 -1
  5. numexpr-2.14.0/VERSION +1 -0
  6. numexpr-2.14.0/numexpr/__init__.py +82 -0
  7. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/complex_functions.hpp +33 -30
  8. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/cpuinfo.py +277 -236
  9. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/expressions.py +136 -89
  10. numexpr-2.14.0/numexpr/interpreter.pyi +52 -0
  11. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/necompiler.py +179 -118
  12. numexpr-2.14.0/numexpr/py.typed +0 -0
  13. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/tests/__init__.py +3 -2
  14. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/tests/conftest.py +1 -1
  15. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/tests/test_numexpr.py +8 -0
  16. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/utils.py +76 -40
  17. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/version.py +2 -2
  18. numexpr-2.14.0/numexpr/version.pyi +6 -0
  19. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr.egg-info/PKG-INFO +2 -1
  20. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr.egg-info/SOURCES.txt +3 -0
  21. {numexpr-2.13.1 → numexpr-2.14.0}/pyproject.toml +21 -0
  22. {numexpr-2.13.1 → numexpr-2.14.0}/setup.py +2 -0
  23. numexpr-2.13.1/VERSION +0 -1
  24. numexpr-2.13.1/numexpr/__init__.py +0 -66
  25. {numexpr-2.13.1 → numexpr-2.14.0}/ADDFUNCS.rst +0 -0
  26. {numexpr-2.13.1 → numexpr-2.14.0}/AUTHORS.txt +0 -0
  27. {numexpr-2.13.1 → numexpr-2.14.0}/LICENSE.txt +0 -0
  28. {numexpr-2.13.1 → numexpr-2.14.0}/LICENSES/cpuinfo.txt +0 -0
  29. {numexpr-2.13.1 → numexpr-2.14.0}/README.rst +0 -0
  30. {numexpr-2.13.1 → numexpr-2.14.0}/bench/boolean_timing.py +0 -0
  31. {numexpr-2.13.1 → numexpr-2.14.0}/bench/free_threading.py +0 -0
  32. {numexpr-2.13.1 → numexpr-2.14.0}/bench/issue-36.py +0 -0
  33. {numexpr-2.13.1 → numexpr-2.14.0}/bench/issue-47.py +0 -0
  34. {numexpr-2.13.1 → numexpr-2.14.0}/bench/large_array_vs_numpy.py +0 -0
  35. {numexpr-2.13.1 → numexpr-2.14.0}/bench/multidim.py +0 -0
  36. {numexpr-2.13.1 → numexpr-2.14.0}/bench/poly.py +0 -0
  37. {numexpr-2.13.1 → numexpr-2.14.0}/bench/timing.py +0 -0
  38. {numexpr-2.13.1 → numexpr-2.14.0}/bench/unaligned-simple.py +0 -0
  39. {numexpr-2.13.1 → numexpr-2.14.0}/bench/varying-expr.py +0 -0
  40. {numexpr-2.13.1 → numexpr-2.14.0}/bench/vml_timing.py +0 -0
  41. {numexpr-2.13.1 → numexpr-2.14.0}/bench/vml_timing2.py +0 -0
  42. {numexpr-2.13.1 → numexpr-2.14.0}/bench/vml_timing3.py +0 -0
  43. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/bespoke_functions.hpp +0 -0
  44. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/functions.hpp +0 -0
  45. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/interp_body.cpp +0 -0
  46. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/interpreter.cpp +0 -0
  47. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/interpreter.hpp +0 -0
  48. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/missing_posix_functions.hpp +0 -0
  49. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/module.cpp +0 -0
  50. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/module.hpp +0 -0
  51. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/msvc_function_stubs.hpp +0 -0
  52. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/numexpr_config.hpp +0 -0
  53. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/numexpr_object.cpp +0 -0
  54. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/numexpr_object.hpp +0 -0
  55. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/opcodes.hpp +0 -0
  56. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/str-two-way.hpp +0 -0
  57. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/win32/pthread.c +0 -0
  58. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/win32/pthread.h +0 -0
  59. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr/win32/stdint.h +0 -0
  60. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr.egg-info/dependency_links.txt +0 -0
  61. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr.egg-info/requires.txt +0 -0
  62. {numexpr-2.13.1 → numexpr-2.14.0}/numexpr.egg-info/top_level.txt +0 -0
  63. {numexpr-2.13.1 → numexpr-2.14.0}/requirements.txt +0 -0
  64. {numexpr-2.13.1 → numexpr-2.14.0}/setup.cfg +0 -0
  65. {numexpr-2.13.1 → numexpr-2.14.0}/site.cfg.example +0 -0
@@ -1,31 +1,27 @@
1
1
  =========================
2
- Announcing NumExpr 2.13.
2
+ Announcing NumExpr 2.14.
3
3
  =========================
4
4
 
5
5
  Hi everyone,
6
6
 
7
- NumExpr 2.13.1 introduces a couple of patches for maximum/minimum and
8
- multiplication/addition for booleans to match NumPy behaviour.
9
- Thanks to Luke Shaw for these contributions.
7
+ NumExpr 2.14.0 introduces a couple of patches for tan/tanh and
8
+ adds static typing support.
9
+ Thanks to Luke Shaw and Joren Hammudoglu (@jorenham) for these contributions.
10
10
 
11
11
  Project documentation is available at:
12
12
 
13
13
  https://numexpr.readthedocs.io/
14
14
 
15
- Changes from 2.12.1 to 2.13.0
15
+ Changes from 2.13.1 to 2.14.0
16
16
  -----------------------------
17
17
 
18
- * New functionality has been added:
19
- * Bitwise operators (and, or, not, xor): `&, |, ~, ^`
20
- * New binary arithmetic operator for floor division: `//`
21
- * New functions: `signbit`, `hypot`, `copysign`, `nextafter`, `maximum`,
22
- `minimum`, `log2`, `trunc`, `round` and `sign`.
23
- * Also enables integer outputs for integer inputs for
24
- `abs`, `fmod`, `copy`, `ones_like`, `sign` and `round`.
18
+ * Numerical stability for overflow has been improved for ``tan`` and ``tanh``
19
+ to handle possible overflows for complex numbers.
25
20
 
26
- Thanks to Luke Shaw for the contributions.
21
+ * Static typing support has been added, making NumExpr compatible with
22
+ static type checkers like `mypy` and `pyright`.
23
+ Thanks to Joren Hammudoglu (@jorenham) for the work.
27
24
 
28
- * New wheels for Python 3.14 and 3.14t are provided.
29
25
 
30
26
  What's Numexpr?
31
27
  ---------------
@@ -2,7 +2,7 @@ include MANIFEST.in VERSION
2
2
 
3
3
  include *.rst *.txt *.cfg site.cfg.example
4
4
 
5
- recursive-include numexpr *.cpp *.hpp *.py
5
+ recursive-include numexpr *.cpp *.hpp *.py *.pyi py.typed
6
6
  recursive-include numexpr/win32 *.c *.h
7
7
  exclude numexpr/__config__.py RELEASING.txt site.cfg
8
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: numexpr
3
- Version: 2.13.1
3
+ Version: 2.14.0
4
4
  Summary: Fast numerical expression evaluator for NumPy
5
5
  Author-email: "David M. Cooke, Francesc Alted, and others" <blosc@blosc.org>
6
6
  Maintainer-email: Blosc Development Team <blosc@blosc.org>
@@ -14,6 +14,7 @@ Classifier: Intended Audience :: Information Technology
14
14
  Classifier: Intended Audience :: Science/Research
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Typing :: Typed
17
18
  Classifier: Operating System :: Microsoft :: Windows
18
19
  Classifier: Operating System :: Unix
19
20
  Classifier: Programming Language :: Python :: 3
@@ -1,13 +1,25 @@
1
1
  =====================================
2
- Release notes for NumExpr 2.13 series
2
+ Release notes for NumExpr 2.14 series
3
3
  =====================================
4
4
 
5
+ Changes from 2.13.1 to 2.14.0
6
+ -----------------------------
7
+
8
+ * Numerical stability for overflow has been improved for ``tan`` and ``tanh``
9
+ to handle possible overflows for complex numbers.
10
+
11
+ * Static typing support has been added, making NumExpr compatible with
12
+ static type checkers like `mypy` and `pyright`.
13
+ Thanks to Joren Hammudoglu (@jorenham) for the work.
14
+
15
+
5
16
  Changes from 2.13.0 to 2.13.1
6
17
  -----------------------------
7
18
 
8
19
  * Patch to maximum/minimum functions in order to match NumPy NaN handling
9
20
  * Patch to convert '+'->'|' and '*'->'&' for booleans
10
21
 
22
+
11
23
  Changes from 2.12.1 to 2.13.0
12
24
  -----------------------------
13
25
 
numexpr-2.14.0/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.14.0
@@ -0,0 +1,82 @@
1
+ ###################################################################
2
+ # Numexpr - Fast numerical array expression evaluator for NumPy.
3
+ #
4
+ # License: MIT
5
+ # Author: See AUTHORS.txt
6
+ #
7
+ # See LICENSE.txt and LICENSES/*.txt for details about copyright and
8
+ # rights to use.
9
+ ####################################################################
10
+
11
+ """
12
+ Numexpr is a fast numerical expression evaluator for NumPy. With it,
13
+ expressions that operate on arrays (like "3*a+4*b") are accelerated
14
+ and use less memory than doing the same calculation in Python.
15
+
16
+ See:
17
+
18
+ https://github.com/pydata/numexpr
19
+
20
+ for more info about it.
21
+
22
+ """
23
+
24
+ from typing import TYPE_CHECKING, Final
25
+
26
+ if TYPE_CHECKING:
27
+ import unittest
28
+
29
+ # the `import _ as _` are needed for mypy to understand these are re-exports
30
+
31
+ from numexpr.interpreter import __BLOCK_SIZE1__ as __BLOCK_SIZE1__
32
+ from numexpr.interpreter import MAX_THREADS as MAX_THREADS
33
+ from numexpr.interpreter import use_vml as use_vml
34
+
35
+ is_cpu_amd_intel: Final = False # DEPRECATION WARNING: WILL BE REMOVED IN FUTURE RELEASE
36
+
37
+ # cpuinfo imports were moved into the test submodule function that calls them
38
+ # to improve import times.
39
+
40
+ from numexpr.expressions import E as E
41
+ from numexpr.necompiler import NumExpr as NumExpr
42
+ from numexpr.necompiler import disassemble as disassemble
43
+ from numexpr.necompiler import evaluate as evaluate
44
+ from numexpr.necompiler import re_evaluate as re_evaluate
45
+ from numexpr.necompiler import validate as validate
46
+ from numexpr.utils import _init_num_threads
47
+ from numexpr.utils import detect_number_of_cores as detect_number_of_cores
48
+ from numexpr.utils import detect_number_of_threads as detect_number_of_threads
49
+ from numexpr.utils import get_num_threads as get_num_threads
50
+ from numexpr.utils import get_vml_version as get_vml_version
51
+ from numexpr.utils import set_num_threads as set_num_threads
52
+ from numexpr.utils import set_vml_accuracy_mode as set_vml_accuracy_mode
53
+ from numexpr.utils import set_vml_num_threads as set_vml_num_threads
54
+
55
+ # Detect the number of cores
56
+ ncores: Final = detect_number_of_cores()
57
+ # Initialize the number of threads to be used
58
+ nthreads: Final = _init_num_threads()
59
+ # The default for VML is 1 thread (see #39)
60
+ # set_vml_num_threads(1)
61
+
62
+ from . import version as version
63
+
64
+ __version__: Final = version.version
65
+
66
+ def print_versions() -> None:
67
+ """Print the versions of software that numexpr relies on."""
68
+ try:
69
+ import numexpr.tests
70
+ return numexpr.tests.print_versions() # type: ignore[no-untyped-call]
71
+ except ImportError:
72
+ # To maintain Python 2.6 compatibility we have simple error handling
73
+ raise ImportError('`numexpr.tests` could not be imported, likely it was excluded from the distribution.')
74
+
75
+ def test(verbosity: int = 1) -> "unittest.result.TestResult":
76
+ """Run all the tests in the test suite."""
77
+ try:
78
+ import numexpr.tests
79
+ return numexpr.tests.test(verbosity=verbosity) # type: ignore[no-untyped-call]
80
+ except ImportError:
81
+ # To maintain Python 2.6 compatibility we have simple error handling
82
+ raise ImportError('`numexpr.tests` could not be imported, likely it was excluded from the distribution.')
@@ -390,42 +390,45 @@ nc_sinh(std::complex<double> *x, std::complex<double> *r)
390
390
  static void
391
391
  nc_tan(std::complex<double> *x, std::complex<double> *r)
392
392
  {
393
- double sr,cr,shi,chi;
394
- double rs,is,rc,ic;
395
- double d;
396
- double xr=x->real(), xi=x->imag();
397
- sr = sin(xr);
398
- cr = cos(xr);
399
- shi = sinh(xi);
400
- chi = cosh(xi);
401
- rs = sr*chi;
402
- is = cr*shi;
403
- rc = cr*chi;
404
- ic = -sr*shi;
405
- d = rc*rc + ic*ic;
406
- r->real((rs*rc+is*ic)/d);
407
- r->imag((is*rc-rs*ic)/d);
393
+ double xr = x->real();
394
+ double xi = x->imag();
395
+ double imag_part;
396
+
397
+ double denom = cos(2*xr) + cosh(2*xi);
398
+ // handle overflows
399
+ if (xi > 20) {
400
+ imag_part = 1.0 / (1.0 + exp(-4*xi));
401
+ } else if (xi < -20) {
402
+ imag_part = -1.0 / (1.0 + exp(4*xi));
403
+ } else {
404
+ imag_part = sinh(2*xi) / denom;
405
+ }
406
+ double real_part = sin(2*xr) / denom;
407
+
408
+ r->real(real_part);
409
+ r->imag(imag_part);
408
410
  return;
409
411
  }
410
412
 
411
413
  static void
412
414
  nc_tanh(std::complex<double> *x, std::complex<double> *r)
413
415
  {
414
- double si,ci,shr,chr;
415
- double rs,is,rc,ic;
416
- double d;
417
- double xr=x->real(), xi=x->imag();
418
- si = sin(xi);
419
- ci = cos(xi);
420
- shr = sinh(xr);
421
- chr = cosh(xr);
422
- rs = ci*shr;
423
- is = si*chr;
424
- rc = ci*chr;
425
- ic = si*shr;
426
- d = rc*rc + ic*ic;
427
- r->real((rs*rc+is*ic)/d);
428
- r->imag((is*rc-rs*ic)/d);
416
+ double xr = x->real();
417
+ double xi = x->imag();
418
+ double real_part;
419
+ double denom = cosh(2*xr) + cos(2*xi);
420
+ // handle overflows
421
+ if (xr > 20) {
422
+ real_part = 1.0 / (1.0 + exp(-4*xr));
423
+ } else if (xr < -20) {
424
+ real_part = -1.0 / (1.0 + exp(4*xr));
425
+ } else {
426
+ real_part = sinh(2*xr) / denom;
427
+ }
428
+ double imag_part = sin(2*xi) / denom;
429
+
430
+ r->real(real_part);
431
+ r->imag(imag_part);
429
432
  return;
430
433
  }
431
434