DHI / mikeio

Read, write and manipulate dfs0, dfs1, dfs2, dfs3, dfsu and mesh files.
https://dhi.github.io/mikeio
BSD 3-Clause "New" or "Revised" License
136 stars 53 forks source link

MIKEIO 1.6.3 is not working with the Pandas 2.1.3 #626

Closed mohm-dhi closed 7 months ago

mohm-dhi commented 7 months ago

Installing mikeio 1.6.3 now install pandas 2.1.3 as it dependency which is not compatible with mikeio. We should fix the pandas version to be less than 2. I tested this on a new environment that only had mikeio installed. Using mikeio 1.4.1 and Pandas 1.5.3 the problem solved but I need newer version of mikeio.

import mikeio

ds = mikeio.read("input/file.dfs2") print(ds)


ERROR MESSAGE

Traceback (most recent call last): File "C:\DHI\42803850 - CCZIS\pythonProject\main.py", line 3, in ds = mikeio.read("input/CHS_bathy_CGVD2013_R1.dfs2") File "C:\DHI\DHI Mikeio\mikeio__init__.py", line 127, in read return dfs.read(items=items, time=time, keepdims=keepdims, **kwargs) File "C:\DHI\DHI Mikeio\mikeio\dfs_dfs2.py", line 216, in read single_time_selected, time_steps = _valid_timesteps(self._dfs.FileInfo, time) File "C:\DHI\DHI Mikeio\mikeio\dfs_dfs.py", line 151, in _valid_timesteps time = pd.date_range(start_time_file, periods=nt, freq=freq) File "C:\Users\mohm\Miniconda3\envs\cczis\lib\site-packages\pandas\core\indexes\datetimes.py", line 945, in date_range dtarr = DatetimeArray._generate_range( File "C:\Users\mohm\Miniconda3\envs\cczis\lib\site-packages\pandas\core\arrays\datetimes.py", line 446, in _generate_range i8values = generate_regular_range(start, end, periods, freq, unit=unit) File "C:\Users\mohm\Miniconda3\envs\cczis\lib\site-packages\pandas\core\arrays_ranges.py", line 84, in generate_regular_range values = np.arange(b, e, stride, dtype=np.int64) ValueError: arange: cannot compute length

mohm-dhi commented 7 months ago

to add to the above: installing mikeio 1.6.2 with pandas 2.1.3 works without problem 💯 why 1.6.3 is not working then !

ecomodeller commented 7 months ago

Strange, I haven't seen any tests failing from the main branch related to pandas 2.1.3

ecomodeller commented 7 months ago

Hi @mohm-dhi I don't see this issue, can you provide a failing test, that shows when it fails?

$ pip list|grep -e pandas -e mikeio
mikeio                        1.6.3
pandas                        2.1.3
$ pwd
/workspaces/mikeio
$ pytest -q
731 passed, 3 warnings in 24.71s
mohm-dhi commented 7 months ago

I explained and showed you the way I tested it. I just created a new environment using python 3.10 and only pip install mikeio, then I run that simple code to read dfs2 files and show the results.

I tested that on docker too and same results. if you want I can quickly show you on a team call.

ecomodeller commented 7 months ago

Well it is bedtime in Europe😴

Is this by any chance related to #620 or how come it is only relevant for Dfs2?

mohm-dhi commented 7 months ago

we can chat tomorrow. I did not test on other data type but will do.

mohm-dhi commented 7 months ago

I checked dfsu and it is working, I checked another dfs2 file and that works too. Strange, this Dfs2 that has problem supposed to be the standard dsf2 file that I download from MIKE Cloud. So probably an issue with this file.

mohm-dhi commented 7 months ago

I think you are right, it is related to that issue in the PR 620, it is only one time step in the file and that is the output when reading it using mikeio 1.6.2. image