def Func(arg_0, arg_1, arg_2):
        """For a padded grid-stack and psf, compute an unmasked blurred image from an unmasked unblurred image.

        This relies on using the lens data's padded-grid, which is a grid of (y,x) coordinates which extends over the \
        entire image as opposed to just the masked region.

        Parameters
        ----------
        psf : ccd.PSF
            The PSF of the image used for convolution.
        unmasked_image_1d : ndarray
            The 1D unmasked image which is blurred.
        """
        arg_3 = arg_0.regular.convolve_array_1d_with_psf(padded_array_1d=arg_2,
                                                                   arg_1=arg_1)

        return arg_0.regular.scaled_array_2d_from_array_1d(array_1d=arg_3)

For a padded grid - stack and psf compute an unmasked blurred image from an unmasked unblurred image .


def Func(arg_0):
    """Request contexts disappear when the response is started on the server.
    This is done for efficiency reasons and to make it less likely to encounter
    memory leaks with badly written WSGI middlewares.  The downside is that if
    you are using streamed responses, the generator cannot access request bound
    information any more.

    This function however can help you keep the context around for longer::

        from flask import Func, request, Response

        @app.route('/stream')
        def streamed_response():
            @Func
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(generate())

    Alternatively it can also be used around a specific generator::

        from flask import Func, request, Response

        @app.route('/stream')
        def streamed_response():
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(Func(generate()))

    .. versionadded:: 0.9
    """
    try:
        arg_1 = iter(arg_0)
    except TypeError:
        def decorator(*arg_2, **arg_3):
            arg_1 = arg_0()
            return Func(arg_1)
        return update_wrapper(decorator, arg_0)

    def generator():
        arg_4 = _request_ctx_stack.top
        if arg_4 is None:
            raise RuntimeError('Attempted to stream with context but '
                'there was no context in the first place to keep around.')
        with arg_4:
            # Dummy sentinel.  Has to be inside the context block or we're
            # not actually keeping the context around.
            yield None

            # The try/finally is here so that if someone passes a WSGI level
            # iterator in we're still running the cleanup logic.  Generators
            # don't need that because they are closed on their destruction
            # automatically.
            try:
                for arg_5 in arg_1:
                    yield arg_5
            finally:
                if hasattr(arg_1, 'close'):
                    arg_1.close()

    # The trick is to start the generator.  Then the code execution runs until
    # the first dummy None is yielded at which point the context was already
    # pushed.  This item is discarded.  Then when the iteration continues the
    # real generator is executed.
    arg_6 = generator()
    next(arg_6)
    return arg_6

Request contexts disappear when the response is started on the server.
    This is done for efficiency reasons and to make it less likely to encounter
    memory leaks with badly written WSGI middlewares.  The downside is that if
    you are using streamed responses, the generator cannot access request bound
    information any more.

    This function however can help you keep the context around for longer::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            @stream_with_context
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(generate())

    Alternatively it can also be used around a specific generator::

        from flask import stream_with_context, request, Response

        @app.route('/stream')
        def streamed_response():
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(stream_with_context(generate()))

    .. versionadded:: 0.9

Request contexts disappear when the response is started on the server . This is done for efficiency reasons and to make it less likely to encounter memory leaks with badly written WSGI middlewares . The downside is that if you are using streamed responses the generator cannot access request bound information any more .


def Func(arg_0, arg_1):
        """Poll for the result of a transfer

        :param transfer_id: Unique identifier for the transfer
        :return: If the transfer succeeded, it will return the result. If the
            transfer failed, it will raise the exception associated to the
            failure.
        """
        arg_0._transfer_states[arg_1].wait_till_done()
        arg_2 = arg_0._transfer_states[arg_1].exception
        if arg_2:
            raise arg_2
        return None


(
        self,
        src,
        tar,
        word_approx_min=0.3,
        char_approx_min=0.73,
        tests=2 ** 12 - 1,
    )

return (
            synoname(src, tar, word_approx_min, char_approx_min, tests, False)
            / 14
        )

def Func(
        arg_0,
        arg_1,
        arg_2,
        arg_3=0.3,
        arg_4=0.73,
        arg_5=2 ** 12 - 1,
    ):
        """Return the normalized Synoname Funcance between two words.

        Parameters
        ----------
        src : str
            Source string for comparison
        tar : str
            Target string for comparison
        word_approx_min : float
            The minimum word approximation value to signal a 'word_approx'
            match
        char_approx_min : float
            The minimum character approximation value to signal a 'char_approx'
            match
        tests : int or Iterable
            Either an integer indicating tests to perform or a list of test
            names to perform (defaults to performing all tests)

        Returns
        -------
        float
            Normalized Synoname Funcance

        """
        return (
            synoname(arg_1, arg_2, arg_3, arg_4, arg_5, False)
            / 14
        )

Return the normalized Synoname distance between two words.

        Parameters
        ----------
        src : str
            Source string for comparison
        tar : str
            Target string for comparison
        word_approx_min : float
            The minimum word approximation value to signal a 'word_approx'
            match
        char_approx_min : float
            The minimum character approximation value to signal a 'char_approx'
            match
        tests : int or Iterable
            Either an integer indicating tests to perform or a list of test
            names to perform (defaults to performing all tests)

        Returns
        -------
        float
            Normalized Synoname distance

Return the normalized Synoname distance between two words .


def Func ( arg_0 ) : if arg_0 . _globalInhibition or arg_0 . _inhibitionRadius > arg_0 . _numInputs : arg_0 . FuncGlobal ( ) else : arg_0 . FuncLocal ( )

def Func(arg_0):
    """
    Updates the minimum duty cycles defining normal activity for a column. A
    column with activity duty cycle below this minimum threshold is boosted.
    """
    if arg_0._globalInhibition or arg_0._inhibitionRadius > arg_0._numInputs:
      arg_0.FuncGlobal()
    else:
      arg_0.FuncLocal()

Updates the minimum duty cycles defining normal activity for a column . A column with activity duty cycle below this minimum threshold is boosted .


def
Func
(
arg_0
)
:
if
len
(
arg_0
)
!=
1
:
raise
Exception
(
'The target string must be one letter.'
)
if
not
is_hangul
(
arg_0
)
:
raise
NotHangulException
(
'The target string must be Hangul'
)
arg_1
=
lt
.
hangul_index
(
arg_0
)
return
arg_1
%
NUM_JONG
>
0

def Func(arg_0):
    """Check whether this letter contains Jongsung"""
    if len(arg_0) != 1:
        raise Exception('The target string must be one letter.')
    if not is_hangul(arg_0):
        raise NotHangulException('The target string must be Hangul')

    arg_1 = lt.hangul_index(arg_0)
    return arg_1 % NUM_JONG > 0


def Func(arg_0, arg_1, arg_2):
    """ create physical plan """
    if not arg_2 or not arg_2.IsInitialized():
      raise_(StateException("Physical Plan protobuf not init properly",
                            StateException.EX_TYPE_PROTOBUF_ERROR), sys.exc_info()[2])

    arg_3 = arg_0.get_pplan_path(arg_1)
    LOG.info("Adding topology: {0} to path: {1}".format(
        arg_1, arg_3))
    arg_4 = arg_2.SerializeToString()
    try:
      arg_0.client.create(arg_3, value=arg_4, makepath=True)
      return True
    except NoNodeError:
      raise_(StateException("NoNodeError while creating pplan",
                            StateException.EX_TYPE_NO_NODE_ERROR), sys.exc_info()[2])
    except NodeExistsError:
      raise_(StateException("NodeExistsError while creating pplan",
                            StateException.EX_TYPE_NODE_EXISTS_ERROR), sys.exc_info()[2])
    except ZookeeperError:
      raise_(StateException("Zookeeper while creating pplan",
                            StateException.EX_TYPE_ZOOKEEPER_ERROR), sys.exc_info()[2])
    except Exception:
      # Just re raise the exception.
      raise


def
Func
(
)
:
arg_0
=
False
try
:
import
idaapi
arg_0
=
True
except
ImportError
:
arg_0
=
False
if
arg_0
:
arg_1
=
arg_3
.
path
[
:
]
try
:
arg_2
=
os
.
path
.
dirname
(
idaapi
.
__file__
)
arg_3
.
path
.
insert
(
0
,
arg_2
)
if
idaapi
.
IDA_SDK_VERSION
>=
690
:
from
PyQt5
import
QtCore
return
QtCore
else
:
from
PySide
import
QtCore
return
QtCore
finally
:
arg_3
.
path
=
arg_1
else
:
try
:
from
PyQt5
import
QtCore
return
QtCore
except
ImportError
:
pass
try
:
from
PySide
import
QtCore
return
QtCore
except
ImportError
:
pass
raise
ImportError
(
"No module named PySide or PyQt"
)

def Func():
    """
    This nasty piece of code is here to force the loading of IDA's
     Qt bindings.
    Without it, Python attempts to load PySide from the site-packages
     directory, and failing, as it does not play nicely with IDA.

    via: github.com/tmr232/Cute
    """
    arg_0 = False
    try:
        # if we're running under IDA,
        # then we'll use IDA's Qt bindings
        import idaapi
        arg_0 = True
    except ImportError:
        # not running under IDA,
        # so use default Qt installation
        arg_0 = False

    if arg_0:
        arg_1 = arg_3.path[:]
        try:
            arg_2 = os.path.dirname(idaapi.__file__)
            arg_3.path.insert(0, arg_2)
            if idaapi.IDA_SDK_VERSION >= 690:
                from PyQt5 import QtCore
                return QtCore
            else:
                from PySide import QtCore
                return QtCore
        finally:
            arg_3.path = arg_1
    else:
        try:
            from PyQt5 import QtCore
            return QtCore
        except ImportError:
            pass

        try:
            from PySide import QtCore
            return QtCore
        except ImportError:
            pass

        raise ImportError("No module named PySide or PyQt")

This nasty piece of code is here to force the loading of IDA s Qt bindings . Without it Python attempts to load PySide from the site - packages directory and failing as it does not play nicely with IDA .


return self._provider_root() + '/' + job_id + '/' + dir_name

def Func ( arg_0 , arg_1 , arg_2 , arg_3 ) : arg_4 = 'task' if arg_2 is None else str ( arg_2 ) if arg_3 : arg_4 = '%s.%s' % ( arg_4 , arg_3 ) return arg_0 . _provider_root ( ) + '/' + arg_1 + '/' + arg_4

def Func(arg_0, arg_1, arg_2, arg_3):
    """The local dir for staging files for that particular task."""
    arg_4 = 'task' if arg_2 is None else str(arg_2)
    if arg_3:
      arg_4 = '%s.%s' % (arg_4, arg_3)
    return arg_0._provider_root() + '/' + arg_1 + '/' + arg_4

The local dir for staging files for that particular task .


(requests, stream=True, pool=None, size=1, exception_handler=None)

def Func ( arg_0 , arg_1 = True , arg_2 = None , arg_3 = 1 , arg_4 = None ) : arg_2 = arg_2 if arg_2 else Pool ( arg_3 ) arg_0 = list ( arg_0 ) arg_0 = arg_2 . Func ( send , arg_0 ) arg_5 = [ ] for arg_6 in arg_0 : if arg_6 . response is not None : arg_5 . append ( arg_6 . response ) elif arg_4 and hasattr ( arg_6 , 'exception' ) : arg_5 . append ( arg_4 ( arg_6 , arg_6 . exception ) ) else : arg_5 . append ( None ) if not arg_2 : arg_2 . close ( ) return arg_5

def Func(arg_0, arg_1=True, arg_2=None, arg_3=1, arg_4=None):
    """Concurrently converts a list of Requests to Responses.

    :param requests: a collection of Request objects.
    :param stream: If False, the content will not be downloaded immediately.
    :param size: Specifies the number of workers to run at a time. If 1, no parallel processing.
    :param exception_handler: Callback function, called when exception occured. Params: Request, Exception
    """

    arg_2 = arg_2 if arg_2 else Pool(arg_3)
    arg_0 = list(arg_0)

    arg_0 = arg_2.Func(send, arg_0)

    arg_5 = []
    for arg_6 in arg_0:
        if arg_6.response is not None:
            arg_5.append(arg_6.response)
        elif arg_4 and hasattr(arg_6, 'exception'):
            arg_5.append(arg_4(arg_6, arg_6.exception))
        else:
            arg_5.append(None)

    if not arg_2:
        arg_2.close()

    return arg_5

Concurrently converts a list of Requests to Responses .


def Func ( arg_0 ) : if "file_to_test" in PyFunceble . INTERN : Generate ( arg_0 . domain_status , arg_0 . source , arg_0 . expiration_date ) . info_files ( ) Percentage ( arg_0 . domain_status ) . count ( ) arg_0 . _prints_status_screen ( ) if arg_0 . _do_not_produce_file ( ) : return None if ( not PyFunceble . CONFIGURATION [ "no_files" ] and PyFunceble . CONFIGURATION [ "split" ] ) : arg_0 . _prints_Func ( ) else : arg_0 . unified_file ( )

def Func(arg_0):  # pylint: disable=inconsistent-return-statements
        """
        Generate a file according to the domain status.
        """

        if "file_to_test" in PyFunceble.INTERN:
            # We are not testing as an imported module.

            # We generate the hosts file.
            Generate(arg_0.domain_status, arg_0.source, arg_0.expiration_date).info_files()

            # We are testing a file content.

            # We increase the percentage count.
            Percentage(arg_0.domain_status).count()

            # We print on screen if needed.
            arg_0._prints_status_screen()

            if arg_0._do_not_produce_file():
                return None

            if (
                not PyFunceble.CONFIGURATION["no_files"]
                and PyFunceble.CONFIGURATION["split"]
            ):
                # * The file non-generation of file is globaly deactivated.
                # and
                # * We have to split the outputs.

                # We print or generate the files.
                arg_0._prints_Func()
            else:
                # * The file non-generation of file is globaly activated.
                # or
                # * We do not have to split the outputs.

                # We print or generate the unified files.
                arg_0.unified_file()

Generate a file according to the domain status .


def Func ( arg_0 , arg_1 ) : if isinstance ( arg_0 , dict ) : for arg_2 , arg_3 in arg_0 . items ( ) : if arg_2 == arg_1 : yield arg_3 for arg_4 in Func ( arg_3 , arg_1 ) : yield arg_4 elif isinstance ( arg_0 , list ) : for arg_3 in arg_0 : for arg_4 in Func ( arg_3 , arg_1 ) : yield arg_4

def Func(arg_0, arg_1):
    """
    Search for a key in a nested dict, or list of nested dicts, and return the values.

    :param data: dict/list to search
    :param key: key to find
    :return: matches for key
    """
    if isinstance(arg_0, dict):
        for arg_2, arg_3 in arg_0.items():
            if arg_2 == arg_1:
                yield arg_3
            for arg_4 in Func(arg_3, arg_1):
                yield arg_4
    elif isinstance(arg_0, list):
        for arg_3 in arg_0:
            for arg_4 in Func(arg_3, arg_1):
                yield arg_4

Search for a key in a nested dict or list of nested dicts and return the values .


An endpoint helping check the health status of the Airflow instance,
        including metadatabase and scheduler.

def Func ( arg_0 , arg_1 = None ) : arg_2 = jobs . BaseJob arg_3 = { } arg_4 = timedelta ( seconds = conf . getint ( 'scheduler' , 'scheduler_Func_check_threshold' ) ) arg_5 = None arg_3 [ 'metadatabase' ] = { 'status' : 'Funcy' } try : arg_5 = arg_1 . query ( func . max ( arg_2 . latest_heartbeat ) ) . filter ( arg_2 . state == 'running' , arg_2 . job_type == 'SchedulerJob' ) . scalar ( ) except Exception : arg_3 [ 'metadatabase' ] [ 'status' ] = 'unFuncy' if not arg_5 : arg_6 = 'unFuncy' else : if timezone . utcnow ( ) - arg_5 <= arg_4 : arg_6 = 'Funcy' else : arg_6 = 'unFuncy' arg_3 [ 'scheduler' ] = { 'status' : arg_6 , 'latest_scheduler_heartbeat' : str ( arg_5 ) } return wwwutils . json_response ( arg_3 )

def Func(arg_0, arg_1=None):
        """
        An endpoint helping check the Func status of the Airflow instance,
        including metadatabase and scheduler.
        """

        arg_2 = jobs.BaseJob
        arg_3 = {}
        arg_4 = timedelta(seconds=conf.getint('scheduler',
                                                                         'scheduler_Func_check_threshold'
                                                                         ))

        arg_5 = None
        arg_3['metadatabase'] = {'status': 'Funcy'}
        try:
            arg_5 = arg_1.query(func.max(arg_2.latest_heartbeat)).\
                filter(arg_2.state == 'running', arg_2.job_type == 'SchedulerJob').\
                scalar()
        except Exception:
            arg_3['metadatabase']['status'] = 'unFuncy'

        if not arg_5:
            arg_6 = 'unFuncy'
        else:
            if timezone.utcnow() - arg_5 <= arg_4:
                arg_6 = 'Funcy'
            else:
                arg_6 = 'unFuncy'

        arg_3['scheduler'] = {'status': arg_6,
                                'latest_scheduler_heartbeat': str(arg_5)}

        return wwwutils.json_response(arg_3)

An endpoint helping check the health status of the Airflow instance including metadatabase and scheduler .


def Func(arg_0, arg_1, arg_2, arg_3):
        """Register a handler instance by name with esc_strings."""
        arg_0._handlers[arg_1] = arg_2
        for arg_5 in arg_3:
            arg_0._esc_handlers[arg_5] = arg_2

Register a handler instance by name with esc_strings .


(ctx, config, loglevel, logfilter, verbosity)

def Func ( arg_0 , arg_1 , arg_2 , arg_3 , arg_4 ) : if arg_1 is None : arg_5 = os . path . abspath ( os . path . curdir ) while arg_5 != os . path . sep : arg_1 = os . path . join ( arg_5 , 'Func.conf' ) if os . path . exists ( arg_1 ) : break arg_5 = os . path . dirname ( arg_5 ) else : arg_1 = '/etc/Func/Func.conf' if not os . path . exists ( arg_1 ) : arg_1 = None arg_0 . obj = arg_1 setup_logging ( arg_2 , arg_4 , arg_3 )

def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
    """Manage a Marv site"""
    if arg_1 is None:
        arg_5 = os.path.abspath(os.path.curdir)
        while arg_5 != os.path.sep:
            arg_1 = os.path.join(arg_5, 'Func.conf')
            if os.path.exists(arg_1):
                break
            arg_5 = os.path.dirname(arg_5)
        else:
            arg_1 = '/etc/Func/Func.conf'
            if not os.path.exists(arg_1):
                arg_1 = None
    arg_0.obj = arg_1
    setup_logging(arg_2, arg_4, arg_3)


def Func ( arg_0 , arg_1 ) : arg_2 = dumps ( arg_1 , default = _default ) arg_0 . transport . write ( arg_2 )

def Func(arg_0, arg_1):
        """
        Serializes the response to JSON, and writes it to the transport.
        """
        arg_2 = dumps(arg_1, default=_default)
        arg_0.transport.write(arg_2)

Serializes the response to JSON and writes it to the transport .


def
Func
(
arg_0
,
arg_1
=
)
:
arg_2
=
arg_0
.
getPackage
(
)
if
arg_2
==
''
:
arg_2
=
'core'
arg_3
=
'E{} ({}): {} ({}, L{}); {}; {}'
arg_4
=
arg_3
.
format
(
arg_1
,
arg_0
.
getSeverityAsString
(
)
,
arg_0
.
getCategoryAsString
(
)
,
arg_2
,
arg_0
.
getLine
(
)
,
arg_0
.
getShortMessage
(
)
,
arg_0
.
getMessage
(
)
)
return
arg_4

def Func(arg_0, arg_1=None):
    """String representation of SBMLError.

    Parameters
    ----------
    error : libsbml.SBMLError
    k : index of error

    Returns
    -------
    string representation of error
    """
    arg_2 = arg_0.getPackage()
    if arg_2 == '':
        arg_2 = 'core'

    arg_3 = 'E{} ({}): {} ({}, L{}); {}; {}'
    arg_4 = arg_3.format(arg_1, arg_0.getSeverityAsString(),
                                arg_0.getCategoryAsString(), arg_2,
                                arg_0.getLine(), arg_0.getShortMessage(),
                                arg_0.getMessage())
    return arg_4


This function waits for the relay and responding processes to exit.
            Captures KeyboardInterrupt to shutdown these processes.

def Func ( arg_0 ) : try : arg_0 . relay . Func ( ) arg_0 . responder . Func ( ) except KeyboardInterrupt : print_notification ( "Stopping" ) finally : arg_0 . terminate_processes ( )

def Func(arg_0):
        """
            This function Funcs for the relay and responding processes to exit.
            Captures KeyboardInterrupt to shutdown these processes.
        """
        try:
            arg_0.relay.Func()
            arg_0.responder.Func()
        except KeyboardInterrupt:
            print_notification("Stopping")
        finally:
            arg_0.terminate_processes()

This function waits for the relay and responding processes to exit . Captures KeyboardInterrupt to shutdown these processes .


def Func ( arg_0 , arg_1 ) : arg_2 = { "name" : None , "id" : None , "host" : None , "controller_port" : None , "master_port" : None , "stats_port" : None , } if arg_1 . tmaster : arg_2 [ "name" ] = arg_1 . tmaster . topology_name arg_2 [ "id" ] = arg_1 . tmaster . topology_id arg_2 [ "host" ] = arg_1 . tmaster . host arg_2 [ "controller_port" ] = arg_1 . tmaster . controller_port arg_2 [ "master_port" ] = arg_1 . tmaster . master_port arg_2 [ "stats_port" ] = arg_1 . tmaster . stats_port return arg_2

def Func(arg_0, arg_1):
    """
    Returns the representation of tmaster that will
    be returned from Tracker.
    """
    arg_2 = {
        "name": None,
        "id": None,
        "host": None,
        "controller_port": None,
        "master_port": None,
        "stats_port": None,
    }
    if arg_1.tmaster:
      arg_2["name"] = arg_1.tmaster.topology_name
      arg_2["id"] = arg_1.tmaster.topology_id
      arg_2["host"] = arg_1.tmaster.host
      arg_2["controller_port"] = arg_1.tmaster.controller_port
      arg_2["master_port"] = arg_1.tmaster.master_port
      arg_2["stats_port"] = arg_1.tmaster.stats_port

    return arg_2

Returns the representation of tmaster that will be returned from Tracker .


def Func(arg_0, arg_1):
    """Parse information about a Func."""
    arg_2 = {'builds': {'37': None, '38': None}, 'symbol': None, 'description': None, 'ensembl_id': None, 'record': None}

    for arg_3 in arg_2['builds']:
        arg_4 = arg_0.hgnc_Func(arg_1, arg_3=arg_3)
        if arg_4:

            arg_4['position'] = "{this[chromosome]}:{this[start]}-{this[end]}".format(this=arg_4)
            arg_2['aliases'] = arg_4['aliases']
            arg_2['hgnc_id'] = arg_4['hgnc_id']
            arg_2['description'] = arg_4['description']
            arg_2['builds'][arg_3] = arg_4
            arg_2['symbol'] = arg_4['hgnc_symbol']
            arg_2['description'] = arg_4['description']
            arg_2['entrez_id'] = arg_4.get('entrez_id')
            arg_2['pli_score'] = arg_4.get('pli_score')

            add_Func_links(arg_4, int(arg_3))

            arg_2['omim_id'] = arg_4.get('omim_id')
            arg_2['incomplete_penetrance'] = arg_4.get('incomplete_penetrance',False)
            arg_2['inheritance_models'] = arg_4.get('inheritance_models',[])
            for arg_5 in arg_4['transcripts']:
                arg_5['position'] = ("{this[chrom]}:{this[start]}-{this[end]}"
                                          .format(this=arg_5))
                add_tx_links(arg_5, arg_3)

            for arg_6 in arg_4.get('phenotypes',[]):
                arg_6['omim_link'] = omim(arg_6.get('mim_number'))

            if not arg_2['record']:
                arg_2['record'] = arg_4

    # If none of the Funcs where found
    if not any(arg_2.values()):
        raise ValueError

    return arg_2


def Func ( arg_0 , arg_1 ) : arg_0 . resetTimeout ( ) arg_2 = ( arg_0 . _buffer + arg_1 ) . splitlines ( ) if arg_1 . endswith ( b'\n' ) or arg_1 . endswith ( b'\r' ) : arg_0 . _buffer = b'' else : arg_0 . _buffer = arg_2 . pop ( - 1 ) for arg_4 in arg_2 : if arg_0 . transport . disconnecting : return if len ( arg_4 ) > arg_0 . _max_length : arg_0 . lineLengthExceeded ( arg_4 ) return else : arg_0 . lineReceived ( arg_4 ) if len ( arg_0 . _buffer ) > arg_0 . _max_length : arg_0 . lineLengthExceeded ( arg_0 . _buffer ) return

def Func(arg_0, arg_1):
        """
        Translates bytes into lines, and calls lineReceived.

        Copied from ``twisted.protocols.basic.LineOnlyReceiver`` but using
        str.splitlines() to split on ``\r\n``, ``\n``, and ``\r``.
        """
        arg_0.resetTimeout()
        arg_2 = (arg_0._buffer + arg_1).splitlines()

        # str.splitlines() doesn't split the string after a trailing newline
        # character so we must check if there is a trailing newline and, if so,
        # clear the buffer as the line is "complete". Else, the line is
        # incomplete and we keep the last line in the buffer.
        if arg_1.endswith(b'\n') or arg_1.endswith(b'\r'):
            arg_0._buffer = b''
        else:
            arg_0._buffer = arg_2.pop(-1)

        for arg_4 in arg_2:
            if arg_0.transport.disconnecting:
                # this is necessary because the transport may be told to lose
                # the connection by a line within a larger packet, and it is
                # important to disregard all the lines in that packet following
                # the one that told it to close.
                return
            if len(arg_4) > arg_0._max_length:
                arg_0.lineLengthExceeded(arg_4)
                return
            else:
                arg_0.lineReceived(arg_4)
        if len(arg_0._buffer) > arg_0._max_length:
            arg_0.lineLengthExceeded(arg_0._buffer)
            return

