Skip to content

Add complex.{__abs__, __eq__, __neg__} #410

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

Merged
merged 6 commits into from
Feb 10, 2019

Conversation

OddCoincidence
Copy link
Contributor

The former required the addition of the NotImplemented constant to match cpython`s behavior.

@cthulahoops
Copy link
Collaborator

Can we test these using idiomatic python rather than calling the magic methods directly:

Eg:

assert abs(complex(3, 4)) == 5
assert complex(3, 4) == complex(3, 4)

etc?

@windelbouwman
Copy link
Contributor

@cthulahoops I agree, this is cleaner testcode. It will invoke the magic method at some point in time.

@@ -130,6 +130,7 @@ pub struct PyContext {
pub map_type: PyObjectRef,
pub memoryview_type: PyObjectRef,
pub none: PyObjectRef,
pub not_implemented: PyObjectRef,
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, I cannot be believe we did not implement this yet ;)

@OddCoincidence OddCoincidence changed the title Add complex.{__eq__, __neg__} Add complex.{__abs__, __eq__, __neg__} Feb 9, 2019
@OddCoincidence
Copy link
Contributor Author

Thanks to @cthulahoops's suggestion, I think I found a subtle bug in the way the binary magic methods currently are implemented. Filed as #419. I will work around it here, and fix this in another PR.

@cthulahoops
Copy link
Collaborator

Looks ready to merge, but has conflicts to resolve.

@windelbouwman
Copy link
Contributor

I resolved the conflict.

@windelbouwman windelbouwman merged commit 03a2aad into RustPython:master Feb 10, 2019
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