Skip to content

Conversation

@RobbieKiwi
Copy link
Contributor

Closes #451

Changes proposed in this Pull Request

Previously a timezone-aware datetime index coordinate would get converted into integers before comparison, resulting in a warning that the index does not match the pandas index.
Now there is special logic to handle this case that makes sure the coord is compared correctly.
Note this will only work in the 1D case

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@RobbieKiwi
Copy link
Contributor Author

Maybe it would be easier to disallow timezone indexes entirely. There are some other issues that can pop up (for example when adding tz-aware data to non tz aware data) that lead to an error with numpy not understanding the datetime[ns, UTC] type when it tries to join the data

Copy link
Collaborator

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great @RobbieKiwi ; any chance we can generalize to multi-dim case?

@RobbieKiwi
Copy link
Contributor Author

RobbieKiwi commented Dec 14, 2025

I added a check for the multi-dimensional case.
Also I added some logic to catch the strange type error that comes out of DataArray when you try to combine data with different timezones.
Previously this would lead to a not very useful error message something like:
"Cannot multiply pandas.Series with linopy.Variable"
Now instead there is a more useful error message which specifically mentions the timezone issue

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

Successfully merging this pull request may close these issues.

Using timezone aware datetime in coords causes a warning

2 participants