Repository: modin-project/modin

Issue:
Windows Memory Issue for `Series.view`

### Describe the problem
<!-- Describe the problem clearly here. -->
Test Failure during #957. For now, marking as skip for Windows only and will need to fix later. `view` defaults to pandas in this case, but something with the deserialization must be causing an issue, even when `dtype=None`.



Discussion:
After digging on this a little bit, I'm going to postpone until after this next release. It's not deserialization, I believe it is differences in numpy on Windows and Linux that is causing some issue.

Resolving patch:
diff --git a/modin/backends/base/query_compiler.py b/modin/backends/base/query_compiler.py
--- a/modin/backends/base/query_compiler.py
+++ b/modin/backends/base/query_compiler.py
@@ -426,6 +426,10 @@ def notna(self):
     def round(self, **kwargs):
         pass
 
+    @abc.abstractmethod
+    def series_view(self, **kwargs):
+        pass
+
     @abc.abstractmethod
     def unique(self, **kwargs):
         pass
diff --git a/modin/backends/pandas/query_compiler.py b/modin/backends/pandas/query_compiler.py
--- a/modin/backends/pandas/query_compiler.py
+++ b/modin/backends/pandas/query_compiler.py
@@ -426,6 +426,9 @@ def transpose(self, *args, **kwargs):
     negative = MapFunction.register(pandas.DataFrame.__neg__)
     notna = MapFunction.register(pandas.DataFrame.notna, dtypes=np.bool)
     round = MapFunction.register(pandas.DataFrame.round)
+    series_view = MapFunction.register(
+        lambda df, *args, **kwargs: pandas.DataFrame(df.squeeze().view(*args, **kwargs))
+    )
 
     # END Map partitions operations
 
diff --git a/modin/pandas/series.py b/modin/pandas/series.py
--- a/modin/pandas/series.py
+++ b/modin/pandas/series.py
@@ -1266,7 +1266,9 @@ def value_counts(
         )
 
     def view(self, dtype=None):
-        return self._default_to_pandas(pandas.Series.view, dtype=dtype)
+        return self.__constructor__(
+            query_compiler=self._query_compiler.series_view(dtype=dtype)
+        )
 
     def where(
         self,


Test patch:
diff --git a/modin/pandas/test/test_series.py b/modin/pandas/test/test_series.py
--- a/modin/pandas/test/test_series.py
+++ b/modin/pandas/test/test_series.py
@@ -2778,13 +2778,24 @@ def test_var(data, skipna, ddof):
         df_equals(modin_result, pandas_result)
 
 
-@pytest.mark.skipif(sys.platform == "win32", reason="Windows memory issue #960")
-@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
-def test_view(data):
-    modin_series, pandas_series = create_test_series(data)
+def test_view():
+    modin_series = pd.Series([-2, -1, 0, 1, 2], dtype="int8")
+    pandas_series = pandas.Series([-2, -1, 0, 1, 2], dtype="int8")
+    modin_result = modin_series.view(dtype="uint8")
+    pandas_result = pandas_series.view(dtype="uint8")
+    df_equals(modin_result, pandas_result)
 
-    with pytest.warns(UserWarning):
-        modin_series.view(None)
+    modin_series = pd.Series([-20, -10, 0, 10, 20], dtype="int32")
+    pandas_series = pandas.Series([-20, -10, 0, 10, 20], dtype="int32")
+    modin_result = modin_series.view(dtype="float32")
+    pandas_result = pandas_series.view(dtype="float32")
+    df_equals(modin_result, pandas_result)
+
+    modin_series = pd.Series([-200, -100, 0, 100, 200], dtype="int64")
+    pandas_series = pandas.Series([-200, -100, 0, 100, 200], dtype="int64")
+    modin_result = modin_series.view(dtype="float64")
+    pandas_result = pandas_series.view(dtype="float64")
+    df_equals(modin_result, pandas_result)
 
 
 def test_where():