Skip to content

Commit c0d10e0

Browse files
committed
Fix Derivative import from sympy
1 parent 326dd82 commit c0d10e0

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

core/DisplaySympy.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,30 @@ void DisplaySympy::import(Ex& ex)
574574

575575
// Move child nodes of partial to the right place.
576576
if(*it->name=="\\partial") {
577-
// std::cerr << Ex(it) << std::endl;
578577
auto args = ex.begin(it);
579578
++args;
580579
while(args!=ex.end(it)) {
581580
auto nxt=args;
582581
++nxt;
583-
ex.move_before(ex.begin(it), args)->fl.parent_rel=str_node::p_sub;
582+
auto loc = ex.move_before(ex.begin(it), args);
583+
loc->fl.parent_rel=str_node::p_sub;
584+
585+
// If the argument is \comma{x}{n} expand this to 'n' arguments 'x'.
586+
// This is to handle Sympy returning 'Derivative(f(x), (x,2))' for the
587+
// 2nd order derivative.
588+
589+
if(*loc->name=="\\comma") {
590+
auto x=ex.begin(loc);
591+
auto n=x; ++n;
592+
if(! n->is_integer())
593+
throw RuntimeException("DisplaySympy::import received un-parseable Derivative expression.");
594+
int nn=to_long(*n->multiplier);
595+
for(int k=0; k<nn; ++k)
596+
ex.insert_subtree(loc, x);
597+
ex.erase(loc);
598+
}
599+
600+
584601
args=nxt;
585602
}
586603
// ex.flatten(comma);

web2/cadabra2/source/download.html

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ <h1>Download and install</h1>
1111
<h2>Binary packages</h2>
1212
<p>
1313
Packages for various Linux distributions and for Windows (beta!) are
14-
available for download here. They get updated on a semi-regular
15-
basis by yours truly.
14+
available for download here. Installation on macOS can be done
15+
through HomeBrew; see below. All these packages get updated on a
16+
semi-regular basis by yours truly; if you run into trouble, email me.
1617
</p>
1718
<p>
1819
Note that if your distribution has a <code>cadabra</code> package, this
@@ -101,15 +102,24 @@ <h2>Binary packages</h2>
101102
<div class="distronum"><a href="https://cadabra.science/packages/debian9">Debian Stretch 9</a></div>
102103
</div>
103104

104-
<!-- <div class="distrotype">
105+
<div class="distrotype">
105106
<img src="static/images/apple_logo.png"/>
106107
<div class="distronum">macOS</a></div>
107108
<div class="distrotxt">
108-
Cadabra is available via the Homebrew package manager; just type
109+
Cadabra is available via the Homebrew package manager. First
110+
make sure that you have MacTeX installed, either by installing
111+
it directly, or by using homebrew with
112+
<code>brew tap caskroom/cask</code>
113+
<code>brew cask install mactex</code>
114+
After that, you can install Cadabra using
115+
<code>brew tap kpeeters/repo</code>
109116
<code>brew install cadabra2</code>
110-
to take care of installation.
117+
Please not that this has not yet received a lot of testing; if
118+
you encounter problems, please
119+
email <a href="mailto:[email protected]">[email protected]</a>
120+
so they can be fixed and other people can benefit from it.
111121
</div>
112-
</div> -->
122+
</div>
113123

114124
<div class="distrotype">
115125
<img src="static/images/windows_logo.png"/>

0 commit comments

Comments
 (0)