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

Fix deprecation warning from numpy.genfromtxt #230

Closed
dopplershift opened this issue May 23, 2018 · 1 comment
Closed

Fix deprecation warning from numpy.genfromtxt #230

dopplershift opened this issue May 23, 2018 · 1 comment

Comments

@dopplershift
Copy link
Member

So this code:

from datetime import datetime

from siphon.catalog import TDSCatalog

metar_cat_url = ('http://thredds-test.unidata.ucar.edu/thredds/catalog/'
                 'irma/metar/catalog.xml?dataset=irma/metar/Metar_Station_Data_-_IRMA_fc.cdmr')
catalog = TDSCatalog(metar_cat_url)
metar_dataset = catalog.datasets['Feature Collection']
ncss = metar_dataset.subset()
query = ncss.query()
query.lonlat_box(north=34, south=24, east=-80, west=-90)
query.time(datetime(2017, 9, 10, 12))
query.variables('temperature', 'dewpoint', 'altimeter_setting',
                'wind_speed', 'wind_direction', 'sky_coverage')
query.accept('csv')
data = ncss.get_data(query)

produces the warning:

python3.6/site-packages/siphon/ncss.py:433: VisibleDeprecationWarning: Reading unicode strings without specifying the encoding argument is deprecated. Set the encoding, use None for the system default.
converters={'date': lambda s: parse_iso_date(s.decode('utf-8'))})

For some reason, our existing tests don't trigger this warning. The warning occurs because numpy 1.14 started being more pedantic about the encoding stuff, and adding an encoding keyword. We can make things work fine by passing this kwarg with a value of 'utf-8', but of course that means we only work on numpy 1.14. Switching to StringIO instead of BytesIO does not solve the issue. Options I can think of:

  1. Bump numpy requirement to 1.14
  2. Add our own wrapper/helper for genfromtxt that is a straight passthru on numpy > 1.14, and drops the encoding kwarg otherwise
  3. Add a warning filter to swallow the deprecation warning, bump numpy to 1.14 much later.
@dopplershift
Copy link
Member Author

This was fixed by #809 and moving to numpy 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant