Maintenance will be performed on,,, and on Tuesday 19th January 2021 starting at approximately 8am MST. It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please direct and comments, questions, or concerns to

Commit faeaacee authored by John Douglas Veitch's avatar John Douglas Veitch

Merge branch 'nonstrict_version' into 'master'

lalinference_nest2pos: allow non-strict enforcement of identical LALSuite versions

See merge request !560
parents dfeda784 dc504362
Pipeline #37643 passed with stages
in 71 minutes and 30 seconds
......@@ -11,7 +11,7 @@ from lalinference import LALInferenceHDF5PosteriorSamplesDatasetName as posterio
from lalinference import LALInferenceHDF5NestedSamplesDatasetName as nested_dset_name
from lalinference.nest2pos import draw_posterior_many, draw_N_posterior_many, compute_weights
usage = '''%prog [-N Nlive] [-p posterior.hdf5] [-H header.txt] [--npos Npos] datafile1.hdf5 [datafile2.hdf5 ...]
usage = '''%prog [-N Nlive] [-p posterior.hdf5] [-H header.txt] [--npos Npos] [--non-strict-versions] datafile1.hdf5 [datafile2.hdf5 ...]
%prog takes at least one nested sampling output file and outputs posterior
\tsamples. If more than one input file is specified, each file is converted,
......@@ -25,7 +25,7 @@ usage = '''%prog [-N Nlive] [-p posterior.hdf5] [-H header.txt] [--npos Npos] da
def read_nested_from_hdf5(nested_path_list):
def read_nested_from_hdf5(nested_path_list, strict_versions=True):
headers = None
input_arrays = []
metadata = {}
......@@ -45,9 +45,12 @@ def read_nested_from_hdf5(nested_path_list):
if key in metadata[level]:
if collision == 'raise':
if attrs[key]!=metadata[level][key]:
raise ValueError(
'Metadata mismtach on level %r for key %r:\n\t%r != %r'
% (level, key, attrs[key], metadata[level][key]))
if key == 'version' and not strict_versions:
raise ValueError(
'Metadata mismtach on level %r for key %r:\n\t%r != %r'
% (level, key, attrs[key], metadata[level][key]))
elif collision == 'append':
if isinstance(metadata[level][key], list):
......@@ -249,6 +252,11 @@ if __name__ == '__main__':
'-v', '--verbose', action='store_true', default=False,
help='Print some additional information')
'--non-strict-versions', action='store_true', dest='nonstrict',
default=False, help='Set this flag to allow combining of nested '
'sample HDF5 files that do no necessarily have '
'the same verion information')
opts, args = parser.parse_args()
# Argument checking
......@@ -278,7 +286,8 @@ if __name__ == '__main__':
print('Nlive is ignored in favor of the value in the HDF metadata.')
# Read the input file
return_values = read_nested_from_hdf5(datafiles)
return_values = read_nested_from_hdf5(datafiles,
strict_versions=(not opts.nonstrict))
(input_arrays, log_noise_evidence, log_max_likelihood,
metadata, nlive, run_identifier) = return_values
if len(input_arrays)==0:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment