-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2630169
commit 3662ae8
Showing
5 changed files
with
206 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import tempfile | ||
|
||
import lmdb | ||
import sgkit | ||
import zarr | ||
|
||
import tsinfer | ||
from tsinfer import exceptions | ||
|
||
|
||
def open_lmbd_readonly(path): | ||
# We set the mapsize here because LMBD will map 1TB of virtual memory if | ||
# we don't, making it hard to figure out how much memory we're actually | ||
# using. | ||
map_size = None | ||
try: | ||
map_size = os.path.getsize(path) | ||
except OSError as e: | ||
raise exceptions.FileFormatError(str(e)) from e | ||
try: | ||
store = zarr.LMDBStore( | ||
path, map_size=map_size, readonly=True, subdir=False, lock=False | ||
) | ||
except lmdb.InvalidError as e: | ||
raise exceptions.FileFormatError(f"Unknown file format:{str(e)}") from e | ||
except lmdb.Error as e: | ||
raise exceptions.FileFormatError(str(e)) from e | ||
return store | ||
|
||
|
||
def test_ancestor_compat(small_sd_fixture): | ||
with tempfile.TemporaryDirectory(prefix="tsi_eval") as tmpdir: | ||
f = f"{tmpdir}/test.ancestors" | ||
tsinfer.generate_ancestors(small_sd_fixture, path=f) | ||
store = open_lmbd_readonly(f) | ||
sgkit.load_dataset(store) |
Oops, something went wrong.