beeware / voc

A transpiler that converts Python code into Java bytecode
http://beeware.org/voc
BSD 3-Clause "New" or "Revised" License
869 stars 518 forks source link

Complete implementation of operations on standard types #36

Open freakboy3742 opened 8 years ago

freakboy3742 commented 8 years ago

Java has a specific set of allowed operator and operations. Python has a set of operators and operations as well. However, the two don't match exactly. For example, Java will allow any object to be added to a java.lang.String; Python does not. On the other hand, Python allows multiplication of str by int (producing a duplicated string); Java does not.

In order to replicate Python behavior in Java, Python's logic for all the basic operations needs to be implemented in the VOC Java support library.

The test suite contains around 2800 tests in the that are currently marked as "expected failures". These reflect an attempt to do "every operation between every base data type". The task: pick a data type, and write the implementation of one of the dunder operation (e.g., __add__ or __xor__) or comparison (__lt__ or __eq__) methods.

The tests will pass (and become unexpected successes) when the output of Python code doing that operation is the same when run through CPython and VOC - and I mean byte-identical, down to the text and punctuation of the error message if appropriate.

If you want to see an example of what is involved, check out the implementation of add for integers. If you have an int, Python will allows you to add an int or a float to it; all other types raise a TypeError. The list of operations on int that still need to be implemented can be found here; if you add a new operation, delete the line that corresponds to that test, and the test will report as a pass, rather than an expected fail.

freakboy3742 commented 8 years ago

When you submit a PR for this, prefix the PR message with "Refs #36", so it will be associated with this ticket.

ankush981 commented 8 years ago

Folks, I'm picking up the test_unary_positive test in tests/test_str.py. Please don't work on it so that we can avoid collisions! :smile:

ankush981 commented 8 years ago

I forgot to mention, I'll be doing all the unary operator tests for String. Please stay away -- they're mine! :stuck_out_tongue_closed_eyes:

ankush981 commented 8 years ago

Hello, people. I'll be picking up the following tests for string types:

'test_eq_bytearray',
'test_eq_bytes',
'test_eq_class',
'test_eq_complex',
'test_eq_frozenset',
cflee commented 8 years ago

I'm working through the Int class' unary and binary operations.

mzwaen commented 8 years ago

Hi! I'm working on the data type Boolean, starting with comparison methods.

khoobks commented 8 years ago

I'm working through the List class

khoobks commented 8 years ago

I'm working through the Tuple class

prachi2396 commented 8 years ago

Hello, I'll be picking up the byte class.

elitalobo commented 8 years ago

Hello I am working on Int class (power and xor)

ericatkin commented 8 years ago

I'm working on next builtin.

katlings commented 8 years ago

I'm going to work on multiplying some data structures (test_multiply_*), starting with str, float, and list

Instead working on fleshing out the Set class with operations and compator errors

julisi commented 8 years ago

I'm attempting InplaceStrOperationTests 'test_add_int'

julisi commented 8 years ago

I'm now attempting BinaryStrOperationTests 'test_subscr_class' SCRATCH that -- having issues and terminating for now. Please feel free to fix this class if you wish.

encukou commented 8 years ago

Please reserve float for me until Sunday, June 5th.

AnneTheAgile commented 8 years ago

All my background in integer binary calculations is stale. It seems like the int / shift functions might be a good place to start, but are there handy docs online with the specs for binary math done by java? ty! Anne via PyGotham curiosity about PyBee coins and great lecture on Python for Android/iOS.

freakboy3742 commented 8 years ago

@AnneTheAgile Most of the operations for int have been implemented, except for those related to types that aren't fully defined (complex, bytearray, etc). There's a couple missing (or buggy) for floor divide, true divide and inline multiplication.

