aodn / python-aodntools

Repository for templates and code relating to generating standard NetCDF files for the Australia Ocean Data Network
GNU Lesser General Public License v3.0
10 stars 3 forks source link

Fix deprecation and run-time warnings #112

Open mhidas opened 4 years ago

mhidas commented 4 years ago

Various DeprecationWarning and RuntimeWarning pop up when running the unittests. These should ideally be fixed before they become errors.

E.g.

test_aodntools/ncwriter/test_template.py::TestDatasetTemplate::test_ensure_completeness
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:282: DeprecationWarning: Please use assertRaisesRegex instead.
    template.ensure_completeness)
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:286: DeprecationWarning: Please use assertRaisesRegex instead.
    template.ensure_completeness)

test_aodntools/ncwriter/test_template.py::TestDatasetTemplate::test_ensure_consistency
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:318: DeprecationWarning: Please use assertRaisesRegex instead.
    template.ensure_consistency)  # now should fail because dim X is already set
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:323: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(ValidationError, 'undefined dimensions', template.ensure_consistency)
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:330: DeprecationWarning: Please use assertRaisesRegex instead.
    template.ensure_consistency

test_aodntools/ncwriter/test_template.py::TestDatasetTemplate::test_invalid_json
  /home/travis/build/aodn/python-aodntools/test_aodntools/ncwriter/test_template.py:105: DeprecationWarning: Please use assertRaisesRegex instead.
    self.assertRaisesRegexp(ValueError, error_pattern, DatasetTemplate.from_json, BAD_JSON)

test_aodntools/timeseries_products/test_aggregated_timeseries.py::TestAggregatedTimeseries::test_main_aggregator
  /home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in less
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  /home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in greater
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  /home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in reduce
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ghost commented 4 years ago

Not sure about the numpy one, but the assertRaisesRegex one is just a straight search/replace, because it was just renamed.

mhidas commented 4 years ago

Yep, I just wasn't ready to fix them right now, and as you say the numpy ones will take a bit more debugging, so just noting here as a reminder for later.

mhidas commented 4 years ago
/sw/chef/src/python-aodntools/aodntools/timeseries_products/hourly_timeseries.py:540: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.
  nc_aggregated = nc_aggregated.drop('OBSERVATION')
mhidas commented 4 years ago
/sw/chef/src/python-aodntools/aodntools/timeseries_products/gridded_timeseries.py:88: SerializationWarning: saving variable TEMP_count with floating point data as an integer dtype without any _FillValue to use for NaNs
  agg_dataset.to_netcdf(output_path, encoding=encoding, format='NETCDF4_CLASSIC')
mhidas commented 4 years ago
velocity_hourly_timeseries.py:195: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
  chunk_start = np.datetime64(nc.attrs['time_deployment_start'])
velocity_hourly_timeseries.py:196: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
  chunk_end = np.datetime64(nc.attrs['time_deployment_end'])
mhidas commented 1 year ago

See also #136 :

hourly_timeseries.py:401: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

and

hourly_timeseries.py:311: FutureWarning: 'base' in .resample() and in Grouper() is deprecated. The new arguments that you should use are 'offset' or 'origin'.