Skip to content

Commit 47bfd12

Browse files
djkapnerfcollman
authored andcommitted
moved force_shear assignment before load from json in affine (#125)
1 parent 17df356 commit 47bfd12

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

renderapi/transform/leaf/affine_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def __init__(self, M00=1.0, M01=0.0, M10=0.0, M11=1.0, B0=0.0, B1=0.0,
7575
(will supersede all other parameters if not None)
7676
7777
"""
78+
self.force_shear = force_shear
7879
if json is not None:
7980
self.from_dict(json)
8081
else:
@@ -88,7 +89,6 @@ def __init__(self, M00=1.0, M01=0.0, M10=0.0, M11=1.0, B0=0.0, B1=0.0,
8889
self.labels = labels
8990
self.load_M()
9091
self.transformId = transformId
91-
self.force_shear = force_shear
9292

9393
@property
9494
def dataString(self):

test/test_transform.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,28 @@ def test_affine_fail():
103103
am.estimate(points_in, points_out[0:-2, :])
104104

105105

106+
def test_json_affine():
107+
M00 = .9
108+
M10 = -0.2
109+
M01 = 0.3
110+
M11 = .85
111+
B0 = 245.3
112+
B1 = -234.1
113+
am = renderapi.transform.AffineModel(M00=M00,
114+
M10=M10,
115+
M01=M01,
116+
M11=M11,
117+
B0=B0,
118+
B1=B1)
119+
120+
props = np.array(am.calc_properties())
121+
jam = am.to_dict()
122+
am2 = renderapi.transform.AffineModel(json=jam)
123+
jprops = np.array(am2.calc_properties())
124+
125+
assert(np.all(np.abs(props - jprops) < EPSILON))
126+
127+
106128
def test_affine_random():
107129
M00 = .9
108130
M10 = -0.2

0 commit comments

Comments
 (0)