Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize tests to use pytest #39

Merged
merged 7 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand Down Expand Up @@ -144,3 +145,5 @@ ENV/

# Rope project settings
.ropeproject


7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
include:
- stage: test
script:
- scons --test
- scons
- pytest tests
compiler: gcc
env: COMPILER=g++-4.8
addons:
Expand Down Expand Up @@ -62,6 +63,6 @@ env:
- PYTHON_VERSION=3.6
- NUMPY_VERSION='stable'
- ASTROPY_VERSION='stable'
- CONDA_DEPENDENCIES='matplotlib scons seaborn jinja2 lxml'
- PIP_DEPENDENCIES='git+git://github.com/wtbarnes/cldoc.git@py3fix mkdocs mkdocs-material beautifulsoup4'
- CONDA_DEPENDENCIES='matplotlib scons seaborn jinja2 lxml pytest'
- PIP_DEPENDENCIES='git+git://github.com/wtbarnes/cldoc.git@py3fix mkdocs mkdocs-material beautifulsoup4 hissw'
- secure: fEC6R5e7+R/vcEY+Av7cWPUHVn2eKVRdrgPy2t9l4ja8op3OFL6gsMA4kUXmWfVT+kxwu7OfNzoId/2NQHoqNxGY3qV/dV+kE36xOy9go1aPTCfc2r5oZeWn8kDnoyBr8/hqO7LBMlpjgFGll+YVxm8YLmOFYxGI5JSeihAy2N7Lrs6V10OLFT3cnyWXMp40E/90G1he5RJbh+7KBtz2l82wDoqdVM+7mhEVdZLkVrpdcUGBY9UjVTTSO8Y0wYfAPi+HciFkJLKCbp76gQtjOVvSQTjZyBmHwJmpMXHO4NXhRQQn5uR4CLLCuv35YyijUGck1DUoLoSW70g8PuISOhdiEVeWZ6rp8gnK6a/XWIyhJhj8OwOdufFoYYVvSckmOy49uFmOZAGArNzYDPNRr3/wE6Crb1tScjJvTmcE57/qeUOidKqrRloS2n/evQEY3ES4HuVtb3gHWoQq1X9QqoeS0G3dAPwqJeEYzhDHEuDS5pPHbMaqnLHmvy/M3I8mqsGhTNloAsjvMwavKoCBnUkDpjHaGhGzTTq0qCVmkubekL+Op3s/bE39G4WRD6W61HGNoJIi/XGRiy6aPwjBOEJMgpmx9YQ1zAxmdEi78BEJfO2sGrL1X5ghT42IBiYz3eueYXl/2EcaDVzn/dn+3IA9YdiCgCWx0y3R44mbiKI=
9 changes: 0 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,4 @@ for sd in subdirs:
if not os.path.exists('bin'):
os.makedirs('bin')

print('Compiling ebtel++')
env.Program('bin/ebtel++.run', allobjs)

