[Numpy-discussion] Re: Add to NumPy a function to compute cumulative sums from 0.

2023-08-22 Thread Alan G. Isaac

`cumsum` provides a sequence of partial sums, exactly as expected.
https://reference.wolfram.com/language/ref/Accumulate.html
https://www.mathworks.com/help/matlab/ref/cumsum.html
https://docs.julialang.org/en/v1/base/arrays/#Base.cumsum
https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:scanl1

`diff` also behaves as expected, and as you expect.
But I do not think that is the question.
The question is, how useful would it be for numpy to have a
less commonly needed and closely related function.
(I have no need of it, and I don't really see a pressing need.)



On 8/22/2023 10:36 AM, john.daw...@camlingroup.com wrote:

For n values there are n-1 differences. Equivalently, for k differences there 
are k+1 values. Herefor, `diff` ought to reduce length by 1 and `cumsum` ought 
to increase it by 1. Returning arrays of the same length is a fencepost error. 
This is a problem in the current behaviour of `cumsum` and the proposed 
behaviour of `diff0`.

___
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


Re: [Numpy-discussion] Comment published in Nature Astronomy about The ecological impact of computing with Python

2020-11-24 Thread Alan G. Isaac

On 11/24/2020 2:06 PM, Charles R Harris wrote:

There are still ozone holes over the Antarctic, last time I looked they were 
explained as due to an influx of cold air.


I believe industrial CFC usage, which has fallen since the Montreal Protocol,
is still considered the primary culprit in ozone layer thinning. Is there
a particular model you have in mind? (Ideally one with publicly available
source code and some data.)



On 11/24/2020 2:06 PM, Charles R Harris wrote:

If you want to deal with GHG, push nuclear power.


Yes. However, solar is becoming competitive is some regions
for cost per watt, and avoids the worst waste disposal issues.

fwiw, Alan Isaac
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] problem with numpy 1.19.4 install via pip on Win 10

2020-12-02 Thread Alan G. Isaac

numpy 1.19.3 installs fine.
numpy 1.19.4 appears to install but does not work.
(Details below. The supplied tinyurl appears relevant.)
Alan Isaac

PS test> python38 -m pip install -U numpy
Collecting numpy
  Using cached numpy-1.19.4-cp38-cp38-win_amd64.whl (13.0 MB)
Installing collected packages: numpy
Successfully installed numpy-1.19.4
PS test> python38
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
 ** On entry to DGEBAL parameter number  3 had an illegal value
 ** On entry to DGEHRD  parameter number  2 had an illegal value
 ** On entry to DORGHR DORGQR parameter number  2 had an illegal value
 ** On entry to DHSEQR parameter number  4 had an illegal value
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python38\lib\site-packages\numpy\__init__.py", line 305, in 

_win_os_check()
  File "C:\Program Files\Python38\lib\site-packages\numpy\__init__.py", line 
302, in _win_os_check
raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('C:\\Program Files\\Python38\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug 
in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86

>>>
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] problem with numpy 1.19.4 install via pip on Win 10

2020-12-03 Thread Alan G. Isaac

"current expectation is that this [fix] will be able to be released near the end of 
January 2021"
!


On 12/2/2020 7:13 PM, Ilhan Polat wrote:
Yes this is known and we are waiting MS to roll out a solution for this. Here are more details 
https://developercommunity2.visualstudio.com/t/fmod-after-an-update-to-windows-2004-is-causing-a/1207405 


___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NEP 48: Spending NumPy Project funds

2021-02-22 Thread Alan G. Isaac

Yes.

On 2/22/2021 7:08 AM, Pearu Peterson wrote:

it is nobody's business, IMHO, and is likely very hard if not impossible to 
verify

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] two questions about `choose`

2021-04-17 Thread Alan G. Isaac

1. Is there a technical reason for `choose` not accept a `dtype` argument?

2. Separately, mypy is unhappy with my 2nd argument to `choose`:
Argument 2 to "choose" has incompatible type "Tuple[int, Sequence[float]]";
expected "Union[Union[int, float, complex, str, bytes, generic], Sequence[Union[int, 
float, complex, str, bytes, generic]], Sequence[Sequence[Any]],_SupportsArray]"
However, `choose` is happy to have e.g. `choices=(0,seq)` (and I hope it will 
remain so!).

E.g.,
a = a = (0,1,1,0,0,0,1,1)  #binary array
np.choose((0,range(8)) #array([0, 1, 2, 0, 0, 0, 6, 7])

Thanks, Alan Isaac
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] two questions about `choose`

2021-04-18 Thread Alan G. Isaac

I think you are saying that this current behavior of `choose` should
be considered a bug. I hope not, because as illustrated, it is useful.
How would you propose to efficiently do the same substitutions?


On 4/17/2021 4:27 PM, Kevin Sheppard wrote:
2. I would describe this a a bug. I think sequences are converted to arrays and in this case the conversion is not returning a 2 element object array but 
expanding and then concatenation.



On Sat, Apr 17, 2021, 18:56 Alan G. Isaac mailto:alan.is...@gmail.com>> wrote:



2. Separately, mypy is unhappy with my 2nd argument to `choose`:
Argument 2 to "choose" has incompatible type "Tuple[int, Sequence[float]]";
expected "Union[Union[int, float, complex, str, bytes, generic], 
Sequence[Union[int, float, complex, str, bytes, generic]],
Sequence[Sequence[Any]],_SupportsArray]"
However, `choose` is happy to have e.g. `choices=(0,seq)` (and I hope it 
will remain so!).

E.g.,
a = a = (0,1,1,0,0,0,1,1)  #binary array
np.choose(a, (0,range(8))     #array([0, 1, 2, 0, 0, 0, 6, 7])

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] EHN: Discusions about 'add numpy.topk'

2021-05-30 Thread Alan G. Isaac

Is there any thought of allowing for other comparisons?
In which case `last_k` might be preferable.
Alan Isaac

On 5/30/2021 2:38 AM, Ilhan Polat wrote:


I think "max_k" is a good generalization of the regular "max".

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] EHN: Discusions about 'add numpy.topk'

2021-05-30 Thread Alan G. Isaac

Mathematica and Julia both seem relevant here.
Mma has TakeLargest (and Wolfram tends to think hard about names).
https://reference.wolfram.com/language/ref/TakeLargest.html
Julia's closest comparable is perhaps partialsortperm:
https://docs.julialang.org/en/v1/base/sort/#Base.Sort.partialsortperm
Alan Isaac



On 5/30/2021 4:40 AM, kang...@mail.ustc.edu.cn wrote:

Hi, Thanks for reply, I present some details below:

___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion