Repository: modin-project/modin

Issue:
TypeError thrown after setitem

### Describe the problem
<!-- Describe the problem clearly here. -->
Because of how `block_lengths` and `block_widths` are computed for the Ray engine, we sometimes run into this issue if we've update the values for a single partition.

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

Full error traceback:

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/Downloads/kaggle1/kaggle1.py in <module>
     58 df_train['SalePrice'] = np.log(df_train['SalePrice'])
     59 fig = plt.figure()
---> 60 res = stats.probplot(df_train['SalePrice'], plot=plt)
     61 fig = plt.figure()
     62 res = stats.probplot(df_train['GrLivArea'], plot=plt)

~/software_builds/modin/modin/pandas/base.py in __getitem__(self, key)
   3177             return self._getitem_slice(indexer)
   3178         else:
-> 3179             return self._getitem(key)
   3180 
   3181     def _getitem_slice(self, key):

~/software_builds/modin/modin/pandas/dataframe.py in _getitem(self, key)
   1834             # return self._getitem_multilevel(key)
   1835         else:
-> 1836             return self._getitem_column(key)
   1837 
   1838     def _getitem_column(self, key):

~/software_builds/modin/modin/pandas/dataframe.py in _getitem_column(self, key)
   1839         if key not in self.keys():
   1840             raise KeyError("{}".format(key))
-> 1841         s = self._reduce_dimension(self._query_compiler.getitem_column_array([key]))
   1842         s._parent = self
   1843         return s

~/software_builds/modin/modin/backends/pandas/query_compiler.py in getitem_column_array(self, key, numeric)
   1987         else:
   1988             numeric_indices = key
-> 1989         result = self.data.mask(col_indices=numeric_indices)
   1990         # We can't just set the columns to key here because there may be
   1991         # multiple instances of a key.

~/software_builds/modin/modin/engines/base/frame/partition_manager.py in mask(self, row_indices, col_indices)
    983         if col_indices is not None:
    984             col_partitions_list = self._get_dict_of_block_index(
--> 985                 0, col_indices, ordered=True
    986             )
    987         else:

~/software_builds/modin/modin/engines/base/frame/partition_manager.py in _get_dict_of_block_index(self, axis, indices, ordered)
    682         print(cumulative)
    683         print(cumulative.dtype)
--> 684         partition_ids = np.digitize(indices, cumulative)
    685         # If the output order doesn't matter or if the indices are monotonically
    686         # increasing, the computation is significantly simpler and faster than doing

TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
```


Discussion:

Resolving patch:
diff --git a/modin/engines/ray/generic/frame/partition_manager.py b/modin/engines/ray/generic/frame/partition_manager.py
--- a/modin/engines/ray/generic/frame/partition_manager.py
+++ b/modin/engines/ray/generic/frame/partition_manager.py
@@ -53,7 +53,12 @@ def block_lengths(self):
                     )
             else:
                 self._lengths_cache = np.array(
-                    [obj.length() for obj in self._partitions_cache.T[0]]
+                    [
+                        obj.length()
+                        if isinstance(obj.length(), int)
+                        else ray.get(obj.length().oid)
+                        for obj in self._partitions_cache.T[0]
+                    ]
                 )
         return self._lengths_cache
 
@@ -88,6 +93,11 @@ def block_widths(self):
                     )
             else:
                 self._widths_cache = np.array(
-                    [obj.width() for obj in self._partitions_cache[0]]
+                    [
+                        obj.width()
+                        if isinstance(obj.width(), int)
+                        else ray.get(obj.width().oid)
+                        for obj in self._partitions_cache[0]
+                    ]
                 )
         return self._widths_cache


Test patch: