html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/7834#issuecomment-1543534474,https://api.github.com/repos/pydata/xarray/issues/7834,1543534474,IC_kwDOAMm_X85cAHeK,132147,2023-05-11T08:07:58Z,2023-05-11T08:07:58Z,CONTRIBUTOR,"I thtew this pull request up before leaving the office so it would run all the tests. Turns out that `np.can_cast` is the wrong option here. It doesn't consider casting floats to integers safe even if all values are correctly representable. Another solution will have to be found.
I can investigate further on Monday, and combine this with the linked issues. Thanks for the extra context
--
Tim Heap
***@***.***
On Thu, 11 May 2023, at 18:03, Kai Mühlbauer wrote:
>
>
> @mx-moth Yes, this casting should be fixed.
>
> I'm adding a bit of context here, as this might need to be solved in combination with #7098 and #7827 . #7098 removes undefined casting for decoding. In #7827 there are efforts to do this for encoding, too.
>
> As `cast_to_int_if_safe` is called for encoding as well as decoding I'm not sure if all cases have been catched by these two PR.
>
> One issue on decoding is that at least for datetime64 based times the calculated `time_deltas` are currently converted to float64 in the presence of `NaT` (although `NaT` can perfectly be expressed as int64). It would be great if you could try your PR on top of #7827 (which includes #7098 ) to see if that fixes the errors in this PR.
>
>
> —
> Reply to this email directly, view it on GitHub , or unsubscribe .
> You are receiving this because you were mentioned.Message ID: ***@***.***>
> ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1705163672
https://github.com/pydata/xarray/pull/7834#issuecomment-1543433057,https://api.github.com/repos/pydata/xarray/issues/7834,1543433057,IC_kwDOAMm_X85b_uth,132147,2023-05-11T06:52:46Z,2023-05-11T06:52:46Z,CONTRIBUTOR,"Using latest xarray and numpy >= 1.24.0, the following code generates a warning. This function is called when saving datasets to disk using `dataset.to_netcdf`:
```python
import numpy as np
from xarray.coding.times import cast_to_int_if_safe
array = np.array([1., 2., np.nan])
cast_to_int_if_safe(array)
```
```
$HOME/projects/xarray/xarray/coding/times.py:619: RuntimeWarning: invalid value encountered in cast
int_num = np.asarray(num, dtype=np.int64)
array([ 1., 2., nan])
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1705163672
https://github.com/pydata/xarray/pull/7834#issuecomment-1543417823,https://api.github.com/repos/pydata/xarray/issues/7834,1543417823,IC_kwDOAMm_X85b_q_f,132147,2023-05-11T06:36:59Z,2023-05-11T06:36:59Z,CONTRIBUTOR,"Unsure if new tests need to be added, as the intention is that no behaviour changes except for the lack of warnings from numpy.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1705163672
https://github.com/pydata/xarray/pull/6049#issuecomment-1000813144,https://api.github.com/repos/pydata/xarray/issues/6049,1000813144,IC_kwDOAMm_X847pzJY,132147,2021-12-24T12:06:36Z,2021-12-24T12:06:36Z,CONTRIBUTOR,Thanks!,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1071806607
https://github.com/pydata/xarray/pull/6049#issuecomment-987270522,https://api.github.com/repos/pydata/xarray/issues/6049,987270522,IC_kwDOAMm_X8462I16,132147,2021-12-06T21:58:06Z,2021-12-06T21:58:06Z,CONTRIBUTOR,"The `ubuntu-latest-py38-flakey` check is failing due to a 503 Service Unavailable for something I've not modified. I cant seem to prod the test runner to run that check again, in case it was a temporary error.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1071806607