eradiate.converters

eradiate.converters.auto_or(wrapped_converter)[source]

A converter that allows an attribute to be set to AUTO.

Parameters:

wrapped_converter (callable()) – The converter that is used for non-AUTO values.

Returns:

callable()

eradiate.converters.convert_absdb(value)[source]

Attempt conversion of a value to an absorption database.

Parameters:

value – The value for which conversion is attempted.

Returns:

MonoAbsorptionDatabase or CKDAbsorptionDatabase

Notes

Conversion rules are as follows:

  • If value is a string, try converting using the factory’s create() method. Do not raise if this fails.

  • If value is a string or a path, try converting using the from_directory() constructor after passing through the file resolver. The returned type is consistent with the active mode.

  • If value is a dict, try converting using the from_dict() constructor. The returned type is consistent with the active mode.

  • Otherwise, do not convert.

eradiate.converters.convert_thermoprops(value)[source]

Converter for atmosphere thermophysical properties specifications.

eradiate.converters.on_quantity(wrapped_converter)[source]

Apply a converter to the magnitude of a pint.Quantity.

Parameters:

wrapped_converter (callable()) – The converter which will be applied to the magnitude of a pint.Quantity.

Returns:

callable()

eradiate.converters.passthrough(predicate)[source]

Pass through values for which predicate returns True; otherwise, apply wrapped converter.

eradiate.converters.passthrough_type(types)[source]

Pass through values of a specified type; otherwise, apply wrapped converter.

See also

passthrough()

eradiate.converters.resolve_keyword(path_forming_func)[source]

Attempt resolving a keyword into a path constructed from a keyword by the path_forming_func parameter.

If the generated path points to a file, the path is returned; otherwise, value is returned without modification.

Parameters:

path_forming_func (callable()) – A callable with signature f(x: str) -> Path that constructs relative or absolute paths from keywords. Relative paths are then resolved by the file resolver.

eradiate.converters.resolve_path(value)[source]

Resolve a file path with the file resolver. The current working directory is included in the path lookup.

eradiate.converters.to_mi_scalar_transform(value)[source]

Convert an array-like value to a mitsuba.ScalarTransform4f. If value is a Numpy array, it is used to initialize a mitsuba.ScalarTransform4f without copy; if it is a list, a Numpy array is first created from it. Otherwise, value is forwarded without change.