Skip to content

Commit 7941e33

Browse files
committed
Added partial boolean flag to zoom.
1 parent 1b48cd3 commit 7941e33

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

core/algorithms/zoom.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
using namespace cadabra;
88

9-
zoom::zoom(const Kernel& k, Ex& e, Ex& rules_)
10-
: Algorithm(k, e), rules(rules_)
9+
zoom::zoom(const Kernel& k, Ex& e, Ex& rules_, bool partial)
10+
: Algorithm(k, e), rules(rules_), partial(partial)
1111
{
1212
// Convert rules into a list (if it isn't already)
1313
rules = cadabra::make_list(rules);
@@ -66,7 +66,7 @@ Algorithm::result_t zoom::apply(iterator& it)
6666
// Wrap all things which we want to remove from view in an
6767
// \ldots node.
6868

69-
substitute subs(kernel, tr, rules);
69+
substitute subs(kernel, tr, rules, partial);
7070
sibling_iterator sib=tr.begin(it);
7171
bool hiding=false;
7272
sibling_iterator current_ldots=tr.end(it);

core/algorithms/zoom.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace cadabra {
77

88
class zoom : public Algorithm {
99
public:
10-
zoom(const Kernel& k, Ex& e, Ex& r);
10+
zoom(const Kernel& k, Ex& e, Ex& r, bool partial = true);
1111

1212
virtual bool can_apply(iterator) override;
1313
virtual result_t apply(iterator&) override;
@@ -17,6 +17,8 @@ namespace cadabra {
1717

1818
std::vector<sibling_iterator> to_erase;
1919
std::vector<Ex::path_t> to_keep;
20+
21+
bool partial;
2022
};
2123

2224
}

core/pythoncdb/py_algorithms.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace cadabra {
133133
def_algo<substitute, Ex, bool>(m, "substitute", true, false, 0, py::arg("rules"), py::arg("partial") = true);
134134
def_algo<take_match, Ex>(m, "take_match", true, false, 0, py::arg("rules"));
135135
def_algo<replace_match>(m, "replace_match", false, false, 0);
136-
def_algo<zoom, Ex>(m, "zoom", true, false, 0, py::arg("rules"));
136+
def_algo<zoom, Ex, bool>(m, "zoom", true, false, 0, py::arg("rules"), py::arg("partial") = true);
137137
def_algo_preorder<unzoom>(m, "unzoom", true, false, 0);
138138
def_algo<untrace>(m, "untrace", true, false, 0);
139139
def_algo<rewrite_indices, Ex, Ex>(m, "rewrite_indices", true, false, 0, py::arg("preferred"), py::arg("converters"));

0 commit comments

Comments
 (0)