Skip to content

Commit

Permalink
Restored the external object check.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jan 19, 2024
1 parent 19f8638 commit d7a467d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
8 changes: 5 additions & 3 deletions src/dolomite_base/save_simple_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ def _save_simple_list_internal(x: Union[dict, list], path: str, simple_list_mode
ghandle.attrs["uzuki_version"] = "1.3"
_save_simple_list_recursive(x, externals, ghandle)

children = []
for i, ex in enumerate(externals):
alt_save_object(ex, os.path.join(path, str(i)), **kwargs)
if len(externals):
exdir = os.path.join(path, "other_contents")
os.mkdir(exdir)
for i, ex in enumerate(externals):
alt_save_object(ex, os.path.join(exdir, str(i)), **kwargs)
return


Expand Down
51 changes: 24 additions & 27 deletions tests/test_simple_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,33 +259,30 @@ def test_simple_list_special_float():
assert np.ma.is_masked(roundtrip["e"][2])


#def test_simple_list_external():
# everything = {
# "a": BiocFrame({ "a_1": [ 1, 2, 3 ], "a_2": [ "A", "B", "C" ] }),
# "b": BiocFrame(number_of_rows=10),
# }
#
# dir = mkdtemp()
#
# # Stage as JSON.
# meta = dl.save_object(everything, dir, "foo")
# dl.write_metadata(meta, dir)
#
# roundtrip = dl.load_json_simple_list(meta, dir)
# assert roundtrip["a"].column_names == [ "a_1", "a_2" ]
# assert roundtrip["a"].shape[0] == 3
# assert roundtrip["b"].column_names == []
# assert roundtrip["b"].shape[0] == 10
#
# # Stage as HDF5.
# meta = dl.save_object(everything, dir, "foo2", mode="hdf5")
# dl.write_metadata(meta, dir)
#
# roundtrip = dl.load_object(meta, dir)
# assert roundtrip["a"].column_names == [ "a_1", "a_2" ]
# assert roundtrip["a"].shape[0] == 3
# assert roundtrip["b"].column_names == []
# assert roundtrip["b"].shape[0] == 10
def test_simple_list_external():
everything = {
"a": BiocFrame({ "a_1": [ 1, 2, 3 ], "a_2": [ "A", "B", "C" ] }),
"b": BiocFrame(number_of_rows=10),
}


# Stage as JSON.
dir = os.path.join(mkdtemp(), "json")
dl.save_object(everything, dir, simple_list_mode='json')
roundtrip = dl.read_object(dir)
assert roundtrip["a"].get_column_names().as_list() == [ "a_1", "a_2" ]
assert roundtrip["a"].shape[0] == 3
assert roundtrip["b"].get_column_names().as_list() == []
assert roundtrip["b"].shape[0] == 10

# Stage as HDF5.
dir = os.path.join(mkdtemp(), "hdf5")
dl.save_object(everything, dir, simple_list_mode="hdf5")
roundtrip = dl.read_object(dir)
assert roundtrip["a"].get_column_names().as_list() == [ "a_1", "a_2" ]
assert roundtrip["a"].shape[0] == 3
assert roundtrip["b"].get_column_names().as_list() == []
assert roundtrip["b"].shape[0] == 10


def test_simple_list_factor():
Expand Down

0 comments on commit d7a467d

Please sign in to comment.