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

Passing empty array to date2num raises IndexError: index 0 is out of bounds for axis 0 with size 0 #315

Closed
roballsopp opened this issue Jan 22, 2024 · 1 comment

Comments

@roballsopp
Copy link

Environment:

cftime 1.6.2, Python 3.10.12

Description:

Passing an empty array to cftime.date2num raises the following error:

  File "src/cftime/_cftime.pyx", line 218, in cftime._cftime.date2num
IndexError: index 0 is out of bounds for axis 0 with size 0

Steps to Reproduce:

cftime.date2num([], 'seconds since 2000-01-01 12:00:00')

Expected Behavior

When passing an empty array, I expected an empty array to be returned without an error, or at least for date2num to raise a descriptive error ("an empty dates array is not supported"). The former seems to be the behavior of other functions in this package like num2pydate.

jswhit added a commit that referenced this issue Jan 23, 2024
jswhit added a commit that referenced this issue Jan 24, 2024
@jswhit
Copy link
Collaborator

jswhit commented Jan 24, 2024

closed by PR #316

@jswhit jswhit closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants