Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rcode #11973

Merged
merged 24 commits into from
Jan 18, 2017
Merged

Rcode #11973

merged 24 commits into from
Jan 18, 2017

Conversation

mamueller
Copy link
Contributor

I implemented an Rcode printer. I basically copied the ccode printer along with its tests and adapted both to produce valid R code from symy expressions. I do not know about any problems.
I have been using part of the functionality to check numerical solutions of an R package against symbolic solutions computed with sympy and then translated to R code automatically.

@@ -230,7 +230,8 @@ def order(self):

def doprint(self, expr):
"""Returns printer's representation for expr (as a string)"""
return self._str(self._print(expr))
res=self._str(self._print(expr))
return res
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just a leftover of "print debugging..." I removed the print but forgot to inline it again, I will do it now along with the removal of the white space that I forgot as well..

# Unknown object, fall back to the emptyPrinter.
return self.emptyPrinter(expr)
res=self.emptyPrinter(expr)
return res
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason for this change either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above...

@moorepants
Copy link
Member

This is great! Thanks so much for this addition.

A few things need to be fixed:

Other than, that I think this is looking great!

@mamueller
Copy link
Contributor Author

mamueller commented Dec 24, 2016

Coverage report: 77% Show keyboard shortcuts
Module statements missing excluded coverage
Total 118475 26949 742 77%
...
sympy/printing/rcode.py 151 49 1 68%
...
coverage.py v4.2, created at 2016-12-24 01:00

@mamueller
Copy link
Contributor Author

mamueller commented Dec 24, 2016 via email

@moorepants
Copy link
Member

The key one is this:

sympy/printing/rcode.py 151 49 1 68%

Which is better than average for the code printers. That's fine for now I suppose, but it would be nice to increase the test coverage.


return getattr(self, printmethod)(expr, *args, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be fixed.

class RCodePrinter(CodePrinter):
"""A printer to convert python expressions to strings of c code"""
printmethod = "_rcode"
language = "C"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines still have references to C.

@moorepants moorepants added the PR: author's turn The PR has been reviewed and the author needs to submit more changes. label Dec 26, 2016
@mamueller
Copy link
Contributor Author

mamueller commented Jan 10, 2017

I think that I have addressed all issues by now.
In my python 3.5 environment also the ./bin/test and ./bin/doctest yield no errors. So I wonder why the travis build has this remaining issue, (which I was not able to reproduce in my python 3.5.2 virtualenv)
I am not yet very familiar with the sympy pullrequest process but I suspect that the author's turn label could be removed now.
Thanks for your time

@bjodah bjodah removed the PR: author's turn The PR has been reviewed and the author needs to submit more changes. label Jan 18, 2017
@bjodah
Copy link
Member

bjodah commented Jan 18, 2017

I restarted the failed test on travis and it passes.
Thank you @mamueller for this contribution - it looks good, although I don't really know R, let's merge this now and iterate on it later if needed.

@bjodah bjodah merged commit 8b3fcd8 into sympy:master Jan 18, 2017
@mamueller
Copy link
Contributor Author

Thanks a lot.
I am happy that it worked out.
Cheers
Markus

@mamueller mamueller deleted the Rcode branch January 3, 2019 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants