`Tensor` v1: contiguous N-D arrays
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by locating the existing Matrix implementation, its arithmetic and aggregate tests, and the Cown/sub-interpreter round-trip coverage. Resolve the listed rank, aggregate, and constructor questions before implementing the Tensor scope; done means contiguous arbitrary-rank double storage, the specified arithmetic and aggregates, shape validation, and the requested Cown behavior without changing Matrix.
Written by the indexing model from the issue text.
Description
Problem
bocpy ships a dense 2-D Matrix and nothing else. Anything users do that is naturally N-dimensional — image stacks, batched feature tensors, multi-channel audio, simulation grids, anything with a leading batch axis — has to be flattened by hand or coordinated as a Python list of Matrix objects. Both lose the in-place, cown-friendly arithmetic that makes Matrix worth using in the first place.
Desired functionality
A first-class Tensor Python type with arbitrary-rank contiguous storage of doubles, the same arithmetic surface as Matrix (elementwise binary, elementwise unary, scalar binary, aggregates with optional axis=), and the same cown / sub-interpreter round-trip story. Users should be able to put a Tensor inside a Cown, mutate it from a behavior, and observe the change in the next behavior, exactly as they do today with Matrix.
Constraints
- Contiguous storage only — no strides, no views, no transpose-without-copy.
- Same-shape binary ops only; mismatched shapes raise immediately.
- No matmul on
Tensor. Rank-2 linear algebra stays onMatrix. Matrixis untouched by this work.
Out of scope
Broadcasting, full Matrix-parity indexing, Matrix/Tensor unification, views, reshape, fancy indexing.
Open questions
- Are rank-0 tensors a valid shape?
- Does a rank-reducing aggregate on a rank-
kTensor always return a rank-k-1Tensor, including the rank-1 → rank-0 case? - Constructor shape: a single positional shape tuple, named factory methods, or both?
- Dominant language
- Python
- Stars
- 184
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/bocpy
-
Difficulty 3/5 1-2 days Newbie friendliness 63/100
-
design
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
design
Difficulty 5/5 Over a week Newbie friendliness 28/100
-
maths
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
maths
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100