repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
threeML/astromodels
astromodels/functions/functions_2D.py
Latitude_galactic_diffuse.get_total_spatial_integral
def get_total_spatial_integral(self, z=None): """ Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z). """ ...
python
def get_total_spatial_integral(self, z=None): """ Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z). """ ...
Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z).
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/functions_2D.py#L99-L115
threeML/astromodels
astromodels/core/tree.py
OldNode._get_child_from_path
def _get_child_from_path(self, path): """ Return a children below this level, starting from a path of the kind "this_level.something.something.name" :param path: the key :return: the child """ keys = path.split(".") this_child = self for key in keys: ...
python
def _get_child_from_path(self, path): """ Return a children below this level, starting from a path of the kind "this_level.something.something.name" :param path: the key :return: the child """ keys = path.split(".") this_child = self for key in keys: ...
Return a children below this level, starting from a path of the kind "this_level.something.something.name" :param path: the key :return: the child
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/tree.py#L210-L232
threeML/astromodels
astromodels/core/tree.py
OldNode._find_instances
def _find_instances(self, cls): """ Find all the instances of cls below this node. :return: a dictionary of instances of cls """ instances = collections.OrderedDict() for child_name, child in self._children.iteritems(): if isinstance(child, cls): ...
python
def _find_instances(self, cls): """ Find all the instances of cls below this node. :return: a dictionary of instances of cls """ instances = collections.OrderedDict() for child_name, child in self._children.iteritems(): if isinstance(child, cls): ...
Find all the instances of cls below this node. :return: a dictionary of instances of cls
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/tree.py#L299-L329
threeML/astromodels
astromodels/core/model_parser.py
clone_model
def clone_model(model_instance): """ Returns a copy of the given model with all objects cloned. This is equivalent to saving the model to a file and reload it, but it doesn't require writing or reading to/from disk. The original model is not touched. :param model: model to be cloned :return: a clon...
python
def clone_model(model_instance): """ Returns a copy of the given model with all objects cloned. This is equivalent to saving the model to a file and reload it, but it doesn't require writing or reading to/from disk. The original model is not touched. :param model: model to be cloned :return: a clon...
Returns a copy of the given model with all objects cloned. This is equivalent to saving the model to a file and reload it, but it doesn't require writing or reading to/from disk. The original model is not touched. :param model: model to be cloned :return: a cloned copy of the given model
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model_parser.py#L40-L53
threeML/astromodels
setup.py
sanitize_lib_name
def sanitize_lib_name(library_path): """ Get a fully-qualified library name, like /usr/lib/libgfortran.so.3.0, and returns the lib name needed to be passed to the linker in the -l option (for example gfortran) :param library_path: :return: """ lib_name = os.path.basename(library_path) ...
python
def sanitize_lib_name(library_path): """ Get a fully-qualified library name, like /usr/lib/libgfortran.so.3.0, and returns the lib name needed to be passed to the linker in the -l option (for example gfortran) :param library_path: :return: """ lib_name = os.path.basename(library_path) ...
Get a fully-qualified library name, like /usr/lib/libgfortran.so.3.0, and returns the lib name needed to be passed to the linker in the -l option (for example gfortran) :param library_path: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/setup.py#L32-L51
threeML/astromodels
setup.py
find_library
def find_library(library_root, additional_places=None): """ Returns the name of the library without extension :param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so :return: the name of the library found (NOTE: this is *not* the path), and a director...
python
def find_library(library_root, additional_places=None): """ Returns the name of the library without extension :param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so :return: the name of the library found (NOTE: this is *not* the path), and a director...
Returns the name of the library without extension :param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so :return: the name of the library found (NOTE: this is *not* the path), and a directory path if the library is not in the system paths (and None other...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/setup.py#L54-L172
threeML/astromodels
astromodels/utils/table.py
dict_to_table
def dict_to_table(dictionary, list_of_keys=None): """ Return a table representing the dictionary. :param dictionary: the dictionary to represent :param list_of_keys: optionally, only the keys in this list will be inserted in the table :return: a Table instance """ # assert len(dictionary.v...
python
def dict_to_table(dictionary, list_of_keys=None): """ Return a table representing the dictionary. :param dictionary: the dictionary to represent :param list_of_keys: optionally, only the keys in this list will be inserted in the table :return: a Table instance """ # assert len(dictionary.v...
Return a table representing the dictionary. :param dictionary: the dictionary to represent :param list_of_keys: optionally, only the keys in this list will be inserted in the table :return: a Table instance
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/table.py#L6-L49
threeML/astromodels
astromodels/utils/table.py
Table._base_repr_
def _base_repr_(self, html=False, show_name=True, **kwargs): """ Override the method in the astropy.Table class to avoid displaying the description, and the format of the columns """ table_id = 'table{id}'.format(id=id(self)) data_lines, outs = self.formatter._p...
python
def _base_repr_(self, html=False, show_name=True, **kwargs): """ Override the method in the astropy.Table class to avoid displaying the description, and the format of the columns """ table_id = 'table{id}'.format(id=id(self)) data_lines, outs = self.formatter._p...
Override the method in the astropy.Table class to avoid displaying the description, and the format of the columns
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/table.py#L60-L78
eamigo86/graphene-django-extras
graphene_django_extras/views.py
ExtraGraphQLView.fetch_cache_key
def fetch_cache_key(request): """ Returns a hashed cache key. """ m = hashlib.md5() m.update(request.body) return m.hexdigest()
python
def fetch_cache_key(request): """ Returns a hashed cache key. """ m = hashlib.md5() m.update(request.body) return m.hexdigest()
Returns a hashed cache key.
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/views.py#L42-L47
eamigo86/graphene-django-extras
graphene_django_extras/views.py
ExtraGraphQLView.dispatch
def dispatch(self, request, *args, **kwargs): """ Fetches queried data from graphql and returns cached & hashed key. """ if not graphql_api_settings.CACHE_ACTIVE: return self.super_call(request, *args, **kwargs) cache = caches["default"] operation_ast = self.get_operation_as...
python
def dispatch(self, request, *args, **kwargs): """ Fetches queried data from graphql and returns cached & hashed key. """ if not graphql_api_settings.CACHE_ACTIVE: return self.super_call(request, *args, **kwargs) cache = caches["default"] operation_ast = self.get_operation_as...
Fetches queried data from graphql and returns cached & hashed key.
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/views.py#L54-L74
eamigo86/graphene-django-extras
graphene_django_extras/directives/date.py
_parse
def _parse(partial_dt): """ parse a partial datetime object to a complete datetime object """ dt = None try: if isinstance(partial_dt, datetime): dt = partial_dt if isinstance(partial_dt, date): dt = _combine_date_time(partial_dt, time(0, 0, 0)) if isi...
python
def _parse(partial_dt): """ parse a partial datetime object to a complete datetime object """ dt = None try: if isinstance(partial_dt, datetime): dt = partial_dt if isinstance(partial_dt, date): dt = _combine_date_time(partial_dt, time(0, 0, 0)) if isi...
parse a partial datetime object to a complete datetime object
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/directives/date.py#L73-L94
eamigo86/graphene-django-extras
graphene_django_extras/utils.py
get_obj
def get_obj(app_label, model_name, object_id): """ Function used to get a object :param app_label: A valid Django Model or a string with format: <app_label>.<model_name> :param model_name: Key into kwargs that contains de data: new_person :param object_id: :return: instance """ try: ...
python
def get_obj(app_label, model_name, object_id): """ Function used to get a object :param app_label: A valid Django Model or a string with format: <app_label>.<model_name> :param model_name: Key into kwargs that contains de data: new_person :param object_id: :return: instance """ try: ...
Function used to get a object :param app_label: A valid Django Model or a string with format: <app_label>.<model_name> :param model_name: Key into kwargs that contains de data: new_person :param object_id: :return: instance
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L104-L130
eamigo86/graphene-django-extras
graphene_django_extras/utils.py
create_obj
def create_obj(django_model, new_obj_key=None, *args, **kwargs): """ Function used by my on traditional Mutations to create objs :param django_model: A valid Django Model or a string with format: <app_label>.<model_name> :param new_obj_key: Key into kwargs that contains de data: new_person :para...
python
def create_obj(django_model, new_obj_key=None, *args, **kwargs): """ Function used by my on traditional Mutations to create objs :param django_model: A valid Django Model or a string with format: <app_label>.<model_name> :param new_obj_key: Key into kwargs that contains de data: new_person :para...
Function used by my on traditional Mutations to create objs :param django_model: A valid Django Model or a string with format: <app_label>.<model_name> :param new_obj_key: Key into kwargs that contains de data: new_person :param args: :param kwargs: Dict with model attributes values :return: ins...
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L133-L165
eamigo86/graphene-django-extras
graphene_django_extras/utils.py
clean_dict
def clean_dict(d): """ Remove all empty fields in a nested dict """ if not isinstance(d, (dict, list)): return d if isinstance(d, list): return [v for v in (clean_dict(v) for v in d) if v] return OrderedDict( [(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d...
python
def clean_dict(d): """ Remove all empty fields in a nested dict """ if not isinstance(d, (dict, list)): return d if isinstance(d, list): return [v for v in (clean_dict(v) for v in d) if v] return OrderedDict( [(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d...
Remove all empty fields in a nested dict
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L168-L179
eamigo86/graphene-django-extras
graphene_django_extras/utils.py
_get_queryset
def _get_queryset(klass): """ Returns a QuerySet from a Model, Manager, or QuerySet. Created to make get_object_or_404 and get_list_or_404 more DRY. Raises a ValueError if klass is not a Model, Manager, or QuerySet. """ if isinstance(klass, QuerySet): return klass elif isinstance(kl...
python
def _get_queryset(klass): """ Returns a QuerySet from a Model, Manager, or QuerySet. Created to make get_object_or_404 and get_list_or_404 more DRY. Raises a ValueError if klass is not a Model, Manager, or QuerySet. """ if isinstance(klass, QuerySet): return klass elif isinstance(kl...
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make get_object_or_404 and get_list_or_404 more DRY. Raises a ValueError if klass is not a Model, Manager, or QuerySet.
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L224-L246
eamigo86/graphene-django-extras
graphene_django_extras/utils.py
get_Object_or_None
def get_Object_or_None(klass, *args, **kwargs): """ Uses get() to return an object, or None if the object does not exist. klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query. Note: Like with get(), an MultipleObjectsReturn...
python
def get_Object_or_None(klass, *args, **kwargs): """ Uses get() to return an object, or None if the object does not exist. klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query. Note: Like with get(), an MultipleObjectsReturn...
Uses get() to return an object, or None if the object does not exist. klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query. Note: Like with get(), an MultipleObjectsReturned will be raised if more than one object is found. ...
https://github.com/eamigo86/graphene-django-extras/blob/b27fd6b5128f6b6a500a8b7a497d76be72d6a232/graphene_django_extras/utils.py#L249-L267
Proteus-tech/tormor
tormor/schema.py
find_schema_paths
def find_schema_paths(schema_files_path=DEFAULT_SCHEMA_FILES_PATH): """Searches the locations in the `SCHEMA_FILES_PATH` to try to find where the schema SQL files are located. """ paths = [] for path in schema_files_path: if os.path.isdir(path): paths.append(path) if paths: ...
python
def find_schema_paths(schema_files_path=DEFAULT_SCHEMA_FILES_PATH): """Searches the locations in the `SCHEMA_FILES_PATH` to try to find where the schema SQL files are located. """ paths = [] for path in schema_files_path: if os.path.isdir(path): paths.append(path) if paths: ...
Searches the locations in the `SCHEMA_FILES_PATH` to try to find where the schema SQL files are located.
https://github.com/Proteus-tech/tormor/blob/3083b0cd2b9a4d21b20dfd5c27678b23660548d7/tormor/schema.py#L41-L51
Proteus-tech/tormor
tormor/connection.py
Connection.execute
def execute(self, cmd, *args, **kwargs): """ Execute the SQL command and return the data rows as tuples """ self.cursor.execute(cmd, *args, **kwargs)
python
def execute(self, cmd, *args, **kwargs): """ Execute the SQL command and return the data rows as tuples """ self.cursor.execute(cmd, *args, **kwargs)
Execute the SQL command and return the data rows as tuples
https://github.com/Proteus-tech/tormor/blob/3083b0cd2b9a4d21b20dfd5c27678b23660548d7/tormor/connection.py#L66-L69
Proteus-tech/tormor
tormor/connection.py
Connection.select
def select(self, cmd, *args, **kwargs): """ Execute the SQL command and return the data rows as tuples """ self.cursor.execute(cmd, *args, **kwargs) return self.cursor.fetchall()
python
def select(self, cmd, *args, **kwargs): """ Execute the SQL command and return the data rows as tuples """ self.cursor.execute(cmd, *args, **kwargs) return self.cursor.fetchall()
Execute the SQL command and return the data rows as tuples
https://github.com/Proteus-tech/tormor/blob/3083b0cd2b9a4d21b20dfd5c27678b23660548d7/tormor/connection.py#L71-L75
plivo/sharq-server
runner.py
run
def run(): """Exposes a CLI to configure the SharQ Server and runs the server.""" # create a arg parser and configure it. parser = argparse.ArgumentParser(description='SharQ Server.') parser.add_argument('-c', '--config', action='store', required=True, help='Absolute path of the ...
python
def run(): """Exposes a CLI to configure the SharQ Server and runs the server.""" # create a arg parser and configure it. parser = argparse.ArgumentParser(description='SharQ Server.') parser.add_argument('-c', '--config', action='store', required=True, help='Absolute path of the ...
Exposes a CLI to configure the SharQ Server and runs the server.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/runner.py#L38-L97
plivo/sharq-server
sharq_server/server.py
setup_server
def setup_server(config_path): """Configure SharQ server, start the requeue loop and return the server.""" # configure the SharQ server server = SharQServer(config_path) # start the requeue loop gevent.spawn(server.requeue) return server
python
def setup_server(config_path): """Configure SharQ server, start the requeue loop and return the server.""" # configure the SharQ server server = SharQServer(config_path) # start the requeue loop gevent.spawn(server.requeue) return server
Configure SharQ server, start the requeue loop and return the server.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L204-L212
plivo/sharq-server
sharq_server/server.py
SharQServer.requeue
def requeue(self): """Loop endlessly and requeue expired jobs.""" job_requeue_interval = float( self.config.get('sharq', 'job_requeue_interval')) while True: self.sq.requeue() gevent.sleep(job_requeue_interval / 1000.00)
python
def requeue(self): """Loop endlessly and requeue expired jobs.""" job_requeue_interval = float( self.config.get('sharq', 'job_requeue_interval')) while True: self.sq.requeue() gevent.sleep(job_requeue_interval / 1000.00)
Loop endlessly and requeue expired jobs.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L57-L63
plivo/sharq-server
sharq_server/server.py
SharQServer._view_enqueue
def _view_enqueue(self, queue_type, queue_id): """Enqueues a job into SharQ.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) except Exception, e: response['message'] = e.message return jsonify(**re...
python
def _view_enqueue(self, queue_type, queue_id): """Enqueues a job into SharQ.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) except Exception, e: response['message'] = e.message return jsonify(**re...
Enqueues a job into SharQ.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L69-L91
plivo/sharq-server
sharq_server/server.py
SharQServer._view_dequeue
def _view_dequeue(self, queue_type): """Dequeues a job from SharQ.""" response = { 'status': 'failure' } request_data = { 'queue_type': queue_type } try: response = self.sq.dequeue(**request_data) if response['status'] == '...
python
def _view_dequeue(self, queue_type): """Dequeues a job from SharQ.""" response = { 'status': 'failure' } request_data = { 'queue_type': queue_type } try: response = self.sq.dequeue(**request_data) if response['status'] == '...
Dequeues a job from SharQ.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L93-L110
plivo/sharq-server
sharq_server/server.py
SharQServer._view_finish
def _view_finish(self, queue_type, queue_id, job_id): """Marks a job as finished in SharQ.""" response = { 'status': 'failure' } request_data = { 'queue_type': queue_type, 'queue_id': queue_id, 'job_id': job_id } try: ...
python
def _view_finish(self, queue_type, queue_id, job_id): """Marks a job as finished in SharQ.""" response = { 'status': 'failure' } request_data = { 'queue_type': queue_type, 'queue_id': queue_id, 'job_id': job_id } try: ...
Marks a job as finished in SharQ.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L112-L131
plivo/sharq-server
sharq_server/server.py
SharQServer._view_interval
def _view_interval(self, queue_type, queue_id): """Updates the queue interval in SharQ.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) interval = request_data['interval'] except Exception, e: resp...
python
def _view_interval(self, queue_type, queue_id): """Updates the queue interval in SharQ.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) interval = request_data['interval'] except Exception, e: resp...
Updates the queue interval in SharQ.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L133-L159
plivo/sharq-server
sharq_server/server.py
SharQServer._view_metrics
def _view_metrics(self, queue_type, queue_id): """Gets SharQ metrics based on the params.""" response = { 'status': 'failure' } request_data = {} if queue_type: request_data['queue_type'] = queue_type if queue_id: request_data['queue_id...
python
def _view_metrics(self, queue_type, queue_id): """Gets SharQ metrics based on the params.""" response = { 'status': 'failure' } request_data = {} if queue_type: request_data['queue_type'] = queue_type if queue_id: request_data['queue_id...
Gets SharQ metrics based on the params.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L161-L178
plivo/sharq-server
sharq_server/server.py
SharQServer._view_clear_queue
def _view_clear_queue(self, queue_type, queue_id): """remove queueu from SharQ based on the queue_type and queue_id.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) except Exception, e: response['message'] = e...
python
def _view_clear_queue(self, queue_type, queue_id): """remove queueu from SharQ based on the queue_type and queue_id.""" response = { 'status': 'failure' } try: request_data = json.loads(request.data) except Exception, e: response['message'] = e...
remove queueu from SharQ based on the queue_type and queue_id.
https://github.com/plivo/sharq-server/blob/9f4c50eb5ee28d1084591febc4a3a34d7ffd0556/sharq_server/server.py#L180-L201
depop/python-automock
automock/base.py
_get_from_path
def _get_from_path(import_path): # type: (str) -> Callable """ Kwargs: import_path: full import path (to a mock factory function) Returns: (the mock factory function) """ module_name, obj_name = import_path.rsplit('.', 1) module = import_module(module_name) return getatt...
python
def _get_from_path(import_path): # type: (str) -> Callable """ Kwargs: import_path: full import path (to a mock factory function) Returns: (the mock factory function) """ module_name, obj_name = import_path.rsplit('.', 1) module = import_module(module_name) return getatt...
Kwargs: import_path: full import path (to a mock factory function) Returns: (the mock factory function)
https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L32-L43
depop/python-automock
automock/base.py
register
def register(func_path, factory=mock.MagicMock): # type: (str, Callable) -> Callable """ Kwargs: func_path: import path to mock (as you would give to `mock.patch`) factory: function that returns a mock for the patched func Returns: (decorator) Usage: automock.regis...
python
def register(func_path, factory=mock.MagicMock): # type: (str, Callable) -> Callable """ Kwargs: func_path: import path to mock (as you would give to `mock.patch`) factory: function that returns a mock for the patched func Returns: (decorator) Usage: automock.regis...
Kwargs: func_path: import path to mock (as you would give to `mock.patch`) factory: function that returns a mock for the patched func Returns: (decorator) Usage: automock.register('path.to.func.to.mock') # default MagicMock automock.register('path.to.func.to.mock', Cu...
https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L46-L72
depop/python-automock
automock/base.py
start_patching
def start_patching(name=None): # type: (Optional[str]) -> None """ Initiate mocking of the functions listed in `_factory_map`. For this to work reliably all mocked helper functions should be imported and used like this: import dp_paypal.client as paypal res = paypal.do_paypal_expre...
python
def start_patching(name=None): # type: (Optional[str]) -> None """ Initiate mocking of the functions listed in `_factory_map`. For this to work reliably all mocked helper functions should be imported and used like this: import dp_paypal.client as paypal res = paypal.do_paypal_expre...
Initiate mocking of the functions listed in `_factory_map`. For this to work reliably all mocked helper functions should be imported and used like this: import dp_paypal.client as paypal res = paypal.do_paypal_express_checkout(...) (i.e. don't use `from dp_paypal.client import x` import s...
https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L88-L121
depop/python-automock
automock/base.py
stop_patching
def stop_patching(name=None): # type: (Optional[str]) -> None """ Finish the mocking initiated by `start_patching` Kwargs: name (Optional[str]): if given, only unpatch the specified path, else all defined default mocks """ global _patchers, _mocks if not _patchers: ...
python
def stop_patching(name=None): # type: (Optional[str]) -> None """ Finish the mocking initiated by `start_patching` Kwargs: name (Optional[str]): if given, only unpatch the specified path, else all defined default mocks """ global _patchers, _mocks if not _patchers: ...
Finish the mocking initiated by `start_patching` Kwargs: name (Optional[str]): if given, only unpatch the specified path, else all defined default mocks
https://github.com/depop/python-automock/blob/8a02acecd9265c8f9a00d7b8e097cae87cdf28bd/automock/base.py#L124-L145
matousc89/padasip
padasip/preprocess/standardize_back.py
standardize_back
def standardize_back(xs, offset, scale): """ This is function for de-standarization of input series. **Args:** * `xs` : standardized input (1 dimensional array) * `offset` : offset to add (float). * `scale` : scale (float). **Returns:** * `x` : original (destandardised) ser...
python
def standardize_back(xs, offset, scale): """ This is function for de-standarization of input series. **Args:** * `xs` : standardized input (1 dimensional array) * `offset` : offset to add (float). * `scale` : scale (float). **Returns:** * `x` : original (destandardised) ser...
This is function for de-standarization of input series. **Args:** * `xs` : standardized input (1 dimensional array) * `offset` : offset to add (float). * `scale` : scale (float). **Returns:** * `x` : original (destandardised) series
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/standardize_back.py#L33-L62
matousc89/padasip
padasip/preprocess/standardize.py
standardize
def standardize(x, offset=None, scale=None): """ This is function for standarization of input series. **Args:** * `x` : series (1 dimensional array) **Kwargs:** * `offset` : offset to remove (float). If not given, \ the mean value of `x` is used. * `scale` : scale (float). If...
python
def standardize(x, offset=None, scale=None): """ This is function for standarization of input series. **Args:** * `x` : series (1 dimensional array) **Kwargs:** * `offset` : offset to remove (float). If not given, \ the mean value of `x` is used. * `scale` : scale (float). If...
This is function for standarization of input series. **Args:** * `x` : series (1 dimensional array) **Kwargs:** * `offset` : offset to remove (float). If not given, \ the mean value of `x` is used. * `scale` : scale (float). If not given, \ the standard deviation of `x` is used....
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/standardize.py#L62-L100
matousc89/padasip
padasip/preprocess/input_from_history.py
input_from_history
def input_from_history(a, n, bias=False): """ This is function for creation of input matrix. **Args:** * `a` : series (1 dimensional array) * `n` : size of input matrix row (int). It means how many samples \ of previous history you want to use \ as the filter input. It also repres...
python
def input_from_history(a, n, bias=False): """ This is function for creation of input matrix. **Args:** * `a` : series (1 dimensional array) * `n` : size of input matrix row (int). It means how many samples \ of previous history you want to use \ as the filter input. It also repres...
This is function for creation of input matrix. **Args:** * `a` : series (1 dimensional array) * `n` : size of input matrix row (int). It means how many samples \ of previous history you want to use \ as the filter input. It also represents the filter length. **Kwargs:** * `bias`...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/input_from_history.py#L34-L72
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.init_weights
def init_weights(self, w, n=-1): """ This function initialises the adaptive weights of the filter. **Args:** * `w` : initial weights of filter. Possible values are: * array with initial weights (1 dimensional array) of filter size * "random" : ...
python
def init_weights(self, w, n=-1): """ This function initialises the adaptive weights of the filter. **Args:** * `w` : initial weights of filter. Possible values are: * array with initial weights (1 dimensional array) of filter size * "random" : ...
This function initialises the adaptive weights of the filter. **Args:** * `w` : initial weights of filter. Possible values are: * array with initial weights (1 dimensional array) of filter size * "random" : create random weights * "zer...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L16-L56
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.predict
def predict(self, x): """ This function calculates the new output value `y` from input array `x`. **Args:** * `x` : input vector (1 dimension array) in length of filter. **Returns:** * `y` : output value (float) calculated from input array. """ y = np...
python
def predict(self, x): """ This function calculates the new output value `y` from input array `x`. **Args:** * `x` : input vector (1 dimension array) in length of filter. **Returns:** * `y` : output value (float) calculated from input array. """ y = np...
This function calculates the new output value `y` from input array `x`. **Args:** * `x` : input vector (1 dimension array) in length of filter. **Returns:** * `y` : output value (float) calculated from input array.
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L58-L72
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.pretrained_run
def pretrained_run(self, d, x, ntrain=0.5, epochs=1): """ This function sacrifices part of the data for few epochs of learning. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are inp...
python
def pretrained_run(self, d, x, ntrain=0.5, epochs=1): """ This function sacrifices part of the data for few epochs of learning. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are inp...
This function sacrifices part of the data for few epochs of learning. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * `ntrain` : train to test...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L74-L110
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.explore_learning
def explore_learning(self, d, x, mu_start=0, mu_end=1., steps=100, ntrain=0.5, epochs=1, criteria="MSE", target_w=False): """ Test what learning rate is the best. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows...
python
def explore_learning(self, d, x, mu_start=0, mu_end=1., steps=100, ntrain=0.5, epochs=1, criteria="MSE", target_w=False): """ Test what learning rate is the best. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows...
Test what learning rate is the best. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * `mu_start` : starting learning rate (float) ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L112-L168
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.check_float_param
def check_float_param(self, param, low, high, name): """ Check if the value of the given parameter is in the given range and a float. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float ...
python
def check_float_param(self, param, low, high, name): """ Check if the value of the given parameter is in the given range and a float. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float ...
Check if the value of the given parameter is in the given range and a float. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float with a value between `low` and `high`. **Args:** * `par...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L170-L203
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.check_int
def check_int(self, param, error_msg): """ This function check if the parameter is int. If yes, the function returns the parameter, if not, it raises error message. **Args:** * `param` : parameter to check (int or similar) * `error_ms` : lowest ...
python
def check_int(self, param, error_msg): """ This function check if the parameter is int. If yes, the function returns the parameter, if not, it raises error message. **Args:** * `param` : parameter to check (int or similar) * `error_ms` : lowest ...
This function check if the parameter is int. If yes, the function returns the parameter, if not, it raises error message. **Args:** * `param` : parameter to check (int or similar) * `error_ms` : lowest allowed value (int), or None **Ret...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L205-L224
matousc89/padasip
padasip/filters/base_filter.py
AdaptiveFilter.check_int_param
def check_int_param(self, param, low, high, name): """ Check if the value of the given parameter is in the given range and an int. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float wit...
python
def check_int_param(self, param, low, high, name): """ Check if the value of the given parameter is in the given range and an int. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float wit...
Check if the value of the given parameter is in the given range and an int. Designed for testing parameters like `mu` and `eps`. To pass this function the variable `param` must be able to be converted into a float with a value between `low` and `high`. **Args:** * `para...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/base_filter.py#L226-L259
matousc89/padasip
padasip/filters/nlmf.py
FilterNLMF.adapt
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y nu = self.mu / (self.eps + np.dot(x, x)) ...
python
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y nu = self.mu / (self.eps + np.dot(x, x)) ...
Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/nlmf.py#L123-L136
matousc89/padasip
padasip/filters/nlmf.py
FilterNLMF.run
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value...
python
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value...
This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value (1 dimensional array). The siz...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/nlmf.py#L138-L183
matousc89/padasip
padasip/misc/error_evaluation.py
get_valid_error
def get_valid_error(x1, x2=-1): """ Function that validates: * x1 is possible to convert to numpy array * x2 is possible to convert to numpy array (if exists) * x1 and x2 have the same length (if both exist) """ # just error if type(x2) == int and x2 == -1: try: ...
python
def get_valid_error(x1, x2=-1): """ Function that validates: * x1 is possible to convert to numpy array * x2 is possible to convert to numpy array (if exists) * x1 and x2 have the same length (if both exist) """ # just error if type(x2) == int and x2 == -1: try: ...
Function that validates: * x1 is possible to convert to numpy array * x2 is possible to convert to numpy array (if exists) * x1 and x2 have the same length (if both exist)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L99-L125
matousc89/padasip
padasip/misc/error_evaluation.py
logSE
def logSE(x1, x2=-1): """ 10 * log10(e**2) This function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then thi...
python
def logSE(x1, x2=-1): """ 10 * log10(e**2) This function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then thi...
10 * log10(e**2) This function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L127-L149
matousc89/padasip
padasip/misc/error_evaluation.py
MAE
def MAE(x1, x2=-1): """ Mean absolute error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this sho...
python
def MAE(x1, x2=-1): """ Mean absolute error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this sho...
Mean absolute error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series **...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L152-L173
matousc89/padasip
padasip/misc/error_evaluation.py
MSE
def MSE(x1, x2=-1): """ Mean squared error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this shou...
python
def MSE(x1, x2=-1): """ Mean squared error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this shou...
Mean squared error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series **R...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L175-L196
matousc89/padasip
padasip/misc/error_evaluation.py
RMSE
def RMSE(x1, x2=-1): """ Root-mean-square error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this...
python
def RMSE(x1, x2=-1): """ Root-mean-square error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this...
Root-mean-square error - this function accepts two series of data or directly one series with error. **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L198-L219
matousc89/padasip
padasip/misc/error_evaluation.py
get_mean_error
def get_mean_error(x1, x2=-1, function="MSE"): """ This function returns desired mean error. Options are: MSE, MAE, RMSE **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this shou...
python
def get_mean_error(x1, x2=-1, function="MSE"): """ This function returns desired mean error. Options are: MSE, MAE, RMSE **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this shou...
This function returns desired mean error. Options are: MSE, MAE, RMSE **Args:** * `x1` - first data series or error (1d array) **Kwargs:** * `x2` - second series (1d array) if first series was not error directly,\\ then this should be the second series **Returns:** * `e` - mean...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L221-L246
matousc89/padasip
padasip/detection/elbnd.py
ELBND
def ELBND(w, e, function="max"): """ This function estimates Error and Learning Based Novelty Detection measure from given data. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. * `e` : error of adapti...
python
def ELBND(w, e, function="max"): """ This function estimates Error and Learning Based Novelty Detection measure from given data. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. * `e` : error of adapti...
This function estimates Error and Learning Based Novelty Detection measure from given data. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. * `e` : error of adaptive model (1d array) **Kwargs:** * `...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/detection/elbnd.py#L93-L138
matousc89/padasip
padasip/filters/rls.py
FilterRLS.adapt
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y R1 = np.dot(np.dot(np.dot(self.R,x),x.T),se...
python
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y R1 = np.dot(np.dot(np.dot(self.R,x),x.T),se...
Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/rls.py#L208-L224
matousc89/padasip
padasip/filters/rls.py
FilterRLS.run
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output val...
python
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output val...
This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value (1 dimensional array). The s...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/rls.py#L226-L273
matousc89/padasip
padasip/filters/ap.py
FilterAP.adapt
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ # create input matrix and target vector self.x_mem[:,1:] = self.x_mem[:,:-1] ...
python
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ # create input matrix and target vector self.x_mem[:,1:] = self.x_mem[:,:-1] ...
Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/ap.py#L205-L227
matousc89/padasip
padasip/filters/ap.py
FilterAP.run
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value...
python
def run(self, d, x): """ This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value...
This function filters multiple samples in a row. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Returns:** * `y` : output value (1 dimensional array). The siz...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/ap.py#L229-L285
matousc89/padasip
padasip/preprocess/lda.py
LDA_base
def LDA_base(x, labels): """ Base function used for Linear Discriminant Analysis. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Returns:** * ...
python
def LDA_base(x, labels): """ Base function used for Linear Discriminant Analysis. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Returns:** * ...
Base function used for Linear Discriminant Analysis. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Returns:** * `eigenvalues`, `eigenvectors` : eigen...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L104-L144
matousc89/padasip
padasip/preprocess/lda.py
LDA
def LDA(x, labels, n=False): """ Linear Discriminant Analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Kwargs:** * `n` : number of...
python
def LDA(x, labels, n=False): """ Linear Discriminant Analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Kwargs:** * `n` : number of...
Linear Discriminant Analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Kwargs:** * `n` : number of features returned (integer) - how many c...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L146-L181
matousc89/padasip
padasip/preprocess/lda.py
LDA_discriminants
def LDA_discriminants(x, labels): """ Linear Discriminant Analysis helper for determination how many columns of data should be reduced. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ s...
python
def LDA_discriminants(x, labels): """ Linear Discriminant Analysis helper for determination how many columns of data should be reduced. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ s...
Linear Discriminant Analysis helper for determination how many columns of data should be reduced. **Args:** * `x` : input matrix (2d array), every row represents new sample * `labels` : list of labels (iterable), every item should be label for \ sample with corresponding index **Returns:...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/lda.py#L184-L208
matousc89/padasip
padasip/filters/gngd.py
FilterGNGD.adapt
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y self.eps = self.eps - self.ro * self.mu * e...
python
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y self.eps = self.eps - self.ro * self.mu * e...
Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/gngd.py#L158-L175
matousc89/padasip
padasip/filters/ocnlms.py
FilterOCNLMS.adapt
def adapt(self, d, x): """ Adapt weights according one desired value and its input. Args: * `d` : desired value (float) * `x` : input array (1-dimensional array) """ self.update_memory_x(x) m_d, m_x = self.read_memory() # estimate y = np...
python
def adapt(self, d, x): """ Adapt weights according one desired value and its input. Args: * `d` : desired value (float) * `x` : input array (1-dimensional array) """ self.update_memory_x(x) m_d, m_x = self.read_memory() # estimate y = np...
Adapt weights according one desired value and its input. Args: * `d` : desired value (float) * `x` : input array (1-dimensional array)
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/ocnlms.py#L54-L72
matousc89/padasip
padasip/filters/ocnlms.py
FilterOCNLMS.read_memory
def read_memory(self): """ This function read mean value of target`d` and input vector `x` from history """ if self.mem_empty == True: if self.mem_idx == 0: m_x = np.zeros(self.n) m_d = 0 else: m_x = np.mean(...
python
def read_memory(self): """ This function read mean value of target`d` and input vector `x` from history """ if self.mem_empty == True: if self.mem_idx == 0: m_x = np.zeros(self.n) m_d = 0 else: m_x = np.mean(...
This function read mean value of target`d` and input vector `x` from history
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/ocnlms.py#L86-L105
matousc89/padasip
padasip/filters/__init__.py
filter_data
def filter_data(d, x, model="lms", **kwargs): """ Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * An...
python
def filter_data(d, x, model="lms", **kwargs): """ Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * An...
Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * Any key argument that can be accepted with selected filter m...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/__init__.py#L179-L228
matousc89/padasip
padasip/filters/__init__.py
AdaptiveFilter
def AdaptiveFilter(model="lms", **kwargs): """ Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * Any ...
python
def AdaptiveFilter(model="lms", **kwargs): """ Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * Any ...
Function that filter data with selected adaptive filter. **Args:** * `d` : desired value (1 dimensional array) * `x` : input matrix (2-dimensional array). Rows are samples, columns are input arrays. **Kwargs:** * Any key argument that can be accepted with selected filter ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/__init__.py#L230-L281
matousc89/padasip
padasip/detection/le.py
learning_entropy
def learning_entropy(w, m=10, order=1, alpha=False): """ This function estimates Learning Entropy. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. **Kwargs:** * `m` : window size (1d array) - how man...
python
def learning_entropy(w, m=10, order=1, alpha=False): """ This function estimates Learning Entropy. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. **Kwargs:** * `m` : window size (1d array) - how man...
This function estimates Learning Entropy. **Args:** * `w` : history of adaptive parameters of an adaptive model (2d array), every row represents parameters in given time index. **Kwargs:** * `m` : window size (1d array) - how many last samples are used for evaluation of every sample. ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/detection/le.py#L145-L200
matousc89/padasip
padasip/ann/mlp.py
Layer.activation
def activation(self, x, f="sigmoid", der=False): """ This function process values of layer outputs with activation function. **Args:** * `x` : array to process (1-dimensional array) **Kwargs:** * `f` : activation function * `der` : normal output, or its deri...
python
def activation(self, x, f="sigmoid", der=False): """ This function process values of layer outputs with activation function. **Args:** * `x` : array to process (1-dimensional array) **Kwargs:** * `f` : activation function * `der` : normal output, or its deri...
This function process values of layer outputs with activation function. **Args:** * `x` : array to process (1-dimensional array) **Kwargs:** * `f` : activation function * `der` : normal output, or its derivation (bool) **Returns:** * values processed with ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L126-L152
matousc89/padasip
padasip/ann/mlp.py
Layer.predict
def predict(self, x): """ This function make forward pass through this layer (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of nodes in thi...
python
def predict(self, x): """ This function make forward pass through this layer (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of nodes in thi...
This function make forward pass through this layer (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of nodes in this layer.
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L154-L170
matousc89/padasip
padasip/ann/mlp.py
Layer.update
def update(self, w, e): """ This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `w` : weights of the laye...
python
def update(self, w, e): """ This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `w` : weights of the laye...
This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `w` : weights of the layers (2-dimensional layer). Every ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L172-L198
matousc89/padasip
padasip/ann/mlp.py
NetworkMLP.train
def train(self, x, d, epochs=10, shuffle=False): """ Function for batch training of MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). * `d` : input array (n-dimensional array). Every row represen...
python
def train(self, x, d, epochs=10, shuffle=False): """ Function for batch training of MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). * `d` : input array (n-dimensional array). Every row represen...
Function for batch training of MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). * `d` : input array (n-dimensional array). Every row represents target for one input vector. Target can be one or more...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L267-L334
matousc89/padasip
padasip/ann/mlp.py
NetworkMLP.run
def run(self, x): """ Function for batch usage of already trained and tested MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). **Returns:** * `y`: output vector (n-dimensional array). Every ...
python
def run(self, x): """ Function for batch usage of already trained and tested MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). **Returns:** * `y`: output vector (n-dimensional array). Every ...
Function for batch usage of already trained and tested MLP. **Args:** * `x` : input array (2-dimensional array). Every row represents one input vector (features). **Returns:** * `y`: output vector (n-dimensional array). Every row represents output (out...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L336-L365
matousc89/padasip
padasip/ann/mlp.py
NetworkMLP.predict
def predict(self, x): """ This function make forward pass through MLP (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of MLP outputs. ...
python
def predict(self, x): """ This function make forward pass through MLP (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of MLP outputs. ...
This function make forward pass through MLP (no update). **Args:** * `x` : input vector (1-dimensional array) **Returns:** * `y` : output of MLP (float or 1-diemnsional array). Size depends on number of MLP outputs.
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L413-L436
matousc89/padasip
padasip/ann/mlp.py
NetworkMLP.update
def update(self, d): """ This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `e` : error used for...
python
def update(self, d): """ This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `e` : error used for...
This function make update according provided target and the last used input vector. **Args:** * `d` : target (float or 1-dimensional array). Size depends on number of MLP outputs. **Returns:** * `e` : error used for update (float or 1-diemnsional array). ...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/ann/mlp.py#L438-L467
matousc89/padasip
padasip/preprocess/pca.py
PCA_components
def PCA_components(x): """ Principal Component Analysis helper to check out eigenvalues of components. **Args:** * `x` : input matrix (2d array), every row represents new sample **Returns:** * `components`: sorted array of principal components eigenvalues """ # validat...
python
def PCA_components(x): """ Principal Component Analysis helper to check out eigenvalues of components. **Args:** * `x` : input matrix (2d array), every row represents new sample **Returns:** * `components`: sorted array of principal components eigenvalues """ # validat...
Principal Component Analysis helper to check out eigenvalues of components. **Args:** * `x` : input matrix (2d array), every row represents new sample **Returns:** * `components`: sorted array of principal components eigenvalues
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/pca.py#L68-L91
matousc89/padasip
padasip/preprocess/pca.py
PCA
def PCA(x, n=False): """ Principal component analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample **Kwargs:** * `n` : number of features returned (integer) - how many columns should the output keep **Returns:** * `new_x` : matrix ...
python
def PCA(x, n=False): """ Principal component analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample **Kwargs:** * `n` : number of features returned (integer) - how many columns should the output keep **Returns:** * `new_x` : matrix ...
Principal component analysis function. **Args:** * `x` : input matrix (2d array), every row represents new sample **Kwargs:** * `n` : number of features returned (integer) - how many columns should the output keep **Returns:** * `new_x` : matrix with reduced size (lower number o...
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/preprocess/pca.py#L94-L127
widdowquinn/pyani
pyani/pyani_graphics.py
clean_axis
def clean_axis(axis): """Remove ticks, tick labels, and frame from axis""" axis.get_xaxis().set_ticks([]) axis.get_yaxis().set_ticks([]) for spine in list(axis.spines.values()): spine.set_visible(False)
python
def clean_axis(axis): """Remove ticks, tick labels, and frame from axis""" axis.get_xaxis().set_ticks([]) axis.get_yaxis().set_ticks([]) for spine in list(axis.spines.values()): spine.set_visible(False)
Remove ticks, tick labels, and frame from axis
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L63-L68
widdowquinn/pyani
pyani/pyani_graphics.py
get_seaborn_colorbar
def get_seaborn_colorbar(dfr, classes): """Return a colorbar representing classes, for a Seaborn plot. The aim is to get a pd.Series for the passed dataframe columns, in the form: 0 colour for class in col 0 1 colour for class in col 1 ... colour for class in col ... n colour for ...
python
def get_seaborn_colorbar(dfr, classes): """Return a colorbar representing classes, for a Seaborn plot. The aim is to get a pd.Series for the passed dataframe columns, in the form: 0 colour for class in col 0 1 colour for class in col 1 ... colour for class in col ... n colour for ...
Return a colorbar representing classes, for a Seaborn plot. The aim is to get a pd.Series for the passed dataframe columns, in the form: 0 colour for class in col 0 1 colour for class in col 1 ... colour for class in col ... n colour for class in col n
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L72-L98
widdowquinn/pyani
pyani/pyani_graphics.py
get_safe_seaborn_labels
def get_safe_seaborn_labels(dfr, labels): """Returns labels guaranteed to correspond to the dataframe.""" if labels is not None: return [labels.get(i, i) for i in dfr.index] return [i for i in dfr.index]
python
def get_safe_seaborn_labels(dfr, labels): """Returns labels guaranteed to correspond to the dataframe.""" if labels is not None: return [labels.get(i, i) for i in dfr.index] return [i for i in dfr.index]
Returns labels guaranteed to correspond to the dataframe.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L102-L106
widdowquinn/pyani
pyani/pyani_graphics.py
get_seaborn_clustermap
def get_seaborn_clustermap(dfr, params, title=None, annot=True): """Returns a Seaborn clustermap.""" fig = sns.clustermap( dfr, cmap=params.cmap, vmin=params.vmin, vmax=params.vmax, col_colors=params.colorbar, row_colors=params.colorbar, figsize=(params.fi...
python
def get_seaborn_clustermap(dfr, params, title=None, annot=True): """Returns a Seaborn clustermap.""" fig = sns.clustermap( dfr, cmap=params.cmap, vmin=params.vmin, vmax=params.vmax, col_colors=params.colorbar, row_colors=params.colorbar, figsize=(params.fi...
Returns a Seaborn clustermap.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L110-L134
widdowquinn/pyani
pyani/pyani_graphics.py
heatmap_seaborn
def heatmap_seaborn(dfr, outfilename=None, title=None, params=None): """Returns seaborn heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format) """ # Decide on figure layout size: a minimum size is required for ...
python
def heatmap_seaborn(dfr, outfilename=None, title=None, params=None): """Returns seaborn heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format) """ # Decide on figure layout size: a minimum size is required for ...
Returns seaborn heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format)
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L138-L175
widdowquinn/pyani
pyani/pyani_graphics.py
add_mpl_dendrogram
def add_mpl_dendrogram(dfr, fig, heatmap_gs, orientation="col"): """Return a dendrogram and corresponding gridspec, attached to the fig Modifies the fig in-place. Orientation is either 'row' or 'col' and determines location and orientation of the rendered dendrogram. """ # Row or column axes? i...
python
def add_mpl_dendrogram(dfr, fig, heatmap_gs, orientation="col"): """Return a dendrogram and corresponding gridspec, attached to the fig Modifies the fig in-place. Orientation is either 'row' or 'col' and determines location and orientation of the rendered dendrogram. """ # Row or column axes? i...
Return a dendrogram and corresponding gridspec, attached to the fig Modifies the fig in-place. Orientation is either 'row' or 'col' and determines location and orientation of the rendered dendrogram.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L179-L215
widdowquinn/pyani
pyani/pyani_graphics.py
get_mpl_heatmap_axes
def get_mpl_heatmap_axes(dfr, fig, heatmap_gs): """Return axis for Matplotlib heatmap.""" # Create heatmap axis heatmap_axes = fig.add_subplot(heatmap_gs[1, 1]) heatmap_axes.set_xticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[0])) heatmap_axes.set_yticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[...
python
def get_mpl_heatmap_axes(dfr, fig, heatmap_gs): """Return axis for Matplotlib heatmap.""" # Create heatmap axis heatmap_axes = fig.add_subplot(heatmap_gs[1, 1]) heatmap_axes.set_xticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[0])) heatmap_axes.set_yticks(np.linspace(0, dfr.shape[0] - 1, dfr.shape[...
Return axis for Matplotlib heatmap.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L219-L228
widdowquinn/pyani
pyani/pyani_graphics.py
add_mpl_colorbar
def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"): """Add class colorbars to Matplotlib heatmap.""" for name in dfr.index[dend["dendrogram"]["leaves"]]: if name not in params.classes: params.classes[name] = name # Assign a numerical value to each class, for mpl classdi...
python
def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"): """Add class colorbars to Matplotlib heatmap.""" for name in dfr.index[dend["dendrogram"]["leaves"]]: if name not in params.classes: params.classes[name] = name # Assign a numerical value to each class, for mpl classdi...
Add class colorbars to Matplotlib heatmap.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L231-L269
widdowquinn/pyani
pyani/pyani_graphics.py
add_mpl_labels
def add_mpl_labels(heatmap_axes, rowlabels, collabels, params): """Add labels to Matplotlib heatmap axes, in-place.""" if params.labels: # If a label mapping is missing, use the key text as fall back rowlabels = [params.labels.get(lab, lab) for lab in rowlabels] collabels = [params.label...
python
def add_mpl_labels(heatmap_axes, rowlabels, collabels, params): """Add labels to Matplotlib heatmap axes, in-place.""" if params.labels: # If a label mapping is missing, use the key text as fall back rowlabels = [params.labels.get(lab, lab) for lab in rowlabels] collabels = [params.label...
Add labels to Matplotlib heatmap axes, in-place.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L273-L285
widdowquinn/pyani
pyani/pyani_graphics.py
add_mpl_colorscale
def add_mpl_colorscale(fig, heatmap_gs, ax_map, params, title=None): """Add colour scale to heatmap.""" # Set tick intervals cbticks = [params.vmin + e * params.vdiff for e in (0, 0.25, 0.5, 0.75, 1)] if params.vmax > 10: exponent = int(floor(log10(params.vmax))) - 1 cbticks = [int(round...
python
def add_mpl_colorscale(fig, heatmap_gs, ax_map, params, title=None): """Add colour scale to heatmap.""" # Set tick intervals cbticks = [params.vmin + e * params.vdiff for e in (0, 0.25, 0.5, 0.75, 1)] if params.vmax > 10: exponent = int(floor(log10(params.vmax))) - 1 cbticks = [int(round...
Add colour scale to heatmap.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L289-L308
widdowquinn/pyani
pyani/pyani_graphics.py
heatmap_mpl
def heatmap_mpl(dfr, outfilename=None, title=None, params=None): """Returns matplotlib heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format) - params - a list of parameters for plotting: [colormap, vmin, vmax] - l...
python
def heatmap_mpl(dfr, outfilename=None, title=None, params=None): """Returns matplotlib heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format) - params - a list of parameters for plotting: [colormap, vmin, vmax] - l...
Returns matplotlib heatmap with cluster dendrograms. - dfr - pandas DataFrame with relevant data - outfilename - path to output file (indicates output format) - params - a list of parameters for plotting: [colormap, vmin, vmax] - labels - dictionary of alternative labels, keyed by default sequence ...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_graphics.py#L312-L375
widdowquinn/pyani
pyani/run_multiprocessing.py
run_dependency_graph
def run_dependency_graph(jobgraph, workers=None, logger=None): """Creates and runs pools of jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing verbosity - logger - a logger module logger (optional) The strategy here is to...
python
def run_dependency_graph(jobgraph, workers=None, logger=None): """Creates and runs pools of jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing verbosity - logger - a logger module logger (optional) The strategy here is to...
Creates and runs pools of jobs based on the passed jobgraph. - jobgraph - list of jobs, which may have dependencies. - verbose - flag for multiprocessing verbosity - logger - a logger module logger (optional) The strategy here is to loop over each job in the list of jobs (jobgraph), and create/pop...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L22-L48
widdowquinn/pyani
pyani/run_multiprocessing.py
populate_cmdsets
def populate_cmdsets(job, cmdsets, depth): """Creates a list of sets containing jobs at different depths of the dependency tree. This is a recursive function (is there something quicker in the itertools module?) that descends each 'root' job in turn, populating each """ if len(cmdsets) < depth:...
python
def populate_cmdsets(job, cmdsets, depth): """Creates a list of sets containing jobs at different depths of the dependency tree. This is a recursive function (is there something quicker in the itertools module?) that descends each 'root' job in turn, populating each """ if len(cmdsets) < depth:...
Creates a list of sets containing jobs at different depths of the dependency tree. This is a recursive function (is there something quicker in the itertools module?) that descends each 'root' job in turn, populating each
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L51-L65
widdowquinn/pyani
pyani/run_multiprocessing.py
multiprocessing_run
def multiprocessing_run(cmdlines, workers=None): """Distributes passed command-line jobs using multiprocessing. - cmdlines - an iterable of command line strings Returns the sum of exit codes from each job that was run. If all goes well, this should be 0. Anything else and the calling function shou...
python
def multiprocessing_run(cmdlines, workers=None): """Distributes passed command-line jobs using multiprocessing. - cmdlines - an iterable of command line strings Returns the sum of exit codes from each job that was run. If all goes well, this should be 0. Anything else and the calling function shou...
Distributes passed command-line jobs using multiprocessing. - cmdlines - an iterable of command line strings Returns the sum of exit codes from each job that was run. If all goes well, this should be 0. Anything else and the calling function should act accordingly.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/run_multiprocessing.py#L69-L89
widdowquinn/pyani
pyani/pyani_files.py
get_input_files
def get_input_files(dirname, *ext): """Returns files in passed directory, filtered by extension. - dirname - path to input directory - *ext - list of arguments describing permitted file extensions """ filelist = [f for f in os.listdir(dirname) if os.path.splitext(f)[-1] in ext] ...
python
def get_input_files(dirname, *ext): """Returns files in passed directory, filtered by extension. - dirname - path to input directory - *ext - list of arguments describing permitted file extensions """ filelist = [f for f in os.listdir(dirname) if os.path.splitext(f)[-1] in ext] ...
Returns files in passed directory, filtered by extension. - dirname - path to input directory - *ext - list of arguments describing permitted file extensions
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_files.py#L27-L35
widdowquinn/pyani
pyani/pyani_files.py
get_sequence_lengths
def get_sequence_lengths(fastafilenames): """Returns dictionary of sequence lengths, keyed by organism. Biopython's SeqIO module is used to parse all sequences in the FASTA file corresponding to each organism, and the total base count in each is obtained. NOTE: ambiguity symbols are not discounted...
python
def get_sequence_lengths(fastafilenames): """Returns dictionary of sequence lengths, keyed by organism. Biopython's SeqIO module is used to parse all sequences in the FASTA file corresponding to each organism, and the total base count in each is obtained. NOTE: ambiguity symbols are not discounted...
Returns dictionary of sequence lengths, keyed by organism. Biopython's SeqIO module is used to parse all sequences in the FASTA file corresponding to each organism, and the total base count in each is obtained. NOTE: ambiguity symbols are not discounted.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_files.py#L39-L52
widdowquinn/pyani
bin/average_nucleotide_identity.py
parse_cmdline
def parse_cmdline(): """Parse command-line arguments for script.""" parser = ArgumentParser(prog="average_nucleotide_identity.py") parser.add_argument( "--version", action="version", version="%(prog)s: pyani " + VERSION ) parser.add_argument( "-o", "--outdir", dest="o...
python
def parse_cmdline(): """Parse command-line arguments for script.""" parser = ArgumentParser(prog="average_nucleotide_identity.py") parser.add_argument( "--version", action="version", version="%(prog)s: pyani " + VERSION ) parser.add_argument( "-o", "--outdir", dest="o...
Parse command-line arguments for script.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L185-L435
widdowquinn/pyani
bin/average_nucleotide_identity.py
last_exception
def last_exception(): """ Returns last exception as a string, or use in logging. """ exc_type, exc_value, exc_traceback = sys.exc_info() return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
python
def last_exception(): """ Returns last exception as a string, or use in logging. """ exc_type, exc_value, exc_traceback = sys.exc_info() return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
Returns last exception as a string, or use in logging.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L439-L443
widdowquinn/pyani
bin/average_nucleotide_identity.py
make_outdir
def make_outdir(): """Make the output directory, if required. This is a little involved. If the output directory already exists, we take the safe option by default, and stop with an error. We can, however, choose to force the program to go on, in which case we can either clobber the existing dire...
python
def make_outdir(): """Make the output directory, if required. This is a little involved. If the output directory already exists, we take the safe option by default, and stop with an error. We can, however, choose to force the program to go on, in which case we can either clobber the existing dire...
Make the output directory, if required. This is a little involved. If the output directory already exists, we take the safe option by default, and stop with an error. We can, however, choose to force the program to go on, in which case we can either clobber the existing directory, or not. The option...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L447-L490
widdowquinn/pyani
bin/average_nucleotide_identity.py
compress_delete_outdir
def compress_delete_outdir(outdir): """Compress the contents of the passed directory to .tar.gz and delete.""" # Compress output in .tar.gz file and remove raw output tarfn = outdir + ".tar.gz" logger.info("\tCompressing output from %s to %s", outdir, tarfn) with tarfile.open(tarfn, "w:gz") as fh: ...
python
def compress_delete_outdir(outdir): """Compress the contents of the passed directory to .tar.gz and delete.""" # Compress output in .tar.gz file and remove raw output tarfn = outdir + ".tar.gz" logger.info("\tCompressing output from %s to %s", outdir, tarfn) with tarfile.open(tarfn, "w:gz") as fh: ...
Compress the contents of the passed directory to .tar.gz and delete.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L494-L502
widdowquinn/pyani
bin/average_nucleotide_identity.py
calculate_anim
def calculate_anim(infiles, org_lengths): """Returns ANIm result dataframes for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Finds ANI by the ANIm method, as described in Richter et al (2009) Proc Natl Acad S...
python
def calculate_anim(infiles, org_lengths): """Returns ANIm result dataframes for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Finds ANI by the ANIm method, as described in Richter et al (2009) Proc Natl Acad S...
Returns ANIm result dataframes for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Finds ANI by the ANIm method, as described in Richter et al (2009) Proc Natl Acad Sci USA 106: 19126-19131 doi:10.1073/pnas.09064121...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L506-L599
widdowquinn/pyani
bin/average_nucleotide_identity.py
calculate_tetra
def calculate_tetra(infiles): """Calculate TETRA for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates TETRA correlation scores, as described in: Richter M, Rossello-Mora R (2009) Shifting the genomic ...
python
def calculate_tetra(infiles): """Calculate TETRA for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates TETRA correlation scores, as described in: Richter M, Rossello-Mora R (2009) Shifting the genomic ...
Calculate TETRA for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates TETRA correlation scores, as described in: Richter M, Rossello-Mora R (2009) Shifting the genomic gold standard for the prokaryotic...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L603-L632
widdowquinn/pyani
bin/average_nucleotide_identity.py
unified_anib
def unified_anib(infiles, org_lengths): """Calculate ANIb for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates ANI by the ANIb method, as described in Goris et al. (2007) Int J Syst Evol Micr 57: 81-91...
python
def unified_anib(infiles, org_lengths): """Calculate ANIb for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates ANI by the ANIb method, as described in Goris et al. (2007) Int J Syst Evol Micr 57: 81-91...
Calculate ANIb for files in input directory. - infiles - paths to each input file - org_lengths - dictionary of input sequence lengths, keyed by sequence Calculates ANI by the ANIb method, as described in Goris et al. (2007) Int J Syst Evol Micr 57: 81-91. doi:10.1099/ijs.0.64483-0. There are some...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L636-L752
widdowquinn/pyani
bin/average_nucleotide_identity.py
write
def write(results): """Write ANIb/ANIm/TETRA results to output directory. - results - results object from analysis Each dataframe is written to an Excel-format file (if args.write_excel is True), and plain text tab-separated file in the output directory. The order of result output must be reflecte...
python
def write(results): """Write ANIb/ANIm/TETRA results to output directory. - results - results object from analysis Each dataframe is written to an Excel-format file (if args.write_excel is True), and plain text tab-separated file in the output directory. The order of result output must be reflecte...
Write ANIb/ANIm/TETRA results to output directory. - results - results object from analysis Each dataframe is written to an Excel-format file (if args.write_excel is True), and plain text tab-separated file in the output directory. The order of result output must be reflected in the order of filestems...
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L756-L780
widdowquinn/pyani
bin/average_nucleotide_identity.py
draw
def draw(filestems, gformat): """Draw ANIb/ANIm/TETRA results - filestems - filestems for output files - gformat - the format for output graphics """ # Draw heatmaps for filestem in filestems: fullstem = os.path.join(args.outdirname, filestem) outfilename = fullstem + ".%s" % gf...
python
def draw(filestems, gformat): """Draw ANIb/ANIm/TETRA results - filestems - filestems for output files - gformat - the format for output graphics """ # Draw heatmaps for filestem in filestems: fullstem = os.path.join(args.outdirname, filestem) outfilename = fullstem + ".%s" % gf...
Draw ANIb/ANIm/TETRA results - filestems - filestems for output files - gformat - the format for output graphics
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L784-L809
widdowquinn/pyani
bin/average_nucleotide_identity.py
subsample_input
def subsample_input(infiles): """Returns a random subsample of the input files. - infiles: a list of input files for analysis """ logger.info("--subsample: %s", args.subsample) try: samplesize = float(args.subsample) except TypeError: # Not a number logger.error( "-...
python
def subsample_input(infiles): """Returns a random subsample of the input files. - infiles: a list of input files for analysis """ logger.info("--subsample: %s", args.subsample) try: samplesize = float(args.subsample) except TypeError: # Not a number logger.error( "-...
Returns a random subsample of the input files. - infiles: a list of input files for analysis
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/average_nucleotide_identity.py#L813-L842
widdowquinn/pyani
pyani/pyani_jobs.py
Job.wait
def wait(self, interval=SGE_WAIT): """Wait until the job finishes, and poll SGE on its status.""" finished = False while not finished: time.sleep(interval) interval = min(2 * interval, 60) finished = os.system("qstat -j %s > /dev/null" % (self.name))
python
def wait(self, interval=SGE_WAIT): """Wait until the job finishes, and poll SGE on its status.""" finished = False while not finished: time.sleep(interval) interval = min(2 * interval, 60) finished = os.system("qstat -j %s > /dev/null" % (self.name))
Wait until the job finishes, and poll SGE on its status.
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_jobs.py#L77-L83