Beispiel #1
0
    def __new__(cls, *args, **kwargs):
        if Docorator.__instance__ is None:
            Docorator.__instance__ = DocstringProcessor()

        # Add custom parameter type sections
        a = DocstringProcessor.param_like_sections
        Docorator.__instance__.param_like_sections = a + [
        ]  # ["Attributes", "Settings"]
        # Add custom text type sections
        a = Docorator.__instance__.text_sections
        Docorator.__instance__.text_sections = a + []

        # Create a single list of all section types
        a = Docorator.__instance__.param_like_sections
        b = Docorator.__instance__.text_sections
        Docorator.__instance__.all_sections = a + b

        return Docorator.__instance__
Beispiel #2
0
    """Indet the given string"""
    str_indent = ' ' * num
    return str_indent + ('\n' + str_indent).join(text.splitlines())


def append_original_doc(parent, num=0):
    """Return an iterator that append the docstring of the given `parent`
    function to the applied function"""
    def func(func):
        func.__doc__ = func.__doc__ and func.__doc__ + indent(
            parent.__doc__, num)
        return func
    return func


_docstrings = DocstringProcessor()

_docstrings.get_sectionsf('DocstringProcessor.get_sections')(
        dedent(DocstringProcessor.get_sections))


class PsyplotDocstringProcessor(DocstringProcessor):
    """
    A :class:`docrep.DocstringProcessor` subclass with possible types section
    """

    param_like_sections = DocstringProcessor.param_like_sections + [
        'Possible types']

    @_docstrings.dedent
    def get_sections(self, s, base, sections=[
Beispiel #3
0
 def __new__(cls, *args, **kwargs):
     if Docorator.__instance__ is None:
         Docorator.__instance__ = DocstringProcessor()
     return Docorator.__instance__
Beispiel #4
0
d = DocstringProcessor(
    adata=_adata,
    img_container=_img_container,
    copy=_copy,
    copy_cont=_copy_cont,
    numba_parallel=_numba_parallel,
    seed=_seed,
    n_perms=_n_perms,
    img_layer=_img_layer,
    feature_name=_feature_name,
    yx=_yx,
    feature_ret=_feature_ret,
    size=_size,
    cluster_key=_cluster_key,
    spatial_key=_spatial_key,
    conn_key=_conn_key,
    plotting=_plotting,
    cat_plotting=_cat_plotting,
    plotting_returns=_plotting_returns,
    parallelize=_parallelize,
    channels=_channels,
    segment_kwargs=_segment_kwargs,
    ligrec_test_returns=_ligrec_test_returns,
    corr_method=_corr_method,
    heatmap_plotting=_heatmap_plotting,
    custom_fn=_custom_fn,
    as_array=_as_array,
    layer_added=_layer_added,
)
Beispiel #5
0
import re
import os.path as osp
import six
import inspect
from docrep import DocstringProcessor

docstrings = DocstringProcessor()


def dir_contains(dirname, path, exists=True):
    """Check if a file of directory is contained in another.

    Parameters
    ----------
    dirname: str
        The base directory that should contain `path`
    path: str
        The name of a directory or file that should be in `dirname`
    exists: bool
        If True, the `path` and `dirname` must exist

    Notes
    -----
    `path` and `dirname` must be either both absolute or both relative
    paths"""
    if exists:
        dirname = osp.abspath(dirname)
        path = osp.abspath(path)
        if six.PY2 or six.PY34:
            return osp.exists(path) and osp.samefile(
                osp.commonprefix([dirname, path]), dirname)
Beispiel #6
0
d = DocstringProcessor(
    plotting=_plotting,
    n_jobs=_n_jobs,
    parallel=_parallel,
    model=_model,
    adata=_adata,
    adata_ret=_adata_ret,
    just_plots=_just_plots,
    backward=_backward,
    initial=_initial,
    terminal=_terminal,
    final=_final,
    eigen=_eigen,
    initial_or_terminal=f"{_initial} or {_terminal}",
    n_cells=_n_cells,
    fit=_fit,
    copy=_copy,
    density_correction=_density_correction,
    time_range=_time_range,
    time_ranges=_time_ranges,
    velocity_mode=_velocity_mode,
    velocity_backward_mode=_velocity_backward_mode,
    velocity_backward_mode_high_lvl=_velocity_backward_mode_high_lvl,
    model_callback=_model_callback,
    genes=_genes,
    softmax_scale=_softmax_scale,
    time_mode=_time_mode,
    write_to_adata=_write_to_adata,
)
Beispiel #7
0
R_sort = r"""The ordered top left part of shape `(m, m)` of the real Schur matrix of `P`.
The ordered real partial Schur matrix `R` of `P` fulfills

.. math:: \tilde{P} Q = Q R

with the ordered real matrix of dominant Schur vectors `Q`."""

eigenvalues_m = """An array of shape `(m,)` containing the `m` dominant eigenvalues of `P`."""

eigenvalues_k = """An array of shape `(k,)` containing the `k` dominant eigenvalues of `P`."""

d = DocstringProcessor(
    P=P,
    m=m,
    k=k,
    m_optimize=m_optimize,
    z=z,
    z_P=z_P,
    method=method,
    tol_krylov=tol_krylov,
    eta=eta,
    chi_ret=chi_ret,
    rot_matrix_ret=rot_matrix_ret,
    crispness_ret=crispness_ret,
    Q_sort=Q_sort,
    R_sort=R_sort,
    eigenvalues_m=eigenvalues_m,
    eigenvalues_k=eigenvalues_k,
)
Beispiel #8
0
    - :attr:`omnipath.constants.InteractionDataset.LIGREC_EXTRA`
    - :attr:`omnipath.constants.InteractionDataset.DOROTHEA`
    - :attr:`omnipath.constants.InteractionDataset.TF_TARGET`
    - :attr:`omnipath.constants.InteractionDataset.TF_MIRNA`
    - :attr:`omnipath.constants.InteractionDataset.TF_REGULONS`
    - :attr:`omnipath.constants.InteractionDataset.MIRNA_TARGET`
    - :attr:`omnipath.constants.InteractionDataset.LNCRNA_MRNA`"""
_validate = """
Validate the ``value`` for the :attr:`param`.

Parameters
----------
value
    Value to validate.

Returns
-------
    The valid values."""
_query_resources = """
    Return the available resources for this query."""
_query_params = """
    Return the available values for each parameter, if available."""

d = DocstringProcessor(
    general_get=_general_get,
    interaction_datasets=_interactions_datasets,
    validate=_validate,
    query_params=_query_params,
    query_resources=_query_resources,
)
Beispiel #9
0
d = DocstringProcessor(
    plotting=_plotting,
    n_jobs=_n_jobs,
    parallel=_parallel,
    model=_model,
    adata=_adata,
    adata_ret=_adata_ret,
    just_plots=_just_plots,
    backward=_backward,
    initial=_initial,
    terminal=_terminal,
    eigen=_eigen,
    initial_or_terminal=f"{_initial} or {_terminal}",
    n_cells=_n_cells,
    fit=_fit,
    copy=_copy,
    density_correction=_density_correction,
    time_range=_time_range,
    velocity_mode=_velocity_mode,
    velocity_backward_mode=_velocity_backward_mode,
    velocity_backward_mode_high_lvl=_velocity_backward_mode_high_lvl,
    model_callback=_model_callback,
    genes=_genes,
    softmax_scale=_softmax_scale,
    time_mode=_time_mode,
    write_to_adata=_write_to_adata,
    en_cutoff_p_thresh=_en_cutoff_p_thresh,
    return_models=_return_models,
    plots_or_returns_models=_plots_or_returns_models,
    basis=_basis,
    velocity_scheme=_velocity_scheme,
    cond_num=_cond_num,
    soft_scheme=_soft_scheme_fmt.format("", "", ""),
    soft_scheme_kernel=_soft_scheme_fmt.format(
        *([" Only used when `threshold_scheme='soft'`."] * 3)),
    rw_ixs=_rw_ixs,
)
Beispiel #10
0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from docrep import DocstringProcessor

docstrings = DocstringProcessor()


def rgba2rgb(image, color=(255, 255, 255)):
    """Alpha composite an RGBA Image with a specified color.

    Source: http://stackoverflow.com/a/9459208/284318

    Parameters
    ----------
    image: PIL.Image
        The PIL RGBA Image object
    color: tuple
        The rgb color for the background

    Returns