Planet SymPy
http://planet.sympy.org/
enPlanet SymPy - http://planet.sympy.org/https://asmeurer.github.io/blog/posts/github-reviews-gripes/GitHub Reviews GripesAaron Meurer (asmeurer)Thu, 06 Oct 2016 00:12:16 GMT
https://asmeurer.github.io/blog/posts/github-reviews-gripes/
<div><p><em>Update: I want to keep the original post intact, but I'll post any feature
updates that GitHub makes here as they are released.</em></p>
<ul>
<li><p><em>You can now <a href="https://github.com/blog/2265-dismissing-reviews-on-pull-requests">dismiss a review</a>.</em></p></li>
<li><p><em>You can
now
<a href="https://github.com/blog/2306-filter-pull-request-reviews-and-review-requests">filter the pull request list by review</a>.
The review status of a PR also appears in the pull request list (albeit in
very tiny and easy to miss text).</em></p></li>
</ul>
<hr />
<p>GitHub
<a href="https://github.com/blog/2256-a-whole-new-github-universe-announcing-new-tools-forums-and-features">recently</a> rolled
out a new feature on their pull requests called "Reviews". The feature is (in
theory), something that I've
been
<a href="https://groups.google.com/d/msg/sympy/KJwDwT_P6Lw/27ha6ipuBwAJ">asking for</a>.
However, it really falls short in a big way, and I wanted to write down my
gripes with it, in the hopes that it spurs someone at GitHub to fix it.</p>
<p>If you don't know, GitHub has had, for some time, a feature called "pull
requests" ("PRs"), which lets you quite nicely show the diff and commit
differences between two branches before merging them. People can comment on
pull requests, or on individual lines in the diff. Once an administrator feels
that the pull request is "ready", they can click a button and have the branch
automatically merged.</p>
<p>The concept seems super simple
in <a href="https://en.wikipedia.org/wiki/Hindsight_bias">retrospect</a>, but this
feature completely revolutionized open source software development. It really
is the bread and butter of GitHub. I would argue that this one single feature
has made GitHub the (<em>the</em>) primary hosting site for open source software.</p>
<p>Aside from being an awesome idea, GitHub's trademark with pull requests, along
with their other features, has been absolute simplicity in implementation.
GitHub Reviews marks, by my estimation, the first major feature released by
GitHub that completely and utterly lacks in this execution of simplicity.</p>
<p>Let's look at what Reviews is. When the feature first came out, I had a hard
time figuring out how it even worked (the
poor
<a href="https://twitter.com/asmeurer/status/776125249712717824">release date docs</a>
didn't help here either).</p>
<p>Basically, at the bottom of a pull request, you now see this</p>
<p><img src="https://asmeurer.github.io/blog/reviews1.png" width="788" /></p>
<p>Clicking the "Add your review" button takes you to the diff page (first gripe:
why does it move you to the diff page?), and opens this dialog</p>
<p><img src="https://asmeurer.github.io/blog/reviews2.png" width="1020" /></p>
<p>"OK", you might think, "this is simple enough. A review is just a special
comment box where I can approve or reject a pull request." (This is basically
the feature that I've been wanting, the ability to approve or reject pull
requests.) And if you thought that, you'd be wrong.</p>
<p>The simplest way I can describe a review, having played with it, is that it is
a distinct method of commenting on pull requests and on lines of diffs of pull
requests. Distinct, that is, from the methods that <strong>already exist</strong> in the
GitHub pull requests feature. That's right. There are now two ways to comment
on a pull request (or on a line in a pull request). There's the old way, which
involves typing text into the box at the bottom of the main pull request page
(or on a line, and then pressing "Add a single comment"), and the new way,
which involves clicking a special button at the top of the diff view (and the
diff view only) (or by clicking a line in the diff and
clicking "Start a review").</p>
<p>How do these two ways of the extremely simple task of commenting differ from
one another? Two ways. One, with the old way, when you comment on a PR (or
line), the comment is made immediately. It's saved instantly to the GitHub
database, and a notification email is sent to everyone subscribed to the PR.
With the new way, the comment is <strong>not</strong> made immediately. Instead, you start
a "review", which postpones all comments from being published until you scroll
to the top and press a button ("Review changes"). <strong>Did you forget to scroll
to the top and press that button? Oh well, your comments never got sent to
anyone.</strong></p>
<p>Now, I've been told by some people that delayed commenting is a feature that
they like. I can see how fewer total emails could be nice. <strong>But if you just
want a way to delay comments, why do you need distinct commenting UIs?</strong>
Couldn't the same thing be achieved via a user setting (I highly suspect that
any given person will either like or dislike delayed commenting universally)?
Or with a checkbox next to the comment button, like "delay notifications for
this comment"? You can probably guess by now which of the two commenting
systems I prefer. But guess what happens when I press the "Cmd-Enter" keyboard
shortcut that's been hard-wired into my brain to submit a comment? I'll give
you a hint: the
result
<a href="https://twitter.com/asmeurer/status/781949163562999808">does not make me happy</a>.</p>
<p>The second distinction between normal, old-fashioned commenting and the
new-fangled reviews system is that when you finalize a review, you can elect
to "approve" or "reject" the pull request. This approval or rejection gets set
as a special status on the pull request. This status, for me personally, is
the only feature here that I've been wanting. It turns out, however, that it's
completely broken, and useless.</p>
<p>Here's my problem. We have, at the time of
writing, <a href="https://github.com/sympy/sympy/pulls">382 open pull requests</a> in
SymPy. A lot of these are old, and need to be triaged. But the problem from my
point of view is the new ones. When I look through the list of pull requests,
I want to be able to know, at a glance, which ones are "reviewable". For me,
this means two things</p>
<ol>
<li><p>The tests pass.</p></li>
<li><p>No other reviewer (myself included) has already requested changes, which
still need to be made by the PR author.</p></li>
</ol>
<p>Point 1 is really easy to see. In the pull request list, there is a nice green
checkmark if Travis passed and a red X if it failed.</p>
<p><img src="https://asmeurer.github.io/blog/prlist.png" width="608" /></p>
<p>The second point is a disaster. Unfortunately, there's no simple way to do
this. You might suggest adding a special label, like "Needs changes", to pull
requests that have been reviewed. The problem with this is that the label
won't go away when the changes have been made. And to worsen things, people
who don't have push access (in the list above, only two PR authors have push
access, and one of them is me), cannot add or remove labels on pull requests.</p>
<p>Another thing
that
<a href="https://twitter.com/asmeurer/status/771393023389339649">has been suggested to me</a> is
an external "review" service that sets a status for a review. The problem with
this (aside from the fact that I couldn't find one that actually did the very
simple thing that I wanted), is that you now have to teach all your pull
request reviewers to use this service. You might as well forget about it.</p>
<p>Having a first-class way in GitHub for reviewers to say "I approve these
changes" or "I don't approve these changes" would be a huge boon, because then
everyone would use it.</p>
<p>So great right, this new Reviews feature is exactly what you want, you say.
You can now approve or reject pull requests.</p>
<p>Well no, because GitHub managed to overengineer this feature to the point of
making it useless. This completely simple feature. All they had to do was
extend the status UI and add a simple "I approve/I reject" button. If they did
that, it would have worked perfectly.</p>
<p>Here are the problems. First, the pull request list has no indication of
review status. Guess which pull requests in the above screenshot have reviews
(and which are positive and which are negative). You can't tell (for example,
the last one in the list has a negative review). If they were actually treated
like statuses, like the UI suggests that they would, you would at least see an
X on the ones that have negative reviews (positive reviews I'm much less
worried about; most people who review PRs have merge access, so if they like
the PR they can just merge it). I would suggest to GitHub to add, next to the
status checkbox, a picture of everyone who's made a review on the PR, with a
green checkmark or red X to indicate the type of review. Also, add buttons
(<strong>buttons</strong>, not just buried advanced search options) to filter by reviews.</p>
<p>OK, so that's a minor UI annoyance, but it gets worse. Next on the docket, <strong>you
can't review your own pull requests.</strong> It's not allowed for some reason.</p>
<p><img src="https://asmeurer.github.io/blog/reviews3.png" width="411" /></p>
<p>Now why would you want to review your own pull request, you might ask? Aren't
you always going to "approve" your own PR? Well, first off, no. There is such
a thing as
a <a href="http://ben.balter.com/2015/12/08/types-of-pull-requests/">WIP PR</a>. The
author setting a negative review on his own PR would be a great way to
indicate WIP status (especially given the way reviews work, see my next
gripe). Secondly, the "author" of a pull request is just the person who
clicked the "New pull request" button. That's not necessarily the only person
who has changes in the pull request. Thanks to the magic of how git works,
it's quite easy to have a pull request with commits from many people. Multiple
people pushing to a shared branch, with a matching pull request for discussion
(and easy viewing of new commits and diff) is a valid and useful workflow
(it's the only one I know of that works for writing collaborative prose). For
the <a href="https://github.com/sympy/sympy-paper">SymPy paper</a>, I wanted to use
GitHub Reviews to sign off on a common branch, but since I'm the one who
started the pull request, I couldn't do it.</p>
<p>Next gripe, and this, I want to stress, makes the whole feature completely
useless for my needs: <strong>reviews do not reset when new commits are pushed</strong>.
Now, I just outlined above two use-cases where you might want to do a review
that doesn't reset (marking WIP, and marking approval, although the second is
debatable), but both of those can easily be done by other means, like editing
the title of the PR, or old-fashioned commenting. The whole point of Reviews
(especially negative reviews), you'd think, would be to indicate to people
that the pull request, as it currently stands, needs new changes. A negative
review is like failing your "human" test suite.</p>
<p>But unlike your automated test suite, which reset and get a new go every time
you push a change (because hey, who knows, maybe the change ACTUALLY FIXED THE
ISSUE), reviews do not reset, unless the original reviewers explicitly change
them. So my dream of being able to glance at the pull request list and see
which PRs need changes has officially
been <a href="https://en.wiktionary.org/wiki/pipe_dream">piped</a>. Even if the list
actually showed what PRs have been reviewed, it would be a lie, because as
soon as the PR author pushes a change, the review status becomes potentially
outdated.</p>
<p>Now, given the rocky start that this whole feature has had, I figured that
this was probably just a simple bug. But after I reported it to GitHub,
they've informed me that this is in fact <em>intended behavior</em>.</p>
<p>To make things worse, GitHub has another feature with Reviews,
called
<a href="https://help.github.com/articles/approving-a-pull-request-with-required-reviews/">required reviews</a>.
You can make it so that every pull request must receive at least one positive
review and zero negative reviews before it can be merged (go to the branch
settings for your repository). This works similar to required status checks,
which make it so that your tests must pass before a PR can be merged. In
practice, this means you need zero negative reviews, since anyone with push
access could just do a positive review before merging (although annoyingly,
you have to actually manually do it; IMHO, just requiring zero negative
reviews should be sufficient, since merging is implicitly a positive review).</p>
<p>Now, you can see that the above "feature" of reviews not resetting breaks the
whole thing. If someone negative reviews a PR, that one person has to go in
and change their review before it can be merged. And even if the author pushes
new changes to fix the issues outlined in the review, the PR cannot be merged
until the reviewer resets it. So this actually makes the reviewing situation
<em>worse</em>, because now anyone who reviews a pull request at any point in time
has to go through with it all the way to the merge. I can't go to a PR that
someone requested changes for, which were later made by the author, and merge
it. I have to ping the reviewer and get them to change their review first.
Needless to say, we do not have this feature enabled for SymPy's repo.</p>
<p>I think I maybe see the intended use-case here. You want to make it so that
people's reviews are not forgotten or ignored. But that's completely foreign
to my own problems. I trust the SymPy community, and the people who have push
access to do due diligence before merging a pull request. And if a bad change
gets in, we can revert it. Maybe this feature matters more for projects that
continuously deploy. Likely most of the code internal at GitHub works like
that. But guess what GitHub, most of the code <em>on</em> GitHub does <em>not</em> work like
that. You need to rethink this feature to support more than just your
use-cases.</p>
<p>I think starting simple, say, just a simple "approve/reject" button on each
PR, which just adds an icon, and that's it, would have been a better approach.
Then they could have listened to the feedback on what sorts of things people
wanted it to be able to do (like setting a status, or showing up in the search
list, or "delayed commenting" if that's really what people want). This is how
GitHub used to do things. It's frustrating to see a feature implemented that
doesn't (yet) do quite what you want, but it's even more frustrating to see a
feature implemented that does all the things that you don't want.</p>
<h2>Summary</h2>
<p>Yes, I'm a little mad here. I hope you enjoyed my rant. Here are what I see as
the problems with the "Reviews" feature. I don't know how to fix these
problems (I'm not a UI/UX guy. GitHub supposedly hires them, though).</p>
<ul>
<li><p>There are now two distinct ways to comment on a PR (delayed and non-delayed).
There should be one (say, with a checkbox to delay commenting).</p></li>
<li><p>If you insist on keeping delayed commenting, let me turn it off by default
(default = the Cmd-Enter keyboard shortcut).</p></li>
<li><p>The reviews button is buried on the diff page. I would put it under the
main PR comment box, and just reuse the same comment box.</p></li>
<li><p>Reviews should show up in the pull request list. They should be filterable
with a nice UI.</p></li>
<li><p>Let me review my own pull requests. These can be excluded from required
reviews (that makes sense to me). Beyond that, there's no reason this
shouldn't be allowed.</p></li>
<li><p>Don't require a positive review for required reviews, only zero negative
reviews. Merging a PR is implicitly positively reviewing it.</p></li>
<li><p>Allow reviews to reset when new commits are pushed.</p></li>
</ul>
<p>I get that the last point may not be what everyone wants. But GitHub needs to
think about UI, and defaults here. Right now, the UI looks like reviews are
like statuses, but they actually aren't because of this.</p>
<p>I am dispirited to see GitHub release such a broken feature, but even the best
trip up sometimes. I'm not yet calling "doom" on GitHub. Everyone has
their <a href="https://en.wikipedia.org/wiki/Apple_USB_Mouse">hockey puck mice</a>. I'm
actually hopeful that they can fix these issues, and implement a feature that
makes real headway into helping me solve one of my biggest problems on GitHub
right now, the reviewing of pull requests.</p></div>https://asmeurer.github.io/blog/posts/tuples/TuplesAaron Meurer (asmeurer)Thu, 22 Sep 2016 02:33:14 GMT
https://asmeurer.github.io/blog/posts/tuples/
<div><p>Today, David Beazley made some tweets:</p>
<blockquote class="twitter-tweet"><p dir="ltr" lang="en">At the bookstore. I'll admit I judge Python books by their tuple description. "Read only list?" Back on the shelf. Nope.</p>— David Beazley (@dabeaz) <a href="https://twitter.com/dabeaz/status/778634205395845120">September 21, 2016</a></blockquote>
<blockquote class="twitter-tweet"><p dir="ltr" lang="en">Usually there's a sentence nearby "sometimes you need a read only list." No. No, I haven't. Not in 20 years. Not even once. Sorry.</p>— David Beazley (@dabeaz) <a href="https://twitter.com/dabeaz/status/778635637457088512">September 21, 2016</a></blockquote>
<blockquote class="twitter-tweet"><p dir="ltr" lang="en">My main objection is that "read only list" is a lazy description lacking thought. A red flag for every other topic that might be covered.</p>— David Beazley (@dabeaz) <a href="https://twitter.com/dabeaz/status/778639979052498944">September 21, 2016</a></blockquote>
<p>There are quite a few good responses to these tweets, both from David and from
others (and from yours truly). I recommend reading the the thread (click on
the <a href="https://twitter.com/dabeaz/status/778634205395845120">first tweet</a> above).</p>
<p>Now to start off, I want to say that I respect the hell out of David Beazley.
The guy literally <a href="http://www.dabeaz.com/cookbook.html">wrote the book</a> on
Python, and he knows way more about Python than I ever will. He's also one of
the most entertaining Python people you can
<a href="https://twitter.com/dabeaz">follow on Twitter</a>. But hey, that doesn't mean I
can't disagree sometimes.</p>
<h2>List vs. Tuple. Fight!</h2>
<p>As you probably know, there are two "array" datatypes in Python, <code>list</code> and
<code>tuple</code>.<sup id="fnref:list"><a class="footnote-ref" href="https://asmeurer.github.io/blog/posts/tuples/#fn:list" rel="footnote">1</a></sup> The primary difference between the two is that lists are <em>mutable</em>,
that is you can change their entries and length after they are created, with
methods like <code>.append</code> or <code>+=</code>. Tuples, on the other hand, are <em>immutable</em>.
Once you create one, you cannot change it. This makes the implementation
simpler (and hence faster, although don't let anyone tell you you should use a
tuple just because it's faster). This, as
<a href="http://nedbatchelder.com/blog/201608/lists_vs_tuples.html">Ned Batchelder</a>
points out, is the only technical difference between the two.</p>
<p>The the idea that particularly bugs me here is that tuples are primarily
useful as "record" datatypes.</p>
<blockquote class="twitter-tweet"><p dir="ltr" lang="en"><a href="https://twitter.com/AllenDowney">@AllenDowney</a> Better than "read-only-list." ;-). Mainly looking for the tuple-as-record description. That's often what's missing.</p>— David Beazley (@dabeaz) <a href="https://twitter.com/dabeaz/status/778685294593716224">September 21, 2016</a></blockquote>
<p>Tuples are awesome for records. This is both by design—since they have a
fixed shape, the positions in a tuple can be "fixed" values, and by convention—if a
Python programmer sees parentheses instead of square brackets, he is more
likely to see the object as "record-like". The <code>namedtuple</code> object in the standard library
takes the record idea further by letting you actually name the fields:</p>
<pre class="code literal-block"><span class="o">>>></span> <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span>
<span class="o">>>></span> <span class="n">person</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s">'Person'</span><span class="p">,</span> <span class="s">'name, age'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">person</span><span class="p">(</span><span class="s">'Aaron'</span><span class="p">,</span> <span class="mi">26</span><span class="p">)</span>
<span class="n">Person</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">'Aaron'</span><span class="p">,</span> <span class="n">age</span><span class="o">=</span><span class="mi">26</span><span class="p">)</span>
</pre>
<p>But is that really the <em>only</em> place you'd want to use a tuple over a list?</p>
<p>Consider five other places you might encounter a tuple in Python, courtesy of
Allen Downey:</p>
<blockquote class="twitter-tweet"><p dir="ltr" lang="en"><a href="https://twitter.com/dabeaz">@dabeaz</a> (1) tuple assignment (2) multiple return values (3) *args (4) output from zip, enumerate, etc (5) key in dictionary</p>— Allen Downey (@AllenDowney) <a href="https://twitter.com/AllenDowney/status/778691102094176257">September 21, 2016</a></blockquote>
<p>In code these look like:</p>
<ol>
<li>
<p><strong>Multiple assignments:</strong></p>
<pre class="code literal-block">>>> (a, b) = 1, 2
</pre>
<p>(yes, the parentheses are optional here, as they are in many places where a
tuple can be used, but this is still a tuple, or at least it looks like one ;)</p>
</li>
<li>
<p><strong>Multiple return values:</strong></p>
<p>For example,
<a href="https://docs.python.org/3/library/os.html#os.walk"><code>os.walk</code></a>. This is
for the most part a special case of using tuples as records.</p>
</li>
<li>
<p><strong><code>*args</code>:</strong></p>
<pre class="code literal-block">>>> def f(*args):
... print(type(args), args)
...
>>> f(1, 2, 3)
<class 'tuple'> (1, 2, 3)
</pre>
<p>Arbitrary positional function arguments are always stored as a <code>tuple</code>.</p>
</li>
<li>
<p><strong>Return value from builtins <code>zip</code>, <code>enumerate</code>, etc.:</strong></p>
<pre class="code literal-block">>>> for i in zip(range(3), 'abc'):
... print(i)
...
(0, 'a')
(1, 'b')
(2, 'c')
>>> for i in enumerate('abc'):
... print(i)
...
(0, 'a')
(1, 'b')
(2, 'c')
</pre>
<p>This also applies to the combinatoric generators in
<a href="https://docs.python.org/3.6/library/itertools.html">itertools</a> (like
<code>product</code>, <code>combinations</code>, etc.)</p>
</li>
<li>
<p><strong>Dictionary keys:</strong></p>
<pre class="code literal-block">>>> {
... (0, 0): '.',
... (0, 1): ' ',
... (1, 0): '.',
... (1, 1): ' ',
... }
{(0, 1): ' ', (1, 0): '.', (0, 0): '.', (1, 1): ' '}
</pre>
</li>
</ol>
<p>This last one I find to be very important. You could arguably use a list for
the first four of Allen Downey's points<sup id="fnref:assign"><a class="footnote-ref" href="https://asmeurer.github.io/blog/posts/tuples/#fn:assign" rel="footnote">2</a></sup> (or Python could have, if it wanted to). But it
is
<a href="https://asmeurer.github.io/blog/posts/what-happens-when-you-mess-with-hashing-in-python/">impossible</a>
to meaningfully hash a mutable data structure in Python, and hashability is a
requirement for dictionary keys.</p>
<p>However, be careful. Not all tuples are hashable. Tuples can contain
anything, but only tuples of immutable values are hashable. Consider<sup id="fnref:TypeError"><a class="footnote-ref" href="https://asmeurer.github.io/blog/posts/tuples/#fn:TypeError" rel="footnote">4</a></sup></p>
<pre class="code literal-block"><span class="o">>>></span> <span class="n">t</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
<span class="o">>>></span> <span class="n">t</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">t</span>
<span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">])</span>
</pre>
<p>Such tuples are not hashable, and cannot be used as dictionary keys.</p>
<pre class="code literal-block"><span class="o">>>></span> <span class="nb">hash</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
<span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
<span class="n">File</span> <span class="s">"<ipython-input-39-36822ba665ca>"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">1</span><span class="p">,</span> <span class="ow">in</span> <span class="o"><</span><span class="n">module</span><span class="o">></span>
<span class="nb">hash</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
<span class="ne">TypeError</span><span class="p">:</span> <span class="n">unhashable</span> <span class="nb">type</span><span class="p">:</span> <span class="s">'list'</span>
</pre>
<h2>Why is <code>list</code> the Default?</h2>
<p>My second gripe here is this notion that your default ordered collection
object in Python should be <code>list</code>. <code>tuples</code> are only to be used as "records",
or if you suspect <em>might</em> want to use it as a dictionary key. First off, you
never know when you'll want something to be hashable. Both dictionary keys and
<code>sets</code> require hashability. Suppose you want to de-duplicate a collection of
sequences. If you represent the sequences with <code>list</code>, you'll either have to
write a custom loop that checks for duplicates, or manually convert them to
<code>tuple</code> and throw them in a <code>set</code>. If you start with <code>tuple</code>, you don't have
to worry about it (again, assuming the entries of the tuples are all hashable
as well).</p>
<p>Consider another usage of tuples, which I consider to be
important, namely tree structures. Say you wanted a simple representation of a
Python syntax tree. You might represent <code>1 - 2*(-3 + 4)</code> as</p>
<pre class="code literal-block"><span class="p">(</span><span class="s">'-'</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="s">'*'</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="s">'+'</span><span class="p">,</span> <span class="p">(</span><span class="s">'-'</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">4</span><span class="p">)))</span>
</pre>
<p>This isn't really a record. The meaning of the entries in the tuples is
determined by the first value of the tuple, not position. In this example, the length
of the tuple also signifies meaning (binary vs. unary <code>-</code>).</p>
<p>If this looks familiar to you, it's because this is how the language Lisp
represents all programs. This is a common pattern.
<a href="http://dask.pydata.org/en/latest/graphs.html">Dask graphs</a> use tuples and
dictionaries to represent computations.
<a href="http://docs.sympy.org/latest/tutorial/manipulation.html">SymPy expression trees</a>
use tuples and Python classes to represent symbolic mathematical expressions.</p>
<p>But why use tuples over lists here? Suppose you had an object like the one
above, but using lists: <code>['-', 1, ['*', 2, ['+', ['-', 3], 4]]]</code>. If you
discover you need to use this as a dictionary key, or want to put it in a
<code>set</code>, you would need to convert this to a hashable object. To do this you
need to write a function that recursively converts each <code>list</code> to a <code>tuple</code>.
See how long it takes you to write that function correctly.</p>
<h2>Mutability is Bad</h2>
<p>More to the point, however, mutability is bad. I counted 12 distinct methods
on <code>list</code> that mutate it (how many can you remember off the top of your
head?<sup id="fnref:mutate"><a class="footnote-ref" href="https://asmeurer.github.io/blog/posts/tuples/#fn:mutate" rel="footnote">3</a></sup>). <em>Any</em> function that gets access to a list can mutate it,
using any one of these methods. All it takes is for someone to forget that
<code>+=</code> mutates a list (and that they should copy it first) for code completely
distant from the origin definition to cause issues. The hardest bug I ever
debugged had a three character
<a href="https://github.com/inducer/pudb/commit/b979fc5909c8d731eb907fc25f4e97904fb7cbbd">fix</a>,
adding <code>[:]</code> to copy a global list that I was (accidentally) mutating. It took
me a several hour airplane ride and some deep dark magic that I'll leave for
another blog post to discover the source of my problems (the problems I was
having appeared to be quite distant from the actual source).</p>
<h2>A Better "Default"</h2>
<p>I propose that Python code in general would be vastly improved if people used
<code>tuple</code> as the default ordered collection, and only switched to <code>list</code> if
mutation was necessary (it's less necessary than you think; you can always
copy a tuple instead of mutating it). I agree with David Beazley that you
don't "sometimes need a read only list". Rather, you "sometimes need a
writable tuple".</p>
<p>This makes more sense than defaulting to <code>list</code>, and only switching to <code>tuple</code>
when hashability is needed, or when some weird "rule of thumb" applies that
says that you should use <code>tuple</code> if you have a "record". Maybe there's a good
reason that <code>*args</code> and almost all builtin and standard library functions
return tuples instead of lists. It's harder to accidentally break someone
else's code, or have someone else accidentally break your code, when your data
structures are immutable.</p>
<h2>Footnotes</h2>
<div class="footnote">
<hr />
<ol>
<li id="fn:list">
<p>I want to avoid saying "a tuple is an immutable list", since "list"
can be interpreted in two ways, as an English word meaning "ordered
collection" (in
which case, the statement is true), or as the Python type <code>list</code> (in which
case, the statement is false—<code>tuple</code> is not a subclass of <code>list</code>). <a class="footnote-backref" href="https://asmeurer.github.io/blog/posts/tuples/#fnref:list" rev="footnote" title="Jump back to footnote 1 in the text">↩</a></p>
</li>
<li id="fn:assign">
<p>Yes,</p>
<pre class="code literal-block">>>> [a, b] = 1, 2
</pre>
<p>works. <a class="footnote-backref" href="https://asmeurer.github.io/blog/posts/tuples/#fnref:assign" rev="footnote" title="Jump back to footnote 2 in the text">↩</a></p>
</li>
<li id="fn:mutate">
<p></p><div id="spoiler" style="display: none;">
<code>__delitem__</code>, <code>__iadd__</code>, <code>__imul__</code>, <code>__setitem__</code>, <code>append</code>, <code>clear</code>, <code>extend</code>, <code>insert</code>,
<code>pop</code>, <code>remove</code>, <code>reverse</code>, and <code>sort</code>.
</div>
<button title="Click to show/hide content" type="button">Show/hide answer</button> <a class="footnote-backref" href="https://asmeurer.github.io/blog/posts/tuples/#fnref:mutate" rev="footnote" title="Jump back to footnote 3 in the text">↩</a>
</li>
<li id="fn:TypeError">
<p>One of the tweets from the conversation:</p>
<p></p><blockquote class="twitter-tweet"><p dir="ltr" lang="en"><a href="https://twitter.com/asmeurer">@asmeurer</a> <a href="https://twitter.com/AllenDowney">@AllenDowney</a> As yes:<br /><br />t = (1,2, [3, 4])<br />t[2] += [5,6]<br /><br />;-)</p>— David Beazley (@dabeaz) <a href="https://twitter.com/dabeaz/status/778697399975813120">September 21, 2016</a></blockquote>
<p>This is similar to this example. But
it turns out this one doesn't work:</p>
<pre class="code literal-block">>>> t = (1,2, [3, 4])
>>> t[2] += [5,6]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
</pre>
<p>I have no idea why. It seems to me that it should work. <code>t[2]</code> is a list
and <code>list</code> has <code>__iadd__</code> defined. It seems that Python gets kind of weird
about things on the left-hand side of an assignment. <strong>EDIT:
<a href="http://stackoverflow.com/a/29747466/161801">Here's</a> why.</strong> <a class="footnote-backref" href="https://asmeurer.github.io/blog/posts/tuples/#fnref:TypeError" rev="footnote" title="Jump back to footnote 4 in the text">↩</a></p>
</li>
</ol>
</div></div>http://nishnik.github.io/GSoC-Thirteenth-WeekGSoC Thirteenth WeekNishant Nikhil (nishnik)Fri, 02 Sep 2016 00:00:00 GMT
http://nishnik.github.io/GSoC-Thirteenth-Week/
<p><img alt="Logo" src="https://summerofcode.withgoogle.com/static/img/summer-of-code-logo.svg" /></p>
<p>This week I worked on the <a href="https://github.com/symengine/symengine/pull/1066">PR</a> of factoring square free polynomials.
Adding many changes for size in base. Like changing this:</p>
<pre><code class="language-C++">auto l = std::ceil(std::log(2 * B + 1) / std::log(mp_get_ui(fsqf.first)));
</code></pre>
<p>to</p>
<pre><code class="language-C++">if (mp_fits_slong_p(B)) {
temp = 2 * B + 1;
l = std::ceil(std::log(mp_get_d(temp))
/ std::log(mp_get_ui(fsqf.first)));
} else {
auto b_d = mp_get_d(mp_abs(b));
l = std::ceil(
(1 + std::log2(n + 1) / 2.0 + n + log2_d_A + std::log2(b_d))
/ (std::log2(mp_get_ui(fsqf.first))));
}
</code></pre>
<p>This prevented over-flow.
And a lot of implementation changes were incorporated in <code class="highlighter-rouge">gf_gcdex</code> also.</p>
<p>I also wrote documentation on <code class="highlighter-rouge">Fields</code> module <a href="https://github.com/symengine/symengine/wiki/Fields-in-SymEngine">here</a>.</p>https://gxyd.github.io/GSoC GSoC 2016 Project with SymPy(wrap up): Computational Group TheoryGSoC 2016 Project with SymPy(wrap up): Computational Group TheoryGaurav Dhingra (gxyd)Sun, 21 Aug 2016 18:30:00 GMT
https://gxyd.github.io/gsoc2016/gsoc2016_project.html
<p>
Hi, I'm Gaurav Dhingra (<a href="https://github.com/gxyd">@gxyd</a>) and this post is a report of my work for SymPy under <a href="https://summerofcode.withgoogle.com">Google Summer of Code 2016</a>.
</p>
<p>
This is also intended to be a description of my work for submission to <b>GSoC's Final Evaluation</b>.
</p>
<p>
<h3>
<u>Work Product Submission</u>
</h3>
</p>
<p>
<a href="https://github.com/gxyd/sympy/pull/6">PR for GSoC 2016 product submission: Gaurav Dhingra</a>.<br /><br />
<a href="https://github.com/gxyd/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory">GSoC proposal</a>
<h4>Pull Requests</h4>
</p>
<p>
<ul>
<font color="green">[Completed]</font>
<li><a href="https://github.com/sympy/sympy/pull/10350">#10350 <i>FreeGroup</i> implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11140">#11140 <i>FpGroup</i> implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11231">#11231 <i>Low Index Subgroups</i> algorithm implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11295">#11295 <i>Reidemeister Schreier</i> algorithm implementation in SymPy</a></li>
<li><a href="https://github.com/sympy/sympy/pull/11460">#11460 Add documentation for FpGroup file and fix separate bug</a></li>
</ul>
</p>
<p>
<ul>
<font color="red">[Work-in-progress]</font>
<li><a href="https://github.com/sympy/sympy/pull/11361">#11361 <i>Modified Todd Coxeter</i> algorithm implementation in SymPy</a></li>
</ul>
</p>
</p>
<p>
<h4>Bugs reported</h4>
<font color="green">[closed]</font>
<ul>
<li><a href="https://github.com/sympy/sympy/issues/11449">#11449 <i>TypeError</i> on compressing a Coset Table generated by coset table method</a>.</li>
</ul>
</p>
<p>
<h3>Brief Information</h3>
</p>
<p>
<b>Project</b>: <a href="https://summerofcode.withgoogle.com/projects/#5798586428162048">Group Theory</a>
<br /><br />
<b>Blog</b>: <a href="https://gxyd.github.io/gsoc.html">https://gxyd.github.io/gsoc.html</a>
<br /><br />
<b>My Website</b>: https://gxyd.github.io
<br /><br />
<b>e-mail</b>: axyd0000[at]gmail.com, igauravdhingra[at]protonmail.com
<br /><br />
I am a pre-final year undergraduate student of Applied Mathematics at IIT Roorkee.
</p>
<p>
<h3>Before GSoC</h3>
</p>
<p>
I heard about the GSoC program and about SymPy org. since of one of my college mate, Prasoon Shukla (he also participated in GSoC with SymPy). I was quite amazed by how mathematics and computer science could intersect and help in solving math problems.
</p>
<p>
I have been contributing to SymPy from May last year. In the beginning I tended often to work on issues that were more often related to my then on-going courses in my college. In December I completed a basic course on Group Theory, so I thought of choosing to work on Group Theory and I saw quite a few things in CGT were missing from SymPy and those functionalities were already there in GAP and Magma. So I asked them from Kalevi, regarding things that could be taken up for a gsoc project. So finally with some discussions with him and Aaron, I was sure by December end that I was going to work on implementing Finitely Presented Group in SymPy. I looked upto the last GSoC project on CGT by Alexandar Makelov, for reference material that could be used for the implementation and it turned out that the book by Derek Holt, Handbook of Computational Group Theory (will mention as shortly <i>the Handbook</i>).
<p>
<p>
Though I already started working on <a href="https://github.com/sympy/sympy/pull/10350">PR #10350</a> for implementation of free groups in beginning January though I started working on the proposal from February beginning.
</p>
<p>
So what I should do? Since I was quite sure of the project. Well at that moment I thought, since I am a mathematics major, choosing this project would also help me. So I reached out to Kalevi, said to him what I was thinking to do, what could be good for the project. So we worked upon making a good gsoc proposal.
</p>
<p>
Here is my <a href="https://github.com/gxyd/sympy/wiki/GSoC-2016-Application-Gaurav-Dhingra:-Group-Theory">GSoC proposal</a>. Now that the summer is over and I've tackled a lot more with computational group theory, it seems that the main points in my GSoC proposal were:
<ul>
<li>Implementation of different algebraic structures monoid, free monoid, free group, semi group, free semi group, magma, etc.
<li>Rewriting System for reducing the elements of finitely presented groups.
<li>The Todd-Coxeter algorithm for coset enumeration, used to find the index of a subgroup of a finitely presented group.
<li>Reidemeister Schreier algorithm.
<li>Implementation of main <code>Group</code> class.
</ul>
</p>
<p>
Well, I submitted my proposal and needed to wait until April 22 to the result, and then...
</p>
<img height="200" src="https://gxyd.github.io/images/gsoc_selection.png" width="650" />
<br /><br />
<i>I was selected _/\_</i>
<p>
I got lucky to have Kalevi Suominen like mentor too. Aaron Meurer, the project leader of SymPy was to be co-mentor, and I felt honored to be alloted my preferred mentors.
</p>
<p>
<h3>During GSoC</h3>
</p>
<p>
A more detailed account of my progress can be found on my blog <a href="https://gxyd.gitub.io/gsoc.html">here</a>
<ul>
<li>We started working on 7th May, we first started with working on completing the Free Group <a href="https://github.com/sympy/sympy/pull/10350">PR#10350</a> and we discussed things on our channel <a href="https://gitter.im/sympy/GroupTheory">sympy/GroupTheory</a>. We had some discussion on whether <code>Basic</code> should be a <i>super-class</i> of <code>FreeGroup</code> or not. In the end we decied not to derive <code>FreeGroup</code> from <code>Basic</code>. Its basic methods had already been written, most of them inspired from GAP software.</li>
<li>For the first point in my proposal (i.e implementation of algebraic structures), we didn't started with them (infact we never worked on them). We then moved onto the Coset Enumeration which covered 5 weeks of work in my timeline, but we didn't spend that much time, atleast on the first go at that moment, that did took alomost 3 weeks including the implementation of two strategies of enumeration <i>Felsch</i> and <i>HLT</i>. It was the very heart of our GSoC project. There were quite a few bugs that were there in algorithm, especially the bug #11449, to which the Kalevi found the solution.</li>
<li>For the second point we never reached it, there wasn't sufficient time for that. Then we decided to rather implement the <i>Low Index Subgroups</i> algortithm. It was quite fun to implement the algorithm, since it gave some good insight into CGT. More on this on <a href="https://gxyd.github.io/feeds/gsoc_week_5.html">blog for week 5</a>.</li>
<li>From here I had passed my mid-term evaluations. Then we started with work on <i>Reidemeister Schreier</i> algorithm. The algorithm was mainly implemeted using the <a href="http://staff.itee.uq.edu.au/havas/1974h.pdf">Havas paper</a>, though the current implementation in SymPy doesn't produce the best simplifed presentation. No good pseudocode is available for the algorithm, the major difficulty being the <i>sequence</i> of applying the operation. More on this on <a href="https://gxyd.github.io/gsoc_week_6.html">blog for week 6</a>.</li>
<li>After we thought that the result returned by Reidemeister Schreier algorithm we moved onto <i>modified todd coxeter</i> algorithm. The main difficulty in it was defining the $\tau$ which can be read on the our channel for comments by Kalevi, I belive it can help in solving that problem.</li>
<li>As to the fifth point (i.e making <code>Group</code> class), we never worked upon it. Also the topic of <i>Presenation of Finite Groups</i> , could not get much attention, since of my busy college schedule.</li>
</ul>
</p>
<p>
<h5><u>Commits/Code written during GSoC</u></h5>
</p>
<p>
Since I have commited quite a few commits un-related to my project. So I decided to <i>cherry-pick</i> the commits made for my GSoC project. So the combined commits makes the things quite clear. <a href="https://github.com/sympy/sympy/commits/master?author=gxyd">commits in GSoC 2016 product submission: Gaurav Dhingra</a>.
</p>
<p>
<h5><u>Most annoying issue</u></h5>
</p>
<p>
<a href="https://github.com/sympy/sympy/issues/11449">issue #11449</a>
</p>
<p>
<h3>After GSoC</h3>
</p>
<p>
There is still much to be done regarding the finitely presented groups. As during the program my efforts were directed mainly towards getting the fundamental algorithms for finitely presented groups in, the overall structure of the module hasn't received much attention.
</p>
<p>
The algorithms are in, but the methods in sympy/combinatorics/fp_groups.py are not that much user-friendly. The code organization is not terrible, I think. Some suggestions (both for me and anyone else interested) for future work are:
<ul>
<li><b>Cosets in permutation groups</b>: [verbatim-copy of Kalevi's mail - <i>"next thing to do"</i>] Finding cosets in permutation groups is more challenging to implement since there seems to be no ready-made pseudocode. However, there is a description of the procedure with an example in section 4.6.7. It can be based on the existing implementation of the <i>Screier-Sims algorithm</i>.</li>
<li><b>Finitely generated abelian groups</b>: [verbatim-copy of Kalevi's mail - <i>"next thing to do"</i>] There is useful pseudocode in chapter 9 of the book by Holt that should make it fairly easy to implement the basic methods of abelian groups. We should probably try to base the implementation on the code in <code>polys.agca</code> as abelian groups are the same as Z-modules. It is all essentially about linear algebra over the integers.</li>
<li><b>Complete modified Todd Coxeter algorithm</b>: <a href="https://github.com/sympy/sympy/pull/11361">PR #11361</a> One bug is currently there in the algorithm, which can be fixed since we have to make assignments to $\tau$. Also currently no tests have been added, which can be added.</li>
<li><b>Rewriting System</b>: This can be a good candidate for a major work, I included this topic in my proposal though was left untouched. Perhaps <i>GAP</i> could be first seen in this regard. Like always</li>
<li><b>Groups folder</b>: After a few of the above mentioned things have been done, I believe it could be a good time to make a folder named <code>groups</code>, since finitely presented groups should not be a part of combinatorics module which would contain the all algebraic structures including the permutation groups.</li>
<li><b>Non-associative algebra</b>: (Perhaps I got the spelling of <i>associative</i> this time right!) Albert CAS could be used to understand the workings related to non-associative algebra, it contains quite good functionalities.</li>
</ul>
</p>
<p>
<h3>Things I did right/wrong</h3>
</p>
<p>
<ul>
<li>I often lagged in writing blogs.</li>
<li>I worked more than expected hours before 15 July (before college started) but much less in the last one month of GSoC because of a little busy schedule.</li>
</ul>
</p>
<p>
<h3>Conclusion</h3>
</p>
<p>
I had say that I did about 70% of the work I promised to do in my proposal, considering that I also did two non-included task of Low Index subgroups algorithm and Modified Todd Coxeter algorithm, so I can say I swapped my work. It is good enough, and I hope to get back to extending the things that I have started. There's still some revision to be made, some code to be clean up. And I'm doing that.
</p>
<p>
I don't really know if I'll pass final evaluations by Google, but, regardless, I'm really glad for all the coding and development experience I got during these weeks. I'll probably use for personal projects, may be in Dissertation in last year, and try to contribute more to SymPy.
</p>
<p>
I appreciate the help of my mentor <a href="https://github.com/jksuom">Kalevi Suominen</a> who was always there for any query that I had regarding Group Theory in project, and I appreciate his ability to reply back within 1 hour for any message I left any time of day and every day of the week including weekend (I call it 1-hour rule). I think he was a wonderful mentor and I learnt a lot from him, and my co-mentor <a href="https://github.com/asmeurer">Aaron Meurer</a>, the current project leader of SymPy, and the entire SymPy community for helping me out and reviewing my work!
</p>
<p>
Also thank you <font color="#4885ed">G</font><font color="#db3236">o</font><font color="#f4c20d">o</font><font color="#4885ed">g</font><font color="#3cba54">l</font><font color="#db3236">e</font>.
</p>
</p>
<p>
<p>
अलविदा !
</p>http://nishnik.github.io/GSoC-Twelfth-WeekGSoC Twelfth WeekNishant Nikhil (nishnik)Sat, 20 Aug 2016 00:00:00 GMT
http://nishnik.github.io/GSoC-Twelfth-Week/
<p><img alt="Logo" src="https://summerofcode.withgoogle.com/static/img/summer-of-code-logo.svg" /></p>
<p>This week I started work on polynomial factorization in <code class="highlighter-rouge">Z</code>.
I implemented the zassenhaus’s algorithm, which factors a primitive square-free polynomial.<br />
The basic idea behind factoring a polynomial in <code class="highlighter-rouge">Z</code> is first to make it square free using <code class="highlighter-rouge">Yun's</code> algorithm or something similar and then choosing a prime number <code class="highlighter-rouge">p</code>, such that the polynomial mod <code class="highlighter-rouge">p</code> is square free, and <code class="highlighter-rouge">p</code> doesn’t divide its leading coefficient.
After that it is reduced to factoring polynomial in finite field. Which has already been implemented, then we lift all the factors from the finite field to <code class="highlighter-rouge">Z</code> using hensel lifting.
<br />
The number of time Hensel Lifting has to be done is found using the <a href="http://www.csd.uwo.ca/~moreno//CS424/Lectures/ResultantGcd.html/node5.html">Mignotte’s bound</a>.
<br />
This wall required implementation of extended euclidean GCD in the finite fields.
So, after the implementation of factorization of square free algorithms, we were able to perform:</p>
<pre><code class="language-C++">f = UIntPoly::from_vec(x, {1_z, 0_z, -9_z});
// f = -9x**2 + 1
out = f->zz_zassenhaus();
// out is a set of RCP<const UIntPoly>
// out = {-3x + 1, -3x - 1}
out_f = f->zz_factor_sqf();
// out_f is a pair<integer_class, std::set<RCP<const UIntPoly>>
// out_.f.first = 1
// out_f. second = {3x + 1, 3x - 1}
</code></pre>
<p>After this I need to implement the algorithm for square free factorization and the trial division for finding the power of factor in the polynomial, this way we will be able to factor the polynomials.
The PR is <a href="https://github.com/symengine/symengine/pull/1066">here</a>.</p>http://shekharrajak.github.io/Coding-Period-week-13Coding Period Week 13 - Last week and conclusionShekhar Prasad Rajak (shekharrajak)Sat, 20 Aug 2016 00:00:00 GMT
http://shekharrajak.github.io/Coding-Period-week-13/
<hr />
<p><strong>Documentation nonlinsolve:</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11532">#11532</a></p>
<hr />
<p><strong>Conclusion :</strong></p>
<p>So the GSoC coding period is going to end. Here I am writing what I did, my todo list and suggestions for future work.</p>
<ul>
<li>
<p>One can see the progress report of each week and minutes of meeting here :
<a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Solvers-Progress">GSoC-2016-Solvers-Progress</a></p>
</li>
<li>
<p>My all the PRs link is here : <a href="https://github.com/sympy/sympy/pulls?utf8=%E2%9C%93&q=is%3Aopen%7Cclosed%20is%3Apr%20author%3AShekharrajak%20">sympy/pulls/shekharrajak</a></p>
</li>
<li>
<p>I have created a vertical timeline to show all the work in chrononical order in this link : <a href="http://shekharrajak.github.io/gsoc16_final.html">timeline</a></p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>
<p>I find one issue : <a href="https://github.com/sympy/sympy/issues/11534">#11534</a> in mailing list discussion. This shows that we need better
<code class="highlighter-rouge">invert</code> method for inverting nested roots/powers equtions in <code class="highlighter-rouge">solveset</code> .</p>
</li>
<li>
<p>and this <a href="https://github.com/sympy/sympy/issues/11528">#11528</a>. <code class="highlighter-rouge">factor_list</code> will be helpful in factoring the equation in <code class="highlighter-rouge">solveset</code> and solve for it factors and union the solution(during the PR #11188 discussion with Harsh this idea came out). It will actually replace the <a href="https://github.com/sympy/sympy/blob/master/sympy/solvers/solveset.py#L646">elif f.is_Mul and all(_is_finite_with_finite_vars(m, domain)</a> statement in <code class="highlighter-rouge">_solveset</code> and <code class="highlighter-rouge">factor_list</code> will be used soon.</p>
</li>
</ul>http://sampadblog.wordpress.com/?p=1042GSoC Week 12 and Wrap-upSampad Saha (sampadsaha5)Fri, 19 Aug 2016 18:49:39 GMT
https://sampadblog.wordpress.com/2016/08/19/gsoc-week-12-and-wrap-up/
<p>Hello all! This is officially the last week for Google Summer of Code 2016. The submission and final evaluation has already started. Last week I was busy with fixing bugs and preparing documentation for the beam module.</p>
<h4><em><strong>The things that I have implemented till now</strong></em></h4>
<ul>
<li>DiracDelta can be represented in piecewise form.</li>
<li>DiracDelta and Heaviside have a detailed docstring.</li>
<li>DiracDelta can be pretty printed using δ(x).</li>
<li>Singularity Function module which can perform all sort of mathematical operations on discontinuity functions.</li>
<li>Beam module which can solve 2D beam bending problems.</li>
</ul>
<h4><em><strong>Future Plans</strong></em></h4>
<p>Jason has came up with some new ideas for beam module:</p>
<ul>
<li>Plot the shear, bending, slope and deflection diagrams..</li>
<li>Compute the strain and stress at any location in the beam.</li>
<li>Improve the beam module for more complicated loads.</li>
</ul>
<p>I have planed for a long term association with SymPy, I am taking the full responsibilty of my code and I will try to contribute as much as I can. I will help the new developers with the Sympy code paradigms and the development workflow.</p>
<p>I have been able to meet all the target that I had mentioned in my <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Application-Sampad-Kumar-Saha:-Singularity-Functions">proposal</a> and all of my pull requests have got merged except PR <a href="https://github.com/sympy/sympy/pull/11494">11494</a>. It was great working with Sympy. Jason, Sartaj, Aaron, Kalevi, Isuru and all other sympy members have helped me a lot. Many of the times, I used to get stuck with some implementation, testing or with the Travis CI build but, for everytime they have always tried to help me fix them. My mentors have always appreciated and motivated me. I got to learn many new thing about the software development workflow. Thank you Sympy for making this summer an awesome journey of learning and coding.</p>
<p>That’s all folks.</p>
<p>Happy Coding.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/sampadblog.wordpress.com/1042/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sampadblog.wordpress.com/1042/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=sampadblog.wordpress.com&blog=102728326&post=1042&subd=sampadblog&ref=&feed=1" width="1" />http://rajithsays.wordpress.com/?p=445GSoC : EpilogueRajith Vidanaarachchi (rajithv)Fri, 19 Aug 2016 05:01:52 GMT
https://rajithsays.wordpress.com/2016/08/19/gsoc-epilogue/
<h2>Overview:</h2>
<p style="text-align: justify;">For the duration of GSoC, I have worked on the SymEngine project, with focus on writing the Cwrapper and specifically the Ruby Wrapper. Major work during the project timeline included wrapping already existing features such as MPC, MPFR, arbitrary precision evaluations, Matrices, expression parsing etc., and new features such as lambdifying expressions in Ruby and Exception Handling.</p>
<h2>Proposal:</h2>
<p>My proposal for GSoC 2016 can be viewed here <a href="https://docs.google.com/document/d/1HKEzqpm3yk9ax5Fs7POQaBFZFxSOjy1MXNyeB7JXBxg/edit#heading=h.t8we2dfbtvd1">[1]</a>.</p>
<h2>Progress Report:</h2>
<p style="text-align: justify;">After 13 weeks of GSoC, we’re now at the end of the summer, and it is time for me to explain and report what I did with SymEngine and its Ruby Wrappers throughout the summer.</p>
<p style="text-align: justify;">For reporting purposes, I will take each week’s workload and indicate the status in a tabular manner, with links to the relevant PRs. Due to the nature of the project, each part usually consists of two PRs. One to the SymEngine repository <a href="https://github.com/symengine/symengine/">[2]</a>, and the other to the SymEngine.rb <a href="https://github.com/symengine/symengine.rb/">[3]</a> repository.</p>
<table cellpadding="4" cellspacing="0" width="100%">
<colgroup>
<col width="51*" />
<col width="51*" />
<col width="51*" />
<col width="51*" />
<col width="51*" /> </colgroup>
<tbody>
<tr valign="top">
<td width="20%">Week</td>
<td width="20%">Work</td>
<td width="20%">SymEngine</td>
<td width="20%">SymEngine.RB</td>
<td width="20%">Comments</td>
</tr>
<tr valign="top">
<td width="20%">1, 2</td>
<td width="20%">Complex Numbers & Floating Points</td>
<td width="20%">Completed</p>
<p>Wrappers for Real Double: <a href="https://github.com/symengine/symengine/pull/954">PR#954</a></p>
<p>Implementing real_double_get_d method: <a href="https://github.com/symengine/symengine/pull/966">PR#966</a></p>
<p>Wrappers for Real MPFR and Complex MPC: <a href="https://github.com/symengine/symengine/pull/972">PR#972</a></p>
<p>fixes #974: <a href="https://github.com/symengine/symengine/pull/975">PR#975</a></td>
<td width="20%">Completed</p>
<p>Real Double Class: <a href="https://github.com/symengine/symengine.rb/pull/46">PR#46</a></p>
<p>Ruby Wrappers for Real MPFR and Complex MPC: <a href="https://github.com/symengine/symengine.rb/pull/49">PR#49</a></td>
<td width="20%"></td>
</tr>
<tr valign="top">
<td width="20%">3</td>
<td width="20%">Derivatives, Substitutions, Abs</td>
<td width="20%">Completed</p>
<p>Function symbol Cwrappers: <a href="https://github.com/symengine/symengine/pull/982">PR#982</a></td>
<td width="20%">Completed</p>
<p>Abs: <a href="https://github.com/symengine/symengine.rb/pull/50">PR#50</a></p>
<p>Function symbol Ruby Wrappers: <a href="https://github.com/symengine/symengine.rb/pull/51">PR#51</a></td>
<td width="20%"></td>
</tr>
<tr valign="top">
<td width="20%">3</td>
<td width="20%">Series & Polynomials</td>
<td width="20%">–</td>
<td width="20%">–</td>
<td width="20%">The relevant parts in SymEngine’s C++ code library was not ready, so I had to skip this part.</td>
</tr>
<tr valign="top">
<td width="20%">3</td>
<td width="20%">Evalf</td>
<td width="20%">Completed</p>
<p>Common evals method and its Cwrappers: <a href="https://github.com/symengine/symengine/pull/987">PR#987</a></p>
<p>Sign check for Numbers: <a href="https://github.com/symengine/symengine/pull/1027">PR#1027</a></td>
<td width="20%">Completed</p>
<p>evalf ruby wrapper: <a href="https://github.com/symengine/symengine.rb/pull/55">PR#55</a></td>
<td width="20%">This was not included in the original proposal. Completed to compensate for Series and Polynomials.</td>
</tr>
<tr valign="top">
<td width="20%">4, 5, 6</td>
<td width="20%">Matrices</td>
<td width="20%">Completed.</p>
<p>Matrix Cwrappers: <a href="https://github.com/symengine/symengine/pull/992">PR#992</a></td>
<td width="20%">PR Under Review.</p>
<p>Matrix Ruby Wrappers: <a href="https://github.com/symengine/symengine.rb/pull/56">PR#56</a></td>
<td width="20%"></td>
</tr>
<tr valign="top">
<td width="20%">7</td>
<td width="20%">Parser</td>
<td width="20%">Completed</p>
<p>CWrapper for parser: <a href="https://github.com/symengine/symengine/pull/1029">PR#1029</a></td>
<td width="20%">Completed.</p>
<p>Ruby wrapper for parser: <a href="https://github.com/symengine/symengine.rb/pull/60">PR#60</a></td>
<td width="20%">Awaiting merging.</td>
</tr>
<tr valign="top">
<td width="20%">8</td>
<td width="20%">Lambdify</td>
<td width="20%">N/A</td>
<td width="20%">Completed</p>
<p>Lambdify as a module level function: <a href="https://github.com/symengine/symengine.rb/pull/61">PR#61</a></td>
<td width="20%">All work was performed on Ruby Wrappers directly.</td>
</tr>
<tr valign="top">
<td width="20%">9, 10</td>
<td width="20%">Exception Handling</td>
<td width="20%">Completed</p>
<p>Exception Handling: <a href="https://github.com/symengine/symengine/pull/1044">PR#1044</a></p>
<p>Fixing enum issue in Exceptions: <a href="https://github.com/symengine/symengine/pull/1069">PR#1069</a></td>
<td width="20%">Completed</p>
<p>Exception Handling: <a href="https://github.com/symengine/symengine.rb/pull/64">PR#64</a></td>
<td width="20%">Wiki on exception handling. <a href="https://github.com/symengine/symengine/wiki/SymEngine-Exceptions">[4]</a></td>
</tr>
<tr valign="top">
<td width="20%">11</td>
<td width="20%">Interfacing with GMP, MPFR, MPC gems</td>
<td width="20%">Incomplete</td>
<td width="20%">Incomplete</td>
<td width="20%"></td>
</tr>
<tr valign="top">
<td width="20%">12</td>
<td width="20%">Buffer Period</td>
<td width="20%">N/A</td>
<td width="20%">N/A</td>
<td width="20%">Allocated time to catch up with missed work.</td>
</tr>
<tr valign="top">
<td width="20%">13</td>
<td width="20%">Iruby Notebooks</td>
<td width="20%">N/A</td>
<td width="20%">Awaiting Merging<br />
Changes to beginner notebook:<br />
<a href="https://github.com/symengine/symengine.rb/pull/59">PR#59</a></td>
<td width="20%">Although the examples are ready, and were included in SymEngine’s presentation at SciPy <a href="https://www.youtube.com/watch?v=03rBe2RdMt4">[5]</a>, they were not merged, pending improvements to the formatting.</td>
</tr>
</tbody>
</table>
<h3>Other PRs:</h3>
<p>The following PRs were made for minor contributions.</p>
<ul>
<li>Fixes several warnings : <a href="https://github.com/symengine/symengine/pull/994">PR#994</a></li>
<li>Adding symengine_config.h to Cwrapper: <a href="https://github.com/symengine/symengine/pull/984">PR#984</a></li>
<li>Formating Fix: <a href="https://github.com/symengine/symengine.rb/pull/65">PR#65</a></li>
<li>Create ruby_example.ipynb: <a href="https://github.com/certik/scipy-2016-symengine-talk/pull/17">PR#17 2016-symengine-talk</a></li>
</ul>
<h3>Summary of Merged Contributions:</h3>
<ul>
<li>On SymEngine/SymEngine Repository:</li>
</ul>
<p><a href="https://github.com/symengine/symengine/commits?author=rajithv">https://github.com/symengine/symengine/commits?author=rajithv<br />
</a>106 commits / 4,316 ++ / 1,928 —</p>
<ul>
<li>On SymEngine/SymEngine.RB Repository:</li>
</ul>
<p><a href="https://github.com/symengine/symengine.rb/commits?author=rajithv">https://github.com/symengine/symengine.rb/commits?author=rajithv<br />
</a>134 commits / 3,756 ++ / 1,319 —</p>
<p>—</p>
<p>[1] <a href="https://docs.google.com/document/d/1HKEzqpm3yk9ax5Fs7POQaBFZFxSOjy1MXNyeB7JXBxg/edit#heading=h.t8we2dfbtvd1">https://docs.google.com/document/d/1HKEzqpm3yk9ax5Fs7POQaBFZFxSOjy1MXNyeB7JXBxg/edit#heading=h.t8we2dfbtvd1<br />
</a>[2] <a href="https://github.com/symengine/symengine/pull/994">https://github.com/symengine/symengine/<br />
</a>[3] <a href="https://github.com/symengine/symengine.rb/">https://github.com/symengine/symengine.rb/</a><br />
[4] <a href="https://github.com/symengine/symengine/wiki/SymEngine-Exceptions">https://github.com/symengine/symengine/wiki/SymEngine-Exceptions</a><br />
[5] <a href="https://www.youtube.com/watch?v=03rBe2RdMt4">https://www.youtube.com/watch?v=03rBe2RdMt4</a></p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/rajithsays.wordpress.com/445/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rajithsays.wordpress.com/445/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=rajithsays.wordpress.com&blog=110498904&post=445&subd=rajithsays&ref=&feed=1" width="1" />http://jbm950.github.io//2016/08/19/GSoC-week-14.htmlGSoC Week 14James Milam (jbm950)Fri, 19 Aug 2016 00:00:00 GMT
http://jbm950.github.io//2016/08/19/GSoC-week-14.html
<p>This is the final week of GSoC! I have the write up of the work done on a
different <a href="http://jbm950.github.io/../../../GSoC-Final-Submission.html">page</a>.</p>
<p>This project has been a wonderful learning experience and I have met many
wonderful people over the course of this summer. Before the summer began I had
never written any test code. Now at the conclusion of the summer I have written
benchmark tests and I try to make sure the code I write has complete unit
coverage. I feel that this is one of my biggest areas of improvement over the
past 3 months. I have also learned a considerable amount about the combination
of programming and dynamics. Prior to GSoC my experience with dynamics
consisted solely of finding the equations of motion by hand. With my time in
GSoC I have been exposed to finding the equations of motion programatically and
using the results with an ode integrator. I have also obtained a more in depth
knowledge of different algorithms for creating the equations of motion.</p>
<p>Another thing that I have enjoyed in this experience is seeing how a large
programming project works. I feel that this will make me more employable in the
future as well as allow me to help any other new open source community get up
and running.</p>
<p>Lastly, one of the big highlights of my summer was my trip to Austin, TX for
Scipy 2016. Being a GSoC student I not only got to go to my first professional
conference but I was able to help give one of the tutorials. Also I was able to
meet many of the other people who work on sympy. This went a long way in making
my contributions to sympy from being just contributions to some organization to
working on a project with other people. It was also neat to meet the developers
of other open source projects. Like my comment about sympy, I now see those
projects less as being “project name” and more as the people actually working
on them.</p>
<p>I have enjoyed my GSoC experience and if I were eligible I would not hesitate
to apply again. I would like to thank those who chose me and made this summer
of learning and experiences possible.</p>http://srajangarg.github.io//2016/08/16/Containers-for-MPolyContainers for Multivariate PolynomialsSrajan Garg (srajangarg)Tue, 16 Aug 2016 00:00:00 GMT
http://srajangarg.github.io//2016/08/16/Containers-for-MPoly/
<h3 id="overview">Overview</h3>
<p>After the last blog post, I started working on the “fixing up the remainder of rational polynomials”. This also included adding support for basic to rational polynomial conversions. The current work is in <a href="https://github.com/symengine/symengine/pull/1055">#1055</a> which has not been merged in yet.</p>
<p>Another thing I started working on was conversions from SymEngine symbolics to multivariate polynomials. The way the current conversions work, led me to change the overall structure of multivariate polynomials.</p>
<h3 id="restructuring-multivariate-polynomials">Restructuring Multivariate Polynomials</h3>
<p>The current working of basic conversions is that it constructs the “internal container” of the polynomial as it parses the expression. These containers have operators overloaded and they can easily be manipulated by the functions. Handling multivariate polynomials using this approach would be impossible with the current structure of the code. There were no “containers” per se in the previous implementation.</p>
<p>I thought it would be better if we can implement a container based polynomial structure for multivariate polynomials too. Fortunately, the way the SymEngine polynomials work, an approach similar to the univariate case of containers worked. The container is a wrapper around a map from vector to a value (the coefficient)</p>
<div class="language-c++ highlighter-rouge"><pre class="highlight"><code><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Vec</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Value</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Wrapper</span><span class="o">></span>
<span class="k">class</span> <span class="nc">UDictWrapper</span>
<span class="p">{</span>
<span class="k">public</span><span class="o">:</span>
<span class="k">using</span> <span class="n">Dict</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">unordered_map</span><span class="o"><</span><span class="n">Vec</span><span class="p">,</span> <span class="n">Value</span><span class="p">,</span> <span class="n">vec_hash</span><span class="o"><</span><span class="n">Vec</span><span class="o">>></span><span class="p">;</span>
<span class="n">Dict</span> <span class="n">dict_</span><span class="p">;</span>
<span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">vec_size</span><span class="p">;</span>
<span class="p">...</span>
</code></pre>
</div>
<p>The polynomial class uses this as a container, along with information about the generators and their ordering. Apart from holding the map, this class has various constructors, and all the operators overloaded for it. It also has helper functions, which help translate the current keys to another specific order/ arrangement. The container assumes that the all operations done to it are with other “adjusted” containers. Currently, the job of adjusting/aligning th container has been delegated to functions like <code class="highlighter-rouge">add_mpoly</code> etc.</p>
<div class="language-c++ highlighter-rouge"><pre class="highlight"><code><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Poly</span><span class="o">></span>
<span class="n">RCP</span><span class="o"><</span><span class="k">const</span> <span class="n">Poly</span><span class="o">></span> <span class="n">add_mpoly</span><span class="p">(</span><span class="k">const</span> <span class="n">Poly</span> <span class="o">&</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="n">Poly</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">typename</span> <span class="n">Poly</span><span class="o">::</span><span class="n">container_type</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">;</span>
<span class="n">set_basic</span> <span class="n">s</span> <span class="o">=</span> <span class="n">get_translated_container</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">);</span>
<span class="n">x</span> <span class="o">+=</span> <span class="n">y</span><span class="p">;</span>
<span class="k">return</span> <span class="n">Poly</span><span class="o">::</span><span class="n">from_container</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">move</span><span class="p">(</span><span class="n">x</span><span class="p">));</span>
<span class="p">}</span>
</code></pre>
</div>
<p>and</p>
<div class="language-c++ highlighter-rouge"><pre class="highlight"><code><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">Poly</span><span class="p">,</span> <span class="k">typename</span> <span class="n">Container</span><span class="o">></span>
<span class="n">set_basic</span> <span class="n">get_translated_container</span><span class="p">(</span><span class="n">Container</span> <span class="o">&</span><span class="n">x</span><span class="p">,</span> <span class="n">Container</span> <span class="o">&</span><span class="n">y</span><span class="p">,</span>
<span class="k">const</span> <span class="n">Poly</span> <span class="o">&</span><span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="n">Poly</span> <span class="o">&</span><span class="n">b</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">vec_uint</span> <span class="n">v1</span><span class="p">,</span> <span class="n">v2</span><span class="p">;</span>
<span class="n">set_basic</span> <span class="n">s</span><span class="p">;</span>
<span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">sz</span> <span class="o">=</span> <span class="n">reconcile</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">v2</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">vars_</span><span class="p">,</span> <span class="n">b</span><span class="p">.</span><span class="n">vars_</span><span class="p">);</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">a</span><span class="p">.</span><span class="n">poly_</span><span class="p">.</span><span class="n">translate</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">sz</span><span class="p">);</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">b</span><span class="p">.</span><span class="n">poly_</span><span class="p">.</span><span class="n">translate</span><span class="p">(</span><span class="n">v2</span><span class="p">,</span> <span class="n">sz</span><span class="p">);</span>
<span class="k">return</span> <span class="n">s</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>
<p>Basically, both the containers get the ordering of generators in the “new” polynomial which will soon be constructed, and adjust the ordering of the vectors inside their maps accordingly. Thus consistency is maintained. All the work done is in <a href="https://github.com/symengine/symengine/pull/1049">#1049</a> and this has been merged in.</p>
<h3 id="remaining-work">Remaining work</h3>
<ul>
<li>
<p>After getting this restructure done, I started work on the basic to multivariate conversions, though I have not been able to cover it completely. The idea for these conversions remains the same and should be easy to implement.</p>
</li>
<li>
<p>I also could not spend time to integrate wrappers to Piranha polynomials which can be used as multivariate polynomials within SymEngine</p>
</li>
</ul>
<h3 id="wrapping-up-gsoc">Wrapping up GSoC</h3>
<p>This is officially the last week of Google Summer of Code ‘16. Although GSoC is over, I plan to get the above mentioned work finished within August, before any other big undertaking. It has been a wonderful journey of insight and knowledge. Thanks a lot to my mentors Isuru, Ondrej and Sumith for helping me throughout the summers, and always being there for discussions and the silly issues I bombarded them with!</p>
<p>Bye!</p>http://shekharrajak.github.io/Coding-Period-week-12Coding Period Week 12Shekhar Prasad Rajak (shekharrajak)Mon, 15 Aug 2016 00:00:00 GMT
http://shekharrajak.github.io/Coding-Period-week-12/
<hr />
<p><strong>nonlinsolve continue:</strong></p>
<ul>
<li>
<p>PR : <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
</li>
<li>
<p>few things that should be improved in <code class="highlighter-rouge">nonlinsolve</code> :</p>
<div class="highlighter-rouge"><pre class="highlight"><code>- If system of equation contains trigonometric functions, `nonlinsolve`
sometime fails because `solve_trig` of `solveset` is not much better and
`nonlinsolve` have to identify what is the Intersection soln when we have
`2*n*pi + pi/2` and `n*pi + pi/2`(means something similar cases).Right now it is returning
one of them.
- `substitution` function which solves the system of equation using substitution method.
There should be better method to handle `imageset` (Complex solution).
- Code quality of `substitution` should be improved.
</code></pre>
</div>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<ul>
<li>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
</li>
<li>
<p>Imageset/union is generalized and now it handle basically these three cases:</p>
</li>
</ul>
<div class="highlighter-rouge"><pre class="highlight"><code># img1 = ImageSet(Lambda(n, a*n + b), S.Integers)
# img2 = ImageSet(Lambda(n, c*n + d), S.Integers)
In [1]: img1 = ImageSet(Lambda(n, 4*n + 4), S.Integers)
In [2]: img2 = ImageSet(Lambda(n, 4*n), S.Integers)
# when a == c and (b - d == a) then ans is img2.
In [3]: Union(img1, img2)
Out[3]: {4⋅n | n ∊ ℤ}
# -------------------------------------------------------------
In [4]: img1 = ImageSet(Lambda(n, 4*n + 2), S.Integers)
# when a == c and (b - d) == a/2, means value is a/2 * n
In [5]: Union(img1, img2)
Out[5]: {2⋅n | n ∊ ℤ}
# -------------------------------------------------------------
# 5*n + 5/4 ==> 5*n + 1 + 1/4
# 5*n + 1 + 1/4 is in n + 1/4
# check using img1.superset(img2) == true so img1 in ans
img1 = ImageSet(Lambda(n, n + S(1)/4 ), S.Integers)
img2 = ImageSet(Lambda(n, 5*n + S(5)/4 ), S.Integers)
In [4]: Union(img1, img2)
Out[4]: {n + 1/4 | n ∊ ℤ}
# -------------------------------------------------------------
# img1.issuperset(img2) is false so no change
img1 = ImageSet(Lambda(n, 2*n + S(1)/4 ), S.Integers)
img2 = ImageSet(Lambda(n, 5*n +S(5)/4), S.Integers)
In [5]: Union(img1, img2)
Out[5]: {2⋅n + 1/4 | n ∊ ℤ} ∪ {5⋅n + 5/4 | n ∊ ℤ}
</code></pre>
</div>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>I found some more cases where <code class="highlighter-rouge">factor_list</code> fails and opened a PR : https://github.com/sympy/sympy/issues/11528</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>http://jbm950.github.io//2016/08/12/GSoC-week-13.htmlGSoC Week 13James Milam (jbm950)Fri, 12 Aug 2016 00:00:00 GMT
http://jbm950.github.io//2016/08/12/GSoC-week-13.html
<p>This week I spent a lot of time working on FeatherstonesMethod and its
component parts. I started off by moving a bunch of spatial vector functions
from another PR I have to the featherstone PR and used some of those functions
to calculate the spatial inertia of Body objects. The next thing I worked on
was completely rewriting the internals of the joint code. The joints now
consist of 4 reference frames and points (one set at each of the bodys mass
centers and one set per body at the joint location).</p>
<p>After this I ran some basic code that used these new features and kept making
changes until the code was able to run without producing errors. I used this
same method of work with FeatherstonesMethod and now it too is able to run
without producing errors. Now that the code runs it was time to make sure that
the output is correct which is a lot more involved than the previous step of
work. To begin I solved for the spatial inertia by hand and used this
calculation to create test code for Body.spatial_inertia. As expected the code
initially was completely incorrect but it now passes the test. I have since
been working on the tests for the joint code. Since this code is completely new
to the sympy repository it takes a lot more planning than the body test did.
Also I need to solve the kinematics by hand for the joints so that I have a
base for the test code. This is where I am currently located in the process.</p>
<p>Also this week I addressed review comments on SymbolicSystem and have moved
that PR closer to being able to merge. One of the current hang ups is trying to
force Sphinx to autodocument the __init__ method. I think the best solution
currently is to move the relevant code back to the main docstring for the class
and not worry about trying to document the __init__ method.</p>
<p>While working on rewriting the joint code I came across a bug in frame.py and
have created a docstring with a fix to this along with a test to make sure the
fix works.</p>
<p>Lastly I reviewed a PR that adds a docstring to a method that did not yet have
a docstring. The PR had some information in it that was incorrect and after
some research I was able to make some suggestions for its implementation.</p>
<h3 id="future-directions">Future Directions</h3>
<p>Next week is the last full week of GSoC and my main priority is getting the
final evaluation information correctly finished so that the work can be
processed correctly. My next goal is to make sure SymbolicSystem gets merged
into SymPy. This is not entirely in my hands, however, as I will be having to
wait for feedback and so while waiting I will be pulling off different parts of
FeatherstonesMethod for separate PR’s at the recomendation of my advisor. These
separate PR’s I hope to possibly include in my final evaluation.</p>
<h3 id="prs-and-issues">PR’s and Issues</h3>
<blockquote>
<ul>
<li>(Open) [WIP] Added system.py to physics/mechanics <a href="https://github.com/sympy/sympy/pull/11431">PR
#11431</a></li>
<li>(Open) [WIP] FeatherstonesMethod <a href="https://github.com/sympy/sympy/pull/11415">PR
#11415</a></li>
<li>(Open) Added docstring to jordan_cell method <a href="https://github.com/sympy/sympy/pull/10356">PR
#10356</a></li>
</ul>
</blockquote>http://nishnik.github.io/GSoC-Eleventh-WeekGSoC Eleventh WeekNishant Nikhil (nishnik)Thu, 11 Aug 2016 00:00:00 GMT
http://nishnik.github.io/GSoC-Eleventh-Week/
<p><img alt="Logo" src="https://summerofcode.withgoogle.com/static/img/summer-of-code-logo.svg" /></p>
<p>This week I worked on little refactoring of <code class="highlighter-rouge">Fields</code> module. Like moving functions implementations from <code class="highlighter-rouge">.h</code> file to <code class="highlighter-rouge">.cpp</code> file in <a href="https://github.com/symengine/symengine/pull/1060">this</a> PR. I added a <code class="highlighter-rouge">from_uintpoly</code> method which allows us to create a <code class="highlighter-rouge">GaloisField</code> object from <code class="highlighter-rouge">UIntPoly</code> object in <a href="https://github.com/symengine/symengine/pull/1059/">this</a> PR. After which I worked on the implementation of <code class="highlighter-rouge">diff</code> method for <code class="highlighter-rouge">GaloisField</code> in <a href="https://github.com/symengine/symengine/pull/1060">this</a> PR.
<br />
Then I worked on <code class="highlighter-rouge">Logic</code> module. It is needed for the implementation of <code class="highlighter-rouge">Intersection</code> class in <code class="highlighter-rouge">Sets</code> module. It has the implementation for Logical And, Or and Not operations.
<br />
Both <code class="highlighter-rouge">Or</code> and <code class="highlighter-rouge">And</code> class have a private variable named <code class="highlighter-rouge">container_</code> which is a set of <code class="highlighter-rouge">RCP<const Boolean></code>. It stores the <code class="highlighter-rouge">Boolean</code> objects on which <code class="highlighter-rouge">And</code> and <code class="highlighter-rouge">Or</code> operator can’t be applied using the known rules.
<br />
<code class="highlighter-rouge">Not</code> also has one private variable which is an <code class="highlighter-rouge">RCB<const Boolean></code> object, which stores the <code class="highlighter-rouge">Boolean</code> object on which we were not able to apply <code class="highlighter-rouge">not</code> operator using the current rules.
<br />
Then we have three functions:</p>
<pre><code class="language-C++">RCP<const Boolean> logical_and(const set_boolean &s);
RCP<const Boolean> logical_or(const set_boolean &s);
RCP<const Boolean> logical_not(const RCP<const Boolean> &s);
</code></pre>
<p>These are used to do the respective operation on the operands supplied.
<br />
Talking little about implementaion details:</p>
<pre><code class="language-C++">RCP<const Boolean> logical_and(const set_boolean &s)
{
return and_or<And>(s, false);
}
RCP<const Boolean> logical_or(const set_boolean &s)
{
return and_or<Or>(s, true);
}
</code></pre>
<p>And the function <code class="highlighter-rouge">and_or</code> do the required operations.
<br />
After <a href="https://github.com/symengine/symengine/pull/1061/">this</a> PR gets merged, I would start working on <code class="highlighter-rouge">Intersection</code> class.</p>https://gxyd.github.io/GSoC Week 12GSoC Week 12Gaurav Dhingra (gxyd)Tue, 09 Aug 2016 18:30:00 GMT
https://gxyd.github.io/gsoc2016/gsoc_week_12.html
<p>
Hi all, here's a brief summary of the 12th week of my GSoC:
<br />
Last week I uploaded the <a href="https://gxyd.github.io/gsoc2016/covhtml/index.html">test-coverage files</a> on my website, that revealed some interesting places where a few versions of <code>scan</code> routine in coset enumeration have un-tested <code>if-elif-else</code> case.
</p>
<p>
As we are now approaching the end of GSoC time period, we decided to do some testing with some of the examples from 1973cdhw paper [2]. Coset Enumeration got my attention again since:
</p>
<p>
There seemed to be one bug raising <code>TypeError</code> so opened issue <a href="https://github.com/sympy/sympy/issues/11449">sympy/sympy/#11449</a>, resulting from coset enumeration by the coset-table based method. From beginning it was clear that the issue was not in <code>compress()</code> method. It was quite difficult for me get onto the main source of problem. But then Kalevi had a closer look on the pseudo-code in Derek Holt and also in Sims Finitely Presented Groups.
</p>
<p>
I wrote docstrings for a few of methods and fixed the issue <a href="https://github.com/sympy/sympy/issue/11449">#11449</a> in PR <a href="https://github.com/sympy/sympy/pull/11460">#11460</a>.
</p>
<p>
The problem there in code is explained briefly below
</p>
<b>Previous code-snippet</b>
<p>
<pre>
1 i = 0
2 while i < len(C.omega):
3 alpha = C.omega[i]
4 i += 1
5 for x in C.A:
6 if C.table[alpha][C.A_dict[x]] is None:
7 C.define_f(alpha, x)
8 C.process_deductions(R_c_list[C.A_dict[x]], R_c_list[C.A_dict_inv[x]])
</pre>
</p>
<b>After code-snippet</b>
<p>
<pre>
1 while alpha < len(C.table):
2 if C.p[alpha] == alpha:
3 for x in C.A:
4 if C.p[alpha] != alpha:
5 break
6 if C.table[alpha][C.A_dict[x]] is None:
7 C.define_c(alpha, x)
8 C.process_deductions(R_c_list[C.A_dict[x]], R_c_list[C.A_dict_inv[x]])
</pre>
</p>
<p>
Here $\alpha$ looks over in till $\lt$ <code>C.table</code>. This way all elements of $C.\Omega$ are tested even in case that the set becomes very small. The inner for $x$ loop should also tests $p[i]$ at each round and break if that becomes different from $i$.
</p>
<p>
The changes that have been addressed in <a href="https://github.com/sympy/sympy/pull/11460">PR #11460</a> also include chaging the file name <code>free_group.py</code> to <code>free_groups.py</code>, similar to what we have.
</p>
<p>
It seems that Presentation of Permutation Groups won't happen during GSoC since there's just one more week; instead, I plan to focus on improving and completing the current PR's <a href="https://github.com/sympy/sympy/pull/11361">#11361</a> on Modified Todd-Coxeter algorithm and <a href="https://github.com/sympy/sympy/pull/11460">PR #11460</a> on addition of docstrings and better user methods.
</p>
<p>
One more thing, that I would start in this week though may not be completed this week will be the sphinx documentation of finitely presented groups. I found the documentation of Poly's module by Kalevi very much readable and interesting, may be I can seek to follow that.
</p>
<p>
<h4>References</h4>
<i>
<ul>
<li>1. Derek F. Holt, Bettina Eick, Bettina, Eamonn A. O'Brien, "Handbook of computational group theory", Discrete Mathematics and its Applications (Boca Raton). Chapman & Hall/CRC, Boca Raton, FL, 2005. ISBN 1-5848-372-3 .</li>
<li>2. <a href="http://staff.itee.uq.edu.au/havas/1973cdhw.pdf">John J. Cannon; Lucien A. Dimino; George Havas; Jane M. Watson, "Implementation and Analysis of the Todd-Coxeter Algorithm" , Mathematics of Computation, Vol. 27, No. 123. (Jul., 1973), pp. 463-490</a></li>
</i>
<br />
</ul>http://shubhamtibra.wordpress.com/?p=854GSoC Week 11Subham Tibra (shubhamtibra)Mon, 08 Aug 2016 10:55:52 GMT
https://shubhamtibra.wordpress.com/2016/08/08/gsoc-week-11/
<p>This week I primarily worked on some bugs and added singular initial conditions to the result of <code>expr_to_holonomic()</code>.</p>
<p>Firstly I fixed a bug in <code>.unify()</code>. There were some errors being raised in it when one of the Holonomic Function had ground domain <code>RR</code> or an extension of it. This now works fine.</p>
<pre class="brush: python; title: ; notranslate">
In [9]: expr_to_holonomic(1.4*x)*expr_to_holonomic(a*x, x)
Out[9]: HolonomicFunction((-2.0) + (1.0*x)*Dx, x, 0, {2: [1.4*a]})
In [10]: _9.to_expr()
Out[10]:
2
1.4⋅a⋅x
</pre>
<p>Later I fixed a bug in converting the two types of initial condition into one another. Apparently I forgot to add the <code>factorial</code> term while converting.</p>
<p>After that I added singular initial conditions to the result of <code>expr_to_holonomic()</code>  whenever the Indicial equation have one root. For example:</p>
<pre class="brush: python; title: ; notranslate">
In [14]: expr_to_holonomic(x*exp(x))
Out[14]: HolonomicFunction((-x - 1) + (x)*Dx, x, 0, {1: [1]})
In [15]: _.to_expr()
Out[15]:
x
x⋅ℯ
</pre>
<p>I also changed printing of the class <code>HolonomicFunction</code> to include the initial conditions inside the call, so as to make it proper python. These are implemented in <a href="https://github.com/sympy/sympy/pull/11480">#11480</a> and <a href="https://github.com/sympy/sympy/pull/11451">#11451</a>.</p>
<p>Right now we are trying to find a way to include convergence conditions in the result while converting Holonomic Functions to expressions.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/shubhamtibra.wordpress.com/854/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shubhamtibra.wordpress.com/854/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=shubhamtibra.wordpress.com&blog=106149936&post=854&subd=shubhamtibra&ref=&feed=1" width="1" />http://shekharrajak.github.io/Coding-Period-week-11Coding Period Week 11Shekhar Prasad Rajak (shekharrajak)Sun, 07 Aug 2016 00:00:00 GMT
http://shekharrajak.github.io/Coding-Period-week-11/
<hr />
<p><strong>eliminate() continue:</strong></p>
<ul>
<li>
<p>PR : <a href="https://github.com/sympy/sympy/pull/11485">#11485</a></p>
</li>
<li>
<p>Regarding issue <a href="https://github.com/sympy/sympy/issues/2720">#2720</a>, It is something similar to <code class="highlighter-rouge">eliminate</code> present in
<a href="http://reference.wolfram.com/mathematica/ref/Eliminate.html">wolfram</a>.</p>
</li>
<li>
<p>Right now it is working for real domain and not considering ImageSet, Intersection. Complement. If it find ImageSet, Intersection. Complement
for the symbol to be eliminated, then just raises <code class="highlighter-rouge">NotImaplementedError</code>(in near future it can be implemented).</p>
</li>
<li>
<p>It can take <code class="highlighter-rouge">N</code> nummber of equations and <code class="highlighter-rouge">M</code> number of <code class="highlighter-rouge">symbols</code> to be eliminated. It returns <code class="highlighter-rouge">FiniteSet</code> of equations which doesn’t contains
these <code class="highlighter-rouge">symbols</code>.</p>
</li>
</ul>
<hr />
<p><strong>Continue - Diophantine in Solveset :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11234">11234</a></p>
<ul>
<li>In <a href="https://github.com/sympy/sympy/pull/11234/commits/6bd9689d37647d6c28111097c433accc2127262e">commit</a> : returning
<code class="highlighter-rouge">ConditionSet</code> when it <code class="highlighter-rouge">diophantine</code> doesn’t the diophantine equation type and not able to solve.</li>
</ul>
<hr />
<p><strong>Idea for improved _solve_trig in Solveset :</strong></p>
<div class="highlighter-rouge"><pre class="highlight"><code>
In [1]: solveset(sin(x) + cos(y), x, S.Reals)
Out[1]: {x | x ∊ ℝ ∧ sin(x) + cos(y) = 0}
In [2]: solve(sin(x) + cos(y), x)
Out[2]: [asin(cos(y)) + π, -asin(cos(y))]
</code></pre>
</div>
<ul>
<li>
<p>This above examples is enough to tell that <code class="highlighter-rouge">_solve_trig</code> is not using inverse trigonometric function. We can have something, which can solve trig equations by making free the symbol in lhs and in rhs inverse trig function.</p>
</li>
<li>
<p><code class="highlighter-rouge">solveset(sin(2*x) - sqrt(3)*cos(2*x), x, S.Reals)</code> for this right now <code class="highlighter-rouge">_solve_trig</code> is converting it into <code class="highlighter-rouge">exp</code> form and solving it.
But it is can be simply solved using <code class="highlighter-rouge">sin(x + y) == sin(x)*cos(y) + cos(x)*sin(y)</code> formula.</p>
</li>
<li>
<p>First divide both side with <code class="highlighter-rouge">sqrt(a**2 + b**2)</code> where <code class="highlighter-rouge">a, b</code> is coeff of <code class="highlighter-rouge">sin(2*x)</code> , <code class="highlighter-rouge">cos(2*x)</code>.</p>
</li>
<li>
<p><code class="highlighter-rouge">sin(2*x)/2 - (sqrt(3)/2)*cos(2*x)</code> ==> <code class="highlighter-rouge">sin(2*x)*cos(pi/3) - sin(pi/3)*cos(2*x)</code> ==> <code class="highlighter-rouge">sin(2*x - pi/3)</code>.</p>
</li>
<li>
<p>Now <code class="highlighter-rouge">sin(2*x - pi/3)</code> is solvable using <code class="highlighter-rouge">solve_decomposition</code>.</p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>Some analysis about <code class="highlighter-rouge">Abs</code> solver :</li>
</ul>
<div class="highlighter-rouge"><pre class="highlight"><code>
In [1]: solveset(Abs(x) - 1, x)
ValueError:
Absolute values cannot be inverted in the complex domain.
In [2]: solveset(Abs(x) - (1 + I), x)
ValueError:
Absolute values cannot be inverted in the complex domain.
In [3]: solveset(Abs(x) - y , x)
ValueError:
</code></pre>
</div>
<p>Absolute values cannot be inverted in the complex domain.</p>
<ul>
<li>
<p>In 1st case (for complex domain) ans should be <a href="http://www.wolframalpha.com/input/?i=Abs(x)+-+(1+)+%3D0+for+x">http://www.wolframalpha.com/input/?i=Abs(x)+-+(1+)+%3D0+for+x</a></p>
</li>
<li>
<p>In 2nd case EmptySet.
and in 3rd case (general solution when domain=S.Complexes) soln should be <a href="http://www.wolframalpha.com/input/?i=Abs(x)+-+y+%3D0+for+x">http://www.wolframalpha.com/input/?i=Abs(x)+-+y+%3D0+for+x</a></p>
</li>
<li>
<p>In general( 3rd case) it should print
ConditionSet(x, -Abs(re(y)) <= re(x) and re(x) <= Abs(re(y)) and re(y)>0, Eq(im(y), 0) , S.Complexes).</p>
</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>
<hr />http://sampadblog.wordpress.com/?p=1005GSoC Week 11Sampad Saha (sampadsaha5)Sat, 06 Aug 2016 12:59:00 GMT
https://sampadblog.wordpress.com/2016/08/06/gsoc-week-11/
<p>Hi there! It’s been eleven weeks into GSoC . The module for solving beam bending problems is almost ready. Now, I am focusing fully on example documentation part because it’s very important to let others know what can be done.</p>
<h4><em><strong>So Far</strong></em></h4>
<p>Let us see the capabilities:-</p>
<ul>
<li>Can create a beam object of certain length, second moment of area and modulus of elasticity. A symbol can also be passed for further uses.</li>
<li>Can apply loads using its value, start, end and order.</li>
<li>Can set boundary conditions for the beam.</li>
<li>Can find the load distribution function.</li>
<li>Can find the shear force function.</li>
<li>Can find the bending moment function.</li>
<li>Can find the slope function.</li>
<li>Can find the deflection function.</li>
<li>Can represent each of those function in the Piecewise form.</li>
<li>Can perform all sorts of mathematical operations on these functions.</li>
</ul>
<p>A full fledged documentation of tutorial and example for this module is on its way.</p>
<h4><em><strong>Next Week</strong></em></h4>
<ul>
<li>To complete documenting examples and tutorials.</li>
<li>Get <a href="https://github.com/sympy/sympy/pull/11374">PR 11374</a> merged.</li>
</ul>
<p>That’s all for now, looking forward for week 12.</p>
<p>Happy Coding.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/sampadblog.wordpress.com/1005/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sampadblog.wordpress.com/1005/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=sampadblog.wordpress.com&blog=102728326&post=1005&subd=sampadblog&ref=&feed=1" width="1" />http://jbm950.github.io//2016/08/05/GSoC-week-12.htmlGSoC Week 12James Milam (jbm950)Fri, 05 Aug 2016 00:00:00 GMT
http://jbm950.github.io//2016/08/05/GSoC-week-12.html
<p>This week my main work was on Featherstone’s articulated body algorithm. I
started by prototyping what I thought his algorith might look like in python
code (the algorithm was pulled from chapter 7 of his book). With the passes
prototyped it was apparent that I would need a full description of the
kinematic tree and so I prototyped the building of the kinematic tree from a
single “base” body. I then went on to see what it would look like if the
kinematic tree was built during the first pass of his articulated body
algorithm and decided that keeping the two separate would result in cleaner
code.</p>
<p>With the three passes prototyped and the kinematic tree built I started digging
into Featherstone’s book to better determine the definition of each of the
variables in the algorithm. While doing this I ended up reading a second source
where Featherstone describes the articulated body algorithm and it was helpful
in furthering my understanding of the algorithm as it was a condensed summary.
I then compared the written version of the algorith in his book and this
article with the two matlab versions he has posted online and the python
version her provides a link for online. This helped me see where some terms he
includes in his book he doesn’t include in his code. It also helped me to see
what code for the algorithm might look like.</p>
<p>After working on the mock up of the passes and trying to better understand
them, I switched focus to the joint code that needs to be finished so that it
can be used in my implementation of the articulated body algorithm. This has
lead to some confusion about the design decisions that were made in the past
when putting together the joint code and this is the current stage I am sitting
at as I await feedback on some of my questions.</p>
<p>This week I also looked over a couple of documentation PR’s. One was a simple
matter of fixing some indentation and seems mostly ready to merge but the
second turned some docstrings into raw strings so they could add latex math
code. I don’t know what the general stance is on the latter but I’m of the
opinion that the docstrings should be human readable since people may actually
look through the code for them or hope that help(function) provides something
useful. In this case the latex math code is cluttered and would be better off
in .rst files where people are only going to be reading the rendered version.
On that PR I am awaiting response from someone with sympy to see if this is
indeed prefered.</p>
<h3 id="future-directions">Future Directions</h3>
<p>Hopefully I’ll recieve some feedback about the joints and Featherstone’s method
so I can keep moving forward with these. In the mean time there are a few other
bits of code I will need to complete that the algorithm uses that is not
directly related to my questions. If I finish these tasks before recieving
feedback I will move forward with changing the joint code as I think would be
best.</p>
<h3 id="prs-and-issues">PR’s and Issues</h3>
<blockquote>
<ul>
<li>(Open) [WIP] Added system.py to physics/mechanics <a href="https://github.com/sympy/sympy/pull/11431">PR
#11431</a></li>
<li>(Open) Intendation fixes – sympy/concrete/summations.py <a href="https://github.com/sympy/sympy/pull/11473">PR
#11473</a></li>
<li>(Open) Adjustments to Legendre, Jacobi symbols docstrings <a href="https://github.com/sympy/sympy/pull/11474">PR
#11474</a></li>
<li>(Open) [WIP] FeatherstonesMethod <a href="https://github.com/sympy/sympy/pull/11415">PR
#11415</a></li>
</ul>
</blockquote>http://nishnik.github.io/GSoC-Tenth-WeekGSoC Tenth WeekNishant Nikhil (nishnik)Fri, 05 Aug 2016 00:00:00 GMT
http://nishnik.github.io/GSoC-Tenth-Week/
<p><img alt="Logo" src="https://summerofcode.withgoogle.com/static/img/summer-of-code-logo.svg" /></p>
<p>This week, I had been working on implementaion of <code class="highlighter-rouge">Union</code> and <code class="highlighter-rouge">Contains</code> in <a href="https://github.com/symengine/symengine/pull/1053">this</a> PR. <br />
Our <code class="highlighter-rouge">Set::contains</code> function has been changed from :</p>
<pre><code class="language-C++">virtual bool contains(const RCP<const Basic> &a) const = 0;
</code></pre>
<p>to</p>
<pre><code class="language-C++">virtual RCP<const Boolean> contains(const RCP<const Basic> &a) const = 0;
</code></pre>
<p>And these functions:</p>
<pre><code class="language-C++">virtual bool is_subset(const RCP<const Set> &o) const = 0;
virtual bool is_proper_subset(const RCP<const Set> &o) const = 0;
virtual bool is_superset(const RCP<const Set> &o) const = 0;
virtual bool is_proper_superset(const RCP<const Set> &o) const = 0;
</code></pre>
<p>have been changed to:</p>
<pre><code class="language-C++">bool is_subset(const RCP<const Set> &o) const
{
return eq(*this->set_intersection(o), *this);
}
bool is_proper_subset(const RCP<const Set> &o) const
{
return not eq(*this, *o) and this->is_subset(o);
}
bool is_superset(const RCP<const Set> &o) const
{
return o->is_subset(rcp_from_this_cast<const Set>());
}
bool is_proper_superset(const RCP<const Set> &o) const
{
return not eq(*this, *o) and this->is_superset(o);
}
</code></pre>
<p>depending solely on <code class="highlighter-rouge">set_intersection</code>.</p>
<p>Then the <code class="highlighter-rouge">SymEngine::set_union(const set_set &in, bool solve = true)</code> has been defined which will create a <code class="highlighter-rouge">Union</code> object with <code class="highlighter-rouge">in</code> if it is not solvable, or will do union operation on all of them.
<br />
Our <code class="highlighter-rouge">Union</code> class has <code class="highlighter-rouge">std::set</code> of <code class="highlighter-rouge">Set</code> to store the different Set containers which can’t be unified into one single container.
<br />
Apart from it, the <code class="highlighter-rouge">set_intersection</code> ans <code class="highlighter-rouge">set_union</code> virtual functions have been restructured to handle other <code class="highlighter-rouge">Set</code> types case by case.</p>http://shubhamtibra.wordpress.com/?p=780GSoC Week 10Subham Tibra (shubhamtibra)Mon, 01 Aug 2016 07:31:06 GMT
https://shubhamtibra.wordpress.com/2016/08/01/gsoc-week-10/
<p>Started off this week by continuing my work on <a href="https://github.com/sympy/sympy/pull/11422">#11422</a>. I added support for singular initial conditions in multiplication and made some amendments in addition too. They now can return a Holonomic function with singular initial condition. The input functions can have singular initial condition both or one of them can have singular one and the other one with ordinary initial condition.</p>
<pre class="brush: python; title: ; notranslate">
# one function have singular initial condition and the other have ordinary.
In [4]: expr_to_holonomic(x) + expr_to_holonomic(sqrt(x))
Out[4]: HolonomicFunction((1/2) + (-x/2)Dx + (x**2)Dx**2, x), {1/2: [1], 1: [1]}
In [5]: _4.to_expr()
Out[5]: √x + x
In [6]: expr_to_holonomic(x) * expr_to_holonomic(sqrt(x))
Out[6]: HolonomicFunction((-3/2) + (x)Dx, x), {3/2: [1]}
In [7]: _6.to_expr()
Out[7]:
3/2
x
# both have singular initial conditions.
In [9]: expr_to_holonomic((x)**(S(1)/3)) + expr_to_holonomic(sqrt(x))
Out[9]: HolonomicFunction((1/6) + (x/6)Dx + (x**2)Dx**2, x), {1/3: [1], 1/2: [1]}
In [10]: _9.to_expr()
Out[10]:
3 ___
╲╱ x + √x
In [11]: expr_to_holonomic((x)**(S(1)/3))*expr_to_holonomic(sqrt(x))
Out[11]: HolonomicFunction((-5/6) + (x)Dx, x), {5/6: [1]}
In [12]: _11.to_expr()
Out[12]:
5/6
x
</pre>
<p>I found some problems in coding because of storing these initial conditions in two different attributes. So I merged them to a single attribute and instead added methods to check which one is stored and refactored the existing code using it.</p>
<p>I opened a new PR <a href="https://github.com/sympy/sympy/pull/11451">#11451</a> majorly focused on adding singular initial conditions to the result of <code>.expr_to_holonomic()</code> when necessary. At first I added it in converting polynomials. Here are some examples:</p>
<pre class="brush: python; title: ; notranslate">
In [14]: expr_to_holonomic(3*x**3+4*x**2)
Out[14]: HolonomicFunction((-9*x - 8) + (3*x**2 + 4*x)Dx, x), {2: [4, 3]}
In [15]: _14.to_expr()
Out[15]:
2
x ⋅(3⋅x + 4)
In [16]: expr_to_holonomic(x)
Out[16]: HolonomicFunction((-1) + (x)Dx, x), {1: [1]}
In [17]: _16.to_expr()
Out[17]: x
</pre>
<p>I also a found a bug in <code>.to_hyper()</code> when the recurrence relation has order <code>0</code>. Added its fix too. Earlier the output also considered negative exponents which weren’t needed.</p>
<pre class="brush: python; title: ; notranslate">
# previously
In [18]: expr_to_holonomic(y*x, x).integrate(x).to_expr()
Out[18]:
2
x ⋅y
──── + C₁
2
# after fix
In [19]: expr_to_holonomic(y*x, x).integrate(x).to_expr()
Out[19]:
2
x ⋅y
────
2
</pre>
<p><strong>What Next:</p>
<p></strong>I hope to add singular initial conditions to more types of functions in <code>.expr_to_holonomic()</code>.<br />
</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/shubhamtibra.wordpress.com/780/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shubhamtibra.wordpress.com/780/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=shubhamtibra.wordpress.com&blog=106149936&post=780&subd=shubhamtibra&ref=&feed=1" width="1" />http://srajangarg.github.io//2016/08/01/Multivariate-PolynomailsMultivariate PolynomialsSrajan Garg (srajangarg)Mon, 01 Aug 2016 00:00:00 GMT
http://srajangarg.github.io//2016/08/01/Multivariate-Polynomails/
<h3 id="overview">Overview</h3>
<p>After college has started, work has been slower than usual. Last week I finally wound up Rational Polynomials in <a href="https://github.com/symengine/symengine/pull/1028">#1028</a>. Some minor changes still remain in some parts of the code. Most of the changes left are mainly related to code duplication, and will be fixed by writing their templated versions.</p>
<h3 id="multivariate-polynomials">Multivariate Polynomials</h3>
<p>I started off by reading and understanding how the multivariate class is implemented currently in SymEngine. It was developed by the UC Davis team as a part of their course project. The basic idea is pretty simple. It still is a sparse representation and maps from a vector (representing the powers of each generator in the monomial) to the non-zero coefficient multiplied to it. We use an unordered map instead of the ordered map used in the univariate counterpart. The choice does make some sense, as deciding order between two monomials is subjective and does not make sense (for eg. which is larger <code class="highlighter-rouge">x**2*y</code> or <code class="highlighter-rouge">x*y**2</code>) Even if we define a custom ordering, there are no real benefits I could think of that it would provide.</p>
<p>On a side note, it kind of makes me think why we have stuck to the ordered map implementation for our univariate polynomials. The places it offers benefits are <code class="highlighter-rouge">eval</code> and <code class="highlighter-rouge">mul</code> (in some ways) I worked with ordered maps, as that was the implementation the initial polynomial class was built on. I’m also wondering if it is healthy to use two different implementations for both the polynomial types, univariate and multivariate. This needs to be discussed.</p>
<p>Right now, I’m basically refactoring most of the code written in the multivariate class, so that it matches the API more or less from the univariate case. Some functions have been re-written and some unnecessary storage within the polynomials have been removed. Initially, I thought I will stick with the same container based approach I used in the univariate case. This proves to be non trivial for the multivariate case. So, after some discussion with Isuru, we decided to stick with different implementations for SymEngine polynomials and Piranha polynomials, as combining code was not easy. The current work is in <a href="https://github.com/symengine/symengine/pull/1049">#1049</a></p>
<h3 id="future-work">Future Work</h3>
<p>A lot is on my plate right now. Some of the work I plan to finish by the end of the next two weeks are</p>
<ul>
<li>
<p>Finish up the refactoring of multivariate polynomials, and make their interaction with univariate polynomials as seamless as possible</p>
</li>
<li>
<p>Introduce wrappers for piranha polynomials to be used as multivariate polynomials within SymEngine</p>
</li>
<li>
<p>Fix up the remainder of rational polynomials, and template code wherever possible to remove code duplicates</p>
</li>
<li>
<p>Write conversions from <code class="highlighter-rouge">Basic</code> to multivariate polynomials, which will finish up one part of the coercion framework as proposed by Isuru</p>
</li>
</ul>
<p>Off to work!</p>http://shekharrajak.github.io/Coding-Period-week-10Coding Period Week 10Shekhar Prasad Rajak (shekharrajak)Sat, 30 Jul 2016 00:00:00 GMT
http://shekharrajak.github.io/Coding-Period-week-10/
<hr />
<p><strong>eliminate() continue:</strong></p>
<ul>
<li>
<p>issue <a href="https://github.com/sympy/sympy/issues/2720">#2720</a> : We need some kind of eliminate function, like <a href="http://reference.wolfram.com/mathematica/ref/Eliminate.html">http://reference.wolfram.com/mathematica/ref/Eliminate.html</a>. See also <a href="http://stackoverflow.com/q/20826969/161801">http://stackoverflow.com/q/20826969/161801 </a></p>
</li>
<li>
<p>I am trying to use <code class="highlighter-rouge">subs</code> and <code class="highlighter-rouge">_invert</code> to get answer. May be one can use <code class="highlighter-rouge">replace</code>, <code class="highlighter-rouge">xreplace</code>, <code class="highlighter-rouge">match</code> to eliminate some kind of same sub expression.</p>
</li>
<li>
<p>There can be ans in <code class="highlighter-rouge">Imageset</code>, <code class="highlighter-rouge">Finiteset</code>, <code class="highlighter-rouge">Complement</code>, <code class="highlighter-rouge">Intersection</code> when we use <code class="highlighter-rouge">_invert</code>. So there should be a technique to handle it.</p>
</li>
<li>
<p>Still need some good idea and technique. WIP.</p>
</li>
</ul>
<hr />
<p><strong>Output of solveset should be of one type:</strong></p>
<ul>
<li>
<p>Amit discussed about it. Solution we see in <code class="highlighter-rouge">solveset</code> should be in one type of set. Right now we may have solution in <code class="highlighter-rouge">Imageset</code>, <code class="highlighter-rouge">Finiteset</code>, <code class="highlighter-rouge">Complement</code>, <code class="highlighter-rouge">Intersection</code> or <code class="highlighter-rouge">ConditionSet</code>. So there would be problem for user to handle these many solution type.</p>
</li>
<li>
<p>I think there should be something that separate <code class="highlighter-rouge">Complements</code>, <code class="highlighter-rouge">Intersections</code>,<code class="highlighter-rouge">ConditionSet</code> and main solution in <code class="highlighter-rouge">Finiteset</code>.</p>
</li>
<li>
<p>E.g. if solveset solution is <code class="highlighter-rouge">Intersection(Complement(FiniteSet(x), {y}), {z})</code> then
soln : <code class="highlighter-rouge">FiniteSet(x)</code>, <code class="highlighter-rouge">x != {y}</code>, <code class="highlighter-rouge"><span class="p">{</span><span class="err">x</span><span class="p">}</span><span class="w"> </span><span class="err">intersect</span><span class="w"> </span><span class="p">{</span><span class="err">z</span><span class="p">}</span></code>.</p>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<ul>
<li>
<p>According to the <a href="https://github.com/sympy/sympy/pull/11188#issuecomment-234789616">Harsh comments/review</a> I modified the PR. Now it seems it is
returning more simplified solution( <a href="https://github.com/sympy/sympy/pull/11188/commits/beaac312f03819bd7221887eb2b4cbe5d49bed5e#diff-85baa04bbf4e1dfd9128782738e45424R1141">one case is here</a>) .</p>
</li>
<li>
<p>To understand the changes I did in the <code class="highlighter-rouge">_solve_trig</code> method, one should check <a href="https://gist.github.com/Shekharrajak/17fdcd2320f572fc9fc8674823137e20">this gist</a></p>
</li>
<li>
<p>To see the advantage of imageset union, One good example is in <a href="https://gist.github.com/Shekharrajak/a5efc840d9a7d3062289f2d9c5f20b16">this gist</a></p>
</li>
</ul>
<hr />
<p><strong><em>continue</em></strong></p>http://sampadblog.wordpress.com/?p=985GSoC Week 10Sampad Saha (sampadsaha5)Fri, 29 Jul 2016 11:20:44 GMT
https://sampadblog.wordpress.com/2016/07/29/gsoc-week-10/
<p>Hello, guys. Welcome back. It’s been ten weeks into the coding period. I had a meeting with Jason on 25th of this month. We discussed many new changed on the API that I had implemented before this week. Now, the beam bending module is almost ready to solve beam bending problems.</p>
<p>Let us see how to solve a beam bending problem using this module.</p>
<p>Problem Statement :</p>
<p><img alt="Loaded beam.svg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Loaded_beam.svg/650px-Loaded_beam.svg.png" /></p>
<p>The deflection is restricted at the end of the beam.</p>
<p>Solution :</p>
<pre><code>>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import Symbol, Piecewise
>>> x = Symbol('x')
>>> E = Symbol('E')
>>> I = Symbol('I')
>>> b = Beam(4, E, I)
>>> b.apply_load(value=-9, start=4, order=-1)
>>> b.apply_load(value=-3, start=0, order=-1)
>>> b.apply_load(order=0, start=2, value=6)
>>> b.bc_deflection = [(4, 0)]
>>> b.boundary_conditions
{'deflection': [(4, 0)], 'moment': [], 'slope': []}
>>> b.load
-3*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 2, 0) - 9*SingularityFunction(x, 4, -1)
>>> b.shear_force()
-3*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 2, 1) - 9*SingularityFunction(x, 4, 0)
>>> b.bending_moment()
3*SingularityFunction(x, 0, 1) - 3*SingularityFunction(x, 2, 2) + 9*SingularityFunction(x, 4, 1)
>>> b.slope()
(3*SingularityFunction(x, 0, 2)/2 - SingularityFunction(x, 2, 3) + 9*SingularityFunction(x, 4, 2)/2 - 7)/(E*I)
>>> b.deflection()
(-7*x + SingularityFunction(x, 0, 3)/2 - SingularityFunction(x, 2, 4)/4 + 3*SingularityFunction(x, 4, 3)/2)/(E*I)
</code></pre>
<p>If the user wants to represent the deflection in the piecewise form, then:</p>
<pre><code>>>> b.deflection().rewrite(Piecewise)
(-7*x + Piecewise((x**3, x > 0), (0, True))/2
+ 3*Piecewise(((x - 4)**3, x - 4 > 0), (0, True))/2
- Piecewise(((x - 2)**4, x - 2 > 0), (0, True))/4)/(E*I)
</code></pre>
<p> </p>
<h4><em><strong>Next week </strong></em></h4>
<ul>
<li>Add the end argument in the apply_load method.</li>
<li>Add Sphinx documentations.</li>
</ul>
<p>That’s all for this week. Cheers !!</p>
<p>Happy Coding.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/sampadblog.wordpress.com/985/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sampadblog.wordpress.com/985/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=sampadblog.wordpress.com&blog=102728326&post=985&subd=sampadblog&ref=&feed=1" width="1" />http://jbm950.github.io//2016/07/29/GSoC-week-11.htmlGSoC Week 11James Milam (jbm950)Fri, 29 Jul 2016 00:00:00 GMT
http://jbm950.github.io//2016/07/29/GSoC-week-11.html
<p>Somehow I think I was off by a week. I think last week’s blog post covers week
9 and 10 and this week’s covers week 11. This week I created a full draft for
all components of the <code class="highlighter-rouge">SymbolicSystem</code> class that will take the place of a
equations of motion generator “base class” that was discussed in my project
proposal. I began by creating all of the docstrings for the class followed by
the test code. With the documentation and test code written it was a simple
matter to finish off the code for the class itself. Lastly I added
documentation to two places in sympy, one place contains the autogenerated
documentation from the docstrings and the other place I adapted an example from
pydy to show how to use the new class.</p>
<p>After working on <code class="highlighter-rouge">SymbolicSystem</code> I decided to try to finish off an old PR of
mine regarding the init_printing code that Jason and I had discussed at Scipy.
The idea was to build separate dictionaries to pass to the different printers
in ipython based on the parameters that the specific printers take. The idea
was to find this information using inspect.getargs(). The problem arose when
trying to implement this solution because each separate printer has an expr
argument and a **settings argument and the different possible paramters are
processed internally by the printer. This means that there would not be an
elegant way to build dictionaries for each printer.</p>
<p>The next thing I worked on this week was looking into Jain’s version of the
order(N) method as suggested last week. When I started looking over his book,
however, I found that uses a rather different set of notion than Featherstone
and had some additional terms. I have decided to move forward with
Featherstone’s method due to the summer coming to an end and I am already
familiar with his version of the method. To that end I reread the first part of
chapter 7 in Featherstone’s book where he discusses the articulated body
method.</p>
<p>I reviewed two PR’s this week. This work was rather quick as they were simply
documentation additions. I verified the method docstrings matched what the
mehtod actually does and that the modual docstring included the different
functions present in the file. Determining that they were correct I gave the +1
to merge and they have both since been merged.</p>
<h3 id="future-directions">Future Directions</h3>
<p>The plan for next week is to focus entirely on the order(N) articulated body
method of forming the equations of motion. I plan on writing the three passes
for the method as if I have all of the information and methods I need in order
to make it work. I expect this to be the best way to determine what additional
code I will need in addition to finding my weak points in how well I understand
the method. Once I have a skeleton of the of how the algorithm is supposed to
work I will stop working directly on the algorithm itself and start working on
the peripheral code such as the joints and body code or spatial vector
processing methods.</p>
<h3 id="prs-and-issues">PR’s and Issues</h3>
<blockquote>
<ul>
<li>(Open) [WIP] Added system.py to physics/mechanics <a href="https://github.com/sympy/sympy/pull/11431">PR
#11431</a></li>
<li>(Merged) Added docstrings to delta and mid property methods <a href="https://github.com/sympy/sympy/pull/11432">PR
#11432</a></li>
<li>(Merged) Added top-level docstring for singularities.py <a href="https://github.com/sympy/sympy/pull/11440">PR
#11440</a></li>
</ul>
</blockquote>http://nishnik.github.io/GSoC-Ninth-WeekGSoC Ninth WeekNishant Nikhil (nishnik)Thu, 28 Jul 2016 00:00:00 GMT
http://nishnik.github.io/GSoC-Ninth-Week/
<p><img alt="Logo" src="https://summerofcode.withgoogle.com/static/img/summer-of-code-logo.svg" /></p>
<p>Previous week I had implemented the <strong>Shoup’s Algorithm</strong> in <a href="https://github.com/symengine/symengine/pull/1045">this</a> PR. During the review we came to realise that it is better to use <code class="highlighter-rouge">unsigned int</code> instead of <code class="highlighter-rouge">integer_class</code> because we didn’t need big numbers.
<br /><br />
Working on the same PR, I found a bug in <code class="highlighter-rouge">negate</code> and similar function where we were doing:</p>
<pre><code class="language-C++">for (auto &a : dict_) {
a *= -1;
a += modulo_;
</code></pre>
<p>Here: if the <code class="highlighter-rouge">dict_</code> is <code class="highlighter-rouge">[0, 0, 10]</code>, it will negate to <code class="highlighter-rouge">[11, 11, 1]</code> in <code class="highlighter-rouge">GF(11)</code>. So, it was needed to add a check when the value is <code class="highlighter-rouge">0</code>. So, the method was changed to:</p>
<pre><code class="language-C++">for (auto &a : dict_) {
a *= -1;
if (a != 0_z)
a += modulo_;
}
</code></pre>
<p><br />
Along with it I was working on the <code class="highlighter-rouge">gf_factor</code> <a href="https://github.com/symengine/symengine/pull/1036">PR</a> and it eventually got merged. It introduced <strong>Zassenhaus’s algorithm</strong> and <code class="highlighter-rouge">gf_factor()</code> function. In coming days, we will have to change <code class="highlighter-rouge">gf_factor</code> to switch between <code class="highlighter-rouge">gf_zassenhaus</code> and <code class="highlighter-rouge">gf_shoup</code> according to the degree of polynomial.
<br /><br />
We made one more design change, we changed the factor container from <code class="highlighter-rouge">std::pair<GaloisFieldDict, integer_class></code> to <code class="highlighter-rouge">std::pair<GaloisFieldDict, unsigned></code> because we didn’t need large numbers as power.
<br /><br />
Then I started working on change of base class of <code class="highlighter-rouge">GaloisField</code> class from <code class="highlighter-rouge">UPolyBase</code> to <code class="highlighter-rouge">UIntPolyBase</code>, this needed implementation of <code class="highlighter-rouge">eval</code> and <code class="highlighter-rouge">multi_eval</code> method, then I implemented the iterator for <code class="highlighter-rouge">GaloisField</code> class and the <code class="highlighter-rouge">pow</code> method. The <a href="https://github.com/symengine/symengine/pull/1047/files">PR</a> is under review.</p>http://shubhamtibra.wordpress.com/?p=663GSoC Week 8 and 9Subham Tibra (shubhamtibra)Sun, 24 Jul 2016 18:28:08 GMT
https://shubhamtibra.wordpress.com/2016/07/24/gsoc-week-8-and-9/
<p>I couldn’t write a blog post last week so including progress of week 8 and 9 both here.</p>
<h1><strong>Week 8</strong></h1>
<p>I continued working on the PR <a href="https://github.com/sympy/sympy/pull/11360">#11360</a>. We added functionality to store a different type of initial condition for regular singular points other than the usual <code>[y(0), y'(0), ...]</code>. The exact format is described <a href="https://github.com/sympy/sympy/blob/master/sympy/holonomic/holonomic.py#L354">here</a> in master, though it is changed to a more elegant form in <a href="https://github.com/sympy/sympy/pull/11422">#11422</a>. This type of initial condition provides more information at regular singular points and is helpful in converting to expressions. Examples on how to use it:</p>
<pre class="brush: python; title: ; notranslate">
In [22]: expr_to_holonomic(sin(x)/x**2, singular_ics={-1: [1, 0, -1]}).to_expr()
Out[22]:
sin(x)
──────
2
x
</pre>
<p>I also added method to compute this type of initial condition for algebraic functions of the form <code>P^r</code>, for some Polynomial <code>P</code> and a Rational Number <code>R</code>.</p>
<pre class="brush: python; title: ; notranslate">
In [25]: expr_to_holonomic(sqrt(x**2+x))
Out[25]: HolonomicFunction((-x - 1/2) + (x**2 + x)Dx, x), {1/2: [1]}
In [26]: _25.to_expr()
Out[26]:
_______
√x⋅╲╱ x + 1
</pre>
<p>After that I made some changes in `to_meijerg()` to return the polynomial itself if the `meijerg` function represents a polynomial instead of raising `NotImplementedError`.</p>
<pre class="brush: python; title: ; notranslate">
In [40]: expr_to_holonomic(4*x**3 + 2*x**2, lenics=3).to_meijerg().expand()
Out[40]:
3 2
4⋅x + 2⋅x
</pre>
<p>I also added code to return the general solution in `_frobenius()` if none of the roots of indicial equation differ by an integer.</p>
<h1>Week 9</h1>
<p>I wasn’t able to do much this week because my college started. I travelled back and had some college related stuff to do.</p>
<p>I opened <a href="https://github.com/sympy/sympy/pull/11422">#11422</a> and first added a basic method to determine the domain for polynomial coefficients in the differential equation.</p>
<pre class="brush: python; title: ; notranslate">
In [77]: expr_to_holonomic(sqrt(y*x+z), x=x, lenics=2).to_expr()
Out[77]:
_________
╲╱ x⋅y + z
In [78]: expr_to_holonomic(1.1329138213*x)
Out[78]: HolonomicFunction((-1.1329138213) + (1.1329138213*x)Dx, x), f(0) = 0
</pre>
<p>Then I added support for the new type of initial condition on regular singular points in <code>.integrate()</code>.</p>
<pre class="brush: python; title: ; notranslate">
In [83]: expr_to_holonomic(sin(x)/x**3, singular_ics={-2: [1, 0, -1]}).integrate(x).to_expr()
Out[83]:
⎛ 2 ⎞
-⎝x ⋅Si(x) + x⋅cos(x) + sin(x)⎠
────────────────────────────────
2
2⋅x
</pre>
<p>Also added support for the same in addition.</p>
<pre class="brush: python; title: ; notranslate">
In [6]: expr_to_holonomic(sqrt(x)) + expr_to_holonomic(sqrt(2*x))
Out[6]: HolonomicFunction((-1/2) + (x)Dx, x), {1/2: [1 + sqrt(2)]}
In [7]: _6.to_expr()
Out[7]: √x⋅(1 + √2)
</pre>
<p>I plan to continue my work on this PR and add more support for this initial condition.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/shubhamtibra.wordpress.com/663/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shubhamtibra.wordpress.com/663/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=shubhamtibra.wordpress.com&blog=106149936&post=663&subd=shubhamtibra&ref=&feed=1" width="1" />http://rajithsays.wordpress.com/?p=416GSoC Week 9 ProgressRajith Vidanaarachchi (rajithv)Sun, 24 Jul 2016 18:26:27 GMT
https://rajithsays.wordpress.com/2016/07/24/gsoc-week-9-progress/
<p>In the <a href="https://rajithsays.wordpress.com/2016/07/16/gsoc-week-8-progress/">last blog post</a> I reported that lambdify function was fully wrapped. Yes, that’s what I thought at the time! But it did indeed dragged on quite a bit, requiring many changes, which were very educative for me in terms of how Ruby looks at user experience. Several changes were done, including structural changes on calling lambdify, and for supporting older Ruby versions. The really interesting and long discussions on this can be viewed in the <a href="https://github.com/symengine/symengine.rb/pull/61" target="_blank">PR 61</a>.</p>
<p>Apart from that, simultaneously I started reading and exchanging ideas on exception handling. It was agreed that in the C wrappers, an error code to be returned, which can be accessed from the Ruby wrapper, which in turn can raise a Ruby exception. The preliminary model can be seen in <a href="https://github.com/symengine/symengine/pull/1044" target="_blank">PR 1044</a> in SymEngine and <a href="https://github.com/symengine/symengine.rb/pull/64" target="_blank">PR 64</a> in SymEngine Ruby wrapper.</p>
<p>Right now any exception is caught and sent to the Ruby Wrapper with an error code of -1, which raises a generic Runtime Error in Ruby. Although not very informative, this is helpful in prevention of crashing the Ruby runtime.</p>
<p>To illustrate, when the following code (a division by zero) is run before and after is shown.</p>
<p>Before:</p>
<pre>irb(main):001:0> require 'symengine'
=> true
irb(main):002:0> x = SymEngine(1)
=> #<SymEngine::Integer(1)>
irb(main):003:0> y = SymEngine(0)
=> #<SymEngine::Integer(0)>
irb(main):004:0> x/y
terminate called after throwing an instance of 'Teuchos::NullReferenceError'
  what():  /home/rajith/Development/symengine/symengine/utilities/teuchos/Teuchos_RCPNode.cpp:720:
Throw number = 1
Throw test that evaluated to true: true
Teuchos::RCP<SymEngine::Basic const> : You can not call operator->() or operator*() if getRawPtr()==0!
Abort caught. Printing stacktrace:
Traceback (most recent call last):
Done.
[2]    590 abort (core dumped)  irb</pre>
<p>After:</p>
<pre>irb(main):001:0> require 'symengine'
=> true
irb(main):002:0> x = SymEngine(1)
=> #<SymEngine::Integer(1)>
irb(main):003:0> y = SymEngine(0)
=> #<SymEngine::Integer(0)>
irb(main):004:0> x/y
RuntimeError: Runtime Error
    from (irb):4:in `/'
    from (irb):4
    from /usr/bin/irb:11:in `<main>'
irb(main):005:0></pre>
<p>This is a good improvement overall, but as it’s nicer to have a more descriptive error shown to the user, that part will be the continuation of exception handling during the 10th week.</p>
<p>See you next week!</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/rajithsays.wordpress.com/416/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rajithsays.wordpress.com/416/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=rajithsays.wordpress.com&blog=110498904&post=416&subd=rajithsays&ref=&feed=1" width="1" />http://srajangarg.github.io//2016/07/23/Rational-Polynomials-ft-BugsRational Polynomials ft. BugsSrajan Garg (srajangarg)Sat, 23 Jul 2016 00:00:00 GMT
http://srajangarg.github.io//2016/07/23/Rational-Polynomials-ft-Bugs/
<h3 id="overview">Overview</h3>
<p>Sorry I haven’t been able to report my work for about two weeks now. Things have become slower mainly due to the fact that my university has resumed and along with it a heavily packed timetable and assignments in the first week don’t help. I also caught a bad fever the past week which really hindered my progress, but it’s dying down and I will resume my work with full vigor eventually.</p>
<p>The work I did do has been summarized below.</p>
<h3 id="bug-fixes">Bug Fixes</h3>
<p>While writing the code for the rational polynomials, as mentioned in the last blogpost, I encountered various bugs. Some of them caused other bugs to be exposed, which took a lot of time for me to debug.</p>
<ul>
<li>
<p><code class="highlighter-rouge">pow(Poly, uint)</code> was throwing a segmentation fault. After digging in and wasting more than four hours on unrelated checks I figured out that the <code class="highlighter-rouge">eq</code> inside the polynomial class was incorrect. Without checking whether the other parameter was a <code class="highlighter-rouge">Poly</code> or not, I was <code class="highlighter-rouge">static_cast</code>ing it which posed a problem.</p>
</li>
<li>
<p>The happiness was shortlived, as the bug persisted. On further inspection I found that the polynomial was being treated as a number! This was because <code class="highlighter-rouge">is_a_Number</code> relied on typecodes, and the polynomial types were defined before the <code class="highlighter-rouge">NUMBERWRAPPER</code> class, which deemed them numbers. The fix for this was simple, just move the polynomial type code definitions after the numbers.</p>
</li>
<li>
<p>The <code class="highlighter-rouge">pow</code> tests pass, but what’s this? All the <code class="highlighter-rouge">MSVC</code> builds on appveyor fail. They all fail a <code class="highlighter-rouge">coeff</code> test. Wow, I had not changed any code related to <code class="highlighter-rouge">coeff</code> at all, how does it affect that specific test and only on the <code class="highlighter-rouge">MSVC</code> compiler? This kept me wondering and looking at the source for a day. Finally, I had to login to the VM of appveyor running the tests. I was not familiar with windows development environment at all, which was the reason I failed a couple of times before I gave up debugging. The next morning I woke up determined to fix this Windows bug, I set the break points in Visual Studio and started the code execution. I found it! It was a bug in the <code class="highlighter-rouge">CoeffVisitor</code> itself. The code for the <code class="highlighter-rouge">coeff</code> function was incomplete. Why wasn’t this bug being captured before? Probably because the previous change (in the typecodes) caused a reordering in a map, which no other compiler was doing. Do read up <a href="https://github.com/symengine/symengine/pull/1033#issuecomment-232973025">here</a> for more details.</p>
</li>
<li>
<p>An appveyor build was failing for unknown reason, which had to be shifted to allowed failures</p>
</li>
</ul>
<p>This was basically the components of <a href="https://github.com/symengine/symengine/pull/1033">#1033</a>. Less quantity of changes, but really important none the less.</p>
<h3 id="rational-polynomials">Rational Polynomials</h3>
<p>The work with rational polynomials continues. I had underestimated the amount of work required, and I also feel that I should have broken down rational polynomials into three parts each, just like integer polynomials. Right now, the work continues in <a href="https://github.com/symengine/symengine/pull/1028">#1028</a>, but it’s soon going to become huge with all varieties of changes.</p>
<h3 id="miscellaneous">Miscellaneous</h3>
<p>I finally benchmarked <a href="https://github.com/sakra/cotire">cotire</a> to see how much speedup it was providing to SymEngine builds. <a href="https://github.com/symengine/symengine/issues/1023">Here</a> is the short summary of the speedups obtained, and the work to include it is in <a href="https://github.com/symengine/symengine/pull/1041">#1041</a>.</p>
<p>Also a small bug was present in our flint and gmp rational number wrappers. We were not canonicalizing on construction from two integers. It was fixed in <a href="https://github.com/symengine/symengine/pull/1031">#1031</a>.</p>
<p>Laters!</p>http://sampadblog.wordpress.com/?p=942GSoC Week 9Sampad Saha (sampadsaha5)Fri, 22 Jul 2016 19:48:05 GMT
https://sampadblog.wordpress.com/2016/07/22/gsoc-week-9/
<p>Hello, guys. Welcome back. It’s been nine weeks into the coding period. I had a meeting with Jason on 17<sup>th </sup> of this month. He was attending the code sprints at Scipy and I am very glad to meet other Sympy developers.</p>
<h4><em><strong>So Far</strong></em></h4>
<ul>
<li>I have closed the PR <a href="https://github.com/sympy/sympy/pull/11266">11266</a>.</li>
<li>In PR <a href="https://github.com/sympy/sympy/pull/11374">11374</a>, I have removed the use of mechanics Point.</li>
<li>I have made boundary_conditions as property and the inputs are no longer as **kwargs. Each of the inputs namely moment, slope and deflection are initiated as an empty list. But I have some doubts regarding the behaviour of this method. I feel that this should be used only in the case when a full new set of boundary conditions are given as input. Since to input dynamically, there exists some methods already which would handle each of the cases explicitly. Those methods appends the new inputs whereas this method would delete the existing boundary conditions and apply the newer one. This way the property of being mutable would remain.</li>
<li>Replaced the solve function by linsolve. Since solve is going to be depreciated in the mear future.</li>
<li>I have added the docstrings for slope and deflection method as well as for the beam class.</li>
<li>In deflection method, I have added a new case where if there is no slope boundary condition but there is deflection boundary conditions, it would give operate.</li>
</ul>
<h4><em><strong>Next Week</strong></em></h4>
<ul>
<li>I will be working on adding a documentation file for this beam bending problem module exclusively.</li>
<li>Add some more test for checking the corner cases.</li>
</ul>
<p>That’s all for this week. Cheers !!</p>
<p>Happy Coding.</p><br /> <a href="http://feeds.wordpress.com/1.0/gocomments/sampadblog.wordpress.com/942/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sampadblog.wordpress.com/942/" /></a> <img alt="" border="0" height="1" src="https://pixel.wp.com/b.gif?host=sampadblog.wordpress.com&blog=102728326&post=942&subd=sampadblog&ref=&feed=1" width="1" />http://jbm950.github.io//2016/07/22/GSoC-week-8-9.htmlGSoC Week 8 & 9James Milam (jbm950)Fri, 22 Jul 2016 00:00:00 GMT
http://jbm950.github.io//2016/07/22/GSoC-week-8-9.html
<p>Last week I did not end up writing a blog post and so I am combining that
week’s post with this week. Last week I attended the SciPy 2016 conference and
was able to meet my mentor, and many other contributers to SymPy, in person. I
was also able to help out with the Pydy tutorial. During this time at the
conference (and this current week) I was able to flesh out the remaining
details on the different portions of the project. I have updated <a href="https://github.com/pydy/pydy/pull/353">PR
#353</a> to reflect the api decisions for
SymbolicSystem (previously eombase.EOM).</p>
<p>In line with trying to put the finishing touches on implementation details
before diving in to code, Jason and I met with someone who has actually
implemented the algorithm in the past to help us with details surrounding
Featherstone’s method. He also pointed me to a different description of the
same algorithm that may be easier to implement.</p>
<p>This week I also worked on rewriting the docstrings in
physics/mechanics/body.py because I found the docstrings currently there to be
somewhat confusing. I also did a review on one of Jason’s PR’s where he reduces
the amount of work that *method.rhs() has to do when inverting the mass matrix
by pulling out the kinematical information before the inversion takes place.</p>
<h3 id="future-directions">Future Directions</h3>
<p>With the work these past two weeks being focused on implementing the different
parts of the projects, I will start implementing these various parts next week.
I will first work on finishing off the SymbolicSystem object and then move
towards implementing the OrderNMethod. This work should be very straight
forward with all the work that has been put into planning the api’s.</p>
<h3 id="prs-and-issues">PR’s and Issues</h3>
<blockquote>
<ul>
<li>(Merged) Speeds up the linear system solve in KanesMethod.rhs() <a href="https://github.com/sympy/sympy/pull/10965">PR
#10965</a></li>
<li>(Open) Docstring cleanup of physics/mechanics/body.py <a href="https://github.com/sympy/sympy/pull/11416">PR
#11416</a></li>
<li>(Open) [WIP] Created a basis on which to discuss EOM class <a href="https://github.com/pydy/pydy/pull/353">PR
#353</a></li>
</ul>
</blockquote>