get_unit

function of dascore.units source

get_unit(
    value ,
)-> ‘Unit’

Convert a value to a pint unit.

Usually quantities, generated with get_quantity, are easy to work with.

Examples

import dascore as dc

# Create unit from string
unit = dc.get_unit('m/s')
assert str(unit) == 'm / s'

# Create unit from existing quantity
quantity = dc.get_quantity('10 Hz')
unit = dc.get_unit(quantity.units)
assert str(unit) == 'Hz'