Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torchani
Commits
4f834e2c
Unverified
Commit
4f834e2c
authored
Mar 21, 2020
by
Gao, Xiang
Committed by
GitHub
Mar 21, 2020
Browse files
Improve new dataset API (#433)
parent
6b058c6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
torchani/data/__init__.py
torchani/data/__init__.py
+10
-6
No files found.
torchani/data/__init__.py
View file @
4f834e2c
...
@@ -82,7 +82,6 @@ class Transformations:
...
@@ -82,7 +82,6 @@ class Transformations:
@
staticmethod
@
staticmethod
def
subtract_self_energies
(
iter_
,
self_energies
=
None
):
def
subtract_self_energies
(
iter_
,
self_energies
=
None
):
iter_
=
list
(
iter_
)
intercept
=
0.0
intercept
=
0.0
if
isinstance
(
self_energies
,
utils
.
EnergyShifter
):
if
isinstance
(
self_energies
,
utils
.
EnergyShifter
):
shifter
=
self_energies
shifter
=
self_energies
...
@@ -185,9 +184,6 @@ class TransformableIterable:
...
@@ -185,9 +184,6 @@ class TransformableIterable:
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
wrapped_iter
)
return
iter
(
self
.
wrapped_iter
)
def
__next__
(
self
):
return
next
(
self
.
wrapped_iter
)
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
transformation
=
getattr
(
Transformations
,
name
)
transformation
=
getattr
(
Transformations
,
name
)
...
@@ -220,6 +216,14 @@ class TransformableIterable:
...
@@ -220,6 +216,14 @@ class TransformableIterable:
def
load
(
path
,
additional_properties
=
()):
def
load
(
path
,
additional_properties
=
()):
properties
=
PROPERTIES
+
additional_properties
properties
=
PROPERTIES
+
additional_properties
# https://stackoverflow.com/a/39564774
class
IterableAdapter
:
def
__init__
(
self
,
iterator_factory
):
self
.
iterator_factory
=
iterator_factory
def
__iter__
(
self
):
return
self
.
iterator_factory
()
def
h5_files
(
path
):
def
h5_files
(
path
):
"""yield file name of all h5 files in a path"""
"""yield file name of all h5 files in a path"""
if
isdir
(
path
):
if
isdir
(
path
):
...
@@ -232,7 +236,7 @@ def load(path, additional_properties=()):
...
@@ -232,7 +236,7 @@ def load(path, additional_properties=()):
def
molecules
():
def
molecules
():
for
f
in
h5_files
(
path
):
for
f
in
h5_files
(
path
):
anidata
=
anidataloader
(
f
)
anidata
=
anidataloader
(
f
)
anidata_size
=
anidata
.
size
()
anidata_size
=
anidata
.
group_
size
()
use_pbar
=
PKBAR_INSTALLED
and
verbose
use_pbar
=
PKBAR_INSTALLED
and
verbose
if
use_pbar
:
if
use_pbar
:
pbar
=
pkbar
.
Pbar
(
'=> loading {}, total molecules: {}'
.
format
(
f
,
anidata_size
),
anidata_size
)
pbar
=
pkbar
.
Pbar
(
'=> loading {}, total molecules: {}'
.
format
(
f
,
anidata_size
),
anidata_size
)
...
@@ -252,7 +256,7 @@ def load(path, additional_properties=()):
...
@@ -252,7 +256,7 @@ def load(path, additional_properties=()):
ret
[
k
]
=
m
[
k
][
i
]
ret
[
k
]
=
m
[
k
][
i
]
yield
ret
yield
ret
return
TransformableIterable
(
conformations
())
return
TransformableIterable
(
IterableAdapter
(
lambda
:
conformations
())
)
__all__
=
[
'load'
]
__all__
=
[
'load'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment