bw2parameters.interpreter#
Classes#
Module Contents#
- class bw2parameters.interpreter.Interpreter(*args, **kwargs)[source]#
Bases:
asteval.Interpreter
- class bw2parameters.interpreter.PintInterpreter(*args, units=None, **kwargs)[source]#
Bases:
Interpreter
- _raise_proper_pint_exception()[source]#
Make sure that pint exceptions are correctly raised during evaluation
- add_symbols(symbols)[source]#
Adds symbols to symtable while making sure that pint Quantities are from same registry as self.ureg (otherwise self.eval will fail).
- get_pint_symbols(text, known_symbols=None, ignore_symtable=True)[source]#
Parses an expression and returns all symbols which can be interpreted as pint units.
- get_unknown_symbols(text, known_symbols=None, ignore_symtable=False, include_pint_units=False, no_pint_units=None)[source]#
Parses the given expression and returns a list of symbols, which are neither contained in the symtable, nor in known_symbols, nor can be interpreted as pint units
- classmethod parameter_list_to_dict(param_list)[source]#
Takes a list of parameter objects and returns a dict where keys are the parameter names and values are the interpreted pint.Quantities (or float where no unit is defined).
- classmethod set_amount_and_unit(obj, quantity=None, to_unit=None)[source]#
Takes an arbitrary object and tries to set it’s amount and unit fields. amount field is the magnitude of the pint.Quantity after conversion to to_unit. If no to_unit is given, the quantity’s own unit will be used. If the input is not a pint.Quantity then obj[‘unit’] will be used. If no quantity is given, then obj[‘amount’] and obj[‘unit’] are used.