skchem.utils.helpers
Module providing helper functions for scikit-chem
# skchem.utils.io
IO helper functions for skchem.
skchem.utils.io.
json_dump
(obj, target=None)[source]¶Write object as json to file or stream, or return as string.
skchem.utils.io.
line_count
(filename)[source]¶Quickly count the number of lines in a file.
Adapted from http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python
Parameters: | filename (str) – The name of the file to count for. |
---|
skchem.utils.io.
sdf_count
(filename)[source]¶Efficiently count molecules in an sdf file.
Specifically, the function counts the number of times ‘$$$$’ occurs at the start of lines in the file.
Parameters: | filename (str) – The filename of the sdf file. |
---|---|
Returns: | the number of molecules in the file. |
Return type: | int |
# skchem.utils.progress
Module implementing progress bars.
skchem.utils.suppress
Class for suppressing C extensions output.
skchem.utils.suppress.
Suppressor
[source]¶Bases: object
A context manager for doing a “deep suppression” of stdout and stderr.
It will suppress all print, even if the print originates in a compiled C/Fortran sub-function.
This will not suppress raised exceptions, since exceptions are printed to stderr just before a script exits, and after the context manager has exited (at least, I think that is why it lets exceptions through).
null_fds
= [4, 5]¶skchem.utils
Module providing utility functions for scikit-chem
skchem.utils.
Suppressor
[source]¶Bases: object
A context manager for doing a “deep suppression” of stdout and stderr.
It will suppress all print, even if the print originates in a compiled C/Fortran sub-function.
This will not suppress raised exceptions, since exceptions are printed to stderr just before a script exits, and after the context manager has exited (at least, I think that is why it lets exceptions through).
null_fds
= [4, 5]¶skchem.utils.
NamedProgressBar
(name=None, **kwargs)[source]¶Bases: progressbar.bar.ProgressBar
skchem.utils.
json_dump
(obj, target=None)[source]¶Write object as json to file or stream, or return as string.
skchem.utils.
yaml_dump
(obj, target=None)[source]¶Write object as yaml to file or stream, or return as string.
skchem.utils.
line_count
(filename)[source]¶Quickly count the number of lines in a file.
Adapted from http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python
Parameters: | filename (str) – The name of the file to count for. |
---|
skchem.utils.
sdf_count
(filename)[source]¶Efficiently count molecules in an sdf file.
Specifically, the function counts the number of times ‘$$$$’ occurs at the start of lines in the file.
Parameters: | filename (str) – The filename of the sdf file. |
---|---|
Returns: | the number of molecules in the file. |
Return type: | int |
skchem.utils.
nanarray
(shape)[source]¶Produce an array of NaN in provided shape.
Parameters: | shape (tuple) – The shape of the nan array to produce. |
---|---|
Returns: | np.array |