issues
2 rows where "created_at" is on date 2020-08-12 and user = 6063709 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: created_at (date), updated_at (date), closed_at (date)
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at ▲ | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
677296128 | MDU6SXNzdWU2NzcyOTYxMjg= | 4336 | cftime_range fails for base cftime.datetime object | aidanheerdegen 6063709 | open | 0 | 8 | 2020-08-12T00:56:18Z | 2023-11-26T22:40:03Z | CONTRIBUTOR | What happened:
What you expected to happen: I expected Minimal Complete Verifiable Example:
Anything else we need to know?: Returns this error: ```python TypeError Traceback (most recent call last) <ipython-input-29-d090ea15e436> in <module> 2 import xarray 3 date = cftime.datetime(10,1,1) ----> 4 xarray.cftime_range(date, periods=3, freq='Y') /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in cftime_range(start, end, periods, freq, normalize, name, closed, calendar) 973 else: 974 offset = to_offset(freq) --> 975 dates = np.array(list(_generate_range(start, end, periods, offset))) 976 977 left_closed = False /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in _generate_range(start, end, periods, offset) 744 """ 745 if start: --> 746 start = offset.rollforward(start) 747 748 if end: /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in rollforward(self, date) 526 def rollforward(self, date): 527 """Roll date forward to nearest end of year""" --> 528 if self.onOffset(date): 529 return date 530 else: /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in onOffset(self, date) 522 """Check if the given date is in the set of possible dates created 523 using a length-one version of this offset class.""" --> 524 return date.day == _days_in_month(date) and date.month == self.month 525 526 def rollforward(self, date): /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in _days_in_month(date) 195 else: 196 reference = type(date)(date.year, date.month + 1, 1) --> 197 return (reference - timedelta(days=1)).day 198 199 TypeError: unsupported operand type(s) for -: 'cftime._cftime.datetime' and 'datetime.timedelta'
The error occurs here https://github.com/pydata/xarray/blob/master/xarray/coding/cftime_offsets.py#L197 because this operation is not defined for the base class https://github.com/Unidata/cftime/blob/master/cftime/_cftime.pyx#L1054 The relevant tests all seem to use datetime strings which are by default https://github.com/pydata/xarray/blob/master/xarray/coding/cftime_offsets.py#L788 Environment: Output of <tt>xr.show_versions()</tt>INSTALLED VERSIONS ------------------ commit: None python: 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 2.6.32-754.18.2.el6.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_AU.utf8 LANG: en_AU.UTF-8 LOCALE: en_AU.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.4 xarray: 0.16.0 pandas: 1.1.0 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.3 pydap: installed h5netcdf: 0.8.1 h5py: 2.10.0 Nio: 1.5.5 zarr: 2.4.0 cftime: 1.0.3.4 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: 1.1.5 cfgrib: 0.9.8.4 iris: 2.4.0 bottleneck: 1.3.2 dask: 2.22.0 distributed: 2.22.0 matplotlib: 3.3.0 cartopy: 0.18.0 seaborn: 0.10.1 numbagg: None pint: 0.14 setuptools: 49.2.0.post20200712 pip: 20.1.1 conda: installed pytest: 6.0.1 IPython: 7.17.0 sphinx: 3.2.0 |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4336/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
xarray 13221727 | issue | ||||||||
677307460 | MDU6SXNzdWU2NzczMDc0NjA= | 4337 | cftime_range does not support default cftime.datetime formatted output strings | aidanheerdegen 6063709 | closed | 0 | 5 | 2020-08-12T01:28:30Z | 2020-08-17T23:27:07Z | 2020-08-17T23:27:07Z | CONTRIBUTOR | Is your feature request related to a problem? Please describe. The
ValueError Traceback (most recent call last) <ipython-input-70-a16c1fcab8d6> in <module> 3 date = cftime.datetime(10,1,1).strftime() 4 print(date) ----> 5 xarray.cftime_range(date, periods=3, freq='Y') /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in cftime_range(start, end, periods, freq, normalize, name, closed, calendar) 963 964 if start is not None: --> 965 start = to_cftime_datetime(start, calendar) 966 start = _maybe_normalize_date(start, normalize) 967 if end is not None: /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in to_cftime_datetime(date_str_or_date, calendar) 683 "a calendar type must be provided" 684 ) --> 685 date, _ = _parse_iso8601_with_reso(get_date_type(calendar), date_str_or_date) 686 return date 687 elif isinstance(date_str_or_date, cftime.datetime): /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftimeindex.py in _parse_iso8601_with_reso(date_type, timestr) 101 102 default = date_type(1, 1, 1) --> 103 result = parse_iso8601(timestr) 104 replace = {} 105 /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftimeindex.py in parse_iso8601(datetime_string) 94 if match: 95 return match.groupdict() ---> 96 raise ValueError("no ISO-8601 match for string: %s" % datetime_string) 97 98 ValueError: no ISO-8601 match for string: 10-01-01 00:00:00 ``` Describe the solution you'd like
It would be good if Describe alternatives you've considered Specifying an ISO-8601 compatible format (using A work-around is to zero-pad manually
Additional context I think this is a relatively small addition to the codebase but would make it easier and less confusing to use the default format that is also used by the the function itself. It is easy to support as it is consistent and uniform. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4337/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | xarray 13221727 | issue |
Advanced export
JSON shape: default, array, newline-delimited, object
CREATE TABLE [issues] ( [id] INTEGER PRIMARY KEY, [node_id] TEXT, [number] INTEGER, [title] TEXT, [user] INTEGER REFERENCES [users]([id]), [state] TEXT, [locked] INTEGER, [assignee] INTEGER REFERENCES [users]([id]), [milestone] INTEGER REFERENCES [milestones]([id]), [comments] INTEGER, [created_at] TEXT, [updated_at] TEXT, [closed_at] TEXT, [author_association] TEXT, [active_lock_reason] TEXT, [draft] INTEGER, [pull_request] TEXT, [body] TEXT, [reactions] TEXT, [performed_via_github_app] TEXT, [state_reason] TEXT, [repo] INTEGER REFERENCES [repos]([id]), [type] TEXT ); CREATE INDEX [idx_issues_repo] ON [issues] ([repo]); CREATE INDEX [idx_issues_milestone] ON [issues] ([milestone]); CREATE INDEX [idx_issues_assignee] ON [issues] ([assignee]); CREATE INDEX [idx_issues_user] ON [issues] ([user]);