diff options
Diffstat (limited to 'gerber')
-rw-r--r-- | gerber/gerber_statements.py | 2 | ||||
-rw-r--r-- | gerber/tests/test_gerber_statements.py | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gerber/gerber_statements.py b/gerber/gerber_statements.py index a198bb9..fd1e629 100644 --- a/gerber/gerber_statements.py +++ b/gerber/gerber_statements.py @@ -293,7 +293,7 @@ class ADParamStmt(ParamStmt): self.d = d self.shape = shape if modifiers: - self.modifiers = [tuple([float(x) for x in m.split("X")]) for m in modifiers.split(",") if len(m)] + self.modifiers = [tuple([float(x) for x in m.split("X") if len(x)]) for m in modifiers.split(",") if len(m)] else: self.modifiers = [tuple()] diff --git a/gerber/tests/test_gerber_statements.py b/gerber/tests/test_gerber_statements.py index f3249b1..b5c20b1 100644 --- a/gerber/tests/test_gerber_statements.py +++ b/gerber/tests/test_gerber_statements.py @@ -635,6 +635,24 @@ def test_ADParamStmt_factory(): assert_equal(ad.d, 1) assert_equal(ad.shape, 'R') + stmt = {'param': 'AD', 'd': 1, 'shape': 'C', "modifiers": "1.42"} + ad = ADParamStmt.from_dict(stmt) + assert_equal(ad.d, 1) + assert_equal(ad.shape, 'C') + assert_equal(ad.modifiers, [(1.42,)]) + + stmt = {'param': 'AD', 'd': 1, 'shape': 'C', "modifiers": "1.42X"} + ad = ADParamStmt.from_dict(stmt) + assert_equal(ad.d, 1) + assert_equal(ad.shape, 'C') + assert_equal(ad.modifiers, [(1.42,)]) + + stmt = {'param': 'AD', 'd': 1, 'shape': 'R', "modifiers": "1.42X1.24"} + ad = ADParamStmt.from_dict(stmt) + assert_equal(ad.d, 1) + assert_equal(ad.shape, 'R') + assert_equal(ad.modifiers, [(1.42, 1.24)]) + def test_ADParamStmt_conversion(): stmt = {'param': 'AD', 'd': 0, 'shape': 'C', 'modifiers': '25.4X25.4,25.4X25.4'} ad = ADParamStmt.from_dict(stmt) |