Translates bytes into lines and calls lineReceived .


def Func ( arg_0 ) : arg_1 = [ ] for arg_2 , arg_3 in list ( arg_0 . state_names . items ( ) ) : if arg_0 . _has_state ( arg_2 ) : arg_1 . append ( arg_3 ) return '|' . join ( arg_1 )

def Func(arg_0):
        """
        Returns a textual representation of this Task's state.
        """
        arg_1 = []
        for arg_2, arg_3 in list(arg_0.state_names.items()):
            if arg_0._has_state(arg_2):
                arg_1.append(arg_3)
        return '|'.join(arg_1)

Returns a textual representation of this Task s state .


(value: float, cutoff: Optional[float] = None)

def Func(arg_0: arg_1, arg_2: arg_3[arg_1] = None) -> int:
    """Assign if a value is greater than or less than a cutoff."""
    arg_2 = arg_2 if arg_2 is not None else 0

    if arg_0 > arg_2:
        return 1

    if arg_0 < (-1 * arg_2):
        return - 1

    return 0

Assign if a value is greater than or less than a cutoff .


def Func ( arg_0 ) : arg_1 = arg_0 . __subclasses__ ( ) for arg_2 in list ( arg_1 ) : arg_1 . extend ( Func ( arg_2 ) ) return arg_1

def Func(arg_0):
    """Gets the subclasses of a class."""
    arg_1 = arg_0.__subclasses__()
    for arg_2 in list(arg_1):
        arg_1.extend(Func(arg_2))
    return arg_1


Move this object below the referenced object.

def Func(arg_0, arg_1):
        """
        Move this object Func the referenced object.
        """
        if not arg_0._valid_ordering_reference(arg_1):
            raise ValueError(
                "%r can only be moved Func instances of %r which %s equals %r." % (
                    arg_0, arg_0.__class__, arg_0.order_with_respect_to,
                    arg_0._get_order_with_respect_to()
                )
            )
        if arg_0.order == arg_1.order:
            return
        if arg_0.order > arg_1.order:
            arg_2 = arg_0.get_ordering_queryset().filter(order__gt=arg_1.order).aggregate(Min('order')).get('order__min') or 0
        else:
            arg_2 = arg_1.order
        arg_0.to(arg_2)

Move this object below the referenced object .


def Func(arg_0='Repository', arg_1=None):
    """
    Print the last commit line and eventual uncommitted changes.
    """
    if arg_1 is None: arg_1 = GIT_PATH

    # If git is available, check fretbursts version
    if not git_path_valid():
        print('\n%s revision unknown (git not found).' % arg_0)
    else:
        arg_2 = get_last_commit_line()
        print('\n{} revision:\n {}\n'.format(arg_0, arg_2))
        if not check_clean_status():
            print('\nWARNING -> Uncommitted changes:')
            print(get_status())

Print the last commit line and eventual uncommitted changes .


Set the social login process state to connect rather than login
        Refer to the implementation of get_social_login in base class and to the
        allauth.socialaccount.helpers module complete_social_login function.

def Func ( arg_0 , * arg_1 , ** arg_2 ) : arg_3 = super ( SocialConnectMixin , arg_0 ) . Func ( * arg_1 , ** arg_2 ) arg_3 . state [ 'process' ] = AuthProcess . CONNECT return arg_3

def Func(arg_0, *arg_1, **arg_2):
        """
        Set the social login process state to connect rather than login
        Refer to the implementation of Func in base class and to the
        allauth.socialaccount.helpers module complete_social_login function.
        """
        arg_3 = super(SocialConnectMixin, arg_0).Func(*arg_1, **arg_2)
        arg_3.state['process'] = AuthProcess.CONNECT
        return arg_3

Set the social login process state to connect rather than login Refer to the implementation of get_social_login in base class and to the allauth . socialaccount . helpers module complete_social_login function .


def Func ( arg_0 ) : arg_1 = { } for arg_2 in range ( len ( arg_0 ) ) : if arg_2 in arg_0 . _data : continue arg_3 = arg_0 . get_field_descriptor ( arg_2 ) . tags . get ( "default" , [ None ] ) [ 0 ] if arg_3 is not None : arg_1 [ arg_2 ] = arg_3 arg_0 . update ( arg_1 )

def Func(arg_0):
        """
        sets all empty fields for which a default value is defined to default value
        """
        arg_1 = {}
        for arg_2 in range(len(arg_0)):
            if arg_2 in arg_0._data:
                continue
            arg_3 = arg_0.get_field_descriptor(arg_2).tags.get("default", [None])[0]
            if arg_3 is not None:
                arg_1[arg_2] = arg_3

        arg_0.update(arg_1)


def Func(arg_0, arg_1=6, arg_2="bytes"):
    """Compress anything to bytes or string.

    :params obj:
    :params level:
    :params return_type: if bytes, then return bytes; if str, then return
      base64.b64encode bytes in utf-8 string.
    """
    if isinstance(arg_0, binary_type):
        arg_3 = zlib.Func(arg_0, arg_1)
    elif isinstance(arg_0, string_types):
        arg_3 = zlib.Func(arg_0.encode("utf-8"), arg_1)
    else:
        arg_3 = zlib.Func(pickle.dumps(arg_0, protocol=2), arg_1)

    if arg_2 == "bytes":
        return arg_3
    elif arg_2 == "str":
        return base64.b64encode(arg_3).decode("utf-8")
    else:
        raise ValueError("'return_type' has to be one of 'bytes', 'str'!")


def Func ( arg_0 ) : arg_1 = np . zeros ( 4 ) arg_2 = np . zeros_like ( arg_0 . postcard ) arg_0 . obs_flux = np . zeros_like ( arg_0 . reference_flux ) for arg_4 in range ( 4 ) : arg_5 = np . where ( arg_0 . qs == arg_4 ) [ 0 ] arg_6 = np . where ( arg_0 . times [ arg_5 ] > 54947 ) arg_2 [ arg_5 ] = np . roll ( arg_0 . postcard [ arg_5 ] , int ( arg_0 . roll_best [ arg_4 , 0 ] ) , axis = 1 ) arg_2 [ arg_5 ] = np . roll ( arg_2 [ arg_5 ] , int ( arg_0 . roll_best [ arg_4 , 1 ] ) , axis = 2 ) arg_0 . target_flux_pixels = arg_2 [ : , arg_0 . targets == 1 ] arg_0 . target_flux = np . sum ( arg_0 . target_flux_pixels , axis = 1 ) arg_0 . obs_flux [ arg_5 ] = arg_0 . target_flux [ arg_5 ] / arg_0 . reference_flux [ arg_5 ] arg_0 . obs_flux [ arg_5 ] /= np . median ( arg_0 . obs_flux [ arg_5 [ arg_6 ] ] ) arg_9 = np . polyfit ( arg_0 . times [ arg_5 ] [ arg_6 ] , arg_0 . obs_flux [ arg_5 ] [ arg_6 ] , 1 ) arg_1 [ arg_4 ] = np . max ( [ np . std ( arg_0 . obs_flux [ arg_5 ] [ arg_6 ] / ( arg_9 [ 0 ] * arg_0 . times [ arg_5 ] [ arg_6 ] + arg_9 [ 1 ] ) ) , 0.001 ] ) arg_0 . flux_uncert = arg_1

def Func(arg_0):
        """
        Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data
        in each orientation. This function is called by other functions and generally the user will not need
        to interact with it directly.
        """

        arg_1 = np.zeros(4)
        arg_2 = np.zeros_like(arg_0.postcard)
        arg_0.obs_flux = np.zeros_like(arg_0.reference_flux)

        for arg_4 in range(4):
            arg_5 = np.where(arg_0.qs == arg_4)[0]
            arg_6 = np.where(arg_0.times[arg_5] > 54947)

            arg_2[arg_5] = np.roll(arg_0.postcard[arg_5], int(arg_0.roll_best[arg_4,0]), axis=1)
            arg_2[arg_5] = np.roll(arg_2[arg_5], int(arg_0.roll_best[arg_4,1]), axis=2)

            arg_0.target_flux_pixels = arg_2[:,arg_0.targets == 1]
            arg_0.target_flux = np.sum(arg_0.target_flux_pixels, axis=1)

            arg_0.obs_flux[arg_5] = arg_0.target_flux[arg_5] / arg_0.reference_flux[arg_5]
            arg_0.obs_flux[arg_5] /= np.median(arg_0.obs_flux[arg_5[arg_6]])

            arg_9 = np.polyfit(arg_0.times[arg_5][arg_6], arg_0.obs_flux[arg_5][arg_6], 1)
            arg_1[arg_4] = np.max([np.std(arg_0.obs_flux[arg_5][arg_6]/(arg_9[0]*arg_0.times[arg_5][arg_6]+arg_9[1])), 0.001])

        arg_0.flux_uncert = arg_1

Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data in each orientation . This function is called by other functions and generally the user will not need to interact with it directly .


(
    src_collection,
    tar_collection,
    metric=sim,
    mean_func=amean,
    symmetric=False,
)

return (
        max(pairwise_values),
        min(pairwise_values),
        mean_func(pairwise_values),
        std(pairwise_values, mean_func, 0),
    )

def Func(
    arg_0,
    arg_1,
    arg_2=arg_3,
    arg_4=arg_5,
    arg_6=False,
):
    """Calculate the pairwise similarity statistics a collection of strings.

    Calculate pairwise similarities among members of two collections,
    returning the maximum, minimum, mean (according to a supplied function,
    arithmetic mean, by default), and (population) standard deviation
    of those similarities.

    Parameters
    ----------
    src_collection : list
        A collection of terms or a string that can be split
    tar_collection : list
        A collection of terms or a string that can be split
    metric : function
        A similarity metric function
    mean_func : function
        A mean function that takes a list of values and returns a float
    symmetric : bool
        Set to True if all pairwise similarities should be calculated in both
        directions

    Returns
    -------
    tuple
        The max, min, mean, and standard deviation of similarities

    Raises
    ------
    ValueError
        mean_func must be a function
    ValueError
        metric must be a function
    ValueError
        src_collection is neither a string nor iterable
    ValueError
        tar_collection is neither a string nor iterable

    Example
    -------
    >>> tuple(round(_, 12) for _ in Func(
    ... ['Christopher', 'Kristof', 'Christobal'], ['Niall', 'Neal', 'Neil']))
    (0.2, 0.0, 0.118614718615, 0.075070477184)

    """
    if not callable(arg_4):
        raise ValueError('mean_func must be a function')
    if not callable(arg_2):
        raise ValueError('metric must be a function')

    if hasattr(arg_0, 'split'):
        arg_0 = arg_0.split()
    if not hasattr(arg_0, '__iter__'):
        raise ValueError('src_collection is neither a string nor iterable')

    if hasattr(arg_1, 'split'):
        arg_1 = arg_1.split()
    if not hasattr(arg_1, '__iter__'):
        raise ValueError('tar_collection is neither a string nor iterable')

    arg_0 = list(arg_0)
    arg_1 = list(arg_1)

    arg_7 = []

    for arg_8 in arg_0:
        for arg_9 in arg_1:
            arg_7.append(arg_2(arg_8, arg_9))
            if arg_6:
                arg_7.append(arg_2(arg_9, arg_8))

    return (
        max(arg_7),
        min(arg_7),
        arg_4(arg_7),
        std(arg_7, arg_4, 0),
    )

Calculate the pairwise similarity statistics a collection of strings.

    Calculate pairwise similarities among members of two collections,
    returning the maximum, minimum, mean (according to a supplied function,
    arithmetic mean, by default), and (population) standard deviation
    of those similarities.

    Parameters
    ----------
    src_collection : list
        A collection of terms or a string that can be split
    tar_collection : list
        A collection of terms or a string that can be split
    metric : function
        A similarity metric function
    mean_func : function
        A mean function that takes a list of values and returns a float
    symmetric : bool
        Set to True if all pairwise similarities should be calculated in both
        directions

    Returns
    -------
    tuple
        The max, min, mean, and standard deviation of similarities

    Raises
    ------
    ValueError
        mean_func must be a function
    ValueError
        metric must be a function
    ValueError
        src_collection is neither a string nor iterable
    ValueError
        tar_collection is neither a string nor iterable

    Example
    -------
    >>> tuple(round(_, 12) for _ in pairwise_similarity_statistics(
    ... ['Christopher', 'Kristof', 'Christobal'], ['Niall', 'Neal', 'Neil']))
    (0.2, 0.0, 0.118614718615, 0.075070477184)

Calculate the pairwise similarity statistics a collection of strings .


def Func ( arg_0 , arg_1 = 2 ) : arg_0 . frame_no += 1 try : next ( arg_0 . follower ) except ( AttributeError , StopIteration ) as err : arg_0 . reset ( )

def Func(arg_0, arg_1=2):
        '''Advance the physics world by one Func.

        Typically this is called as part of a :class:`pagoda.viewer.Viewer`, but
        it can also be called manually (or some other Funcping mechanism
        entirely can be used).
        '''
        # by default we Func by following our loaded marker data.
        arg_0.frame_no += 1
        try:
            next(arg_0.follower)
        except (AttributeError, StopIteration) as err:
            arg_0.reset()

