1# -*- coding: utf-8 -*-
2# Licensed under a 3-clause BSD style license - see LICENSE.rst
3from astropy.units.core import IrreducibleUnit, Unit
4
5
6class FunctionMixin:
7    """Mixin class that makes UnitBase subclasses callable.
8
9    Provides a __call__ method that passes on arguments to a FunctionUnit.
10    Instances of this class should define ``_function_unit_class`` pointing
11    to the relevant class.
12
13    See units.py and logarithmic.py for usage.
14    """
15    def __call__(self, unit=None):
16        return self._function_unit_class(physical_unit=unit,
17                                         function_unit=self)
18
19
20class IrreducibleFunctionUnit(FunctionMixin, IrreducibleUnit):
21    pass
22
23
24class RegularFunctionUnit(FunctionMixin, Unit):
25    pass
26