Comments (5)
We also have
>>> ndindex(False) == ndindex(0)
False
>>> False == 0
True
because
>>> ndindex(False).raw
array(False)
Not to mention this behavior
>>> ndindex([0, 1]) == np.array([0, 1])
True
>>> np.array([0, 1]) == ndindex([0, 1])
array([False, False])
which we can't do anything about. The best recommendation is to always convert any index object into an ndindex object, and manipulate that, and only use a raw index type (.raw
) at the end when you actually index an array.
from ndindex.
Fix at #93
from ndindex.
Not to mention this behavior
>>> ndindex([0, 1]) == np.array([0, 1]) True >>> np.array([0, 1]) == ndindex([0, 1]) array([False, False])
@asmeurer In your ideal world, which of the following would be the behavior for ndarray
vs NDIndex
equality?
A)
ndindex([0, 1]) == np.array([0, 1])
> array([True, True])
np.array([0, 1]) == ndindex([0, 1])
> array([True, True])
or B)
ndindex([0, 1]) == np.array([0, 1])
> True
np.array([0, 1]) == ndindex([0, 1])
> True
Both can be done. I'd argue for A), since that's now the expected behavior for "array-like" objects (as defined by numpy as of 1.17, I think?). B) is also doable, but it will have to have the side-effect that isinstance(ndindex([0, 1]), np.ndarray)
is True
from ndindex.
I would prefer it if I could make them both give True. == giving an array makes very basic things like checking if an index is in a list or dictionary difficult, because bool() fails on arrays. And anyway, an ndindex array index object is not an array-like. See https://quansight.github.io/ndindex/type-confusion.html#integerarray-and-booleanarray
from ndindex.
I opened a new issue for this over at #95. Let's continue the conversation there
from ndindex.
Related Issues (20)
- Make contributors section in readme
- Old links are broken HOT 4
- Testing mode for hypothesis explain phase
- Use CSS to layout the examples in the slices docs
- Method asflat HOT 2
- Run the doctests with pytest
- Logo HOT 2
- Support field name (string) indices
- Numba support
- Hypothesis not finding failing examples HOT 8
- Test that Tuple.reduce can't remove any indices HOT 2
- Reduce array indices to slices
- Some links in the docs have white background
- A way to serialize/deserialize ndindex HOT 15
- Math is broken in the slices document HOT 3
- ndarray(x) == NDIndex(x) and NDIndex(x) == ndarray(x) should return a consistent result HOT 7
- Consider opening a NEP to allow overrride of ndarray.__getitem__ dispatch HOT 4
- Move repo to Quansight-Labs
- Rename ndindex.py
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ndindex.