[Numpy-discussion] Re: Adding NumpyUnpickler to Numpy 1.26 and future Numpy 2.0

2023-10-10 Thread Ronald van Elburg
I have one more useCase to consider from our ecosystem. 

We dump numpy arrays into a MongoDB using GridFS for subsequent visualization, 
some snippets:

'''Python
with BytesIO() as BIO:
np.save(BIO, numpy_array)
serialized_A = BIO.getvalue()
filehandle_id = self.representations_files.put(serialized_A)
'''

and then restore them in the other application:

'''Python
numpy_array = np.load(BytesIO(serializedA))
'''
For us this is for development work only and I am less concerned about having 
mixed versions in my database, but in principle that is a scenario. But it 
seems to me that for this to work the reading application needs to be migrated 
to version 2 and temporarily extended with the NumpyUnpickler before the 
writing application is migrated. Or they need to be migrated at the same time. 
Is that correct?
___
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: Adding NumpyUnpickler to Numpy 1.26 and future Numpy 2.0

2023-10-10 Thread Nathan
On Tue, Oct 10, 2023 at 7:03 AM Ronald van Elburg <
r.a.j.van.elb...@hetnet.nl> wrote:

> I have one more useCase to consider from our ecosystem.
>
> We dump numpy arrays into a MongoDB using GridFS for subsequent
> visualization, some snippets:
>
> '''Python
> with BytesIO() as BIO:
> np.save(BIO, numpy_array)
> serialized_A = BIO.getvalue()
> filehandle_id = self.representations_files.put(serialized_A)
> '''
>
> and then restore them in the other application:
>
> '''Python
> numpy_array = np.load(BytesIO(serializedA))
> '''
> For us this is for development work only and I am less concerned about
> having mixed versions in my database, but in principle that is a scenario.
> But it seems to me that for this to work the reading application needs to
> be migrated to version 2 and temporarily extended with the NumpyUnpickler
> before the writing application is migrated. Or they need to be migrated at
> the same time. Is that correct?


np.save and np.load will use NumpyUnpickler under the hood so you won’t
have any issues, you would only have issues if you saved or loaded pickles
using the pickle module directly.



> ___
> 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: nathan12...@gmail.com
>
___
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: Change in numpy.percentile

2023-10-10 Thread Matthew Brett
Hi,


On Tue, 10 Oct 2023 at 00:55, Andrew Nelson  wrote:
>
>
> On Mon, 9 Oct 2023 at 23:50, Matthew Brett  wrote:
>>
>> Hi,
>>
>> On Mon, Oct 9, 2023 at 11:49 AM Andrew Nelson  wrote:
>> Could you say more about why you consider:
>> np.mean(x, dropna=True)
>> to be less clear in intent than:
>> np.nanmean(x)
>> ?  Is it just that someone could accidentally forget that the default
>
>
> The discussion isn't a deal breaker for me, I just wanted to put out a 
> different POV.
> The name of the function encodes what it does. By putting them both in the 
> function name it's clear what the function does.
>
> nanmean -> deals with nan when calculating a mean.
>
> -vs-
>
> mean -> calculates a mean
>   |
>   > oh, it has dropna as a keyword argument, that's how you deal with nan.
>
>
> Imagine that one has a large codebase and you have to find all the locations 
> where nans could affect a mean. There may be lots of prod, sum, etc, also 
> distributed within the codebase. You wouldn't want to search for `dropna` 
> because you get every function that handles a nan. If you search for nanmean 
> you only get the locations you want.

So, is this the more or less the difference between:

grep 'np\.nanmean' *.py

and

grep 'np\.mean(.*,\s*dropna\s*=\s*True' *.py

?

Cheers,

Matthew
___
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