[Numpy-discussion] Re: dtype=(bool) vs dtype=bool

2021-10-19 Thread Hongyi Zhao
On Wed, Oct 20, 2021 at 8:29 AM Robert Kern wrote: > > On Tue, Oct 19, 2021 at 8:22 PM wrote: >> >> Do I have to use it this way? > > > Nothing is forcing you to, but everyone else will write it as `dtype=bool`, > not `dtype=(bool)`. `dtype=(bool)` is perfectly syntactically-valid Python. > It'

[Numpy-discussion] Re: dtype=(bool) vs dtype=bool

2021-10-19 Thread hongyi . zhao
Do I have to use it this way? ___ 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...@ma

[Numpy-discussion] Re: dtype=(bool) vs dtype=bool

2021-10-19 Thread hongyi . zhao
> You could use `dis.dis` to compare the two expressions and see that they > compile to the same bytecode. Do you mean the following: In [1]: import numpy as np In [2]: from dis import dis In [7]: dis('bool') 1 0 LOAD_NAME0 (bool) 2 RETURN_VALUE In [8]:

[Numpy-discussion] dtype=(bool) vs dtype=bool

2021-10-19 Thread hongyi . zhao
See the following testing in IPython shell: In [6]: import numpy as np In [7]: a = np.array([1], dtype=(bool)) In [8]: b = np.array([1], dtype=bool) In [9]: a Out[9]: array([ True]) In [10]: b Out[10]: array([ True]) It seems that dtype=(bool) and dtype=bool are both correct usages. If so, wh

[Numpy-discussion] Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-18 Thread hongyi . zhao
I've written the following python code snippet in pycharm: ```python import numpy as np from numpy import pi, sin a = np.array([1], dtype=bool) if np.in|vert(a) == ~a: print('ok') ``` When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see infor

[Numpy-discussion] Re: The source code corresponding to numpy.invert.

2021-10-04 Thread Hongyi Zhao
On Mon, Oct 4, 2021 at 11:54 PM Stephen Waterbury wrote: > > On 10/4/21 10:07 AM, Hongyi Zhao wrote: > > On Mon, Oct 4, 2021 at 9:33 PM Robert Kern wrote: > > On Mon, Oct 4, 2021 at 5:17 AM Hongyi Zhao wrote: > > That’s just the way Python’s syntax works. Operators are

[Numpy-discussion] Re: The source code corresponding to numpy.invert.

2021-10-04 Thread Hongyi Zhao
On Mon, Oct 4, 2021 at 9:33 PM Robert Kern wrote: > > On Mon, Oct 4, 2021 at 5:17 AM Hongyi Zhao wrote: >> >> >> > That’s just the way Python’s syntax works. Operators are not names that >> > can be resolved to objects that can be compared with the `is

[Numpy-discussion] Re: The source code corresponding to numpy.invert.

2021-10-04 Thread Hongyi Zhao
On Mon, Oct 4, 2021 at 4:41 PM Robert Kern wrote: > > On Mon, Oct 4, 2021 at 1:09 AM wrote: >> >> Thank you for pointing this out. This is the code block which includes the >> first appearance of the keyword `logical_not`. >> >> BTW, why can't the ~ operator be tested equal to 'np.invert', as sh

[Numpy-discussion] Re: The source code corresponding to numpy.invert.

2021-10-03 Thread hongyi . zhao
Thank you for pointing this out. This is the code block which includes the first appearance of the keyword `logical_not`. BTW, why can't the ~ operator be tested equal to 'np.invert', as shown below: ``` In [1]: import numpy as np In [3]: np.invert is np.bitwise_not Out[3]: True In [4]: np.inv

[Numpy-discussion] Re: The source code corresponding to numpy.invert.

2021-10-03 Thread hongyi . zhao
> (the bool implementation uses the `logical_not` loop). Do you the following code snippet: https://github.com/numpy/numpy/blob/3c1e9b4717b2eb33a2bf2d495006bc300f5b8765/numpy/core/src/umath/loops.c.src#L1627-L1633 ___ NumPy-Discussion mailing list -- nu

[Numpy-discussion] The source code corresponding to numpy.invert.

2021-10-03 Thread hongyi . zhao
I noticed the following documentation on `numpy.invert`: [1] numpy.invert [...] Compute bit-wise inversion, or bit-wise NOT, element-wise. Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-12 Thread Hongyi Zhao
On Mon, Oct 12, 2020 at 10:41 PM Andrea Gavana wrote: > > Hi, > > On Mon, 12 Oct 2020 at 16.22, Hongyi Zhao wrote: >> >> On Mon, Oct 12, 2020 at 9:33 PM Andrea Gavana >> wrote: >> > >> > Hi, >> > >> > On Mon, 12 Oct 2020 at 14:3

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-12 Thread Hongyi Zhao
On Mon, Oct 12, 2020 at 9:33 PM Andrea Gavana wrote: > > Hi, > > On Mon, 12 Oct 2020 at 14:38, Hongyi Zhao wrote: >> >> On Sun, Oct 11, 2020 at 3:42 PM Evgeni Burovski >> wrote: >> > >> > On Sun, Oct 11, 2020 at 9:55 AM Evgeni Burovski >> &g

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-12 Thread Hongyi Zhao
appropriate. What's your point of view on this testing results? Regards, HY > > > > > Second: > > > > Move the loop into cython. > > > > > > > > > > вс, 11 окт. 2020 г., 9:32 Hongyi Zhao : > >> > >> On Sun, Oc

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-11 Thread Hongyi Zhao
nations on the reasons why doing so can improve performance? > > Second: > > Move the loop into cython. > > > > > вс, 11 окт. 2020 г., 9:32 Hongyi Zhao : >> >> On Sun, Oct 11, 2020 at 2:02 PM Andrea Gavana >> wrote: >> > >> > >>

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-11 Thread Hongyi Zhao
; > (Or avoid the overhead of trapz by just implementing the trapezoid formula > > manually) > > > Roughly like this: > https://gist.github.com/ev-br/0250e4eee461670cf489515ee427eb99 I try to run this notebook, but find that all of the function/variable/method can't be found a

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-11 Thread Hongyi Zhao
also learned that the numpy array is optimized and has the performance close to C/C++. > > > > > Second: > > > > Move the loop into cython. > > > > > > > > > > вс, 11 окт. 2020 г., 9:32 Hongyi Zhao : > >> > >> On Sun, Oct 1

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-11 Thread Hongyi Zhao
t; > Second: > > Move the loop into cython. Will this be more efficient than the schema like parallelization based on python modules, say, joblib? > > > > > вс, 11 окт. 2020 г., 9:32 Hongyi Zhao : >> >> On Sun, Oct 11, 2020 at 2:02 PM Andrea Gavana

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-10 Thread Hongyi Zhao
On Sun, Oct 11, 2020 at 2:02 PM Andrea Gavana wrote: > > > > On Sun, 11 Oct 2020 at 07.52, Hongyi Zhao wrote: >> >> On Sun, Oct 11, 2020 at 1:33 PM Andrea Gavana >> wrote: >> > >> > >> > >> > On Sun, 11 Oct 2020 at 07.14, Andr

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-10 Thread Hongyi Zhao
On Sun, Oct 11, 2020 at 1:33 PM Andrea Gavana wrote: > > > > On Sun, 11 Oct 2020 at 07.14, Andrea Gavana wrote: >> >> Hi, >> >> On Sun, 11 Oct 2020 at 00.27, Hongyi Zhao wrote: >>> >>> On Sun, Oct 11, 2020 at 1:48 AM Robert Kern wrote:

Re: [Numpy-discussion] The mu.py script will keep running and never end.

2020-10-10 Thread Hongyi Zhao
mu.py [-10.999 -10.999 -10.999 ... 20. 20. 20. ] [4.973e-84 4.973e-84 4.973e-84 ... 4.973e-84 4.973e-84 4.973e-84] real0m41.056s user0m43.970s sys0m3.813s But are there any ways to further improve/increase efficiency? Regards, HY > > On Sat, Oct 10, 2020, 8:23 A

[Numpy-discussion] The mu.py script will keep running and never end.

2020-10-10 Thread Hongyi Zhao
es/numpy/lib/function_base.py", line 2192, in _vectorize_call outputs = ufunc(*inputs) File "mu.py", line 8, in fermi return 1./(exp((E-mu)/kT)+1) KeyboardInterrupt Any helps and hints for this problem will be highly appreciated? Regards, -- Hongyi Zhao