py21cmfast.wrapper.arrays

Module for dealing with arrays that are input/output to C functions.

Attributes

Classes

Array

A flexible array management class providing state tracking and initialization capabilities.

ArrayProxy

Exposes an OutputStruct's Array field as a plain numpy array.

CacheBackend

Abstract base class for cache backends.

H5Backend

Backend for caching arrays in a HDF5 file.

Functions

expose_arrays(→ type)

Class decorator exposing every private Array field as a plain numpy array.

Module Contents

py21cmfast.wrapper.arrays.expose_arrays(cls: type) → type[source]

Class decorator exposing every private Array field as a plain numpy array.

Must be applied outside attrs.define, so that it runs once attrs has finished building the class:

@expose_arrays
@attrs.define(slots=False, kw_only=True)
class InitialConditions(OutputStruct):
    _hires_density = _arrayfield()

Keeping the Array in the private field means attrs’ generated __repr__, eq and asdict continue to see it, so inspecting a purged struct still never touches the disk. The public name is purely this descriptor. attrs strips the leading underscore for __init__, so InitialConditions(hires_density=…) is unchanged.

Parameters:

cls (type)

Return type:

type

py21cmfast.wrapper.arrays.logger[source]