-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from usnistgov/70-build-tests-for-sst1rsoxsdb-…
…loader add CI tests for sst1rsoxsdb loader
- Loading branch information
Showing
2 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import sys | ||
sys.path.append("src/") | ||
|
||
try: | ||
import tiled | ||
import tiled.client | ||
try: | ||
client = tiled.client.from_profile('rsoxs') | ||
from PyHyperScattering.load import SST1RSoXSDB | ||
SKIP_DB_TESTING=False | ||
except tiled.profiles.ProfileNotFound: | ||
SKIP_DB_TESTING=True | ||
except ImportError: | ||
SKIP_DB_TESTING=True | ||
|
||
|
||
|
||
|
||
import numpy as np | ||
import pandas as pd | ||
import xarray as xr | ||
import pytest | ||
|
||
must_have_tiled = pytest.mark.skipif(SKIP_DB_TESTING,reason='Connection to Tiled server not possible in this environment.') | ||
|
||
|
||
@pytest.fixture(autouse=True,scope='module') | ||
def sstdb(): | ||
sstdb = SST1RSoXSDB(corr_mode='none') | ||
return sstdb | ||
|
||
@must_have_tiled | ||
def test_SST1DB_load_single_scan_legacy_hinted_dims(sstdb): | ||
run = sstdb.loadRun(21792).unstack('system') | ||
assert 'energy' in run.indexes | ||
|
||
@must_have_tiled | ||
def test_SST1DB_load_single_scan_legacy_explicit_dims(sstdb): | ||
run = sstdb.loadRun(21792,dims=['energy','polarization']).unstack('system') | ||
assert type(run) == xr.DataArray | ||
assert 'energy' in run.indexes | ||
assert 'polarization' in run.indexes | ||
|
||
@must_have_tiled | ||
def test_SST1DB_load_snake_scan_hinted_dims(sstdb): | ||
run = sstdb.loadRun(48812,dims=['sam_th','polarization']).unstack('system') | ||
assert type(run) == xr.DataArray | ||
assert 'sam_th' in run.indexes | ||
assert 'polarization' in run.indexes | ||
|
||
|
||
@must_have_tiled | ||
def test_SST1DB_load_snake_scan_explicit_dims(sstdb): | ||
run = sstdb.loadRun(48812).unstack('system') | ||
assert type(run) == xr.DataArray | ||
assert 'sam_th' in run.indexes | ||
assert 'polarization' in run.indexes |