voc icon indicating copy to clipboard operation
voc copied to clipboard

Complete implementation of operations on standard types

Open freakboy3742 opened this issue 9 years ago • 139 comments

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 avatar Dec 04 '15 22:12 freakboy3742

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

freakboy3742 avatar Dec 04 '15 22:12 freakboy3742

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 avatar Feb 02 '16 15:02 ankush981

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 avatar Feb 06 '16 16:02 ankush981

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',

ankush981 avatar Feb 07 '16 13:02 ankush981

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

cflee avatar Mar 11 '16 12:03 cflee

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

mzwaen avatar Mar 18 '16 09:03 mzwaen

I'm working through the List class

khoobks avatar Mar 21 '16 14:03 khoobks

I'm working through the Tuple class

khoobks avatar Mar 25 '16 06:03 khoobks

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

prachi2396 avatar Mar 27 '16 09:03 prachi2396

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

elitalobo avatar Apr 04 '16 08:04 elitalobo

I'm working on next builtin.

ericatkin avatar Jun 01 '16 21:06 ericatkin

~~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

katlings avatar Jun 02 '16 17:06 katlings

I'm attempting InplaceStrOperationTests 'test_add_int'

julisi avatar Jun 02 '16 19:06 julisi

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.

julisi avatar Jun 03 '16 16:06 julisi

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

encukou avatar Jun 03 '16 23:06 encukou

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.

AnneTheAgile avatar Jul 17 '16 10:07 AnneTheAgile

@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 :-)

freakboy3742 avatar Jul 17 '16 13:07 freakboy3742

Going to try the str inline right shift operator

gholder avatar Jul 21 '16 15:07 gholder

nevermind. Already done in vox. Trying float_eq_list

gholder avatar Jul 21 '16 15:07 gholder

Trying float_ne_list

gholder avatar Jul 21 '16 17:07 gholder

Working on test_list.InplaceListOperationTests.test_add_tuple.

harisibrahimkv avatar Jul 22 '16 16:07 harisibrahimkv

Working on test_list.test_subtract_slice.

skimbrel avatar Jul 31 '16 20:07 skimbrel

Looking at BinaryStrOperationTests.test_modulo_bool

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

DylanGraham avatar Aug 14 '16 23:08 DylanGraham

Looking at test_bytes and the Bytes type

thefon avatar Aug 15 '16 00:08 thefon

I'll be working on set's behaviour.

tkcranny avatar Aug 15 '16 02:08 tkcranny

I'm now looking at InplaceListOperationTests: test_multiply_list test_multiply_int test_multiply_bool

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

DylanGraham avatar Aug 16 '16 05:08 DylanGraham

Looking at iadd for bytes on a List

DylanGraham avatar Aug 18 '16 13:08 DylanGraham

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

thefon avatar Aug 19 '16 14:08 thefon

I'll handle the missing multiply operations:

  • ~~test_multiply_bytearray~~
  • ~~test_multiply_bytes~~
  • test_multiply_class (depends on Type implementation)
  • test_multiply_complex
  • test_multiply_frozenset

italomaia avatar Oct 18 '16 12:10 italomaia

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

tyagow avatar Oct 18 '16 16:10 tyagow