code: def validate_units(self, value):
          
          self.validate_quantity(value)
          self.units_type = inspect.stack()[1][3].split('_')[-1]
          assert self.units_type, ("`validate_units` should not be called "
                                   "directly. It should be called by a "
                                   "_validate_type_* methods that sets "
                                   "`units_type`")
          units = getattr(pq, self.units_map[self.units_type])
          if not value.simplified.units == units:
              self._error('%s' % value,
                          "Must have dimensions of %s." % self.units_type)
          return True
docs: Validate units, assuming that it was called by _validate_type_*.