natcap.invest.spec_utils

natcap.invest.spec_utils.format_unit(unit)

Represent a pint Unit as user-friendly unicode text.

This attempts to follow the style guidelines from the NIST Guide to the SI (https://www.nist.gov/pml/special-publication-811): - Use standard symbols rather than spelling out - Use ‘/’ to represent division - Use the center dot ‘ · ‘ to represent multiplication - Combine denominators into one, surrounded by parentheses

Parameters

unit (pint.Unit) – the unit to format

Raises

TypeError if unit is not an instance of pint.Unit.

Returns

String describing the unit.

natcap.invest.spec_utils.serialize_args_spec(spec)

Serialize an ARGS_SPEC dict to a JSON string.

Parameters

spec (dict) – An invest model’s ARGS_SPEC.

Raises
  • TypeError if any object type within the spec is not handled by

  • json.dumps or by the fallback serializer.

Returns

JSON String