question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quantity.__array_function__ follow up for Quantity

See original GitHub issue

EDIT: non-Quantity discussion of __array_function__ is in #8610

In the non-yet-merged but ready-for-review #8808, support for numpy’s __array_function__ is introduced. For a number of functions, a decision still needs to be made, mostly on whether to stick exactly to the numpy docstring or to make adjustments to parameter defaults that make the function more useful for Quantity

  • np.isclose, np.allclose: these were never all that useful since internally they calculate abs(a - b) < atol + rtol * abs(a) and atol is given as a small number, which is interpreted as dimensionless. For Quantity, we could either set it to 0 or assume the units of a, but in either case it would become inconsistent with the docstring that users actually see. (Decision: units of a - #9463)
  • np.broadcast_arrays and np.broadcast_to by default return plain arrays, needing subok=True to work for Quantity. We could change the default if a Quantity is present. Again, the possible issue is that the docstring will no longer be correct. (Decision: leave as is, since old code could cease working; #9463)

Furthermore, a few top-level functions need an actual implementation and/or better test cases:

  • np.histogram2d and np.histogramdd (see #8900)
  • np.piecewise (see #8884)
  • np.apply_along_axis and np.apply_over_axis (see #8900)
  • The setops functions such as np.unique might as well be supported (see #8900)

And finally we should also cover the numpy submodules that have routines not exported to the top level. In particular:

  • np.fft (#9464)
  • np.linalg (see issue #8622; PR #9494)
  • np.polynomial (has no functions that can be overridden).

EDIT: And it would probably be good to add tests for Quantity subclasses:

  • LogQuantity such as Magnitude
  • Angles such as Longitude

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bsipoczcommented, Oct 27, 2019

@mhvk - I’m removing the milestone from here as there are no more open PRs ready for 4.0 that are related.

0reactions
mhvkcommented, Jul 17, 2020

Since this is mostly done, closing - leftovers at #10575.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guidelines and examples of array formulas - Microsoft Support
An array formula (one that spans multiple cells) can do calculations on rows and columns of cells where you might otherwise need to...
Read more >
Array formulas and functions in Excel - examples and guidelines
The tutorial explains what is an array formula in Excel and provides examples of using Excel array functions and constants.
Read more >
sum up quantity in occured products inside an array of objects
Use reduce and in the accumulator array check if there exist a object with a name ... quantity: 10 }, ] let sum...
Read more >
Product of Array except itself - GeeksforGeeks
Given an array arr[] of n integers, construct a Product Array prod[] (of same size) such that prod[i] is equal to the product...
Read more >
Number of array elements - MATLAB numel - MathWorks
This MATLAB function returns the number of elements, n, in array A, equivalent to prod(size(A)).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found