Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-26871: Support new ShiftMap simplifications #58

Merged
merged 3 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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