Advance the physics world by one step.

        Typically this is called as part of a :class:`pagoda.viewer.Viewer`, but
        it can also be called manually (or some other stepping mechanism
        entirely can be used).


def Func(arg_0, arg_1, arg_2):
    """Copy the DICOM file groups to folder_path. Each group will be copied into
    a subfolder with named given by groupby_field.

    Parameters
    ----------
    dicom_groups: boyle.dicom.sets.DicomFileSet

    folder_path: str
     Path to where copy the DICOM files.

    groupby_field_name: str
     DICOM field name. Will get the value of this field to name the group
     folder.
    """
    if arg_0 is None or not arg_0:
        raise ValueError('Expected a boyle.dicom.sets.DicomFileSet.')
    if not os.path.exists(arg_1):
        os.makedirs(arg_1, exist_ok=False)

    for arg_3 in arg_0:
        if arg_2 is not None and len(arg_2) > 0:
            arg_4 = DicomFile(arg_3)
            arg_5 = ''
            for arg_6 in arg_2:
                arg_5 = os.path.join(arg_5, arg_4.get_attributes(arg_6))
            arg_5 = str(arg_5)
        else:
            arg_5 = os.path.basename(arg_3)

        arg_7 = os.path.join(arg_1, arg_5)
        os.makedirs(arg_7, exist_ok=False)

        log.debug('Copying files to {}.'.format(arg_7))

        import shutil
        arg_8 = arg_0[arg_3]

        for arg_9 in arg_8:
            arg_10 = os.path.join(arg_7, os.path.basename(arg_9))
            while os.path.exists(arg_10):
                arg_10 += '+'
            shutil.copy2(arg_9, arg_10)

Copy the DICOM file groups to folder_path . Each group will be copied into a subfolder with named given by groupby_field .


def Func ( arg_0 , arg_1 ) : arg_2 = arg_1 . add_subparsers ( ) for arg_3 in arg_0 . config [ 'subparsers' ] : arg_4 = arg_2 . add_parser ( arg_3 ) arg_0 . create_commands ( arg_0 . config [ 'subparsers' ] [ arg_3 ] , arg_4 )

def Func(arg_0, arg_1):
        """ get config for subparser and create commands"""
        arg_2 = arg_1.add_subparsers()
        for arg_3 in arg_0.config['subparsers']:
            arg_4 = arg_2.add_parser(arg_3)
            arg_0.create_commands(arg_0.config['subparsers'][arg_3], arg_4)


(job, vcfs, ref_fasta, ref_fai, ref_dict, merge_option='UNIQUIFY')

def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5='UNIQUIFY'):
    """
    Merges VCF files using GATK CombineVariants

    :param JobFunctionWrappingJob job: Toil Job instance
    :param dict vcfs: Dictionary of VCF FileStoreIDs {sample identifier: FileStoreID}
    :param str ref_fasta: FileStoreID for reference genome fasta
    :param str ref_fai: FileStoreID for reference genome index file
    :param str ref_dict: FileStoreID for reference genome sequence dictionary file
    :param str merge_option: Value for --genotypemergeoption flag (Default: 'UNIQUIFY')
                            'UNIQUIFY': Multiple variants at a single site are merged into a
                                        single variant record.
                            'UNSORTED': Used to merge VCFs from the same sample
    :return: FileStoreID for merged VCF file
    :rtype: str
    """
    arg_0.fileStore.logToMaster('Running GATK CombineVariants')

    arg_6 = {'genome.fa': arg_2,
              'genome.fa.fai': arg_3,
              'genome.dict': arg_4}
    arg_6.update(arg_1)

    arg_7 = arg_0.fileStore.getLocalTempDir()
    for arg_8, arg_9 in arg_6.iteritems():
        arg_0.fileStore.readGlobalFile(arg_9, os.path.join(arg_7, arg_8))

    arg_10 = ['-T', 'CombineVariants',
               '-R', '/data/genome.fa',
               '-o', '/data/merged.vcf',
               '--genotypemergeoption', arg_5]

    for arg_11, arg_12 in arg_1.iteritems():
        arg_10.extend(['--variant', os.path.join('/data', arg_11)])

    arg_13 = ['--rm', 'log-driver', 'none',
                         '-e', 'JAVA_OPTS=-Djava.io.tmpdir=/data/ -Xmx{}'.format(arg_0.memory)]
    dockerCall(arg_0=arg_0, workDir=arg_7,
               parameters=arg_10,
               tool='quay.io/ucsc_cgl/gatk:3.5--dba6dae49156168a909c43330350c6161dc7ecc2',
               dockerParameters=arg_13)

    return arg_0.fileStore.writeGlobalFile(os.path.join(arg_7, 'merged.vcf'))


def Func ( ) : for arg_0 in [ "http://routerlogin.net:5000" , "https://routerlogin.net" , "http://routerlogin.net" ] : try : arg_1 = requests . get ( arg_0 + "/soap/server_sa/" , headers = _get_soap_headers ( "Test:1" , "test" ) , verify = False ) if arg_1 . status_code == 200 : return arg_0 except requests . exceptions . RequestException : pass return None

def Func():
    """
    Try to autodetect the base URL of the router SOAP service.

    Returns None if it can't be found.
    """
    for arg_0 in ["http://routerlogin.net:5000", "https://routerlogin.net",
                "http://routerlogin.net"]:
        try:
            arg_1 = requests.get(arg_0 + "/soap/server_sa/",
                             headers=_get_soap_headers("Test:1", "test"),
                             verify=False)
            if arg_1.status_code == 200:
                return arg_0
        except requests.exceptions.RequestException:
            pass

    return None

Try to autodetect the base URL of the router SOAP service .


(alpha=1.0, per_channel=False, name=None, deterministic=False, random_state=None)

return contrast_lib.LinearContrast(alpha=alpha, per_channel=per_channel, name=name, deterministic=deterministic,
                                       random_state=random_state)

def Func(arg_0=1.0, arg_1=False, arg_2=None, arg_3=False, arg_4=None):
    """
    Augmenter that changes the contrast of images.

    dtype support:

        See ``imgaug.augmenters.contrast.LinearContrast``.

    Parameters
    ----------
    alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Strength of the contrast normalization. Higher values than 1.0
        lead to higher contrast, lower values decrease the contrast.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be sampled per image from
              the range ``a <= x <= b`` and be used as the alpha value.
            * If a list, then a random value will be sampled per image from
              that list.
            * If a StochasticParameter, then this parameter will be used to
              sample the alpha value per image.

    per_channel : bool or float, optional
        Whether to use the same value for all channels (False)
        or to sample a new value for each channel (True).
        If this value is a float ``p``, then for ``p`` percent of all images
        `per_channel` will be treated as True, otherwise as False.

    name : None or str, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    deterministic : bool, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or numpy.random.RandomState, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    Examples
    --------
    >>> iaa.Func((0.5, 1.5))

    Decreases oder improves contrast per image by a random factor between
    0.5 and 1.5. The factor 0.5 means that any difference from the center value
    (i.e. 128) will be halved, leading to less contrast.

    >>> iaa.Func((0.5, 1.5), per_channel=0.5)

    Same as before, but for 50 percent of all images the normalization is done
    independently per channel (i.e. factors can vary per channel for the same
    image). In the other 50 percent of all images, the factor is the same for
    all channels.

    """
    # placed here to avoid cyclic dependency
    from . import contrast as contrast_lib
    return contrast_lib.LinearContrast(arg_0=arg_0, arg_1=arg_1, arg_2=arg_2, arg_3=arg_3,
                                       arg_4=arg_4)

Augmenter that changes the contrast of images.

    dtype support:

        See ``imgaug.augmenters.contrast.LinearContrast``.

    Parameters
    ----------
    alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Strength of the contrast normalization. Higher values than 1.0
        lead to higher contrast, lower values decrease the contrast.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value will be sampled per image from
              the range ``a <= x <= b`` and be used as the alpha value.
            * If a list, then a random value will be sampled per image from
              that list.
            * If a StochasticParameter, then this parameter will be used to
              sample the alpha value per image.

    per_channel : bool or float, optional
        Whether to use the same value for all channels (False)
        or to sample a new value for each channel (True).
        If this value is a float ``p``, then for ``p`` percent of all images
        `per_channel` will be treated as True, otherwise as False.

    name : None or str, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    deterministic : bool, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or numpy.random.RandomState, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    Examples
    --------
    >>> iaa.ContrastNormalization((0.5, 1.5))

    Decreases oder improves contrast per image by a random factor between
    0.5 and 1.5. The factor 0.5 means that any difference from the center value
    (i.e. 128) will be halved, leading to less contrast.

    >>> iaa.ContrastNormalization((0.5, 1.5), per_channel=0.5)

    Same as before, but for 50 percent of all images the normalization is done
    independently per channel (i.e. factors can vary per channel for the same
    image). In the other 50 percent of all images, the factor is the same for
    all channels.

Augmenter that changes the contrast of images .


def Func ( arg_0 ) : arg_1 = JavaObjectUnmarshaller ( arg_0 ) arg_1 . add_transformer ( DefaultObjectTransformer ( ) ) return arg_1 . readObject ( )

def Func(arg_0):
  """
  Deserializes Java primitive data and objects serialized by ObjectOutputStream
  from a file-like object.
  """
  arg_1 = JavaObjectUnmarshaller(arg_0)
  arg_1.add_transformer(DefaultObjectTransformer())
  return arg_1.readObject()

Deserializes Java primitive data and objects serialized by ObjectOutputStream from a file - like object .


def Func(arg_0, arg_1):
        """
        Saves aggregate DMARC reports to Splunk

        Args:
            aggregate_reports: A list of aggregate report dictionaries
            to save in Splunk

        """
        logger.debug("Saving aggregate reports to Splunk")
        if type(arg_1) == dict:
            arg_1 = [arg_1]

        if len(arg_1) < 1:
            return

        arg_2 = arg_0._common_data.copy()
        arg_3 = ""
        for arg_4 in arg_1:
            for arg_5 in arg_4["records"]:
                arg_6 = dict()
                for arg_7 in arg_4["report_metadata"]:
                    arg_6[arg_7] = arg_4["report_metadata"][arg_7]
                arg_6["published_policy"] = arg_4["policy_published"]
                arg_6["source_ip_address"] = arg_5["source"][
                    "ip_address"]
                arg_6["source_country"] = arg_5["source"]["country"]
                arg_6["source_reverse_dns"] = arg_5["source"][
                    "reverse_dns"]
                arg_6["source_base_domain"] = arg_5["source"][
                    "base_domain"]
                arg_6["message_count"] = arg_5["count"]
                arg_6["disposition"] = arg_5["policy_evaluated"][
                    "disposition"
                ]
                arg_6["spf_aligned"] = arg_5["alignment"]["spf"]
                arg_6["dkim_aligned"] = arg_5["alignment"]["dkim"]
                arg_6["passed_dmarc"] = arg_5["alignment"]["dmarc"]
                arg_6["header_from"] = arg_5["identifiers"][
                    "header_from"]
                arg_6["envelope_from"] = arg_5["identifiers"][
                    "envelope_from"]
                if "dkim" in arg_5["auth_results"]:
                    arg_6["dkim_results"] = arg_5["auth_results"][
                        "dkim"]
                if "spf" in arg_5["auth_results"]:
                    arg_6["spf_results"] = arg_5["auth_results"][
                        "spf"]

                arg_2["sourcetype"] = "dmarc:aggregate"
                arg_8 = human_timestamp_to_timestamp(
                    arg_6["begin_date"])
                arg_2["time"] = arg_8
                arg_2["event"] = arg_6.copy()
                arg_3 += "{0}\n".format(json.dumps(arg_2))

        if not arg_0.session.verify:
            logger.debug("Skipping certificate verification for Splunk HEC")
        try:
            arg_9 = arg_0.session.post(arg_0.url, arg_2=arg_3,
                                         timeout=arg_0.timeout)
            arg_9 = arg_9.json()
        except Exception as e:
            raise SplunkError(e.__str__())
        if arg_9["code"] != 0:
            raise SplunkError(arg_9["text"])


return default_auto_cast_fn(self, sigOrVal, toType)

def Func ( arg_0 , arg_1 , arg_2 ) : if isinstance ( arg_1 , Value ) : return Func__val ( arg_0 , arg_1 , arg_2 ) elif isinstance ( arg_2 , HBool ) : if arg_0 . bit_length ( ) == 1 : arg_3 = 0 if arg_1 . _dtype . negated else 1 return arg_1 . _eq ( arg_0 . getValueCls ( ) . fromPy ( arg_3 , arg_0 ) ) elif isinstance ( arg_2 , Bits ) : if arg_0 . bit_length ( ) == arg_2 . bit_length ( ) : return arg_1 . _convSign ( arg_2 . signed ) elif arg_2 == INT : return Operator . withRes ( AllOps . BitsToInt , [ arg_1 ] , arg_2 ) return default_auto_cast_fn ( arg_0 , arg_1 , arg_2 )

def Func(arg_0, arg_1, arg_2):
    """
    Cast signed-unsigned, to int or bool
    """
    if isinstance(arg_1, Value):
        return Func__val(arg_0, arg_1, arg_2)
    elif isinstance(arg_2, HBool):
        if arg_0.bit_length() == 1:
            arg_3 = 0 if arg_1._dtype.negated else 1
            return arg_1._eq(arg_0.getValueCls().fromPy(arg_3, arg_0))
    elif isinstance(arg_2, Bits):
        if arg_0.bit_length() == arg_2.bit_length():
            return arg_1._convSign(arg_2.signed)
    elif arg_2 == INT:
        return Operator.withRes(AllOps.BitsToInt, [arg_1], arg_2)

    return default_auto_cast_fn(arg_0, arg_1, arg_2)


def Func ( arg_0 ) : return np . divide ( np . abs ( arg_0 . image ) , arg_0 . noise_map )

def Func(arg_0):
        """The estimated absolute_signal-to-noise_maps mappers of the image."""
        return np.divide(np.abs(arg_0.image), arg_0.noise_map)

The estimated absolute_signal - to - noise_maps mappers of the image .


(self, media, media_size,
                              path=None,
                              media_type=None,
                              media_category=None,
                              chunk_size=2**20,
                              **params)

async def Func ( arg_0 , arg_1 , arg_2 , arg_3 = None , arg_4 = None , arg_5 = None , arg_6 = 2 ** 20 , ** arg_7 ) : if isinstance ( arg_1 , bytes ) : arg_1 = io . BytesIO ( arg_1 ) arg_8 = arg_1 . read ( arg_6 ) arg_9 = asyncio . iscoroutine ( arg_8 ) if arg_9 : arg_8 = await arg_8 if arg_4 is None : arg_10 = await utils . get_media_metadata ( arg_8 , arg_3 ) arg_4 , arg_5 = arg_10 elif arg_5 is None : arg_5 = utils . get_category ( arg_4 ) arg_11 = await arg_0 . upload . media . upload . post ( command = "INIT" , total_bytes = arg_2 , arg_4 = arg_4 , arg_5 = arg_5 , ** arg_7 ) arg_12 = arg_11 [ 'media_id' ] arg_13 = 0 while arg_8 : if arg_9 : arg_14 = arg_0 . upload . media . upload . post ( command = "APPEND" , arg_12 = arg_12 , arg_1 = arg_8 , segment_index = arg_13 ) arg_8 , arg_15 = await asyncio . gather ( arg_1 . read ( arg_6 ) , arg_14 ) else : await arg_0 . upload . media . upload . post ( command = "APPEND" , arg_12 = arg_12 , arg_1 = arg_8 , segment_index = arg_13 ) arg_8 = arg_1 . read ( arg_6 ) arg_13 += 1 arg_16 = await arg_0 . upload . media . upload . post ( command = "FINALIZE" , arg_12 = arg_12 ) if 'processing_info' in arg_16 : while arg_16 [ 'processing_info' ] . get ( 'state' ) != "succeeded" : arg_17 = arg_16 [ 'processing_info' ] if arg_17 . get ( 'state' ) == "failed" : arg_18 = arg_17 . get ( 'error' , { } ) arg_19 = arg_18 . get ( 'message' , str ( arg_16 ) ) raise exceptions . MediaProcessingError ( data = arg_16 , arg_19 = arg_19 , ** arg_7 ) arg_20 = arg_17 [ 'check_after_secs' ] await asyncio . sleep ( arg_20 ) arg_16 = await arg_0 . upload . media . upload . get ( command = "STATUS" , arg_12 = arg_12 , ** arg_7 ) return arg_11

async def Func(arg_0, arg_1, arg_2,
                              arg_3=None,
                              arg_4=None,
                              arg_5=None,
                              arg_6=2**20,
                              **arg_7):
        """
            upload media in chunks

        Parameters
        ----------
        media : file object
            a file object of the media
        media_size : int
            size of the media
        path : str, optional
            filename of the media
        media_type : str, optional
            mime type of the media
        media_category : str, optional
            twitter media category, must be used with ``media_type``
        chunk_size : int, optional
            size of a chunk in bytes
        params : dict, optional
            additional parameters of the request

        Returns
        -------
        .data_processing.PeonyResponse
            Response of the request
        """
        if isinstance(arg_1, bytes):
            arg_1 = io.BytesIO(arg_1)

        arg_8 = arg_1.read(arg_6)
        arg_9 = asyncio.iscoroutine(arg_8)

        if arg_9:
            arg_8 = await arg_8

        if arg_4 is None:
            arg_10 = await utils.get_media_metadata(arg_8, arg_3)
            arg_4, arg_5 = arg_10
        elif arg_5 is None:
            arg_5 = utils.get_category(arg_4)

        arg_11 = await arg_0.upload.media.upload.post(
            command="INIT",
            total_bytes=arg_2,
            arg_4=arg_4,
            arg_5=arg_5,
            **arg_7
        )

        arg_12 = arg_11['media_id']
        arg_13 = 0

        while arg_8:
            if arg_9:
                arg_14 = arg_0.upload.media.upload.post(command="APPEND",
                                                    arg_12=arg_12,
                                                    arg_1=arg_8,
                                                    segment_index=arg_13)
                arg_8, arg_15 = await asyncio.gather(arg_1.read(arg_6), arg_14)
            else:
                await arg_0.upload.media.upload.post(command="APPEND",
                                                    arg_12=arg_12,
                                                    arg_1=arg_8,
                                                    segment_index=arg_13)

                arg_8 = arg_1.read(arg_6)

            arg_13 += 1

        arg_16 = await arg_0.upload.media.upload.post(command="FINALIZE",
                                                     arg_12=arg_12)

        if 'processing_info' in arg_16:
            while arg_16['processing_info'].get('state') != "succeeded":
                arg_17 = arg_16['processing_info']
                if arg_17.get('state') == "failed":
                    arg_18 = arg_17.get('error', {})

                    arg_19 = arg_18.get('message', str(arg_16))

                    raise exceptions.MediaProcessingError(data=arg_16,
                                                          arg_19=arg_19,
                                                          **arg_7)

                arg_20 = arg_17['check_after_secs']
                await asyncio.sleep(arg_20)

                arg_16 = await arg_0.upload.media.upload.get(
                    command="STATUS",
                    arg_12=arg_12,
                    **arg_7
                )

        return arg_11


def Func ( ) : with contextlib . closing ( connect_to_db ( ) ) as db : db . cursor ( ) . executescript ( DB_SCHEMA ) db . commit ( )

def Func():
    """Initializes DB."""
    with contextlib.closing(connect_to_db()) as db:
        db.cursor().executescript(DB_SCHEMA)
        db.commit()


def Func(arg_0, arg_1, arg_2=False):
        """
        Convert archetypes of the model into original feature space.

        :param H2OFrame test_data: The dataset upon which the model was trained.
        :param bool reverse_transform: Whether the transformation of the training data during model-building
            should be reversed on the projected archetypes.

        :returns: model archetypes projected back into the original training data's feature space.
        """
        if arg_1 is None or arg_1.nrow == 0: raise ValueError("Must specify test data")
        arg_3 = h2o.api("POST /3/Predictions/models/%s/frames/%s" % (arg_0.model_id, arg_1.frame_id),
                    data={"project_archetypes": True, "reverse_transform": arg_2})
        return h2o.get_frame(arg_3["model_metrics"][0]["predictions"]["frame_id"]["name"])

Convert archetypes of the model into original feature space .


def Func ( arg_0 ) : arg_1 = arg_0 . read ( 1 ) arg_2 = len ( arg_1 ) == 0 if not arg_2 : arg_3 = arg_0 . tell ( ) arg_0 . seek ( arg_3 - 1 ) return arg_2

def Func(arg_0):
    """Determine if end-of-file is reached for file fd."""
    arg_1 = arg_0.read(1)
    arg_2 = len(arg_1) == 0
    if not arg_2:
        arg_3 = arg_0.tell()
        arg_0.seek(arg_3 - 1)
    return arg_2

Determine if end - of - file is reached for file fd .


def
Func
(
arg_0
,
arg_1
,
arg_2
=
)
:
arg_2
=
self
.
format
if
arg_2
is
else
arg_2
arg_3
=
getattr
(
arg_0
,
"load_%s"
%
arg_2
,
)
if
arg_3
is
:
raise
ValueError
(
"Unknown format '%s'."
%
arg_2
)
return
arg_3
(
arg_1
)

def Func(arg_0, arg_1, arg_2=None):
        """ Load the object to a given file like object with the given
            protocol.
        """
        arg_2 = self.format if arg_2 is None else arg_2
        arg_3 = getattr(arg_0, "load_%s" % arg_2, None)
        if arg_3 is None:
            raise ValueError("Unknown format '%s'." % arg_2)
        return arg_3(arg_1)

Load the object to a given file like object with the given protocol .


def Func ( arg_0 , arg_1 ) : arg_2 = [ ] arg_3 = TMemoryBuffer ( arg_1 ) if six . byte2int ( arg_1 ) == TType . STRUCT : arg_4 , arg_5 = read_list_begin ( arg_3 ) else : arg_5 = 1 for arg_4 in range ( arg_5 ) : arg_6 = zipkin_core . Span ( ) arg_6 . read ( TBinaryProtocol ( arg_3 ) ) arg_2 . append ( arg_0 . _decode_thrift_span ( arg_6 ) ) return arg_2

def Func(arg_0, arg_1):
        """Decodes an encoded list of spans.

        :param spans: encoded list of spans
        :type spans: bytes
        :return: list of spans
        :rtype: list of Span
        """
        arg_2 = []
        arg_3 = TMemoryBuffer(arg_1)

        if six.byte2int(arg_1) == TType.STRUCT:
            arg_4, arg_5 = read_list_begin(arg_3)
        else:
            arg_5 = 1

        for arg_4 in range(arg_5):
            arg_6 = zipkin_core.Span()
            arg_6.read(TBinaryProtocol(arg_3))
            arg_2.append(arg_0._decode_thrift_span(arg_6))
        return arg_2


def Func ( arg_0 , arg_1 ) : arg_2 = [ ] arg_3 = [ ] arg_4 = [ ] arg_5 = { } arg_6 = { } for arg_7 in arg_0 : arg_5 . setdefault ( arg_7 . unified_job_template , [ ] ) arg_5 [ arg_7 . unified_job_template ] . append ( arg_7 ) for arg_7 in arg_1 : arg_6 . setdefault ( arg_7 . unified_job_template , [ ] ) arg_6 [ arg_7 . unified_job_template ] . append ( arg_7 ) for arg_8 in arg_5 : if arg_8 not in arg_6 : arg_3 . extend ( arg_5 [ arg_8 ] ) continue arg_9 = arg_5 [ arg_8 ] arg_10 = arg_6 . pop ( arg_8 ) if len ( arg_9 ) == 1 and len ( arg_10 ) == 1 : arg_4 . append ( ( arg_9 [ 0 ] , arg_10 [ 0 ] ) ) else : arg_3 . extend ( arg_9 ) arg_2 . extend ( arg_10 ) for arg_11 in arg_6 . values ( ) : arg_2 . extend ( arg_11 ) return arg_2 , arg_3 , arg_4

def Func(arg_0, arg_1):
    '''
    Investigate two lists of workflow TreeNodes and categorize them.

    There will be three types of nodes after categorization:
        1. Nodes that only exists in the new list. These nodes will later be
        created recursively.
        2. Nodes that only exists in the old list. These nodes will later be
        deleted recursively.
        3. Node pairs that makes an exact match. These nodes will be further
        investigated.

    Corresponding nodes of old and new lists will be distinguished by their
    unified_job_template value. A special case is that both the old and the new
    lists contain one type of node, say A, and at least one of them contains
    duplicates. In this case all A nodes in the old list will be categorized as
    to-be-deleted and all A nodes in the new list will be categorized as
    to-be-created.
    '''
    arg_2 = []
    arg_3 = []
    arg_4 = []
    arg_5 = {}
    arg_6 = {}
    for arg_7 in arg_0:
        arg_5.setdefault(arg_7.unified_job_template, [])
        arg_5[arg_7.unified_job_template].append(arg_7)
    for arg_7 in arg_1:
        arg_6.setdefault(arg_7.unified_job_template, [])
        arg_6[arg_7.unified_job_template].append(arg_7)
    for arg_8 in arg_5:
        if arg_8 not in arg_6:
            arg_3.extend(arg_5[arg_8])
            continue
        arg_9 = arg_5[arg_8]
        arg_10 = arg_6.pop(arg_8)
        if len(arg_9) == 1 and len(arg_10) == 1:
            arg_4.append((arg_9[0], arg_10[0]))
        else:
            arg_3.extend(arg_9)
            arg_2.extend(arg_10)
    for arg_11 in arg_6.values():
        arg_2.extend(arg_11)
    return arg_2, arg_3, arg_4

Investigate two lists of workflow TreeNodes and categorize them .


def Func(arg_0):
        r'''Method to load all data, and set all_methods based on the available
        data and properties. Demo function for testing only; must be
        implemented according to the methods available for each individual
        method.
        '''
        arg_1 = []
        arg_2, arg_3 = [], []
        if arg_0.CASRN in ['7732-18-5', '67-56-1', '64-17-5']:
            arg_1.append(TEST_METHOD_1)
            arg_0.TEST_METHOD_1_Tmin = 200.
            arg_0.TEST_METHOD_1_Tmax = 350
            arg_0.TEST_METHOD_1_coeffs = [1, .002]
            arg_2.append(arg_0.TEST_METHOD_1_Tmin); arg_3.append(arg_0.TEST_METHOD_1_Tmax)
        if arg_0.CASRN in ['67-56-1']:
            arg_1.append(TEST_METHOD_2)
            arg_0.TEST_METHOD_2_Tmin = 300.
            arg_0.TEST_METHOD_2_Tmax = 400
            arg_0.TEST_METHOD_2_coeffs = [1, .003]
            arg_2.append(arg_0.TEST_METHOD_2_Tmin); arg_3.append(arg_0.TEST_METHOD_2_Tmax)
        arg_0.all_methods = set(arg_1)
        if arg_2 and arg_3:
            arg_0.Tmin = min(arg_2)
            arg_0.Tmax = max(arg_3)

r Method to load all data and set all_methods based on the available data and properties . Demo function for testing only ; must be implemented according to the methods available for each individual method .


def Func ( arg_0 , arg_1 ) : arg_2 = [ 'mean' , 'std' , 'min' , 'max' ] arg_3 = range ( 0 , 100 , 1 ) for arg_4 , arg_5 in arg_1 . items ( ) : for arg_6 , arg_7 in arg_5 . items ( ) : arg_8 = arg_1 [ arg_4 ] [ arg_6 ] . values ( ) if arg_0 . groupby : arg_9 = arg_6 + '.' + arg_4 else : arg_9 = arg_4 if arg_4 . startswith ( 'qps' ) : arg_0 . calculated_stats [ arg_9 ] , arg_0 . calculated_percentiles [ arg_9 ] = naarad . utils . calculate_stats ( arg_8 , arg_2 , arg_3 ) else : arg_0 . calculated_stats [ arg_9 ] , arg_0 . calculated_percentiles [ arg_9 ] = naarad . utils . calculate_stats ( list ( heapq . merge ( * arg_8 ) ) , arg_2 , arg_3 ) arg_0 . update_summary_stats ( arg_9 )

def Func(arg_0, arg_1):
    """
    Calculate stats such as percentile and mean

    :param dict metric_store: The metric store used to store all the parsed log data
    :return: None
    """
    arg_2 = ['mean', 'std', 'min', 'max']  # TODO: get input from user
    arg_3 = range(0, 100, 1)  # TODO: get input from user
    for arg_4, arg_5 in arg_1.items():
      for arg_6, arg_7 in arg_5.items():
        arg_8 = arg_1[arg_4][arg_6].values()
        if arg_0.groupby:
          arg_9 = arg_6 + '.' + arg_4
        else:
          arg_9 = arg_4
        if arg_4.startswith('qps'):
          arg_0.calculated_stats[arg_9], arg_0.calculated_percentiles[arg_9] = naarad.utils.calculate_stats(arg_8, arg_2, arg_3)
        else:
          arg_0.calculated_stats[arg_9], arg_0.calculated_percentiles[arg_9] = naarad.utils.calculate_stats(list(heapq.merge(*arg_8)), arg_2,
                                                                                arg_3)
        arg_0.update_summary_stats(arg_9)


def Func ( arg_0 : arg_1 [ arg_2 , arg_3 [ arg_4 ] ] ) -> OptionalParser : if isinstance ( arg_0 , str ) : arg_0 = lit ( arg_0 ) return OptionalParser ( arg_0 )

def Func(arg_0: arg_1[arg_2, arg_3[arg_4]]) -> OptionalParser:
    """Optionally match a parser.

    An ``OptionalParser`` attempts to match ``parser``. If it succeeds, it
    returns a list of length one with the value returned by the parser as the
    only element. If it fails, it returns an empty list.

    Args:
        parser: Parser or literal
    """
    if isinstance(arg_0, str):
        arg_0 = lit(arg_0)
    return OptionalParser(arg_0)


def Func(arg_0):
        """Attempts to detect at BOM at the start of the stream. If
        an encoding can be determined from the BOM return the name of the
        encoding otherwise return None"""
        arg_1 = {
            codecs.BOM_UTF8: 'utf-8',
            codecs.BOM_UTF16_LE: 'utf-16-le', codecs.BOM_UTF16_BE: 'utf-16-be',
            codecs.BOM_UTF32_LE: 'utf-32-le', codecs.BOM_UTF32_BE: 'utf-32-be'
        }

        # Go to beginning of file and read in 4 bytes
        arg_2 = arg_0.rawStream.read(4)
        assert isinstance(arg_2, bytes)

        # Try detecting the BOM using bytes from the string
        arg_3 = arg_1.get(arg_2[:3])         # UTF-8
        arg_4 = 3
        if not arg_3:
            # Need to detect UTF-32 before UTF-16
            arg_3 = arg_1.get(arg_2)         # UTF-32
            arg_4 = 4
            if not arg_3:
                arg_3 = arg_1.get(arg_2[:2])  # UTF-16
                arg_4 = 2

        # Set the read position past the BOM if one was found, otherwise
        # set it to the start of the stream
        arg_0.rawStream.seek(arg_3 and arg_4 or 0)

        return arg_3

Attempts to detect at BOM at the start of the stream . If an encoding can be determined from the BOM return the name of the encoding otherwise return None


def
Func
(
arg_0
,
arg_1
,
arg_2
=
True
)
:
arg_3
=
pexdoc
.
exh
.
addex
(
RuntimeError
,
"Waveforms are not compatible"
)
arg_4
=
(
bool
(
arg_0
.
indep_scale
!=
arg_1
.
indep_scale
)
,
bool
(
arg_0
.
dep_scale
!=
arg_1
.
dep_scale
)
,
bool
(
arg_0
.
indep_units
!=
arg_1
.
indep_units
)
,
(
bool
(
arg_0
.
dep_units
!=
arg_1
.
dep_units
)
if
arg_2
else
False
)
,
bool
(
arg_0
.
interp
!=
arg_1
.
interp
)
,
)
arg_3
(
any
(
arg_4
)
)

def Func(arg_0, arg_1, arg_2=True):
    """Verify that two waveforms can be combined with various mathematical functions."""
    arg_3 = pexdoc.exh.addex(RuntimeError, "Waveforms are not compatible")
    arg_4 = (
        bool(arg_0.indep_scale != arg_1.indep_scale),
        bool(arg_0.dep_scale != arg_1.dep_scale),
        bool(arg_0.indep_units != arg_1.indep_units),
        (bool(arg_0.dep_units != arg_1.dep_units) if arg_2 else False),
        bool(arg_0.interp != arg_1.interp),
    )
    arg_3(any(arg_4))

Verify that two waveforms can be combined with various mathematical functions .


def
Func
(
arg_0
)
:
if
arg_0
.
stanza_type
not
in
(
"set"
,
"get"
)
:
raise
ValueError
(
"Results may only be generated for"
" 'set' or 'get' iq"
)
arg_1
=
Iq
(
stanza_type
=
"result"
,
from_jid
=
arg_0
.
to_jid
,
to_jid
=
arg_0
.
from_jid
,
stanza_id
=
arg_0
.
stanza_id
)
return
arg_1

def Func(arg_0):
        """Create result response for the a "get" or "set" iq stanza.

        :return: new `Iq` object with the same "id" as self, "from" and "to"
            attributes replaced and type="result".
        :returntype: `Iq`"""

        if arg_0.stanza_type not in ("set", "get"):
            raise ValueError("Results may only be generated for"
                                                        " 'set' or 'get' iq")
        arg_1 = Iq(stanza_type = "result", from_jid = arg_0.to_jid,
                        to_jid = arg_0.from_jid, stanza_id = arg_0.stanza_id)
        return arg_1

Create result response for the a get or set iq stanza .


def Func ( arg_0 ) : arg_1 , arg_2 , arg_3 = arg_0 . rpartition ( '.' ) __import__ ( arg_1 ) arg_4 = sys . modules [ arg_1 ] return getattr ( arg_4 , arg_3 )

def Func(arg_0):
    """
    Load the keyring class indicated by name.

    These popular names are tested to ensure their presence.

    >>> popular_names = [
    ...      'keyring.backends.Windows.WinVaultKeyring',
    ...      'keyring.backends.OS_X.Keyring',
    ...      'keyring.backends.kwallet.DBusKeyring',
    ...      'keyring.backends.SecretService.Keyring',
    ...  ]
    >>> list(map(Func, popular_names))
    [...]

    These legacy names are retained for compatibility.

    >>> legacy_names = [
    ...  ]
    >>> list(map(Func, legacy_names))
    [...]
    """
    arg_1, arg_2, arg_3 = arg_0.rpartition('.')
    __import__(arg_1)
    arg_4 = sys.modules[arg_1]
    return getattr(arg_4, arg_3)

Load the keyring class indicated by name.

    These popular names are tested to ensure their presence.

    >>> popular_names = [
    ...      'keyring.backends.Windows.WinVaultKeyring',
    ...      'keyring.backends.OS_X.Keyring',
    ...      'keyring.backends.kwallet.DBusKeyring',
    ...      'keyring.backends.SecretService.Keyring',
    ...  ]
    >>> list(map(_load_keyring_class, popular_names))
    [...]

    These legacy names are retained for compatibility.

    >>> legacy_names = [
    ...  ]
    >>> list(map(_load_keyring_class, legacy_names))
    [...]

Load the keyring class indicated by name .


(states, filter_beyond_lag,
                                        filter_threshold)

def Func ( arg_0 , arg_1 , arg_2 ) : with tf . compat . v1 . name_scope ( 'effective_sample_size_single_state' , values = [ arg_0 , arg_1 , arg_2 ] ) : arg_0 = tf . convert_to_tensor ( value = arg_0 , name = 'states' ) arg_3 = arg_0 . dtype arg_4 = stats . auto_correlation ( arg_0 , axis = 0 , max_lags = arg_1 ) if arg_2 is not None : arg_2 = tf . convert_to_tensor ( value = arg_2 , dtype = arg_3 , name = 'filter_threshold' ) arg_5 = arg_4 < arg_2 arg_5 = tf . cast ( arg_5 , dtype = arg_3 ) arg_5 = tf . cumsum ( arg_5 , axis = 0 ) arg_5 = tf . maximum ( 1. - arg_5 , 0. ) arg_4 *= arg_5 arg_6 = _axis_size ( arg_0 , axis = 0 ) arg_7 = tf . range ( 0. , _axis_size ( arg_4 , axis = 0 ) ) arg_8 = ( arg_6 - arg_7 ) / arg_6 if arg_4 . shape . ndims is not None : arg_9 = [ - 1 ] + [ 1 ] * ( arg_4 . shape . ndims - 1 ) else : arg_9 = tf . concat ( ( [ - 1 ] , tf . ones ( [ tf . rank ( arg_4 ) - 1 ] , dtype = tf . int32 ) ) , axis = 0 ) arg_8 = tf . reshape ( arg_8 , arg_9 ) return arg_6 / ( - 1 + 2 * tf . reduce_sum ( input_tensor = arg_8 * arg_4 , axis = 0 ) )

def Func(arg_0, arg_1,
                                        arg_2):
  """ESS computation for one single Tensor argument."""

  with tf.compat.v1.name_scope(
      'effective_sample_size_single_state',
      values=[arg_0, arg_1, arg_2]):

    arg_0 = tf.convert_to_tensor(value=arg_0, name='states')
    arg_3 = arg_0.dtype

    # filter_beyond_lag == None ==> auto_corr is the full sequence.
    arg_4 = stats.auto_correlation(
        arg_0, axis=0, max_lags=arg_1)
    if arg_2 is not None:
      arg_2 = tf.convert_to_tensor(
          value=arg_2, dtype=arg_3, name='filter_threshold')
      # Get a binary mask to zero out values of auto_corr below the threshold.
      #   mask[i, ...] = 1 if auto_corr[j, ...] > threshold for all j <= i,
      #   mask[i, ...] = 0, otherwise.
      # So, along dimension zero, the mask will look like [1, 1, ..., 0, 0,...]
      # Building step by step,
      #   Assume auto_corr = [1, 0.5, 0.0, 0.3], and filter_threshold = 0.2.
      # Step 1:  mask = [False, False, True, False]
      arg_5 = arg_4 < arg_2
      # Step 2:  mask = [0, 0, 1, 1]
      arg_5 = tf.cast(arg_5, dtype=arg_3)
      # Step 3:  mask = [0, 0, 1, 2]
      arg_5 = tf.cumsum(arg_5, axis=0)
      # Step 4:  mask = [1, 1, 0, 0]
      arg_5 = tf.maximum(1. - arg_5, 0.)
      arg_4 *= arg_5

    # With R[k] := auto_corr[k, ...],
    # ESS = N / {1 + 2 * Sum_{k=1}^N (N - k) / N * R[k]}
    #     = N / {-1 + 2 * Sum_{k=0}^N (N - k) / N * R[k]} (since R[0] = 1)
    #     approx N / {-1 + 2 * Sum_{k=0}^M (N - k) / N * R[k]}
    # where M is the filter_beyond_lag truncation point chosen above.

    # Get the factor (N - k) / N, and give it shape [M, 1,...,1], having total
    # ndims the same as auto_corr
    arg_6 = _axis_size(arg_0, axis=0)
    arg_7 = tf.range(0., _axis_size(arg_4, axis=0))
    arg_8 = (arg_6 - arg_7) / arg_6
    if arg_4.shape.ndims is not None:
      arg_9 = [-1] + [1] * (arg_4.shape.ndims - 1)
    else:
      arg_9 = tf.concat(
          ([-1],
           tf.ones([tf.rank(arg_4) - 1], dtype=tf.int32)),
          axis=0)
    arg_8 = tf.reshape(arg_8, arg_9)

    return arg_6 / (-1 +
                2 * tf.reduce_sum(input_tensor=arg_8 * arg_4, axis=0))

ESS computation for one single Tensor argument .


(self, module_name: str, attr: str, fallback: str = None)

def Func(arg_0, arg_1: arg_2, arg_3: arg_2, arg_4: arg_2 = None):
        """Inserts Interpreter Library of imports into sketch in a very non-consensual way"""

        # Import the module Named in the string
        try:
            arg_5 = importlib.import_module(arg_1)

        # If module is not found it checks if an alternative is is listed
        # If it is then it substitutes it, just so that the code can run
        except ImportError:
            if arg_4 is not None:
                arg_5 = importlib.import_module(arg_4)
                arg_0.__logger.warn(arg_1 + " not available: Replaced with " + arg_4)
            else:
                arg_0.__logger.warn(arg_1 + " not available: No Replacement Specified")

        # Cram the module into the __sketch in the form of module -> "attr"
        # AKA the same as `import module as attr`
        if not arg_3 in dir(arg_0.__sketch):
            setattr(arg_0.__sketch, arg_3, arg_5)
        else:
            arg_0.__logger.warn(arg_3 +" could not be imported as it's label is already used in the sketch")

Inserts Interpreter Library of imports into sketch in a very non - consensual way


def Func ( arg_0 , arg_1 ) : def gen_lambdas ( ) : def gen ( ) : yield arg_1 + "\n" arg_2 = gen ( ) arg_3 = 0 arg_4 = [ ] for arg_5 in tokenize . generate_tokens ( getattr ( arg_2 , "next" , getattr ( arg_2 , "__next__" , None ) ) ) : if arg_3 == 0 : if arg_5 [ 0 ] == tokenize . NAME and arg_5 [ 1 ] == "lambda" : arg_3 = 1 arg_4 = [ arg_5 ] arg_6 = 0 elif arg_3 == 1 : if arg_5 [ 0 ] == tokenize . NAME : arg_4 . append ( arg_5 ) arg_3 = 2 else : arg_3 = 0 elif arg_3 == 2 : if arg_5 [ 0 ] == tokenize . OP and arg_5 [ 1 ] == ":" : arg_4 . append ( arg_5 ) arg_3 = 3 else : arg_3 = 0 elif arg_3 == 3 : if arg_6 == 0 and ( arg_5 [ 0 ] == tokenize . OP and arg_5 [ 1 ] in ",)" or arg_5 [ 0 ] == tokenize . ENDMARKER ) : yield tokenize . untokenize ( arg_4 ) . strip ( ) arg_3 = 0 else : arg_4 . append ( arg_5 ) if arg_5 [ 0 ] == tokenize . OP : if arg_5 [ 1 ] in "[({" : arg_6 += 1 if arg_5 [ 1 ] in "])}" : arg_6 -= 1 assert not arg_4 arg_7 = arg_0 . __code__ . co_code for arg_8 in gen_lambdas ( ) : try : arg_9 = eval ( arg_8 , globals ( ) , locals ( ) ) if arg_9 . __code__ . co_code == arg_7 : return arg_8 . split ( ":" , 1 ) [ 1 ] . strip ( ) except Exception : pass return "<lambda>"

def Func(arg_0, arg_1):
    """Attempt to find the source code of the ``lambda_fn`` within the string ``src``."""
    def gen_lambdas():
        def gen():
            yield arg_1 + "\n"

        arg_2 = gen()
        arg_3 = 0
        arg_4 = []
        for arg_5 in tokenize.generate_tokens(getattr(arg_2, "next", getattr(arg_2, "__next__", None))):
            if arg_3 == 0:
                if arg_5[0] == tokenize.NAME and arg_5[1] == "lambda":
                    arg_3 = 1
                    arg_4 = [arg_5]
                    arg_6 = 0
            elif arg_3 == 1:
                if arg_5[0] == tokenize.NAME:
                    arg_4.append(arg_5)
                    arg_3 = 2
                else:
                    arg_3 = 0
            elif arg_3 == 2:
                if arg_5[0] == tokenize.OP and arg_5[1] == ":":
                    arg_4.append(arg_5)
                    arg_3 = 3
                else:
                    arg_3 = 0
            elif arg_3 == 3:
                if arg_6 == 0 and (arg_5[0] == tokenize.OP and arg_5[1] in ",)" or arg_5[0] == tokenize.ENDMARKER):
                    yield tokenize.untokenize(arg_4).strip()
                    arg_3 = 0
                else:
                    arg_4.append(arg_5)
                    if arg_5[0] == tokenize.OP:
                        if arg_5[1] in "[({": arg_6 += 1
                        if arg_5[1] in "])}": arg_6 -= 1
        assert not arg_4

    arg_7 = arg_0.__code__.co_code
    for arg_8 in gen_lambdas():
        try:
            arg_9 = eval(arg_8, globals(), locals())
            if arg_9.__code__.co_code == arg_7:
                return arg_8.split(":", 1)[1].strip()
        except Exception:
            pass
    return "<lambda>"

Attempt to find the source code of the lambda_fn within the string src .


def Func ( arg_0 , * arg_1 ) : with context . ExceptionTrap ( ) : with context . ExceptionTrap ( * arg_1 ) as exc : arg_0 ( ) return bool ( exc )

def Func(arg_0, *arg_1):
	"""
	Return True if the callable throws the specified exception

	>>> Func(lambda: int('3'))
	False
	>>> Func(lambda: int('a'))
	True
	>>> Func(lambda: int('a'), KeyError)
	False
	"""
	with context.ExceptionTrap():
		with context.ExceptionTrap(*arg_1) as exc:
			arg_0()
	return bool(exc)

Return True if the callable throws the specified exception

	>>> throws_exception(lambda: int('3'))
	False
	>>> throws_exception(lambda: int('a'))
	True
	>>> throws_exception(lambda: int('a'), KeyError)
	False


def Func(arg_0, arg_1, arg_2="template"):

    '''create an input file using jinja2 by filling a template
    with the values from the option variable passed in.'''

    # restructure option list into jinja2 input format
    arg_3 = {}
    for arg_4 in arg_0:
        try:
            arg_3.update(arg_4)
        except ValueError:
            raise RuntimeError(
                ("inputs.py, Func : format of item '{0}' is not "
                 "supported. Expecting a dictionary.".format(str(arg_4))))

    # load the template and fill it with the option variable contents
    import jinja2
    try:
        arg_5 = jinja2.FileSystemLoader(searchpath=arg_2)
        arg_6 = jinja2.Environment(loader=arg_5)
        arg_7 = arg_6.get_template(arg_1)
        arg_8 = arg_7.render(arg_3)
    except jinja2.TemplateNotFound:
        raise RuntimeError("template '{0}' not found".format(arg_1))
    # return the particular input file as a string
    return arg_8

create an input file using jinja2 by filling a template with the values from the option variable passed in .


def Func ( arg_0 ) : if not arg_0 . _conn : arg_0 . _conn = storage . Client ( credentials = arg_0 . _get_credentials ( ) ) return arg_0 . _conn

def Func(arg_0):
        """
        Returns a Google Cloud Storage service object.
        """
        if not arg_0._conn:
            arg_0._conn = storage.Client(credentials=arg_0._get_credentials())

        return arg_0._conn

Returns a Google Cloud Storage service object .


def
Func
(
)
:
arg_0
=
requests
.
get
(
VACATIONS_URL
,
headers
=
HEADERS
)
arg_1
=
str
(
arg_0
.
status_code
)
if
arg_1
==
'401'
:
_LOGGER
.
error
(
"Token expired."
)
return
False
return
arg_0
.
json
(
)

def Func():
        """
        Pull the accounts vacations.
        """
        arg_0 = requests.get(VACATIONS_URL, headers=HEADERS)
        arg_1 = str(arg_0.status_code)
        if arg_1 == '401':
            _LOGGER.error("Token expired.")
            return False
        return arg_0.json()


return self._perform_action(
            {'type': 'change_kernel', 'kernel': kernel.id},
            return_dict
        )

def
Func
(
arg_0
,
arg_1
,
arg_2
=
True
)
:
if
type
(
arg_1
)
!=
Kernel
:
raise
BadKernelObject
(
"Use Kernel object"
)
return
arg_0
.
_perform_action
(
{
'type'
:
'Func'
,
'kernel'
:
arg_1
.
id
}
,
arg_2
)

def Func(arg_0, arg_1, arg_2=True):
        """Change the kernel to a new one

        Args:
            kernel : instance of digitalocean.Kernel.Kernel

        Optional Args:
            return_dict (bool): Return a dict when True (default),
                otherwise return an Action.

        Returns dict or Action
        """
        if type(arg_1) != Kernel:
            raise BadKernelObject("Use Kernel object")

        return arg_0._perform_action(
            {'type': 'Func', 'kernel': arg_1.id},
            arg_2
        )


(self, institute, case, collaborator_id, user, link)

def Func(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5):
        """Share a case with a new institute.

        Arguments:
            institute (dict): A Institute object
            case (dict): Case object
            collaborator_id (str): A instute id
            user (dict): A User object
            link (str): The url to be used in the event

        Return:
            updated_case
        """
        if arg_3 in arg_2.get('collaborators', []):
            raise ValueError('new customer is already a collaborator')

        arg_0.create_event(
            arg_1=arg_1,
            arg_2=arg_2,
            arg_4=arg_4,
            arg_5=arg_5,
            category='case',
            verb='Func',
            subject=arg_3
        )

        arg_6 = arg_0.case_collection.find_one_and_update(
            {'_id': arg_2['_id']},
            {
                '$push': {'collaborators': arg_3}
            },
            return_document=pymongo.ReturnDocument.AFTER
        )
        LOG.debug("Case updated")
        return arg_6


If all of the constraints are satisfied with the given value, defers
        to the composed AMP argument's ``toString`` method.

def Func ( arg_0 , arg_1 ) : arg_0 . _checkConstraints ( arg_1 ) return arg_0 . baseArgument . Func ( arg_1 )

def Func(arg_0, arg_1):
        """
        If all of the constraints are satisfied with the given value, defers
        to the composed AMP argument's ``Func`` method.
        """
        arg_0._checkConstraints(arg_1)
        return arg_0.baseArgument.Func(arg_1)

If all of the constraints are satisfied with the given value defers to the composed AMP argument s toString method .


def Func ( ) : with open ( os . path . join ( REPO_DIR , "VERSION" ) , "r" ) as versionFile : return versionFile . read ( ) . strip ( )

def Func():
  """
  Get version from local file.
  """
  with open(os.path.join(REPO_DIR, "VERSION"), "r") as versionFile:
    return versionFile.read().strip()


def Func ( arg_0 , arg_1 , arg_2 , arg_3 ) : with open ( os . path . join ( arg_0 . datadir , arg_3 ) , 'wb' ) as new_file : with open ( os . path . join ( arg_0 . datadir , arg_1 ) , 'rb' ) as file_1 : new_file . write ( file_1 . read ( ) ) with open ( os . path . join ( arg_0 . datadir , arg_2 ) , 'rb' ) as file_2 : new_file . write ( file_2 . read ( ) )

def Func(arg_0, arg_1, arg_2, arg_3):
        """
            Combines the files 1 and 2 into 3.
        """
        with open(os.path.join(arg_0.datadir, arg_3), 'wb') as new_file:
            with open(os.path.join(arg_0.datadir, arg_1), 'rb') as file_1:
                new_file.write(file_1.read())
            with open(os.path.join(arg_0.datadir, arg_2), 'rb') as file_2:
                new_file.write(file_2.read())


return tf.concat([tf.reshape(grad, [U.numel(v)])
                      for (v, grad) in zip(var_list, grads)], 0)

def Func ( arg_0 , arg_1 ) : return tf . concat ( [ tf . reshape ( arg_3 , [ U . numel ( arg_2 ) ] ) for ( arg_2 , arg_3 ) in zip ( arg_0 , arg_1 ) ] , 0 )

def Func(arg_0, arg_1):
    """Flattens a variables and their gradients.
    """
    return tf.concat([tf.reshape(arg_3, [U.numel(arg_2)])
                      for (arg_2, arg_3) in zip(arg_0, arg_1)], 0)

Flattens a variables and their gradients .


def
Func
(
arg_0
,
arg_1
)
:
if
arg_0
.
status
==
"disconnected"
:
return
logging
.
debug
(
"ConnectorDB:WS: Websocket closed"
)
if
arg_0
.
pingtimer
is
not
:
arg_0
.
pingtimer
.
cancel
(
)
arg_0
.
disconnected_time
=
time
.
time
(
)
if
arg_0
.
status
==
"disconnecting"
:
arg_0
.
status
=
"disconnected"
elif
arg_0
.
status
==
"connected"
:
arg_0
.
__reconnect
(
)

def Func(arg_0, arg_1):
        """Called when the websocket is closed"""
        if arg_0.status == "disconnected":
            return  # This can be double-called on disconnect
        logging.debug("ConnectorDB:WS: Websocket closed")

        # Turn off the ping timer
        if arg_0.pingtimer is not None:
            arg_0.pingtimer.cancel()

        arg_0.disconnected_time = time.time()
        if arg_0.status == "disconnecting":
            arg_0.status = "disconnected"
        elif arg_0.status == "connected":
            arg_0.__reconnect()


def Func ( arg_0 , arg_1 , arg_2 , arg_3 ) : arg_4 = arg_1 . get ( 'task' , replacements = { 'slug' : arg_2 , 'identifier' : arg_3 } ) return arg_0 ( ** arg_4 )

def Func(arg_0, arg_1, arg_2, arg_3):
        """Retrieve a task from the server"""
        arg_4 = arg_1.get(
            'task',
            replacements={
                'slug': arg_2,
                'identifier': arg_3})
        return arg_0(**arg_4)


def Func(arg_0):
    '''Retrieve S3 access key settings from s3cmd's config file, if present; otherwise return None.'''
    try:
      if arg_0.s3cfg != None:
        arg_1 = "%s" % arg_0.s3cfg
      else:
        arg_1 = "%s/.s3cfg" % os.environ["HOME"]
      if not os.path.exists(arg_1):
        return None
      arg_2 = ConfigParser.ConfigParser()
      arg_2.read(arg_1)
      arg_3 = arg_2.get("default", "access_key"), arg_2.get("default", "secret_key")
      debug("read S3 keys from %s file", arg_1)
      return arg_3
    except Exception as e:
      info("could not read S3 keys from %s file; skipping (%s)", arg_1, e)
      return None

Retrieve S3 access key settings from s3cmd s config file if present ; otherwise return None .


def
Func
(
arg_0
)
:
arg_0
.
add_tag
(
'header_scan'
)
arg_1
=
False
try
:
arg_2
=
requests
.
head
(
'http://{}:{}'
.
format
(
arg_0
.
address
,
arg_0
.
port
)
,
timeout
=
1
)
print_success
(
"Found http service on {}:{}"
.
format
(
arg_0
.
address
,
arg_0
.
port
)
)
arg_0
.
add_tag
(
'http'
)
arg_1
=
True
try
:
arg_0
.
banner
=
arg_2
.
headers
[
'Server'
]
except
KeyError
:
pass
except
(
ConnectionError
,
ConnectTimeout
,
ReadTimeout
,
Error
)
:
pass
if
not
arg_1
:
try
:
arg_2
=
requests
.
head
(
'https://{}:{}'
.
format
(
arg_0
.
address
,
arg_0
.
port
)
,
verify
=
False
,
timeout
=
3
)
arg_0
.
add_tag
(
'https'
)
print_success
(
"Found https service on {}:{}"
.
format
(
arg_0
.
address
,
arg_0
.
port
)
)
try
:
arg_0
.
banner
=
arg_2
.
headers
[
'Server'
]
except
KeyError
:
pass
except
(
ConnectionError
,
ConnectTimeout
,
ReadTimeout
,
Error
)
:
pass
arg_0
.
save
(
)

def Func(arg_0):
    """
        Connect to a service to see if it is a http or https server.
    """
    # Try HTTP
    arg_0.add_tag('header_scan')
    arg_1 = False
    try:
        arg_2 = requests.head('http://{}:{}'.format(arg_0.address, arg_0.port), timeout=1)
        print_success("Found http service on {}:{}".format(arg_0.address, arg_0.port))
        arg_0.add_tag('http')
        arg_1 = True
        try:
            arg_0.banner = arg_2.headers['Server']
        except KeyError:
            pass
    except (ConnectionError, ConnectTimeout, ReadTimeout, Error):
        pass

    if not arg_1:
        # Try HTTPS
        try:
            arg_2 = requests.head('https://{}:{}'.format(arg_0.address, arg_0.port), verify=False, timeout=3)
            arg_0.add_tag('https')
            print_success("Found https service on {}:{}".format(arg_0.address, arg_0.port))
            try:
                arg_0.banner = arg_2.headers['Server']
            except KeyError:
                pass
        except (ConnectionError, ConnectTimeout, ReadTimeout, Error):
            pass
    arg_0.save()

Connect to a service to see if it is a http or https server .


def Func ( arg_0 ) : arg_0 . tree . root . branch_length = 0.001 arg_0 . tree . root . mutation_length = arg_0 . tree . root . branch_length arg_0 . tree . root . mutations = [ ] arg_0 . tree . ladderize ( ) arg_0 . _prepare_nodes ( ) arg_0 . _leaves_lookup = { node . name : node for node in arg_0 . tree . get_terminals ( ) }

def Func(arg_0):
        """
        Set link to parent and calculate distance to root for all tree nodes.
        Should be run once the tree is read and after every rerooting,
        topology change or branch length optimizations.
        """
        arg_0.tree.root.branch_length = 0.001
        arg_0.tree.root.mutation_length = arg_0.tree.root.branch_length
        arg_0.tree.root.mutations = []
        arg_0.tree.ladderize()
        arg_0._prepare_nodes()
        arg_0._leaves_lookup = {node.name:node for node in arg_0.tree.get_terminals()}

Set link to parent and calculate distance to root for all tree nodes . Should be run once the tree is read and after every rerooting topology change or branch length optimizations .


def
Func
(
arg_0
,
arg_1
=
'train'
)
:
arg_2
=
21
arg_3
=
int
(
(
arg_2
1
)
/
2
)
arg_4
=
[
{
'char'
:
' '
,
'type'
:
'p'
,
'target'
:
True
}
]
arg_5
=
pd
.
DataFrame
(
arg_4
*
arg_3
)
arg_6
=
[
]
for
arg_7
in
article_types
:
arg_6
.
append
(
pd
.
read_csv
(
os
.
path
.
join
(
arg_0
,
arg_1
,
'df_best_{}_{}.csv'
.
format
(
arg_7
,
arg_1
)
)
)
)
arg_6
=
pd
.
concat
(
arg_6
)
arg_6
=
pd
.
concat
(
(
arg_5
,
arg_6
,
arg_5
)
)
arg_6
[
'char'
]
=
arg_6
[
'char'
]
.
map
(
lambda
x
:
CHARS_MAP
.
get
(
x
,
80
)
)
arg_6
[
'type'
]
=
arg_6
[
'type'
]
.
map
(
lambda
x
:
CHAR_TYPES_MAP
.
get
(
x
,
4
)
)
arg_5
=
create_n_gram_df
(
arg_6
,
arg_2
=
arg_2
)
arg_8
=
[
'char'
+
str
(
i
+
1
)
for
i
in
range
(
arg_3
)
]
+
[
'char-'
+
str
(
i
+
1
)
for
i
in
range
(
arg_3
)
]
+
[
'char'
]
arg_9
=
[
'type'
+
str
(
i
+
1
)
for
i
in
range
(
arg_3
)
]
+
[
'type-'
+
str
(
i
+
1
)
for
i
in
range
(
arg_3
)
]
+
[
'type'
]
arg_10
=
arg_5
[
arg_8
]
.
as_matrix
(
)
arg_11
=
arg_5
[
arg_9
]
.
as_matrix
(
)
arg_12
=
arg_5
[
'target'
]
.
astype
(
int
)
.
as_matrix
(
)
return
arg_10
,
arg_11
,
arg_12

def Func(arg_0, arg_1='train'):
    """
    Transform processed path into feature matrix and output array

    Input
    =====
    best_processed_path: str, path to processed BEST dataset

    option: str, 'train' or 'test'
    """
    # padding for training and testing set
    arg_2 = 21
    arg_3 = int((arg_2 - 1)/2)
    arg_4 = [{'char': ' ', 'type': 'p', 'target': True}]
    arg_5 = pd.DataFrame(arg_4 * arg_3)

    arg_6 = []
    for arg_7 in article_types:
        arg_6.append(pd.read_csv(os.path.join(arg_0, arg_1, 'df_best_{}_{}.csv'.format(arg_7, arg_1))))
    arg_6 = pd.concat(arg_6)
    arg_6 = pd.concat((arg_5, arg_6, arg_5)) # pad with empty string feature

    arg_6['char'] = arg_6['char'].map(lambda x: CHARS_MAP.get(x, 80))
    arg_6['type'] = arg_6['type'].map(lambda x: CHAR_TYPES_MAP.get(x, 4))
    arg_5 = create_n_gram_df(arg_6, arg_2=arg_2)

    arg_8 = ['char' + str(i + 1) for i in range(arg_3)] + \
               ['char-' + str(i + 1) for i in range(arg_3)] + ['char']
    arg_9 = ['type' + str(i + 1) for i in range(arg_3)] + \
               ['type-' + str(i + 1) for i in range(arg_3)] + ['type']

    arg_10 = arg_5[arg_8].as_matrix()
    arg_11 = arg_5[arg_9].as_matrix()
    arg_12 = arg_5['target'].astype(int).as_matrix()

    return arg_10, arg_11, arg_12


(self, x, y=None, batch_size=32, nb_epoch=10, validation_data=None, distributed=True)

def
Func
(
arg_0
,
arg_1
,
arg_2
=
,
arg_3
=
32
,
arg_4
=
10
,
arg_5
=
,
arg_6
=
True
)
:
if
arg_6
:
if
isinstance
(
arg_1
,
np
.
ndarray
)
and
isinstance
(
arg_2
,
np
.
ndarray
)
:
arg_7
=
to_sample_rdd
(
arg_1
,
arg_2
)
if
arg_5
:
arg_5
=
to_sample_rdd
(
*
arg_5
)
elif
(
isinstance
(
arg_1
,
RDD
)
or
isinstance
(
arg_1
,
DataSet
)
)
and
not
arg_2
:
arg_7
=
arg_1
else
:
raise
TypeError
(
"Unsupported training data type: %s"
%
type
(
arg_1
)
)
callBigDlFunc
(
arg_0
.
bigdl_type
,
"Func"
,
arg_0
.
value
,
arg_7
,
arg_3
,
arg_4
,
arg_5
)
else
:
if
arg_5
:
arg_8
=
[
JTensor
.
from_ndarray
(
arg_1
)
for
arg_1
in
to_list
(
arg_5
[
0
]
)
]
arg_9
=
JTensor
.
from_ndarray
(
arg_5
[
1
]
)
else
:
arg_8
,
arg_9
=
,
callBigDlFunc
(
arg_0
.
bigdl_type
,
"Func"
,
arg_0
.
value
,
[
JTensor
.
from_ndarray
(
arg_1
)
for
arg_1
in
to_list
(
arg_1
)
]
,
JTensor
.
from_ndarray
(
arg_2
)
,
arg_3
,
arg_4
,
arg_8
,
arg_9
,
multiprocessing
.
cpu_count
(
)
)

def Func(arg_0, arg_1, arg_2=None, arg_3=32, arg_4=10, arg_5=None, arg_6=True):
        """
        Train a model for a fixed number of epochs on a dataset.

        # Arguments
        x: Input data. A Numpy array or RDD of Sample or Image DataSet.
        y: Labels. A Numpy array. Default is None if x is already RDD of Sample or Image DataSet.
        batch_size: Number of samples per gradient update.
        nb_epoch: Number of iterations to train.
        validation_data: Tuple (x_val, y_val) where x_val and y_val are both Numpy arrays.
                         Or RDD of Sample. Default is None if no validation is involved.
        distributed: Boolean. Whether to train the model in distributed mode or local mode.
                     Default is True. In local mode, x and y must both be Numpy arrays.
        """
        if arg_6:
            if isinstance(arg_1, np.ndarray) and isinstance(arg_2, np.ndarray):
                arg_7 = to_sample_rdd(arg_1, arg_2)
                if arg_5:
                    arg_5 = to_sample_rdd(*arg_5)
            elif (isinstance(arg_1, RDD) or isinstance(arg_1, DataSet)) and not arg_2:
                arg_7 = arg_1
            else:
                raise TypeError("Unsupported training data type: %s" % type(arg_1))
            callBigDlFunc(arg_0.bigdl_type, "Func",
                          arg_0.value,
                          arg_7,
                          arg_3,
                          arg_4,
                          arg_5)
        else:
            if arg_5:
                arg_8 = [JTensor.from_ndarray(arg_1) for arg_1 in to_list(arg_5[0])]
                arg_9 = JTensor.from_ndarray(arg_5[1])
            else:
                arg_8, arg_9 = None, None
            callBigDlFunc(arg_0.bigdl_type, "Func",
                          arg_0.value,
                          [JTensor.from_ndarray(arg_1) for arg_1 in to_list(arg_1)],
                          JTensor.from_ndarray(arg_2),
                          arg_3,
                          arg_4,
                          arg_8,
                          arg_9,
                          multiprocessing.cpu_count())

Train a model for a fixed number of epochs on a dataset .