Skip to content

Commit

Permalink
Merge pull request #284 from sblunt/v1-results-load-compatibility
Browse files Browse the repository at this point in the history
V1 results load compatibility
  • Loading branch information
semaphoreP committed Sep 28, 2021
2 parents c52c24e + 10fca1b commit 21c519f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ orbitize/example_data/*test.hdf5

# images & storage files generated by tutorials
*.hdf5
!orbitize/example_data/v1_posterior.hdf5
*.fits
*.png
tests/test_results.h5
Expand Down
Binary file added orbitize/example_data/v1_posterior.hdf5
Binary file not shown.
5 changes: 4 additions & 1 deletion orbitize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def load_results(self, filename, append=False):
post = np.array(hf.get('post'))
lnlike = np.array(hf.get('lnlike'))
data = np.array(hf.get('data'))
self.data = table.Table(data) # turn back into astropy table, also keeps str formatted right
try:
self.data = table.Table(data) # turn back into astropy table, also keeps str formatted right
except ValueError: # old version of results
self.data = None

# get the tau reference epoch
try:
Expand Down
13 changes: 12 additions & 1 deletion tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import orbitize
from orbitize import results, read_input
from orbitize import results, read_input, DATADIR
import numpy as np
import matplotlib.pyplot as plt
import pytest
Expand All @@ -14,6 +14,14 @@
'sma1': 0, 'ecc1':1, 'inc1':2, 'aop1':3, 'pan1':4, 'tau1':5, 'plx':6, 'mtot':7
}

def test_load_v1_results():
"""
Tests that loading a posterior generated with v1.0.0 of the code works.
"""

myResults = results.Results()
myResults.load_results('{}v1_posterior.hdf5'.format(DATADIR))


def simulate_orbit_sampling(n_sim_orbits):
"""
Expand Down Expand Up @@ -218,6 +226,9 @@ def test_plot_orbits(results_to_test):
return (Figure1, Figure2, Figure3, Figure4, Figure5)

if __name__ == "__main__":

test_load_v1_results()

test_results = test_init_and_add_samples()

test_results_printing(test_results)
Expand Down

0 comments on commit 21c519f

Please sign in to comment.