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

Correct function def of gray_to_bin and bin_to_gray #14468

Merged
merged 5 commits into from
Mar 13, 2018

Conversation

Malkhan52
Copy link
Contributor

Hello everyone!
This is my first commit to sympy.
I corrected definition of two functions named bin_to_gray and gray_to_bin.
There is an issue #117 in sympy-live repo but I checked same was because of sympy, so I send PR here.
I have tested with some examples.

>>> from sympy.combinatorics.graycode import gray_to_bin
>>> gray_to_bin('100')
'111'

example taken from issue #117 from:- https://github.com/sympy/sympy-live/issues/117
Copy link
Member

@smichr smichr Mar 10, 2018

Choose a reason for hiding this comment

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

The test_graycode file would be a good place for this.

def test_live_issue_117():
    assert bin_to_gray('0100') == '0110'
    assert bin_to_gray('0101') == '0111'
    for bits in ('0100', '0101'):
        assert gray_to_bin(bin_to_gray(bits)) == bits

These were confirmed with online calculator.

Note: in one test you spelled gray as gtay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing.
& sorry for that typo.

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to put a reference to the issue in the docstring. Putting it in the commit message is sufficient for provenance.

Malkhan52 and others added 3 commits March 11, 2018 09:37
Examples are included in the test suite.
Add newline.

Note: doctests taken from issue at sympy/sympy-live#117
@smichr
Copy link
Member

smichr commented Mar 13, 2018

There were some PEP8 issues that I corrected: a line with space and a file with no newline at the end. I also removed the docstring tests that were essentially duplicated in the test suite.

@smichr smichr merged commit daae269 into sympy:master Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants