sf.array(obj, dtype=None, device="host")
Build an array by quantizing obj. Always copies.
list | nested list | numpy array | SF scalar | SFArray
The data. A 0-d input returns a scalar.
dtype spec
default:"None"
Required unless
obj already holds SF values, in which case it defaults to theirs.str
default:"\"host\""
Where to place the result. Only sf16 is accepted on Atreides.
overflow in 2 of 100 element(s)), in catalogue order.
sf.asarray(obj, dtype=None, device="host")
Like sf.array, but returns obj itself when it is already an SFArray of that dtype on that device, and otherwise converts (a change of device uploads or downloads; a change of dtype casts).
sf.zeros(shape, dtype="sf16", device="host")
An array of zeros. No events.
sf.full(shape, value, dtype=None, device="host")
An array filled with value, quantized through the policy. dtype is required unless value is an SF scalar.
sf.ones(shape, dtype="sf16", device="host")
Filled with the literal 1, which no width can hold: raises SFOverflowError under the default policy and saturates to max under over="ignore". Use sf.full(shape, sf.info(dt).max, dt) for the largest value.
sf.from_codes(codes, dt, device="host")
An array from integer codes, validated in the width of dt. No quantization, no events.
sf.cast(x, dt) and arr.astype(dt)
Convert to another width. Widening is exact; narrowing re-quantizes through the policy (overflow and underflow with counts). Scalars and arrays.
The SFArray class
Attributes
numpy int64 array
The integer codes. Read-only.
numpy array
The sign-magnitude patterns.
type
The scalar class, e.g.
sf.sf16.tuple, int, int
As in NumPy.
str
"host" or a device name.SFStatus | None
The status of the heavy operation that produced this array;
None for host arrays.SFArray
Transpose (a view).
Methods
Indexing
a[idx] accepts everything NumPy accepts for reading: integers, slices, boolean and integer arrays, None. A scalar index returns an SF scalar; anything else returns an SFArray of the same dtype and device. Assignment is not supported: arrays are immutable.
Operators
The scalar operators, element by element, with NumPy broadcasting; comparisons return NumPy boolean arrays.@ is sf.matmul. See Elementwise operations.