Skip to content

Options

Library-wide behaviour switches (e.g. the coordinate/unit backend), set globally, scoped with a with block, or applied as a decorator.

fiery.xtensor.set_options

set_options(**options: Any)

Set one or more options, globally or for a with block.

Options:

  • combine_axes -- how axis descriptors (type/orientation/any custom field) combine when two operands meet in a name-aware op (broadcast, alignment, cat/stack/matmul/einsum/…). Either a single policy applied to every field, or a {field: policy} dict for per-field control (with "*" as the default for unlisted fields). Policies:

    • "drop_conflicts" (default) -- keep a field the operands agree on, drop it where they conflict;
    • "strict" (alias "raise") -- raise ValueError on a conflict;
    • "override" -- keep the left operand's value;
    • "drop" -- always drop the field.
  • unit_backend -- the physical-unit engine for data units: None (default) means units are inert opaque strings; "pint" enables validation/algebra/conversion (and is rejected at set time if pint is not installed).

  • unit_policy -- what a dimensionally invalid/ambiguous step does: "drop" (default) silently drops the unit, "strict" raises.
  • interp_bound -- the default boundary condition for interp, i.e. how an out-of-range query is resolved. "replicate" (default) clamps to the edge value; other names ("wrap", "reflect", "mirror", "zero", …) mirror fiery.interpol. A per-call bound= overrides it.
  • interp_extrapolate -- whether interp extrapolates past the ends (True (default); with interp_bound="replicate" this is the clamp). A per-call extrapolate= overrides it.

Any option can be set permanently or only for a with block:

set_options(combine_axes="strict")                    # until changed
with set_options(combine_axes="strict"):              # for this block
    ...
# per-field: drop everything, but a clashing `type` is an error
with set_options(combine_axes={"*": "drop", "type": "raise"}):
    ...