import numpy as np

from psyrun.io import load_infile, save_infile
from psyrun.pspace import Param


def test_infile_with_none(tmpdir):
    filename = str(tmpdir.join('infile.h5'))
    pspace = (Param(a=[1.], b=[1.]) + Param(a=[2.], c=[2.])).build()
    save_infile(pspace, filename)
    saved_pspace = load_infile(filename).build()
    assert sorted(pspace.keys()) == sorted(saved_pspace.keys())
    for k in pspace:
        for a, b in zip(pspace[k], saved_pspace[k]):
            assert a == b or (np.isnan(a)and np.isnan(b))

@@ -35,27 +35,60 @@
  import 
-load_infile
+append_to_results, load_infile, load_results
 , save_i
@@ -555,8 +555,368 @@
 nan(b))%0A
+%0A%0Adef test_merging_multidimensional_results(tmpdir):%0A    filename = str(tmpdir.join('r.h5'))%0A%0A    data1 = %7B'a': np.zeros((2, 2, 2))%7D%0A    data2 = %7B'a': np.ones((3, 2, 2))%7D%0A%0A    append_to_results(data1, filename)%0A    append_to_results(data2, filename)%0A%0A    saved = load_results(filename)%0A    assert np.all(np.concatenate(%5Bdata1%5B'a'%5D, data2%5B'a'%5D%5D) == saved%5B'a'%5D)%0A

Test merging of results.