Skip to content

Commit

Permalink
adding back in test with slightly change path set up
Browse files Browse the repository at this point in the history
  • Loading branch information
kirstybayliss committed Nov 8, 2023
1 parent 33ab4ff commit 97b6b88
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions openquake/wkf/tests/adaptive_smoothing_wkf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from openquake.hmtk.parsers.catalogue import CsvCatalogueParser
from pathlib import Path

HERE = os.path.dirname(__file__)
HERE = Path(__file__).parent
#HERE = os.path.dirname(__file__)
DATA_PATH = os.path.relpath(os.path.join(HERE, 'data', 'adap_smooth'))

class AdaptiveSmoothingTestwkf(unittest.TestCase):
Expand Down Expand Up @@ -85,30 +86,30 @@ def test_adap_smooth(self):
computed = pd.read_csv(fname_out)
np.testing.assert_almost_equal(expected, computed['nocc'], decimal=4)

# def test_adap_smoothing_wkf(self):
# """ Test adaptive smoothing build """
#
# # set up tmp directory and tmp file
# tmpdir = Path(tempfile.gettempdir())
# if not os.path.exists(tmpdir):
# os.makedirs(tmpdir)
def test_adap_smoothing_wkf(self):
""" Test adaptive smoothing build """

# set up tmp directory and tmp file
tmpdir = Path(tempfile.gettempdir())
if not os.path.exists(tmpdir):
os.makedirs(tmpdir)

# folder_out = tempfile.mkdtemp(suffix='adapsmooth', prefix=None, dir=tmpdir)
# fname_out = '{}/smooth_adap.csv'.format(folder_out)
folder_out = tempfile.mkdtemp(suffix='adapsmooth', prefix=None, dir=tmpdir)
fname_out = '{}/smooth_adap.csv'.format(folder_out)

# config = os.path.join(DATA_PATH, 'smooth_config.toml')
# fname_h3 = os.path.join(DATA_PATH, 'mapping_h2.csv')
config = os.path.join(DATA_PATH, 'smooth_config.toml')
fname_h3 = os.path.join(DATA_PATH, 'mapping_h2.csv')

# Run the code
# cmd = f"oqm wkf wkf_adaptive_smoothing {self.fname} {fname_h3} {config} {fname_out}"
# p = subprocess.run(cmd, shell=True)
cmd = f"oqm wkf wkf_adaptive_smoothing {self.fname} {fname_h3} {config} {fname_out}"
p = subprocess.run(cmd, shell=True)

# assert p.returncode == 0
assert p.returncode == 0

# expected = np.array([0.000984, 0.000983, 0.001360, 0.001375,0.002249,
# 0.002325, 0.000881, 0.001852, 0.001765, 0.002598, 0.002911, 0.000004,
# 0.000044, 0.000926, 0.000099, 0.002677, 0.001304])
expected = np.array([0.000984, 0.000983, 0.001360, 0.001375,0.002249,
0.002325, 0.000881, 0.001852, 0.001765, 0.002598, 0.002911, 0.000004,
0.000044, 0.000926, 0.000099, 0.002677, 0.001304])

# set up an expected
# computed = pd.read_csv(fname_out)
# np.testing.assert_almost_equal(expected, computed['nocc'], decimal=4)
computed = pd.read_csv(fname_out)
np.testing.assert_almost_equal(expected, computed['nocc'], decimal=4)

0 comments on commit 97b6b88

Please sign in to comment.