-
Notifications
You must be signed in to change notification settings - Fork 156
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
Update flake8 to 7.1.1. #1458
Update flake8 to 7.1.1. #1458
Conversation
if type(geo1) != type(geo2): | ||
assert TypeError | ||
if type(geo1) is not type(geo2): | ||
raise TypeError |
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.
The previous code assert TypeError
was definitely wrong (it doesn't raise!). But now I'm seeing test failures:
___________________________ test_cudf_dataframe_init ___________________________
[gw7] linux -- Python 3.10.15 /pyenv/versions/3.10.15/bin/python
def test_cudf_dataframe_init():
df = cudf.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
gdf = cuspatial.GeoDataFrame(df)
> assert_eq_geo_df(gdf.to_pandas(), df.to_pandas())
tests/test_geodataframe.py:465:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
geo1 = a b
0 1 4
1 2 5
2 3 6, geo2 = a b
0 1 4
1 2 5
2 3 6
def assert_eq_geo_df(geo1, geo2):
if type(geo1) is not type(geo2):
> raise TypeError
E TypeError
tests/test_geodataframe.py:97: TypeError
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.
I wanted to help so looked into this a bit.
Here's the specific error I now see in the one failing test:
FAILED tests/test_geodataframe.py::test_cudf_dataframe_init - AssertionError: assert <class 'geopandas.geodataframe.GeoDataFrame'> is <class 'pandas.core.frame.DataFrame'>
+ where <class 'geopandas.geodataframe.GeoDataFrame'> = type( a b\n0 1 4\n1 2 5\n2 3 6)
+ and <class 'pandas.core.frame.DataFrame'> = type( a b\n0 1 4\n1 2 5\n2 3 6)
Here's the source code of that test:
cuspatial/python/cuspatial/cuspatial/tests/test_geodataframe.py
Lines 462 to 465 in a2d21c9
def test_cudf_dataframe_init(): | |
df = cudf.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) | |
gdf = cuspatial.GeoDataFrame(df) | |
assert_eq_geo_df(gdf.to_pandas(), df.to_pandas()) |
It looks to me like it's intentional behavior that the cuspatial.GeoDataFrame.to_pandas()
method actually returns a geopandas.GeoDataFrame
, not a pandas.DataFrame
.
cuspatial/python/cuspatial/cuspatial/core/geodataframe.py
Lines 70 to 80 in a2d21c9
def to_pandas(self, nullable=False): | |
""" | |
Calls `self.to_geopandas`, converting GeoSeries columns into GeoPandas | |
columns and cudf.Series columns into pandas.Series columns, and | |
returning a pandas.DataFrame. | |
Parameters | |
---------- | |
nullable: matches the cudf `to_pandas` signature, not yet supported. | |
""" | |
return self.to_geopandas(nullable=nullable) |
So I guess one of these has to happen:
cuspatial.GeoDataFrame.to_pandas()
needs to start returning apandas.DataFrame
instead (as the name implies)- the have-the-same-type expectation needs to be removed from that test
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.
From a cursory check, it appears the intention is for this check to assert that both arguments are geopandas.GeoDataFrame
objects, so I think the usage here is incorrect.
I imagine the test should have been assert_eq_geo_df(gdf.to_pandas(), gpd.GeoDataFrame(df.to_pandas()))
?
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.
I'll try that locally. Thanks, that sounds like the right direction to me.
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.
Yup, that worked on my local build. I pushed the change. Thanks @mroeschke!
/merge |
Description
We need to update flake8 to fix a false-positive that appears with older flake8 versions on Python 3.12.
Checklist