Skip to content

Commit

Permalink
Apply comment
Browse files Browse the repository at this point in the history
Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
  • Loading branch information
YarShev committed Feb 24, 2022
1 parent 2bb3a6e commit 4fc997b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
11 changes: 11 additions & 0 deletions modin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ def from_arrow(cls, at, data_cls):
def free(self):
pass

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict:
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol."
)

@classmethod
def from_dataframe(cls, df, data_cls):
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol."
)

to_pandas = PandasQueryCompiler.to_pandas
default_to_pandas = PandasQueryCompiler.default_to_pandas

Expand Down
10 changes: 4 additions & 6 deletions modin/core/storage_formats/base/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def to_numpy(self, **kwargs): # noqa: PR02

# Dataframe exchange protocol

@abc.abstractmethod
def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict:
"""
Get a DataFrame exchange protocol object representing data of the Modin DataFrame.
Expand All @@ -390,11 +391,10 @@ def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> di
dict
A dictionary object following the DataFrame protocol specification.
"""
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol."
)
pass

@classmethod
@abc.abstractmethod
def from_dataframe(cls, df, data_cls):
"""
Build QueryCompiler from a DataFrame object supporting the dataframe exchange protocol `__dataframe__()`.
Expand All @@ -412,9 +412,7 @@ def from_dataframe(cls, df, data_cls):
BaseQueryCompiler
QueryCompiler containing data from the DataFrame.
"""
raise NotImplementedError(
"The selected execution does not implement import via the DataFrame exchange protocol."
)
pass

# END Dataframe exchange protocol

Expand Down
15 changes: 15 additions & 0 deletions modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ def from_pandas(cls, df, data_cls):
def from_arrow(cls, at, data_cls):
return cls(data_cls.from_arrow(at))

# Dataframe exchange protocol

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict:
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol yet."
)

@classmethod
def from_dataframe(cls, df, data_cls):
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol yet."
)

# END Dataframe exchange protocol

index = property(_get_axis(0), _set_axis(0))
columns = property(_get_axis(1), _set_axis(1))

Expand Down
15 changes: 15 additions & 0 deletions modin/experimental/core/storage_formats/omnisci/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ def from_arrow(cls, at, data_cls):
shape_hint = None
return cls(data_cls.from_arrow(at), shape_hint=shape_hint)

# Dataframe exchange protocol

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict:
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol yet."
)

@classmethod
def from_dataframe(cls, df, data_cls):
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol yet."
)

# END Dataframe exchange protocol

default_to_pandas = PandasQueryCompiler.default_to_pandas

def copy(self):
Expand Down
2 changes: 2 additions & 0 deletions modin/test/test_executions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_base_abstract_methods():
"from_pandas",
"from_arrow",
"default_to_pandas",
"from_dataframe",
"to_dataframe",
]

not_implemented_methods = BASE_EXECUTION.__abstractmethods__.difference(
Expand Down

0 comments on commit 4fc997b

Please sign in to comment.