mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
utils test added
This commit is contained in:
parent
4f8345ac86
commit
b491096a95
3 changed files with 19 additions and 5 deletions
4
.github/workflows/CI.yml
vendored
4
.github/workflows/CI.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
|
||||
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9"]
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
|
@ -27,7 +27,7 @@ jobs:
|
|||
- name: Install
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e .
|
||||
pip install .
|
||||
pip install pytest
|
||||
pip install pytest-cov
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ class Obs:
|
|||
arr[r] = (self.r_values[r_name] - sub_r_mean) / (self.e_dvalue[e_name] * np.sqrt(e_N / self.shape[r_name] - 1))
|
||||
plt.hist(arr, rwidth=0.8, bins=len(self.e_content[e_name]))
|
||||
plt.title('Replica distribution' + e_name + ' (mean=0, var=1), Q=' + str(np.around(self.e_Q[e_name], decimals=2)))
|
||||
plt.show()
|
||||
plt.draw()
|
||||
|
||||
def plot_history(self):
|
||||
"""Plot derived Monte Carlo history for each ensemble."""
|
||||
|
@ -440,7 +440,7 @@ class Obs:
|
|||
plt.errorbar(x, y, fmt='.', markersize=3)
|
||||
plt.xlim(-0.5, e_N - 0.5)
|
||||
plt.title(e_name)
|
||||
plt.show()
|
||||
plt.draw()
|
||||
|
||||
def plot_piechart(self):
|
||||
"""Plot piechart which shows the fractional contribution of each
|
||||
|
@ -454,7 +454,7 @@ class Obs:
|
|||
fig1, ax1 = plt.subplots()
|
||||
ax1.pie(sizes, labels=labels, startangle=90, normalize=True)
|
||||
ax1.axis('equal')
|
||||
plt.show()
|
||||
plt.draw()
|
||||
|
||||
return dict(zip(self.e_names, sizes))
|
||||
|
||||
|
|
|
@ -171,3 +171,17 @@ def test_overloaded_functions():
|
|||
assert np.max((ad_obs.deltas['t'] - fd_obs.deltas['t']) / ad_obs.deltas['t']) < 1e-8, item.__name__
|
||||
assert np.abs((ad_obs.value - item(val)) / ad_obs.value) < 1e-10, item.__name__
|
||||
assert np.abs(ad_obs.dvalue - dval * np.abs(deriv[i](val))) < 1e-6, item.__name__
|
||||
|
||||
def test_utils():
|
||||
my_obs = pe.pseudo_Obs(1.0, 0.5, 't')
|
||||
my_obs.print(0)
|
||||
my_obs.print(1)
|
||||
my_obs.print(2)
|
||||
assert not my_obs.zero_within_error()
|
||||
my_obs.plot_tauint()
|
||||
my_obs.plot_rho()
|
||||
my_obs.plot_rep_dist()
|
||||
my_obs.plot_history()
|
||||
my_obs.plot_piechart()
|
||||
assert my_obs > (my_obs - 1)
|
||||
assert my_obs < (my_obs + 1)
|
||||
|
|
Loading…
Add table
Reference in a new issue