You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by ha...@apache.org on 2020/03/13 01:51:56 UTC

[incubator-mxnet] branch master updated: [numpy] add magic methods for symbol bitwise ops (#17807)

This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 18c2a26  [numpy] add magic methods for symbol bitwise ops (#17807)
18c2a26 is described below

commit 18c2a264bb5062a4de60ba54f5ba1fe85dce24cc
Author: Yiyan66 <57...@users.noreply.github.com>
AuthorDate: Fri Mar 13 09:51:08 2020 +0800

    [numpy] add magic methods for symbol bitwise ops (#17807)
---
 python/mxnet/symbol/numpy/_symbol.py | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/python/mxnet/symbol/numpy/_symbol.py b/python/mxnet/symbol/numpy/_symbol.py
index 8e00876..11e574a 100644
--- a/python/mxnet/symbol/numpy/_symbol.py
+++ b/python/mxnet/symbol/numpy/_symbol.py
@@ -185,6 +185,42 @@ class _Symbol(Symbol):
         """x.__add__(y) <=> x + y"""
         return add(self, other)
 
+    def __invert__(self):
+        """x.__invert__() <=> ~x"""
+        return invert(self)
+
+    def __and__(self, other):
+        """x.__and__(y) <=> x & y"""
+        return bitwise_and(self, other)
+
+    def __or__(self, other):
+        """x.__or__(y) <=> x | y"""
+        return bitwise_or(self, other)
+
+    def __xor__(self, other):
+        """x.__xor__(y) <=> x ^ y"""
+        return bitwise_xor(self, other)
+
+    def __round__(self, n=0):
+        """x.__round__(n)"""
+        return round(self, decimals=n)
+
+    def __abs__(self):
+        """x.__abs__()"""
+        return absolute(self)
+
+    def __ceil__(self):
+        """x.__ceil__()"""
+        return ceil(self)
+
+    def __floor__(self):
+        """x.__floor__()"""
+        return floor(self)
+
+    def __trunc__(self):
+        """x.__trunc__()"""
+        return trunc(self)
+
     def __sub__(self, other):
         """x.__sub__(y) <=> x - y"""
         return subtract(self, other)