'Internal helper for dealing with units associated units properties
when setting values on |UnitsSpec| properties.
When ``value`` is a dict, this function may mutate the value of the
associated units property.
Args:
obj (HasProps) : instance to update units spec property value for
value (obj) : new value to set for the property
Returns:
copy of ``value``, with \'units\' key and value removed when
applicable'

def _extract_units(self, obj, value):

    if isinstance(value, dict):
        if ('units' in value):
            value = copy(value)
        units = value.pop('units', None)
        if units:
            self.units_prop.__set__(obj, units)
    return value
