Opened 7 years ago
Last modified 4 years ago
#302 new defect
Usability problem: Cannot access .shape member of numpy.ndarray as tuple
Reported by: | NNemec | Owned by: | somebody |
---|---|---|---|
Priority: | major | Milestone: | wishlist |
Component: | Parsing | Keywords: | numerics |
Cc: |
Description
On typed variable of type numpy.ndarray, the .shape member does not work
cdef numpy.ndarray var = numpy.zeros((3,))
print var.shape
gives the cython compiler error "Cannot convert 'numpy.npy_intp *' to Python object"
===================
Comment by dagss (mailing list):
This is mostly a question of semantics. shape is defined to be a C integer array for speed of var.shape[0]. How can we define a generic rule in Cython which makes both possible?
Should the behaviour of "var.shape" e.g. depend on the requested return value? This means overloading on return value which is a non-trivial language change, though perhaps appropriate here.
Thoughts welcome!
Change History (4)
comment:1 Changed 7 years ago by NNemec
- Component changed from Build System to Invalid
- Owner somebody deleted
comment:2 Changed 7 years ago by NNemec
- Keywords numerics added
comment:3 Changed 7 years ago by dagss
- Component changed from Invalid to Parsing
- Milestone set to wishlist
- Owner set to somebody
- Summary changed from .shape member of numpy.ndarray broken to Usability problem: Cannot access .shape member of numpy.ndarray as tuple
Not very satisfying, but of course the following will work: