Skip to content
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

Depreciation warnings dump #558

Open
jpolton opened this issue Sep 21, 2022 · 5 comments
Open

Depreciation warnings dump #558

jpolton opened this issue Sep 21, 2022 · 5 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@jpolton
Copy link
Collaborator

jpolton commented Sep 21, 2022

When running the pytest unit_test.py there are always some depreciation warnings that can be preemptively fixed, or at least flagged.

Ran pip install . && /Users/jeff/opt/anaconda3/envs/coast_dev/bin/pytest unit_testing/unit_test.py -s
Not sure why pytest isn't in my path...

...
================================================================ warnings summary ================================================================
../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/gridded.py:170: 198 warnings
unit_testing/unit_test.py: 201 warnings
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/gridded.py:170: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.
    self.dataset = self.dataset.drop(var)

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/_utils/logging_util.py:79
../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/_utils/logging_util.py:79
unit_testing/unit_test.py::test_gridded_initialisation::test_gridded_load_of_data_only
unit_testing/unit_test.py::test_bgc_gridded_initialisation::test_gridded_load_bgc_data
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/_utils/logging_util.py:79: UserWarning: /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/gridded.py._setup_grid_obj.81: No NEMO domain specified, only limited functionality will be available
    return warnings.warn(add_info(msg), *args, **kwargs)

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/dataarray.py:4860: 12 warnings
unit_testing/unit_test.py: 12 warnings
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/dataarray.py:4860: DeprecationWarning: Behaviour of argmin/argmax with neither dim nor axis argument will change to return a dict of indices of each dimension. To get a single, flat index, please use np.argmin(da.data) or np.argmax(da.data) instead of da.argmin() or da.argmax().
    result = self.variable.argmin(dim, axis, keep_attrs, skipna)

unit_testing/test_general_utils.py:42
unit_testing/unit_test.py::test_general_utils::test_bst_to_gmt
  /Users/jeff/GitHub/COAsT/unit_testing/test_general_utils.py:42: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
    check1 = np.datetime64(bst_obj.localize(datetime_obj).astimezone(pytz.utc)) == np.datetime64(

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/computation.py:771
unit_testing/unit_test.py::test_diagnostic_methods::test_construct_pycnocline_depth_and_thickness
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/computation.py:771: RuntimeWarning: invalid value encountered in sqrt
    result_data = func(*input_data)

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/pyproj/__init__.py:89
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/pyproj/__init__.py:89: UserWarning: pyproj unable to set database path.
    _pyproj_global_context_initialize()

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/tidegauge.py:539: 120 warnings
unit_testing/unit_test.py: 120 warnings
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/tidegauge.py:539: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
    time.append(np.datetime64(bst_obj.localize(datetime_obj).astimezone(pytz.utc)))

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/dataarray.py:4965
unit_testing/unit_test.py::test_tidegauge_methods::test_tidegauge_for_tabulated_data
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/xarray/core/dataarray.py:4965: DeprecationWarning: Behaviour of argmin/argmax with neither dim nor axis argument will change to return a dict of indices of each dimension. To get a single, flat index, please use np.argmin(da.data) or np.argmax(da.data) instead of da.argmin() or da.argmax().
    result = self.variable.argmax(dim, axis, keep_attrs, skipna)

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/tidegauge.py:83
unit_testing/unit_test.py::test_tidegauge_analysis::test_harmonic_analysis_utide
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/data/tidegauge.py:83: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.
    ds_coords = xr.Dataset(self.dataset.coords).drop("time")

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/diagnostics/profile_analysis.py:47
unit_testing/unit_test.py::test_profile_methods::test_compare_processed_profile_with_model
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/diagnostics/profile_analysis.py:47: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.
    dataset = dataset.drop(time_var_list)

../../opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/diagnostics/profile_analysis.py:115
unit_testing/unit_test.py::test_profile_methods::test_compare_processed_profile_with_model
  /Users/jeff/opt/anaconda3/envs/coast_dev/lib/python3.8/site-packages/coast/diagnostics/profile_analysis.py:115: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.
    dataset = dataset.drop(time_var_list)

unit_testing/test_climatology.py:32
unit_testing/unit_test.py::test_climatology::test_monthly_and_seasonal_climatology
  /Users/jeff/GitHub/COAsT/unit_testing/test_climatology.py:32: RuntimeWarning: Mean of empty slice
    mn = mn = np.nanmean(ds.temperature, axis=0)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================ 70 passed, 682 warnings in 55397.40s (15:23:17) ====
@jpolton
Copy link
Collaborator Author

jpolton commented Sep 21, 2022

Fixed some things. argmin/argmax, drop_vars

Created new coast environment using pip. This actually then exposed the HDF5 errors that are plaguing the notebooks. It also showed new depreciation issues.

Ran (in new environment) pip install . && /Users/jeff/opt/anaconda3/envs/coast/bin/pytest unit_testing/unit_test.py -s
Not sure why pytest isn't in my path...

...

==================================================================================== warnings summary =====================================================================================
../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/pydap/model.py:175
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/pydap/model.py:175: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    from collections import OrderedDict, Mapping

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/pydap/responses/das.py:14
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/pydap/responses/das.py:14: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    from collections import Iterable

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/_utils/logging_util.py:79
../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/_utils/logging_util.py:79
unit_testing/unit_test.py::test_gridded_initialisation::test_gridded_load_of_data_only
unit_testing/unit_test.py::test_bgc_gridded_initialisation::test_gridded_load_bgc_data
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/_utils/logging_util.py:79: UserWarning: /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/gridded.py._setup_grid_obj.81: No NEMO domain specified, only limited functionality will be available
    return warnings.warn(add_info(msg), *args, **kwargs)

unit_testing/test_general_utils.py:42
unit_testing/unit_test.py::test_general_utils::test_bst_to_gmt
  /Users/jeff/GitHub/COAsT/unit_testing/test_general_utils.py:42: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
    check1 = np.datetime64(bst_obj.localize(datetime_obj).astimezone(pytz.utc)) == np.datetime64(

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/xarray/core/computation.py:771
unit_testing/unit_test.py::test_diagnostic_methods::test_construct_pycnocline_depth_and_thickness
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/xarray/core/computation.py:771: RuntimeWarning: invalid value encountered in sqrt
    result_data = func(*input_data)

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:352
../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:352
unit_testing/unit_test.py::test_altimetry_methods::test_altimetry_load_subset_and_comparison
unit_testing/unit_test.py::test_altimetry_methods::test_altimetry_load_subset_and_comparison
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:352: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
    corr = pdvar.corr(method=method)

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:366
../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:366
unit_testing/unit_test.py::test_altimetry_methods::test_altimetry_load_subset_and_comparison
unit_testing/unit_test.py::test_altimetry_methods::test_altimetry_load_subset_and_comparison
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/altimetry.py:366: FutureWarning: The default value of numeric_only in DataFrame.cov is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
    cov = pdvar.cov()

../../opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/tidegauge.py:539: 120 warnings
unit_testing/unit_test.py: 120 warnings
  /Users/jeff/opt/anaconda3/envs/coast/lib/python3.8/site-packages/coast/data/tidegauge.py:539: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
    time.append(np.datetime64(bst_obj.localize(datetime_obj).astimezone(pytz.utc)))

unit_testing/test_climatology.py:32
unit_testing/unit_test.py::test_climatology::test_monthly_and_seasonal_climatology
  /Users/jeff/GitHub/COAsT/unit_testing/test_climatology.py:32: RuntimeWarning: Mean of empty slice
    mn = mn = np.nanmean(ds.temperature, axis=0)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================================== 70 passed, 260 warnings in 796.89s (0:13:16) =====================

@jpolton jpolton mentioned this issue Sep 21, 2022
16 tasks
@jpolton
Copy link
Collaborator Author

jpolton commented Sep 22, 2022

A number of these have been fixed. It would be good to review this and see what else needs attention.

@thogar-computer
Copy link
Member

thogar-computer commented Oct 24, 2023

maybe more warning as there might be newer packages - look to fix ones that will stop working in the future.

@thogar-computer
Copy link
Member

Time box for 1 day

@soutobias soutobias moved this from BODC - Todo to BODC - In Progress in COAsT_dev Nov 8, 2023
@soutobias soutobias self-assigned this Nov 8, 2023
@soutobias
Copy link
Collaborator

After updating the Python version, there were still some deprecation warnings present in the code. I successfully addressed and resolved all of the warnings associated with the COAsT code. However, there remain certain warnings related to the xarray and utide libraries, which cannot be eliminated since they pertain to dependencies. The PR link is: #649

@soutobias soutobias moved this from BODC - In Progress to Merged to Develop in COAsT_dev Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: Merged to Develop
Development

No branches or pull requests

3 participants