File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,6 @@ namespace cadabra {
290290 return str.str ();
291291 }
292292
293-
294293 pybind11::object Ex_as_sympy (Ex_ptr ex)
295294 {
296295 // Generate a string which can be parsed by Sympy.
@@ -306,6 +305,11 @@ namespace cadabra {
306305 return ret;
307306 }
308307
308+ pybind11::object ExNode_as_sympy (const ExNode& exnode)
309+ {
310+ return Ex_as_sympy (exnode.ex );
311+ }
312+
309313 std::string Ex_as_sympy_string (Ex_ptr ex)
310314 {
311315 // Check to see if the expression is a scalar without dummy indices.
@@ -692,6 +696,7 @@ namespace cadabra {
692696 .def (" __setitem__" , &ExNode::setitem_iterator)
693697 .def (" _latex_" , &ExNode::_latex_)
694698 .def (" __str__" , &ExNode::__str__)
699+ .def (" _sympy_" , &ExNode_as_sympy)
695700 .def (" terms" , &ExNode::terms, " Return an ExNode iterator over all terms at the level of the current ExNode." )
696701 .def (" factors" , &ExNode::factors, " Return an ExNode iterator over all factors at the level of the current ExNode." )
697702 .def (" own_indices" , &ExNode::own_indices, " Return an ExNode iterator over all indices which are not inherited from child nodes." )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ def test01():
44 __cdbkernel__=create_scope()
55 ex:=3x + x**2 + a x**2 + b x;
66 q=SympyBridge(ex)
7- q.from_sympy( str(sympy.collect(q.to_sympy(), str( $x$) )) )
7+ q.from_sympy( str(sympy.collect(q.to_sympy(), $x$)) )
88 tst:= x**2 (a + 1) + x ( b + 3) - @(ex);
99 assert(tst==0)
1010 print("Test 01 passed")
You can’t perform that action at this time.
0 commit comments