in dimensionality.py I changed the __div__ function and got the correct behavior:
def __div__(self, other):
if not isinstance(other, Dimensionality):
scaling = self.scaling / float(other)
units = self.units dimensions = copy.deepcopy(self._dimensions)
else:
units = []
old = []
new = []
for su, ou, od, in zip(self._units, other._units, other._dimensions):
if (su and ou) and (su != ou): old.append(ou+'^%d'%od) new.append(su+'^%d'%od)
if ou and not su: units.append(ou) else: units.append(su)
old = '*'.join(old)
new = '*'.join(new) scaling, offset = _udunits.convert(old, new) dimensions = self._dimensions - other._dimensions compound = copy.deepcopy(self._compound)
for k, v in other._compound.items():
if k in self._compound: compound[k] -= v # changed this from += to -= else: compound[k] = -v # changed from = v to = -v
new = self.__class__(units, dimensions, **compound) new._scaling = scaling
new._offset = offset
return new
I think I fixed this:
in dimensionality.py I changed the __div__ function and got the correct behavior:
def __div__(self, other):
dimensions = copy.deepcopy( self._dimension s)
old. append( ou+'^%d' %od)
new. append( su+'^%d' %od)
else: units.append(su)
scaling, offset = _udunits. convert( old, new)
dimensions = self._dimensions - other._dimensions
compound = copy.deepcopy( self._compound) compound. items() :
compound[ k] -= v # changed this from += to -=
else:
compound[ k] = -v # changed from = v to = -v class__ (units, dimensions, **compound)
new._scaling = scaling
if not isinstance(other, Dimensionality):
scaling = self.scaling / float(other)
units = self.units
else:
units = []
old = []
new = []
for su, ou, od, in zip(self._units, other._units, other._dimensions):
if (su and ou) and (su != ou):
if ou and not su: units.append(ou)
old = '*'.join(old)
new = '*'.join(new)
for k, v in other._
if k in self._compound:
new = self.__
new._offset = offset
return new