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
{{ message }}
Repository navigation
Commit 65d1afb
Browse filesBrowse the repository at this point in the historyBrowse files
docs(indexing): state that a key's type picks relative or absolute indexing
Make the one rule about indexing a LazyArray prominent: NumPy keys are
positions relative to the view, an `IndexDomain` key names absolute
coordinates of the view's domain, an `IndexTransform` key composes onto
it, no key type has two readings, and every view keeps its absolute
domain whichever key produced it. A guide section with a runnable
snippet carries the table and the pandas `ix` / TensorStore comparison;
the module docstring, README, and API page point at it.
Assisted-by: ClaudeCode:claude-fable-5-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copy file name to clipboardExpand all lines: packages/zarr-indexing/docs/guide/index.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,32 @@ literal domain, as a TensorStore view does: `source[10:20]` has domain
114
114
`[10, 20)`, and a further `[2:5]` on it has domain `[12, 15)`. A domain or
115
115
transform key addresses those literal coordinates directly.
116
116
117
+
### The key's type picks the frame {#the-keys-type-picks-the-frame}
118
+
119
+
**The type of a key decides whether it is relative or absolute.** This is the
120
+
one rule to remember about indexing a `LazyArray`:
121
+
122
+
| Key type | Read as | Example |
123
+
| --- | --- | --- |
124
+
| slice, integer, `...`, `None`, index array, mask |**Relative**: positions in the current view, NumPy-style |`view[2:5]`, `view[-1]`, `view.oindex[[3, 1]]`|
125
+
|`IndexDomain`|**Absolute**: coordinates of the view's domain, restricted to a box |`view[IndexDomain((12,), (15,))]`|
126
+
|`IndexTransform`|**Absolute**: composed onto the view; the key's domain becomes the new view's domain |`view[IndexTransform.identity(view.transform.domain)[12:15]]`|
127
+
128
+
No key type is valid in both readings, so a key never has two meanings. That is
129
+
the property pandas lost with value-based `ix` dispatch and removed in favor of
130
+
`loc` and `iloc`; TensorStore keeps it by giving each key type one fixed
131
+
reading, and so does this wrapper. The only difference from TensorStore is
132
+
which reading the NumPy key gets: absolute there, relative here.
133
+
134
+
Whichever key produced a view, **its domain is always absolute**:
135
+
`view.transform.domain` reports literal coordinates after `view[2:5]` exactly as
136
+
it does after `view[IndexDomain(...)]`. The relative reading exists only at the
137
+
moment a NumPy key is interpreted, so relative and absolute steps compose freely.
138
+
139
+
```python
140
+
--8<--"snippets/key_types.py:key-types"
141
+
```
142
+
117
143
### A transform points from the request to the source
118
144
119
145
An `IndexTransform` records how every coordinate in a request finds its source
0 commit comments