Ones
Shippingarray_onesnumpy-style one-filled array source; shape rank picks Vector / Matrix / Tensor
Signature
Outputs
arrayArray— A one-filled array. Rank of the requested shape picks Vector / Matrix / Tensor.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
shape | text | 3, 3 | Target shape as comma-separated dimensions (numpy-style): '5' → a 1-D Vector, '3, 4' → a 2-D Matrix, '2, 3, 4' → an n-D Tensor. The rank picks the output type. |
unit | text | Optional physical unit. Applied only when the result is 1-D (a Vector); Matrix/Tensor results are dimensionless in the data model, so it is dropped there — re-attach downstream with Set Unit if needed. |
Description
Ones is numpy.ones: a pure source that emits an array filled with . It shares its executor with Full (fixing the fill value to ) and its parameter set with Zeros.
As with all array builders, the Shape rank selects the output variant (rank 1 → Vector, 2 → Matrix, ≥ 3 → Tensor), and the optional Unit is honoured only on a 1-D Vector result. A ones-vector is the multiplicative identity per element and a handy building block for constant masks, broadcasting scaffolds, or full-by-scaling ().
Mathematics
Examples
A ones column
Set Shape = 5. The output is a 5-element Vector of ones — e.g. the constant/bias column of a design matrix.
Scaling to a constant
Multiply a Shape = 100 ones vector by downstream to get a length-100 constant vector — equivalent to Full with value .
Applications
- The bias / intercept column of a regression design matrix.
- A uniform weighting or all-pass mask before element-wise multiplication.
- A broadcasting scaffold or a `full`-value via scaling a ones array.
Neat
Ones and Zeros register with the *same* param spec (`ZEROS_SPECS`); only the constant handed to `array_factory::filled` differs (1.0 vs 0.0).
Known issues
Unit is kept only on rank-1 (Vector) results; Matrix/Tensor drop it.
Element count capped at 100,000,000.