Exemple #1
0
def merge_data(data_list, attrs_list):
    """Merge dictionaries with data.

    Keyword arguments:
    data_list -- the dictionary with data dictionaries
    """

    data = None
    attrs = None

    for f in data_list:
        size = check.get_size(data_list[f])
        if not data:
            print "\nThe following datasets were found in %s:\n" % f
            msg.list_dataset(data_list[f])
            data = data_list[f]
            attrs = attrs_list[f]
        else:
            print "\nAdding %(n)d entries from %(f)s" % {"n": size, "f": f}
            check.check_keys(data, data_list[f])
            check.check_shapes(data, data_list[f])
            for key in data_list[f]:
                data[key] = np.append(data[key], data_list[f][key], axis=0)
            attrs['n_events'] += attrs_list[f]['n_events']

    return data, attrs
def add_data(source, output, range):

    """Merge dictionaries with data.

    Keyword arguments:
    source -- input hdf5 file path
    output -- output hdf5 file
    range -- where to save data in output arrays
    """

    data = h5py.File(source, 'r')

    print "\nAdding entries from %(f)s in [%(i)d:%(f)d]" \
          % {"f": source, "i": range[0], "f": range[1]}
    check.check_keys(data, output)
    check.check_shapes(data, output)
    for key in data:
        output[key][range[0]:range[1]] = data[key]

    data.close()
def add_data(source, output, range):

    """Merge dictionaries with data.

    Keyword arguments:
    source -- input hdf5 file path
    output -- output hdf5 file
    range -- where to save data in output arrays
    """

    data = h5py.File(source, 'r')

    print("\nAdding entries from %(f)s in [%(i)d:%(j)d]"
          % {"f": source, "i": range[0], "j": range[1]})
    check.check_keys(data, output)
    check.check_shapes(data, output)
    for key in data:
        output[key][range[0]:range[1]] = data[key]

    data.close()
Exemple #4
0
        print("usage: ./diff file1 file2 [fullcheck]")
        sys.exit(1)

    in1 = h5py.File(sys.argv[1], 'r')
    in2 = h5py.File(sys.argv[2], 'r')

    print("\nThe following datasets were found in %s:\n" % sys.argv[1])
    msg.list_dataset(in1)
    print("\nThe following datasets were found in %s:\n" % sys.argv[2])
    msg.list_dataset(in2)

    check.check_keys(in1, in2)

    check.same_sizes(in1, in2)

    check.check_shapes(in1, in2)

    for key in in1:
        try:
            if not np.array_equal(in1[key], in2[key]):
                sys.exit(1)
                msg.error("%s datasets are different." % key)
            else:
                msg.info("%s match." % key)
        except Exception as e:
            print(e)
            if len(sys.argv) == 4 and sys.argv[3] == "fullcheck":
                fullcheck(in1[key], in2[key], key)
            else:
                partcheck(in1[key], in2[key], key)
Exemple #5
0
import msg
import check

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print("usage: ./diff file1 file2")
        sys.exit(1)

    data1 = hdf5.load(sys.argv[1])
    data2 = hdf5.load(sys.argv[2])

    print("\nThe following datasets were found in %s:\n" % sys.argv[1])
    msg.list_dataset(data1)
    print("\nThe following datasets were found in %s:\n" % sys.argv[2])
    msg.list_dataset(data2)

    check.check_keys(data1, data2)

    if check.get_size(data1) != check.get_size(data2):
        msg.error("Different number of entries.")
        sys.exit(1)

    check.check_shapes(data1, data2)

    for key in data1:
        if not np.equal(data1[key], data2[key]).all():
            msg.error("Different entries for dataset: %s" % key)
            sys.exit(1)

    msg.info("Files are the same.")