Repository: modin-project/modin

Issue:
Add QC methods for numpy operations like sqrt, and pow
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. What kind of performance improvements would you like to see with this new API?
I would like to add query compiler methods for operations like square root, exp, and square.


Discussion:

Resolving patch:
diff --git a/modin/core/storage_formats/pandas/query_compiler.py b/modin/core/storage_formats/pandas/query_compiler.py
--- a/modin/core/storage_formats/pandas/query_compiler.py
+++ b/modin/core/storage_formats/pandas/query_compiler.py
@@ -1496,6 +1496,12 @@ def isin_func(df, values):
     _tanh = Map.register(
         lambda df, *args, **kwargs: pandas.DataFrame(np.tanh(df, *args, **kwargs))
     )  # Needed for numpy API
+    _sqrt = Map.register(
+        lambda df, *args, **kwargs: pandas.DataFrame(np.sqrt(df, *args, **kwargs))
+    )  # Needed for numpy API
+    _exp = Map.register(
+        lambda df, *args, **kwargs: pandas.DataFrame(np.exp(df, *args, **kwargs))
+    )  # Needed for numpy API
     negative = Map.register(pandas.DataFrame.__neg__)
     notna = Map.register(pandas.DataFrame.notna, dtypes=np.bool_)
     round = Map.register(pandas.DataFrame.round)
diff --git a/modin/numpy/arr.py b/modin/numpy/arr.py
--- a/modin/numpy/arr.py
+++ b/modin/numpy/arr.py
@@ -952,8 +952,26 @@ def exp(
         subok=True,
     ):
         return self._unary_math_operator(
-            "rpow",
-            numpy.e,
+            "_exp",
+            out=out,
+            where=where,
+            casting=casting,
+            order=order,
+            dtype=dtype,
+            subok=subok,
+        )
+
+    def sqrt(
+        self,
+        out=None,
+        where=True,
+        casting="same_kind",
+        order="K",
+        dtype=None,
+        subok=True,
+    ):
+        return self._unary_math_operator(
+            "_sqrt",
             out=out,
             where=where,
             casting=casting,
@@ -1853,9 +1871,9 @@ def _norm(self, ord=None, axis=None, keepdims=False):
             result = result.sum(axis=0)
         if axis is None:
             # Return a scalar
-            return result.pow(0.5).to_numpy()[0, 0]
+            return result._sqrt().to_numpy()[0, 0]
         else:
-            result = result.pow(0.5)
+            result = result._sqrt()
             # the DF may be transposed after processing through pandas
             # check query compiler shape to ensure this is a row vector (1xN) not column (Nx1)
             if len(result.index) != 1:
diff --git a/modin/numpy/math.py b/modin/numpy/math.py
--- a/modin/numpy/math.py
+++ b/modin/numpy/math.py
@@ -432,7 +432,7 @@ def sqrt(
             dtype=dtype,
             subok=subok,
         )
-    return x.power(0.5, out, where, casting, order, dtype, subok)
+    return x.sqrt(out, where, casting, order, dtype, subok)
 
 
 def exp(


Test patch:
diff --git a/modin/numpy/test/test_array_arithmetic.py b/modin/numpy/test/test_array_arithmetic.py
--- a/modin/numpy/test/test_array_arithmetic.py
+++ b/modin/numpy/test/test_array_arithmetic.py
@@ -64,7 +64,7 @@ def test_basic_arithmetic_with_broadcast(operand1_shape, operand2_shape, operato
 
 @pytest.mark.parametrize("operator", ["__pow__", "__floordiv__", "__mod__"])
 def test_arithmetic(operator):
-    """Test of operators that do not yet support broadcasting"""
+    """Test of operators that do not yet support broadcasting."""
     for size, textdim in ((100, "1D"), ((10, 10), "2D")):
         operand1 = numpy.random.randint(-100, 100, size=size)
         lower_bound = -100 if operator != "__pow__" else 0
@@ -136,16 +136,18 @@ def test_scalar_arithmetic(size):
     )
 
 
-def test_abs():
+@pytest.mark.parametrize("op_name", ["abs", "exp", "sqrt", "tanh"])
+def test_unary_arithmetic(op_name):
     numpy_flat_arr = numpy.random.randint(-100, 100, size=100)
     modin_flat_arr = np.array(numpy_flat_arr)
     numpy.testing.assert_array_equal(
-        numpy.abs(numpy_flat_arr), np.abs(modin_flat_arr)._to_numpy()
+        getattr(numpy, op_name)(numpy_flat_arr),
+        getattr(np, op_name)(modin_flat_arr)._to_numpy(),
     )
     numpy_arr = numpy_flat_arr.reshape((10, 10))
     modin_arr = np.array(numpy_arr)
     numpy.testing.assert_array_equal(
-        numpy.abs(numpy_arr), np.abs(modin_arr)._to_numpy()
+        getattr(numpy, op_name)(numpy_arr), getattr(np, op_name)(modin_arr)._to_numpy()
     )