Skip to content

Commit

Permalink
add transform.Point
Browse files Browse the repository at this point in the history
This patch adds an implementation of `TransformItem` for points (`fromdims=0`).
This is seemingly useless, as the implementation doesn't add anything to its
base `Matrix`. However, the constructor is simpler than `Matrix` and `Matrix`
is currently used for points instances only. Replacing thoses instances with
`Point` is done in a follow-up patch.
  • Loading branch information
joostvanzwieten committed Dec 30, 2021
1 parent 88b209b commit 109b983
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nutils/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ def __init__(self, trans1, trans2):
def det(self):
return self.trans1.det * self.trans2.det

class Point(Matrix):

@types.apply_annotations
def __init__(self, offset:types.arraydata):
super().__init__(numpy.zeros((offset.shape[0],0)), offset)

## EVALUABLE TRANSFORM CHAIN

class EvaluableTransformChain(Evaluable):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class SimplexChild(TestInvertible):
def setUp(self):
super().setUp(trans=transform.SimplexChild(3, 1), linear=numpy.eye(3)/2, offset=[.5,0,0])

class Point(TestTransform):

def setUp(self):
super().setUp(trans=transform.Point(numpy.array([1.,2.,3.])), linear=numpy.zeros((3,0)), offset=[1.,2.,3.])

del TestTransform, TestInvertible, TestUpdim


Expand Down

0 comments on commit 109b983

Please sign in to comment.