@classmethod
def fromstring(cls, string):
    """
        Parse the string into a quantity object.
        :param string:
        :return:
        """
    values = cls.parser_re.match(string).groupdict()
    try:
        magnitude = int(values['magnitude'])
    except ValueError:
        magnitude = float(values['magnitude'])
    units = cls.parse_units(values['units'])
    return cls(magnitude, units)
