File: mixin.py

package info (click to toggle)
python-astropy 1.3-8~bpo8%2B2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 44,292 kB
  • sloc: ansic: 160,360; python: 137,322; sh: 11,493; lex: 7,638; yacc: 4,956; xml: 1,796; makefile: 474; cpp: 364
file content (25 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from ..core import IrreducibleUnit, Unit


class FunctionMixin(object):
    """Mixin class that makes UnitBase subclasses callable.

    Provides a __call__ method that passes on arguments to a FunctionUnit.
    Instances of this class should define ``_function_unit_class`` pointing
    to the relevant class.

    See units.py and logarithmic.py for usage.
    """
    def __call__(self, unit=None):
        return self._function_unit_class(physical_unit=unit,
                                         function_unit=self)


class IrreducibleFunctionUnit(FunctionMixin, IrreducibleUnit):
    pass


class RegularFunctionUnit(FunctionMixin, Unit):
    pass