-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExampleDataset can now be iterated over and has tests.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
import molgrid | ||
import numpy as np | ||
import os | ||
import torch | ||
|
||
from pytest import approx | ||
from numpy import around | ||
|
||
datadir = os.path.dirname(__file__) + '/data' | ||
|
||
#make sure we can map and iterate | ||
def test_example_dataset(): | ||
fname = datadir + "/small.types" | ||
e = molgrid.ExampleDataset(data_root=datadir + "/structs") | ||
e.populate(fname) | ||
|
||
assert len(e) == 1000 | ||
assert e[-1].labels[1] == approx(-10.3) | ||
assert e[3].labels[1] == approx(-6.05) | ||
|
||
for ex in e: | ||
pass | ||
assert ex.labels[1] == approx(-10.3) | ||
|
||
for ex in e: | ||
break | ||
|
||
assert ex.labels[1] == approx(6.05) |