forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.py
More file actions
42 lines (30 loc) · 1.09 KB
/
transform.py
File metadata and controls
42 lines (30 loc) · 1.09 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ['BaseTransform', 'CompositeTransform']
class BaseTransform:
"""
A transformation object.
This is used to construct transformations such as scaling, stretching, and
so on.
"""
def __add__(self, other):
return CompositeTransform(other, self)
class CompositeTransform(BaseTransform):
"""
A combination of two transforms.
Parameters
----------
transform_1 : :class:`astropy.visualization.BaseTransform`
The first transform to apply.
transform_2 : :class:`astropy.visualization.BaseTransform`
The second transform to apply.
"""
def __init__(self, transform_1, transform_2):
super().__init__()
self.transform_1 = transform_1
self.transform_2 = transform_2
def __call__(self, values, clip=True):
return self.transform_2(self.transform_1(values, clip=clip), clip=clip)
@property
def inverse(self):
return CompositeTransform(self.transform_2.inverse,
self.transform_1.inverse)