You can see the operations that are "missing" by looking at a test file (like ( https://github.com/pybee/voc/blob/master/tests/datatypes/test_int.py)[this one]) - any entry in the "not_implemented" section indicates an operator that isn't implemented (or isn't correctly implemented) for a given data type pair.

If you find me at the conference, I'm happy to give you some in-person pointers. I might even give you a coin in advance, if you promise you'll keep going until you get a commit :-)

gholder commented 8 years ago

Going to try the str inline right shift operator

gholder commented 8 years ago

nevermind. Already done in vox. Trying float_eq_list

gholder commented 8 years ago

Trying float_ne_list

harisibrahimkv commented 8 years ago

Working on test_list.InplaceListOperationTests.test_add_tuple.

skimbrel commented 8 years ago

Working on test_list.test_subtract_slice.

DylanGraham commented 8 years ago

Looking at BinaryStrOperationTests.test_modulo_bool

Not working on this any more. It's up for grabs

thefon commented 8 years ago

Looking at test_bytes and the Bytes type

tkcranny commented 8 years ago

I'll be working on set's behaviour.

DylanGraham commented 8 years ago

I'm now looking at InplaceListOperationTests: test_multiply_list test_multiply_int test_multiply_bool

This is looking good: OK (expected failures=42)

DylanGraham commented 8 years ago

Looking at iadd for bytes on a List

thefon commented 8 years ago

Bytes is pretty much done. I can also do ByteArray since that's a clone of Bytes.

italomaia commented 8 years ago

I'll handle the missing multiply operations:

tyagow commented 8 years ago

i'm working on Bool multiply bytes... test_multiply_bytes test_multiply_bytearray

juliomfreitas commented 8 years ago

I'm working on this case for Bool class

'test_and_int'

smilin-desperado commented 8 years ago

I'm working on the 'and' operator of the Complex class

henriquebraga commented 8 years ago

IMplementend endswith test

ju6ge commented 7 years ago

324 working on test_int inline true division in int class

working on implementing multiply in complex class

341 Now working on implementing true division in complex class

pranav-asthana commented 7 years ago

@freakboy3742 Hi. I'd like to work on this. First timer here. I was thinking of the str data type. Could you give me some suggestions as to what to pick and how to go about it.

freakboy3742 commented 7 years ago

@PranavAsty Our getting started docs walk you through the process of your first contribution. If you need more specific details, let us know!

captaincrunch21 commented 7 years ago

Hi I'd like to contribute , can any one suggest any method or datatype to work on?

eliasdorneles commented 7 years ago

Hi @captaincrunch21 ! My suggestion for you would be to implement the Python builtin function enumerate(). Basically, it would consist of adding an implementation for this function: https://github.com/pybee/voc/blob/master/python/common/org/Python.java#L599-L610

You should add some tests for enumerate() here: https://github.com/pybee/voc/blob/master/tests/builtins/test_enumerate.py#L4-L5

For examples of tests for a builtin function, see here the tests for sum(). Essentially, you need to write some python code in the test, which will be executed by the test suite both with CPython and with Java+VOC and it will check if the output is the same.

If you need more details, just ask!

avikantz commented 7 years ago

Hi, I'm new here and I'd like to contribute, could you suggest any method/data type I can pick and work on?

eliasdorneles commented 7 years ago

@avikantz Hi and welcome! So, there are some builtin functions like max, min, zip, enumerate that are missing, you can try implementing one of those. :) You can also grep for NotImplementedError inside the python/common/org directory. Ask help in Gitter if you get stuck.

gEt-rIgHt-jR commented 7 years ago

I've started working on enumerate function.

avikantz commented 7 years ago

Ok, @gEt-rIgHt-jR I shall look into max, min and zip then.

tbliu commented 7 years ago

I can try working on filter

encore0117 commented 7 years ago

Hi! First timer here. I'd like to work on frozenset., specifically "len", "in", and "not in".

I guess someone else is working on those. Will look for something else.

@ASP1234 I guess it is probably better to sign up here first so two people don't work on the same thing.

ad1269 commented 7 years ago

I picked up the add function in float to support addition with complex numbers.

ASP1234 commented 7 years ago

Working on the frozenset. Sent a PR regarding len() fixes

shriakhilc commented 7 years ago

Hello. I'm new to open source and this is my first time trying to contribute to a project, but I have experience in both Java and Python. I've already set up the environment as described in the Getting Started docs. Could you point me to something that I can work on?

freakboy3742 commented 7 years ago

@TheGamer007 Hi - our guide for how to get started can be found here - that gives you a starting place for your first contribution. If you've got any questions, just ask!

bittik commented 7 years ago

working on sets isdisjoint() issubset() and issuperset() #426

shriakhilc commented 7 years ago

~Working on list.__rmul__~ I'm sorry, that was already implemented. I'll look for something else and comment here.