slgentil / croco

Code CROCO de base + CONFIGS qui contient les différentes configurations
0 stars 1 forks source link

test on dimensions in `interp2z` fails if no name #22

Closed NoeLahaye closed 4 years ago

NoeLahaye commented 4 years ago

https://github.com/slgentil/croco/blob/7dcdfeb068c8dfae015c29cc519c3bd0fa67493c/crocosi/gridop.py#L493

if v (the DataArrayto interpolate) has no name, this raises the error:

ValueError: cannot reset_coords with drop=False on an unnamed DataArrray

apatlpo commented 4 years ago

wow this seems like a strong constraint to me.

But I don't understand why we are resetting coords here? Couldn't we just do:

    if z_dim==zt_dim and not v[z_dim].equals(zt[zt_dim]):

? @NoeLahaye, gitblame seems to indicate this was added during the vmodes PR. Could you please look at the above suggestion and see if it breaks your workflow?

NoeLahaye commented 4 years ago

can you explain to me what is gitblame? It seems to be very useful.

Your suggestion was indeed a previous version, if I remember correctly. The reason why we had to use reset_coords is that just comparing with equals is raising an error if some coordinates are different. cf. DataArray.equals doc:

True if two DataArrays have the same dimensions, coordinates and values; otherwise False

apatlpo commented 4 years ago

gitblame: if you click on 1/ the link in your initial post that brings you to the line of code that breaks and then 2/ on the three dots right next to the line number and 3/ on View git blame you'll have a view of how each line of code was modified last.

After reading DataArray.equals doc, shouldn't we use more simply ==?

NoeLahaye commented 4 years ago

After reading DataArray.equals doc, shouldn't we use more simply ==?

Lol, you are probably right... Which one of us make the change and try it?

NoeLahaye commented 4 years ago

fixed in c16668c