-
Notifications
You must be signed in to change notification settings - Fork 75
/
test_masscons.py
37 lines (31 loc) · 1.03 KB
/
test_masscons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ========================================================================
#
# Imports
#
# ========================================================================
import os
import numpy.testing as npt
import pandas as pd
import unittest
# ========================================================================
#
# Test definitions
#
# ========================================================================
class ConsTestCase(unittest.TestCase):
"""Tests for conservation in Pele."""
def test_conservation(self):
"""Are mass and energy conserved?"""
# Load the data
fdir = os.path.abspath(".")
fname = os.path.join(fdir, "datlog")
df = pd.read_csv(fname, sep="\\s+")
npt.assert_allclose(df.mass, df.mass[0], rtol=1e-13)
npt.assert_allclose(df.rho_E, df.rho_E[0], rtol=1e-13)
# ========================================================================
#
# Main
#
# ========================================================================
if __name__ == "__main__":
unittest.main()