TST: tested generate_RW. Difficult to test outputs so just looked to …#68
TST: tested generate_RW. Difficult to test outputs so just looked to …#68nhuntwalker wants to merge 2 commits intoastroML:mainfrom
Conversation
…see if the mean of the output random walk is more or less centered around the input mean
|
For this test, we should explicitly set a random seed (otherwise there are rare cases in which it will fail). The best way is probably to use a local seed, e.g. # ...
rng = np.random.RandomState(0)
xmean = rng.rand()*200 - 100
N = len(t)
y = generate_damped_RW(t, tau=tau, z=z, xmean=xmean, random_state=rng)
# ... |
|
Same goes for other tests that depend on a random state. |
|
Yeah I was just realizing that as I was working on a test of the lomb_scargle_bootstrap module |
|
Interesting issue. I'm trying to test astroML.time_series.multiterm_periodogram and I'm feeding it the appropriate data structures (arrays) and it's not working. Toward the end of the function, it's dying because I'm apparently trying to set an array element with a sequence. Really what's happening is the function is trying to set an array element with an empty array. Not sure why numpy.linalg.lstsq() is returning an empty array |
|
It looks like in testing To write a unit test, you should think about what the purpose of the function is, and think about how to test that this purpose is fulfilled for a variety of inputs. For example, here we could use very well-sampled, high signal-to-noise data and check that (1) the routine returns the correct result, and (2) the distribution returned is very narrow around this value. Then use some poorly sampled/low signal-to-noise data and confirm that the resulting distribution is much wider. I would also add a routine which tests the exact numerical output for a known input. |
…see if the mean of the output random walk is more or less centered around the input mean