repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
guaix-ucm/numina
numina/array/blocks.py
blk_nd
def blk_nd(blk, shape): """Iterate through the blocks that cover an array. This function first iterates trough the blocks that recover the part of the array given by max_blk_coverage and then iterates with smaller blocks for the rest of the array. :param blk: the N-dimensional shape of the blo...
python
def blk_nd(blk, shape): """Iterate through the blocks that cover an array. This function first iterates trough the blocks that recover the part of the array given by max_blk_coverage and then iterates with smaller blocks for the rest of the array. :param blk: the N-dimensional shape of the blo...
[ "def", "blk_nd", "(", "blk", ",", "shape", ")", ":", "internals", "=", "(", "blk_1d", "(", "b", ",", "s", ")", "for", "b", ",", "s", "in", "zip", "(", "blk", ",", "shape", ")", ")", "return", "product", "(", "*", "internals", ")" ]
Iterate through the blocks that cover an array. This function first iterates trough the blocks that recover the part of the array given by max_blk_coverage and then iterates with smaller blocks for the rest of the array. :param blk: the N-dimensional shape of the block :param shape: the N-dime...
[ "Iterate", "through", "the", "blocks", "that", "cover", "an", "array", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L192-L226
train
Iterate through the blocks that cover an array.
guaix-ucm/numina
numina/array/blocks.py
block_view
def block_view(arr, block=(3, 3)): """Provide a 2D block view to 2D array. No error checking made. Therefore meaningful (as implemented) only for blocks strictly compatible with the shape of A. """ # simple shape and strides computations may seem at first strange # unless one is able to recog...
python
def block_view(arr, block=(3, 3)): """Provide a 2D block view to 2D array. No error checking made. Therefore meaningful (as implemented) only for blocks strictly compatible with the shape of A. """ # simple shape and strides computations may seem at first strange # unless one is able to recog...
[ "def", "block_view", "(", "arr", ",", "block", "=", "(", "3", ",", "3", ")", ")", ":", "# simple shape and strides computations may seem at first strange", "# unless one is able to recognize the 'tuple additions' involved ;-)", "shape", "=", "(", "arr", ".", "shape", "[",...
Provide a 2D block view to 2D array. No error checking made. Therefore meaningful (as implemented) only for blocks strictly compatible with the shape of A.
[ "Provide", "a", "2D", "block", "view", "to", "2D", "array", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/blocks.py#L229-L241
train
Provide a 2D block view to 2D array.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
is_citeable
def is_citeable(publication_info): """Check some fields in order to define if the article is citeable. :param publication_info: publication_info field already populated :type publication_info: list """ def _item_has_pub_info(item): return all( key in item for key in ( ...
python
def is_citeable(publication_info): """Check some fields in order to define if the article is citeable. :param publication_info: publication_info field already populated :type publication_info: list """ def _item_has_pub_info(item): return all( key in item for key in ( ...
[ "def", "is_citeable", "(", "publication_info", ")", ":", "def", "_item_has_pub_info", "(", "item", ")", ":", "return", "all", "(", "key", "in", "item", "for", "key", "in", "(", "'journal_title'", ",", "'journal_volume'", ")", ")", "def", "_item_has_page_or_art...
Check some fields in order to define if the article is citeable. :param publication_info: publication_info field already populated :type publication_info: list
[ "Check", "some", "fields", "in", "order", "to", "define", "if", "the", "article", "is", "citeable", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L46-L75
train
Check if the article is citeable.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder._sourced_dict
def _sourced_dict(self, source=None, **kwargs): """Like ``dict(**kwargs)``, but where the ``source`` key is special. """ if source: kwargs['source'] = source elif self.source: kwargs['source'] = self.source return kwargs
python
def _sourced_dict(self, source=None, **kwargs): """Like ``dict(**kwargs)``, but where the ``source`` key is special. """ if source: kwargs['source'] = source elif self.source: kwargs['source'] = self.source return kwargs
[ "def", "_sourced_dict", "(", "self", ",", "source", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "source", ":", "kwargs", "[", "'source'", "]", "=", "source", "elif", "self", ".", "source", ":", "kwargs", "[", "'source'", "]", "=", "self", ...
Like ``dict(**kwargs)``, but where the ``source`` key is special.
[ "Like", "dict", "(", "**", "kwargs", ")", "but", "where", "the", "source", "key", "is", "special", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L136-L143
train
Like dict but where the source key is special.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_abstract
def add_abstract(self, abstract, source=None): """Add abstract. :param abstract: abstract for the current document. :type abstract: string :param source: source for the given abstract. :type source: string """ self._append_to('abstracts', self._sourced_dict( ...
python
def add_abstract(self, abstract, source=None): """Add abstract. :param abstract: abstract for the current document. :type abstract: string :param source: source for the given abstract. :type source: string """ self._append_to('abstracts', self._sourced_dict( ...
[ "def", "add_abstract", "(", "self", ",", "abstract", ",", "source", "=", "None", ")", ":", "self", ".", "_append_to", "(", "'abstracts'", ",", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "abstract", ".", "strip", "(", ")", ",", ")",...
Add abstract. :param abstract: abstract for the current document. :type abstract: string :param source: source for the given abstract. :type source: string
[ "Add", "abstract", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L150-L162
train
Add an abstract to the current document.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_arxiv_eprint
def add_arxiv_eprint(self, arxiv_id, arxiv_categories): """Add arxiv eprint. :param arxiv_id: arxiv id for the current document. :type arxiv_id: string :param arxiv_categories: arXiv categories for the current document. :type arxiv_categories: list """ self._app...
python
def add_arxiv_eprint(self, arxiv_id, arxiv_categories): """Add arxiv eprint. :param arxiv_id: arxiv id for the current document. :type arxiv_id: string :param arxiv_categories: arXiv categories for the current document. :type arxiv_categories: list """ self._app...
[ "def", "add_arxiv_eprint", "(", "self", ",", "arxiv_id", ",", "arxiv_categories", ")", ":", "self", ".", "_append_to", "(", "'arxiv_eprints'", ",", "{", "'value'", ":", "arxiv_id", ",", "'categories'", ":", "arxiv_categories", ",", "}", ")", "self", ".", "se...
Add arxiv eprint. :param arxiv_id: arxiv id for the current document. :type arxiv_id: string :param arxiv_categories: arXiv categories for the current document. :type arxiv_categories: list
[ "Add", "arxiv", "eprint", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L165-L178
train
Add arxiv eprint.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_doi
def add_doi(self, doi, source=None, material=None): """Add doi. :param doi: doi for the current document. :type doi: string :param source: source for the doi. :type source: string :param material: material for the doi. :type material: string """ ...
python
def add_doi(self, doi, source=None, material=None): """Add doi. :param doi: doi for the current document. :type doi: string :param source: source for the doi. :type source: string :param material: material for the doi. :type material: string """ ...
[ "def", "add_doi", "(", "self", ",", "doi", ",", "source", "=", "None", ",", "material", "=", "None", ")", ":", "if", "doi", "is", "None", ":", "return", "try", ":", "doi", "=", "idutils", ".", "normalize_doi", "(", "doi", ")", "except", "AttributeErr...
Add doi. :param doi: doi for the current document. :type doi: string :param source: source for the doi. :type source: string :param material: material for the doi. :type material: string
[ "Add", "doi", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L181-L211
train
Add a DOI to the current document.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.make_author
def make_author(self, full_name, affiliations=(), roles=(), raw_affiliations=(), source=None, ids=(), emails=(), alternative_names=()): """Make a subrecord representing an ...
python
def make_author(self, full_name, affiliations=(), roles=(), raw_affiliations=(), source=None, ids=(), emails=(), alternative_names=()): """Make a subrecord representing an ...
[ "def", "make_author", "(", "self", ",", "full_name", ",", "affiliations", "=", "(", ")", ",", "roles", "=", "(", ")", ",", "raw_affiliations", "=", "(", ")", ",", "source", "=", "None", ",", "ids", "=", "(", ")", ",", "emails", "=", "(", ")", ","...
Make a subrecord representing an author. Args: full_name(str): full name of the author. If not yet in standard Inspire form, it will be normalized. affiliations(List[str]): Inspire normalized affiliations of the author. roles(List[str]): Inspi...
[ "Make", "a", "subrecord", "representing", "an", "author", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L224-L273
train
Make a subrecord representing an author.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_book
def add_book(self, publisher=None, place=None, date=None): """ Make a dictionary that is representing a book. :param publisher: publisher name :type publisher: string :param place: place of publication :type place: string :param date: A (partial) date in any f...
python
def add_book(self, publisher=None, place=None, date=None): """ Make a dictionary that is representing a book. :param publisher: publisher name :type publisher: string :param place: place of publication :type place: string :param date: A (partial) date in any f...
[ "def", "add_book", "(", "self", ",", "publisher", "=", "None", ",", "place", "=", "None", ",", "date", "=", "None", ")", ":", "imprint", "=", "{", "}", "if", "date", "is", "not", "None", ":", "imprint", "[", "'date'", "]", "=", "normalize_date", "(...
Make a dictionary that is representing a book. :param publisher: publisher name :type publisher: string :param place: place of publication :type place: string :param date: A (partial) date in any format. The date should contain at least a year :type date: ...
[ "Make", "a", "dictionary", "that", "is", "representing", "a", "book", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L276-L302
train
Add a new entry to the internal list of the imprints.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_isbn
def add_isbn(self, isbn, medium=None): """ :param isbns: the isbns of the book :type isbns: object """ isbn_dict = {} if isbn is not None: isbn_dict['value'] = normalize_isbn(isbn) if medium is not None: isbn_dict['medium'] = medium ...
python
def add_isbn(self, isbn, medium=None): """ :param isbns: the isbns of the book :type isbns: object """ isbn_dict = {} if isbn is not None: isbn_dict['value'] = normalize_isbn(isbn) if medium is not None: isbn_dict['medium'] = medium ...
[ "def", "add_isbn", "(", "self", ",", "isbn", ",", "medium", "=", "None", ")", ":", "isbn_dict", "=", "{", "}", "if", "isbn", "is", "not", "None", ":", "isbn_dict", "[", "'value'", "]", "=", "normalize_isbn", "(", "isbn", ")", "if", "medium", "is", ...
:param isbns: the isbns of the book :type isbns: object
[ ":", "param", "isbns", ":", "the", "isbns", "of", "the", "book", ":", "type", "isbns", ":", "object" ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L305-L316
train
Adds an ISBN to the isbns list.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_book_series
def add_book_series(self, title, volume=None): """ :param volume: the volume of the book :type volume: string :param title: the title of the book :type title: string """ book_series = {} if title is not None: book_series['title'] = title ...
python
def add_book_series(self, title, volume=None): """ :param volume: the volume of the book :type volume: string :param title: the title of the book :type title: string """ book_series = {} if title is not None: book_series['title'] = title ...
[ "def", "add_book_series", "(", "self", ",", "title", ",", "volume", "=", "None", ")", ":", "book_series", "=", "{", "}", "if", "title", "is", "not", "None", ":", "book_series", "[", "'title'", "]", "=", "title", "if", "volume", "is", "not", "None", "...
:param volume: the volume of the book :type volume: string :param title: the title of the book :type title: string
[ ":", "param", "volume", ":", "the", "volume", "of", "the", "book", ":", "type", "volume", ":", "string" ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L319-L333
train
Adds a book series to the book_series attribute
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_inspire_categories
def add_inspire_categories(self, subject_terms, source=None): """Add inspire categories. :param subject_terms: user categories for the current document. :type subject_terms: list :param source: source for the given categories. :type source: string """ for catego...
python
def add_inspire_categories(self, subject_terms, source=None): """Add inspire categories. :param subject_terms: user categories for the current document. :type subject_terms: list :param source: source for the given categories. :type source: string """ for catego...
[ "def", "add_inspire_categories", "(", "self", ",", "subject_terms", ",", "source", "=", "None", ")", ":", "for", "category", "in", "subject_terms", ":", "category_dict", "=", "self", ".", "_sourced_dict", "(", "source", ",", "term", "=", "category", ",", ")"...
Add inspire categories. :param subject_terms: user categories for the current document. :type subject_terms: list :param source: source for the given categories. :type source: string
[ "Add", "inspire", "categories", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L344-L358
train
Add inspire categories for the given subject terms.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_keyword
def add_keyword(self, keyword, schema=None, source=None): """Add a keyword. Args: keyword(str): keyword to add. schema(str): schema to which the keyword belongs. source(str): source for the keyword. """ keyword_dict = self._sourced_dict(source, value=...
python
def add_keyword(self, keyword, schema=None, source=None): """Add a keyword. Args: keyword(str): keyword to add. schema(str): schema to which the keyword belongs. source(str): source for the keyword. """ keyword_dict = self._sourced_dict(source, value=...
[ "def", "add_keyword", "(", "self", ",", "keyword", ",", "schema", "=", "None", ",", "source", "=", "None", ")", ":", "keyword_dict", "=", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "keyword", ")", "if", "schema", "is", "not", "None...
Add a keyword. Args: keyword(str): keyword to add. schema(str): schema to which the keyword belongs. source(str): source for the keyword.
[ "Add", "a", "keyword", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L361-L374
train
Add a keyword to the internal dictionary.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_private_note
def add_private_note(self, private_notes, source=None): """Add private notes. :param private_notes: hidden notes for the current document :type private_notes: string :param source: source for the given private notes :type source: string """ self._append_to('_pri...
python
def add_private_note(self, private_notes, source=None): """Add private notes. :param private_notes: hidden notes for the current document :type private_notes: string :param source: source for the given private notes :type source: string """ self._append_to('_pri...
[ "def", "add_private_note", "(", "self", ",", "private_notes", ",", "source", "=", "None", ")", ":", "self", ".", "_append_to", "(", "'_private_notes'", ",", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "private_notes", ",", ")", ")" ]
Add private notes. :param private_notes: hidden notes for the current document :type private_notes: string :param source: source for the given private notes :type source: string
[ "Add", "private", "notes", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L377-L389
train
Add private notes.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_publication_info
def add_publication_info( self, year=None, cnum=None, artid=None, page_end=None, page_start=None, journal_issue=None, journal_title=None, journal_volume=None, pubinfo_freetext=None, material=None, parent_record=None, ...
python
def add_publication_info( self, year=None, cnum=None, artid=None, page_end=None, page_start=None, journal_issue=None, journal_title=None, journal_volume=None, pubinfo_freetext=None, material=None, parent_record=None, ...
[ "def", "add_publication_info", "(", "self", ",", "year", "=", "None", ",", "cnum", "=", "None", ",", "artid", "=", "None", ",", "page_end", "=", "None", ",", "page_start", "=", "None", ",", "journal_issue", "=", "None", ",", "journal_title", "=", "None",...
Add publication info. :param year: year of publication :type year: integer :param cnum: inspire conference number :type cnum: string :param artid: article id :type artid: string :param page_end: final page for the article :type page_end: string ...
[ "Add", "publication", "info", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L392-L480
train
Add publication info to the internal record.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_thesis
def add_thesis( self, defense_date=None, degree_type=None, institution=None, date=None ): """Add thesis info. :param defense_date: defense date for the current thesis :type defense_date: string. A formatted date is required (yyyy-mm-dd) :para...
python
def add_thesis( self, defense_date=None, degree_type=None, institution=None, date=None ): """Add thesis info. :param defense_date: defense date for the current thesis :type defense_date: string. A formatted date is required (yyyy-mm-dd) :para...
[ "def", "add_thesis", "(", "self", ",", "defense_date", "=", "None", ",", "degree_type", "=", "None", ",", "institution", "=", "None", ",", "date", "=", "None", ")", ":", "self", ".", "record", ".", "setdefault", "(", "'thesis_info'", ",", "{", "}", ")"...
Add thesis info. :param defense_date: defense date for the current thesis :type defense_date: string. A formatted date is required (yyyy-mm-dd) :param degree_type: degree type for the current thesis :type degree_type: string :param institution: author's affiliation for the cur...
[ "Add", "thesis", "info", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L503-L537
train
Add a thesis info entry to the internal record.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_license
def add_license( self, url=None, license=None, material=None, imposing=None ): """Add license. :param url: url for the description of the license :type url: string :param license: license type :type license: string :param mat...
python
def add_license( self, url=None, license=None, material=None, imposing=None ): """Add license. :param url: url for the description of the license :type url: string :param license: license type :type license: string :param mat...
[ "def", "add_license", "(", "self", ",", "url", "=", "None", ",", "license", "=", "None", ",", "material", "=", "None", ",", "imposing", "=", "None", ")", ":", "hep_license", "=", "{", "}", "try", ":", "license_from_url", "=", "get_license_from_url", "(",...
Add license. :param url: url for the description of the license :type url: string :param license: license type :type license: string :param material: material type :type material: string :param imposing: imposing type :type imposing: string
[ "Add", "license", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L559-L593
train
Add license to the internal list.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_public_note
def add_public_note(self, public_note, source=None): """Add public note. :param public_note: public note for the current article. :type public_note: string :param source: source for the given notes. :type source: string """ self._append_to('public_notes', self._...
python
def add_public_note(self, public_note, source=None): """Add public note. :param public_note: public note for the current article. :type public_note: string :param source: source for the given notes. :type source: string """ self._append_to('public_notes', self._...
[ "def", "add_public_note", "(", "self", ",", "public_note", ",", "source", "=", "None", ")", ":", "self", ".", "_append_to", "(", "'public_notes'", ",", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "public_note", ",", ")", ")" ]
Add public note. :param public_note: public note for the current article. :type public_note: string :param source: source for the given notes. :type source: string
[ "Add", "public", "note", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L596-L608
train
Add public note.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_title
def add_title(self, title, subtitle=None, source=None): """Add title. :param title: title for the current document :type title: string :param subtitle: subtitle for the current document :type subtitle: string :param source: source for the given title :type sour...
python
def add_title(self, title, subtitle=None, source=None): """Add title. :param title: title for the current document :type title: string :param subtitle: subtitle for the current document :type subtitle: string :param source: source for the given title :type sour...
[ "def", "add_title", "(", "self", ",", "title", ",", "subtitle", "=", "None", ",", "source", "=", "None", ")", ":", "title_entry", "=", "self", ".", "_sourced_dict", "(", "source", ",", "title", "=", "title", ",", ")", "if", "subtitle", "is", "not", "...
Add title. :param title: title for the current document :type title: string :param subtitle: subtitle for the current document :type subtitle: string :param source: source for the given title :type source: string
[ "Add", "title", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L611-L630
train
Add a title to the list of titles.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_title_translation
def add_title_translation(self, title, language, source=None): """Add title translation. :param title: translated title :type title: string :param language: language for the original title :type language: string (2 characters ISO639-1) :param source: source for the giv...
python
def add_title_translation(self, title, language, source=None): """Add title translation. :param title: translated title :type title: string :param language: language for the original title :type language: string (2 characters ISO639-1) :param source: source for the giv...
[ "def", "add_title_translation", "(", "self", ",", "title", ",", "language", ",", "source", "=", "None", ")", ":", "title_translation", "=", "self", ".", "_sourced_dict", "(", "source", ",", "title", "=", "title", ",", "language", "=", "language", ",", ")",...
Add title translation. :param title: translated title :type title: string :param language: language for the original title :type language: string (2 characters ISO639-1) :param source: source for the given title :type source: string
[ "Add", "title", "translation", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L633-L651
train
Add a title translation.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_report_number
def add_report_number(self, report_number, source=None): """Add report numbers. :param report_number: report number for the current document :type report_number: string :param source: source for the given report number :type source: string """ self._append_to('r...
python
def add_report_number(self, report_number, source=None): """Add report numbers. :param report_number: report number for the current document :type report_number: string :param source: source for the given report number :type source: string """ self._append_to('r...
[ "def", "add_report_number", "(", "self", ",", "report_number", ",", "source", "=", "None", ")", ":", "self", ".", "_append_to", "(", "'report_numbers'", ",", "self", ".", "_sourced_dict", "(", "source", ",", "value", "=", "report_number", ",", ")", ")" ]
Add report numbers. :param report_number: report number for the current document :type report_number: string :param source: source for the given report number :type source: string
[ "Add", "report", "numbers", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L665-L677
train
Adds a report number to the report numbers list.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_collaboration
def add_collaboration(self, collaboration): """Add collaboration. :param collaboration: collaboration for the current document :type collaboration: string """ collaborations = normalize_collaboration(collaboration) for collaboration in collaborations: self._a...
python
def add_collaboration(self, collaboration): """Add collaboration. :param collaboration: collaboration for the current document :type collaboration: string """ collaborations = normalize_collaboration(collaboration) for collaboration in collaborations: self._a...
[ "def", "add_collaboration", "(", "self", ",", "collaboration", ")", ":", "collaborations", "=", "normalize_collaboration", "(", "collaboration", ")", "for", "collaboration", "in", "collaborations", ":", "self", ".", "_append_to", "(", "'collaborations'", ",", "{", ...
Add collaboration. :param collaboration: collaboration for the current document :type collaboration: string
[ "Add", "collaboration", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L680-L690
train
Add a collaboration to the list of collaborations for the current document.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_acquisition_source
def add_acquisition_source( self, method, date=None, submission_number=None, internal_uid=None, email=None, orcid=None, source=None, datetime=None, ): """Add acquisition source. :type submission_number: integer :type e...
python
def add_acquisition_source( self, method, date=None, submission_number=None, internal_uid=None, email=None, orcid=None, source=None, datetime=None, ): """Add acquisition source. :type submission_number: integer :type e...
[ "def", "add_acquisition_source", "(", "self", ",", "method", ",", "date", "=", "None", ",", "submission_number", "=", "None", ",", "internal_uid", "=", "None", ",", "email", "=", "None", ",", "orcid", "=", "None", ",", "source", "=", "None", ",", "dateti...
Add acquisition source. :type submission_number: integer :type email: integer :type source: string :param date: UTC date in isoformat .. deprecated:: 30.1.0 Use ``datetime`` instead. :type date: string :param method: meth...
[ "Add", "acquisition", "source", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L693-L743
train
Add an acquisition source to the record.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_copyright
def add_copyright( self, material=None, holder=None, statement=None, url=None, year=None ): """Add Copyright. :type material: string :type holder: string :type statement: string :type url: string :type year: int ...
python
def add_copyright( self, material=None, holder=None, statement=None, url=None, year=None ): """Add Copyright. :type material: string :type holder: string :type statement: string :type url: string :type year: int ...
[ "def", "add_copyright", "(", "self", ",", "material", "=", "None", ",", "holder", "=", "None", ",", "statement", "=", "None", ",", "url", "=", "None", ",", "year", "=", "None", ")", ":", "copyright", "=", "{", "}", "for", "key", "in", "(", "'holder...
Add Copyright. :type material: string :type holder: string :type statement: string :type url: string :type year: int
[ "Add", "Copyright", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L754-L785
train
Add Copyright.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_figure
def add_figure(self, key, url, **kwargs): """Add a figure. Args: key (string): document key url (string): document url Keyword Args: caption (string): simple description label (string): material (string): original_url (stri...
python
def add_figure(self, key, url, **kwargs): """Add a figure. Args: key (string): document key url (string): document url Keyword Args: caption (string): simple description label (string): material (string): original_url (stri...
[ "def", "add_figure", "(", "self", ",", "key", ",", "url", ",", "*", "*", "kwargs", ")", ":", "figure", "=", "self", ".", "_check_metadata_for_file", "(", "key", "=", "key", ",", "url", "=", "url", ",", "*", "*", "kwargs", ")", "for", "dict_key", "i...
Add a figure. Args: key (string): document key url (string): document url Keyword Args: caption (string): simple description label (string): material (string): original_url (string): original url filename (string): curr...
[ "Add", "a", "figure", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L863-L899
train
Add a figure to the record.
inspirehep/inspire-schemas
inspire_schemas/builders/literature.py
LiteratureBuilder.add_document
def add_document(self, key, url, **kwargs): """ Adds document to record Args: key (string): document key url (string): document url Keyword Args: description (string): simple description fulltext (bool): mark if this is a full text ...
python
def add_document(self, key, url, **kwargs): """ Adds document to record Args: key (string): document key url (string): document url Keyword Args: description (string): simple description fulltext (bool): mark if this is a full text ...
[ "def", "add_document", "(", "self", ",", "key", ",", "url", ",", "*", "*", "kwargs", ")", ":", "document", "=", "self", ".", "_check_metadata_for_file", "(", "key", "=", "key", ",", "url", "=", "url", ",", "*", "*", "kwargs", ")", "for", "dict_key", ...
Adds document to record Args: key (string): document key url (string): document url Keyword Args: description (string): simple description fulltext (bool): mark if this is a full text hidden (bool): is document should be hidden mate...
[ "Adds", "document", "to", "record", "Args", ":", "key", "(", "string", ")", ":", "document", "key", "url", "(", "string", ")", ":", "document", "url", "Keyword", "Args", ":", "description", "(", "string", ")", ":", "simple", "description", "fulltext", "(...
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L902-L940
train
Adds a document to the record.
guaix-ucm/numina
numina/array/offrot.py
fit_offset_and_rotation
def fit_offset_and_rotation(coords0, coords1): """Fit a rotation and a traslation between two sets points. Fit a rotation matrix and a traslation bewtween two matched sets consisting of M N-dimensional points Parameters ---------- coords0 : (M, N) array_like coords1 : (M, N) array_lke ...
python
def fit_offset_and_rotation(coords0, coords1): """Fit a rotation and a traslation between two sets points. Fit a rotation matrix and a traslation bewtween two matched sets consisting of M N-dimensional points Parameters ---------- coords0 : (M, N) array_like coords1 : (M, N) array_lke ...
[ "def", "fit_offset_and_rotation", "(", "coords0", ",", "coords1", ")", ":", "coords0", "=", "numpy", ".", "asarray", "(", "coords0", ")", "coords1", "=", "numpy", ".", "asarray", "(", "coords1", ")", "cp", "=", "coords0", ".", "mean", "(", "axis", "=", ...
Fit a rotation and a traslation between two sets points. Fit a rotation matrix and a traslation bewtween two matched sets consisting of M N-dimensional points Parameters ---------- coords0 : (M, N) array_like coords1 : (M, N) array_lke Returns ------- offset : (N, ) array_like ...
[ "Fit", "a", "rotation", "and", "a", "traslation", "between", "two", "sets", "points", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/offrot.py#L17-L71
train
Fit a rotation matrix and a traslation between two matched sets points.
ponty/eagexp
eagexp/image3d.py
export_image3d
def export_image3d(input, output, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False): ''' Exporting eagle .brd file into 3D image file using Eagle3D and povray. GUI is not displayed if ``pyvirtualdisplay`` is installed. If export is blocked somehow (e.g. popup window is displayed) the...
python
def export_image3d(input, output, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False): ''' Exporting eagle .brd file into 3D image file using Eagle3D and povray. GUI is not displayed if ``pyvirtualdisplay`` is installed. If export is blocked somehow (e.g. popup window is displayed) the...
[ "def", "export_image3d", "(", "input", ",", "output", ",", "size", "=", "(", "800", ",", "600", ")", ",", "pcb_rotate", "=", "(", "0", ",", "0", ",", "0", ")", ",", "timeout", "=", "20", ",", "showgui", "=", "False", ")", ":", "input", "=", "no...
Exporting eagle .brd file into 3D image file using Eagle3D and povray. GUI is not displayed if ``pyvirtualdisplay`` is installed. If export is blocked somehow (e.g. popup window is displayed) then after timeout operation is canceled with exception. Problem can be investigated by setting 'showgui' flag. ...
[ "Exporting", "eagle", ".", "brd", "file", "into", "3D", "image", "file", "using", "Eagle3D", "and", "povray", ".", "GUI", "is", "not", "displayed", "if", "pyvirtualdisplay", "is", "installed", ".", "If", "export", "is", "blocked", "somehow", "(", "e", ".",...
1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2
https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/image3d.py#L17-L77
train
Export an eagle. brd file into 3D image file.
ponty/eagexp
eagexp/image3d.py
pil_image3d
def pil_image3d(input, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False): ''' same as export_image3d, but there is no output file, PIL object is returned instead ''' f = tempfile.NamedTemporaryFile(suffix='.png', prefix='eagexp_') output = f.name export_image3d(input, output=out...
python
def pil_image3d(input, size=(800, 600), pcb_rotate=(0, 0, 0), timeout=20, showgui=False): ''' same as export_image3d, but there is no output file, PIL object is returned instead ''' f = tempfile.NamedTemporaryFile(suffix='.png', prefix='eagexp_') output = f.name export_image3d(input, output=out...
[ "def", "pil_image3d", "(", "input", ",", "size", "=", "(", "800", ",", "600", ")", ",", "pcb_rotate", "=", "(", "0", ",", "0", ",", "0", ")", ",", "timeout", "=", "20", ",", "showgui", "=", "False", ")", ":", "f", "=", "tempfile", ".", "NamedTe...
same as export_image3d, but there is no output file, PIL object is returned instead
[ "same", "as", "export_image3d", "but", "there", "is", "no", "output", "file", "PIL", "object", "is", "returned", "instead" ]
1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2
https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/image3d.py#L80-L91
train
same as export_image3d but returns PIL object instead
guaix-ucm/numina
numina/dal/mockdal.py
MockDAL.search_prod_type_tags
def search_prod_type_tags(self, ins, type, tags, pipeline): '''Returns the first coincidence...''' return StoredProduct(id=100, content='null.fits', tags={})
python
def search_prod_type_tags(self, ins, type, tags, pipeline): '''Returns the first coincidence...''' return StoredProduct(id=100, content='null.fits', tags={})
[ "def", "search_prod_type_tags", "(", "self", ",", "ins", ",", "type", ",", "tags", ",", "pipeline", ")", ":", "return", "StoredProduct", "(", "id", "=", "100", ",", "content", "=", "'null.fits'", ",", "tags", "=", "{", "}", ")" ]
Returns the first coincidence...
[ "Returns", "the", "first", "coincidence", "..." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/dal/mockdal.py#L32-L34
train
Returns the first coincidence for a given product type and tags
guaix-ucm/numina
numina/array/display/polfit_residuals.py
polfit_residuals
def polfit_residuals( x, y, deg, reject=None, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=False, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with display of residuals and additional work with R. Parame...
python
def polfit_residuals( x, y, deg, reject=None, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=False, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with display of residuals and additional work with R. Parame...
[ "def", "polfit_residuals", "(", "x", ",", "y", ",", "deg", ",", "reject", "=", "None", ",", "color", "=", "'b'", ",", "size", "=", "75", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "=", "None", ...
Polynomial fit with display of residuals and additional work with R. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy array, float Y coordinates of the data being fitted. deg : int Degree of the fitting polynomial. reje...
[ "Polynomial", "fit", "with", "display", "of", "residuals", "and", "additional", "work", "with", "R", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/polfit_residuals.py#L21-L281
train
Polynomial fit with display of residuals and additional work with R.
guaix-ucm/numina
numina/array/display/polfit_residuals.py
polfit_residuals_with_sigma_rejection
def polfit_residuals_with_sigma_rejection( x, y, deg, times_sigma_reject, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=None, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with iterative rejection of points. ...
python
def polfit_residuals_with_sigma_rejection( x, y, deg, times_sigma_reject, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=None, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with iterative rejection of points. ...
[ "def", "polfit_residuals_with_sigma_rejection", "(", "x", ",", "y", ",", "deg", ",", "times_sigma_reject", ",", "color", "=", "'b'", ",", "size", "=", "75", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", ...
Polynomial fit with iterative rejection of points. This function makes use of function polfit_residuals for display purposes. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy array, float Y coordinates of the data being fitted...
[ "Polynomial", "fit", "with", "iterative", "rejection", "of", "points", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/polfit_residuals.py#L284-L460
train
Polynomial fit with iterative rejection of points.
guaix-ucm/numina
numina/array/display/polfit_residuals.py
polfit_residuals_with_cook_rejection
def polfit_residuals_with_cook_rejection( x, y, deg, times_sigma_cook, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=None, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with iterative rejection of points. ...
python
def polfit_residuals_with_cook_rejection( x, y, deg, times_sigma_cook, color='b', size=75, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, use_r=None, geometry=(0,0,640,480), debugplot=0): """Polynomial fit with iterative rejection of points. ...
[ "def", "polfit_residuals_with_cook_rejection", "(", "x", ",", "y", ",", "deg", ",", "times_sigma_cook", ",", "color", "=", "'b'", ",", "size", "=", "75", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "="...
Polynomial fit with iterative rejection of points. This function makes use of function polfit_residuals for display purposes. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy array, float Y coordinates of the data being fitted...
[ "Polynomial", "fit", "with", "iterative", "rejection", "of", "points", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/polfit_residuals.py#L463-L658
train
Polynomial fit with iterative rejection of points.
pylp/pylp
pylp/cli/logger.py
_make_color_fn
def _make_color_fn(color): """Create a function that set the foreground color.""" def _color(text = ""): return (_color_sep + color + _color_sep2 + text + _color_sep + "default" + _color_sep2) return _color
python
def _make_color_fn(color): """Create a function that set the foreground color.""" def _color(text = ""): return (_color_sep + color + _color_sep2 + text + _color_sep + "default" + _color_sep2) return _color
[ "def", "_make_color_fn", "(", "color", ")", ":", "def", "_color", "(", "text", "=", "\"\"", ")", ":", "return", "(", "_color_sep", "+", "color", "+", "_color_sep2", "+", "text", "+", "_color_sep", "+", "\"default\"", "+", "_color_sep2", ")", "return", "_...
Create a function that set the foreground color.
[ "Create", "a", "function", "that", "set", "the", "foreground", "color", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L21-L26
train
Create a function that sets the foreground color.
pylp/pylp
pylp/cli/logger.py
just_log
def just_log(*texts, sep = ""): """Log a text without adding the current time.""" if config.silent: return text = _color_sep + "default" + _color_sep2 + sep.join(texts) array = text.split(_color_sep) for part in array: parts = part.split(_color_sep2, 1) if len(parts) != 2 or not parts[1]: continue if...
python
def just_log(*texts, sep = ""): """Log a text without adding the current time.""" if config.silent: return text = _color_sep + "default" + _color_sep2 + sep.join(texts) array = text.split(_color_sep) for part in array: parts = part.split(_color_sep2, 1) if len(parts) != 2 or not parts[1]: continue if...
[ "def", "just_log", "(", "*", "texts", ",", "sep", "=", "\"\"", ")", ":", "if", "config", ".", "silent", ":", "return", "text", "=", "_color_sep", "+", "\"default\"", "+", "_color_sep2", "+", "sep", ".", "join", "(", "texts", ")", "array", "=", "text"...
Log a text without adding the current time.
[ "Log", "a", "text", "without", "adding", "the", "current", "time", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L34-L55
train
Log a text without adding the current time.
pylp/pylp
pylp/cli/logger.py
log
def log(*texts, sep = ""): """Log a text.""" text = sep.join(texts) count = text.count("\n") just_log("\n" * count, *get_time(), text.replace("\n", ""), sep=sep)
python
def log(*texts, sep = ""): """Log a text.""" text = sep.join(texts) count = text.count("\n") just_log("\n" * count, *get_time(), text.replace("\n", ""), sep=sep)
[ "def", "log", "(", "*", "texts", ",", "sep", "=", "\"\"", ")", ":", "text", "=", "sep", ".", "join", "(", "texts", ")", "count", "=", "text", ".", "count", "(", "\"\\n\"", ")", "just_log", "(", "\"\\n\"", "*", "count", ",", "*", "get_time", "(", ...
Log a text.
[ "Log", "a", "text", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/logger.py#L63-L67
train
Log a text.
pylp/pylp
pylp/lib/src.py
find_files
def find_files(globs): """Find files to include.""" last_cwd = os.getcwd() os.chdir(config.cwd) gex, gin = separate_globs(globs) # Find excluded files exclude = [] for glob in gex: parse_glob(glob, exclude) files = [] include = [] order = 0 # Find included files and removed excluded files for glob in...
python
def find_files(globs): """Find files to include.""" last_cwd = os.getcwd() os.chdir(config.cwd) gex, gin = separate_globs(globs) # Find excluded files exclude = [] for glob in gex: parse_glob(glob, exclude) files = [] include = [] order = 0 # Find included files and removed excluded files for glob in...
[ "def", "find_files", "(", "globs", ")", ":", "last_cwd", "=", "os", ".", "getcwd", "(", ")", "os", ".", "chdir", "(", "config", ".", "cwd", ")", "gex", ",", "gin", "=", "separate_globs", "(", "globs", ")", "# Find excluded files", "exclude", "=", "[", ...
Find files to include.
[ "Find", "files", "to", "include", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/src.py#L17-L45
train
Find files to include and exclude.
pylp/pylp
pylp/lib/src.py
src
def src(globs, **options): """Read some files and return a stream.""" # Create an array of globs if only one string is given if isinstance(globs, str): globs = [ globs ] # Find files files = find_files(globs) # Create a stream stream = Stream() # Options options["cwd"] = config.cwd if "base" in options...
python
def src(globs, **options): """Read some files and return a stream.""" # Create an array of globs if only one string is given if isinstance(globs, str): globs = [ globs ] # Find files files = find_files(globs) # Create a stream stream = Stream() # Options options["cwd"] = config.cwd if "base" in options...
[ "def", "src", "(", "globs", ",", "*", "*", "options", ")", ":", "# Create an array of globs if only one string is given", "if", "isinstance", "(", "globs", ",", "str", ")", ":", "globs", "=", "[", "globs", "]", "# Find files", "files", "=", "find_files", "(", ...
Read some files and return a stream.
[ "Read", "some", "files", "and", "return", "a", "stream", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/src.py#L49-L82
train
Read some files and return a stream.
zzyztyy/pyIGRF
pyIGRF/value.py
igrf_value
def igrf_value(lat, lon, alt=0., year=2005.): """ :return D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total intensity """ ...
python
def igrf_value(lat, lon, alt=0., year=2005.): """ :return D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total intensity """ ...
[ "def", "igrf_value", "(", "lat", ",", "lon", ",", "alt", "=", "0.", ",", "year", "=", "2005.", ")", ":", "X", ",", "Y", ",", "Z", ",", "F", "=", "calculate", ".", "igrf12syn", "(", "0", ",", "year", ",", "1", ",", "alt", ",", "lat", ",", "l...
:return D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total intensity
[ ":", "return", "D", "is", "declination", "(", "+", "ve", "east", ")", "I", "is", "inclination", "(", "+", "ve", "down", ")", "H", "is", "horizontal", "intensity", "X", "is", "north", "component", "Y", "is", "east", "component", "Z", "is", "vertical", ...
3369ccafec34d18ca2c57f48b867cb2417078866
https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/value.py#L8-L23
train
Returns the value of the IGRF for a given location.
zzyztyy/pyIGRF
pyIGRF/value.py
igrf_variation
def igrf_variation(lat, lon, alt=0., year=2005): """ Annual variation D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total inten...
python
def igrf_variation(lat, lon, alt=0., year=2005): """ Annual variation D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total inten...
[ "def", "igrf_variation", "(", "lat", ",", "lon", ",", "alt", "=", "0.", ",", "year", "=", "2005", ")", ":", "X", ",", "Y", ",", "Z", ",", "F", "=", "calculate", ".", "igrf12syn", "(", "0", ",", "year", ",", "1", ",", "alt", ",", "lat", ",", ...
Annual variation D is declination (+ve east) I is inclination (+ve down) H is horizontal intensity X is north component Y is east component Z is vertical component (+ve down) F is total intensity
[ "Annual", "variation", "D", "is", "declination", "(", "+", "ve", "east", ")", "I", "is", "inclination", "(", "+", "ve", "down", ")", "H", "is", "horizontal", "intensity", "X", "is", "north", "component", "Y", "is", "east", "component", "Z", "is", "vert...
3369ccafec34d18ca2c57f48b867cb2417078866
https://github.com/zzyztyy/pyIGRF/blob/3369ccafec34d18ca2c57f48b867cb2417078866/pyIGRF/value.py#L26-L44
train
Calculate the annual variation of the IGRF at a given location.
guaix-ucm/numina
numina/logger.py
log_to_history
def log_to_history(logger, name): """Decorate function, adding a logger handler stored in FITS.""" def log_to_history_decorator(method): def l2h_method(self, ri): history_header = fits.Header() fh = FITSHistoryHandler(history_header) fh.setLevel(logging.INFO) ...
python
def log_to_history(logger, name): """Decorate function, adding a logger handler stored in FITS.""" def log_to_history_decorator(method): def l2h_method(self, ri): history_header = fits.Header() fh = FITSHistoryHandler(history_header) fh.setLevel(logging.INFO) ...
[ "def", "log_to_history", "(", "logger", ",", "name", ")", ":", "def", "log_to_history_decorator", "(", "method", ")", ":", "def", "l2h_method", "(", "self", ",", "ri", ")", ":", "history_header", "=", "fits", ".", "Header", "(", ")", "fh", "=", "FITSHist...
Decorate function, adding a logger handler stored in FITS.
[ "Decorate", "function", "adding", "a", "logger", "handler", "stored", "in", "FITS", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/logger.py#L30-L54
train
Decorate function adding a logger handler stored in FITS.
guaix-ucm/numina
numina/types/base.py
DataTypeBase.create_db_info
def create_db_info(): """Create metadata structure""" result = {} result['instrument'] = '' result['uuid'] = '' result['tags'] = {} result['type'] = '' result['mode'] = '' result['observation_date'] = "" result['origin'] = {} return result
python
def create_db_info(): """Create metadata structure""" result = {} result['instrument'] = '' result['uuid'] = '' result['tags'] = {} result['type'] = '' result['mode'] = '' result['observation_date'] = "" result['origin'] = {} return result
[ "def", "create_db_info", "(", ")", ":", "result", "=", "{", "}", "result", "[", "'instrument'", "]", "=", "''", "result", "[", "'uuid'", "]", "=", "''", "result", "[", "'tags'", "]", "=", "{", "}", "result", "[", "'type'", "]", "=", "''", "result",...
Create metadata structure
[ "Create", "metadata", "structure" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/base.py#L151-L161
train
Create metadata structure
pylp/pylp
pylp/utils/decorators.py
task
def task(obj = None, deps = None): """Decorator for creating a task.""" # The decorator is not used as a function if callable(obj): __task(obj.__name__, obj) return obj # The decorator is used as a function def __decorated(func): __task(obj if obj else obj.__name__, deps, func) return func return __deco...
python
def task(obj = None, deps = None): """Decorator for creating a task.""" # The decorator is not used as a function if callable(obj): __task(obj.__name__, obj) return obj # The decorator is used as a function def __decorated(func): __task(obj if obj else obj.__name__, deps, func) return func return __deco...
[ "def", "task", "(", "obj", "=", "None", ",", "deps", "=", "None", ")", ":", "# The decorator is not used as a function", "if", "callable", "(", "obj", ")", ":", "__task", "(", "obj", ".", "__name__", ",", "obj", ")", "return", "obj", "# The decorator is used...
Decorator for creating a task.
[ "Decorator", "for", "creating", "a", "task", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/decorators.py#L18-L30
train
Decorator for creating a task.
rfk/playitagainsam
playitagainsam/recorder.py
Recorder._read_one_byte
def _read_one_byte(self, fd): """Read a single byte, or raise OSError on failure.""" c = os.read(fd, 1) if not c: raise OSError return c
python
def _read_one_byte(self, fd): """Read a single byte, or raise OSError on failure.""" c = os.read(fd, 1) if not c: raise OSError return c
[ "def", "_read_one_byte", "(", "self", ",", "fd", ")", ":", "c", "=", "os", ".", "read", "(", "fd", ",", "1", ")", "if", "not", "c", ":", "raise", "OSError", "return", "c" ]
Read a single byte, or raise OSError on failure.
[ "Read", "a", "single", "byte", "or", "raise", "OSError", "on", "failure", "." ]
897cc8e8ca920a4afb8597b4a345361065a3f108
https://github.com/rfk/playitagainsam/blob/897cc8e8ca920a4afb8597b4a345361065a3f108/playitagainsam/recorder.py#L141-L146
train
Read a single byte from a file descriptor.
guaix-ucm/numina
numina/tools/arg_file_is_new.py
arg_file_is_new
def arg_file_is_new(parser, arg, mode='w'): """Auxiliary function to give an error if the file already exists. Parameters ---------- parser : parser object Instance of argparse.ArgumentParser() arg : string File name. mode : string Optional string that specifies the mode...
python
def arg_file_is_new(parser, arg, mode='w'): """Auxiliary function to give an error if the file already exists. Parameters ---------- parser : parser object Instance of argparse.ArgumentParser() arg : string File name. mode : string Optional string that specifies the mode...
[ "def", "arg_file_is_new", "(", "parser", ",", "arg", ",", "mode", "=", "'w'", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "arg", ")", ":", "parser", ".", "error", "(", "\"\\nThe file \\\"%s\\\"\\nalready exists and \"", "\"cannot be overwritten!\"", ...
Auxiliary function to give an error if the file already exists. Parameters ---------- parser : parser object Instance of argparse.ArgumentParser() arg : string File name. mode : string Optional string that specifies the mode in which the file is opened. Returns ...
[ "Auxiliary", "function", "to", "give", "an", "error", "if", "the", "file", "already", "exists", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/arg_file_is_new.py#L17-L42
train
Auxiliary function to give an error if the file already exists.
guaix-ucm/numina
numina/array/ccd_line.py
intersection_spectrail_arcline
def intersection_spectrail_arcline(spectrail, arcline): """Compute intersection of spectrum trail with arc line. Parameters ---------- spectrail : SpectrumTrail object Instance of SpectrumTrail class. arcline : ArcLine object Instance of ArcLine class Returns ------- xr...
python
def intersection_spectrail_arcline(spectrail, arcline): """Compute intersection of spectrum trail with arc line. Parameters ---------- spectrail : SpectrumTrail object Instance of SpectrumTrail class. arcline : ArcLine object Instance of ArcLine class Returns ------- xr...
[ "def", "intersection_spectrail_arcline", "(", "spectrail", ",", "arcline", ")", ":", "# approximate location of the solution", "expected_x", "=", "(", "arcline", ".", "xlower_line", "+", "arcline", ".", "xupper_line", ")", "/", "2.0", "# composition of polynomials to find...
Compute intersection of spectrum trail with arc line. Parameters ---------- spectrail : SpectrumTrail object Instance of SpectrumTrail class. arcline : ArcLine object Instance of ArcLine class Returns ------- xroot, yroot : tuple of floats (X,Y) coordinates of the i...
[ "Compute", "intersection", "of", "spectrum", "trail", "with", "arc", "line", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L250-L286
train
Compute intersection of spectrum trail with arc line.
guaix-ucm/numina
numina/array/ccd_line.py
CCDLine.fit
def fit(self, x, y, deg, w=None, y_vs_x=True, times_sigma_reject=None, title=None, debugplot=0): """Update the arc line from least squares fit to data. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy ar...
python
def fit(self, x, y, deg, w=None, y_vs_x=True, times_sigma_reject=None, title=None, debugplot=0): """Update the arc line from least squares fit to data. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy ar...
[ "def", "fit", "(", "self", ",", "x", ",", "y", ",", "deg", ",", "w", "=", "None", ",", "y_vs_x", "=", "True", ",", "times_sigma_reject", "=", "None", ",", "title", "=", "None", ",", "debugplot", "=", "0", ")", ":", "# protections", "if", "type", ...
Update the arc line from least squares fit to data. Parameters ---------- x : 1d numpy array, float X coordinates of the data being fitted. y : 1d numpy array, float Y coordinates of the data being fitted. deg : int Degree of the fitting polyn...
[ "Update", "the", "arc", "line", "from", "least", "squares", "fit", "to", "data", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L41-L148
train
Update the arc line from least squares fit to data.
guaix-ucm/numina
numina/array/ccd_line.py
CCDLine.linspace_pix
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=None): """Return x,y values evaluated with a given pixel step. The returned values are computed within the corresponding bounding box of the line. Parameters ---------- start : float Minimum ...
python
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=None): """Return x,y values evaluated with a given pixel step. The returned values are computed within the corresponding bounding box of the line. Parameters ---------- start : float Minimum ...
[ "def", "linspace_pix", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "pixel_step", "=", "1", ",", "y_vs_x", "=", "None", ")", ":", "if", "y_vs_x", ":", "if", "start", "is", "None", ":", "xmin", "=", "self", ".", "bb_nc1_ori...
Return x,y values evaluated with a given pixel step. The returned values are computed within the corresponding bounding box of the line. Parameters ---------- start : float Minimum pixel coordinate to evaluate the independent variable. stop : flo...
[ "Return", "x", "y", "values", "evaluated", "with", "a", "given", "pixel", "step", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L150-L203
train
Return x y values evaluated with a given pixel step.
guaix-ucm/numina
numina/array/ccd_line.py
CCDLine.offset
def offset(self, offset_value): """Return a copy of self, shifted a constant offset. Parameters ---------- offset_value : float Number of pixels to shift the CCDLine. """ new_instance = deepcopy(self) new_instance.poly_funct.coef[0] += offset_value ...
python
def offset(self, offset_value): """Return a copy of self, shifted a constant offset. Parameters ---------- offset_value : float Number of pixels to shift the CCDLine. """ new_instance = deepcopy(self) new_instance.poly_funct.coef[0] += offset_value ...
[ "def", "offset", "(", "self", ",", "offset_value", ")", ":", "new_instance", "=", "deepcopy", "(", "self", ")", "new_instance", ".", "poly_funct", ".", "coef", "[", "0", "]", "+=", "offset_value", "return", "new_instance" ]
Return a copy of self, shifted a constant offset. Parameters ---------- offset_value : float Number of pixels to shift the CCDLine.
[ "Return", "a", "copy", "of", "self", "shifted", "a", "constant", "offset", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L205-L217
train
Return a copy of self shifted a constant offset.
guaix-ucm/numina
numina/array/ccd_line.py
ArcLine.linspace_pix
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=False): """Return x,y values evaluated with a given pixel step.""" return CCDLine.linspace_pix(self, start=start, stop=stop, pixel_step=pixel_step, y_vs_x=y_vs_x)
python
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=False): """Return x,y values evaluated with a given pixel step.""" return CCDLine.linspace_pix(self, start=start, stop=stop, pixel_step=pixel_step, y_vs_x=y_vs_x)
[ "def", "linspace_pix", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "pixel_step", "=", "1", ",", "y_vs_x", "=", "False", ")", ":", "return", "CCDLine", ".", "linspace_pix", "(", "self", ",", "start", "=", "start", ",", "stop...
Return x,y values evaluated with a given pixel step.
[ "Return", "x", "y", "values", "evaluated", "with", "a", "given", "pixel", "step", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L229-L232
train
Return x y values evaluated with a given pixel step.
guaix-ucm/numina
numina/array/ccd_line.py
SpectrumTrail.linspace_pix
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=True): """Return x,y values evaluated with a given pixel step.""" return CCDLine.linspace_pix(self, start=start, stop=stop, pixel_step=pixel_step, y_vs_x=y_vs_x)
python
def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=True): """Return x,y values evaluated with a given pixel step.""" return CCDLine.linspace_pix(self, start=start, stop=stop, pixel_step=pixel_step, y_vs_x=y_vs_x)
[ "def", "linspace_pix", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "pixel_step", "=", "1", ",", "y_vs_x", "=", "True", ")", ":", "return", "CCDLine", ".", "linspace_pix", "(", "self", ",", "start", "=", "start", ",", "stop"...
Return x,y values evaluated with a given pixel step.
[ "Return", "x", "y", "values", "evaluated", "with", "a", "given", "pixel", "step", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L244-L247
train
Return x y values evaluated with a given pixel step.
guaix-ucm/numina
numina/tools/imath.py
compute_operation
def compute_operation(file1, file2, operation, output, display, args_z1z2, args_bbox, args_keystitle, args_geometry): """Compute output = file1 operation file2. Parameters ---------- file1 : file object First FITS file. file2 : file object Second FITS file. ...
python
def compute_operation(file1, file2, operation, output, display, args_z1z2, args_bbox, args_keystitle, args_geometry): """Compute output = file1 operation file2. Parameters ---------- file1 : file object First FITS file. file2 : file object Second FITS file. ...
[ "def", "compute_operation", "(", "file1", ",", "file2", ",", "operation", ",", "output", ",", "display", ",", "args_z1z2", ",", "args_bbox", ",", "args_keystitle", ",", "args_geometry", ")", ":", "# read first FITS file", "with", "fits", ".", "open", "(", "fil...
Compute output = file1 operation file2. Parameters ---------- file1 : file object First FITS file. file2 : file object Second FITS file. operation : string Mathematical operation. output : file object Output FITS file. display : string Character strin...
[ "Compute", "output", "=", "file1", "operation", "file2", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/tools/imath.py#L25-L111
train
Compute the output of a single Mathematical operation file1 and file2.
guaix-ucm/numina
numina/array/stats.py
robust_std
def robust_std(x, debug=False): """Compute a robust estimator of the standard deviation See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine in Astronomy, by Ivezic, Connolly, VanderPlas & Gray Parameters ---------- x : 1d numpy array, float Array of input values which standa...
python
def robust_std(x, debug=False): """Compute a robust estimator of the standard deviation See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine in Astronomy, by Ivezic, Connolly, VanderPlas & Gray Parameters ---------- x : 1d numpy array, float Array of input values which standa...
[ "def", "robust_std", "(", "x", ",", "debug", "=", "False", ")", ":", "x", "=", "numpy", ".", "asarray", "(", "x", ")", "# compute percentiles and robust estimator", "q25", "=", "numpy", ".", "percentile", "(", "x", ",", "25", ")", "q75", "=", "numpy", ...
Compute a robust estimator of the standard deviation See Eq. 3.36 (page 84) in Statistics, Data Mining, and Machine in Astronomy, by Ivezic, Connolly, VanderPlas & Gray Parameters ---------- x : 1d numpy array, float Array of input values which standard deviation is requested. debug : ...
[ "Compute", "a", "robust", "estimator", "of", "the", "standard", "deviation" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/stats.py#L17-L48
train
Compute a robust estimator of the standard deviation of a single object.
guaix-ucm/numina
numina/array/stats.py
summary
def summary(x, rm_nan=False, debug=False): """Compute basic statistical parameters. Parameters ---------- x : 1d numpy array, float Input array with values which statistical properties are requested. rm_nan : bool If True, filter out NaN values before computing statistics. ...
python
def summary(x, rm_nan=False, debug=False): """Compute basic statistical parameters. Parameters ---------- x : 1d numpy array, float Input array with values which statistical properties are requested. rm_nan : bool If True, filter out NaN values before computing statistics. ...
[ "def", "summary", "(", "x", ",", "rm_nan", "=", "False", ",", "debug", "=", "False", ")", ":", "# protections", "if", "type", "(", "x", ")", "is", "np", ".", "ndarray", ":", "xx", "=", "np", ".", "copy", "(", "x", ")", "else", ":", "if", "type"...
Compute basic statistical parameters. Parameters ---------- x : 1d numpy array, float Input array with values which statistical properties are requested. rm_nan : bool If True, filter out NaN values before computing statistics. debug : bool If True prints computed v...
[ "Compute", "basic", "statistical", "parameters", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/stats.py#L51-L126
train
Compute basic statistical parameters.
bachya/pyopenuv
example.py
run
async def run(websession: ClientSession): """Run.""" try: # Create a client: client = Client( '<API_KEY>', 39.7974509, -104.8887227, websession, altitude=1609.3) # Get current UV info: print('CURRENT UV DATA:') ...
python
async def run(websession: ClientSession): """Run.""" try: # Create a client: client = Client( '<API_KEY>', 39.7974509, -104.8887227, websession, altitude=1609.3) # Get current UV info: print('CURRENT UV DATA:') ...
[ "async", "def", "run", "(", "websession", ":", "ClientSession", ")", ":", "try", ":", "# Create a client:", "client", "=", "Client", "(", "'<API_KEY>'", ",", "39.7974509", ",", "-", "104.8887227", ",", "websession", ",", "altitude", "=", "1609.3", ")", "# Ge...
Run.
[ "Run", "." ]
f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46
https://github.com/bachya/pyopenuv/blob/f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46/example.py#L16-L41
train
Run the main function.
guaix-ucm/numina
numina/array/trace/traces.py
trace
def trace(arr, x, y, axis=0, background=0.0, step=4, hs=1, tol=2, maxdis=2.0, gauss=1): '''Trace peak in array starting in (x,y). Trace a peak feature in an array starting in position (x,y). Parameters ---------- arr : array A 2D array x : float x coordinate of the i...
python
def trace(arr, x, y, axis=0, background=0.0, step=4, hs=1, tol=2, maxdis=2.0, gauss=1): '''Trace peak in array starting in (x,y). Trace a peak feature in an array starting in position (x,y). Parameters ---------- arr : array A 2D array x : float x coordinate of the i...
[ "def", "trace", "(", "arr", ",", "x", ",", "y", ",", "axis", "=", "0", ",", "background", "=", "0.0", ",", "step", "=", "4", ",", "hs", "=", "1", ",", "tol", "=", "2", ",", "maxdis", "=", "2.0", ",", "gauss", "=", "1", ")", ":", "i", ",",...
Trace peak in array starting in (x,y). Trace a peak feature in an array starting in position (x,y). Parameters ---------- arr : array A 2D array x : float x coordinate of the initial position y : float y coordinate of the initial position axis : {0, 1} S...
[ "Trace", "peak", "in", "array", "starting", "in", "(", "x", "y", ")", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/trace/traces.py#L16-L71
train
Trace a peak in an array starting in position x y.
guaix-ucm/numina
numina/array/trace/traces.py
fit_trace_polynomial
def fit_trace_polynomial(trace, deg, axis=0): ''' Fit a trace information table to a polynomial. Parameters ---------- trace A 2D array, 2 columns and n rows deg : int Degree of polynomial axis : {0, 1} Spatial axis of the array (0 is Y, 1 is X). ''' ...
python
def fit_trace_polynomial(trace, deg, axis=0): ''' Fit a trace information table to a polynomial. Parameters ---------- trace A 2D array, 2 columns and n rows deg : int Degree of polynomial axis : {0, 1} Spatial axis of the array (0 is Y, 1 is X). ''' ...
[ "def", "fit_trace_polynomial", "(", "trace", ",", "deg", ",", "axis", "=", "0", ")", ":", "dispaxis", "=", "axis_to_dispaxis", "(", "axis", ")", "# FIT to a polynomial", "pfit", "=", "numpy", ".", "polyfit", "(", "trace", "[", ":", ",", "0", "]", ",", ...
Fit a trace information table to a polynomial. Parameters ---------- trace A 2D array, 2 columns and n rows deg : int Degree of polynomial axis : {0, 1} Spatial axis of the array (0 is Y, 1 is X).
[ "Fit", "a", "trace", "information", "table", "to", "a", "polynomial", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/trace/traces.py#L74-L94
train
Fit a trace information table to a polynomial.
guaix-ucm/numina
numina/array/display/fileinfo.py
list_fileinfo_from_txt
def list_fileinfo_from_txt(filename): """Returns a list of FileInfo instances if filename is a TXT file. Parameters ---------- filename : string Name of a file (wildcards are acceptable) or a TXT file containing a list of files. Empty Lines, and lines starting by a hash or a...
python
def list_fileinfo_from_txt(filename): """Returns a list of FileInfo instances if filename is a TXT file. Parameters ---------- filename : string Name of a file (wildcards are acceptable) or a TXT file containing a list of files. Empty Lines, and lines starting by a hash or a...
[ "def", "list_fileinfo_from_txt", "(", "filename", ")", ":", "# check for input file", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "# check for wildcards", "list_fits_files", "=", "glob", ".", "glob", "(", "filename", ")", "if", "l...
Returns a list of FileInfo instances if filename is a TXT file. Parameters ---------- filename : string Name of a file (wildcards are acceptable) or a TXT file containing a list of files. Empty Lines, and lines starting by a hash or a at symbol in the TXT file are ignored. ...
[ "Returns", "a", "list", "of", "FileInfo", "instances", "if", "filename", "is", "a", "TXT", "file", ".", "Parameters", "----------", "filename", ":", "string", "Name", "of", "a", "file", "(", "wildcards", "are", "acceptable", ")", "or", "a", "TXT", "file", ...
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/fileinfo.py#L48-L96
train
Returns a list of FileInfo instances containing the name of the files and additional file information.
druids/django-chamber
chamber/models/humanized_helpers/__init__.py
price_humanized
def price_humanized(value, inst, currency=None): """ Return a humanized price """ return (natural_number_with_currency(value, ugettext('CZK') if currency is None else currency) if value is not None else ugettext('(None)'))
python
def price_humanized(value, inst, currency=None): """ Return a humanized price """ return (natural_number_with_currency(value, ugettext('CZK') if currency is None else currency) if value is not None else ugettext('(None)'))
[ "def", "price_humanized", "(", "value", ",", "inst", ",", "currency", "=", "None", ")", ":", "return", "(", "natural_number_with_currency", "(", "value", ",", "ugettext", "(", "'CZK'", ")", "if", "currency", "is", "None", "else", "currency", ")", "if", "va...
Return a humanized price
[ "Return", "a", "humanized", "price" ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/humanized_helpers/__init__.py#L6-L11
train
Returns a humanized price for the given value.
guaix-ucm/numina
numina/datamodel.py
DataModel.get_imgid
def get_imgid(self, img): """Obtain a unique identifier of the image. Parameters ---------- img : astropy.io.fits.HDUList Returns ------- str: Identification of the image """ imgid = img.filename() # More heuristics here......
python
def get_imgid(self, img): """Obtain a unique identifier of the image. Parameters ---------- img : astropy.io.fits.HDUList Returns ------- str: Identification of the image """ imgid = img.filename() # More heuristics here......
[ "def", "get_imgid", "(", "self", ",", "img", ")", ":", "imgid", "=", "img", ".", "filename", "(", ")", "# More heuristics here...", "# get FILENAME keyword, CHECKSUM, for example...", "hdr", "=", "self", ".", "get_header", "(", "img", ")", "if", "'checksum'", "i...
Obtain a unique identifier of the image. Parameters ---------- img : astropy.io.fits.HDUList Returns ------- str: Identification of the image
[ "Obtain", "a", "unique", "identifier", "of", "the", "image", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L164-L191
train
Obtain a unique identifier of the image.
guaix-ucm/numina
numina/datamodel.py
DataModel.get_darktime
def get_darktime(self, img): """Obtain DARKTIME""" header = self.get_header(img) if 'DARKTIME' in header.keys(): return header['DARKTIME'] else: return self.get_exptime(img)
python
def get_darktime(self, img): """Obtain DARKTIME""" header = self.get_header(img) if 'DARKTIME' in header.keys(): return header['DARKTIME'] else: return self.get_exptime(img)
[ "def", "get_darktime", "(", "self", ",", "img", ")", ":", "header", "=", "self", ".", "get_header", "(", "img", ")", "if", "'DARKTIME'", "in", "header", ".", "keys", "(", ")", ":", "return", "header", "[", "'DARKTIME'", "]", "else", ":", "return", "s...
Obtain DARKTIME
[ "Obtain", "DARKTIME" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L193-L199
train
Obtain DARKTIME from the header or the EXPTIME if it exists.
guaix-ucm/numina
numina/datamodel.py
DataModel.get_exptime
def get_exptime(self, img): """Obtain EXPTIME""" header = self.get_header(img) if 'EXPTIME' in header.keys(): etime = header['EXPTIME'] elif 'EXPOSED' in header.keys(): etime = header['EXPOSED'] else: etime = 1.0 return etime
python
def get_exptime(self, img): """Obtain EXPTIME""" header = self.get_header(img) if 'EXPTIME' in header.keys(): etime = header['EXPTIME'] elif 'EXPOSED' in header.keys(): etime = header['EXPOSED'] else: etime = 1.0 return etime
[ "def", "get_exptime", "(", "self", ",", "img", ")", ":", "header", "=", "self", ".", "get_header", "(", "img", ")", "if", "'EXPTIME'", "in", "header", ".", "keys", "(", ")", ":", "etime", "=", "header", "[", "'EXPTIME'", "]", "elif", "'EXPOSED'", "in...
Obtain EXPTIME
[ "Obtain", "EXPTIME" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L201-L211
train
Obtain EXPTIME from header or 1. 0
guaix-ucm/numina
numina/datamodel.py
DataModel.gather_info
def gather_info(self, dframe): """Obtain a summary of information about the image.""" with dframe.open() as hdulist: info = self.gather_info_hdu(hdulist) return info
python
def gather_info(self, dframe): """Obtain a summary of information about the image.""" with dframe.open() as hdulist: info = self.gather_info_hdu(hdulist) return info
[ "def", "gather_info", "(", "self", ",", "dframe", ")", ":", "with", "dframe", ".", "open", "(", ")", "as", "hdulist", ":", "info", "=", "self", ".", "gather_info_hdu", "(", "hdulist", ")", "return", "info" ]
Obtain a summary of information about the image.
[ "Obtain", "a", "summary", "of", "information", "about", "the", "image", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L217-L221
train
Obtain a summary of information about the image.
guaix-ucm/numina
numina/datamodel.py
DataModel.gather_info_hdu
def gather_info_hdu(self, hdulist): """Obtain a summary of information about the image.""" values = {} values['n_ext'] = len(hdulist) extnames = [hdu.header.get('extname', '') for hdu in hdulist[1:]] values['name_ext'] = ['PRIMARY'] + extnames fits_extractor = self.extra...
python
def gather_info_hdu(self, hdulist): """Obtain a summary of information about the image.""" values = {} values['n_ext'] = len(hdulist) extnames = [hdu.header.get('extname', '') for hdu in hdulist[1:]] values['name_ext'] = ['PRIMARY'] + extnames fits_extractor = self.extra...
[ "def", "gather_info_hdu", "(", "self", ",", "hdulist", ")", ":", "values", "=", "{", "}", "values", "[", "'n_ext'", "]", "=", "len", "(", "hdulist", ")", "extnames", "=", "[", "hdu", ".", "header", ".", "get", "(", "'extname'", ",", "''", ")", "for...
Obtain a summary of information about the image.
[ "Obtain", "a", "summary", "of", "information", "about", "the", "image", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/datamodel.py#L227-L238
train
Obtain a summary of information about the image.
SUNCAT-Center/CatHub
cathub/make_folders_template.py
main
def main( title, authors, year, email, journal='', volume='', number='', pages='', publisher='', doi='', tags=[], DFT_code='Quantum ESPRESSO', DFT_functionals=['BEEF-vdW'], reactions=[ {'reactants...
python
def main( title, authors, year, email, journal='', volume='', number='', pages='', publisher='', doi='', tags=[], DFT_code='Quantum ESPRESSO', DFT_functionals=['BEEF-vdW'], reactions=[ {'reactants...
[ "def", "main", "(", "title", ",", "authors", ",", "year", ",", "email", ",", "journal", "=", "''", ",", "volume", "=", "''", ",", "number", "=", "''", ",", "pages", "=", "''", ",", "publisher", "=", "''", ",", "doi", "=", "''", ",", "tags", "="...
Automatically generate an organized folder structure for a DFT calculation. Start by copying the script to a folder in your username and assign the right information to the arguments in the function. You can change the parameters and run the script several times if you, for example, are using diff...
[ "Automatically", "generate", "an", "organized", "folder", "structure", "for", "a", "DFT", "calculation", "." ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/make_folders_template.py#L14-L225
train
This function is used to generate a folder structure for a given catalysis - hub. org.
pylp/pylp
pylp/lib/runner.py
TaskRunner.log_starting
def log_starting(self): """Log that the task has started.""" self.start_time = time.perf_counter() logger.log("Starting '", logger.cyan(self.name), "'...")
python
def log_starting(self): """Log that the task has started.""" self.start_time = time.perf_counter() logger.log("Starting '", logger.cyan(self.name), "'...")
[ "def", "log_starting", "(", "self", ")", ":", "self", ".", "start_time", "=", "time", ".", "perf_counter", "(", ")", "logger", ".", "log", "(", "\"Starting '\"", ",", "logger", ".", "cyan", "(", "self", ".", "name", ")", ",", "\"'...\"", ")" ]
Log that the task has started.
[ "Log", "that", "the", "task", "has", "started", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L50-L53
train
Log that the task has started.
pylp/pylp
pylp/lib/runner.py
TaskRunner.log_finished
def log_finished(self): """Log that this task is done.""" delta = time.perf_counter() - self.start_time logger.log("Finished '", logger.cyan(self.name), "' after ", logger.magenta(time_to_text(delta)))
python
def log_finished(self): """Log that this task is done.""" delta = time.perf_counter() - self.start_time logger.log("Finished '", logger.cyan(self.name), "' after ", logger.magenta(time_to_text(delta)))
[ "def", "log_finished", "(", "self", ")", ":", "delta", "=", "time", ".", "perf_counter", "(", ")", "-", "self", ".", "start_time", "logger", ".", "log", "(", "\"Finished '\"", ",", "logger", ".", "cyan", "(", "self", ".", "name", ")", ",", "\"' after \...
Log that this task is done.
[ "Log", "that", "this", "task", "is", "done", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L56-L60
train
Log that this task is done.
pylp/pylp
pylp/lib/runner.py
TaskRunner.call_task_fn
def call_task_fn(self): """Call the function attached to the task.""" if not self.fn: return self.log_finished() future = asyncio.Future() future.add_done_callback(lambda x: self.log_finished()) if inspect.iscoroutinefunction(self.fn): f = asyncio.ensure_future(self.fn()) f.add_done_callback(lambda...
python
def call_task_fn(self): """Call the function attached to the task.""" if not self.fn: return self.log_finished() future = asyncio.Future() future.add_done_callback(lambda x: self.log_finished()) if inspect.iscoroutinefunction(self.fn): f = asyncio.ensure_future(self.fn()) f.add_done_callback(lambda...
[ "def", "call_task_fn", "(", "self", ")", ":", "if", "not", "self", ".", "fn", ":", "return", "self", ".", "log_finished", "(", ")", "future", "=", "asyncio", ".", "Future", "(", ")", "future", ".", "add_done_callback", "(", "lambda", "x", ":", "self", ...
Call the function attached to the task.
[ "Call", "the", "function", "attached", "to", "the", "task", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L63-L77
train
Call the function attached to the task.
pylp/pylp
pylp/lib/runner.py
TaskRunner.bind_end
def bind_end(self, stream, future): """Bind a 'TaskEndTransformer' to a stream.""" if not isinstance(stream, Stream): future.set_result(None) else: stream.pipe(TaskEndTransformer(future))
python
def bind_end(self, stream, future): """Bind a 'TaskEndTransformer' to a stream.""" if not isinstance(stream, Stream): future.set_result(None) else: stream.pipe(TaskEndTransformer(future))
[ "def", "bind_end", "(", "self", ",", "stream", ",", "future", ")", ":", "if", "not", "isinstance", "(", "stream", ",", "Stream", ")", ":", "future", ".", "set_result", "(", "None", ")", "else", ":", "stream", ".", "pipe", "(", "TaskEndTransformer", "("...
Bind a 'TaskEndTransformer' to a stream.
[ "Bind", "a", "TaskEndTransformer", "to", "a", "stream", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L80-L85
train
Bind a TaskEndTransformer to a stream.
pylp/pylp
pylp/lib/runner.py
TaskRunner.start_deps
async def start_deps(self, deps): """Start running dependencies.""" # Get only new dependencies deps = list(filter(lambda dep: dep not in self.called, deps)) self.called += deps # Start only existing dependencies runners = list(filter(lambda x: x and x.future, map(lambda dep: pylp.start(dep), deps))) if...
python
async def start_deps(self, deps): """Start running dependencies.""" # Get only new dependencies deps = list(filter(lambda dep: dep not in self.called, deps)) self.called += deps # Start only existing dependencies runners = list(filter(lambda x: x and x.future, map(lambda dep: pylp.start(dep), deps))) if...
[ "async", "def", "start_deps", "(", "self", ",", "deps", ")", ":", "# Get only new dependencies", "deps", "=", "list", "(", "filter", "(", "lambda", "dep", ":", "dep", "not", "in", "self", ".", "called", ",", "deps", ")", ")", "self", ".", "called", "+=...
Start running dependencies.
[ "Start", "running", "dependencies", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/runner.py#L88-L103
train
Start running dependencies.
xflr6/bitsets
bitsets/bases.py
MemberBits.frommembers
def frommembers(cls, members=()): """Create a set from an iterable of members.""" return cls.fromint(sum(map(cls._map.__getitem__, set(members))))
python
def frommembers(cls, members=()): """Create a set from an iterable of members.""" return cls.fromint(sum(map(cls._map.__getitem__, set(members))))
[ "def", "frommembers", "(", "cls", ",", "members", "=", "(", ")", ")", ":", "return", "cls", ".", "fromint", "(", "sum", "(", "map", "(", "cls", ".", "_map", ".", "__getitem__", ",", "set", "(", "members", ")", ")", ")", ")" ]
Create a set from an iterable of members.
[ "Create", "a", "set", "from", "an", "iterable", "of", "members", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L31-L33
train
Create a set from an iterable of members.
xflr6/bitsets
bitsets/bases.py
MemberBits.frombools
def frombools(cls, bools=()): """Create a set from an iterable of boolean evaluable items.""" return cls.fromint(sum(compress(cls._atoms, bools)))
python
def frombools(cls, bools=()): """Create a set from an iterable of boolean evaluable items.""" return cls.fromint(sum(compress(cls._atoms, bools)))
[ "def", "frombools", "(", "cls", ",", "bools", "=", "(", ")", ")", ":", "return", "cls", ".", "fromint", "(", "sum", "(", "compress", "(", "cls", ".", "_atoms", ",", "bools", ")", ")", ")" ]
Create a set from an iterable of boolean evaluable items.
[ "Create", "a", "set", "from", "an", "iterable", "of", "boolean", "evaluable", "items", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L36-L38
train
Create a set from an iterable of boolean evaluable items.
xflr6/bitsets
bitsets/bases.py
MemberBits.frombits
def frombits(cls, bits='0'): """Create a set from binary string.""" if len(bits) > cls._len: raise ValueError('too many bits %r' % (bits,)) return cls.fromint(bits[::-1], 2)
python
def frombits(cls, bits='0'): """Create a set from binary string.""" if len(bits) > cls._len: raise ValueError('too many bits %r' % (bits,)) return cls.fromint(bits[::-1], 2)
[ "def", "frombits", "(", "cls", ",", "bits", "=", "'0'", ")", ":", "if", "len", "(", "bits", ")", ">", "cls", ".", "_len", ":", "raise", "ValueError", "(", "'too many bits %r'", "%", "(", "bits", ",", ")", ")", "return", "cls", ".", "fromint", "(", ...
Create a set from binary string.
[ "Create", "a", "set", "from", "binary", "string", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L41-L45
train
Create a set from binary string.
xflr6/bitsets
bitsets/bases.py
MemberBits.members
def members(self, as_set=False): """Return the set members tuple/frozenset.""" if as_set: return frozenset(map(self._members.__getitem__, self._indexes())) return tuple(map(self._members.__getitem__, self._indexes()))
python
def members(self, as_set=False): """Return the set members tuple/frozenset.""" if as_set: return frozenset(map(self._members.__getitem__, self._indexes())) return tuple(map(self._members.__getitem__, self._indexes()))
[ "def", "members", "(", "self", ",", "as_set", "=", "False", ")", ":", "if", "as_set", ":", "return", "frozenset", "(", "map", "(", "self", ".", "_members", ".", "__getitem__", ",", "self", ".", "_indexes", "(", ")", ")", ")", "return", "tuple", "(", ...
Return the set members tuple/frozenset.
[ "Return", "the", "set", "members", "tuple", "/", "frozenset", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L60-L64
train
Return the set members tuple or frozenset.
xflr6/bitsets
bitsets/bases.py
MemberBits.atoms
def atoms(self, reverse=False): """Yield the singleton for every set member.""" if reverse: return filter(self.__and__, reversed(self._atoms)) return filter(self.__and__, self._atoms)
python
def atoms(self, reverse=False): """Yield the singleton for every set member.""" if reverse: return filter(self.__and__, reversed(self._atoms)) return filter(self.__and__, self._atoms)
[ "def", "atoms", "(", "self", ",", "reverse", "=", "False", ")", ":", "if", "reverse", ":", "return", "filter", "(", "self", ".", "__and__", ",", "reversed", "(", "self", ".", "_atoms", ")", ")", "return", "filter", "(", "self", ".", "__and__", ",", ...
Yield the singleton for every set member.
[ "Yield", "the", "singleton", "for", "every", "set", "member", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L77-L81
train
Yield the singleton for every set member.
xflr6/bitsets
bitsets/bases.py
MemberBits.inatoms
def inatoms(self, reverse=False): """Yield the singleton for every non-member.""" if reverse: return filterfalse(self.__and__, reversed(self._atoms)) return filterfalse(self.__and__, self._atoms)
python
def inatoms(self, reverse=False): """Yield the singleton for every non-member.""" if reverse: return filterfalse(self.__and__, reversed(self._atoms)) return filterfalse(self.__and__, self._atoms)
[ "def", "inatoms", "(", "self", ",", "reverse", "=", "False", ")", ":", "if", "reverse", ":", "return", "filterfalse", "(", "self", ".", "__and__", ",", "reversed", "(", "self", ".", "_atoms", ")", ")", "return", "filterfalse", "(", "self", ".", "__and_...
Yield the singleton for every non-member.
[ "Yield", "the", "singleton", "for", "every", "non", "-", "member", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L83-L87
train
Yield the singleton for every non - member.
xflr6/bitsets
bitsets/bases.py
MemberBits.powerset
def powerset(self, start=None, excludestart=False): """Yield combinations from start to self in short lexicographic order.""" if start is None: start = self.infimum other = self.atoms() else: if self | start != self: raise ValueError('%r is no ...
python
def powerset(self, start=None, excludestart=False): """Yield combinations from start to self in short lexicographic order.""" if start is None: start = self.infimum other = self.atoms() else: if self | start != self: raise ValueError('%r is no ...
[ "def", "powerset", "(", "self", ",", "start", "=", "None", ",", "excludestart", "=", "False", ")", ":", "if", "start", "is", "None", ":", "start", "=", "self", ".", "infimum", "other", "=", "self", ".", "atoms", "(", ")", "else", ":", "if", "self",...
Yield combinations from start to self in short lexicographic order.
[ "Yield", "combinations", "from", "start", "to", "self", "in", "short", "lexicographic", "order", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L89-L98
train
Yields combinations from start to self in short lexicographic order.
xflr6/bitsets
bitsets/bases.py
MemberBits.count
def count(self, value=True): """Returns the number of present/absent members.""" if value not in (True, False): raise ValueError('can only count True or False, not %r' % (value,)) return bin(self)[2:].count('01'[value])
python
def count(self, value=True): """Returns the number of present/absent members.""" if value not in (True, False): raise ValueError('can only count True or False, not %r' % (value,)) return bin(self)[2:].count('01'[value])
[ "def", "count", "(", "self", ",", "value", "=", "True", ")", ":", "if", "value", "not", "in", "(", "True", ",", "False", ")", ":", "raise", "ValueError", "(", "'can only count True or False, not %r'", "%", "(", "value", ",", ")", ")", "return", "bin", ...
Returns the number of present/absent members.
[ "Returns", "the", "number", "of", "present", "/", "absent", "members", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/bases.py#L116-L120
train
Returns the number of present and absent members.
druids/django-chamber
chamber/shortcuts.py
change
def change(obj, **changed_fields): """ Changes a given `changed_fields` on object and returns changed object. """ obj_field_names = { field.name for field in obj._meta.fields } | { field.attname for field in obj._meta.fields } | {'pk'} for field_name, value in changed_fields...
python
def change(obj, **changed_fields): """ Changes a given `changed_fields` on object and returns changed object. """ obj_field_names = { field.name for field in obj._meta.fields } | { field.attname for field in obj._meta.fields } | {'pk'} for field_name, value in changed_fields...
[ "def", "change", "(", "obj", ",", "*", "*", "changed_fields", ")", ":", "obj_field_names", "=", "{", "field", ".", "name", "for", "field", "in", "obj", ".", "_meta", ".", "fields", "}", "|", "{", "field", ".", "attname", "for", "field", "in", "obj", ...
Changes a given `changed_fields` on object and returns changed object.
[ "Changes", "a", "given", "changed_fields", "on", "object", "and", "returns", "changed", "object", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L54-L68
train
Changes a given changed_fields on object and returns changed object.
druids/django-chamber
chamber/shortcuts.py
change_and_save
def change_and_save(obj, update_only_changed_fields=False, save_kwargs=None, **changed_fields): """ Changes a given `changed_fields` on object, saves it and returns changed object. """ from chamber.models import SmartModel change(obj, **changed_fields) if update_only_changed_fields and not isin...
python
def change_and_save(obj, update_only_changed_fields=False, save_kwargs=None, **changed_fields): """ Changes a given `changed_fields` on object, saves it and returns changed object. """ from chamber.models import SmartModel change(obj, **changed_fields) if update_only_changed_fields and not isin...
[ "def", "change_and_save", "(", "obj", ",", "update_only_changed_fields", "=", "False", ",", "save_kwargs", "=", "None", ",", "*", "*", "changed_fields", ")", ":", "from", "chamber", ".", "models", "import", "SmartModel", "change", "(", "obj", ",", "*", "*", ...
Changes a given `changed_fields` on object, saves it and returns changed object.
[ "Changes", "a", "given", "changed_fields", "on", "object", "saves", "it", "and", "returns", "changed", "object", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L71-L86
train
Changes a given changed_fields on object saves it and returns changed object.
druids/django-chamber
chamber/shortcuts.py
bulk_change_and_save
def bulk_change_and_save(iterable, update_only_changed_fields=False, save_kwargs=None, **changed_fields): """ Changes a given `changed_fields` on each object in a given `iterable`, saves objects and returns the changed objects. """ return [ change_and_save(obj, update_only_changed_fields=upd...
python
def bulk_change_and_save(iterable, update_only_changed_fields=False, save_kwargs=None, **changed_fields): """ Changes a given `changed_fields` on each object in a given `iterable`, saves objects and returns the changed objects. """ return [ change_and_save(obj, update_only_changed_fields=upd...
[ "def", "bulk_change_and_save", "(", "iterable", ",", "update_only_changed_fields", "=", "False", ",", "save_kwargs", "=", "None", ",", "*", "*", "changed_fields", ")", ":", "return", "[", "change_and_save", "(", "obj", ",", "update_only_changed_fields", "=", "upda...
Changes a given `changed_fields` on each object in a given `iterable`, saves objects and returns the changed objects.
[ "Changes", "a", "given", "changed_fields", "on", "each", "object", "in", "a", "given", "iterable", "saves", "objects", "and", "returns", "the", "changed", "objects", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/shortcuts.py#L96-L105
train
Changes a given changed_fields on each object in a given iterable saves objects and returns the changed objects.
guaix-ucm/numina
numina/modeling/gaussbox.py
gauss_box_model
def gauss_box_model(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5): """Integrate a Gaussian profile.""" z = (x - mean) / stddev z2 = z + hpix / stddev z1 = z - hpix / stddev return amplitude * (norm.cdf(z2) - norm.cdf(z1))
python
def gauss_box_model(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5): """Integrate a Gaussian profile.""" z = (x - mean) / stddev z2 = z + hpix / stddev z1 = z - hpix / stddev return amplitude * (norm.cdf(z2) - norm.cdf(z1))
[ "def", "gauss_box_model", "(", "x", ",", "amplitude", "=", "1.0", ",", "mean", "=", "0.0", ",", "stddev", "=", "1.0", ",", "hpix", "=", "0.5", ")", ":", "z", "=", "(", "x", "-", "mean", ")", "/", "stddev", "z2", "=", "z", "+", "hpix", "/", "s...
Integrate a Gaussian profile.
[ "Integrate", "a", "Gaussian", "profile", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/modeling/gaussbox.py#L24-L29
train
Integrate a Gaussian profile.
guaix-ucm/numina
numina/modeling/gaussbox.py
gauss_box_model_deriv
def gauss_box_model_deriv(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5): """Derivative of the integral of a Gaussian profile.""" z = (x - mean) / stddev z2 = z + hpix / stddev z1 = z - hpix / stddev da = norm.cdf(z2) - norm.cdf(z1) fp2 = norm_pdf_t(z2) fp1 = norm_pdf_t(z1) dl = -...
python
def gauss_box_model_deriv(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5): """Derivative of the integral of a Gaussian profile.""" z = (x - mean) / stddev z2 = z + hpix / stddev z1 = z - hpix / stddev da = norm.cdf(z2) - norm.cdf(z1) fp2 = norm_pdf_t(z2) fp1 = norm_pdf_t(z1) dl = -...
[ "def", "gauss_box_model_deriv", "(", "x", ",", "amplitude", "=", "1.0", ",", "mean", "=", "0.0", ",", "stddev", "=", "1.0", ",", "hpix", "=", "0.5", ")", ":", "z", "=", "(", "x", "-", "mean", ")", "/", "stddev", "z2", "=", "z", "+", "hpix", "/"...
Derivative of the integral of a Gaussian profile.
[ "Derivative", "of", "the", "integral", "of", "a", "Gaussian", "profile", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/modeling/gaussbox.py#L32-L47
train
Derivative of the integral of a Gaussian profile.
guaix-ucm/numina
numina/array/wavecalib/peaks_spectrum.py
find_peaks_spectrum
def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0): """Find peaks in array. The algorithm imposes that the signal at both sides of the peak decreases monotonically. Parameters ---------- sx : 1d numpy array, floats Input array. nwinwidth : int Width of the win...
python
def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0): """Find peaks in array. The algorithm imposes that the signal at both sides of the peak decreases monotonically. Parameters ---------- sx : 1d numpy array, floats Input array. nwinwidth : int Width of the win...
[ "def", "find_peaks_spectrum", "(", "sx", ",", "nwinwidth", ",", "threshold", "=", "0", ",", "debugplot", "=", "0", ")", ":", "if", "type", "(", "sx", ")", "is", "not", "np", ".", "ndarray", ":", "raise", "ValueError", "(", "\"sx=\"", "+", "str", "(",...
Find peaks in array. The algorithm imposes that the signal at both sides of the peak decreases monotonically. Parameters ---------- sx : 1d numpy array, floats Input array. nwinwidth : int Width of the window where each peak must be found. threshold : float Minimum ...
[ "Find", "peaks", "in", "array", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/peaks_spectrum.py#L19-L106
train
Find peaks in array.
guaix-ucm/numina
numina/array/wavecalib/peaks_spectrum.py
refine_peaks_spectrum
def refine_peaks_spectrum(sx, ixpeaks, nwinwidth, method=None, geometry=None, debugplot=0): """Refine line peaks in spectrum. Parameters ---------- sx : 1d numpy array, floats Input array. ixpeaks : 1d numpy array, int Initial peak locations, in array coord...
python
def refine_peaks_spectrum(sx, ixpeaks, nwinwidth, method=None, geometry=None, debugplot=0): """Refine line peaks in spectrum. Parameters ---------- sx : 1d numpy array, floats Input array. ixpeaks : 1d numpy array, int Initial peak locations, in array coord...
[ "def", "refine_peaks_spectrum", "(", "sx", ",", "ixpeaks", ",", "nwinwidth", ",", "method", "=", "None", ",", "geometry", "=", "None", ",", "debugplot", "=", "0", ")", ":", "nmed", "=", "nwinwidth", "//", "2", "xfpeaks", "=", "np", ".", "zeros", "(", ...
Refine line peaks in spectrum. Parameters ---------- sx : 1d numpy array, floats Input array. ixpeaks : 1d numpy array, int Initial peak locations, in array coordinates (integers). These values can be the output from the function find_peaks_spectrum(). nwinwidth : in...
[ "Refine", "line", "peaks", "in", "spectrum", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/peaks_spectrum.py#L109-L259
train
Refine line peaks in a spectrum.
pylp/pylp
pylp/utils/paths.py
make_readable_path
def make_readable_path(path): """Make a path more "readable""" home = os.path.expanduser("~") if path.startswith(home): path = "~" + path[len(home):] return path
python
def make_readable_path(path): """Make a path more "readable""" home = os.path.expanduser("~") if path.startswith(home): path = "~" + path[len(home):] return path
[ "def", "make_readable_path", "(", "path", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "if", "path", ".", "startswith", "(", "home", ")", ":", "path", "=", "\"~\"", "+", "path", "[", "len", "(", "home", ")", ":", ...
Make a path more "readable
[ "Make", "a", "path", "more", "readable" ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/paths.py#L13-L19
train
Make a path more readable
xflr6/bitsets
bitsets/combos.py
shortlex
def shortlex(start, other, excludestart=False): """Yield all unions of start with other in shortlex order. >>> ['{:03b}'.format(s) for s in shortlex(0, [0b100, 0b010, 0b001])] ['000', '100', '010', '001', '110', '101', '011', '111'] >>> ', '.join(''.join(sorted(s)) ... for s in shortlex(set(), [{'...
python
def shortlex(start, other, excludestart=False): """Yield all unions of start with other in shortlex order. >>> ['{:03b}'.format(s) for s in shortlex(0, [0b100, 0b010, 0b001])] ['000', '100', '010', '001', '110', '101', '011', '111'] >>> ', '.join(''.join(sorted(s)) ... for s in shortlex(set(), [{'...
[ "def", "shortlex", "(", "start", ",", "other", ",", "excludestart", "=", "False", ")", ":", "if", "not", "excludestart", ":", "yield", "start", "queue", "=", "collections", ".", "deque", "(", "[", "(", "start", ",", "other", ")", "]", ")", "while", "...
Yield all unions of start with other in shortlex order. >>> ['{:03b}'.format(s) for s in shortlex(0, [0b100, 0b010, 0b001])] ['000', '100', '010', '001', '110', '101', '011', '111'] >>> ', '.join(''.join(sorted(s)) ... for s in shortlex(set(), [{'a'}, {'b'}, {'c'}, {'d'}])) ', a, b, c, d, ab, ac, ...
[ "Yield", "all", "unions", "of", "start", "with", "other", "in", "shortlex", "order", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/combos.py#L10-L38
train
Yields all unions of start with other in shortlex order.
xflr6/bitsets
bitsets/combos.py
reverse_shortlex
def reverse_shortlex(end, other, excludeend=False): """Yield all intersections of end with other in reverse shortlex order. >>> ['{:03b}'.format(s) for s in reverse_shortlex(0b111, [0b011, 0b101, 0b110])] ['111', '011', '101', '110', '001', '010', '100', '000'] >>> ', '.join(''.join(sorted(s)) ......
python
def reverse_shortlex(end, other, excludeend=False): """Yield all intersections of end with other in reverse shortlex order. >>> ['{:03b}'.format(s) for s in reverse_shortlex(0b111, [0b011, 0b101, 0b110])] ['111', '011', '101', '110', '001', '010', '100', '000'] >>> ', '.join(''.join(sorted(s)) ......
[ "def", "reverse_shortlex", "(", "end", ",", "other", ",", "excludeend", "=", "False", ")", ":", "if", "not", "excludeend", ":", "yield", "end", "queue", "=", "collections", ".", "deque", "(", "[", "(", "end", ",", "other", ")", "]", ")", "while", "qu...
Yield all intersections of end with other in reverse shortlex order. >>> ['{:03b}'.format(s) for s in reverse_shortlex(0b111, [0b011, 0b101, 0b110])] ['111', '011', '101', '110', '001', '010', '100', '000'] >>> ', '.join(''.join(sorted(s)) ... for s in reverse_shortlex({'a', 'b', 'c', 'd'}, ... [{...
[ "Yield", "all", "intersections", "of", "end", "with", "other", "in", "reverse", "shortlex", "order", "." ]
ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf
https://github.com/xflr6/bitsets/blob/ddcfe17e7c7a11f71f1c6764b2cecf7db05d9cdf/bitsets/combos.py#L41-L70
train
Yield all intersections of end with other in reverse shortlex order.
pylp/pylp
pylp/utils/time.py
time_to_text
def time_to_text(time): """Get a representative text of a time (in s).""" if time < 0.001: return str(round(time * 1000000)) + " µs" elif time < 1: return str(round(time * 1000)) + " ms" elif time < 60: return str(round(time, 1)) + " s" else: return str(round(tim...
python
def time_to_text(time): """Get a representative text of a time (in s).""" if time < 0.001: return str(round(time * 1000000)) + " µs" elif time < 1: return str(round(time * 1000)) + " ms" elif time < 60: return str(round(time, 1)) + " s" else: return str(round(tim...
[ "def", "time_to_text", "(", "time", ")", ":", "if", "time", "<", "0.001", ":", "return", "str", "(", "round", "(", "time", "*", "1000000", ")", ")", "+", "\" µs\"", "elif", "time", "<", "1", ":", "return", "str", "(", "round", "(", "time", "*", "...
Get a representative text of a time (in s).
[ "Get", "a", "representative", "text", "of", "a", "time", "(", "in", "s", ")", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/time.py#L11-L21
train
Get a representative text of a time in s.
druids/django-chamber
chamber/models/fields.py
generate_random_upload_path
def generate_random_upload_path(instance, filename): """ Pass this function to upload_to argument of FileField to store the file on an unguessable path. The format of the path is class_name/hash/original_filename. """ return os.path.join(instance.__class__.__name__.lower(), uuid().hex, filename)
python
def generate_random_upload_path(instance, filename): """ Pass this function to upload_to argument of FileField to store the file on an unguessable path. The format of the path is class_name/hash/original_filename. """ return os.path.join(instance.__class__.__name__.lower(), uuid().hex, filename)
[ "def", "generate_random_upload_path", "(", "instance", ",", "filename", ")", ":", "return", "os", ".", "path", ".", "join", "(", "instance", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ",", "uuid", "(", ")", ".", "hex", ",", "filename", ...
Pass this function to upload_to argument of FileField to store the file on an unguessable path. The format of the path is class_name/hash/original_filename.
[ "Pass", "this", "function", "to", "upload_to", "argument", "of", "FileField", "to", "store", "the", "file", "on", "an", "unguessable", "path", ".", "The", "format", "of", "the", "path", "is", "class_name", "/", "hash", "/", "original_filename", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/fields.py#L89-L94
train
Generate a random upload path for the file.
druids/django-chamber
chamber/models/fields.py
RestrictedFileFieldMixin.generate_filename
def generate_filename(self, instance, filename): """ removes UTF chars from filename """ from unidecode import unidecode return super().generate_filename(instance, unidecode(force_text(filename)))
python
def generate_filename(self, instance, filename): """ removes UTF chars from filename """ from unidecode import unidecode return super().generate_filename(instance, unidecode(force_text(filename)))
[ "def", "generate_filename", "(", "self", ",", "instance", ",", "filename", ")", ":", "from", "unidecode", "import", "unidecode", "return", "super", "(", ")", ".", "generate_filename", "(", "instance", ",", "unidecode", "(", "force_text", "(", "filename", ")", ...
removes UTF chars from filename
[ "removes", "UTF", "chars", "from", "filename" ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/models/fields.py#L69-L75
train
Generate a filename from the given filename.
PaulMcMillan/tasa
tasa/store.py
Queue.next
def next(self): """ Retrieve the next item in the queue. Returns deserialized value, or None if there were no entries in the Queue. """ if self.blocking >= 0: # returns queue name and item, we just need item res = self.redis.blpop([self.name], timeout=sel...
python
def next(self): """ Retrieve the next item in the queue. Returns deserialized value, or None if there were no entries in the Queue. """ if self.blocking >= 0: # returns queue name and item, we just need item res = self.redis.blpop([self.name], timeout=sel...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "blocking", ">=", "0", ":", "# returns queue name and item, we just need item", "res", "=", "self", ".", "redis", ".", "blpop", "(", "[", "self", ".", "name", "]", ",", "timeout", "=", "self", ".",...
Retrieve the next item in the queue. Returns deserialized value, or None if there were no entries in the Queue.
[ "Retrieve", "the", "next", "item", "in", "the", "queue", "." ]
fd548d97fd08e61c0e71296b08ffedb7d949e06a
https://github.com/PaulMcMillan/tasa/blob/fd548d97fd08e61c0e71296b08ffedb7d949e06a/tasa/store.py#L58-L73
train
Retrieve the next item in the queue. Returns deserialized value or None if there are no more items in the queue.
PaulMcMillan/tasa
tasa/store.py
Queue.send
def send(self, *args): """ Send a value to this LIFO Queue. Provided argument is serialized and pushed out. Don't send None. """ # this and the serializer could use some streamlining if None in args: raise TypeError('None is not a valid queue item.') serializ...
python
def send(self, *args): """ Send a value to this LIFO Queue. Provided argument is serialized and pushed out. Don't send None. """ # this and the serializer could use some streamlining if None in args: raise TypeError('None is not a valid queue item.') serializ...
[ "def", "send", "(", "self", ",", "*", "args", ")", ":", "# this and the serializer could use some streamlining", "if", "None", "in", "args", ":", "raise", "TypeError", "(", "'None is not a valid queue item.'", ")", "serialized_values", "=", "[", "self", ".", "serial...
Send a value to this LIFO Queue. Provided argument is serialized and pushed out. Don't send None.
[ "Send", "a", "value", "to", "this", "LIFO", "Queue", "." ]
fd548d97fd08e61c0e71296b08ffedb7d949e06a
https://github.com/PaulMcMillan/tasa/blob/fd548d97fd08e61c0e71296b08ffedb7d949e06a/tasa/store.py#L75-L85
train
Send a value to this LIFO Queue.
PaulMcMillan/tasa
tasa/store.py
Queue.clear
def clear(self): """ Clear any existing values from this queue. """ logger.debug('Clearing queue: "%s"', self.name) return self.redis.delete(self.name)
python
def clear(self): """ Clear any existing values from this queue. """ logger.debug('Clearing queue: "%s"', self.name) return self.redis.delete(self.name)
[ "def", "clear", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Clearing queue: \"%s\"'", ",", "self", ".", "name", ")", "return", "self", ".", "redis", ".", "delete", "(", "self", ".", "name", ")" ]
Clear any existing values from this queue.
[ "Clear", "any", "existing", "values", "from", "this", "queue", "." ]
fd548d97fd08e61c0e71296b08ffedb7d949e06a
https://github.com/PaulMcMillan/tasa/blob/fd548d97fd08e61c0e71296b08ffedb7d949e06a/tasa/store.py#L99-L102
train
Clear any existing values from this queue.
PierreRust/apigpio
apigpio/apigpio.py
u2i
def u2i(uint32): """ Converts a 32 bit unsigned number to signed. uint32:= an unsigned 32 bit number ... print(u2i(4294967272)) -24 print(u2i(37)) 37 ... """ mask = (2 ** 32) - 1 if uint32 & (1 << 31): v = uint32 | ~mask else: v = uint32 & mask r...
python
def u2i(uint32): """ Converts a 32 bit unsigned number to signed. uint32:= an unsigned 32 bit number ... print(u2i(4294967272)) -24 print(u2i(37)) 37 ... """ mask = (2 ** 32) - 1 if uint32 & (1 << 31): v = uint32 | ~mask else: v = uint32 & mask r...
[ "def", "u2i", "(", "uint32", ")", ":", "mask", "=", "(", "2", "**", "32", ")", "-", "1", "if", "uint32", "&", "(", "1", "<<", "31", ")", ":", "v", "=", "uint32", "|", "~", "mask", "else", ":", "v", "=", "uint32", "&", "mask", "return", "v" ...
Converts a 32 bit unsigned number to signed. uint32:= an unsigned 32 bit number ... print(u2i(4294967272)) -24 print(u2i(37)) 37 ...
[ "Converts", "a", "32", "bit", "unsigned", "number", "to", "signed", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L301-L319
train
Convert a 32 bit unsigned number to signed.
PierreRust/apigpio
apigpio/apigpio.py
_u2i
def _u2i(uint32): """ Converts a 32 bit unsigned number to signed. If the number is negative it indicates an error. On error a pigpio exception will be raised if exceptions is True. """ v = u2i(uint32) if v < 0: if exceptions: raise ApigpioError(error_text(v)) retur...
python
def _u2i(uint32): """ Converts a 32 bit unsigned number to signed. If the number is negative it indicates an error. On error a pigpio exception will be raised if exceptions is True. """ v = u2i(uint32) if v < 0: if exceptions: raise ApigpioError(error_text(v)) retur...
[ "def", "_u2i", "(", "uint32", ")", ":", "v", "=", "u2i", "(", "uint32", ")", "if", "v", "<", "0", ":", "if", "exceptions", ":", "raise", "ApigpioError", "(", "error_text", "(", "v", ")", ")", "return", "v" ]
Converts a 32 bit unsigned number to signed. If the number is negative it indicates an error. On error a pigpio exception will be raised if exceptions is True.
[ "Converts", "a", "32", "bit", "unsigned", "number", "to", "signed", ".", "If", "the", "number", "is", "negative", "it", "indicates", "an", "error", ".", "On", "error", "a", "pigpio", "exception", "will", "be", "raised", "if", "exceptions", "is", "True", ...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L322-L332
train
Convert a 32 bit unsigned number to signed integer.
PierreRust/apigpio
apigpio/apigpio.py
_callback_handler.append
def append(self, cb): """Adds a callback.""" self.callbacks.append(cb.callb) self.monitor = self.monitor | cb.callb.bit yield from self.pi._pigpio_aio_command(_PI_CMD_NB, self.handle, self.monitor)
python
def append(self, cb): """Adds a callback.""" self.callbacks.append(cb.callb) self.monitor = self.monitor | cb.callb.bit yield from self.pi._pigpio_aio_command(_PI_CMD_NB, self.handle, self.monitor)
[ "def", "append", "(", "self", ",", "cb", ")", ":", "self", ".", "callbacks", ".", "append", "(", "cb", ".", "callb", ")", "self", ".", "monitor", "=", "self", ".", "monitor", "|", "cb", ".", "callb", ".", "bit", "yield", "from", "self", ".", "pi"...
Adds a callback.
[ "Adds", "a", "callback", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L450-L456
train
Adds a callback to the list of callbacks.
PierreRust/apigpio
apigpio/apigpio.py
_callback_handler.remove
def remove(self, cb): """Removes a callback.""" if cb in self.callbacks: self.callbacks.remove(cb) new_monitor = 0 for c in self.callbacks: new_monitor |= c.bit if new_monitor != self.monitor: self.monitor = new_monitor ...
python
def remove(self, cb): """Removes a callback.""" if cb in self.callbacks: self.callbacks.remove(cb) new_monitor = 0 for c in self.callbacks: new_monitor |= c.bit if new_monitor != self.monitor: self.monitor = new_monitor ...
[ "def", "remove", "(", "self", ",", "cb", ")", ":", "if", "cb", "in", "self", ".", "callbacks", ":", "self", ".", "callbacks", ".", "remove", "(", "cb", ")", "new_monitor", "=", "0", "for", "c", "in", "self", ".", "callbacks", ":", "new_monitor", "|...
Removes a callback.
[ "Removes", "a", "callback", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L459-L469
train
Removes a callback from the list of callbacks.
PierreRust/apigpio
apigpio/apigpio.py
Pi._pigpio_aio_command
def _pigpio_aio_command(self, cmd, p1, p2,): """ Runs a pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applicable). """ with (yield from self...
python
def _pigpio_aio_command(self, cmd, p1, p2,): """ Runs a pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applicable). """ with (yield from self...
[ "def", "_pigpio_aio_command", "(", "self", ",", "cmd", ",", "p1", ",", "p2", ",", ")", ":", "with", "(", "yield", "from", "self", ".", "_lock", ")", ":", "data", "=", "struct", ".", "pack", "(", "'IIII'", ",", "cmd", ",", "p1", ",", "p2", ",", ...
Runs a pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applicable).
[ "Runs", "a", "pigpio", "socket", "command", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L518-L532
train
Runs a pigpio socket command.
PierreRust/apigpio
apigpio/apigpio.py
Pi._pigpio_aio_command_ext
def _pigpio_aio_command_ext(self, cmd, p1, p2, p3, extents, rl=True): """ Runs an extended pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applica...
python
def _pigpio_aio_command_ext(self, cmd, p1, p2, p3, extents, rl=True): """ Runs an extended pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applica...
[ "def", "_pigpio_aio_command_ext", "(", "self", ",", "cmd", ",", "p1", ",", "p2", ",", "p3", ",", "extents", ",", "rl", "=", "True", ")", ":", "with", "(", "yield", "from", "self", ".", "_lock", ")", ":", "ext", "=", "bytearray", "(", "struct", ".",...
Runs an extended pigpio socket command. sl:= command socket and lock. cmd:= the command to be executed. p1:= command parameter 1 (if applicable). p2:= command parameter 2 (if applicable). p3:= total size in bytes of following extents extents:= addition...
[ "Runs", "an", "extended", "pigpio", "socket", "command", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L535-L556
train
Runs an extended pigpio socket command.