if GetOption('test'):
print('Running tests...')
try:
python_path = os.path.join(os.environ['CONDA_PREFIX'], 'bin', 'python')
except KeyError:
python_path = 'python'
env.Command('dummy', None, '{} test/run_tests.py'.format(python_path))
2 changes: 1 addition & 1 deletion docs/mkdocs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ An ebtel++ run is configured by a single XML configuration file. The table below
| **calculate_dem** | `bool` | if True, do the TR and coronal DEM calculation; increases compute time significantly |
| **save_terms** | `bool` | if True, save heat flux, $c_1$ parameter, and radiative loss to a separate file `<output_filename>.terms` |
| **use_adaptive_solver** | `bool` | if True, use adaptive timestep; significantly smaller compute times. In both cases, a Runge-Kutta Cash-Karp integration method is used (see section 16.2 of [Press et al. (1992)][press_num_recipes]) |
| **o.utput_filename** | `string` | path to output file |
| **output_filename** | `string` | path to output file |
| **adaptive_solver_error** | `float` | Allowed truncation error in adaptive timestep routine |
| **adaptive_solver_safety** | `float` | Refinement factor, between 0 and 1, used if timestep becomes too large and solution contains NaNs. Especially important for short, infrequently heated loops. Also controls decreases in timestep due to thermal conduction timestep. Suggested value is 0.5 |
| **c1_cond0** | `float` | Nominal value of $c_1$ during the conduction phase; see Appendix A of [Barnes et al. (2016)][barnes_2016] |
Expand Down
9 changes: 5 additions & 4 deletions docs/xml_to_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def func_info(node, value):
return [f'`{a.find("type").attrs["name"]}` {a.attrs["name"]}' for a in args]
elif value == 'args':
args = node.findAll('argument')
return [{'name': a.attrs['name'], 'description': '' if a.find('doc') is None
return [{'name': a.attrs['name'], 'description': '' if a.find('doc') is None
else a.find('doc').text} for a in args]
elif value == 'return':
return node.find('return').find('type').attrs['name']
Expand All @@ -134,7 +134,7 @@ def parse_class(filename):
class_doc = soup.find('html').find('body').find('class')
# Top level info
name = class_doc.attrs['name']
desc = class_doc.find('doc', recursive=False).text.replace('\n',' ')
desc = class_doc.find('doc', recursive=False).text.replace('\n', ' ')
# Parse Sections
fields = class_doc.find_all('field', recursive=False)
variables = class_doc.find_all('variable', recursive=False)
Expand All @@ -154,12 +154,13 @@ def parse_struct(filename):
soup = BeautifulSoup(f, 'lxml')
struct_doc = soup.find('html').find('body').find('struct')
name = struct_doc.attrs['name']
desc = struct_doc.find('brief', recursive=False).text.replace('\n',' ')
desc = struct_doc.find('brief', recursive=False).text.replace('\n', ' ')
fields = struct_doc.find_all('field', recursive=False)
env = Environment(loader=DictLoader({'struct': struct_template}))
env.filters.update({'field_info': field_info})
return env.get_template('struct').render(name=name, desc=desc, fields=fields,)


def parse_typedef(filename):
with open(filename, 'r') as f:
soup = BeautifulSoup(f, 'lxml')
Expand All @@ -179,7 +180,7 @@ def parse_typedef(filename):
with open(os.path.join(args.xml_dir, 'index.xml'), 'r') as f:
index = BeautifulSoup(f, 'lxml').find('html').find('body').find('index')
entries = [(c.name, c.attrs['name']) for c in index if c.name is not None]
entries = {k: [e[1] for e in entries if e[0]==k] for k in set([e[0] for e in entries])}
entries = {k: [e[1] for e in entries if e[0] == k] for k in set([e[0] for e in entries])}
# Setup environment
env = Environment(loader=DictLoader({'api': api_template}))
# Parse classes
Expand Down
14 changes: 3 additions & 11 deletions source/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,8 @@ state_type Loop::CalculateInitialConditions(void)
}

// Set current state in order pressure_e, pressure_i, density
// Force same if single-fluid enforced
pi_initial = parameters.boltzmann_correction*BOLTZMANN_CONSTANT*density*temperature;
if(parameters.force_single_fluid)
{
pe_initial = pi_initial;
}
else
{
pe_initial = BOLTZMANN_CONSTANT*density*temperature;
}
pe_initial = BOLTZMANN_CONSTANT*density*temperature;
state = {{ pe_initial, pi_initial, density, temperature, temperature }};

return state;
Expand Down Expand Up @@ -386,8 +378,8 @@ double Loop::CalculateScaleHeight(double temperature_e,double temperature_i)
void Loop::CalculateAbundanceCorrection(double helium_to_hydrogen_ratio)
{
double z_avg = (1.0 + 2.0*helium_to_hydrogen_ratio)/(1.0 + helium_to_hydrogen_ratio);
parameters.boltzmann_correction = (1.0 + 1.0/z_avg)/2.0;
parameters.ion_mass_correction = (1.0 + 4.0*helium_to_hydrogen_ratio)/(2.0 + 3.0*helium_to_hydrogen_ratio)*2.0*parameters.boltzmann_correction;
parameters.boltzmann_correction = 1.0/z_avg;
parameters.ion_mass_correction = (1.0 + 4.0*helium_to_hydrogen_ratio)/(2.0 + 3.0*helium_to_hydrogen_ratio)*(1.0 + z_avg)/z_avg;
}

double Loop::CalculateVelocity(double temperature_e, double temperature_i, double pressure_e)
Expand Down
1 change: 0 additions & 1 deletion test/__init__.py

This file was deleted.

62 changes: 0 additions & 62 deletions test/run_tests.py

This file was deleted.

Empty file added tests/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest


def pytest_addoption(parser):
parser.addoption(
"--ebtel_idl_path", action="store", default=None, help="Path to EBTEL IDL code"
)


@pytest.fixture
def ebtel_idl_path(request):
return request.config.getoption("--ebtel_idl_path")
Loading