[Numpy-discussion] Assign shifted diagonal values with `np.fill_diagonal` and similar behaviour as `np.diag`

2020-12-14 Thread Ivan Gonzalez
As the subject says it will be great if `np.fill_diagonal` had a k-ith diagonal argument as `np.diag` does. The behavior expected (and a hack for the solution) is better explained in the following StackOverflow questions by me: https://stackoverflow.com/questions/65299295/assign-shifted-diagonal-va

Re: [Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Robert Kern
On Mon, Dec 14, 2020 at 3:27 PM Evgeni Burovski wrote: > > > > I also think that the lock only matters for Multithreaded code not > Multiprocess. I believe the latter pickles and unpickles any Generator > object (and the underying BitGenerator) and so each process has its own > version. Note t

Re: [Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Evgeni Burovski
> I also think that the lock only matters for Multithreaded code not > Multiprocess. I believe the latter pickles and unpickles any Generator > object (and the underying BitGenerator) and so each process has its own > version. Note that when multiprocessing the recommended procedure is to us

Re: [Numpy-discussion] Installing numpy

2020-12-14 Thread Ralf Gommers
On Mon, Dec 14, 2020 at 3:26 PM Matti Picus wrote: > NumPy HEAD does not support python2. You should use v1.16.6 which was the > last release to support python2. > That said, we should raise a comprehensible error. As well as write a test that checks we avoid py27 syntax errors like f-strings in

Re: [Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Kevin Sheppard
I don’t think it that strange.  You always need the GIL before you interact with Python code. The lock is a python object, and so you need the GIL.  You could redesign your code to always use different bit generators so that you would never use the same one, in which case you wouldn’t need to worry

Re: [Numpy-discussion] Installing numpy

2020-12-14 Thread Matti Picus
NumPy HEAD does not support python2. You should use v1.16.6 which was the last release to support python2. Matti On 12/14/20 4:14 PM, Lianyuan Zheng wrote: Is this caused by the python version installed too old (v2.7.17) or other

Re: [Numpy-discussion] Installing numpy

2020-12-14 Thread Kevin Sheppard
NumPy does not support Python 2.7. If you must use 2.7 you need to use NumPy 1.16.6.  Otherwise, you should probably be using Python 3.8 for new work. Kevin  From: Lianyuan ZhengSent: Monday, December 14, 2020 2:15 PMTo: Discussion of Numerical PythonSubject: Re: [Numpy-discussion] Installing numpy

Re: [Numpy-discussion] Installing numpy

2020-12-14 Thread Lianyuan Zheng
Hello, When I run the command "python numpy install", it shows the following error: Traceback (most recent call last): File "setup.py", line 27, in import versioneer File "./numpy/versioneer.py", line 1739 file=sys.stderr) ^ SyntaxError: invalid syntax Is this caused by the

Re: [Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Evgeni Burovski
On Mon, Dec 14, 2020 at 4:46 PM Kevin Sheppard wrote: > > You need to reacquire the gil, then you can get the lock and rerelease the > gil. > > I think this works (on phone, so untested) > > with gil: > with nogil, lock: > ... Thanks Kevin. This surely works, but feels seriously weir

Re: [Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Kevin Sheppard
You need to reacquire the gil, then you can get the lock and rerelease the gil. I think this works (on phone, so untested) with gil: with nogil, lock: ... Kevin On Mon, Dec 14, 2020, 13:37 Evgeni Burovski wrote: > Hi, > > What would be the correct way of locking the bit generator

[Numpy-discussion] locking np.random.Generator in a cython nogil context?

2020-12-14 Thread Evgeni Burovski
Hi, What would be the correct way of locking the bit generator of np.random.Generator in cython's nogil context? (This is threading 101, surely, so please forgive my ignorance). The docs for extending np.random.Generator in cython (https://numpy.org/doc/stable/reference/random/extending.html#cyth