mirror of
https://github.com/fjosw/pyerrors.git
synced 2026-08-04 11:31:21 +02:00
Silence NPY002 on intentional legacy np.random calls
The RNG migration was reverted to keep np.random.seed() behavior, so add per-line noqa: NPY002 on the three legacy np.random calls instead of the Generator API.
This commit is contained in:
parent
9be9fb6767
commit
3ca4b18edb
2 changed files with 3 additions and 3 deletions
|
|
@ -946,6 +946,6 @@ def _construct_prior_obs(i_prior, i_n):
|
|||
return i_prior
|
||||
elif isinstance(i_prior, str):
|
||||
loc_val, loc_dval = _extract_val_and_dval(i_prior)
|
||||
return cov_Obs(loc_val, loc_dval ** 2, '#prior' + str(i_n) + f"_{np.random.randint(2147483647):010d}")
|
||||
return cov_Obs(loc_val, loc_dval ** 2, '#prior' + str(i_n) + f"_{np.random.randint(2147483647):010d}") # noqa: NPY002
|
||||
else:
|
||||
raise TypeError("Prior entries need to be 'Obs' or 'str'.")
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ def pseudo_Obs(value, dvalue, name, samples=1000):
|
|||
return Obs([np.zeros(samples) + value], [name])
|
||||
else:
|
||||
for _ in range(100):
|
||||
deltas = [np.random.normal(0.0, dvalue * np.sqrt(samples), samples)]
|
||||
deltas = [np.random.normal(0.0, dvalue * np.sqrt(samples), samples)] # noqa: NPY002
|
||||
deltas -= np.mean(deltas)
|
||||
deltas *= dvalue / np.sqrt(np.var(deltas) / samples) / np.sqrt(1 + 3 / samples)
|
||||
deltas += value
|
||||
|
|
@ -163,7 +163,7 @@ def gen_correlated_data(means, cov, name, tau=0.5, samples=1000):
|
|||
raise Exception('All integrated autocorrelations have to be >= 0.5.')
|
||||
|
||||
a = (2 * tau - 1) / (2 * tau + 1)
|
||||
rand = np.random.multivariate_normal(np.zeros_like(means), cov * samples, samples)
|
||||
rand = np.random.multivariate_normal(np.zeros_like(means), cov * samples, samples) # noqa: NPY002
|
||||
|
||||
# Normalize samples such that sample variance matches input
|
||||
norm = np.array([np.var(o, ddof=1) / samples for o in rand.T])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue