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

No check of input lengths in meshkernel.GeometryList() #32

Closed
veenstrajelmer opened this issue Feb 7, 2023 · 0 comments · Fixed by #80
Closed

No check of input lengths in meshkernel.GeometryList() #32

veenstrajelmer opened this issue Feb 7, 2023 · 0 comments · Fixed by #80
Labels
bug Something isn't working

Comments

@veenstrajelmer
Copy link
Collaborator

Describe the bug
When supplying x_coordinates and values of different lengths to meshkernel.GeometryList(), I would expect an error but none is given.

To Reproduce

import meshkernel
import xarray as xr
import numpy as np
#general settings
lon_min,lon_max = -6,2
lat_min,lat_max = 48.5,51.2

#select and plot bathy
file_nc_bathy = r'p:\metocean-data\open\GEBCO\2021\GEBCO_2021.nc'
data_bathy = xr.open_dataset(file_nc_bathy)
data_bathy_sel = data_bathy.sel(lon=slice(lon_min-1,lon_max+1),lat=slice(lat_min-1,lat_max+1))

#convert bathy data to geomlist
samp_x,samp_y = np.meshgrid(data_bathy_sel.lon.to_numpy(),data_bathy_sel.lat.to_numpy())
samp_z = data_bathy_sel.elevation.to_numpy().astype(float)
samp_x = samp_x.ravel()
samp_y = samp_y.ravel()
samp_z = samp_z.ravel()
geomlist = meshkernel.GeometryList(x_coordinates=samp_x, y_coordinates=samp_y, values=samp_z[1:])

Expected behavior
An error when supplying input of different lengths

Version info (please complete the following information):

  • OS: Windows, Spyder
  • Version 2.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants