예제 #1
0
파일: numpy2ri.py 프로젝트: gyenney/Tools
def activate():
    global original_converter

    # If module is already activated, there is nothing to do
    if original_converter is not None:
        return

    original_converter = conversion.converter
    new_converter = conversion.Converter('numpy conversion',
                                         template=original_converter)

    for k,v in py2ri.registry.items():
        if k is object:
            continue
        new_converter.py2ri.register(k, v)

    for k,v in ri2ro.registry.items():
        if k is object:
            continue
        new_converter.ri2ro.register(k, v)

    for k,v in py2ro.registry.items():
        if k is object:
            continue
        new_converter.py2ro.register(k, v)

    for k,v in ri2py.registry.items():
        if k is object:
            continue
        new_converter.ri2py.register(k, v)

    conversion.set_conversion(new_converter)
예제 #2
0
def activate():
    warnings.warn('The global conversion available with activate() '
                  'is deprecated and will be removed in the next major '
                  'release. Use a local converter.',
                  category=DeprecationWarning)

    global original_converter

    # If module is already activated, there is nothing to do
    if original_converter is not None:
        return

    original_converter = conversion.converter
    new_converter = conversion.Converter('numpy conversion',
                                         template=original_converter)

    for k, v in py2rpy.registry.items():
        if k is object:
            continue
        new_converter.py2rpy.register(k, v)

    for k, v in rpy2py.registry.items():
        if k is object:
            continue
        new_converter.rpy2py.register(k, v)

    conversion.set_conversion(new_converter)
예제 #3
0
파일: pandas2ri.py 프로젝트: Pumawat/Explo
def activate():
    global original_converter
    # If module is already activated, there is nothing to do
    if original_converter is not None:
        return

    original_converter = conversion.Converter(
        'snapshot before pandas conversion', template=conversion.converter)
    numpy2ri.activate()
    new_converter = conversion.Converter('snapshot before pandas conversion',
                                         template=conversion.converter)
    numpy2ri.deactivate()

    for k, v in py2ri.registry.items():
        if k is object:
            continue
        new_converter.py2ri.register(k, v)

    for k, v in ri2ro.registry.items():
        if k is object:
            continue
        new_converter.ri2ro.register(k, v)

    for k, v in py2ro.registry.items():
        if k is object:
            continue
        new_converter.py2ro.register(k, v)

    for k, v in ri2py.registry.items():
        if k is object:
            continue
        new_converter.ri2py.register(k, v)

    conversion.set_conversion(new_converter)
예제 #4
0
파일: numpy2ri.py 프로젝트: gyenney/Tools
def deactivate():
    global original_converter
    # If module has never been activated or already deactivated,
    # there is nothing to do
    if original_converter is None:
        return

    conversion.set_conversion(original_converter)
    original_converter = None
예제 #5
0
def deactivate():
    global original_converter
    # If module has never been activated or already deactivated,
    # there is nothing to do
    if original_converter is None:
        return

    conversion.set_conversion(original_converter)
    original_converter = None
예제 #6
0
파일: conv.py 프로젝트: theislab/anndata2ri
def deactivate():
    """Deactivate the conversion described above if it is active."""
    global original_converter

    if original_converter is None:
        return

    conversion.set_conversion(original_converter)
    original_converter = None
예제 #7
0
파일: conv.py 프로젝트: ivirshup/anndata2ri
def deactivate():
    """Deactivate!"""
    global original_converter

    if original_converter is None:
        return

    conversion.set_conversion(original_converter)
    original_converter = None
예제 #8
0
파일: conv.py 프로젝트: ivirshup/anndata2ri
def activate():
    """
    Activate conversion for :class:`~anndata.AnnData` objects
    as well as :doc:`numpy` arrays and :class:`pandas.DataFrame`\ s
    via ``rpy2.robjects.numpy2ri`` and ``rpy2.robjects.pandas2ri``.
    """
    global original_converter

    if original_converter is not None:
        return

    new_converter = full_converter()
    original_converter = conversion.converter
    conversion.set_conversion(new_converter)
예제 #9
0
파일: conv.py 프로젝트: theislab/anndata2ri
def activate():
    r"""
    Activate conversion for :class:`~anndata.AnnData` objects
    as well as :ref:`numpy:arrays` and :class:`pandas.DataFrame`\ s
    via ``rpy2.robjects.numpy2ri`` and ``rpy2.robjects.pandas2ri``.

    Does nothing if this is the active converter.
    """
    global original_converter

    if original_converter is not None:
        return

    new_converter = full_converter()
    original_converter = conversion.converter
    conversion.set_conversion(new_converter)
예제 #10
0
def activate():
    """
    Activate conversion between sparse matrices from Scipy and R’s Matrix package.

    Does nothing if this is the active conversion.
    """
    global original_converter

    if original_converter is not None:
        return

    original_converter = conversion.converter

    numpy2ri.activate()
    new_converter = conversion.Converter("scipy conversion",
                                         template=conversion.converter)
    numpy2ri.deactivate()

    overlay_converter(converter, new_converter)

    conversion.set_conversion(new_converter)
예제 #11
0
파일: numpy2ri.py 프로젝트: quantForma/rpy2
def activate():
    global original_converter

    # If module is already activated, there is nothing to do
    if original_converter is not None:
        return

    original_converter = conversion.converter
    new_converter = conversion.Converter('numpy conversion',
                                         template=original_converter)

    for k, v in py2rpy.registry.items():
        if k is object:
            continue
        new_converter.py2rpy.register(k, v)

    for k, v in rpy2py.registry.items():
        if k is object:
            continue
        new_converter.rpy2py.register(k, v)

    conversion.set_conversion(new_converter)