optiwindnet.identityΒΆ

Identities of OptiWindNet data: coordinates, code, link sets, topologies.

Two vocabularies live here, and the distinction is deliberate. The fingerprint_*() functions produce SHA-256 identities of records that are persisted: a coordinate fingerprint is the primary key of a NodeSet row, so its bytes are a stored-data contract that must not drift. The *_id() functions produce non-cryptographic xxh3 ids for objects held in memory – an available-links set, a topology – which nothing reads back from disk and which are free to change with the code that makes them.

Module ContentsΒΆ

optiwindnet.identity.fingerprint_coordinates(VertexC: numpy.ndarray) → tuple[bytes, bytes][source]ΒΆ

Return the SHA-256 digest and canonical .npy bytes of VertexC.

Arrays are normalized to C order before serialization so numerically equal C- and Fortran-contiguous inputs have the same digest. Version 3 of NumPy’s .npy format is used to match persisted NodeSet entries.

optiwindnet.identity.fingerprint_function(function: types.FunctionType) → dict[str, bytes | str][source]ΒΆ

Return the bytecode digest, source filename, and name of function.

The digest intentionally covers only code.co_code to preserve existing database identities. It is not a complete semantic fingerprint: changes to constants, defaults, globals, or closure values may leave the digest unchanged.

optiwindnet.identity.linkset_id(A: networkx.Graph) → bytes[source]ΒΆ

Return the 128-bit xxh3 id of A’s canonical available-links set.

The id covers R, T and the canonical terminal-link array, which is everything that fixes the meaning of a link-bit position and the total bit count. Geometry is deliberately left out: two sites whose meshes have the same combinatorics share an id, and coordinates are identified by fingerprint_coordinates() instead.

optiwindnet.identity.topology_id(linkbits: bitarray.frozenbitarray) → bytes[source]ΒΆ

Return the 128-bit xxh3 id of a topology’s canonical linkbits.

The id covers the length of the available-links set together with the packed bits, so vectors that differ only in the zero padding of the last byte cannot collide. It identifies the set of active links alone: topologies with equal ids may still differ in load assignment or in routing.