Skip to content

Commit

Permalink
Merge pull request #58 from lsst/tickets/DM-26871
Browse files Browse the repository at this point in the history
DM-26871: Support new ShiftMap simplifications
  • Loading branch information
brianv0 committed Oct 7, 2020
2 parents 660595b + ca130be commit b780d76
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/astshim/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ inline bool escapes(int include = -1) {
return ret;
}

inline int ast_version(void) {
return astVersion;
}

} // namespace ast

#endif
1 change: 1 addition & 0 deletions python/astshim/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace {
PYBIND11_MODULE(base, mod) {
mod.def("assertOK", &assertOK, "rawObj1"_a = nullptr, "rawObj2"_a = nullptr);
mod.def("escapes", &escapes, "include"_a = -1);
mod.def("astVersion", &ast_version);

// Make a deep copy to avoid memory issues in Python
mod.def("arrayFromVector", [](std::vector<double> const& data, int nAxes) {
Expand Down
4 changes: 4 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def test_arrayFromVector(self):
with self.assertRaises(RuntimeError):
ast.arrayFromVector(vec=badDataVec, nAxes=nAxes)

def testVersion(self):
version = ast.astVersion()
self.assertGreaterEqual(version, 9001000)


if __name__ == "__main__":
unittest.main()
7 changes: 6 additions & 1 deletion tests/test_unitNormMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ def test_UnitNormMapSimplify(self):
winmap_notunitscale = ast.WinMap(
np.zeros(3), shift, np.ones(3), np.ones(3) * 2 + shift)

if ast.astVersion() >= 9001003:
expected_map = "ShiftMap" # ShiftMap is ShiftMap in 9.1.3
else:
expected_map = "WinMap" # ShiftMap gets simplified to WinMap

for map1, map2, pred_simplified_class_name in (
(unm1, unm2inv, "WinMap"), # ShiftMap gets simplified to WinMap
(unm1, unm2inv, expected_map),
(shiftmap, unm1, "UnitNormMap"),
(winmap_unitscale, unm1, "UnitNormMap"),
(winmap_notunitscale, unm1, "SeriesMap"),
Expand Down

0 comments on commit b780d76

Please sign in to comment.