Conversation
|
It kinda sounds like numpy is unhappy with whatever the 'indexer' function is returning? |
In the issue @rcaneill found out that, when using xarray datarrays, the |
gsw/geostrophy.py
Outdated
| order = 'C' # e.g., xarray DataArray doesn't have flags | ||
| for ind in indexer(SA.shape, axis, order=order): | ||
| igood = goodmask[ind] | ||
| igood = np.array(goodmask[ind]) |
There was a problem hiding this comment.
I think that using np.asarray would be more efficient, avoiding the copy which is unnecessary when the original function arguments are numpy arrays. I would also add a comment that this is needed to support xarray inputs for numpy < 1.23.
efiring
left a comment
There was a problem hiding this comment.
The reason I suggested asarray rather than asanyarray is that the point is to end up with a plain ndarray as the boolean indexing object. It's unlikely to make any difference in practice, since masked arrays will never end up here and DataArrays (and Pandas structures, for that matter) are not ndarray subclasses, at least in recent versions; but I think that asarray still has the advantage of clarifying the intent.
VScode completed to asany and I did not even noticed! I literally copied-and-pasted from your comment. Fixing it in a moment... |
@DocOtak I'm not sure if we can do something fancier here than just casting to an array. Do you have any suggestions?
Closes #95