[Numpy-discussion] Re: Get a function definition/implementation hint similar to the one shown in pycharm.
On Tue, Oct 19, 2021 at 7:26 AM wrote: > 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 information similar to that provided by > `pycharm`, as shown in the following screenshots: > Hi, Could you explain exactly what you're asking about? Are you using pycharm, but want to see similar tooltips with your custom (non-numpy-library) code? Or do you want to see these numpy hints outside pycharm? If the latter, what kind of IDE do you mean? András > > https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png > > https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png > > But I wonder if there are any other python packages/tools that can help me > achieve this goal? > > Regards, > HZ > ___ > 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: deak.and...@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] dtype=(bool) vs dtype=bool
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, which is preferable? Regards, HZ ___ 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: dtype=(bool) vs dtype=bool
On Tue, Oct 19, 2021 at 3:42 PM wrote: > 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, > which is preferable? > This is not really a numpy issue: in Python itself `(bool)` is the exact same thing as `bool`. Superfluous parentheses are just ignored. You could use `dis.dis` to compare the two expressions and see that they compile to the same bytecode. So go with `dtype=bool`. András > Regards, > HZ > ___ > 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: deak.and...@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: dtype=(bool) vs dtype=bool
(something) in python is only needed if you need to change the order of precedence or if you need to split something across 2 or more lines. Otherwise, it has no meaning and it is extraneous. On Tue, Oct 19, 2021 at 9:42 AM wrote: > 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, > which is preferable? > > Regards, > HZ > ___ > 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: ben.v.r...@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: dtype=(bool) vs dtype=bool
> 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]: dis('(bool)') 1 0 LOAD_NAME0 (bool) 2 RETURN_VALUE ___ 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: dtype=(bool) vs dtype=bool
As he said: this is not the appropriate use for this mailing list. On Tue, Oct 19, 2021, 10:05 AM wrote: > > 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]: dis('(bool)') > 1 0 LOAD_NAME0 (bool) > 2 RETURN_VALUE > ___ > 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: rsokla...@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: dtype=(bool) vs dtype=bool
On Tue, Oct 19, 2021 at 4:07 PM wrote: > > You could use `dis.dis` to compare the two expressions and see that they > compile to the same bytecode. > > Do you mean the following: > Indeed, that is exactly what I meant. You don't even need the numpy import for that. Since `bool` and `(bool)` are compiled to the same bytecode, numpy isn't even aware that you put parentheses around `bool` in your code. > 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]: dis('(bool)') > 1 0 LOAD_NAME0 (bool) > 2 RETURN_VALUE > ___ > 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: deak.and...@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: dtype=(bool) vs dtype=bool
On Tue, Oct 19, 2021 at 9:43 AM wrote: > > 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, > which is preferable? For a one-element tuple, add a comma: >>> bool >>> (bool) >>> (bool,) (,) ___ 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] NumPy Development Meeting Wednesday - Triage Focus
Hi all, Our bi-weekly triage-focused NumPy development meeting is Wednesday, October 20th at 16:30 UTC (9:30am Pacific Time). Everyone is invited to join in and edit the work-in-progress meeting topics and notes: https://hackmd.io/68i_JvOYQfy9ERiHgXMPvg I encourage everyone to notify us of issues or PRs that you feel should be prioritized, discussed, or reviewed. Best regards Sebastian signature.asc Description: This is a digitally signed message part ___ 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: dtype=(bool) vs dtype=bool
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...@mail-archive.com
[Numpy-discussion] Re: dtype=(bool) vs dtype=bool
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's just not idiomatic, so readers of your code will wonder why you wrote it that way and if you meant something else and will have trouble reading your code. -- Robert Kern ___ 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: dtype=(bool) vs dtype=bool
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's just not idiomatic, so readers of your code will wonder why you wrote it > that way and if you meant something else and will have trouble reading your > code. I use Emacs, and find that python-lsp-server will give the dtype=() as the completion result, see here [1] for more detailed discussion. [1] https://github.com/python-lsp/python-lsp-server/issues/98 HZ ___ 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: dtype=(bool) vs dtype=bool
On Tue, Oct 19, 2021 at 8:54 PM Hongyi Zhao wrote: > 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's just not idiomatic, so readers of your > code will wonder why you wrote it that way and if you meant something else > and will have trouble reading your code. > > I use Emacs, and find that python-lsp-server will give the dtype=() as > the completion result, see here [1] for more detailed discussion. > > [1] https://github.com/python-lsp/python-lsp-server/issues/98 Well, that's not helpful of python-lsp-server. Is it looking at our type annotations? The annotations for `dtype=` arguments are likely quite complicated because we accept so many different types here, but `()` is not a great completion. -- Robert Kern ___ 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