-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT-#7146: Use BaseQueryCompiler, BasePandasDataset, DataFrame or Series type hints at a high level #7147
Conversation
1ac15a6
to
84dc9d1
Compare
…taFrame or Series type hints at a high level Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
@@ -90,7 +90,7 @@ def unwrap_partitions( | |||
f"Only API Layer objects may be passed in here, got {type(api_layer_object)} instead." | |||
) | |||
|
|||
modin_frame = api_layer_object._query_compiler._modin_frame | |||
modin_frame = api_layer_object._query_compiler._modin_frame # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is # type: ignore[attr-defined]
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy
requires that attribute _modin_frame
be specified for _query_compiler
.
@@ -208,7 +215,9 @@ class ModinAPI: | |||
Object to operate on. | |||
""" | |||
|
|||
def __init__(self, data): | |||
_data: Union[DataFrame, Series] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this become a class attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a practice that allows to specify exactly what attributes all instances have and, in addition, makes it possible to specify its type.
What is written here applies to all of your similar comments.
@@ -45,20 +51,21 @@ class BaseSparseAccessor(ClassLogger): | |||
Object to operate on. | |||
""" | |||
|
|||
_parent: Union[DataFrame, Series] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this become a class attribute?
@@ -174,6 +177,7 @@ class BasePandasDataset(ClassLogger): | |||
# Pandas class that we pretend to be; usually it has the same name as our class | |||
# but lives in "pandas" namespace. | |||
_pandas_class = pandas.core.generic.NDFrame | |||
_query_compiler: BaseQueryCompiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this as a class attribute?
_df: Union[DataFrame, Series] | ||
_query_compiler: BaseQueryCompiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these as class attributes?
@@ -30,7 +36,9 @@ class PartitionIterator(Iterator): | |||
The function to get inner iterables from each partition. | |||
""" | |||
|
|||
def __init__(self, df, axis, func): | |||
df: DataFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this as a class attribute?
_dataframe: Union[DataFrame, Series] | ||
_query_compiler: BaseQueryCompiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
_series: Series | ||
_query_compiler: BaseQueryCompiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
What do these changes do?
To facilitate navigation, allows to automatically find places where functions and attributes are defined.
flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py
black --check modin/ asv_bench/benchmarks scripts/doc_checker.py
git commit -s
BaseQueryCompiler
,BasePandasDataset
,DataFrame
orSeries
type hints at a high level #7146docs/development/architecture.rst
is up-to-date