From 109b98356a59f4370e569606591948e50e6f2c00 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Wed, 29 Dec 2021 22:42:28 +0100 Subject: [PATCH] add transform.Point 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. --- nutils/transform.py | 6 ++++++ tests/test_transform.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/nutils/transform.py b/nutils/transform.py index f2c6fb36b..e6e6e8873 100644 --- a/nutils/transform.py +++ b/nutils/transform.py @@ -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): diff --git a/tests/test_transform.py b/tests/test_transform.py index a4a2e4dc8..ee8b345c6 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -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