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.

On Tue, Jun 4, 2024 at 3:12 PM Rakshit Singh <rakshitsingh421@gmail.com> wrote:
`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

On Tue, Jun 4, 2024 at 3:12 PM Rakshit Singh <rakshitsingh421@gmail.com> wrote:
`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