numpy.sum() returns inconsistent types
See original GitHub issueWith 0D FieldArray inputs, numpy.sum() returns a FieldArray, as expected:
import galois
import numpy
>>> f = galois.Field(2**64-59)
>>> a = f.Random()
>>> b = f.Random()
>>> numpy.sum([a, b], axis=0)
GF(5802771140473745109, order=18446744073709551557)
However, with 1D FieldArray inputs, numpy.sum() returns a numpy.ndarray:
>>> a = f.Random((2,))
>>> b = f.Random((2,))
>>> numpy.sum([a, b], axis=0)
array([27182153923255896342, 13808647080647953998], dtype=object)
I’ve verified that numpy.add.reduce() works the same, and sum() doesn’t have a subok
argument. Is this expected behavior?
Cheers, Tim
Issue Analytics
- State:
- Created 9 months ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Numpy inconsistent results with Pandas and missing values
Calling np.sum on a pandas Series delegates to Series.sum , which ignores NaNs when computing the sum (BY DEFAULT). data['a'].sum() # 12.0 ...
Read more >numpy.sum is incompatible with any of scipy.sparse matrixes
The scipy.sparse sum method could grow a dtype argument. In case it's difficult to implement the accumulator types, it could fail with ...
Read more >numpy.sum — NumPy v1.24 Manual
The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by...
Read more >Writing custom array containers — NumPy v1.25.dev0 Manual
Notice that the return type is a standard numpy.ndarray . >>> type(np.multiply(arr, 2)) <class 'numpy.ndarray'>. How can we pass our custom array type...
Read more >Writing custom array containers — NumPy v1.24 Manual
Notice that the return type is a standard numpy.ndarray . >>> type(np.multiply(arr, 2)) <class 'numpy.ndarray'>. How can we pass our custom array type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yup, appreciate your help.
Cheers, Tim
No problem. Is this issue good to close?