unit_and_type_from_string function

(Shortest import: from brian2.equations.equations import unit_and_type_from_string)

brian2.equations.equations.unit_and_type_from_string(unit_string)[source]

Returns the unit that results from evaluating a string like “siemens / metre ** 2”, allowing for the special string “1” to signify dimensionless units, the string “boolean” for a boolean and “integer” for an integer variable.

Parameters:

unit_string : str

The string that should evaluate to a unit

Returns:

u, type : (Unit, {FLOAT, INTEGER or BOOL})

The resulting unit and the type of the variable.

Raises

ValueError
If the string cannot be evaluated to a unit.