Norms

Norms module.

class finalfusion.norms.Norms(array: numpy.ndarray)[source]

Bases: numpy.ndarray, finalfusion.io.Chunk, collections.abc.Collection, typing.Generic

Norms Chunk.

Norms subclass numpy.ndarray, all typical numpy operations are available.

static __new__(cls, array: numpy.ndarray)[source]

Construct new Norms.

Parameters

array (numpy.ndarray) – Norms array.

Returns

norms – The norms.

Return type

Norms

Raises

AssertionError – If array is not a 1-d array of float32 values.

static chunk_identifier()finalfusion.io.ChunkIdentifier[source]

Get the ChunkIdentifier for this Chunk.

Returns

chunk_identifier

Return type

ChunkIdentifier

static read_chunk(file: BinaryIO)finalfusion.norms.Norms[source]

Read the Chunk and return it.

The file must be positioned before the contents of the Chunk but after its header.

Parameters

file (BinaryIO) – a finalfusion file containing the given Chunk

Returns

chunk – The chunk read from the file.

Return type

Chunk

write_chunk(file: BinaryIO)[source]

Write the Chunk to a file.

Parameters

file (BinaryIO) – Output file for the Chunk

finalfusion.norms.load_norms(file: Union[str, bytes, int, os.PathLike])[source]

Load Norms from a finalfusion file.

Loads the first Norms chunk from a finalfusion file.

Parameters

file (str, bytes, int, PathLike) – Path to finalfusion file containing a Norms chunk.

Returns

norms – First finalfusion Norms in the file.

Return type

Norms

Raises

ValueError – If the file did not contain norms.