id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,900 | rbarrois/tdparser | tdparser/lexer.py | Lexer.register_token | def register_token(self, token_class, regexp=None):
"""Register a token class.
Args:
token_class (tdparser.Token): the token class to register
regexp (optional str): the regexp for elements of that token.
Defaults to the `regexp` attribute of the token class.
... | python | def register_token(self, token_class, regexp=None):
"""Register a token class.
Args:
token_class (tdparser.Token): the token class to register
regexp (optional str): the regexp for elements of that token.
Defaults to the `regexp` attribute of the token class.
... | [
"def",
"register_token",
"(",
"self",
",",
"token_class",
",",
"regexp",
"=",
"None",
")",
":",
"if",
"regexp",
"is",
"None",
":",
"regexp",
"=",
"token_class",
".",
"regexp",
"self",
".",
"tokens",
".",
"register",
"(",
"token_class",
",",
"regexp",
")"... | Register a token class.
Args:
token_class (tdparser.Token): the token class to register
regexp (optional str): the regexp for elements of that token.
Defaults to the `regexp` attribute of the token class. | [
"Register",
"a",
"token",
"class",
"."
] | 31225aa5149f2ab507ccce15a020fbb37d0acb56 | https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L106-L117 |
52,901 | rbarrois/tdparser | tdparser/lexer.py | Lexer.lex | def lex(self, text):
"""Split self.text into a list of tokens.
Args:
text (str): text to parse
Yields:
Token: the tokens generated from the given text.
"""
pos = 0
while text:
token_class, match = self.tokens.get_token(text)
... | python | def lex(self, text):
"""Split self.text into a list of tokens.
Args:
text (str): text to parse
Yields:
Token: the tokens generated from the given text.
"""
pos = 0
while text:
token_class, match = self.tokens.get_token(text)
... | [
"def",
"lex",
"(",
"self",
",",
"text",
")",
":",
"pos",
"=",
"0",
"while",
"text",
":",
"token_class",
",",
"match",
"=",
"self",
".",
"tokens",
".",
"get_token",
"(",
"text",
")",
"if",
"token_class",
"is",
"not",
"None",
":",
"matched_text",
"=",
... | Split self.text into a list of tokens.
Args:
text (str): text to parse
Yields:
Token: the tokens generated from the given text. | [
"Split",
"self",
".",
"text",
"into",
"a",
"list",
"of",
"tokens",
"."
] | 31225aa5149f2ab507ccce15a020fbb37d0acb56 | https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L127-L152 |
52,902 | rbarrois/tdparser | tdparser/lexer.py | Lexer.parse | def parse(self, text):
"""Parse self.text.
Args:
text (str): the text to lex
Returns:
object: a node representing the current rule.
"""
tokens = self.lex(text)
parser = Parser(tokens)
return parser.parse() | python | def parse(self, text):
"""Parse self.text.
Args:
text (str): the text to lex
Returns:
object: a node representing the current rule.
"""
tokens = self.lex(text)
parser = Parser(tokens)
return parser.parse() | [
"def",
"parse",
"(",
"self",
",",
"text",
")",
":",
"tokens",
"=",
"self",
".",
"lex",
"(",
"text",
")",
"parser",
"=",
"Parser",
"(",
"tokens",
")",
"return",
"parser",
".",
"parse",
"(",
")"
] | Parse self.text.
Args:
text (str): the text to lex
Returns:
object: a node representing the current rule. | [
"Parse",
"self",
".",
"text",
"."
] | 31225aa5149f2ab507ccce15a020fbb37d0acb56 | https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L154-L165 |
52,903 | razor-x/scipy-data_fitting | examples/example_helper.py | save_example_fit | def save_example_fit(fit):
"""
Save fit result to a json file and a plot to an svg file.
"""
json_directory = os.path.join('examples', 'json')
plot_directory = os.path.join('examples', 'plots')
if not os.path.isdir(json_directory): os.makedirs(json_directory)
if not os.path.isdir(plot_direct... | python | def save_example_fit(fit):
"""
Save fit result to a json file and a plot to an svg file.
"""
json_directory = os.path.join('examples', 'json')
plot_directory = os.path.join('examples', 'plots')
if not os.path.isdir(json_directory): os.makedirs(json_directory)
if not os.path.isdir(plot_direct... | [
"def",
"save_example_fit",
"(",
"fit",
")",
":",
"json_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'examples'",
",",
"'json'",
")",
"plot_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'examples'",
",",
"'plots'",
")",
"if",
"not",
"... | Save fit result to a json file and a plot to an svg file. | [
"Save",
"fit",
"result",
"to",
"a",
"json",
"file",
"and",
"a",
"plot",
"to",
"an",
"svg",
"file",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/examples/example_helper.py#L10-L23 |
52,904 | razor-x/scipy-data_fitting | examples/example_helper.py | reset_directory | def reset_directory(directory):
"""
Remove `directory` if it exists, then create it if it doesn't exist.
"""
if os.path.isdir(directory): shutil.rmtree(directory)
if not os.path.isdir(directory): os.makedirs(directory) | python | def reset_directory(directory):
"""
Remove `directory` if it exists, then create it if it doesn't exist.
"""
if os.path.isdir(directory): shutil.rmtree(directory)
if not os.path.isdir(directory): os.makedirs(directory) | [
"def",
"reset_directory",
"(",
"directory",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"shutil",
".",
"rmtree",
"(",
"directory",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"os",
... | Remove `directory` if it exists, then create it if it doesn't exist. | [
"Remove",
"directory",
"if",
"it",
"exists",
"then",
"create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/examples/example_helper.py#L25-L30 |
52,905 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/fit.py | Fit.maps | def maps(self):
"""
A dictionary of dictionaries.
Each dictionary defines a map which is used to extend the metadata.
The precise way maps interact with the metadata is defined by `figure.fit._extend_meta`.
That method should be redefined or extended to suit specific use cases.
... | python | def maps(self):
"""
A dictionary of dictionaries.
Each dictionary defines a map which is used to extend the metadata.
The precise way maps interact with the metadata is defined by `figure.fit._extend_meta`.
That method should be redefined or extended to suit specific use cases.
... | [
"def",
"maps",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_maps'",
")",
":",
"maps",
"=",
"{",
"}",
"maps",
"[",
"'tex_symbol'",
"]",
"=",
"{",
"}",
"maps",
"[",
"'siunitx'",
"]",
"=",
"{",
"}",
"maps",
"[",
"'value_transf... | A dictionary of dictionaries.
Each dictionary defines a map which is used to extend the metadata.
The precise way maps interact with the metadata is defined by `figure.fit._extend_meta`.
That method should be redefined or extended to suit specific use cases. | [
"A",
"dictionary",
"of",
"dictionaries",
".",
"Each",
"dictionary",
"defines",
"a",
"map",
"which",
"is",
"used",
"to",
"extend",
"the",
"metadata",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/fit.py#L76-L92 |
52,906 | glenfant/openxmllib | openxmllib/contenttypes.py | ContentTypes.getTreesFor | def getTreesFor(self, document, content_type):
"""Provides all XML documents for that content type
@param document: a Document or subclass object
@param content_type: a MIME content type
@return: list of etree._ElementTree of that content type
"""
# Relative path without... | python | def getTreesFor(self, document, content_type):
"""Provides all XML documents for that content type
@param document: a Document or subclass object
@param content_type: a MIME content type
@return: list of etree._ElementTree of that content type
"""
# Relative path without... | [
"def",
"getTreesFor",
"(",
"self",
",",
"document",
",",
"content_type",
")",
":",
"# Relative path without potential leading path separator",
"# otherwise os.path.join doesn't work",
"for",
"rel_path",
"in",
"self",
".",
"overrides",
"[",
"content_type",
"]",
":",
"if",
... | Provides all XML documents for that content type
@param document: a Document or subclass object
@param content_type: a MIME content type
@return: list of etree._ElementTree of that content type | [
"Provides",
"all",
"XML",
"documents",
"for",
"that",
"content",
"type"
] | c8208f8ecd9fc3ef1e73c1db68081a65361afb3f | https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/contenttypes.py#L89-L103 |
52,907 | glenfant/openxmllib | openxmllib/contenttypes.py | ContentTypes.listMetaContentTypes | def listMetaContentTypes(self):
"""The content types with metadata
@return: ['application/xxx', ...]
"""
all_md_content_types = (
CT_CORE_PROPS,
CT_EXT_PROPS,
CT_CUSTOM_PROPS)
return [k for k in self.overrides.keys() if k in all_md_content_typ... | python | def listMetaContentTypes(self):
"""The content types with metadata
@return: ['application/xxx', ...]
"""
all_md_content_types = (
CT_CORE_PROPS,
CT_EXT_PROPS,
CT_CUSTOM_PROPS)
return [k for k in self.overrides.keys() if k in all_md_content_typ... | [
"def",
"listMetaContentTypes",
"(",
"self",
")",
":",
"all_md_content_types",
"=",
"(",
"CT_CORE_PROPS",
",",
"CT_EXT_PROPS",
",",
"CT_CUSTOM_PROPS",
")",
"return",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"overrides",
".",
"keys",
"(",
")",
"if",
"k",
"in... | The content types with metadata
@return: ['application/xxx', ...] | [
"The",
"content",
"types",
"with",
"metadata"
] | c8208f8ecd9fc3ef1e73c1db68081a65361afb3f | https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/contenttypes.py#L107-L116 |
52,908 | pasztorpisti/json-cfg | src/jsoncfg/tree_python.py | default_number_converter | def default_number_converter(number_str):
"""
Converts the string representation of a json number into its python object equivalent, an
int, long, float or whatever type suits.
"""
is_int = (number_str.startswith('-') and number_str[1:].isdigit()) or number_str.isdigit()
# FIXME: this handles a ... | python | def default_number_converter(number_str):
"""
Converts the string representation of a json number into its python object equivalent, an
int, long, float or whatever type suits.
"""
is_int = (number_str.startswith('-') and number_str[1:].isdigit()) or number_str.isdigit()
# FIXME: this handles a ... | [
"def",
"default_number_converter",
"(",
"number_str",
")",
":",
"is_int",
"=",
"(",
"number_str",
".",
"startswith",
"(",
"'-'",
")",
"and",
"number_str",
"[",
"1",
":",
"]",
".",
"isdigit",
"(",
")",
")",
"or",
"number_str",
".",
"isdigit",
"(",
")",
... | Converts the string representation of a json number into its python object equivalent, an
int, long, float or whatever type suits. | [
"Converts",
"the",
"string",
"representation",
"of",
"a",
"json",
"number",
"into",
"its",
"python",
"object",
"equivalent",
"an",
"int",
"long",
"float",
"or",
"whatever",
"type",
"suits",
"."
] | 4627b14a92521ef8a39bbedaa7af8d380d406d07 | https://github.com/pasztorpisti/json-cfg/blob/4627b14a92521ef8a39bbedaa7af8d380d406d07/src/jsoncfg/tree_python.py#L61-L69 |
52,909 | razor-x/scipy-data_fitting | scipy_data_fitting/plot.py | Plot.save | def save(self, path, **kwargs):
"""
Save the plot to the file at `path`.
Any keyword arguments are passed to [`matplotlib.pyplot.savefig`][1].
[1]: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig
"""
self.plot if not hasattr(self, '_plot') else None
... | python | def save(self, path, **kwargs):
"""
Save the plot to the file at `path`.
Any keyword arguments are passed to [`matplotlib.pyplot.savefig`][1].
[1]: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig
"""
self.plot if not hasattr(self, '_plot') else None
... | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"plot",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_plot'",
")",
"else",
"None",
"self",
".",
"figure",
".",
"savefig",
"(",
"path",
",",
"*",
"*",
"kwargs"... | Save the plot to the file at `path`.
Any keyword arguments are passed to [`matplotlib.pyplot.savefig`][1].
[1]: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig | [
"Save",
"the",
"plot",
"to",
"the",
"file",
"at",
"path",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/plot.py#L123-L132 |
52,910 | mattrobenolt/ec2 | ec2/connection.py | credentials.from_file | def from_file(cls, filename):
"""
Load ACCESS_KEY_ID and SECRET_ACCESS_KEY from csv
generated by Amazon's IAM.
>>> ec2.credentials.from_file('credentials.csv')
"""
import csv
with open(filename, 'r') as f:
reader = csv.DictReader(f)
row = ... | python | def from_file(cls, filename):
"""
Load ACCESS_KEY_ID and SECRET_ACCESS_KEY from csv
generated by Amazon's IAM.
>>> ec2.credentials.from_file('credentials.csv')
"""
import csv
with open(filename, 'r') as f:
reader = csv.DictReader(f)
row = ... | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
")",
":",
"import",
"csv",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"reader",
"=",
"csv",
".",
"DictReader",
"(",
"f",
")",
"row",
"=",
"reader",
".",
"next",
"(",
")",
"# ... | Load ACCESS_KEY_ID and SECRET_ACCESS_KEY from csv
generated by Amazon's IAM.
>>> ec2.credentials.from_file('credentials.csv') | [
"Load",
"ACCESS_KEY_ID",
"and",
"SECRET_ACCESS_KEY",
"from",
"csv",
"generated",
"by",
"Amazon",
"s",
"IAM",
"."
] | fc1f8bce6cf76899165d9ac006371181d52439f8 | https://github.com/mattrobenolt/ec2/blob/fc1f8bce6cf76899165d9ac006371181d52439f8/ec2/connection.py#L53-L68 |
52,911 | getnikola/coil | coil/tasks.py | build | def build(dburl, sitedir, mode):
"""Build a site."""
if mode == 'force':
amode = ['-a']
else:
amode = []
oldcwd = os.getcwd()
os.chdir(sitedir)
db = StrictRedis.from_url(dburl)
job = get_current_job(db)
job.meta.update({'out': '', 'milestone': 0, 'total': 1, 'return': Non... | python | def build(dburl, sitedir, mode):
"""Build a site."""
if mode == 'force':
amode = ['-a']
else:
amode = []
oldcwd = os.getcwd()
os.chdir(sitedir)
db = StrictRedis.from_url(dburl)
job = get_current_job(db)
job.meta.update({'out': '', 'milestone': 0, 'total': 1, 'return': Non... | [
"def",
"build",
"(",
"dburl",
",",
"sitedir",
",",
"mode",
")",
":",
"if",
"mode",
"==",
"'force'",
":",
"amode",
"=",
"[",
"'-a'",
"]",
"else",
":",
"amode",
"=",
"[",
"]",
"oldcwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",... | Build a site. | [
"Build",
"a",
"site",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/tasks.py#L35-L80 |
52,912 | getnikola/coil | coil/tasks.py | orphans | def orphans(dburl, sitedir):
"""Remove all orphans in the site."""
oldcwd = os.getcwd()
os.chdir(sitedir)
db = StrictRedis.from_url(dburl)
job = get_current_job(db)
job.meta.update({'out': '', 'return': None, 'status': None})
job.save()
returncode, out = orphans_single(default_exec=True)... | python | def orphans(dburl, sitedir):
"""Remove all orphans in the site."""
oldcwd = os.getcwd()
os.chdir(sitedir)
db = StrictRedis.from_url(dburl)
job = get_current_job(db)
job.meta.update({'out': '', 'return': None, 'status': None})
job.save()
returncode, out = orphans_single(default_exec=True)... | [
"def",
"orphans",
"(",
"dburl",
",",
"sitedir",
")",
":",
"oldcwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"sitedir",
")",
"db",
"=",
"StrictRedis",
".",
"from_url",
"(",
"dburl",
")",
"job",
"=",
"get_current_job",
"(",
"db",
... | Remove all orphans in the site. | [
"Remove",
"all",
"orphans",
"in",
"the",
"site",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/tasks.py#L83-L97 |
52,913 | getnikola/coil | coil/tasks.py | build_single | def build_single(mode):
"""Build, in the single-user mode."""
if mode == 'force':
amode = ['-a']
else:
amode = []
if executable.endswith('uwsgi'):
# hack, might fail in some environments!
_executable = executable[:-5] + 'python'
else:
_executable = executable
... | python | def build_single(mode):
"""Build, in the single-user mode."""
if mode == 'force':
amode = ['-a']
else:
amode = []
if executable.endswith('uwsgi'):
# hack, might fail in some environments!
_executable = executable[:-5] + 'python'
else:
_executable = executable
... | [
"def",
"build_single",
"(",
"mode",
")",
":",
"if",
"mode",
"==",
"'force'",
":",
"amode",
"=",
"[",
"'-a'",
"]",
"else",
":",
"amode",
"=",
"[",
"]",
"if",
"executable",
".",
"endswith",
"(",
"'uwsgi'",
")",
":",
"# hack, might fail in some environments!"... | Build, in the single-user mode. | [
"Build",
"in",
"the",
"single",
"-",
"user",
"mode",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/tasks.py#L100-L119 |
52,914 | getnikola/coil | coil/tasks.py | orphans_single | def orphans_single(default_exec=False):
"""Remove all orphans in the site, in the single user-mode."""
if not default_exec and executable.endswith('uwsgi'):
# default_exec => rq => sys.executable is sane
_executable = executable[:-5] + 'python'
else:
_executable = executable
p = ... | python | def orphans_single(default_exec=False):
"""Remove all orphans in the site, in the single user-mode."""
if not default_exec and executable.endswith('uwsgi'):
# default_exec => rq => sys.executable is sane
_executable = executable[:-5] + 'python'
else:
_executable = executable
p = ... | [
"def",
"orphans_single",
"(",
"default_exec",
"=",
"False",
")",
":",
"if",
"not",
"default_exec",
"and",
"executable",
".",
"endswith",
"(",
"'uwsgi'",
")",
":",
"# default_exec => rq => sys.executable is sane",
"_executable",
"=",
"executable",
"[",
":",
"-",
"5... | Remove all orphans in the site, in the single user-mode. | [
"Remove",
"all",
"orphans",
"in",
"the",
"site",
"in",
"the",
"single",
"user",
"-",
"mode",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/tasks.py#L122-L138 |
52,915 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/plot.py | Plot.plot_data | def plot_data(self):
"""
Add the data points to the plot.
"""
self.plt.plot(*self.fit.data, **self.options['data']) | python | def plot_data(self):
"""
Add the data points to the plot.
"""
self.plt.plot(*self.fit.data, **self.options['data']) | [
"def",
"plot_data",
"(",
"self",
")",
":",
"self",
".",
"plt",
".",
"plot",
"(",
"*",
"self",
".",
"fit",
".",
"data",
",",
"*",
"*",
"self",
".",
"options",
"[",
"'data'",
"]",
")"
] | Add the data points to the plot. | [
"Add",
"the",
"data",
"points",
"to",
"the",
"plot",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L82-L86 |
52,916 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/plot.py | Plot.plot_fit | def plot_fit(self):
"""
Add the fit to the plot.
"""
self.plt.plot(*self.fit.fit, **self.options['fit']) | python | def plot_fit(self):
"""
Add the fit to the plot.
"""
self.plt.plot(*self.fit.fit, **self.options['fit']) | [
"def",
"plot_fit",
"(",
"self",
")",
":",
"self",
".",
"plt",
".",
"plot",
"(",
"*",
"self",
".",
"fit",
".",
"fit",
",",
"*",
"*",
"self",
".",
"options",
"[",
"'fit'",
"]",
")"
] | Add the fit to the plot. | [
"Add",
"the",
"fit",
"to",
"the",
"plot",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L88-L92 |
52,917 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/plot.py | Plot.add_xlabel | def add_xlabel(self, text=None):
"""
Add a label to the x-axis.
"""
x = self.fit.meta['independent']
if not text:
text = '$' + x['tex_symbol'] + r'$ $(\si{' + x['siunitx'] + r'})$'
self.plt.set_xlabel(text) | python | def add_xlabel(self, text=None):
"""
Add a label to the x-axis.
"""
x = self.fit.meta['independent']
if not text:
text = '$' + x['tex_symbol'] + r'$ $(\si{' + x['siunitx'] + r'})$'
self.plt.set_xlabel(text) | [
"def",
"add_xlabel",
"(",
"self",
",",
"text",
"=",
"None",
")",
":",
"x",
"=",
"self",
".",
"fit",
".",
"meta",
"[",
"'independent'",
"]",
"if",
"not",
"text",
":",
"text",
"=",
"'$'",
"+",
"x",
"[",
"'tex_symbol'",
"]",
"+",
"r'$ $(\\si{'",
"+",
... | Add a label to the x-axis. | [
"Add",
"a",
"label",
"to",
"the",
"x",
"-",
"axis",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L94-L101 |
52,918 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/plot.py | Plot.add_ylabel | def add_ylabel(self, text=None):
"""
Add a label to the y-axis.
"""
y = self.fit.meta['dependent']
if not text:
text = '$' + y['tex_symbol'] + r'$ $(\si{' + y['siunitx'] + r'})$'
self.plt.set_ylabel(text) | python | def add_ylabel(self, text=None):
"""
Add a label to the y-axis.
"""
y = self.fit.meta['dependent']
if not text:
text = '$' + y['tex_symbol'] + r'$ $(\si{' + y['siunitx'] + r'})$'
self.plt.set_ylabel(text) | [
"def",
"add_ylabel",
"(",
"self",
",",
"text",
"=",
"None",
")",
":",
"y",
"=",
"self",
".",
"fit",
".",
"meta",
"[",
"'dependent'",
"]",
"if",
"not",
"text",
":",
"text",
"=",
"'$'",
"+",
"y",
"[",
"'tex_symbol'",
"]",
"+",
"r'$ $(\\si{'",
"+",
... | Add a label to the y-axis. | [
"Add",
"a",
"label",
"to",
"the",
"y",
"-",
"axis",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L103-L110 |
52,919 | razor-x/scipy-data_fitting | scipy_data_fitting/figure/plot.py | Plot.add_text_table | def add_text_table(self, rows, r0, dr, **kwargs):
"""
Add text to a plot in a grid fashion.
`rows` is a list of lists (the rows).
Each row contains the columns,
each column is text to add to the plot.
`r0` is a tuple `(x, y)` that positions the initial text.
`d... | python | def add_text_table(self, rows, r0, dr, **kwargs):
"""
Add text to a plot in a grid fashion.
`rows` is a list of lists (the rows).
Each row contains the columns,
each column is text to add to the plot.
`r0` is a tuple `(x, y)` that positions the initial text.
`d... | [
"def",
"add_text_table",
"(",
"self",
",",
"rows",
",",
"r0",
",",
"dr",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"m",
",",
"row",
"in",
"enumerate",
"(",
"rows",
")",
":",
"for",
"n",
",",
"column",
"in",
"enumerate",
"(",
"row",
")",
":",
"s... | Add text to a plot in a grid fashion.
`rows` is a list of lists (the rows).
Each row contains the columns,
each column is text to add to the plot.
`r0` is a tuple `(x, y)` that positions the initial text.
`dr` is a tuple `(dx, dy)` that determines the column and row spacing.
... | [
"Add",
"text",
"to",
"a",
"plot",
"in",
"a",
"grid",
"fashion",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L112-L139 |
52,920 | praekelt/django-userprofile | userprofile/backends/simple/__init__.py | SimpleBackend._get_redirect_url | def _get_redirect_url(self, request):
"""
Next gathered from session, then GET, then POST,
then users absolute url.
"""
if 'next' in request.session:
next_url = request.session['next']
del request.session['next']
elif 'next' in request.GET:
... | python | def _get_redirect_url(self, request):
"""
Next gathered from session, then GET, then POST,
then users absolute url.
"""
if 'next' in request.session:
next_url = request.session['next']
del request.session['next']
elif 'next' in request.GET:
... | [
"def",
"_get_redirect_url",
"(",
"self",
",",
"request",
")",
":",
"if",
"'next'",
"in",
"request",
".",
"session",
":",
"next_url",
"=",
"request",
".",
"session",
"[",
"'next'",
"]",
"del",
"request",
".",
"session",
"[",
"'next'",
"]",
"elif",
"'next'... | Next gathered from session, then GET, then POST,
then users absolute url. | [
"Next",
"gathered",
"from",
"session",
"then",
"GET",
"then",
"POST",
"then",
"users",
"absolute",
"url",
"."
] | 09e2e08982ffa9fb7e96c715138a0e5537759cd9 | https://github.com/praekelt/django-userprofile/blob/09e2e08982ffa9fb7e96c715138a0e5537759cd9/userprofile/backends/simple/__init__.py#L21-L37 |
52,921 | glenfant/openxmllib | openxmllib/utils.py | IndexableTextExtractor.indexableText | def indexableText(self, tree):
"""Provides the indexable - search engine oriented - raw text
@param tree: an ElementTree
@return: set(["foo", "bar", ...])
"""
rval = set()
root = tree.getroot()
for txp in self.text_elts_xpaths:
elts = txp(root)
... | python | def indexableText(self, tree):
"""Provides the indexable - search engine oriented - raw text
@param tree: an ElementTree
@return: set(["foo", "bar", ...])
"""
rval = set()
root = tree.getroot()
for txp in self.text_elts_xpaths:
elts = txp(root)
... | [
"def",
"indexableText",
"(",
"self",
",",
"tree",
")",
":",
"rval",
"=",
"set",
"(",
")",
"root",
"=",
"tree",
".",
"getroot",
"(",
")",
"for",
"txp",
"in",
"self",
".",
"text_elts_xpaths",
":",
"elts",
"=",
"txp",
"(",
"root",
")",
"texts",
"=",
... | Provides the indexable - search engine oriented - raw text
@param tree: an ElementTree
@return: set(["foo", "bar", ...]) | [
"Provides",
"the",
"indexable",
"-",
"search",
"engine",
"oriented",
"-",
"raw",
"text"
] | c8208f8ecd9fc3ef1e73c1db68081a65361afb3f | https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/utils.py#L57-L76 |
52,922 | chigby/mtg | mtglib/card_extractor.py | CardExtractor._flatten | def _flatten(self, element):
"""Recursively enter and extract text from all child
elements."""
result = [(element.text or '')]
if element.attrib.get('alt'):
result.append(Symbol(element.attrib.get('alt')).textbox)
for sel in element:
result.append(self._fl... | python | def _flatten(self, element):
"""Recursively enter and extract text from all child
elements."""
result = [(element.text or '')]
if element.attrib.get('alt'):
result.append(Symbol(element.attrib.get('alt')).textbox)
for sel in element:
result.append(self._fl... | [
"def",
"_flatten",
"(",
"self",
",",
"element",
")",
":",
"result",
"=",
"[",
"(",
"element",
".",
"text",
"or",
"''",
")",
"]",
"if",
"element",
".",
"attrib",
".",
"get",
"(",
"'alt'",
")",
":",
"result",
".",
"append",
"(",
"Symbol",
"(",
"ele... | Recursively enter and extract text from all child
elements. | [
"Recursively",
"enter",
"and",
"extract",
"text",
"from",
"all",
"child",
"elements",
"."
] | c12976d6c7e13d6859a0fbac4c057dc9529de473 | https://github.com/chigby/mtg/blob/c12976d6c7e13d6859a0fbac4c057dc9529de473/mtglib/card_extractor.py#L38-L49 |
52,923 | thumbor-community/redis | tc_redis/storages/redis_storage.py | Storage.get_storage | def get_storage(self):
'''Get the storage instance.
:return Redis: Redis instance
'''
if self.storage:
return self.storage
self.storage = self.reconnect_redis()
return self.storage | python | def get_storage(self):
'''Get the storage instance.
:return Redis: Redis instance
'''
if self.storage:
return self.storage
self.storage = self.reconnect_redis()
return self.storage | [
"def",
"get_storage",
"(",
"self",
")",
":",
"if",
"self",
".",
"storage",
":",
"return",
"self",
".",
"storage",
"self",
".",
"storage",
"=",
"self",
".",
"reconnect_redis",
"(",
")",
"return",
"self",
".",
"storage"
] | Get the storage instance.
:return Redis: Redis instance | [
"Get",
"the",
"storage",
"instance",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/storages/redis_storage.py#L28-L38 |
52,924 | thumbor-community/redis | tc_redis/storages/redis_storage.py | Storage.on_redis_error | def on_redis_error(self, fname, exc_type, exc_value):
'''Callback executed when there is a redis error.
:param string fname: Function name that was being called.
:param type exc_type: Exception type
:param Exception exc_value: The current exception
:returns: Default value or rai... | python | def on_redis_error(self, fname, exc_type, exc_value):
'''Callback executed when there is a redis error.
:param string fname: Function name that was being called.
:param type exc_type: Exception type
:param Exception exc_value: The current exception
:returns: Default value or rai... | [
"def",
"on_redis_error",
"(",
"self",
",",
"fname",
",",
"exc_type",
",",
"exc_value",
")",
":",
"if",
"self",
".",
"shared_client",
":",
"Storage",
".",
"storage",
"=",
"None",
"else",
":",
"self",
".",
"storage",
"=",
"None",
"if",
"self",
".",
"cont... | Callback executed when there is a redis error.
:param string fname: Function name that was being called.
:param type exc_type: Exception type
:param Exception exc_value: The current exception
:returns: Default value or raise the current exception | [
"Callback",
"executed",
"when",
"there",
"is",
"a",
"redis",
"error",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/storages/redis_storage.py#L55-L75 |
52,925 | getnikola/coil | coil/web.py | configure_url | def configure_url(url):
"""Configure site URL."""
app.config['COIL_URL'] = \
_site.config['SITE_URL'] = _site.config['BASE_URL'] =\
_site.GLOBAL_CONTEXT['blog_url'] =\
site.config['SITE_URL'] = site.config['BASE_URL'] =\
url | python | def configure_url(url):
"""Configure site URL."""
app.config['COIL_URL'] = \
_site.config['SITE_URL'] = _site.config['BASE_URL'] =\
_site.GLOBAL_CONTEXT['blog_url'] =\
site.config['SITE_URL'] = site.config['BASE_URL'] =\
url | [
"def",
"configure_url",
"(",
"url",
")",
":",
"app",
".",
"config",
"[",
"'COIL_URL'",
"]",
"=",
"_site",
".",
"config",
"[",
"'SITE_URL'",
"]",
"=",
"_site",
".",
"config",
"[",
"'BASE_URL'",
"]",
"=",
"_site",
".",
"GLOBAL_CONTEXT",
"[",
"'blog_url'",
... | Configure site URL. | [
"Configure",
"site",
"URL",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L66-L72 |
52,926 | getnikola/coil | coil/web.py | password_hash | def password_hash(password):
"""Hash the password, using bcrypt+sha256.
.. versionchanged:: 1.1.0
:param str password: Password in plaintext
:return: password hash
:rtype: str
"""
try:
return bcrypt_sha256.encrypt(password)
except TypeError:
return bcrypt_sha256.encrypt... | python | def password_hash(password):
"""Hash the password, using bcrypt+sha256.
.. versionchanged:: 1.1.0
:param str password: Password in plaintext
:return: password hash
:rtype: str
"""
try:
return bcrypt_sha256.encrypt(password)
except TypeError:
return bcrypt_sha256.encrypt... | [
"def",
"password_hash",
"(",
"password",
")",
":",
"try",
":",
"return",
"bcrypt_sha256",
".",
"encrypt",
"(",
"password",
")",
"except",
"TypeError",
":",
"return",
"bcrypt_sha256",
".",
"encrypt",
"(",
"password",
".",
"decode",
"(",
"'utf-8'",
")",
")"
] | Hash the password, using bcrypt+sha256.
.. versionchanged:: 1.1.0
:param str password: Password in plaintext
:return: password hash
:rtype: str | [
"Hash",
"the",
"password",
"using",
"bcrypt",
"+",
"sha256",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L209-L221 |
52,927 | getnikola/coil | coil/web.py | generate_menu | def generate_menu():
"""Generate ``menu`` with the rebuild link.
:return: HTML fragment
:rtype: str
"""
if db is not None:
needs_rebuild = db.get('site:needs_rebuild')
else:
needs_rebuild = site.coil_needs_rebuild
if needs_rebuild not in (u'0', u'-1', b'0', b'-1'):
r... | python | def generate_menu():
"""Generate ``menu`` with the rebuild link.
:return: HTML fragment
:rtype: str
"""
if db is not None:
needs_rebuild = db.get('site:needs_rebuild')
else:
needs_rebuild = site.coil_needs_rebuild
if needs_rebuild not in (u'0', u'-1', b'0', b'-1'):
r... | [
"def",
"generate_menu",
"(",
")",
":",
"if",
"db",
"is",
"not",
"None",
":",
"needs_rebuild",
"=",
"db",
".",
"get",
"(",
"'site:needs_rebuild'",
")",
"else",
":",
"needs_rebuild",
"=",
"site",
".",
"coil_needs_rebuild",
"if",
"needs_rebuild",
"not",
"in",
... | Generate ``menu`` with the rebuild link.
:return: HTML fragment
:rtype: str | [
"Generate",
"menu",
"with",
"the",
"rebuild",
"link",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L253-L269 |
52,928 | getnikola/coil | coil/web.py | _author_uid_get | def _author_uid_get(post):
"""Get the UID of the post author.
:param Post post: The post object to determine authorship of
:return: Author UID
:rtype: str
"""
u = post.meta('author.uid')
return u if u else str(current_user.uid) | python | def _author_uid_get(post):
"""Get the UID of the post author.
:param Post post: The post object to determine authorship of
:return: Author UID
:rtype: str
"""
u = post.meta('author.uid')
return u if u else str(current_user.uid) | [
"def",
"_author_uid_get",
"(",
"post",
")",
":",
"u",
"=",
"post",
".",
"meta",
"(",
"'author.uid'",
")",
"return",
"u",
"if",
"u",
"else",
"str",
"(",
"current_user",
".",
"uid",
")"
] | Get the UID of the post author.
:param Post post: The post object to determine authorship of
:return: Author UID
:rtype: str | [
"Get",
"the",
"UID",
"of",
"the",
"post",
"author",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L318-L326 |
52,929 | getnikola/coil | coil/web.py | render | def render(template_name, context=None, code=200, headers=None):
"""Render a response using standard Nikola templates.
:param str template_name: Template name
:param dict context: Context (variables) to use in the template
:param int code: HTTP status code
:param headers: Headers to use for the res... | python | def render(template_name, context=None, code=200, headers=None):
"""Render a response using standard Nikola templates.
:param str template_name: Template name
:param dict context: Context (variables) to use in the template
:param int code: HTTP status code
:param headers: Headers to use for the res... | [
"def",
"render",
"(",
"template_name",
",",
"context",
"=",
"None",
",",
"code",
"=",
"200",
",",
"headers",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{... | Render a response using standard Nikola templates.
:param str template_name: Template name
:param dict context: Context (variables) to use in the template
:param int code: HTTP status code
:param headers: Headers to use for the response
:return: HTML fragment
:rtype: str | [
"Render",
"a",
"response",
"using",
"standard",
"Nikola",
"templates",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L329-L367 |
52,930 | getnikola/coil | coil/web.py | get_user | def get_user(uid):
"""Get an user by the UID.
:param str uid: UID to find
:return: the user
:rtype: User object
:raises ValueError: uid is not an integer
:raises KeyError: if user does not exist
"""
if db is not None:
try:
uid = uid.decode('utf-8')
except Att... | python | def get_user(uid):
"""Get an user by the UID.
:param str uid: UID to find
:return: the user
:rtype: User object
:raises ValueError: uid is not an integer
:raises KeyError: if user does not exist
"""
if db is not None:
try:
uid = uid.decode('utf-8')
except Att... | [
"def",
"get_user",
"(",
"uid",
")",
":",
"if",
"db",
"is",
"not",
"None",
":",
"try",
":",
"uid",
"=",
"uid",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"AttributeError",
":",
"pass",
"d",
"=",
"db",
".",
"hgetall",
"(",
"'user:{0}'",
".",
"form... | Get an user by the UID.
:param str uid: UID to find
:return: the user
:rtype: User object
:raises ValueError: uid is not an integer
:raises KeyError: if user does not exist | [
"Get",
"an",
"user",
"by",
"the",
"UID",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L473-L509 |
52,931 | getnikola/coil | coil/web.py | find_user_by_name | def find_user_by_name(username):
"""Get an user by their username.
:param str username: Username to find
:return: the user
:rtype: User object or None
"""
if db is not None:
uid = db.hget('users', username)
if uid:
return get_user(uid)
else:
for uid, u in... | python | def find_user_by_name(username):
"""Get an user by their username.
:param str username: Username to find
:return: the user
:rtype: User object or None
"""
if db is not None:
uid = db.hget('users', username)
if uid:
return get_user(uid)
else:
for uid, u in... | [
"def",
"find_user_by_name",
"(",
"username",
")",
":",
"if",
"db",
"is",
"not",
"None",
":",
"uid",
"=",
"db",
".",
"hget",
"(",
"'users'",
",",
"username",
")",
"if",
"uid",
":",
"return",
"get_user",
"(",
"uid",
")",
"else",
":",
"for",
"uid",
",... | Get an user by their username.
:param str username: Username to find
:return: the user
:rtype: User object or None | [
"Get",
"an",
"user",
"by",
"their",
"username",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L512-L526 |
52,932 | getnikola/coil | coil/web.py | write_user | def write_user(user):
"""Write an user ot the database.
:param User user: User to write
"""
udata = {}
for f in USER_FIELDS:
udata[f] = getattr(user, f)
for p in PERMISSIONS:
udata[p] = '1' if getattr(user, p) else '0'
db.hmset('user:{0}'.format(user.uid), udata) | python | def write_user(user):
"""Write an user ot the database.
:param User user: User to write
"""
udata = {}
for f in USER_FIELDS:
udata[f] = getattr(user, f)
for p in PERMISSIONS:
udata[p] = '1' if getattr(user, p) else '0'
db.hmset('user:{0}'.format(user.uid), udata) | [
"def",
"write_user",
"(",
"user",
")",
":",
"udata",
"=",
"{",
"}",
"for",
"f",
"in",
"USER_FIELDS",
":",
"udata",
"[",
"f",
"]",
"=",
"getattr",
"(",
"user",
",",
"f",
")",
"for",
"p",
"in",
"PERMISSIONS",
":",
"udata",
"[",
"p",
"]",
"=",
"'1... | Write an user ot the database.
:param User user: User to write | [
"Write",
"an",
"user",
"ot",
"the",
"database",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L529-L542 |
52,933 | getnikola/coil | coil/web.py | login | def login():
"""Handle user authentication.
If requested over GET, present login page.
If requested over POST, log user in.
:param str status: Status of previous request/login attempt
"""
alert = None
alert_status = 'danger'
code = 200
captcha = app.config['COIL_LOGIN_CAPTCHA']
... | python | def login():
"""Handle user authentication.
If requested over GET, present login page.
If requested over POST, log user in.
:param str status: Status of previous request/login attempt
"""
alert = None
alert_status = 'danger'
code = 200
captcha = app.config['COIL_LOGIN_CAPTCHA']
... | [
"def",
"login",
"(",
")",
":",
"alert",
"=",
"None",
"alert_status",
"=",
"'danger'",
"code",
"=",
"200",
"captcha",
"=",
"app",
".",
"config",
"[",
"'COIL_LOGIN_CAPTCHA'",
"]",
"form",
"=",
"LoginForm",
"(",
")",
"if",
"request",
".",
"method",
"==",
... | Handle user authentication.
If requested over GET, present login page.
If requested over POST, log user in.
:param str status: Status of previous request/login attempt | [
"Handle",
"user",
"authentication",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L546-L614 |
52,934 | getnikola/coil | coil/web.py | index | def index():
"""Show the index with all posts.
:param int all: Whether or not should show all posts
"""
context = {'postform': NewPostForm(),
'pageform': NewPageForm(),
'delform': DeleteForm()}
n = request.args.get('all')
if n is None:
wants_now = None
... | python | def index():
"""Show the index with all posts.
:param int all: Whether or not should show all posts
"""
context = {'postform': NewPostForm(),
'pageform': NewPageForm(),
'delform': DeleteForm()}
n = request.args.get('all')
if n is None:
wants_now = None
... | [
"def",
"index",
"(",
")",
":",
"context",
"=",
"{",
"'postform'",
":",
"NewPostForm",
"(",
")",
",",
"'pageform'",
":",
"NewPageForm",
"(",
")",
",",
"'delform'",
":",
"DeleteForm",
"(",
")",
"}",
"n",
"=",
"request",
".",
"args",
".",
"get",
"(",
... | Show the index with all posts.
:param int all: Whether or not should show all posts | [
"Show",
"the",
"index",
"with",
"all",
"posts",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L627-L667 |
52,935 | getnikola/coil | coil/web.py | rebuild | def rebuild(mode=''):
"""Rebuild the site with a nice UI."""
scan_site() # for good measure
if not current_user.can_rebuild_site:
return error('You are not permitted to rebuild the site.</p>'
'<p class="lead">Contact an administartor for '
'more information... | python | def rebuild(mode=''):
"""Rebuild the site with a nice UI."""
scan_site() # for good measure
if not current_user.can_rebuild_site:
return error('You are not permitted to rebuild the site.</p>'
'<p class="lead">Contact an administartor for '
'more information... | [
"def",
"rebuild",
"(",
"mode",
"=",
"''",
")",
":",
"scan_site",
"(",
")",
"# for good measure",
"if",
"not",
"current_user",
".",
"can_rebuild_site",
":",
"return",
"error",
"(",
"'You are not permitted to rebuild the site.</p>'",
"'<p class=\"lead\">Contact an administa... | Rebuild the site with a nice UI. | [
"Rebuild",
"the",
"site",
"with",
"a",
"nice",
"UI",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L823-L848 |
52,936 | getnikola/coil | coil/web.py | serve_bower_components | def serve_bower_components(path):
"""Serve bower components.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/bower_components/ => coil/data/bower_components
"""
res = pkg_resources.resource_filename(
'coil... | python | def serve_bower_components(path):
"""Serve bower components.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/bower_components/ => coil/data/bower_components
"""
res = pkg_resources.resource_filename(
'coil... | [
"def",
"serve_bower_components",
"(",
"path",
")",
":",
"res",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"'coil'",
",",
"os",
".",
"path",
".",
"join",
"(",
"'data'",
",",
"'bower_components'",
")",
")",
"return",
"send_from_directory",
"(",
"res",
... | Serve bower components.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/bower_components/ => coil/data/bower_components | [
"Serve",
"bower",
"components",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L897-L907 |
52,937 | getnikola/coil | coil/web.py | serve_coil_assets | def serve_coil_assets(path):
"""Serve Coil assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/coil_assets/ => coil/data/coil_assets
"""
res = pkg_resources.resource_filename(
'coil', os.path.join('dat... | python | def serve_coil_assets(path):
"""Serve Coil assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/coil_assets/ => coil/data/coil_assets
"""
res = pkg_resources.resource_filename(
'coil', os.path.join('dat... | [
"def",
"serve_coil_assets",
"(",
"path",
")",
":",
"res",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"'coil'",
",",
"os",
".",
"path",
".",
"join",
"(",
"'data'",
",",
"'coil_assets'",
")",
")",
"return",
"send_from_directory",
"(",
"res",
",",
"... | Serve Coil assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/coil_assets/ => coil/data/coil_assets | [
"Serve",
"Coil",
"assets",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L911-L921 |
52,938 | getnikola/coil | coil/web.py | serve_assets | def serve_assets(path):
"""Serve Nikola assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/assets/ => output/assets
"""
res = os.path.join(app.config['NIKOLA_ROOT'],
_site.config["OUTPU... | python | def serve_assets(path):
"""Serve Nikola assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/assets/ => output/assets
"""
res = os.path.join(app.config['NIKOLA_ROOT'],
_site.config["OUTPU... | [
"def",
"serve_assets",
"(",
"path",
")",
":",
"res",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app",
".",
"config",
"[",
"'NIKOLA_ROOT'",
"]",
",",
"_site",
".",
"config",
"[",
"\"OUTPUT_FOLDER\"",
"]",
",",
"'assets'",
")",
"return",
"send_from_directo... | Serve Nikola assets.
This is meant to be used ONLY by the internal dev server.
Please configure your web server to handle requests to this URL::
/assets/ => output/assets | [
"Serve",
"Nikola",
"assets",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L925-L935 |
52,939 | getnikola/coil | coil/web.py | acp_account | def acp_account():
"""Manage the user account of currently-logged-in users.
This does NOT accept admin-specific options.
"""
if request.args.get('status') == 'pwdchange':
alert = 'You must change your password before proceeding.'
alert_status = 'danger'
pwdchange_skip = True
... | python | def acp_account():
"""Manage the user account of currently-logged-in users.
This does NOT accept admin-specific options.
"""
if request.args.get('status') == 'pwdchange':
alert = 'You must change your password before proceeding.'
alert_status = 'danger'
pwdchange_skip = True
... | [
"def",
"acp_account",
"(",
")",
":",
"if",
"request",
".",
"args",
".",
"get",
"(",
"'status'",
")",
"==",
"'pwdchange'",
":",
"alert",
"=",
"'You must change your password before proceeding.'",
"alert_status",
"=",
"'danger'",
"pwdchange_skip",
"=",
"True",
"else... | Manage the user account of currently-logged-in users.
This does NOT accept admin-specific options. | [
"Manage",
"the",
"user",
"account",
"of",
"currently",
"-",
"logged",
"-",
"in",
"users",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L940-L999 |
52,940 | getnikola/coil | coil/web.py | acp_users_edit | def acp_users_edit():
"""Edit an user account."""
global current_user
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
data = request.form
form = UserEditForm()
if n... | python | def acp_users_edit():
"""Edit an user account."""
global current_user
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
data = request.form
form = UserEditForm()
if n... | [
"def",
"acp_users_edit",
"(",
")",
":",
"global",
"current_user",
"if",
"not",
"current_user",
".",
"is_admin",
":",
"return",
"error",
"(",
"\"Not authorized to edit users.\"",
",",
"401",
")",
"if",
"not",
"db",
":",
"return",
"error",
"(",
"'The ACP is not av... | Edit an user account. | [
"Edit",
"an",
"user",
"account",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L1051-L1121 |
52,941 | getnikola/coil | coil/web.py | acp_users_import | def acp_users_import():
"""Import users from a TSV file."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = UserImportForm()
if not form.validate():
return e... | python | def acp_users_import():
"""Import users from a TSV file."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = UserImportForm()
if not form.validate():
return e... | [
"def",
"acp_users_import",
"(",
")",
":",
"if",
"not",
"current_user",
".",
"is_admin",
":",
"return",
"error",
"(",
"\"Not authorized to edit users.\"",
",",
"401",
")",
"if",
"not",
"db",
":",
"return",
"error",
"(",
"'The ACP is not available in single-user mode.... | Import users from a TSV file. | [
"Import",
"users",
"from",
"a",
"TSV",
"file",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L1126-L1138 |
52,942 | getnikola/coil | coil/web.py | acp_users_delete | def acp_users_delete():
"""Delete or undelete an user account."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = UserDeleteForm()
if not form.validate():
re... | python | def acp_users_delete():
"""Delete or undelete an user account."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = UserDeleteForm()
if not form.validate():
re... | [
"def",
"acp_users_delete",
"(",
")",
":",
"if",
"not",
"current_user",
".",
"is_admin",
":",
"return",
"error",
"(",
"\"Not authorized to edit users.\"",
",",
"401",
")",
"if",
"not",
"db",
":",
"return",
"error",
"(",
"'The ACP is not available in single-user mode.... | Delete or undelete an user account. | [
"Delete",
"or",
"undelete",
"an",
"user",
"account",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L1144-L1164 |
52,943 | getnikola/coil | coil/web.py | acp_users_permissions | def acp_users_permissions():
"""Change user permissions."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = PermissionsForm()
users = []
uids = db.hgetall('users... | python | def acp_users_permissions():
"""Change user permissions."""
if not current_user.is_admin:
return error("Not authorized to edit users.", 401)
if not db:
return error('The ACP is not available in single-user mode.', 500)
form = PermissionsForm()
users = []
uids = db.hgetall('users... | [
"def",
"acp_users_permissions",
"(",
")",
":",
"if",
"not",
"current_user",
".",
"is_admin",
":",
"return",
"error",
"(",
"\"Not authorized to edit users.\"",
",",
"401",
")",
"if",
"not",
"db",
":",
"return",
"error",
"(",
"'The ACP is not available in single-user ... | Change user permissions. | [
"Change",
"user",
"permissions",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L1169-L1229 |
52,944 | todofixthis/pyota-ccurl | pyota_ccurl.py | is_installed | def is_installed():
# type: () -> bool
"""
Returns whether the C extension is installed correctly.
"""
try:
# noinspection PyUnresolvedReferences
from ccurl import Curl as CCurl
except ImportError:
return False
else:
# noinspection PyUnresolvedReferences
from iota.crypto import Curl
... | python | def is_installed():
# type: () -> bool
"""
Returns whether the C extension is installed correctly.
"""
try:
# noinspection PyUnresolvedReferences
from ccurl import Curl as CCurl
except ImportError:
return False
else:
# noinspection PyUnresolvedReferences
from iota.crypto import Curl
... | [
"def",
"is_installed",
"(",
")",
":",
"# type: () -> bool",
"try",
":",
"# noinspection PyUnresolvedReferences",
"from",
"ccurl",
"import",
"Curl",
"as",
"CCurl",
"except",
"ImportError",
":",
"return",
"False",
"else",
":",
"# noinspection PyUnresolvedReferences",
"fro... | Returns whether the C extension is installed correctly. | [
"Returns",
"whether",
"the",
"C",
"extension",
"is",
"installed",
"correctly",
"."
] | f22965e40ee1fd61e2206684c8fad61128f38bf5 | https://github.com/todofixthis/pyota-ccurl/blob/f22965e40ee1fd61e2206684c8fad61128f38bf5/pyota_ccurl.py#L6-L19 |
52,945 | mattrobenolt/ec2 | ec2/helpers.py | make_compare | def make_compare(key, value, obj):
"Map a key name to a specific comparison function"
if '__' not in key:
# If no __ exists, default to doing an "exact" comparison
key, comp = key, 'exact'
else:
key, comp = key.rsplit('__', 1)
# Check if comp is valid
if hasattr(Compare, comp... | python | def make_compare(key, value, obj):
"Map a key name to a specific comparison function"
if '__' not in key:
# If no __ exists, default to doing an "exact" comparison
key, comp = key, 'exact'
else:
key, comp = key.rsplit('__', 1)
# Check if comp is valid
if hasattr(Compare, comp... | [
"def",
"make_compare",
"(",
"key",
",",
"value",
",",
"obj",
")",
":",
"if",
"'__'",
"not",
"in",
"key",
":",
"# If no __ exists, default to doing an \"exact\" comparison",
"key",
",",
"comp",
"=",
"key",
",",
"'exact'",
"else",
":",
"key",
",",
"comp",
"=",... | Map a key name to a specific comparison function | [
"Map",
"a",
"key",
"name",
"to",
"a",
"specific",
"comparison",
"function"
] | fc1f8bce6cf76899165d9ac006371181d52439f8 | https://github.com/mattrobenolt/ec2/blob/fc1f8bce6cf76899165d9ac006371181d52439f8/ec2/helpers.py#L12-L22 |
52,946 | leetrout/python-nutritionix | nutritionix.py | Nutritionix.mock_attr | def mock_attr(self, *args, **kwargs):
"""
Empty method to call to slurp up args and kwargs.
`args` get pushed onto the url path.
`kwargs` are converted to a query string and appended to the URL.
"""
self.path.extend(args)
self.qs.update(kwargs)
return sel... | python | def mock_attr(self, *args, **kwargs):
"""
Empty method to call to slurp up args and kwargs.
`args` get pushed onto the url path.
`kwargs` are converted to a query string and appended to the URL.
"""
self.path.extend(args)
self.qs.update(kwargs)
return sel... | [
"def",
"mock_attr",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"path",
".",
"extend",
"(",
"args",
")",
"self",
".",
"qs",
".",
"update",
"(",
"kwargs",
")",
"return",
"self"
] | Empty method to call to slurp up args and kwargs.
`args` get pushed onto the url path.
`kwargs` are converted to a query string and appended to the URL. | [
"Empty",
"method",
"to",
"call",
"to",
"slurp",
"up",
"args",
"and",
"kwargs",
"."
] | 2f900bf78dce5928b2a1c9d568f87e0c1d81455f | https://github.com/leetrout/python-nutritionix/blob/2f900bf78dce5928b2a1c9d568f87e0c1d81455f/nutritionix.py#L38-L47 |
52,947 | pasztorpisti/json-cfg | src/jsoncfg/parser.py | TextParser.column | def column(self):
""" Returns the zero based column number based on the
current position of the parser. """
for i in my_xrange(self._column_query_pos, self.pos):
if self.text[i] == '\t':
self._column += self.tab_size
self._column -= self._column % self... | python | def column(self):
""" Returns the zero based column number based on the
current position of the parser. """
for i in my_xrange(self._column_query_pos, self.pos):
if self.text[i] == '\t':
self._column += self.tab_size
self._column -= self._column % self... | [
"def",
"column",
"(",
"self",
")",
":",
"for",
"i",
"in",
"my_xrange",
"(",
"self",
".",
"_column_query_pos",
",",
"self",
".",
"pos",
")",
":",
"if",
"self",
".",
"text",
"[",
"i",
"]",
"==",
"'\\t'",
":",
"self",
".",
"_column",
"+=",
"self",
"... | Returns the zero based column number based on the
current position of the parser. | [
"Returns",
"the",
"zero",
"based",
"column",
"number",
"based",
"on",
"the",
"current",
"position",
"of",
"the",
"parser",
"."
] | 4627b14a92521ef8a39bbedaa7af8d380d406d07 | https://github.com/pasztorpisti/json-cfg/blob/4627b14a92521ef8a39bbedaa7af8d380d406d07/src/jsoncfg/parser.py#L36-L46 |
52,948 | pasztorpisti/json-cfg | src/jsoncfg/parser.py | TextParser.peek | def peek(self, offset=0):
""" Looking forward in the input text without actually stepping the current position.
returns None if the current position is at the end of the input. """
pos = self.pos + offset
if pos >= self.end:
return None
return self.text[pos] | python | def peek(self, offset=0):
""" Looking forward in the input text without actually stepping the current position.
returns None if the current position is at the end of the input. """
pos = self.pos + offset
if pos >= self.end:
return None
return self.text[pos] | [
"def",
"peek",
"(",
"self",
",",
"offset",
"=",
"0",
")",
":",
"pos",
"=",
"self",
".",
"pos",
"+",
"offset",
"if",
"pos",
">=",
"self",
".",
"end",
":",
"return",
"None",
"return",
"self",
".",
"text",
"[",
"pos",
"]"
] | Looking forward in the input text without actually stepping the current position.
returns None if the current position is at the end of the input. | [
"Looking",
"forward",
"in",
"the",
"input",
"text",
"without",
"actually",
"stepping",
"the",
"current",
"position",
".",
"returns",
"None",
"if",
"the",
"current",
"position",
"is",
"at",
"the",
"end",
"of",
"the",
"input",
"."
] | 4627b14a92521ef8a39bbedaa7af8d380d406d07 | https://github.com/pasztorpisti/json-cfg/blob/4627b14a92521ef8a39bbedaa7af8d380d406d07/src/jsoncfg/parser.py#L90-L96 |
52,949 | getnikola/coil | coil/utils.py | ask | def ask(query, default=None):
"""Ask a question."""
if default:
default_q = ' [{0}]'.format(default)
else:
default_q = ''
if sys.version_info[0] == 3:
inp = input("{query}{default_q}: ".format(
query=query, default_q=default_q)).strip()
else:
inp = raw_inp... | python | def ask(query, default=None):
"""Ask a question."""
if default:
default_q = ' [{0}]'.format(default)
else:
default_q = ''
if sys.version_info[0] == 3:
inp = input("{query}{default_q}: ".format(
query=query, default_q=default_q)).strip()
else:
inp = raw_inp... | [
"def",
"ask",
"(",
"query",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
":",
"default_q",
"=",
"' [{0}]'",
".",
"format",
"(",
"default",
")",
"else",
":",
"default_q",
"=",
"''",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"... | Ask a question. | [
"Ask",
"a",
"question",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L52-L67 |
52,950 | getnikola/coil | coil/utils.py | SiteProxy.reload_site | def reload_site(self):
"""Reload the site from the database."""
rev = int(self.db.get('site:rev'))
if rev != self.revision and self.db.exists('site:rev'):
timeline = self.db.lrange('site:timeline', 0, -1)
self._timeline = []
for data in timeline:
... | python | def reload_site(self):
"""Reload the site from the database."""
rev = int(self.db.get('site:rev'))
if rev != self.revision and self.db.exists('site:rev'):
timeline = self.db.lrange('site:timeline', 0, -1)
self._timeline = []
for data in timeline:
... | [
"def",
"reload_site",
"(",
"self",
")",
":",
"rev",
"=",
"int",
"(",
"self",
".",
"db",
".",
"get",
"(",
"'site:rev'",
")",
")",
"if",
"rev",
"!=",
"self",
".",
"revision",
"and",
"self",
".",
"db",
".",
"exists",
"(",
"'site:rev'",
")",
":",
"ti... | Reload the site from the database. | [
"Reload",
"the",
"site",
"from",
"the",
"database",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L112-L133 |
52,951 | getnikola/coil | coil/utils.py | SiteProxy._read_indexlist | def _read_indexlist(self, name):
"""Read a list of indexes."""
setattr(self, '_' + name, [self._timeline[int(i)] for i in
self.db.lrange('site:{0}'.format(name), 0,
-1)]) | python | def _read_indexlist(self, name):
"""Read a list of indexes."""
setattr(self, '_' + name, [self._timeline[int(i)] for i in
self.db.lrange('site:{0}'.format(name), 0,
-1)]) | [
"def",
"_read_indexlist",
"(",
"self",
",",
"name",
")",
":",
"setattr",
"(",
"self",
",",
"'_'",
"+",
"name",
",",
"[",
"self",
".",
"_timeline",
"[",
"int",
"(",
"i",
")",
"]",
"for",
"i",
"in",
"self",
".",
"db",
".",
"lrange",
"(",
"'site:{0}... | Read a list of indexes. | [
"Read",
"a",
"list",
"of",
"indexes",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L135-L139 |
52,952 | getnikola/coil | coil/utils.py | SiteProxy._write_indexlist | def _write_indexlist(self, name):
"""Write a list of indexes."""
d = [self._site.timeline.index(p) for p in getattr(self._site, name)]
self.db.delete('site:{0}'.format(name))
if d:
self.db.rpush('site:{0}'.format(name), *d) | python | def _write_indexlist(self, name):
"""Write a list of indexes."""
d = [self._site.timeline.index(p) for p in getattr(self._site, name)]
self.db.delete('site:{0}'.format(name))
if d:
self.db.rpush('site:{0}'.format(name), *d) | [
"def",
"_write_indexlist",
"(",
"self",
",",
"name",
")",
":",
"d",
"=",
"[",
"self",
".",
"_site",
".",
"timeline",
".",
"index",
"(",
"p",
")",
"for",
"p",
"in",
"getattr",
"(",
"self",
".",
"_site",
",",
"name",
")",
"]",
"self",
".",
"db",
... | Write a list of indexes. | [
"Write",
"a",
"list",
"of",
"indexes",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L141-L146 |
52,953 | getnikola/coil | coil/utils.py | SiteProxy.scan_posts | def scan_posts(self, really=True, ignore_quit=False, quiet=True):
"""Rescan the site."""
while (self.db.exists('site:lock') and
int(self.db.get('site:lock')) != 0):
self.logger.info("Waiting for DB lock...")
time.sleep(0.5)
self.db.incr('site:lock')
... | python | def scan_posts(self, really=True, ignore_quit=False, quiet=True):
"""Rescan the site."""
while (self.db.exists('site:lock') and
int(self.db.get('site:lock')) != 0):
self.logger.info("Waiting for DB lock...")
time.sleep(0.5)
self.db.incr('site:lock')
... | [
"def",
"scan_posts",
"(",
"self",
",",
"really",
"=",
"True",
",",
"ignore_quit",
"=",
"False",
",",
"quiet",
"=",
"True",
")",
":",
"while",
"(",
"self",
".",
"db",
".",
"exists",
"(",
"'site:lock'",
")",
"and",
"int",
"(",
"self",
".",
"db",
".",... | Rescan the site. | [
"Rescan",
"the",
"site",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L148-L178 |
52,954 | getnikola/coil | coil/utils.py | SiteProxy.timeline | def timeline(self):
"""Get timeline, reloading the site if needed."""
rev = int(self.db.get('site:rev'))
if rev != self.revision:
self.reload_site()
return self._timeline | python | def timeline(self):
"""Get timeline, reloading the site if needed."""
rev = int(self.db.get('site:rev'))
if rev != self.revision:
self.reload_site()
return self._timeline | [
"def",
"timeline",
"(",
"self",
")",
":",
"rev",
"=",
"int",
"(",
"self",
".",
"db",
".",
"get",
"(",
"'site:rev'",
")",
")",
"if",
"rev",
"!=",
"self",
".",
"revision",
":",
"self",
".",
"reload_site",
"(",
")",
"return",
"self",
".",
"_timeline"
... | Get timeline, reloading the site if needed. | [
"Get",
"timeline",
"reloading",
"the",
"site",
"if",
"needed",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L181-L187 |
52,955 | getnikola/coil | coil/utils.py | SiteProxy.posts | def posts(self):
"""Get posts, reloading the site if needed."""
rev = int(self.db.get('site:rev'))
if rev != self.revision:
self.reload_site()
return self._posts | python | def posts(self):
"""Get posts, reloading the site if needed."""
rev = int(self.db.get('site:rev'))
if rev != self.revision:
self.reload_site()
return self._posts | [
"def",
"posts",
"(",
"self",
")",
":",
"rev",
"=",
"int",
"(",
"self",
".",
"db",
".",
"get",
"(",
"'site:rev'",
")",
")",
"if",
"rev",
"!=",
"self",
".",
"revision",
":",
"self",
".",
"reload_site",
"(",
")",
"return",
"self",
".",
"_posts"
] | Get posts, reloading the site if needed. | [
"Get",
"posts",
"reloading",
"the",
"site",
"if",
"needed",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L190-L196 |
52,956 | getnikola/coil | coil/utils.py | SiteProxy.all_posts | def all_posts(self):
"""Get all_posts, reloading the site if needed."""
rev = self.db.get('site:rev')
if int(rev) != self.revision:
self.reload_site()
return self._all_posts | python | def all_posts(self):
"""Get all_posts, reloading the site if needed."""
rev = self.db.get('site:rev')
if int(rev) != self.revision:
self.reload_site()
return self._all_posts | [
"def",
"all_posts",
"(",
"self",
")",
":",
"rev",
"=",
"self",
".",
"db",
".",
"get",
"(",
"'site:rev'",
")",
"if",
"int",
"(",
"rev",
")",
"!=",
"self",
".",
"revision",
":",
"self",
".",
"reload_site",
"(",
")",
"return",
"self",
".",
"_all_posts... | Get all_posts, reloading the site if needed. | [
"Get",
"all_posts",
"reloading",
"the",
"site",
"if",
"needed",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L199-L205 |
52,957 | getnikola/coil | coil/utils.py | SiteProxy.pages | def pages(self):
"""Get pages, reloading the site if needed."""
rev = self.db.get('site:rev')
if int(rev) != self.revision:
self.reload_site()
return self._pages | python | def pages(self):
"""Get pages, reloading the site if needed."""
rev = self.db.get('site:rev')
if int(rev) != self.revision:
self.reload_site()
return self._pages | [
"def",
"pages",
"(",
"self",
")",
":",
"rev",
"=",
"self",
".",
"db",
".",
"get",
"(",
"'site:rev'",
")",
"if",
"int",
"(",
"rev",
")",
"!=",
"self",
".",
"revision",
":",
"self",
".",
"reload_site",
"(",
")",
"return",
"self",
".",
"_pages"
] | Get pages, reloading the site if needed. | [
"Get",
"pages",
"reloading",
"the",
"site",
"if",
"needed",
"."
] | 80ef1827460b0691cf2c98351a14d88e235c9899 | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L208-L214 |
52,958 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.options | def options(self):
"""
Dictionary of options which affect the curve fitting algorithm.
Must contain the key `fit_function` which must be set to
the function that will perform the fit.
All other options are passed as keyword arguments to the `fit_function`.
The default ... | python | def options(self):
"""
Dictionary of options which affect the curve fitting algorithm.
Must contain the key `fit_function` which must be set to
the function that will perform the fit.
All other options are passed as keyword arguments to the `fit_function`.
The default ... | [
"def",
"options",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_options'",
")",
":",
"self",
".",
"_options",
"=",
"{",
"'fit_function'",
":",
"scipy",
".",
"optimize",
".",
"curve_fit",
",",
"'maxfev'",
":",
"1000",
",",
"}",
"... | Dictionary of options which affect the curve fitting algorithm.
Must contain the key `fit_function` which must be set to
the function that will perform the fit.
All other options are passed as keyword arguments to the `fit_function`.
The default options use `scipy.optimize.curve_fit`.... | [
"Dictionary",
"of",
"options",
"which",
"affect",
"the",
"curve",
"fitting",
"algorithm",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L86-L139 |
52,959 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.limits | def limits(self):
"""
Limits to use for the independent variable whenever
creating a linespace, plot, etc.
Defaults to `(-x, x)` where `x` is the largest absolute value
of the data corresponding to the independent variable.
If no such values are negative, defaults to `(0... | python | def limits(self):
"""
Limits to use for the independent variable whenever
creating a linespace, plot, etc.
Defaults to `(-x, x)` where `x` is the largest absolute value
of the data corresponding to the independent variable.
If no such values are negative, defaults to `(0... | [
"def",
"limits",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_limits'",
")",
":",
"xmax",
"=",
"max",
"(",
"abs",
"(",
"self",
".",
"data",
".",
"array",
"[",
"0",
"]",
")",
")",
"xmin",
"=",
"min",
"(",
"self",
".",
"d... | Limits to use for the independent variable whenever
creating a linespace, plot, etc.
Defaults to `(-x, x)` where `x` is the largest absolute value
of the data corresponding to the independent variable.
If no such values are negative, defaults to `(0, x)` instead. | [
"Limits",
"to",
"use",
"for",
"the",
"independent",
"variable",
"whenever",
"creating",
"a",
"linespace",
"plot",
"etc",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L167-L189 |
52,960 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.fixed_values | def fixed_values(self):
"""
A flat tuple of all values corresponding to `scipy_data_fitting.Fit.fixed_parameters`
and `scipy_data_fitting.Fit.constants` after applying any prefixes.
The values mimic the order of those lists.
"""
values = []
values.extend([ prefix... | python | def fixed_values(self):
"""
A flat tuple of all values corresponding to `scipy_data_fitting.Fit.fixed_parameters`
and `scipy_data_fitting.Fit.constants` after applying any prefixes.
The values mimic the order of those lists.
"""
values = []
values.extend([ prefix... | [
"def",
"fixed_values",
"(",
"self",
")",
":",
"values",
"=",
"[",
"]",
"values",
".",
"extend",
"(",
"[",
"prefix_factor",
"(",
"param",
")",
"*",
"param",
"[",
"'value'",
"]",
"for",
"param",
"in",
"self",
".",
"fixed_parameters",
"]",
")",
"values",
... | A flat tuple of all values corresponding to `scipy_data_fitting.Fit.fixed_parameters`
and `scipy_data_fitting.Fit.constants` after applying any prefixes.
The values mimic the order of those lists. | [
"A",
"flat",
"tuple",
"of",
"all",
"values",
"corresponding",
"to",
"scipy_data_fitting",
".",
"Fit",
".",
"fixed_parameters",
"and",
"scipy_data_fitting",
".",
"Fit",
".",
"constants",
"after",
"applying",
"any",
"prefixes",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L510-L521 |
52,961 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.function | def function(self):
"""
The function passed to the `fit_function` specified in `scipy_data_fitting.Fit.options`,
and used by `scipy_data_fitting.Fit.pointspace` to generate plots, etc.
Its number of arguments and their order is determined by items 1, 2, and 3
as listed in `scipy... | python | def function(self):
"""
The function passed to the `fit_function` specified in `scipy_data_fitting.Fit.options`,
and used by `scipy_data_fitting.Fit.pointspace` to generate plots, etc.
Its number of arguments and their order is determined by items 1, 2, and 3
as listed in `scipy... | [
"def",
"function",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_function'",
")",
":",
"function",
"=",
"self",
".",
"model",
".",
"lambdify",
"(",
"self",
".",
"expression",
",",
"self",
".",
"all_variables",
",",
"*",
"*",
"se... | The function passed to the `fit_function` specified in `scipy_data_fitting.Fit.options`,
and used by `scipy_data_fitting.Fit.pointspace` to generate plots, etc.
Its number of arguments and their order is determined by items 1, 2, and 3
as listed in `scipy_data_fitting.Fit.all_variables`.
... | [
"The",
"function",
"passed",
"to",
"the",
"fit_function",
"specified",
"in",
"scipy_data_fitting",
".",
"Fit",
".",
"options",
"and",
"used",
"by",
"scipy_data_fitting",
".",
"Fit",
".",
"pointspace",
"to",
"generate",
"plots",
"etc",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L524-L542 |
52,962 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.curve_fit | def curve_fit(self):
"""
Fits `scipy_data_fitting.Fit.function` to the data and returns
the output from the specified curve fit function.
See `scipy_data_fitting.Fit.options` for details on how to control
or override the the curve fitting algorithm.
"""
if not ha... | python | def curve_fit(self):
"""
Fits `scipy_data_fitting.Fit.function` to the data and returns
the output from the specified curve fit function.
See `scipy_data_fitting.Fit.options` for details on how to control
or override the the curve fitting algorithm.
"""
if not ha... | [
"def",
"curve_fit",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_curve_fit'",
")",
":",
"options",
"=",
"self",
".",
"options",
".",
"copy",
"(",
")",
"fit_function",
"=",
"options",
".",
"pop",
"(",
"'fit_function'",
")",
"indep... | Fits `scipy_data_fitting.Fit.function` to the data and returns
the output from the specified curve fit function.
See `scipy_data_fitting.Fit.options` for details on how to control
or override the the curve fitting algorithm. | [
"Fits",
"scipy_data_fitting",
".",
"Fit",
".",
"function",
"to",
"the",
"data",
"and",
"returns",
"the",
"output",
"from",
"the",
"specified",
"curve",
"fit",
"function",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L609-L632 |
52,963 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.fitted_parameters | def fitted_parameters(self):
"""
A tuple of fitted values for the `scipy_data_fitting.Fit.fitting_parameters`.
The values in this tuple are not scaled by the prefix,
as they are passed back to `scipy_data_fitting.Fit.function`,
e.g. in most standard use cases these would be the ... | python | def fitted_parameters(self):
"""
A tuple of fitted values for the `scipy_data_fitting.Fit.fitting_parameters`.
The values in this tuple are not scaled by the prefix,
as they are passed back to `scipy_data_fitting.Fit.function`,
e.g. in most standard use cases these would be the ... | [
"def",
"fitted_parameters",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_fitted_parameters'",
")",
":",
"return",
"self",
".",
"_fitted_parameters",
"if",
"not",
"self",
".",
"fitting_parameters",
":",
"return",
"tuple",
"(",
")",
"if",
"self... | A tuple of fitted values for the `scipy_data_fitting.Fit.fitting_parameters`.
The values in this tuple are not scaled by the prefix,
as they are passed back to `scipy_data_fitting.Fit.function`,
e.g. in most standard use cases these would be the SI values.
If no fitting parameters were... | [
"A",
"tuple",
"of",
"fitted",
"values",
"for",
"the",
"scipy_data_fitting",
".",
"Fit",
".",
"fitting_parameters",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L635-L650 |
52,964 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.fitted_function | def fitted_function(self):
"""
A function of the single independent variable after
partially evaluating `scipy_data_fitting.Fit.function` at
the `scipy_data_fitting.Fit.fitted_parameters`.
"""
function = self.function
fitted_parameters = self.fitted_parameters
... | python | def fitted_function(self):
"""
A function of the single independent variable after
partially evaluating `scipy_data_fitting.Fit.function` at
the `scipy_data_fitting.Fit.fitted_parameters`.
"""
function = self.function
fitted_parameters = self.fitted_parameters
... | [
"def",
"fitted_function",
"(",
"self",
")",
":",
"function",
"=",
"self",
".",
"function",
"fitted_parameters",
"=",
"self",
".",
"fitted_parameters",
"return",
"lambda",
"x",
":",
"function",
"(",
"x",
",",
"*",
"fitted_parameters",
")"
] | A function of the single independent variable after
partially evaluating `scipy_data_fitting.Fit.function` at
the `scipy_data_fitting.Fit.fitted_parameters`. | [
"A",
"function",
"of",
"the",
"single",
"independent",
"variable",
"after",
"partially",
"evaluating",
"scipy_data_fitting",
".",
"Fit",
".",
"function",
"at",
"the",
"scipy_data_fitting",
".",
"Fit",
".",
"fitted_parameters",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L653-L661 |
52,965 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.computed_fitting_parameters | def computed_fitting_parameters(self):
"""
A list identical to what is set with `scipy_data_fitting.Fit.fitting_parameters`,
but in each dictionary, the key `value` is added with the fitted value of the quantity.
The reported value is scaled by the inverse prefix.
"""
fit... | python | def computed_fitting_parameters(self):
"""
A list identical to what is set with `scipy_data_fitting.Fit.fitting_parameters`,
but in each dictionary, the key `value` is added with the fitted value of the quantity.
The reported value is scaled by the inverse prefix.
"""
fit... | [
"def",
"computed_fitting_parameters",
"(",
"self",
")",
":",
"fitted_parameters",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"v",
")",
"in",
"enumerate",
"(",
"self",
".",
"fitting_parameters",
")",
":",
"param",
"=",
"v",
".",
"copy",
"(",
")",
"param",
"["... | A list identical to what is set with `scipy_data_fitting.Fit.fitting_parameters`,
but in each dictionary, the key `value` is added with the fitted value of the quantity.
The reported value is scaled by the inverse prefix. | [
"A",
"list",
"identical",
"to",
"what",
"is",
"set",
"with",
"scipy_data_fitting",
".",
"Fit",
".",
"fitting_parameters",
"but",
"in",
"each",
"dictionary",
"the",
"key",
"value",
"is",
"added",
"with",
"the",
"fitted",
"value",
"of",
"the",
"quantity",
".",... | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L704-L716 |
52,966 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.pointspace | def pointspace(self, **kwargs):
"""
Returns a dictionary with the keys `data` and `fit`.
`data` is just `scipy_data_fitting.Data.array`.
`fit` is a two row [`numpy.ndarray`][1], the first row values correspond
to the independent variable and are generated using [`numpy.linspace... | python | def pointspace(self, **kwargs):
"""
Returns a dictionary with the keys `data` and `fit`.
`data` is just `scipy_data_fitting.Data.array`.
`fit` is a two row [`numpy.ndarray`][1], the first row values correspond
to the independent variable and are generated using [`numpy.linspace... | [
"def",
"pointspace",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"scale_array",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"prefix_factor",
"(",
"self",
".",
"independent",
")",
"**",
"(",
"-",
"1",
")",
"]",
",",
"[",
"prefix_factor",
"(",
"se... | Returns a dictionary with the keys `data` and `fit`.
`data` is just `scipy_data_fitting.Data.array`.
`fit` is a two row [`numpy.ndarray`][1], the first row values correspond
to the independent variable and are generated using [`numpy.linspace`][2].
The second row are the values of `sci... | [
"Returns",
"a",
"dictionary",
"with",
"the",
"keys",
"data",
"and",
"fit",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L744-L773 |
52,967 | razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | Fit.to_json | def to_json(self, path, points=50, meta=None):
"""
Write the results of the fit to a json file at `path`.
`points` will define the length of the `fit` array.
If `meta` is given, a `meta` key be added with the given value.
The json object has the form
#!text
... | python | def to_json(self, path, points=50, meta=None):
"""
Write the results of the fit to a json file at `path`.
`points` will define the length of the `fit` array.
If `meta` is given, a `meta` key be added with the given value.
The json object has the form
#!text
... | [
"def",
"to_json",
"(",
"self",
",",
"path",
",",
"points",
"=",
"50",
",",
"meta",
"=",
"None",
")",
":",
"pointspace",
"=",
"self",
".",
"pointspace",
"(",
"num",
"=",
"points",
")",
"fit_points",
"=",
"numpy",
".",
"dstack",
"(",
"pointspace",
"[",... | Write the results of the fit to a json file at `path`.
`points` will define the length of the `fit` array.
If `meta` is given, a `meta` key be added with the given value.
The json object has the form
#!text
{
'data': [ [x1, y1], [x2, y2], ... ],
... | [
"Write",
"the",
"results",
"of",
"the",
"fit",
"to",
"a",
"json",
"file",
"at",
"path",
"."
] | c756a645da8629699b3f22244bfb7d5d4d88b179 | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L775-L804 |
52,968 | krischer/pyflex | doc/convert.py | clean_for_doc | def clean_for_doc(nb):
"""
Cleans the notebook to be suitable for inclusion in the docs.
"""
new_cells = []
for cell in nb.worksheets[0].cells:
# Remove the pylab inline line.
if "input" in cell and cell["input"].strip() == "%pylab inline":
continue
# Remove outpu... | python | def clean_for_doc(nb):
"""
Cleans the notebook to be suitable for inclusion in the docs.
"""
new_cells = []
for cell in nb.worksheets[0].cells:
# Remove the pylab inline line.
if "input" in cell and cell["input"].strip() == "%pylab inline":
continue
# Remove outpu... | [
"def",
"clean_for_doc",
"(",
"nb",
")",
":",
"new_cells",
"=",
"[",
"]",
"for",
"cell",
"in",
"nb",
".",
"worksheets",
"[",
"0",
"]",
".",
"cells",
":",
"# Remove the pylab inline line.",
"if",
"\"input\"",
"in",
"cell",
"and",
"cell",
"[",
"\"input\"",
... | Cleans the notebook to be suitable for inclusion in the docs. | [
"Cleans",
"the",
"notebook",
"to",
"be",
"suitable",
"for",
"inclusion",
"in",
"the",
"docs",
"."
] | e1a988793ba79cc3b31051ba3df5b3a23bc769c4 | https://github.com/krischer/pyflex/blob/e1a988793ba79cc3b31051ba3df5b3a23bc769c4/doc/convert.py#L12-L28 |
52,969 | girish946/plot-cat | plotcat/plotcat.py | plotter.set_call_back | def set_call_back(self, func):
"""sets callback function for updating the plot.
in the callback function implement the logic of reading of serial input
also the further processing of the signal if necessary has to be done
in this
callbak function."""
self.timer.add_call... | python | def set_call_back(self, func):
"""sets callback function for updating the plot.
in the callback function implement the logic of reading of serial input
also the further processing of the signal if necessary has to be done
in this
callbak function."""
self.timer.add_call... | [
"def",
"set_call_back",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"timer",
".",
"add_callback",
"(",
"func",
")",
"self",
".",
"timer",
".",
"start",
"(",
")"
] | sets callback function for updating the plot.
in the callback function implement the logic of reading of serial input
also the further processing of the signal if necessary has to be done
in this
callbak function. | [
"sets",
"callback",
"function",
"for",
"updating",
"the",
"plot",
".",
"in",
"the",
"callback",
"function",
"implement",
"the",
"logic",
"of",
"reading",
"of",
"serial",
"input",
"also",
"the",
"further",
"processing",
"of",
"the",
"signal",
"if",
"necessary",... | 033ed32972273eb6a4f98a58805b2cb87b97ccdb | https://github.com/girish946/plot-cat/blob/033ed32972273eb6a4f98a58805b2cb87b97ccdb/plotcat/plotcat.py#L119-L128 |
52,970 | girish946/plot-cat | plotcat/plotcat.py | plotter.plot_self | def plot_self(self, func):
"""define your callback function with the decorator @plotter.plot_self.
in the callback function set the data of lines
in the plot using self.lines[i][j].set_data(your data)"""
def func_wrapper():
func()
try:
self.ma... | python | def plot_self(self, func):
"""define your callback function with the decorator @plotter.plot_self.
in the callback function set the data of lines
in the plot using self.lines[i][j].set_data(your data)"""
def func_wrapper():
func()
try:
self.ma... | [
"def",
"plot_self",
"(",
"self",
",",
"func",
")",
":",
"def",
"func_wrapper",
"(",
")",
":",
"func",
"(",
")",
"try",
":",
"self",
".",
"manager",
".",
"canvas",
".",
"draw",
"(",
")",
"except",
"ValueError",
"as",
"ve",
":",
"print",
"(",
"ve",
... | define your callback function with the decorator @plotter.plot_self.
in the callback function set the data of lines
in the plot using self.lines[i][j].set_data(your data) | [
"define",
"your",
"callback",
"function",
"with",
"the",
"decorator"
] | 033ed32972273eb6a4f98a58805b2cb87b97ccdb | https://github.com/girish946/plot-cat/blob/033ed32972273eb6a4f98a58805b2cb87b97ccdb/plotcat/plotcat.py#L130-L156 |
52,971 | mattrobenolt/ec2 | ec2/base.py | objects_base.filter | def filter(cls, **kwargs):
"""
The meat. Filtering using Django model style syntax.
All kwargs are translated into attributes on the underlying objects.
If the attribute is not found, it looks for a similar key
in the tags.
There are a couple comparisons to check agains... | python | def filter(cls, **kwargs):
"""
The meat. Filtering using Django model style syntax.
All kwargs are translated into attributes on the underlying objects.
If the attribute is not found, it looks for a similar key
in the tags.
There are a couple comparisons to check agains... | [
"def",
"filter",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"qs",
"=",
"cls",
".",
"all",
"(",
")",
"for",
"key",
"in",
"kwargs",
":",
"qs",
"=",
"filter",
"(",
"lambda",
"i",
":",
"make_compare",
"(",
"key",
",",
"kwargs",
"[",
"key",
"]",... | The meat. Filtering using Django model style syntax.
All kwargs are translated into attributes on the underlying objects.
If the attribute is not found, it looks for a similar key
in the tags.
There are a couple comparisons to check against as well:
exact: check strict equa... | [
"The",
"meat",
".",
"Filtering",
"using",
"Django",
"model",
"style",
"syntax",
"."
] | fc1f8bce6cf76899165d9ac006371181d52439f8 | https://github.com/mattrobenolt/ec2/blob/fc1f8bce6cf76899165d9ac006371181d52439f8/ec2/base.py#L57-L84 |
52,972 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.reconnect_redis | def reconnect_redis(self):
'''Reconnect to redis.
:return: Redis client instance
:rettype: redis.Redis
'''
if self.shared_client and Storage.storage:
return Storage.storage
storage = Redis(
port=self.context.config.REDIS_RESULT_STORAGE_SERVER_PO... | python | def reconnect_redis(self):
'''Reconnect to redis.
:return: Redis client instance
:rettype: redis.Redis
'''
if self.shared_client and Storage.storage:
return Storage.storage
storage = Redis(
port=self.context.config.REDIS_RESULT_STORAGE_SERVER_PO... | [
"def",
"reconnect_redis",
"(",
"self",
")",
":",
"if",
"self",
".",
"shared_client",
"and",
"Storage",
".",
"storage",
":",
"return",
"Storage",
".",
"storage",
"storage",
"=",
"Redis",
"(",
"port",
"=",
"self",
".",
"context",
".",
"config",
".",
"REDIS... | Reconnect to redis.
:return: Redis client instance
:rettype: redis.Redis | [
"Reconnect",
"to",
"redis",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L51-L70 |
52,973 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.get_key_from_request | def get_key_from_request(self):
'''Return a key for the current request url.
:return: The storage key for the current url
:rettype: string
'''
path = "result:%s" % self.context.request.url
if self.is_auto_webp():
path += '/webp'
return path | python | def get_key_from_request(self):
'''Return a key for the current request url.
:return: The storage key for the current url
:rettype: string
'''
path = "result:%s" % self.context.request.url
if self.is_auto_webp():
path += '/webp'
return path | [
"def",
"get_key_from_request",
"(",
"self",
")",
":",
"path",
"=",
"\"result:%s\"",
"%",
"self",
".",
"context",
".",
"request",
".",
"url",
"if",
"self",
".",
"is_auto_webp",
"(",
")",
":",
"path",
"+=",
"'/webp'",
"return",
"path"
] | Return a key for the current request url.
:return: The storage key for the current url
:rettype: string | [
"Return",
"a",
"key",
"for",
"the",
"current",
"request",
"url",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L106-L118 |
52,974 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.get_max_age | def get_max_age(self):
'''Return the TTL of the current request.
:returns: The TTL value for the current request.
:rtype: int
'''
default_ttl = self.context.config.RESULT_STORAGE_EXPIRATION_SECONDS
if self.context.request.max_age == 0:
return self.context.re... | python | def get_max_age(self):
'''Return the TTL of the current request.
:returns: The TTL value for the current request.
:rtype: int
'''
default_ttl = self.context.config.RESULT_STORAGE_EXPIRATION_SECONDS
if self.context.request.max_age == 0:
return self.context.re... | [
"def",
"get_max_age",
"(",
"self",
")",
":",
"default_ttl",
"=",
"self",
".",
"context",
".",
"config",
".",
"RESULT_STORAGE_EXPIRATION_SECONDS",
"if",
"self",
".",
"context",
".",
"request",
".",
"max_age",
"==",
"0",
":",
"return",
"self",
".",
"context",
... | Return the TTL of the current request.
:returns: The TTL value for the current request.
:rtype: int | [
"Return",
"the",
"TTL",
"of",
"the",
"current",
"request",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L120-L131 |
52,975 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.put | def put(self, bytes):
'''Save to redis
:param bytes: Bytes to write to the storage.
:return: Redis key for the current url
:rettype: string
'''
key = self.get_key_from_request()
result_ttl = self.get_max_age()
logger.debug(
"[REDIS_RESULT_ST... | python | def put(self, bytes):
'''Save to redis
:param bytes: Bytes to write to the storage.
:return: Redis key for the current url
:rettype: string
'''
key = self.get_key_from_request()
result_ttl = self.get_max_age()
logger.debug(
"[REDIS_RESULT_ST... | [
"def",
"put",
"(",
"self",
",",
"bytes",
")",
":",
"key",
"=",
"self",
".",
"get_key_from_request",
"(",
")",
"result_ttl",
"=",
"self",
".",
"get_max_age",
"(",
")",
"logger",
".",
"debug",
"(",
"\"[REDIS_RESULT_STORAGE] putting `{key}` with ttl `{ttl}`\"",
"."... | Save to redis
:param bytes: Bytes to write to the storage.
:return: Redis key for the current url
:rettype: string | [
"Save",
"to",
"redis"
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L134-L163 |
52,976 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.get | def get(self):
'''Get the item from redis.'''
key = self.get_key_from_request()
result = self.get_storage().get(key)
return result if result else None | python | def get(self):
'''Get the item from redis.'''
key = self.get_key_from_request()
result = self.get_storage().get(key)
return result if result else None | [
"def",
"get",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"get_key_from_request",
"(",
")",
"result",
"=",
"self",
".",
"get_storage",
"(",
")",
".",
"get",
"(",
"key",
")",
"return",
"result",
"if",
"result",
"else",
"None"
] | Get the item from redis. | [
"Get",
"the",
"item",
"from",
"redis",
"."
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L166-L172 |
52,977 | thumbor-community/redis | tc_redis/result_storages/redis_result_storage.py | Storage.last_updated | def last_updated(self):
'''Return the last_updated time of the current request item
:return: A DateTime object
:rettype: datetetime.datetime
'''
key = self.get_key_from_request()
max_age = self.get_max_age()
if max_age == 0:
return datetime.fromtime... | python | def last_updated(self):
'''Return the last_updated time of the current request item
:return: A DateTime object
:rettype: datetetime.datetime
'''
key = self.get_key_from_request()
max_age = self.get_max_age()
if max_age == 0:
return datetime.fromtime... | [
"def",
"last_updated",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"get_key_from_request",
"(",
")",
"max_age",
"=",
"self",
".",
"get_max_age",
"(",
")",
"if",
"max_age",
"==",
"0",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"Storage",
".... | Return the last_updated time of the current request item
:return: A DateTime object
:rettype: datetetime.datetime | [
"Return",
"the",
"last_updated",
"time",
"of",
"the",
"current",
"request",
"item"
] | e434c151b2d32b2209ce9935493258ee29fb1d1d | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/result_storages/redis_result_storage.py#L175-L203 |
52,978 | sacrud/sacrud | sacrud/preprocessing.py | list_of_lists_to_dict | def list_of_lists_to_dict(l):
""" Convert list of key,value lists to dict
[['id', 1], ['id', 2], ['id', 3], ['foo': 4]]
{'id': [1, 2, 3], 'foo': [4]}
"""
d = {}
for key, val in l:
d.setdefault(key, []).append(val)
return d | python | def list_of_lists_to_dict(l):
""" Convert list of key,value lists to dict
[['id', 1], ['id', 2], ['id', 3], ['foo': 4]]
{'id': [1, 2, 3], 'foo': [4]}
"""
d = {}
for key, val in l:
d.setdefault(key, []).append(val)
return d | [
"def",
"list_of_lists_to_dict",
"(",
"l",
")",
":",
"d",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"l",
":",
"d",
".",
"setdefault",
"(",
"key",
",",
"[",
"]",
")",
".",
"append",
"(",
"val",
")",
"return",
"d"
] | Convert list of key,value lists to dict
[['id', 1], ['id', 2], ['id', 3], ['foo': 4]]
{'id': [1, 2, 3], 'foo': [4]} | [
"Convert",
"list",
"of",
"key",
"value",
"lists",
"to",
"dict"
] | 40dcbb22083cb1ad4c1f626843397b89c2ce18f5 | https://github.com/sacrud/sacrud/blob/40dcbb22083cb1ad4c1f626843397b89c2ce18f5/sacrud/preprocessing.py#L23-L32 |
52,979 | tonyseek/python-base36 | base36.py | dumps | def dumps(number):
"""Dumps an integer into a base36 string.
:param number: the 10-based integer.
:returns: the base36 string.
"""
if not isinstance(number, integer_types):
raise TypeError('number must be an integer')
if number < 0:
return '-' + dumps(-number)
value = ''
... | python | def dumps(number):
"""Dumps an integer into a base36 string.
:param number: the 10-based integer.
:returns: the base36 string.
"""
if not isinstance(number, integer_types):
raise TypeError('number must be an integer')
if number < 0:
return '-' + dumps(-number)
value = ''
... | [
"def",
"dumps",
"(",
"number",
")",
":",
"if",
"not",
"isinstance",
"(",
"number",
",",
"integer_types",
")",
":",
"raise",
"TypeError",
"(",
"'number must be an integer'",
")",
"if",
"number",
"<",
"0",
":",
"return",
"'-'",
"+",
"dumps",
"(",
"-",
"num... | Dumps an integer into a base36 string.
:param number: the 10-based integer.
:returns: the base36 string. | [
"Dumps",
"an",
"integer",
"into",
"a",
"base36",
"string",
"."
] | 4650988d9730e5cf9ca4a8fd634556f03c6d1c58 | https://github.com/tonyseek/python-base36/blob/4650988d9730e5cf9ca4a8fd634556f03c6d1c58/base36.py#L17-L35 |
52,980 | gnarlychicken/aiohttp_auth | aiohttp_auth/acl/acl.py | acl_middleware | def acl_middleware(callback):
"""Returns a aiohttp_auth.acl middleware factory for use by the aiohttp
application object.
Args:
callback: This is a callable which takes a user_id (as returned from
the auth.get_auth function), and expects a sequence of permitted ACL
groups to... | python | def acl_middleware(callback):
"""Returns a aiohttp_auth.acl middleware factory for use by the aiohttp
application object.
Args:
callback: This is a callable which takes a user_id (as returned from
the auth.get_auth function), and expects a sequence of permitted ACL
groups to... | [
"def",
"acl_middleware",
"(",
"callback",
")",
":",
"async",
"def",
"_acl_middleware_factory",
"(",
"app",
",",
"handler",
")",
":",
"async",
"def",
"_middleware_handler",
"(",
"request",
")",
":",
"# Save the policy in the request",
"request",
"[",
"GROUPS_KEY",
... | Returns a aiohttp_auth.acl middleware factory for use by the aiohttp
application object.
Args:
callback: This is a callable which takes a user_id (as returned from
the auth.get_auth function), and expects a sequence of permitted ACL
groups to be returned. This can be a empty tup... | [
"Returns",
"a",
"aiohttp_auth",
".",
"acl",
"middleware",
"factory",
"for",
"use",
"by",
"the",
"aiohttp",
"application",
"object",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/acl/acl.py#L10-L36 |
52,981 | gnarlychicken/aiohttp_auth | aiohttp_auth/acl/acl.py | get_user_groups | async def get_user_groups(request):
"""Returns the groups that the user in this request has access to.
This function gets the user id from the auth.get_auth function, and passes
it to the ACL callback function to get the groups.
Args:
request: aiohttp Request object
Returns:
If th... | python | async def get_user_groups(request):
"""Returns the groups that the user in this request has access to.
This function gets the user id from the auth.get_auth function, and passes
it to the ACL callback function to get the groups.
Args:
request: aiohttp Request object
Returns:
If th... | [
"async",
"def",
"get_user_groups",
"(",
"request",
")",
":",
"acl_callback",
"=",
"request",
".",
"get",
"(",
"GROUPS_KEY",
")",
"if",
"acl_callback",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'acl_middleware not installed'",
")",
"user_id",
"=",
"await"... | Returns the groups that the user in this request has access to.
This function gets the user id from the auth.get_auth function, and passes
it to the ACL callback function to get the groups.
Args:
request: aiohttp Request object
Returns:
If the ACL callback function returns None, this ... | [
"Returns",
"the",
"groups",
"that",
"the",
"user",
"in",
"this",
"request",
"has",
"access",
"to",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/acl/acl.py#L39-L69 |
52,982 | gnarlychicken/aiohttp_auth | aiohttp_auth/acl/acl.py | get_permitted | async def get_permitted(request, permission, context):
"""Returns true if the one of the groups in the request has the requested
permission.
The function takes a request, a permission to check for and a context. A
context is a sequence of ACL tuples which consist of a Allow/Deny action,
a group, an... | python | async def get_permitted(request, permission, context):
"""Returns true if the one of the groups in the request has the requested
permission.
The function takes a request, a permission to check for and a context. A
context is a sequence of ACL tuples which consist of a Allow/Deny action,
a group, an... | [
"async",
"def",
"get_permitted",
"(",
"request",
",",
"permission",
",",
"context",
")",
":",
"groups",
"=",
"await",
"get_user_groups",
"(",
"request",
")",
"if",
"groups",
"is",
"None",
":",
"return",
"False",
"for",
"action",
",",
"group",
",",
"permiss... | Returns true if the one of the groups in the request has the requested
permission.
The function takes a request, a permission to check for and a context. A
context is a sequence of ACL tuples which consist of a Allow/Deny action,
a group, and a sequence of permissions for that ACL group. For example::
... | [
"Returns",
"true",
"if",
"the",
"one",
"of",
"the",
"groups",
"in",
"the",
"request",
"has",
"the",
"requested",
"permission",
"."
] | 3d55236889fb14b662279b050de18d43842bb886 | https://github.com/gnarlychicken/aiohttp_auth/blob/3d55236889fb14b662279b050de18d43842bb886/aiohttp_auth/acl/acl.py#L72-L114 |
52,983 | marcinmiklitz/pywindow | pywindow/utilities.py | molecular_weight | def molecular_weight(elements):
"""
Return molecular weight of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
Returns
-------
numpy.float64
A molecular weight of a molecule.
"""
return (np.array([a... | python | def molecular_weight(elements):
"""
Return molecular weight of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
Returns
-------
numpy.float64
A molecular weight of a molecule.
"""
return (np.array([a... | [
"def",
"molecular_weight",
"(",
"elements",
")",
":",
"return",
"(",
"np",
".",
"array",
"(",
"[",
"atomic_mass",
"[",
"i",
".",
"upper",
"(",
")",
"]",
"for",
"i",
"in",
"elements",
"]",
")",
".",
"sum",
"(",
")",
")"
] | Return molecular weight of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
Returns
-------
numpy.float64
A molecular weight of a molecule. | [
"Return",
"molecular",
"weight",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L141-L156 |
52,984 | marcinmiklitz/pywindow | pywindow/utilities.py | dlf_notation | def dlf_notation(atom_key):
"""Return element for atom key using DL_F notation."""
split = list(atom_key)
element = ''
number = False
count = 0
while number is False:
element = "".join((element, split[count]))
count += 1
if is_number(split[count]) is True:
num... | python | def dlf_notation(atom_key):
"""Return element for atom key using DL_F notation."""
split = list(atom_key)
element = ''
number = False
count = 0
while number is False:
element = "".join((element, split[count]))
count += 1
if is_number(split[count]) is True:
num... | [
"def",
"dlf_notation",
"(",
"atom_key",
")",
":",
"split",
"=",
"list",
"(",
"atom_key",
")",
"element",
"=",
"''",
"number",
"=",
"False",
"count",
"=",
"0",
"while",
"number",
"is",
"False",
":",
"element",
"=",
"\"\"",
".",
"join",
"(",
"(",
"elem... | Return element for atom key using DL_F notation. | [
"Return",
"element",
"for",
"atom",
"key",
"using",
"DL_F",
"notation",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L316-L335 |
52,985 | marcinmiklitz/pywindow | pywindow/utilities.py | opls_notation | def opls_notation(atom_key):
"""Return element for OPLS forcefield atom key."""
# warning for Ne, He, Na types overlap
conflicts = ['ne', 'he', 'na']
if atom_key in conflicts:
raise _AtomKeyConflict((
"One of the OPLS conflicting "
"atom_keys has occured '{0}'. "
... | python | def opls_notation(atom_key):
"""Return element for OPLS forcefield atom key."""
# warning for Ne, He, Na types overlap
conflicts = ['ne', 'he', 'na']
if atom_key in conflicts:
raise _AtomKeyConflict((
"One of the OPLS conflicting "
"atom_keys has occured '{0}'. "
... | [
"def",
"opls_notation",
"(",
"atom_key",
")",
":",
"# warning for Ne, He, Na types overlap",
"conflicts",
"=",
"[",
"'ne'",
",",
"'he'",
",",
"'na'",
"]",
"if",
"atom_key",
"in",
"conflicts",
":",
"raise",
"_AtomKeyConflict",
"(",
"(",
"\"One of the OPLS conflicting... | Return element for OPLS forcefield atom key. | [
"Return",
"element",
"for",
"OPLS",
"forcefield",
"atom",
"key",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L338-L354 |
52,986 | marcinmiklitz/pywindow | pywindow/utilities.py | decipher_atom_key | def decipher_atom_key(atom_key, forcefield):
"""
Return element for deciphered atom key.
This functions checks if the forcfield specified by user is supported
and passes the atom key to the appropriate function for deciphering.
Parameters
----------
atom_key : str
The atom key whic... | python | def decipher_atom_key(atom_key, forcefield):
"""
Return element for deciphered atom key.
This functions checks if the forcfield specified by user is supported
and passes the atom key to the appropriate function for deciphering.
Parameters
----------
atom_key : str
The atom key whic... | [
"def",
"decipher_atom_key",
"(",
"atom_key",
",",
"forcefield",
")",
":",
"load_funcs",
"=",
"{",
"'DLF'",
":",
"dlf_notation",
",",
"'DL_F'",
":",
"dlf_notation",
",",
"'OPLS'",
":",
"opls_notation",
",",
"'OPLSAA'",
":",
"opls_notation",
",",
"'OPLS2005'",
"... | Return element for deciphered atom key.
This functions checks if the forcfield specified by user is supported
and passes the atom key to the appropriate function for deciphering.
Parameters
----------
atom_key : str
The atom key which is to be deciphered.
forcefield : str
The ... | [
"Return",
"element",
"for",
"deciphered",
"atom",
"key",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L357-L394 |
52,987 | marcinmiklitz/pywindow | pywindow/utilities.py | shift_com | def shift_com(elements, coordinates, com_adjust=np.zeros(3)):
"""
Return coordinates translated by some vector.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordina... | python | def shift_com(elements, coordinates, com_adjust=np.zeros(3)):
"""
Return coordinates translated by some vector.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordina... | [
"def",
"shift_com",
"(",
"elements",
",",
"coordinates",
",",
"com_adjust",
"=",
"np",
".",
"zeros",
"(",
"3",
")",
")",
":",
"com",
"=",
"center_of_mass",
"(",
"elements",
",",
"coordinates",
")",
"com",
"=",
"np",
".",
"array",
"(",
"[",
"com",
"-"... | Return coordinates translated by some vector.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordinates.
com_adjust : numpy.ndarray (default = [0, 0, 0])
Returns
... | [
"Return",
"coordinates",
"translated",
"by",
"some",
"vector",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L397-L419 |
52,988 | marcinmiklitz/pywindow | pywindow/utilities.py | max_dim | def max_dim(elements, coordinates):
"""
Return the maximum diameter of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordinates.
Returns
-------... | python | def max_dim(elements, coordinates):
"""
Return the maximum diameter of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordinates.
Returns
-------... | [
"def",
"max_dim",
"(",
"elements",
",",
"coordinates",
")",
":",
"atom_vdw_vertical",
"=",
"np",
".",
"matrix",
"(",
"[",
"[",
"atomic_vdw_radius",
"[",
"i",
".",
"upper",
"(",
")",
"]",
"]",
"for",
"i",
"in",
"elements",
"]",
")",
"atom_vdw_horizontal",... | Return the maximum diameter of a molecule.
Parameters
----------
elements : numpy.ndarray
An array of all elements (type: str) in a molecule.
coordinates : numpy.ndarray
An array containing molecule's coordinates.
Returns
------- | [
"Return",
"the",
"maximum",
"diameter",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L422-L448 |
52,989 | marcinmiklitz/pywindow | pywindow/utilities.py | pore_diameter | def pore_diameter(elements, coordinates, com=None):
"""Return pore diameter of a molecule."""
if com is None:
com = center_of_mass(elements, coordinates)
atom_vdw = np.array([[atomic_vdw_radius[x.upper()]] for x in elements])
dist_matrix = euclidean_distances(coordinates, com.reshape(1, -1))
... | python | def pore_diameter(elements, coordinates, com=None):
"""Return pore diameter of a molecule."""
if com is None:
com = center_of_mass(elements, coordinates)
atom_vdw = np.array([[atomic_vdw_radius[x.upper()]] for x in elements])
dist_matrix = euclidean_distances(coordinates, com.reshape(1, -1))
... | [
"def",
"pore_diameter",
"(",
"elements",
",",
"coordinates",
",",
"com",
"=",
"None",
")",
":",
"if",
"com",
"is",
"None",
":",
"com",
"=",
"center_of_mass",
"(",
"elements",
",",
"coordinates",
")",
"atom_vdw",
"=",
"np",
".",
"array",
"(",
"[",
"[",
... | Return pore diameter of a molecule. | [
"Return",
"pore",
"diameter",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L451-L460 |
52,990 | marcinmiklitz/pywindow | pywindow/utilities.py | opt_pore_diameter | def opt_pore_diameter(elements, coordinates, bounds=None, com=None, **kwargs):
"""Return optimised pore diameter and it's COM."""
args = elements, coordinates
if com is not None:
pass
else:
com = center_of_mass(elements, coordinates)
if bounds is None:
pore_r = pore_diameter(... | python | def opt_pore_diameter(elements, coordinates, bounds=None, com=None, **kwargs):
"""Return optimised pore diameter and it's COM."""
args = elements, coordinates
if com is not None:
pass
else:
com = center_of_mass(elements, coordinates)
if bounds is None:
pore_r = pore_diameter(... | [
"def",
"opt_pore_diameter",
"(",
"elements",
",",
"coordinates",
",",
"bounds",
"=",
"None",
",",
"com",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"elements",
",",
"coordinates",
"if",
"com",
"is",
"not",
"None",
":",
"pass",
"else",... | Return optimised pore diameter and it's COM. | [
"Return",
"optimised",
"pore",
"diameter",
"and",
"it",
"s",
"COM",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L469-L486 |
52,991 | marcinmiklitz/pywindow | pywindow/utilities.py | get_gyration_tensor | def get_gyration_tensor(elements, coordinates):
"""
Return the gyration tensor of a molecule.
The gyration tensor should be invariant to the molecule's position.
The known formulas for the gyration tensor have the correction for the
centre of mass of the molecule, therefore, the coordinates are fir... | python | def get_gyration_tensor(elements, coordinates):
"""
Return the gyration tensor of a molecule.
The gyration tensor should be invariant to the molecule's position.
The known formulas for the gyration tensor have the correction for the
centre of mass of the molecule, therefore, the coordinates are fir... | [
"def",
"get_gyration_tensor",
"(",
"elements",
",",
"coordinates",
")",
":",
"# First calculate COM for correction.",
"com",
"=",
"centre_of_mass",
"(",
"elements",
",",
"coordinates",
")",
"# Correct the coordinates for the COM.",
"coordinates",
"=",
"coordinates",
"-",
... | Return the gyration tensor of a molecule.
The gyration tensor should be invariant to the molecule's position.
The known formulas for the gyration tensor have the correction for the
centre of mass of the molecule, therefore, the coordinates are first
corrected for the centre of mass and essentially shif... | [
"Return",
"the",
"gyration",
"tensor",
"of",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L514-L548 |
52,992 | marcinmiklitz/pywindow | pywindow/utilities.py | get_inertia_tensor | def get_inertia_tensor(elements, coordinates):
"""
Return the tensor of inertia a molecule.
Parameters
----------
elements : numpy.ndarray
The array containing the molecule's elemental data.
coordinates : numpy.ndarray
The array containing the Cartesian coordinates of the mole... | python | def get_inertia_tensor(elements, coordinates):
"""
Return the tensor of inertia a molecule.
Parameters
----------
elements : numpy.ndarray
The array containing the molecule's elemental data.
coordinates : numpy.ndarray
The array containing the Cartesian coordinates of the mole... | [
"def",
"get_inertia_tensor",
"(",
"elements",
",",
"coordinates",
")",
":",
"pow2",
"=",
"coordinates",
"**",
"2",
"molecular_weight",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"atomic_mass",
"[",
"e",
".",
"upper",
"(",
")",
"]",
"]",
"for",
"e",
"in",
... | Return the tensor of inertia a molecule.
Parameters
----------
elements : numpy.ndarray
The array containing the molecule's elemental data.
coordinates : numpy.ndarray
The array containing the Cartesian coordinates of the molecule.
Returns
-------
numpy.ndarray
Th... | [
"Return",
"the",
"tensor",
"of",
"inertia",
"a",
"molecule",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L551-L583 |
52,993 | marcinmiklitz/pywindow | pywindow/utilities.py | normalize_vector | def normalize_vector(vector):
"""
Normalize a vector.
A new vector is returned, the original vector is not modified.
Parameters
----------
vector : np.array
The vector to be normalized.
Returns
-------
np.array
The normalized vector.
"""
v = np.divide(vect... | python | def normalize_vector(vector):
"""
Normalize a vector.
A new vector is returned, the original vector is not modified.
Parameters
----------
vector : np.array
The vector to be normalized.
Returns
-------
np.array
The normalized vector.
"""
v = np.divide(vect... | [
"def",
"normalize_vector",
"(",
"vector",
")",
":",
"v",
"=",
"np",
".",
"divide",
"(",
"vector",
",",
"np",
".",
"linalg",
".",
"norm",
"(",
"vector",
")",
")",
"return",
"np",
".",
"round",
"(",
"v",
",",
"decimals",
"=",
"4",
")"
] | Normalize a vector.
A new vector is returned, the original vector is not modified.
Parameters
----------
vector : np.array
The vector to be normalized.
Returns
-------
np.array
The normalized vector. | [
"Normalize",
"a",
"vector",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L590-L608 |
52,994 | marcinmiklitz/pywindow | pywindow/utilities.py | rotation_matrix_arbitrary_axis | def rotation_matrix_arbitrary_axis(angle, axis):
"""
Return a rotation matrix of `angle` radians about `axis`.
Parameters
----------
angle : int or float
The size of the rotation in radians.
axis : numpy.array
A 3 element aray which represents a vector. The vector is the
... | python | def rotation_matrix_arbitrary_axis(angle, axis):
"""
Return a rotation matrix of `angle` radians about `axis`.
Parameters
----------
angle : int or float
The size of the rotation in radians.
axis : numpy.array
A 3 element aray which represents a vector. The vector is the
... | [
"def",
"rotation_matrix_arbitrary_axis",
"(",
"angle",
",",
"axis",
")",
":",
"axis",
"=",
"normalize_vector",
"(",
"axis",
")",
"a",
"=",
"np",
".",
"cos",
"(",
"angle",
"/",
"2",
")",
"b",
",",
"c",
",",
"d",
"=",
"axis",
"*",
"np",
".",
"sin",
... | Return a rotation matrix of `angle` radians about `axis`.
Parameters
----------
angle : int or float
The size of the rotation in radians.
axis : numpy.array
A 3 element aray which represents a vector. The vector is the
axis about which the rotation is carried out.
Returns
... | [
"Return",
"a",
"rotation",
"matrix",
"of",
"angle",
"radians",
"about",
"axis",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L611-L647 |
52,995 | marcinmiklitz/pywindow | pywindow/utilities.py | unit_cell_to_lattice_array | def unit_cell_to_lattice_array(cryst):
"""Return parallelpiped unit cell lattice matrix."""
a_, b_, c_, alpha, beta, gamma = cryst
# Convert angles from degrees to radians.
r_alpha = np.deg2rad(alpha)
r_beta = np.deg2rad(beta)
r_gamma = np.deg2rad(gamma)
# Calculate unit cell volume that is ... | python | def unit_cell_to_lattice_array(cryst):
"""Return parallelpiped unit cell lattice matrix."""
a_, b_, c_, alpha, beta, gamma = cryst
# Convert angles from degrees to radians.
r_alpha = np.deg2rad(alpha)
r_beta = np.deg2rad(beta)
r_gamma = np.deg2rad(gamma)
# Calculate unit cell volume that is ... | [
"def",
"unit_cell_to_lattice_array",
"(",
"cryst",
")",
":",
"a_",
",",
"b_",
",",
"c_",
",",
"alpha",
",",
"beta",
",",
"gamma",
"=",
"cryst",
"# Convert angles from degrees to radians.",
"r_alpha",
"=",
"np",
".",
"deg2rad",
"(",
"alpha",
")",
"r_beta",
"=... | Return parallelpiped unit cell lattice matrix. | [
"Return",
"parallelpiped",
"unit",
"cell",
"lattice",
"matrix",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L693-L717 |
52,996 | marcinmiklitz/pywindow | pywindow/utilities.py | lattice_array_to_unit_cell | def lattice_array_to_unit_cell(lattice_array):
"""Return crystallographic param. from unit cell lattice matrix."""
cell_lengths = np.sqrt(np.sum(lattice_array**2, axis=0))
gamma_r = np.arccos(lattice_array[0][1] / cell_lengths[1])
beta_r = np.arccos(lattice_array[0][2] / cell_lengths[2])
alpha_r = n... | python | def lattice_array_to_unit_cell(lattice_array):
"""Return crystallographic param. from unit cell lattice matrix."""
cell_lengths = np.sqrt(np.sum(lattice_array**2, axis=0))
gamma_r = np.arccos(lattice_array[0][1] / cell_lengths[1])
beta_r = np.arccos(lattice_array[0][2] / cell_lengths[2])
alpha_r = n... | [
"def",
"lattice_array_to_unit_cell",
"(",
"lattice_array",
")",
":",
"cell_lengths",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"sum",
"(",
"lattice_array",
"**",
"2",
",",
"axis",
"=",
"0",
")",
")",
"gamma_r",
"=",
"np",
".",
"arccos",
"(",
"lattice_array... | Return crystallographic param. from unit cell lattice matrix. | [
"Return",
"crystallographic",
"param",
".",
"from",
"unit",
"cell",
"lattice",
"matrix",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L720-L732 |
52,997 | marcinmiklitz/pywindow | pywindow/utilities.py | fractional_from_cartesian | def fractional_from_cartesian(coordinate, lattice_array):
"""Return a fractional coordinate from a cartesian one."""
deorthogonalisation_M = np.matrix(np.linalg.inv(lattice_array))
fractional = deorthogonalisation_M * coordinate.reshape(-1, 1)
return np.array(fractional.reshape(1, -1)) | python | def fractional_from_cartesian(coordinate, lattice_array):
"""Return a fractional coordinate from a cartesian one."""
deorthogonalisation_M = np.matrix(np.linalg.inv(lattice_array))
fractional = deorthogonalisation_M * coordinate.reshape(-1, 1)
return np.array(fractional.reshape(1, -1)) | [
"def",
"fractional_from_cartesian",
"(",
"coordinate",
",",
"lattice_array",
")",
":",
"deorthogonalisation_M",
"=",
"np",
".",
"matrix",
"(",
"np",
".",
"linalg",
".",
"inv",
"(",
"lattice_array",
")",
")",
"fractional",
"=",
"deorthogonalisation_M",
"*",
"coor... | Return a fractional coordinate from a cartesian one. | [
"Return",
"a",
"fractional",
"coordinate",
"from",
"a",
"cartesian",
"one",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L745-L749 |
52,998 | marcinmiklitz/pywindow | pywindow/utilities.py | cartisian_from_fractional | def cartisian_from_fractional(coordinate, lattice_array):
"""Return cartesian coordinate from a fractional one."""
orthogonalisation_M = np.matrix(lattice_array)
orthogonal = orthogonalisation_M * coordinate.reshape(-1, 1)
return np.array(orthogonal.reshape(1, -1)) | python | def cartisian_from_fractional(coordinate, lattice_array):
"""Return cartesian coordinate from a fractional one."""
orthogonalisation_M = np.matrix(lattice_array)
orthogonal = orthogonalisation_M * coordinate.reshape(-1, 1)
return np.array(orthogonal.reshape(1, -1)) | [
"def",
"cartisian_from_fractional",
"(",
"coordinate",
",",
"lattice_array",
")",
":",
"orthogonalisation_M",
"=",
"np",
".",
"matrix",
"(",
"lattice_array",
")",
"orthogonal",
"=",
"orthogonalisation_M",
"*",
"coordinate",
".",
"reshape",
"(",
"-",
"1",
",",
"1... | Return cartesian coordinate from a fractional one. | [
"Return",
"cartesian",
"coordinate",
"from",
"a",
"fractional",
"one",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L752-L756 |
52,999 | marcinmiklitz/pywindow | pywindow/utilities.py | cart2frac_all | def cart2frac_all(coordinates, lattice_array):
"""Convert all cartesian coordinates to fractional."""
frac_coordinates = deepcopy(coordinates)
for coord in range(frac_coordinates.shape[0]):
frac_coordinates[coord] = fractional_from_cartesian(
frac_coordinates[coord], lattice_array)
r... | python | def cart2frac_all(coordinates, lattice_array):
"""Convert all cartesian coordinates to fractional."""
frac_coordinates = deepcopy(coordinates)
for coord in range(frac_coordinates.shape[0]):
frac_coordinates[coord] = fractional_from_cartesian(
frac_coordinates[coord], lattice_array)
r... | [
"def",
"cart2frac_all",
"(",
"coordinates",
",",
"lattice_array",
")",
":",
"frac_coordinates",
"=",
"deepcopy",
"(",
"coordinates",
")",
"for",
"coord",
"in",
"range",
"(",
"frac_coordinates",
".",
"shape",
"[",
"0",
"]",
")",
":",
"frac_coordinates",
"[",
... | Convert all cartesian coordinates to fractional. | [
"Convert",
"all",
"cartesian",
"coordinates",
"to",
"fractional",
"."
] | e5264812157224f22a691741ca2e0aefdc9bd2eb | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/utilities.py#L759-L765 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.