Skip to content

Commit

Permalink
FEAT-#1936: avoid empty frame checks for lazy backend (#1937)
Browse files Browse the repository at this point in the history
Signed-off-by: ienkovich <ilya.enkovich@intel.com>
  • Loading branch information
ienkovich committed Aug 22, 2020
1 parent 36106b4 commit 39afc07
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions modin/backends/base/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def default_to_pandas(self, pandas_op, *args, **kwargs):
# some of these abstract methods, but for the sake of generality they are
# treated differently.

lazy_execution = False

# Metadata modification abstract methods
@abc.abstractmethod
def add_prefix(self, prefix, axis=1):
Expand Down
4 changes: 2 additions & 2 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3438,7 +3438,7 @@ def __ge__(self, right):
return self.ge(right)

def __getitem__(self, key):
if len(self) == 0:
if not self._query_compiler.lazy_execution and len(self) == 0:
return self._default_to_pandas("__getitem__", key)
# see if we can slice the rows
# This lets us reuse code in Pandas to error check
Expand Down Expand Up @@ -3574,7 +3574,7 @@ def __getattribute__(self, item):
"_create_or_update_from_compiler",
"_update_inplace",
]
if item not in default_behaviors:
if item not in default_behaviors and not self._query_compiler.lazy_execution:
method = object.__getattribute__(self, item)
is_callable = callable(method)
# We default to pandas on empty DataFrames. This avoids a large amount of
Expand Down
3 changes: 2 additions & 1 deletion modin/pandas/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def concat(
list_of_objs = [
obj._query_compiler
for obj in list_of_objs
if len(obj.index) or len(obj.columns)
if (not obj._query_compiler.lazy_execution and len(obj.index))
or len(obj.columns)
]
if keys is not None:
if all_series:
Expand Down
4 changes: 2 additions & 2 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def insert(self, loc, column, value, allow_duplicates=False):
# TODO: Remove broadcast of Series
value = value._to_pandas()

if len(self.index) == 0:
if not self._query_compiler.lazy_execution and len(self.index) == 0:
try:
value = pandas.Series(value)
except (TypeError, ValueError, IndexError):
Expand Down Expand Up @@ -2577,7 +2577,7 @@ def setitem_without_string_columns(df):
if not isinstance(value, Series):
value = list(value)

if len(self.index) == 0:
if not self._query_compiler.lazy_execution and len(self.index) == 0:
new_self = DataFrame({key: value}, columns=self.columns)
self._update_inplace(new_self._query_compiler)
else:
Expand Down

0 comments on commit 39afc07

Please sign in to comment.