-
Notifications
You must be signed in to change notification settings - Fork 222
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
WIP: Test lowest versions of all required and optional dependencies #3639
base: main
Are you sure you want to change the base?
Changes from 11 commits
3a5d6da
f303964
3f6909d
788fc46
4139f4e
1263075
d1fa38d
1c69406
3b7b777
6120bbe
3299229
0584459
7d542a9
4733bda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,18 +33,18 @@ dependencies = [ | |||||||||||||||||||||||
"numpy>=1.24", | ||||||||||||||||||||||||
"pandas>=2.0", | ||||||||||||||||||||||||
"xarray>=2023.04", | ||||||||||||||||||||||||
"netCDF4", | ||||||||||||||||||||||||
"packaging", | ||||||||||||||||||||||||
"netCDF4>=1.7", | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed making NetCDF an optional dependency before in #429. Maybe we could revisit that discussion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. NetCDF4 was needed by xarray when reading and writing netCDF files. As mentioned in #239 (comment), previously, our After we refactor our I've opened PR #3643 to see how the PyGMT relies on the netCDF package. Edit: There are only 14 failures in the Python 3.11 + Ubuntu CI job after removing netCDF entirely (see https://github.com/GenericMappingTools/pygmt/actions/runs/11968416461/job/33367210857?pr=3643) and most of them are caused by |
||||||||||||||||||||||||
"packaging>=22.0", | ||||||||||||||||||||||||
] | ||||||||||||||||||||||||
dynamic = ["version"] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[project.optional-dependencies] | ||||||||||||||||||||||||
all = [ | ||||||||||||||||||||||||
"contextily", | ||||||||||||||||||||||||
"geopandas", | ||||||||||||||||||||||||
"IPython", # 'ipython' is not the correct module name. | ||||||||||||||||||||||||
"pyarrow", | ||||||||||||||||||||||||
"rioxarray", | ||||||||||||||||||||||||
"contextily>=1.2", | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to pin to pygmt/pygmt/datasets/tile_map.py Lines 12 to 19 in 97185e8
Xref geopandas/contextily#183, where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know that we require contexily>=1.2 |
||||||||||||||||||||||||
"geopandas>=0.14", | ||||||||||||||||||||||||
"IPython>=8", # 'ipython' is not the correct module name. | ||||||||||||||||||||||||
"pyarrow>=16", | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pinning to ________ test_to_numpy_pyarrow_array_pyarrow_dtypes_string[string_view] ________
> ???
E KeyError: 'string_view'
pyarrow/types.pxi:5025: KeyError
During handling of the above exception, another exception occurred:
dtype = 'string_view'
@pytest.mark.skipif(not _HAS_PYARROW, reason="pyarrow is not installed")
@pytest.mark.parametrize(
"dtype",
[
None,
"string",
"utf8", # alias for string
"large_string",
"large_utf8", # alias for large_string
"string_view",
],
)
def test_to_numpy_pyarrow_array_pyarrow_dtypes_string(dtype):
"""
Test the _to_numpy function with PyArrow arrays of PyArrow string types.
"""
> array = pa.array(["abc", "defg", "12345"], type=dtype)
../pygmt/tests/test_clib_to_numpy.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyarrow/array.pxi:230: in pyarrow.lib.array
???
pyarrow/types.pxi:5040: in pyarrow.lib.ensure_type
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E ValueError: No type alias for string_view
pyarrow/types.pxi:5027: ValueError Code was added in #3608: pygmt/pygmt/tests/test_clib_to_numpy.py Lines 326 to 336 in 97185e8
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PyArrow v16.0 was released in April, 2024. Instead of pinning pyarrow>=16.0, we can just skip There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I just tested older versions from pyarrow v12 to v15, and think we can pin to _________________________________________________________________ test_to_numpy_pyarrow_array_pyarrow_dtypes_date[date64[ms]] __________________________________________________________________
dtype = 'date64[ms]', expected_dtype = 'datetime64[ms]'
@pytest.mark.skipif(not _HAS_PYARROW, reason="pyarrow is not installed")
@pytest.mark.parametrize(
("dtype", "expected_dtype"),
[
pytest.param("date32[day]", "datetime64[D]", id="date32[day]"),
pytest.param("date64[ms]", "datetime64[ms]", id="date64[ms]"),
],
)
def test_to_numpy_pyarrow_array_pyarrow_dtypes_date(dtype, expected_dtype):
"""
Test the _to_numpy function with PyArrow arrays of PyArrow date types.
date32[day] and date64[ms] are stored as 32-bit and 64-bit integers, respectively,
representing the number of days and milliseconds since the UNIX epoch (1970-01-01).
Here we explicitly check the dtype and date unit of the result.
"""
data = [
date(2024, 1, 1),
datetime(2024, 1, 2),
datetime(2024, 1, 3),
]
array = pa.array(data, type=dtype)
result = _to_numpy(array)
_check_result(result, np.datetime64)
> assert result.dtype == expected_dtype # Explicitly check the date unit.
E AssertionError: assert dtype('<M8[D]') == 'datetime64[ms]'
E + where dtype('<M8[D]') = array(['2024-01-01', '2024-01-02', '2024-01-03'], dtype='datetime64[D]').dtype
../pygmt/tests/test_clib_to_numpy.py:364: AssertionError The main change appears to be in apache/arrow#33321, when pyarrow supported preserving the datetime64 temporal resolution. Maybe we can keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjusted pin to |
||||||||||||||||||||||||
"rioxarray>=0.14", | ||||||||||||||||||||||||
] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[project.urls] | ||||||||||||||||||||||||
|
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.
Using
--resolution lowest-direct
for now, because--resolution lowest
grabs many other transitive dependencies that may be hard to install (e.g. missing wheels for newer Python versions, so requires compilation from source). We could switch to--resolution lowest
once the Python ecosystem does lower bound pins a bit more thoroughly (which may take years).