Skip to content

Commit

Permalink
Implemented in-place mod and floor operators for complex numbers on a…
Browse files Browse the repository at this point in the history
… tuple

Signed-off-by: Jenna Hight <[email protected]>
  • Loading branch information
jennahight committed May 29, 2017
1 parent e56c62e commit 8e500ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 12 additions & 2 deletions batavia/types/Tuple.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ Tuple.prototype.__or__ = function(other) {
**************************************************/

Tuple.prototype.__ifloordiv__ = function(other) {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for //=: 'tuple' and '" + type_name(other) + "'")
var types = require('../types')
if (types.isinstance(other, types.Complex)) {
throw new exceptions.TypeError.$pyclass("can't take floor of complex number.")
} else {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for //: 'tuple' and '" + type_name(other) + "'")
}
}

Tuple.prototype.__itruediv__ = function(other) {
Expand Down Expand Up @@ -489,7 +494,12 @@ Tuple.prototype.__imul__ = function(other) {
}

Tuple.prototype.__imod__ = function(other) {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for %=: 'tuple' and '" + type_name(other) + "'")
var types = require('../types')
if (types.isinstance(other, types.Complex)) {
throw new exceptions.TypeError.$pyclass("can't mod complex numbers.")
} else {
throw new exceptions.TypeError.$pyclass("unsupported operand type(s) for %=: 'tuple' and '" + type_name(other) + "'")
}
}

Tuple.prototype.__ipow__ = function(other) {
Expand Down
4 changes: 0 additions & 4 deletions tests/datatypes/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ class InplaceTupleOperationTests(InplaceOperationTestCase, TranspileTestCase):

not_implemented = [

'test_floor_divide_complex',

'test_modulo_complex',

'test_or_bool',
'test_or_bytearray',
'test_or_bytes',
Expand Down

0 comments on commit 8e500ae

Please sign in to comment.