Skip to content

refactor!: Rename the decoded result types to the Tensor family - #172

Merged
kylebarron merged 2 commits into
mainfrom
kyle/rename-tensor-types
Aug 10, 2026
Merged

refactor!: Rename the decoded result types to the Tensor family#172
kylebarron merged 2 commits into
mainfrom
kyle/rename-tensor-types

Conversation

@kylebarron

@kylebarron kylebarron commented Aug 10, 2026

Copy link
Copy Markdown
Member

@d-v-b and I got on a call and decided on some names, as we wrote down here.

In particular, our current DecodedArray becomes Tensor, a type alias that is a union of fixed and variable-length in-memory n-d arrays.

In the future, I would like to explore merging FixedLengthTensor and OptionalFixedLengthTensor into a single class. But that would be a bit messy because the __array__ would sometimes convert to a plain array and other times convert to a masked array.


Written by Claude

Supersedes #136. That PR renamed the DecodedArray alias to ArrayData; this takes a different direction, and branches fresh off main instead (#136 had gone stale against #145#150 and #160#168).

A read returns a Tensor. The four concrete classes are named after the two axes that actually decide the layout: fixed- vs variable-length, and optional (masked) vs not.

Before After
Tensor (class) FixedLengthTensor
VariableArray VariableLengthTensor
MaskedTensor OptionalFixedLengthTensor
MaskedVariableArray OptionalVariableLengthTensor
DecodedArray (alias) Tensor
Tensor: TypeAlias = (
    FixedLengthTensor
    | VariableLengthTensor
    | OptionalFixedLengthTensor
    | OptionalVariableLengthTensor
)

Rust side

  • The Py-prefixed wrappers take the matching names.
  • The internal enum becomes PyTensor (it implements IntoPyObject, so it takes the Py prefix), with variants that mirror the ArrayBytes layouts that produce them: Fixed, Variable, OptionalFixed, OptionalVariable.
  • src/data/tensor.rs becomes src/data/fixed.rs, to pair with variable.rs.
  • repr::decoded_array_repr becomes repr::tensor_repr.
  • PyTensorBuffer keeps its name. It is an internal buffer-protocol helper and is not exported to Python.

Scope

Rename only. No behavior changes.

Follow-up

We want to prototype collapsing the four classes into two, with nullability carried as an optional mask on FixedLengthTensor / VariableLengthTensor rather than as separate Optional* classes. That is a separate PR; this one lands the naming first. The Optional names may get another look then.

Verification

  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • cargo test --all-features — 28 passed
  • nightly cargo fmt --check (with the CI config) — clean
  • pytest — 325 passed, 1 xfailed
  • ruff check / ruff format --check — clean
  • pydoclint on the .pyi stubs — no violations
  • mkdocs build --strict — clean

🤖 Generated with Claude Code

Name the four concrete result classes after the two axes that actually
decide their layout: fixed- vs variable-length, and optional (masked) vs
not. `Tensor` becomes the union that a read returns, which is the name
users see in every read signature.

- `Tensor` (class)         -> `FixedLengthTensor`
- `VariableArray`          -> `VariableLengthTensor`
- `MaskedTensor`           -> `OptionalFixedLengthTensor`
- `MaskedVariableArray`    -> `OptionalVariableLengthTensor`
- `DecodedArray` (alias)   -> `Tensor`

The Rust side follows: the `Py`-prefixed wrappers take the new names, the
internal enum becomes `Tensor` with variants that mirror the `ArrayBytes`
layouts (`Fixed`, `Variable`, `OptionalFixed`, `OptionalVariable`), and
`src/data/tensor.rs` becomes `src/data/fixed.rs` to pair with
`variable.rs`.

This is a rename only. No behavior changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
It is a Rust type that interfaces to and from Python (it implements
IntoPyObject), so it takes the Py prefix like the pyclass wrappers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kylebarron
kylebarron enabled auto-merge (squash) August 10, 2026 20:58
@kylebarron kylebarron self-assigned this Aug 10, 2026
@kylebarron kylebarron added this to the 0.1 milestone Aug 10, 2026
@kylebarron
kylebarron merged commit 1018965 into main Aug 10, 2026
15 checks passed
@kylebarron
kylebarron deleted the kyle/rename-tensor-types branch August 10, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant