EcohydrologyTeam / ClearWater-modules

A collection of water quality and vegetation process simulation modules designed to couple with water transport models.
MIT License
5 stars 0 forks source link

Update all process function typehints (whoops...) #43

Open xaviernogueira opened 9 months ago

xaviernogueira commented 9 months ago

An easy but annoying issue.

Basically all our process functions have incorrect type hints now. I misunderstood xarray.apply_ufunc when I made our process functions have the float in/output typehints. For example:

def a_process_func(input: float) -> float:
     ...

Really, these functions are actually passed the a full xr.DataArray directly. So we need to update these to:

def a_process_func(input: xr.DataArray) -> xr.DataArray:
     ...

Sorry if this is annoying! Since these are scattered all over I think it's best that we just do it going forward and do a search/replace to easily pick up the old ones.

If you find all ": float" and "-> float" you can replace with ": xr.DataArray" and "-> xr.DataArray" respectively. Should only take a few seconds.

My bad!

xaviernogueira commented 7 months ago

Note: (I can handle this), but in PR #53 as well as via using numpy.select instead of xarray.where, we know have process functions in practice outputting numpy.ndarrays. Therefore typehints will need to be updated again.

Just like this:

def a_process_func(input: np.ndarray) -> np.ndarray:
     ...