You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the EigenPy user_type that's compiled and tested as part of eigenpy, the scalar types end up having numpy-array-like functions, which is weird.
For example,
import user_type
a = user_type.CustomDouble(1) # makes a scalar.
dir(a) # reveals a ton of functionality that I wouldn't expect for a scalar
For example, we get .flatten, .prod and .cumsum. This seems weird to me. Like, I don't think a Scalar should have these properties. Furthermore, many of these functions produce errors when called.
a.std() # error!
produces the following error message:
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
Cell In[12], line 1
----> 1 a.std()
File ~/env/b2/lib/python3.12/site-packages/numpy/_core/_methods.py:227, in _std(a, axis, dtype, out, ddof, keepdims, where, mean)
225 def _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
226 where=True, mean=None):
--> 227 ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
228 keepdims=keepdims, where=where, mean=mean)
230 if isinstance(ret, mu.ndarray):
231 ret = um.sqrt(ret, out=ret)
File ~/env/b2/lib/python3.12/site-packages/numpy/_core/_methods.py:173, in _var(a, axis, dtype, out, ddof, keepdims, where, mean)
168 arrmean = mean
169 else:
170 # Compute the mean.
171 # Note that if dtype is not of inexact type then arraymean will
172 # not be either.
--> 173 arrmean = umr_sum(arr, axis, dtype, keepdims=True, where=where)
174 # The shape of rcount has to match arrmean to not change the shape of
175 # out in broadcasting. Otherwise, it cannot be stored back to arrmean.
176 if rcount.ndim == 0:
177 # fast-path for default case when where is True
SystemError: <built-in method reduce of numpy.ufunc object at 0x10768ac40> returned NULL without setting an exception
What am I not understanding? Thanks for your help!
The text was updated successfully, but these errors were encountered:
much of the functions I added were me trying to get Python to crash in a specific way. I failed, which is a good thing, because it means that EigenPy doesn't have the bug I thought it does.
BUT. EigenPy *does* have two issues exercised in the unit tests for the custom type, issues stack-of-tasks#519 and stack-of-tasks#520 . Additionally, this code exercises issue stack-of-tasks#521 , where I try to compute vector norms in two different ways and fail.
Additionally, I bumped the C++ standard to C++14, since Boost 1.87 didn't work correctly with only C++11, and 1.87 is now distributed by homebrew (I develop on a Mac)
I have followed the same strategy as the example provided by NumPy here.
We can further investigate if we really need to inherit from the GenericType of NumPy
In the EigenPy
user_type
that's compiled and tested as part of eigenpy, the scalar types end up having numpy-array-like functions, which is weird.For example,
For example, we get
.flatten
,.prod
and.cumsum
. This seems weird to me. Like, I don't think a Scalar should have these properties. Furthermore, many of these functions produce errors when called.produces the following error message:
What am I not understanding? Thanks for your help!
The text was updated successfully, but these errors were encountered: