ENH: Add more default arguments to various functions

Suggestion: Add the following default arguments to the following functions: - https://numpy.org/doc/stable/reference/generated/numpy.zeros.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.ones.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.empty.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.heaviside.html: x2=0.5 Feel free to add more examples.

I am unable to wrap my head around it. Why would we make a zero array which is empty. It can be done by a normal np.array On Wed, Jun 5, 2024, 12:31 AM Carlos Martin <cgmartin@andrew.cmu.edu> wrote:
Suggestion: Add the following default arguments to the following functions:
- https://numpy.org/doc/stable/reference/generated/numpy.zeros.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.ones.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.empty.html: shape=() - https://numpy.org/doc/stable/reference/generated/numpy.heaviside.html: x2=0.5
Feel free to add more examples. _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-leave@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: rakshitsingh421@gmail.com

On Tue, Jun 4, 2024 at 3:12 PM Rakshit Singh <rakshitsingh421@gmail.com> wrote:
I am unable to wrap my head around it.
Why would we make a zero array which is empty. It can be done by a normal np.array
`shape=()` would not be empty, but a scalar. `np.zeros(())` is the same as `np.array(0.0)`, so it is meaningful, at least. An empty array would be one where one of the axis dimensions is 0, which would make the difference between `zeros()`, `ones()`, and `empty()` meaningless if they all shared a default like that. Nonetheless, I don't think we want to make that a default. It's rarely desired, so it can be rarely requested in an explicit manner. For `np.heaviside()`, a default value was intentionally left unspecified because of the multiple conventions that people want. In the face of ambiguity, refuse the temptation to guess. I think we're comfortable with these choices at this time. -- Robert Kern
participants (3)
-
Carlos Martin
-
Rakshit Singh
-
Robert Kern