Skip to content

Commit

Permalink
__and__ operation implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
deep110 committed Apr 9, 2017
1 parent d5ba461 commit b511beb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 14 additions & 6 deletions python/common/org/python/types/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,20 @@ public org.python.Object __mul__(org.python.Object other) {
// throw new org.python.exceptions.NotImplementedError("__sub__() has not been implemented");
// }

// @org.python.Method(
// __doc__ = ""
// )
// public org.python.Object __and__(org.python.Object other) {
// throw new org.python.exceptions.NotImplementedError("__and__() has not been implemented");
// }
@org.python.Method(
__doc__ = ""
)
public org.python.Object __and__(org.python.Object other) {
java.util.Set set = ((org.python.types.Set) this.copy()).value;
if (other instanceof org.python.types.Set) {
set.retainAll(((org.python.types.Set) other).value);
return new org.python.types.Set(set);
} else if (other instanceof org.python.types.FrozenSet) {
set.retainAll(((org.python.types.FrozenSet) other).value);
return new org.python.types.Set(set);
}
throw new org.python.exceptions.TypeError("unsupported operand type(s) for &: '" + this.typeName() + "' and '" + other.typeName() + "'");
}

// @org.python.Method(
// __doc__ = ""
Expand Down
2 changes: 0 additions & 2 deletions tests/datatypes/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ class BinarySetOperationTests(BinaryOperationTestCase, TranspileTestCase):
'test_add_frozenset',

'test_and_class',
'test_and_frozenset',
'test_and_set',

'test_direct_eq_bytes',
'test_direct_eq_set',
Expand Down

0 comments on commit b511beb

Please sign in to comment.