fastscape-lem / fastscape

A fast, versatile and user-friendly landscape evolution model
https://fastscape.readthedocs.io
BSD 3-Clause "New" or "Revised" License
53 stars 12 forks source link

Add more tests #19

Closed rlange2 closed 9 months ago

rlange2 commented 4 years ago

With this PR, it's planned to update the current test routine for the available Fastscape processes.

I started with initial conditions, which include BareRockSurface, NoErosionHistory, FlatSurface, and Escarpment. The former three are relatively straight forward to do. In Escarpment I considered three cases to parametrize:

I'm not sure if more cases should be included, e.g. zero or negative elevation. Moreover, I don't fully understand what the code following

if scarped_width > 0:

is meant to do, i.e. the full logic behind it. I tried to come up with a proper example but I ended up running into other issues. Because of this, I haven't tested yet the if condition.

Additionally, for testing the FastscapelibContext I supplied a value for ibc since none was given and the test fails otherwise. Do we need to call ibc at one point during the testing? As far as I can see, it's not part of the context dictionary (I might be wrong here).

One more thing, I want to mention. elevation_left has to be a float because of the following line:

self.elevation[:, 1:-1] += np.random.rand(*self.shape)[:, 1:-1]

It's probably a good idea, to include an additional check. Otherwise, a UFuncTypeError is raised.

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

But maybe you want to talk about it in a separate issue.

benbovy commented 3 years ago

elevation_left has to be a float because of the following line:

Good catch. Will fix that in another PR. It will be better to set the dtype of elevation explicitly.