numtraits.py
def identify_unit_framework(target_unit):
    """
    Identify whether the user is requesting unit validation against
    astropy.units, pint, or quantities.
    """

    if HAS_ASTROPY:

        from astropy.units import UnitBase

        if isinstance(target_unit, UnitBase):

            return ASTROPY

    if HAS_PINT:

        from pint.unit import UnitsContainer

        if hasattr(target_unit, 'dimensionality') and isinstance(target_unit.dimensionality, UnitsContainer):

            return PINT

    if HAS_QUANTITIES:

        from quantities.unitquantity import IrreducibleUnit
        from quantities import Quantity

        if isinstance(target_unit, IrreducibleUnit) or isinstance(target_unit, Quantity):

            return QUANTITIES

    raise TraitError("Could not identify unit framework for target unit of type {0}".format(type(target_unit).__name__))
def identify_unit_framework(target_unit):
    """
    Identify whether the user is requesting unit validation against
    astropy.units, pint, or quantities.
    """

    if HAS_ASTROPY:

        from astropy.units import UnitBase

        if isinstance(target_unit, UnitBase):

            return ASTROPY

    if HAS_PINT:

        from pint.unit import UnitsContainer

        if hasattr(target_unit, 'dimensionality') and isinstance(target_unit.dimensionality, UnitsContainer):

            return PINT

    if HAS_QUANTITIES:

        from quantities.unitquantity import IrreducibleUnit
        from quantities import Quantity

        if isinstance(target_unit, IrreducibleUnit) or isinstance(target_unit, Quantity):

            return QUANTITIES

    raise TraitError("Could not identify unit framework for target unit of type {0}".format(type(target_unit).__name__))
Identify whether the user is requesting unit validation against
    astropy.units, pint, or quantities.