[Numpy-discussion] Re: ENH: Add reverse argument to ufunc.accumulate, cumsum, nancumsum, cumprod, nancumprod
My particular use case was computing cumulative returns in the context of reinforcement learning. A GitHub code search suggests that reverse cumsum is a fairly common operation, with 3.8k hits: https://github.com/search?q=%2Fcumsum%5C%28.*%5C%5B%3A%3A-1%5C%5D%5C%29%5C%5B%3A%3A-1%5C%5D%2F&type=code. ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: arch...@mail-archive.com
[Numpy-discussion] Re: ENH: Add reverse argument to ufunc.accumulate, cumsum, nancumsum, cumprod, nancumprod
On Sun, 2025-06-08 at 00:40 +, Carlos Martin wrote: > Add a reverse argument to accumulating functions that, when true, > causes the accumulation to be performed in reverse. Examples: Can you describe use cases? Without that, I am not sure I find the flip solution terrible enough for a very uncommon need. (For ufuncs, if you improved stride support `out=` might allow making the flip no-cost also.) - Sebastian > > - ufunc.accumulate: > https://numpy.org/doc/stable/reference/generated/numpy.ufunc.accumulate.html > - cumsum: > https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html > - nancumsum: > https://numpy.org/doc/stable/reference/generated/numpy.nancumsum.html > - cumprod: > https://numpy.org/doc/stable/reference/generated/numpy.cumprod.html > - nancumprod: > https://numpy.org/doc/stable/reference/generated/numpy.nancumprod.html > > Currently, this can be done via two flips > (https://numpy.org/doc/stable/reference/generated/numpy.flip.html) > before and after the operation. But it might be more efficient to do > it directly at the low level. > ___ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3//lists/numpy-discussion.python.org > Member address: sebast...@sipsolutions.net > ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: arch...@mail-archive.com
[Numpy-discussion] ANN: NumExpr 2.11.0, with free-threaded support, is out!
= Announcing NumExpr 2.11.0 = Hi everyone, NumExpr 2.11.0 Initial support for free-threaded Python 3.13t has been added. This is still experimental, so please report any issues you find. Finally, Python 3.10 is now the minimum supported version. Project documentation is available at: http://numexpr.readthedocs.io/ Changes from 2.10.2 to 2.11.0 - * Initial support for free-threaded Python 3.13t has been added. This is still experimental, so please report any issues you find. For more info, see discussions PRs #504, #505 and #508. Thanks to @andfoy, @rgommers and @FrancescAlted for the work. * Fix imaginary evaluation in the form of `1.1e1j`. This was previously not supported and would raise an error. Thanks to @27rabbitlt for the fix. * The test suite has been modernized to use `pytest` instead of `unittest`. This should make it easier to run the tests and contribute to the project. * Python 3.10 is now the minimum supported version. What's Numexpr? --- Numexpr is a fast numerical expression evaluator for NumPy. With it, expressions that operate on arrays (like "3*a+4*b") are accelerated and use less memory than doing the same calculation in Python. It has multi-threaded capabilities, as well as support for Intel's MKL (Math Kernel Library), which allows an extremely fast evaluation of transcendental functions (sin, cos, tan, exp, log...) while squeezing the last drop of performance out of your multi-core processors. Look here for a some benchmarks of numexpr using MKL: https://github.com/pydata/numexpr/wiki/NumexprMKL Its only dependency is NumPy (MKL is optional), so it works well as an easy-to-deploy, easy-to-use, computational engine for projects that don't want to adopt other solutions requiring more heavy dependencies. Where I can find Numexpr? - The project is hosted at GitHub in: https://github.com/pydata/numexpr You can get the packages from PyPI as well (but not for RC releases): http://pypi.python.org/pypi/numexpr Documentation is hosted at: http://numexpr.readthedocs.io/en/latest/ Share your experience - Let us know of any bugs, suggestions, gripes, kudos, etc. you may have. Enjoy data! ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: arch...@mail-archive.com
[Numpy-discussion] Silent data type casting
Hello, I discovered the horror below. Do we really want silent data type casting in this case? from numpy import * x = array([0]) x[0] = 1.7# Silent data type casting print(x)# Prints [1] instead of [1.7] Olivier ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: arch...@mail-archive.com