Skip to content

Commit

Permalink
Disable two unit tests for chemicals wrapper that act strangely when …
Browse files Browse the repository at this point in the history
…JIT is disabled
  • Loading branch information
ma-sadeghi committed Jul 25, 2023
1 parent 5d1b18e commit 7c7d2fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
19 changes: 9 additions & 10 deletions tests/unit/models/phase/DensityTest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import pytest
import sys
import openpnm as op
from numpy.testing import assert_approx_equal, assert_allclose
from openpnm.utils import get_mixture_model_args
import os

import chemicals
import pytest
from numpy.testing import assert_allclose, assert_approx_equal
from thermo import Chemical

import openpnm as op
from openpnm.utils import get_mixture_model_args

is_python_38 = sys.version_info[:2] == (3, 8)
is_linux = sys.platform.startswith('linux')
condition = is_python_38 and is_linux
condition = int(os.environ.get('NUMBA_DISABLE_JIT', 0)) != 0


@pytest.mark.skipif(condition, reason="Strange error coming from numba/chemicals")
class DensityTest:
def setup_class(self):
self.net = op.network.Cubic(shape=[3, 3, 3])
Expand Down Expand Up @@ -54,6 +52,7 @@ def test_chemicals_for_pure_gas_molar_volume(self):
Vm.append(op.models.phase.chemicals_wrapper(n2, f=f).mean())
assert_allclose(Vm, 8.795e-6, rtol=.3)

@pytest.mark.skipif(condition, reason="Strange error coming from numba/chemicals")
def test_chemicals_wrapper_for_pure_liq_molar_volume(self):
mods = [
chemicals.volume.Yen_Woods_saturation,
Expand Down Expand Up @@ -158,5 +157,5 @@ def test_liquid_pure_and_mixture(self):
t.setup_class()
for item in t.__dir__():
if item.startswith('test'):
print('running test: '+item)
print(f"Running test: {item}")
t.__getattribute__(item)()
25 changes: 13 additions & 12 deletions tests/unit/models/phase/VaporPressureTest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import pytest
import sys
import numpy as np
import openpnm as op
import inspect
from numpy.testing import assert_approx_equal, assert_allclose
import os

import chemicals
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_approx_equal

import openpnm as op

is_python_38 = sys.version_info[:2] == (3, 8)
is_linux = sys.platform.startswith('linux')
condition = is_python_38 and is_linux
condition = int(os.environ.get('NUMBA_DISABLE_JIT', 0)) != 0


@pytest.mark.skipif(condition, reason="Strange error coming from numba/chemicals")
class VaporPressureTest:
def setup_class(self):
self.net = op.network.Cubic(shape=[3, 3, 3])
Expand Down Expand Up @@ -48,6 +46,7 @@ def test_water_no_salinity(self):
assert_approx_equal(self.phase['pore.test'].mean(), 3536.0130)
self.phase['pore.salinity'] = np.zeros((self.phase.Np,))

@pytest.mark.skipif(condition, reason="Strange error coming from numba/chemicals")
def test_generic_chemicals_for_pure_liquid(self):
mods = [
# chemicals.vapor_pressure.Wagner_original, # Needs constants
Expand Down Expand Up @@ -75,15 +74,17 @@ def test_pure_liquid_vapor_pressure_models(self):
'Lee_Kesler': op.models.phase.vapor_pressure.liquid_pure_lk,
# 'Antoine': op.models.phase.vapor_pressure.liquid_pure_antoine,
}
data = chemicals.vapor_pressure.Psat_data_AntoinePoling
# data = chemicals.vapor_pressure.Psat_data_AntoinePoling
for k, v in vals.items():
print(f'Testing {k}')
f = getattr(chemicals.vapor_pressure, k)
args = inspect.getfullargspec(f)[0]
# args = args[0][:-len(args.defaults)]
kwargs = {i: np.atleast_1d(phase[argmap[i]])[0] for i in args}
# if len(set(args).intersection(set(['A', 'B', 'C']))) == 3:
# kwargs.update({i: data.loc[phase.params['CAS']][i] for i in ['A', 'B', 'C']})
# kwargs.update(
# {i: data.loc[phase.params['CAS']][i] for i in ['A', 'B', 'C']}
# )
ref = f(**kwargs)
val = v(phase)[0]
assert_allclose(ref, val, rtol=1e-13)
Expand All @@ -96,5 +97,5 @@ def test_pure_liquid_vapor_pressure_models(self):
t.setup_class()
for item in t.__dir__():
if item.startswith('test'):
print('running test: '+item)
print(f'Running test: {item}')
t.__getattribute__(item)()

0 comments on commit 7c7d2fb

Please sign in to comment.