-
Notifications
You must be signed in to change notification settings - Fork 97
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
Showing
8 changed files
with
124 additions
and
46 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
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 |
---|---|---|
|
@@ -50,7 +50,7 @@ def do_task(mol): | |
|
||
bar.write(e) | ||
|
||
yield r | ||
yield self._wrap_result(r) | ||
bar.update() | ||
|
||
finally: | ||
|
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,63 @@ | ||
from .util import is_missing | ||
|
||
|
||
class Result(list): | ||
r"""Result type.""" | ||
|
||
def __init__(self, r, d): | ||
super(Result, self).__init__(r) | ||
self._descriptors = d | ||
|
||
def fillna(self, value=float('nan')): | ||
r"""Replace missing value to 'value'. | ||
Parameters: | ||
value: value that missing value is replaced | ||
Returns: | ||
Result | ||
""" | ||
return self.__class__( | ||
[(value if is_missing(v) else v) for v in self], | ||
self._descriptors, | ||
) | ||
|
||
def dropna(self): | ||
r"""Delete missing value. | ||
Returns: | ||
Result | ||
""" | ||
newvalues = [] | ||
newdescs = [] | ||
for v, d in zip(self, self._descriptors): | ||
if not is_missing(v): | ||
newvalues.append(v) | ||
newdescs.append(d) | ||
|
||
return self.__class__(newvalues, newdescs) | ||
|
||
def asdict(self, rawkey=False): | ||
r"""Convert Result to dict. | ||
Parameters: | ||
rawkey(bool): | ||
* True: dict key is Descriptor instance | ||
* False: dict key is str | ||
Returns: | ||
dict | ||
""" | ||
if rawkey: | ||
def keyconv(k): | ||
return k | ||
else: | ||
keyconv = str | ||
|
||
return { | ||
keyconv(k): v | ||
for k, v in zip(self._descriptors, self) | ||
} |
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,41 @@ | ||
import os | ||
import warnings | ||
from importlib import import_module | ||
|
||
from ..error import MissingValueBase | ||
|
||
|
||
def all_descriptors(): | ||
r"""**[deprecated]** use mordred.descriptors module instead. | ||
yield all descriptor modules. | ||
:returns: all modules | ||
:rtype: :py:class:`Iterator` (:py:class:`Descriptor`) | ||
""" | ||
warnings.warn( | ||
"all_descriptors() is deprecated, use mordred.descriptors module instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
base_dir = os.path.dirname(os.path.dirname(__file__)) | ||
|
||
for name in os.listdir(base_dir): | ||
name, ext = os.path.splitext(name) | ||
if name[:1] == "_" or ext != ".py" or name == "descriptors": | ||
continue | ||
|
||
yield import_module(".." + name, __package__) | ||
|
||
|
||
def is_missing(v): | ||
"""Check argument is either MissingValue or not. | ||
Parameters: | ||
v(any): value | ||
Returns: | ||
bool | ||
""" | ||
return isinstance(v, MissingValueBase) |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pep8 | ||
flake8 | ||
flake8-isort | ||
flake8-double-quotes | ||
flake8-print | ||
flake8-commas | ||
|