sequince.utils.copying

sequince.utils.copying#

Functions#

array_safe_copy(value)

Recursively copy a value while preserving array backends.

Module Contents#

sequince.utils.copying.array_safe_copy(value)[source]#

Recursively copy a value while preserving array backends.

Array leaves are copied using sequince.array_api.copy(). This avoids calling copy.deepcopy() on backend arrays, which is unsupported for some arrays such as non-leaf PyTorch tensors. Mappings, lists, and tuples are copied recursively; other values use copy.deepcopy().

Parameters:

value (Any) – The value to copy.

Returns:

An independent copy of value where supported by its array backend.

Return type:

Any