--- id: ndindex version: "1.10.1" license: MIT license_treatment: permissive maintenance: aging --- # ndindex — A Python library for manipulating indices of ndarrays. License: permissive · Maintenance: aging · Downloads: 3.6M/mo ## What it is and what it does ndindex is a library for working with array indices as first-class objects. Instead of treating slices, integers, ellipses, and other index types as separate, incompatible objects, ndindex wraps them in a uniform API so you can inspect, transform, and reason about them programmatically. It guarantees that all transformations match actual array indexing semantics—meaning if you reduce or manipulate an index through ndindex, the result will behave identically to real array behavior. The library is useful when you need to reason about array shapes and indices without materializing arrays, optimize index expressions, or verify that an index operation would succeed before executing it. It handles the full range of indexing: simple slices, negative indices, steps, ellipses, boolean masks, integer arrays, and nested tuples. For operations where array shape is known, ndindex can reduce complex indices to simpler equivalent forms. Use it for: - Canonicalize and simplify slice objects to their minimal equivalent form for a given array shape - Compute the output shape of an array after indexing without materializing the array itself - Check whether an index operation would produce an empty result before executing it - Validate and transform user-provided indices in array-processing libraries or frameworks - Implement index-aware optimizations in array computation engines ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. ndindex provides a uniform API for representing and manipulating NumPy array indices—slices, integers, ellipses, None, arrays, and tuples—with semantics guaranteed to match NumPy's behavior. Yes, if you work with array indexing logic in libraries, frameworks, or tools that need to reason about indices without executing them. The library is well-maintained within its scope, has no dependencies, and carries no security vulnerabilities. However, the aging maintenance status (268 days since last release) means you should verify active support if you depend on frequent updates or encounter edge cases. ## Install pip install ndindex uv add ndindex poetry add ndindex ## Installing ndindex Before you install: Medium install friction due to platform-specific wheels across multiple Python versions and architectures, but no runtime dependencies. Last release was 268 days ago; maintenance status is aging. License in practice: MIT license is permissive; you may use, modify, and distribute ndindex freely in commercial and private projects with minimal restrictions. Quickstart: from ndindex import Slice, Tuple # Canonicalize a slice over a shape result = Slice(-2, 10, 3).reduce(5) print(result) # Slice(3, 4, 1) # Compute resulting shape after indexing shape = Tuple(0, slice(0, 10)).newshape((10, 20)) print(shape) # (10,) Requires Python >= 3.9 Verify before relying: - Whether the library handles all edge cases in array indexing semantics beyond the documented scope - Performance characteristics when working with complex multi-dimensional indices ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: medium - Maintenance: aging - Downloads: 3.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags numpy array indexing manipulation, slice canonicalization, index transformation library, ndarray index semantics, array slicing utilities, numpy-indexing, array-manipulation [View on SkillFed](https://skillfed.io/packages/ndindex) · [View on PyPI](https://pypi.org/project/ndindex/)