partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
create_event
Create event in calendar with sms reminder.
notification_google_calendar.py
def create_event(options, config, credentials): """ Create event in calendar with sms reminder. """ try: http = credentials.authorize(httplib2.Http()) service = build("calendar", "v3", http=http) event = { "summary": options.message, "location": "", ...
def create_event(options, config, credentials): """ Create event in calendar with sms reminder. """ try: http = credentials.authorize(httplib2.Http()) service = build("calendar", "v3", http=http) event = { "summary": options.message, "location": "", ...
[ "Create", "event", "in", "calendar", "with", "sms", "reminder", "." ]
vint21h/nagios-notification-google-calendar
python
https://github.com/vint21h/nagios-notification-google-calendar/blob/ef2b58c939d9d55a69a54b4e6a3fd9b61bde50d4/notification_google_calendar.py#L192-L220
[ "def", "create_event", "(", "options", ",", "config", ",", "credentials", ")", ":", "try", ":", "http", "=", "credentials", ".", "authorize", "(", "httplib2", ".", "Http", "(", ")", ")", "service", "=", "build", "(", "\"calendar\"", ",", "\"v3\"", ",", ...
ef2b58c939d9d55a69a54b4e6a3fd9b61bde50d4
test
main
Processing notification call main function.
notification_google_calendar.py
def main(): """ Processing notification call main function. """ # getting info for creating event options = parse_options() config = parse_config(options) credentials = get_google_credentials(options, config) if not options.get_google_credentials: create_event(options, config, ...
def main(): """ Processing notification call main function. """ # getting info for creating event options = parse_options() config = parse_config(options) credentials = get_google_credentials(options, config) if not options.get_google_credentials: create_event(options, config, ...
[ "Processing", "notification", "call", "main", "function", "." ]
vint21h/nagios-notification-google-calendar
python
https://github.com/vint21h/nagios-notification-google-calendar/blob/ef2b58c939d9d55a69a54b4e6a3fd9b61bde50d4/notification_google_calendar.py#L223-L234
[ "def", "main", "(", ")", ":", "# getting info for creating event", "options", "=", "parse_options", "(", ")", "config", "=", "parse_config", "(", "options", ")", "credentials", "=", "get_google_credentials", "(", "options", ",", "config", ")", "if", "not", "opti...
ef2b58c939d9d55a69a54b4e6a3fd9b61bde50d4
test
create
Use docstamp to create documents from the content of a CSV file or a Google Spreadsheet. Examples: \n docstamp create -i badge.csv -t badge_template.svg -o badges docstamp create -i badge.csv -t badge_template.svg -o ./badges -d pdf
docstamp/cli/cli.py
def create(input, template, field, outdir, prefix, otype, command, index, dpi, verbose, unicode_support): """Use docstamp to create documents from the content of a CSV file or a Google Spreadsheet. Examples: \n docstamp create -i badge.csv -t badge_template.svg -o badges docstamp create ...
def create(input, template, field, outdir, prefix, otype, command, index, dpi, verbose, unicode_support): """Use docstamp to create documents from the content of a CSV file or a Google Spreadsheet. Examples: \n docstamp create -i badge.csv -t badge_template.svg -o badges docstamp create ...
[ "Use", "docstamp", "to", "create", "documents", "from", "the", "content", "of", "a", "CSV", "file", "or", "a", "Google", "Spreadsheet", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/cli/cli.py#L62-L159
[ "def", "create", "(", "input", ",", "template", ",", "field", ",", "outdir", ",", "prefix", ",", "otype", ",", "command", ",", "index", ",", "dpi", ",", "verbose", ",", "unicode_support", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "LOG...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
get_extension
Return the extension of fpath. Parameters ---------- fpath: string File name or path check_if_exists: bool Returns ------- str The extension of the file name or path
docstamp/file_utils.py
def get_extension(filepath, check_if_exists=False): """Return the extension of fpath. Parameters ---------- fpath: string File name or path check_if_exists: bool Returns ------- str The extension of the file name or path """ if check_if_exists: if not os.path.e...
def get_extension(filepath, check_if_exists=False): """Return the extension of fpath. Parameters ---------- fpath: string File name or path check_if_exists: bool Returns ------- str The extension of the file name or path """ if check_if_exists: if not os.path.e...
[ "Return", "the", "extension", "of", "fpath", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L21-L47
[ "def", "get_extension", "(", "filepath", ",", "check_if_exists", "=", "False", ")", ":", "if", "check_if_exists", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "err", "=", "'File not found: '", "+", "filepath", "log", ".", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
add_extension_if_needed
Add the extension ext to fpath if it doesn't have it. Parameters ---------- filepath: str File name or path ext: str File extension check_if_exists: bool Returns ------- File name or path with extension added, if needed.
docstamp/file_utils.py
def add_extension_if_needed(filepath, ext, check_if_exists=False): """Add the extension ext to fpath if it doesn't have it. Parameters ---------- filepath: str File name or path ext: str File extension check_if_exists: bool Returns ------- File name or path with extension...
def add_extension_if_needed(filepath, ext, check_if_exists=False): """Add the extension ext to fpath if it doesn't have it. Parameters ---------- filepath: str File name or path ext: str File extension check_if_exists: bool Returns ------- File name or path with extension...
[ "Add", "the", "extension", "ext", "to", "fpath", "if", "it", "doesn", "t", "have", "it", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L50-L76
[ "def", "add_extension_if_needed", "(", "filepath", ",", "ext", ",", "check_if_exists", "=", "False", ")", ":", "if", "not", "filepath", ".", "endswith", "(", "ext", ")", ":", "filepath", "+=", "ext", "if", "check_if_exists", ":", "if", "not", "os", ".", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
get_tempfile
Return a temporary file with the given suffix within dirpath. If dirpath is None, will look for a temporary folder in your system. Parameters ---------- suffix: str Temporary file name suffix dirpath: str Folder path where create the temporary file Returns ------- temp...
docstamp/file_utils.py
def get_tempfile(suffix='.txt', dirpath=None): """ Return a temporary file with the given suffix within dirpath. If dirpath is None, will look for a temporary folder in your system. Parameters ---------- suffix: str Temporary file name suffix dirpath: str Folder path where crea...
def get_tempfile(suffix='.txt', dirpath=None): """ Return a temporary file with the given suffix within dirpath. If dirpath is None, will look for a temporary folder in your system. Parameters ---------- suffix: str Temporary file name suffix dirpath: str Folder path where crea...
[ "Return", "a", "temporary", "file", "with", "the", "given", "suffix", "within", "dirpath", ".", "If", "dirpath", "is", "None", "will", "look", "for", "a", "temporary", "folder", "in", "your", "system", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L95-L115
[ "def", "get_tempfile", "(", "suffix", "=", "'.txt'", ",", "dirpath", "=", "None", ")", ":", "if", "dirpath", "is", "None", ":", "dirpath", "=", "get_temp_dir", "(", ")", "return", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "suffix", ",", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
cleanup
Remove the files in workdir that have the given extension. Parameters ---------- workdir: Folder path from where to clean the files. extension: str File extension without the dot, e.g., 'txt'
docstamp/file_utils.py
def cleanup(workdir, extension): """ Remove the files in workdir that have the given extension. Parameters ---------- workdir: Folder path from where to clean the files. extension: str File extension without the dot, e.g., 'txt' """ [os.remove(f) for f in glob(os.path.join(...
def cleanup(workdir, extension): """ Remove the files in workdir that have the given extension. Parameters ---------- workdir: Folder path from where to clean the files. extension: str File extension without the dot, e.g., 'txt' """ [os.remove(f) for f in glob(os.path.join(...
[ "Remove", "the", "files", "in", "workdir", "that", "have", "the", "given", "extension", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L118-L129
[ "def", "cleanup", "(", "workdir", ",", "extension", ")", ":", "[", "os", ".", "remove", "(", "f", ")", "for", "f", "in", "glob", "(", "os", ".", "path", ".", "join", "(", "workdir", ",", "'*.'", "+", "extension", ")", ")", "]" ]
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
csv_to_json
Convert a CSV file in `csv_filepath` into a JSON file in `json_filepath`. Parameters ---------- csv_filepath: str Path to the input CSV file. json_filepath: str Path to the output JSON file. Will be overwritten if exists. fieldnames: List[str] Names of the fields in the CS...
docstamp/file_utils.py
def csv_to_json(csv_filepath, json_filepath, fieldnames, ignore_first_line=True): """ Convert a CSV file in `csv_filepath` into a JSON file in `json_filepath`. Parameters ---------- csv_filepath: str Path to the input CSV file. json_filepath: str Path to the output JSON file. Will ...
def csv_to_json(csv_filepath, json_filepath, fieldnames, ignore_first_line=True): """ Convert a CSV file in `csv_filepath` into a JSON file in `json_filepath`. Parameters ---------- csv_filepath: str Path to the input CSV file. json_filepath: str Path to the output JSON file. Will ...
[ "Convert", "a", "CSV", "file", "in", "csv_filepath", "into", "a", "JSON", "file", "in", "json_filepath", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L138-L170
[ "def", "csv_to_json", "(", "csv_filepath", ",", "json_filepath", ",", "fieldnames", ",", "ignore_first_line", "=", "True", ")", ":", "import", "csv", "import", "json", "csvfile", "=", "open", "(", "csv_filepath", ",", "'r'", ")", "jsonfile", "=", "open", "("...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
write_to_file
Write `content` inside the file in `file_path` with the given encoding. Parameters ---------- file_path: str Path to the output file. Will be overwritten if exists. content: str The content you want in the file. encoding: str The name of the encoding.
docstamp/file_utils.py
def write_to_file(file_path, content, encoding=None): """ Write `content` inside the file in `file_path` with the given encoding. Parameters ---------- file_path: str Path to the output file. Will be overwritten if exists. content: str The content you want in the file. encoding...
def write_to_file(file_path, content, encoding=None): """ Write `content` inside the file in `file_path` with the given encoding. Parameters ---------- file_path: str Path to the output file. Will be overwritten if exists. content: str The content you want in the file. encoding...
[ "Write", "content", "inside", "the", "file", "in", "file_path", "with", "the", "given", "encoding", ".", "Parameters", "----------", "file_path", ":", "str", "Path", "to", "the", "output", "file", ".", "Will", "be", "overwritten", "if", "exists", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L173-L195
[ "def", "write_to_file", "(", "file_path", ",", "content", ",", "encoding", "=", "None", ")", ":", "try", ":", "# TODO: check if in Python2 this should be this way", "# it's possible that we have to make this function more complex", "# to check type(content) and depending on that set ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
replace_file_content
Modify the content of `filepath`, replacing `old` for `new`. Parameters ---------- filepath: str Path to the file to be modified. It will be overwritten. old: str This is old substring to be replaced. new: str This is new substring, which would replace old substring. ...
docstamp/file_utils.py
def replace_file_content(filepath, old, new, max=1): """ Modify the content of `filepath`, replacing `old` for `new`. Parameters ---------- filepath: str Path to the file to be modified. It will be overwritten. old: str This is old substring to be replaced. new: str Th...
def replace_file_content(filepath, old, new, max=1): """ Modify the content of `filepath`, replacing `old` for `new`. Parameters ---------- filepath: str Path to the file to be modified. It will be overwritten. old: str This is old substring to be replaced. new: str Th...
[ "Modify", "the", "content", "of", "filepath", "replacing", "old", "for", "new", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L198-L220
[ "def", "replace_file_content", "(", "filepath", ",", "old", ",", "new", ",", "max", "=", "1", ")", ":", "with", "open", "(", "filepath", ",", "'r'", ")", "as", "f", ":", "content", "=", "f", ".", "read", "(", ")", "content", "=", "content", ".", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
cleanup_docstamp_output
Remove the 'tmp*.aux', 'tmp*.out' and 'tmp*.log' files in `output_dir`. :param output_dir:
docstamp/file_utils.py
def cleanup_docstamp_output(output_dir=''): """ Remove the 'tmp*.aux', 'tmp*.out' and 'tmp*.log' files in `output_dir`. :param output_dir: """ suffixes = ['aux', 'out', 'log'] files = [f for suf in suffixes for f in glob(os.path.join(output_dir, 'tmp*.{}'.format(suf)))] [os.remove(file) for file...
def cleanup_docstamp_output(output_dir=''): """ Remove the 'tmp*.aux', 'tmp*.out' and 'tmp*.log' files in `output_dir`. :param output_dir: """ suffixes = ['aux', 'out', 'log'] files = [f for suf in suffixes for f in glob(os.path.join(output_dir, 'tmp*.{}'.format(suf)))] [os.remove(file) for file...
[ "Remove", "the", "tmp", "*", ".", "aux", "tmp", "*", ".", "out", "and", "tmp", "*", ".", "log", "files", "in", "output_dir", ".", ":", "param", "output_dir", ":" ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/file_utils.py#L223-L229
[ "def", "cleanup_docstamp_output", "(", "output_dir", "=", "''", ")", ":", "suffixes", "=", "[", "'aux'", ",", "'out'", ",", "'log'", "]", "files", "=", "[", "f", "for", "suf", "in", "suffixes", "for", "f", "in", "glob", "(", "os", ".", "path", ".", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
CopyDoc.parse
Run all parsing functions.
copydoc.py
def parse(self): """ Run all parsing functions. """ for tag in self.soup.findAll('span'): self.create_italic(tag) self.create_strong(tag) self.create_underline(tag) self.unwrap_span(tag) for tag in self.soup.findAll('a'): ...
def parse(self): """ Run all parsing functions. """ for tag in self.soup.findAll('span'): self.create_italic(tag) self.create_strong(tag) self.create_underline(tag) self.unwrap_span(tag) for tag in self.soup.findAll('a'): ...
[ "Run", "all", "parsing", "functions", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L58-L80
[ "def", "parse", "(", "self", ")", ":", "for", "tag", "in", "self", ".", "soup", ".", "findAll", "(", "'span'", ")", ":", "self", ".", "create_italic", "(", "tag", ")", "self", ".", "create_strong", "(", "tag", ")", "self", ".", "create_underline", "(...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.check_next
If next tag is link with same href, combine them.
copydoc.py
def check_next(self, tag): """ If next tag is link with same href, combine them. """ if (type(tag.next_sibling) == element.Tag and tag.next_sibling.name == 'a'): next_tag = tag.next_sibling if tag.get('href') and next_tag.get('href'): ...
def check_next(self, tag): """ If next tag is link with same href, combine them. """ if (type(tag.next_sibling) == element.Tag and tag.next_sibling.name == 'a'): next_tag = tag.next_sibling if tag.get('href') and next_tag.get('href'): ...
[ "If", "next", "tag", "is", "link", "with", "same", "href", "combine", "them", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L89-L104
[ "def", "check_next", "(", "self", ",", "tag", ")", ":", "if", "(", "type", "(", "tag", ".", "next_sibling", ")", "==", "element", ".", "Tag", "and", "tag", ".", "next_sibling", ".", "name", "==", "'a'", ")", ":", "next_tag", "=", "tag", ".", "next_...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.create_italic
See if span tag has italic style and wrap with em tag.
copydoc.py
def create_italic(self, tag): """ See if span tag has italic style and wrap with em tag. """ style = tag.get('style') if style and 'font-style:italic' in style: tag.wrap(self.soup.new_tag('em'))
def create_italic(self, tag): """ See if span tag has italic style and wrap with em tag. """ style = tag.get('style') if style and 'font-style:italic' in style: tag.wrap(self.soup.new_tag('em'))
[ "See", "if", "span", "tag", "has", "italic", "style", "and", "wrap", "with", "em", "tag", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L110-L116
[ "def", "create_italic", "(", "self", ",", "tag", ")", ":", "style", "=", "tag", ".", "get", "(", "'style'", ")", "if", "style", "and", "'font-style:italic'", "in", "style", ":", "tag", ".", "wrap", "(", "self", ".", "soup", ".", "new_tag", "(", "'em'...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.create_strong
See if span tag has bold style and wrap with strong tag.
copydoc.py
def create_strong(self, tag): """ See if span tag has bold style and wrap with strong tag. """ style = tag.get('style') if (style and ('font-weight:bold' in style or 'font-weight:700' in style)): tag.wrap(self.soup.new_tag('strong'))
def create_strong(self, tag): """ See if span tag has bold style and wrap with strong tag. """ style = tag.get('style') if (style and ('font-weight:bold' in style or 'font-weight:700' in style)): tag.wrap(self.soup.new_tag('strong'))
[ "See", "if", "span", "tag", "has", "bold", "style", "and", "wrap", "with", "strong", "tag", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L118-L125
[ "def", "create_strong", "(", "self", ",", "tag", ")", ":", "style", "=", "tag", ".", "get", "(", "'style'", ")", "if", "(", "style", "and", "(", "'font-weight:bold'", "in", "style", "or", "'font-weight:700'", "in", "style", ")", ")", ":", "tag", ".", ...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.create_underline
See if span tag has underline style and wrap with u tag.
copydoc.py
def create_underline(self, tag): """ See if span tag has underline style and wrap with u tag. """ style = tag.get('style') if style and 'text-decoration:underline' in style: tag.wrap(self.soup.new_tag('u'))
def create_underline(self, tag): """ See if span tag has underline style and wrap with u tag. """ style = tag.get('style') if style and 'text-decoration:underline' in style: tag.wrap(self.soup.new_tag('u'))
[ "See", "if", "span", "tag", "has", "underline", "style", "and", "wrap", "with", "u", "tag", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L127-L133
[ "def", "create_underline", "(", "self", ",", "tag", ")", ":", "style", "=", "tag", ".", "get", "(", "'style'", ")", "if", "style", "and", "'text-decoration:underline'", "in", "style", ":", "tag", ".", "wrap", "(", "self", ".", "soup", ".", "new_tag", "...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.parse_attrs
Reject attributes not defined in ATTR_WHITELIST.
copydoc.py
def parse_attrs(self, tag): """ Reject attributes not defined in ATTR_WHITELIST. """ if tag.name in ATTR_WHITELIST.keys(): attrs = copy(tag.attrs) for attr, value in attrs.items(): if attr in ATTR_WHITELIST[tag.name]: tag.attrs[...
def parse_attrs(self, tag): """ Reject attributes not defined in ATTR_WHITELIST. """ if tag.name in ATTR_WHITELIST.keys(): attrs = copy(tag.attrs) for attr, value in attrs.items(): if attr in ATTR_WHITELIST[tag.name]: tag.attrs[...
[ "Reject", "attributes", "not", "defined", "in", "ATTR_WHITELIST", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L141-L153
[ "def", "parse_attrs", "(", "self", ",", "tag", ")", ":", "if", "tag", ".", "name", "in", "ATTR_WHITELIST", ".", "keys", "(", ")", ":", "attrs", "=", "copy", "(", "tag", ".", "attrs", ")", "for", "attr", ",", "value", "in", "attrs", ".", "items", ...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.remove_empty
Remove non-self-closing tags with no children *and* no content.
copydoc.py
def remove_empty(self, tag): """ Remove non-self-closing tags with no children *and* no content. """ has_children = len(tag.contents) has_text = len(list(tag.stripped_strings)) if not has_children and not has_text and not tag.is_empty_element: tag.extract()
def remove_empty(self, tag): """ Remove non-self-closing tags with no children *and* no content. """ has_children = len(tag.contents) has_text = len(list(tag.stripped_strings)) if not has_children and not has_text and not tag.is_empty_element: tag.extract()
[ "Remove", "non", "-", "self", "-", "closing", "tags", "with", "no", "children", "*", "and", "*", "no", "content", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L155-L162
[ "def", "remove_empty", "(", "self", ",", "tag", ")", ":", "has_children", "=", "len", "(", "tag", ".", "contents", ")", "has_text", "=", "len", "(", "list", "(", "tag", ".", "stripped_strings", ")", ")", "if", "not", "has_children", "and", "not", "has_...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc.clean_linebreaks
get unicode string without any other content transformation. and clean extra spaces
copydoc.py
def clean_linebreaks(self, tag): """ get unicode string without any other content transformation. and clean extra spaces """ stripped = tag.decode(formatter=None) stripped = re.sub('\s+', ' ', stripped) stripped = re.sub('\n', '', stripped) return stripped
def clean_linebreaks(self, tag): """ get unicode string without any other content transformation. and clean extra spaces """ stripped = tag.decode(formatter=None) stripped = re.sub('\s+', ' ', stripped) stripped = re.sub('\n', '', stripped) return stripped
[ "get", "unicode", "string", "without", "any", "other", "content", "transformation", ".", "and", "clean", "extra", "spaces" ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L179-L187
[ "def", "clean_linebreaks", "(", "self", ",", "tag", ")", ":", "stripped", "=", "tag", ".", "decode", "(", "formatter", "=", "None", ")", "stripped", "=", "re", ".", "sub", "(", "'\\s+'", ",", "' '", ",", "stripped", ")", "stripped", "=", "re", ".", ...
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc._parse_href
Extract "real" URL from Google redirected url by getting `q` querystring parameter.
copydoc.py
def _parse_href(self, href): """ Extract "real" URL from Google redirected url by getting `q` querystring parameter. """ params = parse_qs(urlsplit(href).query) return params.get('q')
def _parse_href(self, href): """ Extract "real" URL from Google redirected url by getting `q` querystring parameter. """ params = parse_qs(urlsplit(href).query) return params.get('q')
[ "Extract", "real", "URL", "from", "Google", "redirected", "url", "by", "getting", "q", "querystring", "parameter", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L189-L195
[ "def", "_parse_href", "(", "self", ",", "href", ")", ":", "params", "=", "parse_qs", "(", "urlsplit", "(", "href", ")", ".", "query", ")", "return", "params", ".", "get", "(", "'q'", ")" ]
e1ab09b287beb0439748c319cf165cbc06c66624
test
CopyDoc._parse_attr
Parse attribute. Delegate to href parser for hrefs, otherwise return value.
copydoc.py
def _parse_attr(self, tagname, attr, value): """ Parse attribute. Delegate to href parser for hrefs, otherwise return value. """ if tagname == 'a' and attr == 'href': return self._parse_href(value) else: return value
def _parse_attr(self, tagname, attr, value): """ Parse attribute. Delegate to href parser for hrefs, otherwise return value. """ if tagname == 'a' and attr == 'href': return self._parse_href(value) else: return value
[ "Parse", "attribute", ".", "Delegate", "to", "href", "parser", "for", "hrefs", "otherwise", "return", "value", "." ]
nprapps/copydoc
python
https://github.com/nprapps/copydoc/blob/e1ab09b287beb0439748c319cf165cbc06c66624/copydoc.py#L197-L205
[ "def", "_parse_attr", "(", "self", ",", "tagname", ",", "attr", ",", "value", ")", ":", "if", "tagname", "==", "'a'", "and", "attr", "==", "'href'", ":", "return", "self", ".", "_parse_href", "(", "value", ")", "else", ":", "return", "value" ]
e1ab09b287beb0439748c319cf165cbc06c66624
test
translate_key_values
Modify the keys in adict to the ones in translations. Be careful, this will modify your input dictionary. The keys not present in translations will be left intact. Parameters ---------- adict: a dictionary translations: iterable of 2-tuples Each 2-tuple must have the following format: ...
docstamp/model.py
def translate_key_values(adict, translations, default=''): """Modify the keys in adict to the ones in translations. Be careful, this will modify your input dictionary. The keys not present in translations will be left intact. Parameters ---------- adict: a dictionary translations: iterable...
def translate_key_values(adict, translations, default=''): """Modify the keys in adict to the ones in translations. Be careful, this will modify your input dictionary. The keys not present in translations will be left intact. Parameters ---------- adict: a dictionary translations: iterable...
[ "Modify", "the", "keys", "in", "adict", "to", "the", "ones", "in", "translations", ".", "Be", "careful", "this", "will", "modify", "your", "input", "dictionary", ".", "The", "keys", "not", "present", "in", "translations", "will", "be", "left", "intact", "....
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/model.py#L13-L32
[ "def", "translate_key_values", "(", "adict", ",", "translations", ",", "default", "=", "''", ")", ":", "for", "src_key", ",", "dst_key", "in", "translations", ":", "adict", "[", "dst_key", "]", "=", "adict", ".", "pop", "(", "src_key", ",", "default", ")...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
JSONMixin.to_json_str
Convert data to json string representation. Returns: json representation as string.
docstamp/model.py
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ adict = dict(vars(self), sort_keys=True) adict['type'] = self.__class__.__name__ return json.dumps(adict)
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ adict = dict(vars(self), sort_keys=True) adict['type'] = self.__class__.__name__ return json.dumps(adict)
[ "Convert", "data", "to", "json", "string", "representation", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/model.py#L62-L70
[ "def", "to_json_str", "(", "self", ")", ":", "adict", "=", "dict", "(", "vars", "(", "self", ")", ",", "sort_keys", "=", "True", ")", "adict", "[", "'type'", "]", "=", "self", ".", "__class__", ".", "__name__", "return", "json", ".", "dumps", "(", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
find_file_match
Returns absolute paths of files that match the regex within folder_path and all its children folders. Note: The regex matching is done using the match function of the re module. Parameters ---------- folder_path: string regex: string Returns ------- A list of strings.
docstamp/config.py
def find_file_match(folder_path, regex=''): """ Returns absolute paths of files that match the regex within folder_path and all its children folders. Note: The regex matching is done using the match function of the re module. Parameters ---------- folder_path: string regex: string...
def find_file_match(folder_path, regex=''): """ Returns absolute paths of files that match the regex within folder_path and all its children folders. Note: The regex matching is done using the match function of the re module. Parameters ---------- folder_path: string regex: string...
[ "Returns", "absolute", "paths", "of", "files", "that", "match", "the", "regex", "within", "folder_path", "and", "all", "its", "children", "folders", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/config.py#L22-L46
[ "def", "find_file_match", "(", "folder_path", ",", "regex", "=", "''", ")", ":", "outlist", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "folder_path", ")", ":", "outlist", ".", "extend", "(", "[", "os", "....
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
qquery
Quick query. Convenience for using the MicroXPath engine. Give it some XML and an expression and it will yield the results. No fuss. xml_thing - bytes or string, or amara3.xml.tree node xpath_thing - string or parsed XPath expression vars - optional mapping of variables, name to value funcs - o...
pylib/uxml/uxpath/__init__.py
def qquery(xml_thing, xpath_thing, vars=None, funcs=None): ''' Quick query. Convenience for using the MicroXPath engine. Give it some XML and an expression and it will yield the results. No fuss. xml_thing - bytes or string, or amara3.xml.tree node xpath_thing - string or parsed XPath expressio...
def qquery(xml_thing, xpath_thing, vars=None, funcs=None): ''' Quick query. Convenience for using the MicroXPath engine. Give it some XML and an expression and it will yield the results. No fuss. xml_thing - bytes or string, or amara3.xml.tree node xpath_thing - string or parsed XPath expressio...
[ "Quick", "query", ".", "Convenience", "for", "using", "the", "MicroXPath", "engine", ".", "Give", "it", "some", "XML", "and", "an", "expression", "and", "it", "will", "yield", "the", "results", ".", "No", "fuss", ".", "xml_thing", "-", "bytes", "or", "st...
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/__init__.py#L103-L135
[ "def", "qquery", "(", "xml_thing", ",", "xpath_thing", ",", "vars", "=", "None", ",", "funcs", "=", "None", ")", ":", "root", "=", "None", "if", "isinstance", "(", "xml_thing", ",", "nodetype", ")", ":", "root", "=", "xml_thing", "elif", "isinstance", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
p_function_call
FunctionCall : NAME FormalArguments
pylib/uxml/uxpath/parserules.py
def p_function_call(p): """ FunctionCall : NAME FormalArguments """ #Hacking around the ambiguity between node type test & function call if p[1] in ('node', 'text'): p[0] = ast.NodeType(p[1]) else: p[0] = ast.FunctionCall(p[1], p[2])
def p_function_call(p): """ FunctionCall : NAME FormalArguments """ #Hacking around the ambiguity between node type test & function call if p[1] in ('node', 'text'): p[0] = ast.NodeType(p[1]) else: p[0] = ast.FunctionCall(p[1], p[2])
[ "FunctionCall", ":", "NAME", "FormalArguments" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/parserules.py#L280-L288
[ "def", "p_function_call", "(", "p", ")", ":", "#Hacking around the ambiguity between node type test & function call", "if", "p", "[", "1", "]", "in", "(", "'node'", ",", "'text'", ")", ":", "p", "[", "0", "]", "=", "ast", ".", "NodeType", "(", "p", "[", "1...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
boolean_arg
Handles LiteralObjects as well as computable arguments
pylib/uxml/uxpath/functions.py
def boolean_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_boolean(obj)
def boolean_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_boolean(obj)
[ "Handles", "LiteralObjects", "as", "well", "as", "computable", "arguments" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L16-L22
[ "def", "boolean_arg", "(", "ctx", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "obj", "=", "next", "(", "obj", ".", "compute", "(", "ctx", ")", ",", "False", ")", "return", "to_boolean", "(", "obj", ")" ]
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
number_arg
Handles LiteralObjects as well as computable arguments
pylib/uxml/uxpath/functions.py
def number_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_number(obj)
def number_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_number(obj)
[ "Handles", "LiteralObjects", "as", "well", "as", "computable", "arguments" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L25-L31
[ "def", "number_arg", "(", "ctx", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "obj", "=", "next", "(", "obj", ".", "compute", "(", "ctx", ")", ",", "False", ")", "return", "to_number", "(", "obj", ")" ]
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
string_arg
Handles LiteralObjects as well as computable arguments
pylib/uxml/uxpath/functions.py
def string_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_string(obj)
def string_arg(ctx, obj): ''' Handles LiteralObjects as well as computable arguments ''' if hasattr(obj, 'compute'): obj = next(obj.compute(ctx), False) return to_string(obj)
[ "Handles", "LiteralObjects", "as", "well", "as", "computable", "arguments" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L34-L40
[ "def", "string_arg", "(", "ctx", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "obj", "=", "next", "(", "obj", ".", "compute", "(", "ctx", ")", ",", "False", ")", "return", "to_string", "(", "obj", ")" ]
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
name
Yields one string a node name or the empty string, operating on the first item in the provided obj, or the current item if obj is omitted If this item is a node, yield its node name (generic identifier), otherwise yield '' If obj is provided, but empty, yield ''
pylib/uxml/uxpath/functions.py
def name(ctx, obj=None): ''' Yields one string a node name or the empty string, operating on the first item in the provided obj, or the current item if obj is omitted If this item is a node, yield its node name (generic identifier), otherwise yield '' If obj is provided, but empty, yield '' ''' ...
def name(ctx, obj=None): ''' Yields one string a node name or the empty string, operating on the first item in the provided obj, or the current item if obj is omitted If this item is a node, yield its node name (generic identifier), otherwise yield '' If obj is provided, but empty, yield '' ''' ...
[ "Yields", "one", "string", "a", "node", "name", "or", "the", "empty", "string", "operating", "on", "the", "first", "item", "in", "the", "provided", "obj", "or", "the", "current", "item", "if", "obj", "is", "omitted", "If", "this", "item", "is", "a", "n...
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L58-L73
[ "def", "name", "(", "ctx", ",", "obj", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "item", "=", "ctx", ".", "item", "elif", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "item", "=", "next", "(", "obj", ".", "compute", "(", "ctx...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
string_
Yields one string, derived from the argument literal (or the first item in the argument sequence, unless empty in which case yield '') as follows: * If a node, yield its string-value * If NaN, yield 'NaN' * If +0 or -0, yield '0' * If positive infinity, yield 'Infinity' * If negative infinity, yiel...
pylib/uxml/uxpath/functions.py
def string_(ctx, seq=None): ''' Yields one string, derived from the argument literal (or the first item in the argument sequence, unless empty in which case yield '') as follows: * If a node, yield its string-value * If NaN, yield 'NaN' * If +0 or -0, yield '0' * If positive infinity, yield 'In...
def string_(ctx, seq=None): ''' Yields one string, derived from the argument literal (or the first item in the argument sequence, unless empty in which case yield '') as follows: * If a node, yield its string-value * If NaN, yield 'NaN' * If +0 or -0, yield '0' * If positive infinity, yield 'In...
[ "Yields", "one", "string", "derived", "from", "the", "argument", "literal", "(", "or", "the", "first", "item", "in", "the", "argument", "sequence", "unless", "empty", "in", "which", "case", "yield", ")", "as", "follows", ":" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L93-L112
[ "def", "string_", "(", "ctx", ",", "seq", "=", "None", ")", ":", "if", "seq", "is", "None", ":", "item", "=", "ctx", ".", "item", "elif", "hasattr", "(", "seq", ",", "'compute'", ")", ":", "item", "=", "next", "(", "seq", ".", "compute", "(", "...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
concat
Yields one string, concatenation of argument strings
pylib/uxml/uxpath/functions.py
def concat(ctx, *strings): ''' Yields one string, concatenation of argument strings ''' strings = flatten([ (s.compute(ctx) if callable(s) else s) for s in strings ]) strings = (next(string_arg(ctx, s), '') for s in strings) #assert(all(map(lambda x: isinstance(x, str), strings))) #FIXME: Ch...
def concat(ctx, *strings): ''' Yields one string, concatenation of argument strings ''' strings = flatten([ (s.compute(ctx) if callable(s) else s) for s in strings ]) strings = (next(string_arg(ctx, s), '') for s in strings) #assert(all(map(lambda x: isinstance(x, str), strings))) #FIXME: Ch...
[ "Yields", "one", "string", "concatenation", "of", "argument", "strings" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L119-L127
[ "def", "concat", "(", "ctx", ",", "*", "strings", ")", ":", "strings", "=", "flatten", "(", "[", "(", "s", ".", "compute", "(", "ctx", ")", "if", "callable", "(", "s", ")", "else", "s", ")", "for", "s", "in", "strings", "]", ")", "strings", "="...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
starts_with
Yields one boolean, whether the first string starts with the second
pylib/uxml/uxpath/functions.py
def starts_with(ctx, full, part): ''' Yields one boolean, whether the first string starts with the second ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.startswith(part)
def starts_with(ctx, full, part): ''' Yields one boolean, whether the first string starts with the second ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.startswith(part)
[ "Yields", "one", "boolean", "whether", "the", "first", "string", "starts", "with", "the", "second" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L131-L137
[ "def", "starts_with", "(", "ctx", ",", "full", ",", "part", ")", ":", "full", "=", "next", "(", "string_arg", "(", "ctx", ",", "full", ")", ",", "''", ")", "part", "=", "next", "(", "string_arg", "(", "ctx", ",", "part", ")", ",", "''", ")", "y...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
contains
Yields one boolean, whether the first string contains the second
pylib/uxml/uxpath/functions.py
def contains(ctx, full, part): ''' Yields one boolean, whether the first string contains the second ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield part in full
def contains(ctx, full, part): ''' Yields one boolean, whether the first string contains the second ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield part in full
[ "Yields", "one", "boolean", "whether", "the", "first", "string", "contains", "the", "second" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L141-L147
[ "def", "contains", "(", "ctx", ",", "full", ",", "part", ")", ":", "full", "=", "next", "(", "string_arg", "(", "ctx", ",", "full", ")", ",", "''", ")", "part", "=", "next", "(", "string_arg", "(", "ctx", ",", "part", ")", ",", "''", ")", "yiel...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
substring_before
Yields one string
pylib/uxml/uxpath/functions.py
def substring_before(ctx, full, part): ''' Yields one string ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.partition(part)[0]
def substring_before(ctx, full, part): ''' Yields one string ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.partition(part)[0]
[ "Yields", "one", "string" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L151-L157
[ "def", "substring_before", "(", "ctx", ",", "full", ",", "part", ")", ":", "full", "=", "next", "(", "string_arg", "(", "ctx", ",", "full", ")", ",", "''", ")", "part", "=", "next", "(", "string_arg", "(", "ctx", ",", "part", ")", ",", "''", ")",...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
substring_after
Yields one string
pylib/uxml/uxpath/functions.py
def substring_after(ctx, full, part): ''' Yields one string ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.partition(part)[-1]
def substring_after(ctx, full, part): ''' Yields one string ''' full = next(string_arg(ctx, full), '') part = next(string_arg(ctx, part), '') yield full.partition(part)[-1]
[ "Yields", "one", "string" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L161-L167
[ "def", "substring_after", "(", "ctx", ",", "full", ",", "part", ")", ":", "full", "=", "next", "(", "string_arg", "(", "ctx", ",", "full", ")", ",", "''", ")", "part", "=", "next", "(", "string_arg", "(", "ctx", ",", "part", ")", ",", "''", ")", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
substring
Yields one string
pylib/uxml/uxpath/functions.py
def substring(ctx, full, start, length): ''' Yields one string ''' full = next(string_arg(ctx, full), '') start = int(next(to_number(start))) length = int(next(to_number(length))) yield full[start-1:start-1+length]
def substring(ctx, full, start, length): ''' Yields one string ''' full = next(string_arg(ctx, full), '') start = int(next(to_number(start))) length = int(next(to_number(length))) yield full[start-1:start-1+length]
[ "Yields", "one", "string" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L171-L178
[ "def", "substring", "(", "ctx", ",", "full", ",", "start", ",", "length", ")", ":", "full", "=", "next", "(", "string_arg", "(", "ctx", ",", "full", ")", ",", "''", ")", "start", "=", "int", "(", "next", "(", "to_number", "(", "start", ")", ")", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
string_length
Yields one number
pylib/uxml/uxpath/functions.py
def string_length(ctx, s=None): ''' Yields one number ''' if s is None: s = ctx.node elif callable(s): s = next(s.compute(ctx), '') yield len(s)
def string_length(ctx, s=None): ''' Yields one number ''' if s is None: s = ctx.node elif callable(s): s = next(s.compute(ctx), '') yield len(s)
[ "Yields", "one", "number" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L182-L190
[ "def", "string_length", "(", "ctx", ",", "s", "=", "None", ")", ":", "if", "s", "is", "None", ":", "s", "=", "ctx", ".", "node", "elif", "callable", "(", "s", ")", ":", "s", "=", "next", "(", "s", ".", "compute", "(", "ctx", ")", ",", "''", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
boolean
Yields one boolean, false if the argument sequence is empty, otherwise * false if the first item is a boolean and false * false if the first item is a number and positive or negative zero or NaN * false if the first item is a string and '' * true in all other cases
pylib/uxml/uxpath/functions.py
def boolean(ctx, obj): ''' Yields one boolean, false if the argument sequence is empty, otherwise * false if the first item is a boolean and false * false if the first item is a number and positive or negative zero or NaN * false if the first item is a string and '' * true in all other cases ...
def boolean(ctx, obj): ''' Yields one boolean, false if the argument sequence is empty, otherwise * false if the first item is a boolean and false * false if the first item is a number and positive or negative zero or NaN * false if the first item is a string and '' * true in all other cases ...
[ "Yields", "one", "boolean", "false", "if", "the", "argument", "sequence", "is", "empty", "otherwise" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L224-L237
[ "def", "boolean", "(", "ctx", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "obj", "=", "next", "(", "seq", ".", "compute", "(", "ctx", ")", ",", "''", ")", "else", ":", "obj", "=", "seq", "yield", "next", "(", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
number
Yields one float, derived from the first item in the argument sequence (unless empty in which case yield NaN) as follows: * If string with optional whitespace followed by an optional minus sign followed by a Number followed by whitespace, converte to the IEEE 754 number that is nearest (according to the IEEE 754 r...
pylib/uxml/uxpath/functions.py
def number(ctx, seq=None): ''' Yields one float, derived from the first item in the argument sequence (unless empty in which case yield NaN) as follows: * If string with optional whitespace followed by an optional minus sign followed by a Number followed by whitespace, converte to the IEEE 754 number that ...
def number(ctx, seq=None): ''' Yields one float, derived from the first item in the argument sequence (unless empty in which case yield NaN) as follows: * If string with optional whitespace followed by an optional minus sign followed by a Number followed by whitespace, converte to the IEEE 754 number that ...
[ "Yields", "one", "float", "derived", "from", "the", "first", "item", "in", "the", "argument", "sequence", "(", "unless", "empty", "in", "which", "case", "yield", "NaN", ")", "as", "follows", ":" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L265-L277
[ "def", "number", "(", "ctx", ",", "seq", "=", "None", ")", ":", "if", "hasattr", "(", "obj", ",", "'compute'", ")", ":", "obj", "=", "next", "(", "seq", ".", "compute", "(", "ctx", ")", ",", "''", ")", "else", ":", "obj", "=", "seq", "yield", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
foreach_
Yields the result of applying an expression to each item in the input sequence. * seq: input sequence * expr: expression to be converted to string, then dynamically evaluated for each item on the sequence to produce the result
pylib/uxml/uxpath/functions.py
def foreach_(ctx, seq, expr): ''' Yields the result of applying an expression to each item in the input sequence. * seq: input sequence * expr: expression to be converted to string, then dynamically evaluated for each item on the sequence to produce the result ''' from . import context, parse a...
def foreach_(ctx, seq, expr): ''' Yields the result of applying an expression to each item in the input sequence. * seq: input sequence * expr: expression to be converted to string, then dynamically evaluated for each item on the sequence to produce the result ''' from . import context, parse a...
[ "Yields", "the", "result", "of", "applying", "an", "expression", "to", "each", "item", "in", "the", "input", "sequence", "." ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L281-L298
[ "def", "foreach_", "(", "ctx", ",", "seq", ",", "expr", ")", ":", "from", ".", "import", "context", ",", "parse", "as", "uxpathparse", "if", "hasattr", "(", "seq", ",", "'compute'", ")", ":", "seq", "=", "seq", ".", "compute", "(", "ctx", ")", "exp...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
lookup_
Yields a sequence of a single value, the result of looking up a value from the tables provided in the context, or an empty sequence if lookup is unsuccessful * tableid: id of the lookup table to use * expr: expression to be converted to string, then dynamically evaluated for each item on the sequence to produc...
pylib/uxml/uxpath/functions.py
def lookup_(ctx, tableid, key): ''' Yields a sequence of a single value, the result of looking up a value from the tables provided in the context, or an empty sequence if lookup is unsuccessful * tableid: id of the lookup table to use * expr: expression to be converted to string, then dynamically evalu...
def lookup_(ctx, tableid, key): ''' Yields a sequence of a single value, the result of looking up a value from the tables provided in the context, or an empty sequence if lookup is unsuccessful * tableid: id of the lookup table to use * expr: expression to be converted to string, then dynamically evalu...
[ "Yields", "a", "sequence", "of", "a", "single", "value", "the", "result", "of", "looking", "up", "a", "value", "from", "the", "tables", "provided", "in", "the", "context", "or", "an", "empty", "sequence", "if", "lookup", "is", "unsuccessful" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/functions.py#L302-L314
[ "def", "lookup_", "(", "ctx", ",", "tableid", ",", "key", ")", ":", "tableid", "=", "next", "(", "string_arg", "(", "ctx", ",", "tableid", ")", ",", "''", ")", "key", "=", "next", "(", "string_arg", "(", "ctx", ",", "key", ")", ",", "''", ")", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
replace_chars_for_svg_code
Replace known special characters to SVG code. Parameters ---------- svg_content: str Returns ------- corrected_svg: str Corrected SVG content
docstamp/svg_utils.py
def replace_chars_for_svg_code(svg_content): """ Replace known special characters to SVG code. Parameters ---------- svg_content: str Returns ------- corrected_svg: str Corrected SVG content """ result = svg_content svg_char = [ ('&', '&'), ('>', '&g...
def replace_chars_for_svg_code(svg_content): """ Replace known special characters to SVG code. Parameters ---------- svg_content: str Returns ------- corrected_svg: str Corrected SVG content """ result = svg_content svg_char = [ ('&', '&'), ('>', '&g...
[ "Replace", "known", "special", "characters", "to", "SVG", "code", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_utils.py#L13-L36
[ "def", "replace_chars_for_svg_code", "(", "svg_content", ")", ":", "result", "=", "svg_content", "svg_char", "=", "[", "(", "'&'", ",", "'&amp;'", ")", ",", "(", "'>'", ",", "'&gt;'", ")", ",", "(", "'<'", ",", "'&lt;'", ")", ",", "(", "'\"'", ",", "...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
_check_svg_file
Try to read a SVG file if `svg_file` is a string. Raise an exception in case of error or return the svg object. If `svg_file` is a svgutils svg object, will just return it. Parameters ---------- svg_file: str or svgutils.transform.SVGFigure object If a `str`: path to a '.svg' file, ...
docstamp/svg_utils.py
def _check_svg_file(svg_file): """ Try to read a SVG file if `svg_file` is a string. Raise an exception in case of error or return the svg object. If `svg_file` is a svgutils svg object, will just return it. Parameters ---------- svg_file: str or svgutils.transform.SVGFigure object If ...
def _check_svg_file(svg_file): """ Try to read a SVG file if `svg_file` is a string. Raise an exception in case of error or return the svg object. If `svg_file` is a svgutils svg object, will just return it. Parameters ---------- svg_file: str or svgutils.transform.SVGFigure object If ...
[ "Try", "to", "read", "a", "SVG", "file", "if", "svg_file", "is", "a", "string", ".", "Raise", "an", "exception", "in", "case", "of", "error", "or", "return", "the", "svg", "object", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_utils.py#L39-L70
[ "def", "_check_svg_file", "(", "svg_file", ")", ":", "if", "isinstance", "(", "svg_file", ",", "str", ")", ":", "try", ":", "svg", "=", "sg", ".", "fromfile", "(", "svg_file", ")", "except", "Exception", "as", "exc", ":", "raise", "Exception", "(", "'E...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
merge_svg_files
Merge `svg_file2` in `svg_file1` in the given positions `x_coord`, `y_coord` and `scale`. Parameters ---------- svg_file1: str or svgutils svg document object Path to a '.svg' file. svg_file2: str or svgutils svg document object Path to a '.svg' file. x_coord: float Horizo...
docstamp/svg_utils.py
def merge_svg_files(svg_file1, svg_file2, x_coord, y_coord, scale=1): """ Merge `svg_file2` in `svg_file1` in the given positions `x_coord`, `y_coord` and `scale`. Parameters ---------- svg_file1: str or svgutils svg document object Path to a '.svg' file. svg_file2: str or svgutils svg doc...
def merge_svg_files(svg_file1, svg_file2, x_coord, y_coord, scale=1): """ Merge `svg_file2` in `svg_file1` in the given positions `x_coord`, `y_coord` and `scale`. Parameters ---------- svg_file1: str or svgutils svg document object Path to a '.svg' file. svg_file2: str or svgutils svg doc...
[ "Merge", "svg_file2", "in", "svg_file1", "in", "the", "given", "positions", "x_coord", "y_coord", "and", "scale", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_utils.py#L73-L105
[ "def", "merge_svg_files", "(", "svg_file1", ",", "svg_file2", ",", "x_coord", ",", "y_coord", ",", "scale", "=", "1", ")", ":", "svg1", "=", "_check_svg_file", "(", "svg_file1", ")", "svg2", "=", "_check_svg_file", "(", "svg_file2", ")", "svg2_root", "=", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
rsvg_export
Calls the `rsvg-convert` command, to convert a svg to a PDF (with unicode). Parameters ---------- rsvg_binpath: str Path to `rsvg-convert` command input_file: str Path to the input file output_file: str Path to the output file Returns ------- return_value ...
docstamp/svg_utils.py
def rsvg_export(input_file, output_file, dpi=90, rsvg_binpath=None): """ Calls the `rsvg-convert` command, to convert a svg to a PDF (with unicode). Parameters ---------- rsvg_binpath: str Path to `rsvg-convert` command input_file: str Path to the input file output_file: str ...
def rsvg_export(input_file, output_file, dpi=90, rsvg_binpath=None): """ Calls the `rsvg-convert` command, to convert a svg to a PDF (with unicode). Parameters ---------- rsvg_binpath: str Path to `rsvg-convert` command input_file: str Path to the input file output_file: str ...
[ "Calls", "the", "rsvg", "-", "convert", "command", "to", "convert", "a", "svg", "to", "a", "PDF", "(", "with", "unicode", ")", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_utils.py#L108-L144
[ "def", "rsvg_export", "(", "input_file", ",", "output_file", ",", "dpi", "=", "90", ",", "rsvg_binpath", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "input_file", ")", ":", "log", ".", "error", "(", "'File {} not found.'", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
merge_pdfs
Merge all the PDF files in `pdf_filepaths` in a new PDF file `out_filepath`. Parameters ---------- pdf_filepaths: list of str Paths to PDF files. out_filepath: str Path to the result PDF file. Returns ------- path: str The output file path.
docstamp/pdf_utils.py
def merge_pdfs(pdf_filepaths, out_filepath): """ Merge all the PDF files in `pdf_filepaths` in a new PDF file `out_filepath`. Parameters ---------- pdf_filepaths: list of str Paths to PDF files. out_filepath: str Path to the result PDF file. Returns ------- path: str ...
def merge_pdfs(pdf_filepaths, out_filepath): """ Merge all the PDF files in `pdf_filepaths` in a new PDF file `out_filepath`. Parameters ---------- pdf_filepaths: list of str Paths to PDF files. out_filepath: str Path to the result PDF file. Returns ------- path: str ...
[ "Merge", "all", "the", "PDF", "files", "in", "pdf_filepaths", "in", "a", "new", "PDF", "file", "out_filepath", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/pdf_utils.py#L9-L31
[ "def", "merge_pdfs", "(", "pdf_filepaths", ",", "out_filepath", ")", ":", "merger", "=", "PdfFileMerger", "(", ")", "for", "pdf", "in", "pdf_filepaths", ":", "merger", ".", "append", "(", "PdfFileReader", "(", "open", "(", "pdf", ",", "'rb'", ")", ")", "...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
_embed_font_to_svg
Return the ElementTree of the SVG content in `filepath` with the font content embedded.
docstamp/svg_fonts.py
def _embed_font_to_svg(filepath, font_files): """ Return the ElementTree of the SVG content in `filepath` with the font content embedded. """ with open(filepath, 'r') as svgf: tree = etree.parse(svgf) if not font_files: return tree fontfaces = FontFaceGroup() for font_file ...
def _embed_font_to_svg(filepath, font_files): """ Return the ElementTree of the SVG content in `filepath` with the font content embedded. """ with open(filepath, 'r') as svgf: tree = etree.parse(svgf) if not font_files: return tree fontfaces = FontFaceGroup() for font_file ...
[ "Return", "the", "ElementTree", "of", "the", "SVG", "content", "in", "filepath", "with", "the", "font", "content", "embedded", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_fonts.py#L97-L117
[ "def", "_embed_font_to_svg", "(", "filepath", ",", "font_files", ")", ":", "with", "open", "(", "filepath", ",", "'r'", ")", "as", "svgf", ":", "tree", "=", "etree", ".", "parse", "(", "svgf", ")", "if", "not", "font_files", ":", "return", "tree", "fon...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
embed_font_to_svg
Write ttf and otf font content from `font_files` in the svg file in `filepath` and write the result in `outfile`. Parameters ---------- filepath: str The SVG file whose content must be modified. outfile: str The file path where the result will be written. font_files: itera...
docstamp/svg_fonts.py
def embed_font_to_svg(filepath, outfile, font_files): """ Write ttf and otf font content from `font_files` in the svg file in `filepath` and write the result in `outfile`. Parameters ---------- filepath: str The SVG file whose content must be modified. outfile: str The file...
def embed_font_to_svg(filepath, outfile, font_files): """ Write ttf and otf font content from `font_files` in the svg file in `filepath` and write the result in `outfile`. Parameters ---------- filepath: str The SVG file whose content must be modified. outfile: str The file...
[ "Write", "ttf", "and", "otf", "font", "content", "from", "font_files", "in", "the", "svg", "file", "in", "filepath", "and", "write", "the", "result", "in", "outfile", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/svg_fonts.py#L120-L137
[ "def", "embed_font_to_svg", "(", "filepath", ",", "outfile", ",", "font_files", ")", ":", "tree", "=", "_embed_font_to_svg", "(", "filepath", ",", "font_files", ")", "tree", ".", "write", "(", "outfile", ",", "encoding", "=", "'utf-8'", ",", "pretty_print", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
SearchMethod._check_inputs
make some basic checks on the inputs to make sure they are valid
src/melody/search.py
def _check_inputs(self): ''' make some basic checks on the inputs to make sure they are valid''' try: _ = self._inputs[0] except TypeError: raise RuntimeError( "inputs should be iterable but found type='{0}', value=" "'{1}'".format(type(sel...
def _check_inputs(self): ''' make some basic checks on the inputs to make sure they are valid''' try: _ = self._inputs[0] except TypeError: raise RuntimeError( "inputs should be iterable but found type='{0}', value=" "'{1}'".format(type(sel...
[ "make", "some", "basic", "checks", "on", "the", "inputs", "to", "make", "sure", "they", "are", "valid" ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/search.py#L49-L63
[ "def", "_check_inputs", "(", "self", ")", ":", "try", ":", "_", "=", "self", ".", "_inputs", "[", "0", "]", "except", "TypeError", ":", "raise", "RuntimeError", "(", "\"inputs should be iterable but found type='{0}', value=\"", "\"'{1}'\"", ".", "format", "(", "...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
SearchMethod._check_function
make some basic checks on the function to make sure it is valid
src/melody/search.py
def _check_function(self): ''' make some basic checks on the function to make sure it is valid''' # note, callable is valid for Python 2 and Python 3.2 onwards but # not inbetween if not callable(self._function): raise RuntimeError( "provided function '{0}' is...
def _check_function(self): ''' make some basic checks on the function to make sure it is valid''' # note, callable is valid for Python 2 and Python 3.2 onwards but # not inbetween if not callable(self._function): raise RuntimeError( "provided function '{0}' is...
[ "make", "some", "basic", "checks", "on", "the", "function", "to", "make", "sure", "it", "is", "valid" ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/search.py#L65-L79
[ "def", "_check_function", "(", "self", ")", ":", "# note, callable is valid for Python 2 and Python 3.2 onwards but", "# not inbetween", "if", "not", "callable", "(", "self", ".", "_function", ")", ":", "raise", "RuntimeError", "(", "\"provided function '{0}' is not callable\...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
BruteForce._recurse
internal recursion routine called by the run method that generates all input combinations
src/melody/search.py
def _recurse(self, inputs, output): '''internal recursion routine called by the run method that generates all input combinations''' if inputs: my_input = inputs[0] name = my_input.name if my_input.state: my_options = my_input.options(self.state...
def _recurse(self, inputs, output): '''internal recursion routine called by the run method that generates all input combinations''' if inputs: my_input = inputs[0] name = my_input.name if my_input.state: my_options = my_input.options(self.state...
[ "internal", "recursion", "routine", "called", "by", "the", "run", "method", "that", "generates", "all", "input", "combinations" ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/search.py#L121-L140
[ "def", "_recurse", "(", "self", ",", "inputs", ",", "output", ")", ":", "if", "inputs", ":", "my_input", "=", "inputs", "[", "0", "]", "name", "=", "my_input", ".", "name", "if", "my_input", ".", "state", ":", "my_options", "=", "my_input", ".", "opt...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
create_input
create an input file using jinja2 by filling a template with the values from the option variable passed in.
src/melody/inputs.py
def create_input(option, template_name, template_location="template"): '''create an input file using jinja2 by filling a template with the values from the option variable passed in.''' # restructure option list into jinja2 input format jinja2_input = {} for item in option: try: ...
def create_input(option, template_name, template_location="template"): '''create an input file using jinja2 by filling a template with the values from the option variable passed in.''' # restructure option list into jinja2 input format jinja2_input = {} for item in option: try: ...
[ "create", "an", "input", "file", "using", "jinja2", "by", "filling", "a", "template", "with", "the", "values", "from", "the", "option", "variable", "passed", "in", "." ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/inputs.py#L155-L180
[ "def", "create_input", "(", "option", ",", "template_name", ",", "template_location", "=", "\"template\"", ")", ":", "# restructure option list into jinja2 input format", "jinja2_input", "=", "{", "}", "for", "item", "in", "option", ":", "try", ":", "jinja2_input", ...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
Subsets._recurse
We work out all combinations using this internal recursion method
src/melody/inputs.py
def _recurse(self, inputs, output, depth, max_depth): '''We work out all combinations using this internal recursion method''' if depth < max_depth: for index, option in enumerate(inputs): my_output = list(output) my_output.append(option) self._...
def _recurse(self, inputs, output, depth, max_depth): '''We work out all combinations using this internal recursion method''' if depth < max_depth: for index, option in enumerate(inputs): my_output = list(output) my_output.append(option) self._...
[ "We", "work", "out", "all", "combinations", "using", "this", "internal", "recursion", "method" ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/inputs.py#L143-L152
[ "def", "_recurse", "(", "self", ",", "inputs", ",", "output", ",", "depth", ",", "max_depth", ")", ":", "if", "depth", "<", "max_depth", ":", "for", "index", ",", "option", "in", "enumerate", "(", "inputs", ")", ":", "my_output", "=", "list", "(", "o...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
to_string
Cast an arbitrary object or sequence to a string type
pylib/uxml/uxpath/ast.py
def to_string(obj): ''' Cast an arbitrary object or sequence to a string type ''' if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is None: yield '' ...
def to_string(obj): ''' Cast an arbitrary object or sequence to a string type ''' if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is None: yield '' ...
[ "Cast", "an", "arbitrary", "object", "or", "sequence", "to", "a", "string", "type" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/ast.py#L88-L109
[ "def", "to_string", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "LiteralWrapper", ")", ":", "val", "=", "obj", ".", "obj", "elif", "isinstance", "(", "obj", ",", "Iterable", ")", "and", "not", "isinstance", "(", "obj", ",", "str", ")",...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
to_number
Cast an arbitrary object or sequence to a number type
pylib/uxml/uxpath/ast.py
def to_number(obj): ''' Cast an arbitrary object or sequence to a number type ''' if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is None: #FIXME: Shoul...
def to_number(obj): ''' Cast an arbitrary object or sequence to a number type ''' if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is None: #FIXME: Shoul...
[ "Cast", "an", "arbitrary", "object", "or", "sequence", "to", "a", "number", "type" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/ast.py#L112-L132
[ "def", "to_number", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "LiteralWrapper", ")", ":", "val", "=", "obj", ".", "obj", "elif", "isinstance", "(", "obj", ",", "Iterable", ")", "and", "not", "isinstance", "(", "obj", ",", "str", ")",...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
to_boolean
Cast an arbitrary sequence to a boolean type
pylib/uxml/uxpath/ast.py
def to_boolean(obj): ''' Cast an arbitrary sequence to a boolean type ''' #if hasattr(obj, '__iter__'): if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is N...
def to_boolean(obj): ''' Cast an arbitrary sequence to a boolean type ''' #if hasattr(obj, '__iter__'): if isinstance(obj, LiteralWrapper): val = obj.obj elif isinstance(obj, Iterable) and not isinstance(obj, str): val = next(obj, None) else: val = obj if val is N...
[ "Cast", "an", "arbitrary", "sequence", "to", "a", "boolean", "type" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/ast.py#L135-L157
[ "def", "to_boolean", "(", "obj", ")", ":", "#if hasattr(obj, '__iter__'):", "if", "isinstance", "(", "obj", ",", "LiteralWrapper", ")", ":", "val", "=", "obj", ".", "obj", "elif", "isinstance", "(", "obj", ",", "Iterable", ")", "and", "not", "isinstance", ...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
_serialize
Generate token strings which, when joined together, form a valid XPath serialization of the AST.
pylib/uxml/uxpath/ast.py
def _serialize(xp_ast): '''Generate token strings which, when joined together, form a valid XPath serialization of the AST.''' if hasattr(xp_ast, '_serialize'): for tok in xp_ast._serialize(): yield(tok) elif isinstance(xp_ast, str): yield(repr(xp_ast))
def _serialize(xp_ast): '''Generate token strings which, when joined together, form a valid XPath serialization of the AST.''' if hasattr(xp_ast, '_serialize'): for tok in xp_ast._serialize(): yield(tok) elif isinstance(xp_ast, str): yield(repr(xp_ast))
[ "Generate", "token", "strings", "which", "when", "joined", "together", "form", "a", "valid", "XPath", "serialization", "of", "the", "AST", "." ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/uxpath/ast.py#L713-L721
[ "def", "_serialize", "(", "xp_ast", ")", ":", "if", "hasattr", "(", "xp_ast", ",", "'_serialize'", ")", ":", "for", "tok", "in", "xp_ast", ".", "_serialize", "(", ")", ":", "yield", "(", "tok", ")", "elif", "isinstance", "(", "xp_ast", ",", "str", ")...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
change_xml_encoding
Modify the encoding entry in the XML file. Parameters ---------- filepath: str Path to the file to be modified. src_enc: str Encoding that is written in the file dst_enc: str Encoding to be set in the file.
docstamp/xml_utils.py
def change_xml_encoding(filepath, src_enc, dst_enc='utf-8'): """ Modify the encoding entry in the XML file. Parameters ---------- filepath: str Path to the file to be modified. src_enc: str Encoding that is written in the file dst_enc: str Encoding to be set in the fil...
def change_xml_encoding(filepath, src_enc, dst_enc='utf-8'): """ Modify the encoding entry in the XML file. Parameters ---------- filepath: str Path to the file to be modified. src_enc: str Encoding that is written in the file dst_enc: str Encoding to be set in the fil...
[ "Modify", "the", "encoding", "entry", "in", "the", "XML", "file", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/xml_utils.py#L51-L66
[ "def", "change_xml_encoding", "(", "filepath", ",", "src_enc", ",", "dst_enc", "=", "'utf-8'", ")", ":", "enc_attr", "=", "\"encoding='{}'\"", "replace_file_content", "(", "filepath", ",", "enc_attr", ".", "format", "(", "src_enc", ")", ",", "enc_attr", ".", "...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
save_into_qrcode
Save `text` in a qrcode svg image file. Parameters ---------- text: str The string to be codified in the QR image. out_filepath: str Path to the output file color: str A RGB color expressed in 6 hexadecimal values. box_size: scalar Size of the QR code boxes.
docstamp/qrcode.py
def save_into_qrcode(text, out_filepath, color='', box_size=10, pixel_size=1850): """ Save `text` in a qrcode svg image file. Parameters ---------- text: str The string to be codified in the QR image. out_filepath: str Path to the output file color: str A RGB color exp...
def save_into_qrcode(text, out_filepath, color='', box_size=10, pixel_size=1850): """ Save `text` in a qrcode svg image file. Parameters ---------- text: str The string to be codified in the QR image. out_filepath: str Path to the output file color: str A RGB color exp...
[ "Save", "text", "in", "a", "qrcode", "svg", "image", "file", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/qrcode.py#L10-L41
[ "def", "save_into_qrcode", "(", "text", ",", "out_filepath", ",", "color", "=", "''", ",", "box_size", "=", "10", ",", "pixel_size", "=", "1850", ")", ":", "try", ":", "qr", "=", "qrcode", ".", "QRCode", "(", "version", "=", "1", ",", "error_correction...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
_qrcode_to_file
Save a `qrcode` object into `out_filepath`. Parameters ---------- qrcode: qrcode object out_filepath: str Path to the output file.
docstamp/qrcode.py
def _qrcode_to_file(qrcode, out_filepath): """ Save a `qrcode` object into `out_filepath`. Parameters ---------- qrcode: qrcode object out_filepath: str Path to the output file. """ try: qrcode.save(out_filepath) except Exception as exc: raise IOError('Error tryi...
def _qrcode_to_file(qrcode, out_filepath): """ Save a `qrcode` object into `out_filepath`. Parameters ---------- qrcode: qrcode object out_filepath: str Path to the output file. """ try: qrcode.save(out_filepath) except Exception as exc: raise IOError('Error tryi...
[ "Save", "a", "qrcode", "object", "into", "out_filepath", ".", "Parameters", "----------", "qrcode", ":", "qrcode", "object" ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/qrcode.py#L44-L58
[ "def", "_qrcode_to_file", "(", "qrcode", ",", "out_filepath", ")", ":", "try", ":", "qrcode", ".", "save", "(", "out_filepath", ")", "except", "Exception", "as", "exc", ":", "raise", "IOError", "(", "'Error trying to save QR code file {}.'", ".", "format", "(", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
handle_cdata
Return (result, new_position) tuple. Result is cdata string if possible and None if more input is needed Or of course bad syntax can raise a RuntimeError
pylib/uxml/parser.py
def handle_cdata(pos, window, charpat, stopchars): ''' Return (result, new_position) tuple. Result is cdata string if possible and None if more input is needed Or of course bad syntax can raise a RuntimeError ''' cdata = '' cursor = start = pos try: while True: while...
def handle_cdata(pos, window, charpat, stopchars): ''' Return (result, new_position) tuple. Result is cdata string if possible and None if more input is needed Or of course bad syntax can raise a RuntimeError ''' cdata = '' cursor = start = pos try: while True: while...
[ "Return", "(", "result", "new_position", ")", "tuple", ".", "Result", "is", "cdata", "string", "if", "possible", "and", "None", "if", "more", "input", "is", "needed", "Or", "of", "course", "bad", "syntax", "can", "raise", "a", "RuntimeError" ]
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/parser.py#L76-L132
[ "def", "handle_cdata", "(", "pos", ",", "window", ",", "charpat", ",", "stopchars", ")", ":", "cdata", "=", "''", "cursor", "=", "start", "=", "pos", "try", ":", "while", "True", ":", "while", "charpat", ".", "match", "(", "window", "[", "cursor", "]...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
launch
Set the gromacs input data using the supplied input options, run gromacs and extract and return the required outputs.
examples/longbow_gromacs/launch.py
def launch(option): '''Set the gromacs input data using the supplied input options, run gromacs and extract and return the required outputs.''' from melody.inputs import create_input _ = create_input(option, template_name="input.mdp") # save the input file in the appropriate place and launch groma...
def launch(option): '''Set the gromacs input data using the supplied input options, run gromacs and extract and return the required outputs.''' from melody.inputs import create_input _ = create_input(option, template_name="input.mdp") # save the input file in the appropriate place and launch groma...
[ "Set", "the", "gromacs", "input", "data", "using", "the", "supplied", "input", "options", "run", "gromacs", "and", "extract", "and", "return", "the", "required", "outputs", "." ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/examples/longbow_gromacs/launch.py#L38-L56
[ "def", "launch", "(", "option", ")", ":", "from", "melody", ".", "inputs", "import", "create_input", "_", "=", "create_input", "(", "option", ",", "template_name", "=", "\"input.mdp\"", ")", "# save the input file in the appropriate place and launch gromacs using", "# l...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
call_command
Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: str Argument strings list. Returns ------- return_value Command return value.
docstamp/commands.py
def call_command(cmd_name, args_strings): """Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: str Argument strings list. Returns ------- return_value Com...
def call_command(cmd_name, args_strings): """Call CLI command with arguments and returns its return value. Parameters ---------- cmd_name: str Command name or full path to the binary file. arg_strings: str Argument strings list. Returns ------- return_value Com...
[ "Call", "CLI", "command", "with", "arguments", "and", "returns", "its", "return", "value", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/commands.py#L76-L109
[ "def", "call_command", "(", "cmd_name", ",", "args_strings", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "cmd_name", ")", ":", "cmd_fullpath", "=", "which", "(", "cmd_name", ")", "else", ":", "cmd_fullpath", "=", "cmd_name", "try", ":", ...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
GoogleData.getCSV
Returns ------- filename: str
docstamp/data_source.py
def getCSV(self): """ Returns ------- filename: str """ import getpass import gspread user = raw_input("Insert Google username:") password = getpass.getpass(prompt="Insert password:") name = raw_input("SpreadSheet filename on Drive:") ...
def getCSV(self): """ Returns ------- filename: str """ import getpass import gspread user = raw_input("Insert Google username:") password = getpass.getpass(prompt="Insert password:") name = raw_input("SpreadSheet filename on Drive:") ...
[ "Returns", "-------", "filename", ":", "str" ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/data_source.py#L11-L39
[ "def", "getCSV", "(", "self", ")", ":", "import", "getpass", "import", "gspread", "user", "=", "raw_input", "(", "\"Insert Google username:\"", ")", "password", "=", "getpass", ".", "getpass", "(", "prompt", "=", "\"Insert password:\"", ")", "name", "=", "raw_...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
write
Write a MicroXML element node (yes, even one representign a whole document) elem - Amara MicroXML element node to be written out writer - instance of amara3.uxml.writer to implement the writing process
pylib/uxml/writer.py
def write(elem, a_writer): ''' Write a MicroXML element node (yes, even one representign a whole document) elem - Amara MicroXML element node to be written out writer - instance of amara3.uxml.writer to implement the writing process ''' a_writer.start_element(elem.xml_name, attribs=elem.xml_attr...
def write(elem, a_writer): ''' Write a MicroXML element node (yes, even one representign a whole document) elem - Amara MicroXML element node to be written out writer - instance of amara3.uxml.writer to implement the writing process ''' a_writer.start_element(elem.xml_name, attribs=elem.xml_attr...
[ "Write", "a", "MicroXML", "element", "node", "(", "yes", "even", "one", "representign", "a", "whole", "document", ")", "elem", "-", "Amara", "MicroXML", "element", "node", "to", "be", "written", "out", "writer", "-", "instance", "of", "amara3", ".", "uxml"...
uogbuji/amara3-xml
python
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/writer.py#L178-L191
[ "def", "write", "(", "elem", ",", "a_writer", ")", ":", "a_writer", ".", "start_element", "(", "elem", ".", "xml_name", ",", "attribs", "=", "elem", ".", "xml_attributes", ")", "for", "node", "in", "elem", ".", "xml_children", ":", "if", "isinstance", "(...
88c18876418cffc89bb85b4a3193e5002b6b39a6
test
tex2pdf
Call PDFLatex to convert TeX files to PDF. Parameters ---------- tex_file: str Path to the input LateX file. output_file: str Path to the output PDF file. If None, will use the same output directory as the tex_file. output_format: str Output file format. Choices: '...
docstamp/pdflatex.py
def tex2pdf(tex_file, output_file=None, output_format='pdf'): """ Call PDFLatex to convert TeX files to PDF. Parameters ---------- tex_file: str Path to the input LateX file. output_file: str Path to the output PDF file. If None, will use the same output directory as the te...
def tex2pdf(tex_file, output_file=None, output_format='pdf'): """ Call PDFLatex to convert TeX files to PDF. Parameters ---------- tex_file: str Path to the input LateX file. output_file: str Path to the output PDF file. If None, will use the same output directory as the te...
[ "Call", "PDFLatex", "to", "convert", "TeX", "files", "to", "PDF", "." ]
PythonSanSebastian/docstamp
python
https://github.com/PythonSanSebastian/docstamp/blob/b43808f2e15351b0b2f0b7eade9c7ef319c9e646/docstamp/pdflatex.py#L21-L72
[ "def", "tex2pdf", "(", "tex_file", ",", "output_file", "=", "None", ",", "output_format", "=", "'pdf'", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "tex_file", ")", ":", "raise", "IOError", "(", "'Could not find file {}.'", ".", "format",...
b43808f2e15351b0b2f0b7eade9c7ef319c9e646
test
GOLoopFuse.options
Returns all potential loop fusion options for the psy object provided
examples/PSyclone/psyclone.py
def options(self, my_psy): '''Returns all potential loop fusion options for the psy object provided''' # compute options dynamically here as they may depend on previous # changes to the psy tree my_options = [] invokes = my_psy.invokes.invoke_list #print "there ar...
def options(self, my_psy): '''Returns all potential loop fusion options for the psy object provided''' # compute options dynamically here as they may depend on previous # changes to the psy tree my_options = [] invokes = my_psy.invokes.invoke_list #print "there ar...
[ "Returns", "all", "potential", "loop", "fusion", "options", "for", "the", "psy", "object", "provided" ]
rupertford/melody
python
https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/examples/PSyclone/psyclone.py#L129-L155
[ "def", "options", "(", "self", ",", "my_psy", ")", ":", "# compute options dynamically here as they may depend on previous", "# changes to the psy tree", "my_options", "=", "[", "]", "invokes", "=", "my_psy", ".", "invokes", ".", "invoke_list", "#print \"there are {0} invok...
d50459880a87fdd1802c6893f6e12b52d51b3b91
test
transform
Returns a transformed Geometry. Arguments: geom -- any coercible Geometry value or Envelope to_sref -- SpatialReference or EPSG ID as int
greenwich/geometry.py
def transform(geom, to_sref): """Returns a transformed Geometry. Arguments: geom -- any coercible Geometry value or Envelope to_sref -- SpatialReference or EPSG ID as int """ # If we have an envelope, assume it's in the target sref. try: geom = getattr(geom, 'polygon', Envelope(geom...
def transform(geom, to_sref): """Returns a transformed Geometry. Arguments: geom -- any coercible Geometry value or Envelope to_sref -- SpatialReference or EPSG ID as int """ # If we have an envelope, assume it's in the target sref. try: geom = getattr(geom, 'polygon', Envelope(geom...
[ "Returns", "a", "transformed", "Geometry", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L12-L36
[ "def", "transform", "(", "geom", ",", "to_sref", ")", ":", "# If we have an envelope, assume it's in the target sref.", "try", ":", "geom", "=", "getattr", "(", "geom", ",", "'polygon'", ",", "Envelope", "(", "geom", ")", ".", "polygon", ")", "except", "(", "T...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Geometry
Returns an ogr.Geometry instance optionally created from a geojson str or dict. The spatial reference may also be provided.
greenwich/geometry.py
def Geometry(*args, **kwargs): """Returns an ogr.Geometry instance optionally created from a geojson str or dict. The spatial reference may also be provided. """ # Look for geojson as a positional or keyword arg. arg = kwargs.pop('geojson', None) or len(args) and args[0] try: srs = kwarg...
def Geometry(*args, **kwargs): """Returns an ogr.Geometry instance optionally created from a geojson str or dict. The spatial reference may also be provided. """ # Look for geojson as a positional or keyword arg. arg = kwargs.pop('geojson', None) or len(args) and args[0] try: srs = kwarg...
[ "Returns", "an", "ogr", ".", "Geometry", "instance", "optionally", "created", "from", "a", "geojson", "str", "or", "dict", ".", "The", "spatial", "reference", "may", "also", "be", "provided", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L239-L271
[ "def", "Geometry", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Look for geojson as a positional or keyword arg.", "arg", "=", "kwargs", ".", "pop", "(", "'geojson'", ",", "None", ")", "or", "len", "(", "args", ")", "and", "args", "[", "0", "]...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.centroid
Returns the envelope centroid as a (x, y) tuple.
greenwich/geometry.py
def centroid(self): """Returns the envelope centroid as a (x, y) tuple.""" return self.min_x + self.width * 0.5, self.min_y + self.height * 0.5
def centroid(self): """Returns the envelope centroid as a (x, y) tuple.""" return self.min_x + self.width * 0.5, self.min_y + self.height * 0.5
[ "Returns", "the", "envelope", "centroid", "as", "a", "(", "x", "y", ")", "tuple", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L94-L96
[ "def", "centroid", "(", "self", ")", ":", "return", "self", ".", "min_x", "+", "self", ".", "width", "*", "0.5", ",", "self", ".", "min_y", "+", "self", ".", "height", "*", "0.5" ]
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.expand
Expands this envelope by the given Envelope or tuple. Arguments: other -- Envelope, two-tuple, or four-tuple
greenwich/geometry.py
def expand(self, other): """Expands this envelope by the given Envelope or tuple. Arguments: other -- Envelope, two-tuple, or four-tuple """ if len(other) == 2: other += other mid = len(other) // 2 self.ll = map(min, self.ll, other[:mid]) self...
def expand(self, other): """Expands this envelope by the given Envelope or tuple. Arguments: other -- Envelope, two-tuple, or four-tuple """ if len(other) == 2: other += other mid = len(other) // 2 self.ll = map(min, self.ll, other[:mid]) self...
[ "Expands", "this", "envelope", "by", "the", "given", "Envelope", "or", "tuple", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L113-L123
[ "def", "expand", "(", "self", ",", "other", ")", ":", "if", "len", "(", "other", ")", "==", "2", ":", "other", "+=", "other", "mid", "=", "len", "(", "other", ")", "//", "2", "self", ".", "ll", "=", "map", "(", "min", ",", "self", ".", "ll", ...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.intersect
Returns the intersection of this and another Envelope.
greenwich/geometry.py
def intersect(self, other): """Returns the intersection of this and another Envelope.""" inter = Envelope(tuple(self)) if inter.intersects(other): mid = len(other) // 2 inter.ll = map(max, inter.ll, other[:mid]) inter.ur = map(min, inter.ur, other[mid:]) ...
def intersect(self, other): """Returns the intersection of this and another Envelope.""" inter = Envelope(tuple(self)) if inter.intersects(other): mid = len(other) // 2 inter.ll = map(max, inter.ll, other[:mid]) inter.ur = map(min, inter.ur, other[mid:]) ...
[ "Returns", "the", "intersection", "of", "this", "and", "another", "Envelope", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L135-L145
[ "def", "intersect", "(", "self", ",", "other", ")", ":", "inter", "=", "Envelope", "(", "tuple", "(", "self", ")", ")", "if", "inter", ".", "intersects", "(", "other", ")", ":", "mid", "=", "len", "(", "other", ")", "//", "2", "inter", ".", "ll",...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.intersects
Returns true if this envelope intersects another. Arguments: other -- Envelope or tuple of (minX, minY, maxX, maxY)
greenwich/geometry.py
def intersects(self, other): """Returns true if this envelope intersects another. Arguments: other -- Envelope or tuple of (minX, minY, maxX, maxY) """ try: return (self.min_x <= other.max_x and self.max_x >= other.min_x and se...
def intersects(self, other): """Returns true if this envelope intersects another. Arguments: other -- Envelope or tuple of (minX, minY, maxX, maxY) """ try: return (self.min_x <= other.max_x and self.max_x >= other.min_x and se...
[ "Returns", "true", "if", "this", "envelope", "intersects", "another", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L147-L159
[ "def", "intersects", "(", "self", ",", "other", ")", ":", "try", ":", "return", "(", "self", ".", "min_x", "<=", "other", ".", "max_x", "and", "self", ".", "max_x", ">=", "other", ".", "min_x", "and", "self", ".", "min_y", "<=", "other", ".", "max_...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.scale
Returns a new envelope rescaled from center by the given factor(s). Arguments: xfactor -- int or float X scaling factor yfactor -- int or float Y scaling factor
greenwich/geometry.py
def scale(self, xfactor, yfactor=None): """Returns a new envelope rescaled from center by the given factor(s). Arguments: xfactor -- int or float X scaling factor yfactor -- int or float Y scaling factor """ yfactor = xfactor if yfactor is None else yfactor x, y ...
def scale(self, xfactor, yfactor=None): """Returns a new envelope rescaled from center by the given factor(s). Arguments: xfactor -- int or float X scaling factor yfactor -- int or float Y scaling factor """ yfactor = xfactor if yfactor is None else yfactor x, y ...
[ "Returns", "a", "new", "envelope", "rescaled", "from", "center", "by", "the", "given", "factor", "(", "s", ")", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L180-L191
[ "def", "scale", "(", "self", ",", "xfactor", ",", "yfactor", "=", "None", ")", ":", "yfactor", "=", "xfactor", "if", "yfactor", "is", "None", "else", "yfactor", "x", ",", "y", "=", "self", ".", "centroid", "xshift", "=", "self", ".", "width", "*", ...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Envelope.polygon
Returns an OGR Geometry for this envelope.
greenwich/geometry.py
def polygon(self): """Returns an OGR Geometry for this envelope.""" ring = ogr.Geometry(ogr.wkbLinearRing) for coord in self.ll, self.lr, self.ur, self.ul, self.ll: ring.AddPoint_2D(*coord) polyg = ogr.Geometry(ogr.wkbPolygon) polyg.AddGeometryDirectly(ring) r...
def polygon(self): """Returns an OGR Geometry for this envelope.""" ring = ogr.Geometry(ogr.wkbLinearRing) for coord in self.ll, self.lr, self.ur, self.ul, self.ll: ring.AddPoint_2D(*coord) polyg = ogr.Geometry(ogr.wkbPolygon) polyg.AddGeometryDirectly(ring) r...
[ "Returns", "an", "OGR", "Geometry", "for", "this", "envelope", "." ]
bkg/greenwich
python
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/geometry.py#L194-L201
[ "def", "polygon", "(", "self", ")", ":", "ring", "=", "ogr", ".", "Geometry", "(", "ogr", ".", "wkbLinearRing", ")", "for", "coord", "in", "self", ".", "ll", ",", "self", ".", "lr", ",", "self", ".", "ur", ",", "self", ".", "ul", ",", "self", "...
57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141
test
Table.from_name
Imports a mass table from a file
masstable/masstable.py
def from_name(cls, name): "Imports a mass table from a file" filename = os.path.join(package_dir, 'data', name + '.txt') return cls.from_file(filename, name)
def from_name(cls, name): "Imports a mass table from a file" filename = os.path.join(package_dir, 'data', name + '.txt') return cls.from_file(filename, name)
[ "Imports", "a", "mass", "table", "from", "a", "file" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L57-L60
[ "def", "from_name", "(", "cls", ",", "name", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "package_dir", ",", "'data'", ",", "name", "+", "'.txt'", ")", "return", "cls", ".", "from_file", "(", "filename", ",", "name", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.from_file
Imports a mass table from a file
masstable/masstable.py
def from_file(cls, filename, name=''): "Imports a mass table from a file" df = pd.read_csv(filename, header=0, delim_whitespace=True, index_col=[0, 1])['M'] df.name = name return cls(df=df, name=name)
def from_file(cls, filename, name=''): "Imports a mass table from a file" df = pd.read_csv(filename, header=0, delim_whitespace=True, index_col=[0, 1])['M'] df.name = name return cls(df=df, name=name)
[ "Imports", "a", "mass", "table", "from", "a", "file" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L63-L67
[ "def", "from_file", "(", "cls", ",", "filename", ",", "name", "=", "''", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "filename", ",", "header", "=", "0", ",", "delim_whitespace", "=", "True", ",", "index_col", "=", "[", "0", ",", "1", "]", "...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.from_ZNM
Creates a table from arrays Z, N and M Example: ________ >>> Z = [82, 82, 83] >>> N = [126, 127, 130] >>> M = [-21.34, -18.0, -14.45] >>> Table.from_ZNM(Z, N, M, name='Custom Table') Z N 82 126 -21.34 127 -18.00 83 130 -14.4...
masstable/masstable.py
def from_ZNM(cls, Z, N, M, name=''): """ Creates a table from arrays Z, N and M Example: ________ >>> Z = [82, 82, 83] >>> N = [126, 127, 130] >>> M = [-21.34, -18.0, -14.45] >>> Table.from_ZNM(Z, N, M, name='Custom Table') Z N 82 126 ...
def from_ZNM(cls, Z, N, M, name=''): """ Creates a table from arrays Z, N and M Example: ________ >>> Z = [82, 82, 83] >>> N = [126, 127, 130] >>> M = [-21.34, -18.0, -14.45] >>> Table.from_ZNM(Z, N, M, name='Custom Table') Z N 82 126 ...
[ "Creates", "a", "table", "from", "arrays", "Z", "N", "and", "M" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L70-L89
[ "def", "from_ZNM", "(", "cls", ",", "Z", ",", "N", ",", "M", ",", "name", "=", "''", ")", ":", "df", "=", "pd", ".", "DataFrame", ".", "from_dict", "(", "{", "'Z'", ":", "Z", ",", "'N'", ":", "N", ",", "'M'", ":", "M", "}", ")", ".", "set...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.to_file
Export the contents to a file as comma separated values. Parameters ---------- path : string File path where the data should be saved to Example ------- Export the last ten elements of AME2012 to a new file: >>> Table('AME2012').tail(10).to_file('la...
masstable/masstable.py
def to_file(self, path): """Export the contents to a file as comma separated values. Parameters ---------- path : string File path where the data should be saved to Example ------- Export the last ten elements of AME2012 to a new file: >>> T...
def to_file(self, path): """Export the contents to a file as comma separated values. Parameters ---------- path : string File path where the data should be saved to Example ------- Export the last ten elements of AME2012 to a new file: >>> T...
[ "Export", "the", "contents", "to", "a", "file", "as", "comma", "separated", "values", "." ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L96-L112
[ "def", "to_file", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "'Z N M\\n'", ")", "self", ".", "df", ".", "to_csv", "(", "path", ",", "sep", "=", "'\\t'", ",", "mo...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.select
Selects nuclei according to a condition on Z,N or M Parameters ---------- condition : function, Can have one of the signatures f(M), f(Z,N) or f(Z, N, M) must return a boolean value name: string, optional name for the resulting Table Example: ---...
masstable/masstable.py
def select(self, condition, name=''): """ Selects nuclei according to a condition on Z,N or M Parameters ---------- condition : function, Can have one of the signatures f(M), f(Z,N) or f(Z, N, M) must return a boolean value name: string, optional ...
def select(self, condition, name=''): """ Selects nuclei according to a condition on Z,N or M Parameters ---------- condition : function, Can have one of the signatures f(M), f(Z,N) or f(Z, N, M) must return a boolean value name: string, optional ...
[ "Selects", "nuclei", "according", "to", "a", "condition", "on", "Z", "N", "or", "M" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L218-L243
[ "def", "select", "(", "self", ",", "condition", ",", "name", "=", "''", ")", ":", "if", "condition", ".", "func_code", ".", "co_argcount", "==", "1", ":", "idx", "=", "[", "(", "Z", ",", "N", ")", "for", "(", "Z", ",", "N", ")", ",", "M", "in...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.at
Return a selection of the Table at positions given by ``nuclei`` Parameters ---------- nuclei: list of tuples A list where each element is tuple of the form (Z,N) Example ------- Return binding energies at magic nuclei: >>> magic_nuclei = [(20,28), ...
masstable/masstable.py
def at(self, nuclei): """Return a selection of the Table at positions given by ``nuclei`` Parameters ---------- nuclei: list of tuples A list where each element is tuple of the form (Z,N) Example ------- Return binding energies at magic nuclei: ...
def at(self, nuclei): """Return a selection of the Table at positions given by ``nuclei`` Parameters ---------- nuclei: list of tuples A list where each element is tuple of the form (Z,N) Example ------- Return binding energies at magic nuclei: ...
[ "Return", "a", "selection", "of", "the", "Table", "at", "positions", "given", "by", "nuclei" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L245-L266
[ "def", "at", "(", "self", ",", "nuclei", ")", ":", "index", "=", "pd", ".", "MultiIndex", ".", "from_tuples", "(", "nuclei", ",", "names", "=", "[", "'Z'", ",", "'N'", "]", ")", "return", "Table", "(", "df", "=", "self", ".", "df", ".", "ix", "...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.intersection
Select nuclei which also belong to ``table`` Parameters ---------- table: Table, Table object Example: ---------- Table('AME2003').intersection(Table('AME1995'))
masstable/masstable.py
def intersection(self, table): """ Select nuclei which also belong to ``table`` Parameters ---------- table: Table, Table object Example: ---------- Table('AME2003').intersection(Table('AME1995')) """ idx = self.df.index & table.df.index ...
def intersection(self, table): """ Select nuclei which also belong to ``table`` Parameters ---------- table: Table, Table object Example: ---------- Table('AME2003').intersection(Table('AME1995')) """ idx = self.df.index & table.df.index ...
[ "Select", "nuclei", "which", "also", "belong", "to", "table" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L294-L307
[ "def", "intersection", "(", "self", ",", "table", ")", ":", "idx", "=", "self", ".", "df", ".", "index", "&", "table", ".", "df", ".", "index", "return", "Table", "(", "df", "=", "self", ".", "df", "[", "idx", "]", ",", "name", "=", "self", "."...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.not_in
Select nuclei not in table Parameters ---------- table: Table, Table object from where nuclei should be removed Example: ---------- Find the new nuclei in AME2003 with Z,N >= 8: >>> Table('AME2003').not_in(Table('AME1995'))[8:,8:].count 389
masstable/masstable.py
def not_in(self, table): """ Select nuclei not in table Parameters ---------- table: Table, Table object from where nuclei should be removed Example: ---------- Find the new nuclei in AME2003 with Z,N >= 8: >>> Table('AME2003').not_in(Table('AME...
def not_in(self, table): """ Select nuclei not in table Parameters ---------- table: Table, Table object from where nuclei should be removed Example: ---------- Find the new nuclei in AME2003 with Z,N >= 8: >>> Table('AME2003').not_in(Table('AME...
[ "Select", "nuclei", "not", "in", "table" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L309-L325
[ "def", "not_in", "(", "self", ",", "table", ")", ":", "idx", "=", "self", ".", "df", ".", "index", "-", "table", ".", "df", ".", "index", "return", "Table", "(", "df", "=", "self", ".", "df", "[", "idx", "]", ",", "name", "=", "self", ".", "n...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.odd_odd
Selects odd-odd nuclei from the table: >>> Table('FRDM95').odd_odd Out[13]: Z N 9 9 1.21 11 0.10 13 3.08 15 9.32 ...
masstable/masstable.py
def odd_odd(self): """Selects odd-odd nuclei from the table: >>> Table('FRDM95').odd_odd Out[13]: Z N 9 9 1.21 11 0.10 13 3.08 15 9.32 ... """ return self.select(lambda Z, N: (Z % 2) and (N % 2)...
def odd_odd(self): """Selects odd-odd nuclei from the table: >>> Table('FRDM95').odd_odd Out[13]: Z N 9 9 1.21 11 0.10 13 3.08 15 9.32 ... """ return self.select(lambda Z, N: (Z % 2) and (N % 2)...
[ "Selects", "odd", "-", "odd", "nuclei", "from", "the", "table", ":" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L329-L341
[ "def", "odd_odd", "(", "self", ")", ":", "return", "self", ".", "select", "(", "lambda", "Z", ",", "N", ":", "(", "Z", "%", "2", ")", "and", "(", "N", "%", "2", ")", ",", "name", "=", "self", ".", "name", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.odd_even
Selects odd-even nuclei from the table
masstable/masstable.py
def odd_even(self): """ Selects odd-even nuclei from the table """ return self.select(lambda Z, N: (Z % 2) and not(N % 2), name=self.name)
def odd_even(self): """ Selects odd-even nuclei from the table """ return self.select(lambda Z, N: (Z % 2) and not(N % 2), name=self.name)
[ "Selects", "odd", "-", "even", "nuclei", "from", "the", "table" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L345-L349
[ "def", "odd_even", "(", "self", ")", ":", "return", "self", ".", "select", "(", "lambda", "Z", ",", "N", ":", "(", "Z", "%", "2", ")", "and", "not", "(", "N", "%", "2", ")", ",", "name", "=", "self", ".", "name", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.even_odd
Selects even-odd nuclei from the table
masstable/masstable.py
def even_odd(self): """ Selects even-odd nuclei from the table """ return self.select(lambda Z, N: not(Z % 2) and (N % 2), name=self.name)
def even_odd(self): """ Selects even-odd nuclei from the table """ return self.select(lambda Z, N: not(Z % 2) and (N % 2), name=self.name)
[ "Selects", "even", "-", "odd", "nuclei", "from", "the", "table" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L353-L357
[ "def", "even_odd", "(", "self", ")", ":", "return", "self", ".", "select", "(", "lambda", "Z", ",", "N", ":", "not", "(", "Z", "%", "2", ")", "and", "(", "N", "%", "2", ")", ",", "name", "=", "self", ".", "name", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.even_even
Selects even-even nuclei from the table
masstable/masstable.py
def even_even(self): """ Selects even-even nuclei from the table """ return self.select(lambda Z, N: not(Z % 2) and not(N % 2), name=self.name)
def even_even(self): """ Selects even-even nuclei from the table """ return self.select(lambda Z, N: not(Z % 2) and not(N % 2), name=self.name)
[ "Selects", "even", "-", "even", "nuclei", "from", "the", "table" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L361-L365
[ "def", "even_even", "(", "self", ")", ":", "return", "self", ".", "select", "(", "lambda", "Z", ",", "N", ":", "not", "(", "Z", "%", "2", ")", "and", "not", "(", "N", "%", "2", ")", ",", "name", "=", "self", ".", "name", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.error
Calculate error difference Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> Table('DUZU').error(relative_to='AME2003')
masstable/masstable.py
def error(self, relative_to='AME2003'): """ Calculate error difference Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> Table('DUZU').error(relative_to='AME2003') """ df = self.df - ...
def error(self, relative_to='AME2003'): """ Calculate error difference Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> Table('DUZU').error(relative_to='AME2003') """ df = self.df - ...
[ "Calculate", "error", "difference" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L367-L381
[ "def", "error", "(", "self", ",", "relative_to", "=", "'AME2003'", ")", ":", "df", "=", "self", ".", "df", "-", "Table", "(", "relative_to", ")", ".", "df", "return", "Table", "(", "df", "=", "df", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.rmse
Calculate root mean squared error Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> template = '{0:10}|{1:^6.2f}|{2:^6.2f}|{3:^6.2f}' >>> print 'Model ', 'AME95 ', 'AME03 ', 'AME12 ' # Table header ...
masstable/masstable.py
def rmse(self, relative_to='AME2003'): """Calculate root mean squared error Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> template = '{0:10}|{1:^6.2f}|{2:^6.2f}|{3:^6.2f}' >>> print 'Model '...
def rmse(self, relative_to='AME2003'): """Calculate root mean squared error Parameters ---------- relative_to : string, a valid mass table name. Example: ---------- >>> template = '{0:10}|{1:^6.2f}|{2:^6.2f}|{3:^6.2f}' >>> print 'Model '...
[ "Calculate", "root", "mean", "squared", "error" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L383-L414
[ "def", "rmse", "(", "self", ",", "relative_to", "=", "'AME2003'", ")", ":", "error", "=", "self", ".", "error", "(", "relative_to", "=", "relative_to", ")", "return", "math", ".", "sqrt", "(", "(", "error", ".", "df", "**", "2", ")", ".", "mean", "...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.binding_energy
Return binding energies instead of mass excesses
masstable/masstable.py
def binding_energy(self): """ Return binding energies instead of mass excesses """ M_P = 938.2723 # MeV M_E = 0.5110 # MeV M_N = 939.5656 # MeV AMU = 931.494028 # MeV df = self.Z * (M_P + M_E) + (self.A - self.Z) * M_N - (se...
def binding_energy(self): """ Return binding energies instead of mass excesses """ M_P = 938.2723 # MeV M_E = 0.5110 # MeV M_N = 939.5656 # MeV AMU = 931.494028 # MeV df = self.Z * (M_P + M_E) + (self.A - self.Z) * M_N - (se...
[ "Return", "binding", "energies", "instead", "of", "mass", "excesses" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L418-L431
[ "def", "binding_energy", "(", "self", ")", ":", "M_P", "=", "938.2723", "# MeV", "M_E", "=", "0.5110", "# MeV", "M_N", "=", "939.5656", "# MeV", "AMU", "=", "931.494028", "# MeV", "df", "=", "self", ".", "Z", "*", "(", "M_P", "+", "M_E", ")", "+", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.q_alpha
Return Q_alpha
masstable/masstable.py
def q_alpha(self): """Return Q_alpha""" M_ALPHA = 2.4249156 # He4 mass excess in MeV f = lambda parent, daugther: parent - daugther - M_ALPHA return self.derived('Q_alpha', (-2, -2), f)
def q_alpha(self): """Return Q_alpha""" M_ALPHA = 2.4249156 # He4 mass excess in MeV f = lambda parent, daugther: parent - daugther - M_ALPHA return self.derived('Q_alpha', (-2, -2), f)
[ "Return", "Q_alpha" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L435-L439
[ "def", "q_alpha", "(", "self", ")", ":", "M_ALPHA", "=", "2.4249156", "# He4 mass excess in MeV", "f", "=", "lambda", "parent", ",", "daugther", ":", "parent", "-", "daugther", "-", "M_ALPHA", "return", "self", ".", "derived", "(", "'Q_alpha'", ",", "(", "...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.q_beta
Return Q_beta
masstable/masstable.py
def q_beta(self): """Return Q_beta""" f = lambda parent, daugther: parent - daugther return self.derived('Q_beta', (1, -1), f)
def q_beta(self): """Return Q_beta""" f = lambda parent, daugther: parent - daugther return self.derived('Q_beta', (1, -1), f)
[ "Return", "Q_beta" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L443-L446
[ "def", "q_beta", "(", "self", ")", ":", "f", "=", "lambda", "parent", ",", "daugther", ":", "parent", "-", "daugther", "return", "self", ".", "derived", "(", "'Q_beta'", ",", "(", "1", ",", "-", "1", ")", ",", "f", ")" ]
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.s2n
Return 2 neutron separation energy
masstable/masstable.py
def s2n(self): """Return 2 neutron separation energy""" M_N = 8.0713171 # neutron mass excess in MeV f = lambda parent, daugther: -parent + daugther + 2 * M_N return self.derived('s2n', (0, -2), f)
def s2n(self): """Return 2 neutron separation energy""" M_N = 8.0713171 # neutron mass excess in MeV f = lambda parent, daugther: -parent + daugther + 2 * M_N return self.derived('s2n', (0, -2), f)
[ "Return", "2", "neutron", "separation", "energy" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L450-L454
[ "def", "s2n", "(", "self", ")", ":", "M_N", "=", "8.0713171", "# neutron mass excess in MeV", "f", "=", "lambda", "parent", ",", "daugther", ":", "-", "parent", "+", "daugther", "+", "2", "*", "M_N", "return", "self", ".", "derived", "(", "'s2n'", ",", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.s1n
Return 1 neutron separation energy
masstable/masstable.py
def s1n(self): """Return 1 neutron separation energy""" M_N = 8.0713171 # neutron mass excess in MeV f = lambda parent, daugther: -parent + daugther + M_N return self.derived('s1n', (0, -1), f)
def s1n(self): """Return 1 neutron separation energy""" M_N = 8.0713171 # neutron mass excess in MeV f = lambda parent, daugther: -parent + daugther + M_N return self.derived('s1n', (0, -1), f)
[ "Return", "1", "neutron", "separation", "energy" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L458-L462
[ "def", "s1n", "(", "self", ")", ":", "M_N", "=", "8.0713171", "# neutron mass excess in MeV", "f", "=", "lambda", "parent", ",", "daugther", ":", "-", "parent", "+", "daugther", "+", "M_N", "return", "self", ".", "derived", "(", "'s1n'", ",", "(", "0", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.s2p
Return 2 proton separation energy
masstable/masstable.py
def s2p(self): """Return 2 proton separation energy""" M_P = 7.28897050 # proton mass excess in MeV f = lambda parent, daugther: -parent + daugther + 2 * M_P return self.derived('s2p', (-2, 0), f)
def s2p(self): """Return 2 proton separation energy""" M_P = 7.28897050 # proton mass excess in MeV f = lambda parent, daugther: -parent + daugther + 2 * M_P return self.derived('s2p', (-2, 0), f)
[ "Return", "2", "proton", "separation", "energy" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L466-L470
[ "def", "s2p", "(", "self", ")", ":", "M_P", "=", "7.28897050", "# proton mass excess in MeV", "f", "=", "lambda", "parent", ",", "daugther", ":", "-", "parent", "+", "daugther", "+", "2", "*", "M_P", "return", "self", ".", "derived", "(", "'s2p'", ",", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.s1p
Return 1 proton separation energy
masstable/masstable.py
def s1p(self): """Return 1 proton separation energy""" M_P = 7.28897050 # proton mass excess in MeV f = lambda parent, daugther: -parent + daugther + M_P return self.derived('s1p', (-1, 0), f)
def s1p(self): """Return 1 proton separation energy""" M_P = 7.28897050 # proton mass excess in MeV f = lambda parent, daugther: -parent + daugther + M_P return self.derived('s1p', (-1, 0), f)
[ "Return", "1", "proton", "separation", "energy" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L474-L478
[ "def", "s1p", "(", "self", ")", ":", "M_P", "=", "7.28897050", "# proton mass excess in MeV", "f", "=", "lambda", "parent", ",", "daugther", ":", "-", "parent", "+", "daugther", "+", "M_P", "return", "self", ".", "derived", "(", "'s1p'", ",", "(", "-", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.derived
Helper function for derived quantities
masstable/masstable.py
def derived(self, name, relative_coords, formula): """Helper function for derived quantities""" relZ, relN = relative_coords daughter_idx = [(x[0] + relZ, x[1] + relN) for x in self.df.index] values = formula(self.df.values, self.df.loc[daughter_idx].values) return Table(df=pd.Se...
def derived(self, name, relative_coords, formula): """Helper function for derived quantities""" relZ, relN = relative_coords daughter_idx = [(x[0] + relZ, x[1] + relN) for x in self.df.index] values = formula(self.df.values, self.df.loc[daughter_idx].values) return Table(df=pd.Se...
[ "Helper", "function", "for", "derived", "quantities" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L480-L485
[ "def", "derived", "(", "self", ",", "name", ",", "relative_coords", ",", "formula", ")", ":", "relZ", ",", "relN", "=", "relative_coords", "daughter_idx", "=", "[", "(", "x", "[", "0", "]", "+", "relZ", ",", "x", "[", "1", "]", "+", "relN", ")", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.ds2n
Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2)
masstable/masstable.py
def ds2n(self): """Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2) """ idx = [(x[0] + 0, x[1] + 2) for x in self.df.index] values = self.s2n.values - self.s2n.loc[idx].values return Table(df=pd.Series(values, index=self.df....
def ds2n(self): """Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2) """ idx = [(x[0] + 0, x[1] + 2) for x in self.df.index] values = self.s2n.values - self.s2n.loc[idx].values return Table(df=pd.Series(values, index=self.df....
[ "Calculates", "the", "derivative", "of", "the", "neutron", "separation", "energies", ":" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L489-L496
[ "def", "ds2n", "(", "self", ")", ":", "idx", "=", "[", "(", "x", "[", "0", "]", "+", "0", ",", "x", "[", "1", "]", "+", "2", ")", "for", "x", "in", "self", ".", "df", ".", "index", "]", "values", "=", "self", ".", "s2n", ".", "values", ...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2
test
Table.ds2p
Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2)
masstable/masstable.py
def ds2p(self): """Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2) """ idx = [(x[0] + 2, x[1]) for x in self.df.index] values = self.s2p.values - self.s2p.loc[idx].values return Table(df=pd.Series(values, index=self.df.inde...
def ds2p(self): """Calculates the derivative of the neutron separation energies: ds2n(Z,A) = s2n(Z,A) - s2n(Z,A+2) """ idx = [(x[0] + 2, x[1]) for x in self.df.index] values = self.s2p.values - self.s2p.loc[idx].values return Table(df=pd.Series(values, index=self.df.inde...
[ "Calculates", "the", "derivative", "of", "the", "neutron", "separation", "energies", ":" ]
elyase/masstable
python
https://github.com/elyase/masstable/blob/3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2/masstable/masstable.py#L500-L507
[ "def", "ds2p", "(", "self", ")", ":", "idx", "=", "[", "(", "x", "[", "0", "]", "+", "2", ",", "x", "[", "1", "]", ")", "for", "x", "in", "self", ".", "df", ".", "index", "]", "values", "=", "self", ".", "s2p", ".", "values", "-", "self",...
3eb72b22cd3337bc5c6bb95bb7bb73fdbe6ae9e2