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

Add support for bitwise NOT operator #18

Merged
merged 4 commits into from Jun 28, 2022
Merged

Add support for bitwise NOT operator #18

merged 4 commits into from Jun 28, 2022

Conversation

IoIxD
Copy link
Contributor

@IoIxD IoIxD commented Jun 23, 2022

Python has ~0x3, which upon research and testing shows that this is basically the same result as Golang's "^0x3".
This adds support for that.

@IoIxD IoIxD changed the title wait no there's literally just a binary operator missing oops Add support for bitwise not Jun 23, 2022
@IoIxD IoIxD changed the title Add support for bitwise not Add support for bitwise NOT operator Jun 23, 2022
@nottheswimmer
Copy link
Owner

nottheswimmer commented Jun 23, 2022

Thanks so much for contributing! I'm really ecstatic to see the first code contribution to pytago. Would you mind adding a simple test case for this in the examples folder to show off what you've made and running ./scripts/generate_readme.py then pushing?

If you create a new file (instead of adding to an existing one), you'd need to reference it from pytago/tests/test_core.py as well.

It doesn't have to be a new test case, you could just add something to the input and output of an existing examples/*.py/ examples/*.go file pair if you see an appropriate file pair to put it in.

@IoIxD
Copy link
Contributor Author

IoIxD commented Jun 23, 2022

Well I tried to do that.

bitwisenot.py

def main():
	yeah = 9
	yeah &= ~0x3
	print(yeah)

if __name__ == '__main__':
    main()

bitwise.go

package main

import "fmt"

func main() {
	yeah := 9
	yeah &= ^3
	fmt.Println(yeah)
}

generate_scripts.py gives this error:

Traceback (most recent call last):
  File "/home/gavin/Projects/pytago/scripts/generate_readme.py", line 76, in <module>
    main()
  File "/home/gavin/Projects/pytago/scripts/generate_readme.py", line 55, in main
    assert example.endswith(".go")
AssertionError

Weirdly enough, I modified the script to print file names and it seems that it actually stops at listappend...?

gavin@shitpad ~/P/pytago (yeah) [1]> python scripts/generate_readme.py
bitwisenot
listappend
Traceback (most recent call last):

@nottheswimmer
Copy link
Owner

nottheswimmer commented Jun 23, 2022

The filenames should be the same other than the extensions, maybe that's what's wrong here? I see you have bitwisenot.py and bitwise.go. It's probably zipping through the filenames in alphabetical order which is why you're seeing it get paired with something random.

EDIT: Nevermind, I see in the PR you actually did it right (in terms of filenames), just in your message you wrote different names. I will take a look at this ASAP to see if I can figure out what's going on -- hopefully I'll find time late this evening after the Lion King musical :P

EDIT 2: Oh, I think you need to add the test to pytago/tests/test_core.py? I'm not sure if that's the entire issue but it should be there.

@IoIxD
Copy link
Contributor Author

IoIxD commented Jun 27, 2022

That was the issue yes.

@nottheswimmer nottheswimmer merged commit da3b6d3 into nottheswimmer:main Jun 28, 2022
@nottheswimmer
Copy link
Owner

Looks good to me! Thanks so much for the contribution!

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.

None yet

2 participants