repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
tilde-lab/tilde
tilde/apps/perovskite_tilting/perovskite_tilting.py
Perovskite_tilting.get_tiltplanes
def get_tiltplanes(self, sequence): ''' Extract tilting planes basing on distance map ''' tilting_planes = [] distance_map = [] for i in range(1, len(sequence)): distance_map.append([ sequence[i], self.virtual_atoms.get_distance( sequence[0], sequence[i] ) ])...
python
def get_tiltplanes(self, sequence): ''' Extract tilting planes basing on distance map ''' tilting_planes = [] distance_map = [] for i in range(1, len(sequence)): distance_map.append([ sequence[i], self.virtual_atoms.get_distance( sequence[0], sequence[i] ) ])...
[ "def", "get_tiltplanes", "(", "self", ",", "sequence", ")", ":", "tilting_planes", "=", "[", "]", "distance_map", "=", "[", "]", "for", "i", "in", "range", "(", "1", ",", "len", "(", "sequence", ")", ")", ":", "distance_map", ".", "append", "(", "[",...
Extract tilting planes basing on distance map
[ "Extract", "tilting", "planes", "basing", "on", "distance", "map" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/apps/perovskite_tilting/perovskite_tilting.py#L172-L238
tilde-lab/tilde
tilde/apps/perovskite_tilting/perovskite_tilting.py
Perovskite_tilting.get_tilting
def get_tilting(self, oplane): ''' Main procedure ''' surf_atom1, surf_atom2, surf_atom3, surf_atom4 = oplane # divide surface atoms into groups by distance between them compare = [surf_atom2, surf_atom3, surf_atom4] distance_map = [] for i in range(0, 3...
python
def get_tilting(self, oplane): ''' Main procedure ''' surf_atom1, surf_atom2, surf_atom3, surf_atom4 = oplane # divide surface atoms into groups by distance between them compare = [surf_atom2, surf_atom3, surf_atom4] distance_map = [] for i in range(0, 3...
[ "def", "get_tilting", "(", "self", ",", "oplane", ")", ":", "surf_atom1", ",", "surf_atom2", ",", "surf_atom3", ",", "surf_atom4", "=", "oplane", "# divide surface atoms into groups by distance between them", "compare", "=", "[", "surf_atom2", ",", "surf_atom3", ",", ...
Main procedure
[ "Main", "procedure" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/apps/perovskite_tilting/perovskite_tilting.py#L240-L348
deployed/django-emailtemplates
emailtemplates/registry.py
HelpContext.get_help_keys
def get_help_keys(self): """ Returns dict of help_context keys (description texts used in `EmailRegistry.register()` method). """ help_keys = {} for k, v in self.help_context.items(): if isinstance(v, tuple): help_keys[k] = v[0] else: ...
python
def get_help_keys(self): """ Returns dict of help_context keys (description texts used in `EmailRegistry.register()` method). """ help_keys = {} for k, v in self.help_context.items(): if isinstance(v, tuple): help_keys[k] = v[0] else: ...
[ "def", "get_help_keys", "(", "self", ")", ":", "help_keys", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "help_context", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "tuple", ")", ":", "help_keys", "[", "k", "]", "="...
Returns dict of help_context keys (description texts used in `EmailRegistry.register()` method).
[ "Returns", "dict", "of", "help_context", "keys", "(", "description", "texts", "used", "in", "EmailRegistry", ".", "register", "()", "method", ")", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/registry.py#L24-L34
deployed/django-emailtemplates
emailtemplates/registry.py
HelpContext.get_help_values
def get_help_values(self): """ Returns dict of help_context values (example values submitted in `EmailRegistry.register()` method). """ help_values = {} for k, v in self.help_context.items(): if isinstance(v, tuple) and len(v) == 2: help_values[k] = v[...
python
def get_help_values(self): """ Returns dict of help_context values (example values submitted in `EmailRegistry.register()` method). """ help_values = {} for k, v in self.help_context.items(): if isinstance(v, tuple) and len(v) == 2: help_values[k] = v[...
[ "def", "get_help_values", "(", "self", ")", ":", "help_values", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "help_context", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "tuple", ")", "and", "len", "(", "v", ")", "==...
Returns dict of help_context values (example values submitted in `EmailRegistry.register()` method).
[ "Returns", "dict", "of", "help_context", "values", "(", "example", "values", "submitted", "in", "EmailRegistry", ".", "register", "()", "method", ")", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/registry.py#L36-L46
deployed/django-emailtemplates
emailtemplates/registry.py
EmailTemplateRegistry.register
def register(self, path, help_text=None, help_context=None): """ Registers email template. Example usage: email_templates.register('hello_template.html', help_text=u'Hello template', help_context={'username': u'Name of user in hello expression'}) :param path...
python
def register(self, path, help_text=None, help_context=None): """ Registers email template. Example usage: email_templates.register('hello_template.html', help_text=u'Hello template', help_context={'username': u'Name of user in hello expression'}) :param path...
[ "def", "register", "(", "self", ",", "path", ",", "help_text", "=", "None", ",", "help_context", "=", "None", ")", ":", "if", "path", "in", "self", ".", "_registry", ":", "raise", "AlreadyRegistered", "(", "'The template %s is already registered'", "%", "path"...
Registers email template. Example usage: email_templates.register('hello_template.html', help_text=u'Hello template', help_context={'username': u'Name of user in hello expression'}) :param path: Template file path. It will become immutable registry lookup key. :para...
[ "Registers", "email", "template", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/registry.py#L84-L104
deployed/django-emailtemplates
emailtemplates/registry.py
EmailTemplateRegistry.get_registration
def get_registration(self, path): """ Returns registration item for specified path. If an email template is not registered, this will raise NotRegistered. """ if not self.is_registered(path): raise NotRegistered("Email template not registered") return self._r...
python
def get_registration(self, path): """ Returns registration item for specified path. If an email template is not registered, this will raise NotRegistered. """ if not self.is_registered(path): raise NotRegistered("Email template not registered") return self._r...
[ "def", "get_registration", "(", "self", ",", "path", ")", ":", "if", "not", "self", ".", "is_registered", "(", "path", ")", ":", "raise", "NotRegistered", "(", "\"Email template not registered\"", ")", "return", "self", ".", "_registry", "[", "path", "]" ]
Returns registration item for specified path. If an email template is not registered, this will raise NotRegistered.
[ "Returns", "registration", "item", "for", "specified", "path", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/registry.py#L109-L117
deployed/django-emailtemplates
emailtemplates/registry.py
EmailTemplateRegistry.get_form_help_text
def get_form_help_text(self, path): """ Returns text that can be used as form help text for creating email templates. """ try: form_help_text = self.get_registration(path).as_form_help_text() except NotRegistered: form_help_text = u"" return form_h...
python
def get_form_help_text(self, path): """ Returns text that can be used as form help text for creating email templates. """ try: form_help_text = self.get_registration(path).as_form_help_text() except NotRegistered: form_help_text = u"" return form_h...
[ "def", "get_form_help_text", "(", "self", ",", "path", ")", ":", "try", ":", "form_help_text", "=", "self", ".", "get_registration", "(", "path", ")", ".", "as_form_help_text", "(", ")", "except", "NotRegistered", ":", "form_help_text", "=", "u\"\"", "return",...
Returns text that can be used as form help text for creating email templates.
[ "Returns", "text", "that", "can", "be", "used", "as", "form", "help", "text", "for", "creating", "email", "templates", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/registry.py#L137-L145
myth/pepper8
pepper8/generator.py
HtmlGenerator.analyze
def analyze(self, output_file=None): """ Analyzes the parsed results from Flake8 or PEP 8 output and creates FileResult instances :param output_file: If specified, output will be written to this file instead of stdout. """ fr = None for path, code, line, char, desc in se...
python
def analyze(self, output_file=None): """ Analyzes the parsed results from Flake8 or PEP 8 output and creates FileResult instances :param output_file: If specified, output will be written to this file instead of stdout. """ fr = None for path, code, line, char, desc in se...
[ "def", "analyze", "(", "self", ",", "output_file", "=", "None", ")", ":", "fr", "=", "None", "for", "path", ",", "code", ",", "line", ",", "char", ",", "desc", "in", "self", ".", "parser", ".", "parse", "(", ")", ":", "# Create a new FileResult and reg...
Analyzes the parsed results from Flake8 or PEP 8 output and creates FileResult instances :param output_file: If specified, output will be written to this file instead of stdout.
[ "Analyzes", "the", "parsed", "results", "from", "Flake8", "or", "PEP", "8", "output", "and", "creates", "FileResult", "instances", ":", "param", "output_file", ":", "If", "specified", "output", "will", "be", "written", "to", "this", "file", "instead", "of", ...
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/generator.py#L37-L62
myth/pepper8
pepper8/generator.py
HtmlGenerator.generate
def generate(self, output_file=None): """ Generates an HTML file based on data from the Parser object and Jinja2 templates :param output_file: If specified, output will be written to this file instead of stdout. """ fd = output_file # Write to stdout if we do not have a...
python
def generate(self, output_file=None): """ Generates an HTML file based on data from the Parser object and Jinja2 templates :param output_file: If specified, output will be written to this file instead of stdout. """ fd = output_file # Write to stdout if we do not have a...
[ "def", "generate", "(", "self", ",", "output_file", "=", "None", ")", ":", "fd", "=", "output_file", "# Write to stdout if we do not have a file to write to", "if", "not", "fd", ":", "fd", "=", "stdout", "else", ":", "try", ":", "fd", "=", "open", "(", "outp...
Generates an HTML file based on data from the Parser object and Jinja2 templates :param output_file: If specified, output will be written to this file instead of stdout.
[ "Generates", "an", "HTML", "file", "based", "on", "data", "from", "the", "Parser", "object", "and", "Jinja2", "templates", ":", "param", "output_file", ":", "If", "specified", "output", "will", "be", "written", "to", "this", "file", "instead", "of", "stdout"...
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/generator.py#L64-L109
myth/pepper8
pepper8/generator.py
HtmlGenerator.update_stats
def update_stats(self, file_result): """ Reads the data from a FileResult and updates overall statistics :param file_result: A FileResult instance """ for code, count in file_result.violations.items(): if code not in self.violations: self.violations[c...
python
def update_stats(self, file_result): """ Reads the data from a FileResult and updates overall statistics :param file_result: A FileResult instance """ for code, count in file_result.violations.items(): if code not in self.violations: self.violations[c...
[ "def", "update_stats", "(", "self", ",", "file_result", ")", ":", "for", "code", ",", "count", "in", "file_result", ".", "violations", ".", "items", "(", ")", ":", "if", "code", "not", "in", "self", ".", "violations", ":", "self", ".", "violations", "[...
Reads the data from a FileResult and updates overall statistics :param file_result: A FileResult instance
[ "Reads", "the", "data", "from", "a", "FileResult", "and", "updates", "overall", "statistics", ":", "param", "file_result", ":", "A", "FileResult", "instance" ]
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/generator.py#L111-L127
myth/pepper8
pepper8/generator.py
HtmlGenerator.report_build_messages
def report_build_messages(self): """ Checks environment variables to see whether pepper8 is run under a build agent such as TeamCity and performs the adequate actions to report statistics. Will not perform any action if HTML output is written to OUTPUT_FILE and not stdout. Curre...
python
def report_build_messages(self): """ Checks environment variables to see whether pepper8 is run under a build agent such as TeamCity and performs the adequate actions to report statistics. Will not perform any action if HTML output is written to OUTPUT_FILE and not stdout. Curre...
[ "def", "report_build_messages", "(", "self", ")", ":", "if", "os", ".", "getenv", "(", "'TEAMCITY_VERSION'", ")", ":", "tc_build_message_warning", "=", "\"##teamcity[buildStatisticValue key='pepper8warnings' value='{}']\\n\"", "tc_build_message_error", "=", "\"##teamcity[buildS...
Checks environment variables to see whether pepper8 is run under a build agent such as TeamCity and performs the adequate actions to report statistics. Will not perform any action if HTML output is written to OUTPUT_FILE and not stdout. Currently only supports TeamCity. :return: A list...
[ "Checks", "environment", "variables", "to", "see", "whether", "pepper8", "is", "run", "under", "a", "build", "agent", "such", "as", "TeamCity", "and", "performs", "the", "adequate", "actions", "to", "report", "statistics", "." ]
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/generator.py#L129-L146
oscarlazoarjona/fast
fast/bloch.py
phase_transformation
def phase_transformation(Ne, Nl, rm, xi, return_equations=False): """Returns a phase transformation theta_i. The phase transformation is defined in a way such that theta1 + omega_level1 = 0. >>> xi = np.zeros((1, 2, 2)) >>> xi[0, 1, 0] = 1.0 >>> xi[0, 0, 1] = 1.0 >>> rm = np.zeros((3, ...
python
def phase_transformation(Ne, Nl, rm, xi, return_equations=False): """Returns a phase transformation theta_i. The phase transformation is defined in a way such that theta1 + omega_level1 = 0. >>> xi = np.zeros((1, 2, 2)) >>> xi[0, 1, 0] = 1.0 >>> xi[0, 0, 1] = 1.0 >>> rm = np.zeros((3, ...
[ "def", "phase_transformation", "(", "Ne", ",", "Nl", ",", "rm", ",", "xi", ",", "return_equations", "=", "False", ")", ":", "# We first define the needed variables", "E0", ",", "omega_laser", "=", "define_laser_variables", "(", "Nl", ")", "theta", "=", "[", "S...
Returns a phase transformation theta_i. The phase transformation is defined in a way such that theta1 + omega_level1 = 0. >>> xi = np.zeros((1, 2, 2)) >>> xi[0, 1, 0] = 1.0 >>> xi[0, 0, 1] = 1.0 >>> rm = np.zeros((3, 2, 2)) >>> rm[0, 1, 0] = 1.0 >>> rm[1, 1, 0] = 1.0 >>> rm[2, ...
[ "Returns", "a", "phase", "transformation", "theta_i", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L242-L311
oscarlazoarjona/fast
fast/bloch.py
define_simplification
def define_simplification(omega_level, xi, Nl): """Return a simplifying function, its inverse, and simplified frequencies. This implements an index iu that labels energies in a non-degenerate way. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np....
python
def define_simplification(omega_level, xi, Nl): """Return a simplifying function, its inverse, and simplified frequencies. This implements an index iu that labels energies in a non-degenerate way. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np....
[ "def", "define_simplification", "(", "omega_level", ",", "xi", ",", "Nl", ")", ":", "try", ":", "Ne", "=", "len", "(", "omega_level", ")", "except", ":", "Ne", "=", "omega_level", ".", "shape", "[", "0", "]", "#####################################", "# 1 We ...
Return a simplifying function, its inverse, and simplified frequencies. This implements an index iu that labels energies in a non-degenerate way. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [...
[ "Return", "a", "simplifying", "function", "its", "inverse", "and", "simplified", "frequencies", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L314-L380
oscarlazoarjona/fast
fast/bloch.py
find_omega_min
def find_omega_min(omega_levelu, Neu, Nl, xiu): r"""Find the smallest transition frequency for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in ra...
python
def find_omega_min(omega_levelu, Neu, Nl, xiu): r"""Find the smallest transition frequency for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in ra...
[ "def", "find_omega_min", "(", "omega_levelu", ",", "Neu", ",", "Nl", ",", "xiu", ")", ":", "omega_min", "=", "[", "]", "iu0", "=", "[", "]", "ju0", "=", "[", "]", "for", "l", "in", "range", "(", "Nl", ")", ":", "omegasl", "=", "[", "]", "for", ...
r"""Find the smallest transition frequency for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair in coup[l]: ... ...
[ "r", "Find", "the", "smallest", "transition", "frequency", "for", "each", "field", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L383-L414
oscarlazoarjona/fast
fast/bloch.py
detunings_indices
def detunings_indices(Neu, Nl, xiu): r"""Get the indices of the transitions of all fields. They are returned in the form [[(i1, j1), (i2, j2)], ...,[(i1, j1)]]. that is, one list of pairs of indices for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 3...
python
def detunings_indices(Neu, Nl, xiu): r"""Get the indices of the transitions of all fields. They are returned in the form [[(i1, j1), (i2, j2)], ...,[(i1, j1)]]. that is, one list of pairs of indices for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 3...
[ "def", "detunings_indices", "(", "Neu", ",", "Nl", ",", "xiu", ")", ":", "pairs", "=", "[", "]", "for", "l", "in", "range", "(", "Nl", ")", ":", "ind", "=", "[", "]", "for", "iu", "in", "range", "(", "Neu", ")", ":", "for", "ju", "in", "range...
r"""Get the indices of the transitions of all fields. They are returned in the form [[(i1, j1), (i2, j2)], ...,[(i1, j1)]]. that is, one list of pairs of indices for each field. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne))...
[ "r", "Get", "the", "indices", "of", "the", "transitions", "of", "all", "fields", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L417-L448
oscarlazoarjona/fast
fast/bloch.py
detunings_code
def detunings_code(Neu, Nl, pairs, omega_levelu, iu0, ju0): r"""Get the code to calculate the simplified detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> fo...
python
def detunings_code(Neu, Nl, pairs, omega_levelu, iu0, ju0): r"""Get the code to calculate the simplified detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> fo...
[ "def", "detunings_code", "(", "Neu", ",", "Nl", ",", "pairs", ",", "omega_levelu", ",", "iu0", ",", "ju0", ")", ":", "code_det", "=", "\"\"", "for", "l", "in", "range", "(", "Nl", ")", ":", "for", "pair", "in", "pairs", "[", "l", "]", ":", "iu", ...
r"""Get the code to calculate the simplified detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair in coup[l]: ... ...
[ "r", "Get", "the", "code", "to", "calculate", "the", "simplified", "detunings", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L451-L489
oscarlazoarjona/fast
fast/bloch.py
detunings_combinations
def detunings_combinations(pairs): r"""Return all combinations of detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair ...
python
def detunings_combinations(pairs): r"""Return all combinations of detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair ...
[ "def", "detunings_combinations", "(", "pairs", ")", ":", "def", "iter", "(", "pairs", ",", "combs", ",", "l", ")", ":", "combs_n", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "combs", ")", ")", ":", "for", "j", "in", "range", "(", ...
r"""Return all combinations of detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair in coup[l]: ... xi[l, pair[...
[ "r", "Return", "all", "combinations", "of", "detunings", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L492-L524
oscarlazoarjona/fast
fast/bloch.py
detunings_rewrite
def detunings_rewrite(expr, combs, omega_laser, symb_omega_levelu, omega_levelu, iu0, ju0): r"""Rewrite a symbolic expression in terms of allowed transition detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, N...
python
def detunings_rewrite(expr, combs, omega_laser, symb_omega_levelu, omega_levelu, iu0, ju0): r"""Rewrite a symbolic expression in terms of allowed transition detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, N...
[ "def", "detunings_rewrite", "(", "expr", ",", "combs", ",", "omega_laser", ",", "symb_omega_levelu", ",", "omega_levelu", ",", "iu0", ",", "ju0", ")", ":", "Nl", "=", "len", "(", "omega_laser", ")", "Neu", "=", "len", "(", "symb_omega_levelu", ")", "# We f...
r"""Rewrite a symbolic expression in terms of allowed transition detunings. >>> Ne = 6 >>> Nl = 2 >>> omega_level = [0.0, 100.0, 100.0, 200.0, 200.0, 300.0] >>> xi = np.zeros((Nl, Ne, Ne)) >>> coup = [[(1, 0), (2, 0)], [(3, 0), (4, 0), (5, 0)]] >>> for l in range(Nl): ... for pair in co...
[ "r", "Rewrite", "a", "symbolic", "expression", "in", "terms", "of", "allowed", "transition", "detunings", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L527-L624
oscarlazoarjona/fast
fast/bloch.py
fast_hamiltonian
def fast_hamiltonian(Ep, epsilonp, detuning_knob, rm, omega_level, xi, theta, file_name=None): r"""Return a fast function that returns a Hamiltonian as an array. INPUT: - ``Ep`` - A list with the electric field amplitudes (real or complex). - ``epsilonp`` - A list of the polariz...
python
def fast_hamiltonian(Ep, epsilonp, detuning_knob, rm, omega_level, xi, theta, file_name=None): r"""Return a fast function that returns a Hamiltonian as an array. INPUT: - ``Ep`` - A list with the electric field amplitudes (real or complex). - ``epsilonp`` - A list of the polariz...
[ "def", "fast_hamiltonian", "(", "Ep", ",", "epsilonp", ",", "detuning_knob", ",", "rm", ",", "omega_level", ",", "xi", ",", "theta", ",", "file_name", "=", "None", ")", ":", "# We determine which arguments are constants.", "if", "True", ":", "Nl", "=", "len", ...
r"""Return a fast function that returns a Hamiltonian as an array. INPUT: - ``Ep`` - A list with the electric field amplitudes (real or complex). - ``epsilonp`` - A list of the polarization vectors of the fields \ (real or complex). - ``detuning_knob`` - A list of the detunings of each field (r...
[ "r", "Return", "a", "fast", "function", "that", "returns", "a", "Hamiltonian", "as", "an", "array", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L627-L949
oscarlazoarjona/fast
fast/bloch.py
independent_get_coefficients
def independent_get_coefficients(coef, rhouv, s, i, j, k, u, v, unfolding, matrix_form): r"""Get the indices mu, nu, and term coefficients for linear terms. >>> from fast.symbolic import define_density_matrix >>> Ne = 2 >>> coef = 1+2j >>> rhouv = define_density_mat...
python
def independent_get_coefficients(coef, rhouv, s, i, j, k, u, v, unfolding, matrix_form): r"""Get the indices mu, nu, and term coefficients for linear terms. >>> from fast.symbolic import define_density_matrix >>> Ne = 2 >>> coef = 1+2j >>> rhouv = define_density_mat...
[ "def", "independent_get_coefficients", "(", "coef", ",", "rhouv", ",", "s", ",", "i", ",", "j", ",", "k", ",", "u", ",", "v", ",", "unfolding", ",", "matrix_form", ")", ":", "if", "matrix_form", ":", "coef", "=", "-", "coef", "Mu", "=", "unfolding", ...
r"""Get the indices mu, nu, and term coefficients for linear terms. >>> from fast.symbolic import define_density_matrix >>> Ne = 2 >>> coef = 1+2j >>> rhouv = define_density_matrix(Ne)[1, 1] >>> s, i, j, k, u, v = (1, 1, 0, 1, 1, 1) >>> unfolding = Unfolding(Ne, real=True, normalized=True) ...
[ "r", "Get", "the", "indices", "mu", "nu", "and", "term", "coefficients", "for", "linear", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1354-L1381
oscarlazoarjona/fast
fast/bloch.py
linear_get_coefficients
def linear_get_coefficients(coef, rhouv, s, i, j, k, u, v, unfolding, matrix_form): r"""Get the indices mu, nu, and term coefficients for linear terms. We determine mu and nu, the indices labeling the density matrix components d rho[mu] /dt = sum_nu A[mu, nu]*rho[nu] f...
python
def linear_get_coefficients(coef, rhouv, s, i, j, k, u, v, unfolding, matrix_form): r"""Get the indices mu, nu, and term coefficients for linear terms. We determine mu and nu, the indices labeling the density matrix components d rho[mu] /dt = sum_nu A[mu, nu]*rho[nu] f...
[ "def", "linear_get_coefficients", "(", "coef", ",", "rhouv", ",", "s", ",", "i", ",", "j", ",", "k", ",", "u", ",", "v", ",", "unfolding", ",", "matrix_form", ")", ":", "Ne", "=", "unfolding", ".", "Ne", "Mu", "=", "unfolding", ".", "Mu", "# We det...
r"""Get the indices mu, nu, and term coefficients for linear terms. We determine mu and nu, the indices labeling the density matrix components d rho[mu] /dt = sum_nu A[mu, nu]*rho[nu] for this complex and rho_u,v. >>> from fast.symbolic import define_density_matrix >>> Ne = 2 >>> coef = ...
[ "r", "Get", "the", "indices", "mu", "nu", "and", "term", "coefficients", "for", "linear", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1384-L1478
oscarlazoarjona/fast
fast/bloch.py
term_code
def term_code(mu, nu, coef, matrix_form, rhouv_isconjugated, linear=True): r"""Get code to calculate a linear term. >>> term_code(1, 0, 33, False, False, True) ' rhs[1] += (33)*rho[0]\n' """ if coef == 0: return "" coef = str(coef) # We change E_{0i} -> E0[i-1] ini = coef.f...
python
def term_code(mu, nu, coef, matrix_form, rhouv_isconjugated, linear=True): r"""Get code to calculate a linear term. >>> term_code(1, 0, 33, False, False, True) ' rhs[1] += (33)*rho[0]\n' """ if coef == 0: return "" coef = str(coef) # We change E_{0i} -> E0[i-1] ini = coef.f...
[ "def", "term_code", "(", "mu", ",", "nu", ",", "coef", ",", "matrix_form", ",", "rhouv_isconjugated", ",", "linear", "=", "True", ")", ":", "if", "coef", "==", "0", ":", "return", "\"\"", "coef", "=", "str", "(", "coef", ")", "# We change E_{0i} -> E0[i-...
r"""Get code to calculate a linear term. >>> term_code(1, 0, 33, False, False, True) ' rhs[1] += (33)*rho[0]\n'
[ "r", "Get", "code", "to", "calculate", "a", "linear", "term", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1481-L1528
oscarlazoarjona/fast
fast/bloch.py
fast_rabi_terms
def fast_rabi_terms(Ep, epsilonp, rm, xi, theta, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Rabi frequency terms. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_con...
python
def fast_rabi_terms(Ep, epsilonp, rm, xi, theta, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Rabi frequency terms. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_con...
[ "def", "fast_rabi_terms", "(", "Ep", ",", "epsilonp", ",", "rm", ",", "xi", ",", "theta", ",", "unfolding", ",", "matrix_form", "=", "False", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "if", "not", "unfolding", ".", "low...
r"""Return a fast function that returns the Rabi frequency terms. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix >>> from fast.electric_field import electric_field_amplitude_top >>> from fast.symbolic imp...
[ "r", "Return", "a", "fast", "function", "that", "returns", "the", "Rabi", "frequency", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1531-L1745
oscarlazoarjona/fast
fast/bloch.py
fast_lindblad_terms
def fast_lindblad_terms(gamma, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Lindblad terms. We test a basic two-level system. >>> import numpy as np >>> Ne = 2 >>> gamma21 = 2*np.pi*6e6 >>> gamma = np.arra...
python
def fast_lindblad_terms(gamma, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Lindblad terms. We test a basic two-level system. >>> import numpy as np >>> Ne = 2 >>> gamma21 = 2*np.pi*6e6 >>> gamma = np.arra...
[ "def", "fast_lindblad_terms", "(", "gamma", ",", "unfolding", ",", "matrix_form", "=", "False", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "Ne", "=", "unfolding", ".", "Ne", "Nrho", "=", "unfolding", ".", "Nrho", "Mu", "="...
r"""Return a fast function that returns the Lindblad terms. We test a basic two-level system. >>> import numpy as np >>> Ne = 2 >>> gamma21 = 2*np.pi*6e6 >>> gamma = np.array([[0.0, -gamma21], ... [gamma21, 0.0]]) >>> rhos = np.array([[0.6, 3+2j], ... ...
[ "r", "Return", "a", "fast", "function", "that", "returns", "the", "Lindblad", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1920-L2053
oscarlazoarjona/fast
fast/bloch.py
fast_hamiltonian_terms
def fast_hamiltonian_terms(Ep, epsilonp, detuning_knob, omega_level, rm, xi, theta, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Hamiltonian terms. We test a basic t...
python
def fast_hamiltonian_terms(Ep, epsilonp, detuning_knob, omega_level, rm, xi, theta, unfolding, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Hamiltonian terms. We test a basic t...
[ "def", "fast_hamiltonian_terms", "(", "Ep", ",", "epsilonp", ",", "detuning_knob", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "unfolding", ",", "matrix_form", "=", "False", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ...
r"""Return a fast function that returns the Hamiltonian terms. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electric_field_amplitude_top >>> from fast.symbol...
[ "r", "Return", "a", "fast", "function", "that", "returns", "the", "Hamiltonian", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L2056-L2259
oscarlazoarjona/fast
fast/bloch.py
fast_steady_state
def fast_steady_state(Ep, epsilonp, detuning_knob, gamma, omega_level, rm, xi, theta, file_name=None, return_code=False): r"""Return a fast function that returns a steady state. We test a basic two-level system. >>> import numpy as np >>> from scipy.constant...
python
def fast_steady_state(Ep, epsilonp, detuning_knob, gamma, omega_level, rm, xi, theta, file_name=None, return_code=False): r"""Return a fast function that returns a steady state. We test a basic two-level system. >>> import numpy as np >>> from scipy.constant...
[ "def", "fast_steady_state", "(", "Ep", ",", "epsilonp", ",", "detuning_knob", ",", "gamma", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "# We unpack variables.", "if", "...
r"""Return a fast function that returns a steady state. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electric_field_amplitude_top >>> from fast.symbolic impo...
[ "r", "Return", "a", "fast", "function", "that", "returns", "a", "steady", "state", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L2496-L2620
oscarlazoarjona/fast
fast/bloch.py
time_average
def time_average(rho, t): r"""Return a time-averaged density matrix (using trapezium rule). We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electric_field_ampli...
python
def time_average(rho, t): r"""Return a time-averaged density matrix (using trapezium rule). We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electric_field_ampli...
[ "def", "time_average", "(", "rho", ",", "t", ")", ":", "T", "=", "t", "[", "-", "1", "]", "-", "t", "[", "0", "]", "dt", "=", "t", "[", "1", "]", "-", "t", "[", "0", "]", "rhoav", "=", "np", ".", "sum", "(", "rho", "[", "1", ":", "-",...
r"""Return a time-averaged density matrix (using trapezium rule). We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electric_field_amplitude_top >>> from fast.sym...
[ "r", "Return", "a", "time", "-", "averaged", "density", "matrix", "(", "using", "trapezium", "rule", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L2786-L2842
oscarlazoarjona/fast
fast/bloch.py
fast_sweep_steady_state
def fast_sweep_steady_state(Ep, epsilonp, gamma, omega_level, rm, xi, theta, file_name=None, return_code=False): r"""Return an spectrum of density matrices in the steady state. We test a basic two-level system. >>> import numpy as np >>> from sym...
python
def fast_sweep_steady_state(Ep, epsilonp, gamma, omega_level, rm, xi, theta, file_name=None, return_code=False): r"""Return an spectrum of density matrices in the steady state. We test a basic two-level system. >>> import numpy as np >>> from sym...
[ "def", "fast_sweep_steady_state", "(", "Ep", ",", "epsilonp", ",", "gamma", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "# We unpack variables.", "if", "True", ":", "Nl"...
r"""Return an spectrum of density matrices in the steady state. We test a basic two-level system. >>> import numpy as np >>> from sympy import symbols >>> from scipy.constants import physical_constants >>> e_num = physical_constants["elementary charge"][0] >>> hbar_num = physical_constants["P...
[ "r", "Return", "an", "spectrum", "of", "density", "matrices", "in", "the", "steady", "state", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L2845-L2963
oscarlazoarjona/fast
fast/bloch.py
fast_sweep_time_evolution
def fast_sweep_time_evolution(Ep, epsilonp, gamma, omega_level, rm, xi, theta, semi_analytic=True, file_name=None, return_code=False): r"""Return a spectrum of time evolutions of the density matrix. We test a basic two-le...
python
def fast_sweep_time_evolution(Ep, epsilonp, gamma, omega_level, rm, xi, theta, semi_analytic=True, file_name=None, return_code=False): r"""Return a spectrum of time evolutions of the density matrix. We test a basic two-le...
[ "def", "fast_sweep_time_evolution", "(", "Ep", ",", "epsilonp", ",", "gamma", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "semi_analytic", "=", "True", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "# We unpack...
r"""Return a spectrum of time evolutions of the density matrix. We test a basic two-level system. >>> import numpy as np >>> from sympy import symbols >>> from scipy.constants import physical_constants >>> e_num = physical_constants["elementary charge"][0] >>> hbar_num = physical_constants["P...
[ "r", "Return", "a", "spectrum", "of", "time", "evolutions", "of", "the", "density", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L2966-L3158
oscarlazoarjona/fast
fast/bloch.py
observable
def observable(operator, rho, unfolding, complex=False): r"""Return an observable ammount. INPUT: - ``operator`` - An square matrix representing a hermitian operator \ in thesame basis as the density matrix. - ``rho`` - A density matrix in unfolded format, or a list of such \ density matrice...
python
def observable(operator, rho, unfolding, complex=False): r"""Return an observable ammount. INPUT: - ``operator`` - An square matrix representing a hermitian operator \ in thesame basis as the density matrix. - ``rho`` - A density matrix in unfolded format, or a list of such \ density matrice...
[ "def", "observable", "(", "operator", ",", "rho", ",", "unfolding", ",", "complex", "=", "False", ")", ":", "if", "len", "(", "rho", ".", "shape", ")", "==", "2", ":", "return", "np", ".", "array", "(", "[", "observable", "(", "operator", ",", "i",...
r"""Return an observable ammount. INPUT: - ``operator`` - An square matrix representing a hermitian operator \ in thesame basis as the density matrix. - ``rho`` - A density matrix in unfolded format, or a list of such \ density matrices. - ``unfolding`` - A mapping from matrix element indic...
[ "r", "Return", "an", "observable", "ammount", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L3161-L3217
oscarlazoarjona/fast
fast/bloch.py
electric_succeptibility
def electric_succeptibility(l, Ep, epsilonp, rm, n, rho, unfolding, part=0): r"""Return the electric succeptibility for a given field. INPUT: - ``l`` - The index labeling the probe field. - ``Ep`` - A list of the amplitudes of all pump fields. - ``epsilonp`` - The polarization vector of the pro...
python
def electric_succeptibility(l, Ep, epsilonp, rm, n, rho, unfolding, part=0): r"""Return the electric succeptibility for a given field. INPUT: - ``l`` - The index labeling the probe field. - ``Ep`` - A list of the amplitudes of all pump fields. - ``epsilonp`` - The polarization vector of the pro...
[ "def", "electric_succeptibility", "(", "l", ",", "Ep", ",", "epsilonp", ",", "rm", ",", "n", ",", "rho", ",", "unfolding", ",", "part", "=", "0", ")", ":", "epsilonm", "=", "epsilonp", ".", "conjugate", "(", ")", "rp", "=", "np", ".", "array", "(",...
r"""Return the electric succeptibility for a given field. INPUT: - ``l`` - The index labeling the probe field. - ``Ep`` - A list of the amplitudes of all pump fields. - ``epsilonp`` - The polarization vector of the probe field. - ``rm`` - The below-diagonal components of the position opera...
[ "r", "Return", "the", "electric", "succeptibility", "for", "a", "given", "field", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L3220-L3290
oscarlazoarjona/fast
fast/bloch.py
radiated_intensity
def radiated_intensity(rho, i, j, epsilonp, rm, omega_level, xi, N, D, unfolding): r"""Return the radiated intensity in a given direction. >>> from fast import State, Integer, split_hyperfine_to_magnetic >>> g = State("Rb", 87, 5, 1, 3/Integer(2), 0) >>> e = State("Rb", 87, 4, 2,...
python
def radiated_intensity(rho, i, j, epsilonp, rm, omega_level, xi, N, D, unfolding): r"""Return the radiated intensity in a given direction. >>> from fast import State, Integer, split_hyperfine_to_magnetic >>> g = State("Rb", 87, 5, 1, 3/Integer(2), 0) >>> e = State("Rb", 87, 4, 2,...
[ "def", "radiated_intensity", "(", "rho", ",", "i", ",", "j", ",", "epsilonp", ",", "rm", ",", "omega_level", ",", "xi", ",", "N", ",", "D", ",", "unfolding", ")", ":", "def", "inij", "(", "i", ",", "j", ",", "ilist", ",", "jlist", ")", ":", "if...
r"""Return the radiated intensity in a given direction. >>> from fast import State, Integer, split_hyperfine_to_magnetic >>> g = State("Rb", 87, 5, 1, 3/Integer(2), 0) >>> e = State("Rb", 87, 4, 2, 5/Integer(2), 1) >>> magnetic_states = split_hyperfine_to_magnetic([g, e]) >>> omega0 = magnetic_stat...
[ "r", "Return", "the", "radiated", "intensity", "in", "a", "given", "direction", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L3293-L3378
oscarlazoarjona/fast
fast/bloch.py
Unfolding.inverse
def inverse(self, rhov, time_derivative=False): r"""Fold a vector into a matrix. The input of this function can be a numpy array or a sympy Matrix. If the input is understood to represent the time derivative of a density matrix, then the flag time_derivative must be set to True. ...
python
def inverse(self, rhov, time_derivative=False): r"""Fold a vector into a matrix. The input of this function can be a numpy array or a sympy Matrix. If the input is understood to represent the time derivative of a density matrix, then the flag time_derivative must be set to True. ...
[ "def", "inverse", "(", "self", ",", "rhov", ",", "time_derivative", "=", "False", ")", ":", "Ne", "=", "self", ".", "Ne", "Nrho", "=", "self", ".", "Nrho", "IJ", "=", "self", ".", "IJ", "if", "isinstance", "(", "rhov", ",", "np", ".", "ndarray", ...
r"""Fold a vector into a matrix. The input of this function can be a numpy array or a sympy Matrix. If the input is understood to represent the time derivative of a density matrix, then the flag time_derivative must be set to True. >>> unfolding = Unfolding(2, real=True, lower_triangu...
[ "r", "Fold", "a", "vector", "into", "a", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/bloch.py#L1280-L1351
tilde-lab/tilde
tilde/berlinium/plotter.py
bdplotter
def bdplotter(task, **kwargs): ''' bdplotter is based on the fact that phonon DOS/bands and electron DOS/bands are the objects of the same kind. 1) DOS is formatted precomputed / smeared according to a normal distribution 2) bands are formatted precomputed / interpolated through natural cubic spline...
python
def bdplotter(task, **kwargs): ''' bdplotter is based on the fact that phonon DOS/bands and electron DOS/bands are the objects of the same kind. 1) DOS is formatted precomputed / smeared according to a normal distribution 2) bands are formatted precomputed / interpolated through natural cubic spline...
[ "def", "bdplotter", "(", "task", ",", "*", "*", "kwargs", ")", ":", "if", "task", "==", "'bands'", ":", "# CRYSTAL, \"VASP\", EXCITING", "results", "=", "[", "]", "if", "'precomputed'", "in", "kwargs", ":", "for", "n", "in", "range", "(", "len", "(", "...
bdplotter is based on the fact that phonon DOS/bands and electron DOS/bands are the objects of the same kind. 1) DOS is formatted precomputed / smeared according to a normal distribution 2) bands are formatted precomputed / interpolated through natural cubic spline function
[ "bdplotter", "is", "based", "on", "the", "fact", "that", "phonon", "DOS", "/", "bands", "and", "electron", "DOS", "/", "bands", "are", "the", "objects", "of", "the", "same", "kind", ".", "1", ")", "DOS", "is", "formatted", "precomputed", "/", "smeared", ...
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/berlinium/plotter.py#L27-L148
tilde-lab/tilde
tilde/berlinium/plotter.py
eplotter
def eplotter(task, data): # CRYSTAL, VASP, EXCITING ''' eplotter is like bdplotter but less complicated ''' results, color, fdata = [], None, [] if task == 'optstory': color = '#CC0000' clickable = True for n, i in enumerate(data): fdata.append([n, i[4]]) ...
python
def eplotter(task, data): # CRYSTAL, VASP, EXCITING ''' eplotter is like bdplotter but less complicated ''' results, color, fdata = [], None, [] if task == 'optstory': color = '#CC0000' clickable = True for n, i in enumerate(data): fdata.append([n, i[4]]) ...
[ "def", "eplotter", "(", "task", ",", "data", ")", ":", "# CRYSTAL, VASP, EXCITING", "results", ",", "color", ",", "fdata", "=", "[", "]", ",", "None", ",", "[", "]", "if", "task", "==", "'optstory'", ":", "color", "=", "'#CC0000'", "clickable", "=", "T...
eplotter is like bdplotter but less complicated
[ "eplotter", "is", "like", "bdplotter", "but", "less", "complicated" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/berlinium/plotter.py#L151-L177
oscarlazoarjona/fast
fast/magnetic_field.py
lande_g_factors
def lande_g_factors(element, isotope, L=None, J=None, F=None): r"""Return the Lande g-factors for a given atom or level. >>> element = "Rb" >>> isotope = 87 >>> print(lande_g_factors(element, isotope)) [ 9.9999e-01 2.0023e+00 -9.9514e-04] The spin-orbit g-factor for a certain J >...
python
def lande_g_factors(element, isotope, L=None, J=None, F=None): r"""Return the Lande g-factors for a given atom or level. >>> element = "Rb" >>> isotope = 87 >>> print(lande_g_factors(element, isotope)) [ 9.9999e-01 2.0023e+00 -9.9514e-04] The spin-orbit g-factor for a certain J >...
[ "def", "lande_g_factors", "(", "element", ",", "isotope", ",", "L", "=", "None", ",", "J", "=", "None", ",", "F", "=", "None", ")", ":", "atom", "=", "Atom", "(", "element", ",", "isotope", ")", "gL", "=", "atom", ".", "gL", "gS", "=", "atom", ...
r"""Return the Lande g-factors for a given atom or level. >>> element = "Rb" >>> isotope = 87 >>> print(lande_g_factors(element, isotope)) [ 9.9999e-01 2.0023e+00 -9.9514e-04] The spin-orbit g-factor for a certain J >>> print(lande_g_factors(element, isotope, L=0, J=1/Integer(2))) ...
[ "r", "Return", "the", "Lande", "g", "-", "factors", "for", "a", "given", "atom", "or", "level", ".", ">>>", "element", "=", "Rb", ">>>", "isotope", "=", "87", ">>>", "print", "(", "lande_g_factors", "(", "element", "isotope", "))", "[", "9", ".", "99...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/magnetic_field.py#L37-L77
oscarlazoarjona/fast
fast/magnetic_field.py
zeeman_energies
def zeeman_energies(fine_state, Bz): r"""Return Zeeman effect energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in zeeman_energies(ground_state, Bz): ... print(f_group) ...
python
def zeeman_energies(fine_state, Bz): r"""Return Zeeman effect energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in zeeman_energies(ground_state, Bz): ... print(f_group) ...
[ "def", "zeeman_energies", "(", "fine_state", ",", "Bz", ")", ":", "element", "=", "fine_state", ".", "element", "isotope", "=", "fine_state", ".", "isotope", "N", "=", "fine_state", ".", "n", "L", "=", "fine_state", ".", "l", "J", "=", "fine_state", ".",...
r"""Return Zeeman effect energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in zeeman_energies(ground_state, Bz): ... print(f_group) [-2.73736448508248e-24 -2.83044285506388...
[ "r", "Return", "Zeeman", "effect", "energies", "for", "a", "given", "fine", "state", "and", "\\", "magnetic", "field", ".", ">>>", "ground_state", "=", "State", "(", "Rb", "87", "5", "0", "1", "/", "Integer", "(", "2", "))", ">>>", "Bz", "=", "200", ...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/magnetic_field.py#L80-L111
oscarlazoarjona/fast
fast/magnetic_field.py
paschen_back_energies
def paschen_back_energies(fine_state, Bz): r"""Return Paschen-Back regime energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in paschen_back_energies(ground_state, Bz): ... ...
python
def paschen_back_energies(fine_state, Bz): r"""Return Paschen-Back regime energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in paschen_back_energies(ground_state, Bz): ... ...
[ "def", "paschen_back_energies", "(", "fine_state", ",", "Bz", ")", ":", "element", "=", "fine_state", ".", "element", "isotope", "=", "fine_state", ".", "isotope", "N", "=", "fine_state", ".", "n", "L", "=", "fine_state", ".", "l", "J", "=", "fine_state", ...
r"""Return Paschen-Back regime energies for a given fine state and\ magnetic field. >>> ground_state = State("Rb", 87, 5, 0, 1/Integer(2)) >>> Bz = 200.0 >>> Bz = Bz/10000 >>> for f_group in paschen_back_energies(ground_state, Bz): ... print(f_group) [1.51284728917866e-24 3.8048...
[ "r", "Return", "Paschen", "-", "Back", "regime", "energies", "for", "a", "given", "fine", "state", "and", "\\", "magnetic", "field", ".", ">>>", "ground_state", "=", "State", "(", "Rb", "87", "5", "0", "1", "/", "Integer", "(", "2", "))", ">>>", "Bz"...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/magnetic_field.py#L114-L160
tilde-lab/tilde
tilde/core/api.py
API.assign_parser
def assign_parser(self, name): ''' Restricts parsing **name** is a name of the parser class NB: this is the PUBLIC method @procedure ''' for n, p in list(self.Parsers.items()): if n != name: del self.Parsers[n] if len(self.Parse...
python
def assign_parser(self, name): ''' Restricts parsing **name** is a name of the parser class NB: this is the PUBLIC method @procedure ''' for n, p in list(self.Parsers.items()): if n != name: del self.Parsers[n] if len(self.Parse...
[ "def", "assign_parser", "(", "self", ",", "name", ")", ":", "for", "n", ",", "p", "in", "list", "(", "self", ".", "Parsers", ".", "items", "(", ")", ")", ":", "if", "n", "!=", "name", ":", "del", "self", ".", "Parsers", "[", "n", "]", "if", "...
Restricts parsing **name** is a name of the parser class NB: this is the PUBLIC method @procedure
[ "Restricts", "parsing", "**", "name", "**", "is", "a", "name", "of", "the", "parser", "class", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L158-L169
tilde-lab/tilde
tilde/core/api.py
API.formula
def formula(self, atom_sequence): ''' Constructs standardized chemical formula NB: this is the PUBLIC method @returns formula_str ''' labels = {} types = [] y = 0 for k, atomi in enumerate(atom_sequence): lbl = re.sub("[0-9]+", "", atom...
python
def formula(self, atom_sequence): ''' Constructs standardized chemical formula NB: this is the PUBLIC method @returns formula_str ''' labels = {} types = [] y = 0 for k, atomi in enumerate(atom_sequence): lbl = re.sub("[0-9]+", "", atom...
[ "def", "formula", "(", "self", ",", "atom_sequence", ")", ":", "labels", "=", "{", "}", "types", "=", "[", "]", "y", "=", "0", "for", "k", ",", "atomi", "in", "enumerate", "(", "atom_sequence", ")", ":", "lbl", "=", "re", ".", "sub", "(", "\"[0-9...
Constructs standardized chemical formula NB: this is the PUBLIC method @returns formula_str
[ "Constructs", "standardized", "chemical", "formula", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L171-L196
tilde-lab/tilde
tilde/core/api.py
API.savvyize
def savvyize(self, input_string, recursive=False, stemma=False): ''' Determines which files should be processed NB: this is the PUBLIC method @returns filenames_list ''' input_string = os.path.abspath(input_string) tasks = [] restricted = [ symbol for sym...
python
def savvyize(self, input_string, recursive=False, stemma=False): ''' Determines which files should be processed NB: this is the PUBLIC method @returns filenames_list ''' input_string = os.path.abspath(input_string) tasks = [] restricted = [ symbol for sym...
[ "def", "savvyize", "(", "self", ",", "input_string", ",", "recursive", "=", "False", ",", "stemma", "=", "False", ")", ":", "input_string", "=", "os", ".", "path", ".", "abspath", "(", "input_string", ")", "tasks", "=", "[", "]", "restricted", "=", "["...
Determines which files should be processed NB: this is the PUBLIC method @returns filenames_list
[ "Determines", "which", "files", "should", "be", "processed", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L201-L270
tilde-lab/tilde
tilde/core/api.py
API._parse
def _parse(self, parsable, parser_name): ''' Low-level parsing NB: this is the PRIVATE method @returns tilde_obj, error ''' calc, error = None, None try: for calc in self.Parsers[parser_name].iparse(parsable): yield calc, None ...
python
def _parse(self, parsable, parser_name): ''' Low-level parsing NB: this is the PRIVATE method @returns tilde_obj, error ''' calc, error = None, None try: for calc in self.Parsers[parser_name].iparse(parsable): yield calc, None ...
[ "def", "_parse", "(", "self", ",", "parsable", ",", "parser_name", ")", ":", "calc", ",", "error", "=", "None", ",", "None", "try", ":", "for", "calc", "in", "self", ".", "Parsers", "[", "parser_name", "]", ".", "iparse", "(", "parsable", ")", ":", ...
Low-level parsing NB: this is the PRIVATE method @returns tilde_obj, error
[ "Low", "-", "level", "parsing", "NB", ":", "this", "is", "the", "PRIVATE", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L272-L288
tilde-lab/tilde
tilde/core/api.py
API.parse
def parse(self, parsable): ''' High-level parsing: determines the data format and combines parent-children outputs NB: this is the PUBLIC method @returns tilde_obj, error ''' calc, error = None, None try: f = open(parsable, 'rb') ...
python
def parse(self, parsable): ''' High-level parsing: determines the data format and combines parent-children outputs NB: this is the PUBLIC method @returns tilde_obj, error ''' calc, error = None, None try: f = open(parsable, 'rb') ...
[ "def", "parse", "(", "self", ",", "parsable", ")", ":", "calc", ",", "error", "=", "None", ",", "None", "try", ":", "f", "=", "open", "(", "parsable", ",", "'rb'", ")", "if", "is_binary_string", "(", "f", ".", "read", "(", "2048", ")", ")", ":", ...
High-level parsing: determines the data format and combines parent-children outputs NB: this is the PUBLIC method @returns tilde_obj, error
[ "High", "-", "level", "parsing", ":", "determines", "the", "data", "format", "and", "combines", "parent", "-", "children", "outputs", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L290-L345
tilde-lab/tilde
tilde/core/api.py
API.classify
def classify(self, calc, symprec=None): ''' Reasons on normalization, invokes hierarchy API and prepares calc for saving NB: this is the PUBLIC method @returns tilde_obj, error ''' error = None symbols = calc.structures[-1].get_chemical_symbols() calc.info...
python
def classify(self, calc, symprec=None): ''' Reasons on normalization, invokes hierarchy API and prepares calc for saving NB: this is the PUBLIC method @returns tilde_obj, error ''' error = None symbols = calc.structures[-1].get_chemical_symbols() calc.info...
[ "def", "classify", "(", "self", ",", "calc", ",", "symprec", "=", "None", ")", ":", "error", "=", "None", "symbols", "=", "calc", ".", "structures", "[", "-", "1", "]", ".", "get_chemical_symbols", "(", ")", "calc", ".", "info", "[", "'formula'", "]"...
Reasons on normalization, invokes hierarchy API and prepares calc for saving NB: this is the PUBLIC method @returns tilde_obj, error
[ "Reasons", "on", "normalization", "invokes", "hierarchy", "API", "and", "prepares", "calc", "for", "saving", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L347-L509
tilde-lab/tilde
tilde/core/api.py
API.postprocess
def postprocess(self, calc, with_module=None, dry_run=None): ''' Invokes module(s) API NB: this is the PUBLIC method @returns apps_dict ''' for appname, appclass in self.Apps.items(): if with_module and with_module != appname: continue run_permitt...
python
def postprocess(self, calc, with_module=None, dry_run=None): ''' Invokes module(s) API NB: this is the PUBLIC method @returns apps_dict ''' for appname, appclass in self.Apps.items(): if with_module and with_module != appname: continue run_permitt...
[ "def", "postprocess", "(", "self", ",", "calc", ",", "with_module", "=", "None", ",", "dry_run", "=", "None", ")", ":", "for", "appname", ",", "appclass", "in", "self", ".", "Apps", ".", "items", "(", ")", ":", "if", "with_module", "and", "with_module"...
Invokes module(s) API NB: this is the PUBLIC method @returns apps_dict
[ "Invokes", "module", "(", "s", ")", "API", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L511-L561
tilde-lab/tilde
tilde/core/api.py
API.save
def save(self, calc, session): ''' Saves tilde_obj into the database NB: this is the PUBLIC method @returns checksum, error ''' checksum = calc.get_checksum() try: existing_calc = session.query(model.Calculation).filter(model.Calculation.checksum == c...
python
def save(self, calc, session): ''' Saves tilde_obj into the database NB: this is the PUBLIC method @returns checksum, error ''' checksum = calc.get_checksum() try: existing_calc = session.query(model.Calculation).filter(model.Calculation.checksum == c...
[ "def", "save", "(", "self", ",", "calc", ",", "session", ")", ":", "checksum", "=", "calc", ".", "get_checksum", "(", ")", "try", ":", "existing_calc", "=", "session", ".", "query", "(", "model", ".", "Calculation", ")", ".", "filter", "(", "model", ...
Saves tilde_obj into the database NB: this is the PUBLIC method @returns checksum, error
[ "Saves", "tilde_obj", "into", "the", "database", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L563-L706
tilde-lab/tilde
tilde/core/api.py
API.purge
def purge(self, session, checksum): ''' Deletes calc entry by checksum entirely from the database NB source files on disk are not deleted NB: this is the PUBLIC method @returns error ''' C = session.query(model.Calculation).get(checksum) if not C: ...
python
def purge(self, session, checksum): ''' Deletes calc entry by checksum entirely from the database NB source files on disk are not deleted NB: this is the PUBLIC method @returns error ''' C = session.query(model.Calculation).get(checksum) if not C: ...
[ "def", "purge", "(", "self", ",", "session", ",", "checksum", ")", ":", "C", "=", "session", ".", "query", "(", "model", ".", "Calculation", ")", ".", "get", "(", "checksum", ")", "if", "not", "C", ":", "return", "'Calculation does not exist!'", "# datas...
Deletes calc entry by checksum entirely from the database NB source files on disk are not deleted NB: this is the PUBLIC method @returns error
[ "Deletes", "calc", "entry", "by", "checksum", "entirely", "from", "the", "database", "NB", "source", "files", "on", "disk", "are", "not", "deleted", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L708-L787
tilde-lab/tilde
tilde/core/api.py
API.merge
def merge(self, session, checksums, title): ''' Merges calcs into a new calc called DATASET NB: this is the PUBLIC method @returns DATASET, error ''' calc = Output(calcset=checksums) cur_depth = 0 for nested_depth, grid_item, download_size in session.que...
python
def merge(self, session, checksums, title): ''' Merges calcs into a new calc called DATASET NB: this is the PUBLIC method @returns DATASET, error ''' calc = Output(calcset=checksums) cur_depth = 0 for nested_depth, grid_item, download_size in session.que...
[ "def", "merge", "(", "self", ",", "session", ",", "checksums", ",", "title", ")", ":", "calc", "=", "Output", "(", "calcset", "=", "checksums", ")", "cur_depth", "=", "0", "for", "nested_depth", ",", "grid_item", ",", "download_size", "in", "session", "....
Merges calcs into a new calc called DATASET NB: this is the PUBLIC method @returns DATASET, error
[ "Merges", "calcs", "into", "a", "new", "calc", "called", "DATASET", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L789-L828
tilde-lab/tilde
tilde/core/api.py
API.augment
def augment(self, session, parent, addendum): ''' Augments a DATASET with some calcs NB: this is the PUBLIC method @returns error ''' parent_calc = session.query(model.Calculation).get(parent) if not parent_calc or not parent_calc.siblings_count: retur...
python
def augment(self, session, parent, addendum): ''' Augments a DATASET with some calcs NB: this is the PUBLIC method @returns error ''' parent_calc = session.query(model.Calculation).get(parent) if not parent_calc or not parent_calc.siblings_count: retur...
[ "def", "augment", "(", "self", ",", "session", ",", "parent", ",", "addendum", ")", ":", "parent_calc", "=", "session", ".", "query", "(", "model", ".", "Calculation", ")", ".", "get", "(", "parent", ")", "if", "not", "parent_calc", "or", "not", "paren...
Augments a DATASET with some calcs NB: this is the PUBLIC method @returns error
[ "Augments", "a", "DATASET", "with", "some", "calcs", "NB", ":", "this", "is", "the", "PUBLIC", "method" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/api.py#L830-L931
commontk/ctk-cli
ctk_cli/execution.py
isCLIExecutable
def isCLIExecutable(filePath): """Test whether given `filePath` is an executable. Does not really check whether the executable is a CLI (e.g. whether it supports --xml), but can be used to filter out non-executables within a directory with CLI modules. """ # see qSlicerUtils::isCLIExecutable ...
python
def isCLIExecutable(filePath): """Test whether given `filePath` is an executable. Does not really check whether the executable is a CLI (e.g. whether it supports --xml), but can be used to filter out non-executables within a directory with CLI modules. """ # see qSlicerUtils::isCLIExecutable ...
[ "def", "isCLIExecutable", "(", "filePath", ")", ":", "# see qSlicerUtils::isCLIExecutable", "# e.g. https://github.com/Slicer/Slicer/blob/master/Base/QTCore/qSlicerUtils.cxx", "if", "not", "os", ".", "path", ".", "isfile", "(", "filePath", ")", ":", "return", "False", "if",...
Test whether given `filePath` is an executable. Does not really check whether the executable is a CLI (e.g. whether it supports --xml), but can be used to filter out non-executables within a directory with CLI modules.
[ "Test", "whether", "given", "filePath", "is", "an", "executable", ".", "Does", "not", "really", "check", "whether", "the", "executable", "is", "a", "CLI", "(", "e", ".", "g", ".", "whether", "it", "supports", "--", "xml", ")", "but", "can", "be", "used...
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/execution.py#L7-L26
commontk/ctk-cli
ctk_cli/execution.py
listCLIExecutables
def listCLIExecutables(baseDir): """Return list of paths to valid CLI executables within baseDir (non-recursively). This calls `isCLIExecutable()` on all files within `baseDir`.""" return [path for path in glob.glob(os.path.join(os.path.normpath(baseDir), '*')) if isCLIExecutable(path)]
python
def listCLIExecutables(baseDir): """Return list of paths to valid CLI executables within baseDir (non-recursively). This calls `isCLIExecutable()` on all files within `baseDir`.""" return [path for path in glob.glob(os.path.join(os.path.normpath(baseDir), '*')) if isCLIExecutable(path)]
[ "def", "listCLIExecutables", "(", "baseDir", ")", ":", "return", "[", "path", "for", "path", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "normpath", "(", "baseDir", ")", ",", "'*'", ")", ")", "if", ...
Return list of paths to valid CLI executables within baseDir (non-recursively). This calls `isCLIExecutable()` on all files within `baseDir`.
[ "Return", "list", "of", "paths", "to", "valid", "CLI", "executables", "within", "baseDir", "(", "non", "-", "recursively", ")", ".", "This", "calls", "isCLIExecutable", "()", "on", "all", "files", "within", "baseDir", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/execution.py#L29-L33
commontk/ctk-cli
ctk_cli/execution.py
popenCLIExecutable
def popenCLIExecutable(command, **kwargs): """Wrapper around subprocess.Popen constructor that tries to detect Slicer CLI modules and launches them through the Slicer launcher in order to prevent potential DLL dependency issues. Any kwargs are passed on to subprocess.Popen(). If you ever try to us...
python
def popenCLIExecutable(command, **kwargs): """Wrapper around subprocess.Popen constructor that tries to detect Slicer CLI modules and launches them through the Slicer launcher in order to prevent potential DLL dependency issues. Any kwargs are passed on to subprocess.Popen(). If you ever try to us...
[ "def", "popenCLIExecutable", "(", "command", ",", "*", "*", "kwargs", ")", ":", "cliExecutable", "=", "command", "[", "0", "]", "# hack (at least, this does not scale to other module sources):", "# detect Slicer modules and run through wrapper script setting up", "# appropriate r...
Wrapper around subprocess.Popen constructor that tries to detect Slicer CLI modules and launches them through the Slicer launcher in order to prevent potential DLL dependency issues. Any kwargs are passed on to subprocess.Popen(). If you ever try to use this function to run a CLI, you might want to ...
[ "Wrapper", "around", "subprocess", ".", "Popen", "constructor", "that", "tries", "to", "detect", "Slicer", "CLI", "modules", "and", "launches", "them", "through", "the", "Slicer", "launcher", "in", "order", "to", "prevent", "potential", "DLL", "dependency", "iss...
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/execution.py#L41-L69
commontk/ctk-cli
ctk_cli/execution.py
getXMLDescription
def getXMLDescription(cliExecutable, **kwargs): """Call given cliExecutable with --xml and return xml ElementTree representation of standard output. Any kwargs are passed on to subprocess.Popen() (via popenCLIExecutable()).""" command = [cliExecutable, '--xml'] stdout, stdoutFilename = tempfi...
python
def getXMLDescription(cliExecutable, **kwargs): """Call given cliExecutable with --xml and return xml ElementTree representation of standard output. Any kwargs are passed on to subprocess.Popen() (via popenCLIExecutable()).""" command = [cliExecutable, '--xml'] stdout, stdoutFilename = tempfi...
[ "def", "getXMLDescription", "(", "cliExecutable", ",", "*", "*", "kwargs", ")", ":", "command", "=", "[", "cliExecutable", ",", "'--xml'", "]", "stdout", ",", "stdoutFilename", "=", "tempfile", ".", "mkstemp", "(", "'.stdout'", ")", "stderr", ",", "stderrFil...
Call given cliExecutable with --xml and return xml ElementTree representation of standard output. Any kwargs are passed on to subprocess.Popen() (via popenCLIExecutable()).
[ "Call", "given", "cliExecutable", "with", "--", "xml", "and", "return", "xml", "ElementTree", "representation", "of", "standard", "output", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/execution.py#L72-L96
alexwlchan/specktre
src/specktre/utils.py
_candidate_filenames
def _candidate_filenames(): """Generates filenames of the form 'specktre_123AB.png'. The random noise is five characters long, which allows for 62^5 = 916 million possible filenames. """ while True: random_stub = ''.join([ random.choice(string.ascii_letters + string.digits) ...
python
def _candidate_filenames(): """Generates filenames of the form 'specktre_123AB.png'. The random noise is five characters long, which allows for 62^5 = 916 million possible filenames. """ while True: random_stub = ''.join([ random.choice(string.ascii_letters + string.digits) ...
[ "def", "_candidate_filenames", "(", ")", ":", "while", "True", ":", "random_stub", "=", "''", ".", "join", "(", "[", "random", ".", "choice", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ")", "for", "_", "in", "range", "(", "5", ...
Generates filenames of the form 'specktre_123AB.png'. The random noise is five characters long, which allows for 62^5 = 916 million possible filenames.
[ "Generates", "filenames", "of", "the", "form", "specktre_123AB", ".", "png", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/src/specktre/utils.py#L9-L21
alexwlchan/specktre
examples/draw_tilings.py
draw_tiling
def draw_tiling(coord_generator, filename): """Given a coordinate generator and a filename, render those coordinates in a new image and save them to the file.""" im = Image.new('L', size=(CANVAS_WIDTH, CANVAS_HEIGHT)) for shape in coord_generator(CANVAS_WIDTH, CANVAS_HEIGHT): ImageDraw.Draw(im)....
python
def draw_tiling(coord_generator, filename): """Given a coordinate generator and a filename, render those coordinates in a new image and save them to the file.""" im = Image.new('L', size=(CANVAS_WIDTH, CANVAS_HEIGHT)) for shape in coord_generator(CANVAS_WIDTH, CANVAS_HEIGHT): ImageDraw.Draw(im)....
[ "def", "draw_tiling", "(", "coord_generator", ",", "filename", ")", ":", "im", "=", "Image", ".", "new", "(", "'L'", ",", "size", "=", "(", "CANVAS_WIDTH", ",", "CANVAS_HEIGHT", ")", ")", "for", "shape", "in", "coord_generator", "(", "CANVAS_WIDTH", ",", ...
Given a coordinate generator and a filename, render those coordinates in a new image and save them to the file.
[ "Given", "a", "coordinate", "generator", "and", "a", "filename", "render", "those", "coordinates", "in", "a", "new", "image", "and", "save", "them", "to", "the", "file", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/examples/draw_tilings.py#L20-L26
abn/cafeteria
cafeteria/logging/trace.py
trace
def trace(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'TRACE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.trace("Houston, we have a %s", "thorny problem", exc_info=1) """ if self.isEnabledFor(TRACE): self._log...
python
def trace(self, msg, *args, **kwargs): """ Log 'msg % args' with severity 'TRACE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.trace("Houston, we have a %s", "thorny problem", exc_info=1) """ if self.isEnabledFor(TRACE): self._log...
[ "def", "trace", "(", "self", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "isEnabledFor", "(", "TRACE", ")", ":", "self", ".", "_log", "(", "TRACE", ",", "msg", ",", "args", ",", "*", "*", "kwargs", ")" ]
Log 'msg % args' with severity 'TRACE'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.trace("Houston, we have a %s", "thorny problem", exc_info=1)
[ "Log", "msg", "%", "args", "with", "severity", "TRACE", "." ]
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/logging/trace.py#L8-L18
myth/pepper8
pepper8/models.py
ResultContainer.add_error
def add_error(self, code, line, char, description): """ Registers an error for this container with code on line at char. :param code: The PEP 8 error code :param line: The line number of the reported error :param char: Line location of first offending character :param des...
python
def add_error(self, code, line, char, description): """ Registers an error for this container with code on line at char. :param code: The PEP 8 error code :param line: The line number of the reported error :param char: Line location of first offending character :param des...
[ "def", "add_error", "(", "self", ",", "code", ",", "line", ",", "char", ",", "description", ")", ":", "if", "code", "not", "in", "self", ".", "violations", ":", "self", ".", "violations", "[", "code", "]", "=", "0", "self", ".", "violations", "[", ...
Registers an error for this container with code on line at char. :param code: The PEP 8 error code :param line: The line number of the reported error :param char: Line location of first offending character :param description: The human readable description of the thrown error/warning
[ "Registers", "an", "error", "for", "this", "container", "with", "code", "on", "line", "at", "char", ".", ":", "param", "code", ":", "The", "PEP", "8", "error", "code", ":", "param", "line", ":", "The", "line", "number", "of", "the", "reported", "error"...
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/models.py#L16-L28
abn/cafeteria
cafeteria/utilities.py
listify
def listify(arg): """ Simple utility method to ensure an argument provided is a list. If the provider argument is not an instance of `list`, then we return [arg], else arg is returned. :type arg: list :rtype: list """ if isinstance(arg, (set, tuple)): # if it is a set or tuple m...
python
def listify(arg): """ Simple utility method to ensure an argument provided is a list. If the provider argument is not an instance of `list`, then we return [arg], else arg is returned. :type arg: list :rtype: list """ if isinstance(arg, (set, tuple)): # if it is a set or tuple m...
[ "def", "listify", "(", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "(", "set", ",", "tuple", ")", ")", ":", "# if it is a set or tuple make it a list", "return", "list", "(", "arg", ")", "if", "not", "isinstance", "(", "arg", ",", "list", ")", ...
Simple utility method to ensure an argument provided is a list. If the provider argument is not an instance of `list`, then we return [arg], else arg is returned. :type arg: list :rtype: list
[ "Simple", "utility", "method", "to", "ensure", "an", "argument", "provided", "is", "a", "list", ".", "If", "the", "provider", "argument", "is", "not", "an", "instance", "of", "list", "then", "we", "return", "[", "arg", "]", "else", "arg", "is", "returned...
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/utilities.py#L7-L21
abn/cafeteria
cafeteria/utilities.py
resolve_setting
def resolve_setting(default, arg_value=None, env_var=None, config_value=None): """ Resolves a setting for a configuration option. The winning value is chosen from multiple methods of configuration, in the following order of priority (top first): - Explicitly passed argument - Environment variab...
python
def resolve_setting(default, arg_value=None, env_var=None, config_value=None): """ Resolves a setting for a configuration option. The winning value is chosen from multiple methods of configuration, in the following order of priority (top first): - Explicitly passed argument - Environment variab...
[ "def", "resolve_setting", "(", "default", ",", "arg_value", "=", "None", ",", "env_var", "=", "None", ",", "config_value", "=", "None", ")", ":", "if", "arg_value", "is", "not", "None", ":", "return", "arg_value", "else", ":", "env_value", "=", "getenv", ...
Resolves a setting for a configuration option. The winning value is chosen from multiple methods of configuration, in the following order of priority (top first): - Explicitly passed argument - Environment variable - Configuration file entry - Default :param arg_value: Explicitly passed va...
[ "Resolves", "a", "setting", "for", "a", "configuration", "option", ".", "The", "winning", "value", "is", "chosen", "from", "multiple", "methods", "of", "configuration", "in", "the", "following", "order", "of", "priority", "(", "top", "first", ")", ":" ]
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/utilities.py#L34-L62
abn/cafeteria
cafeteria/patterns/borg.py
BorgStateManager.get_state
def get_state(cls, clz): """ Retrieve the state of a given Class. :param clz: types.ClassType :return: Class state. :rtype: dict """ if clz not in cls.__shared_state: cls.__shared_state[clz] = ( clz.init_state() if hasattr(clz, "init_s...
python
def get_state(cls, clz): """ Retrieve the state of a given Class. :param clz: types.ClassType :return: Class state. :rtype: dict """ if clz not in cls.__shared_state: cls.__shared_state[clz] = ( clz.init_state() if hasattr(clz, "init_s...
[ "def", "get_state", "(", "cls", ",", "clz", ")", ":", "if", "clz", "not", "in", "cls", ".", "__shared_state", ":", "cls", ".", "__shared_state", "[", "clz", "]", "=", "(", "clz", ".", "init_state", "(", ")", "if", "hasattr", "(", "clz", ",", "\"ini...
Retrieve the state of a given Class. :param clz: types.ClassType :return: Class state. :rtype: dict
[ "Retrieve", "the", "state", "of", "a", "given", "Class", "." ]
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/patterns/borg.py#L19-L31
tilde-lab/tilde
tilde/core/orm_tools.py
_unique
def _unique(session, cls, queryfunc, constructor, arg, kw): ''' https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/UniqueObject Checks if ORM entity exists according to criteria, if yes, returns it, if no, creates ''' with session.no_autoflush: q = session.query(cls) q = q...
python
def _unique(session, cls, queryfunc, constructor, arg, kw): ''' https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/UniqueObject Checks if ORM entity exists according to criteria, if yes, returns it, if no, creates ''' with session.no_autoflush: q = session.query(cls) q = q...
[ "def", "_unique", "(", "session", ",", "cls", ",", "queryfunc", ",", "constructor", ",", "arg", ",", "kw", ")", ":", "with", "session", ".", "no_autoflush", ":", "q", "=", "session", ".", "query", "(", "cls", ")", "q", "=", "queryfunc", "(", "q", "...
https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/UniqueObject Checks if ORM entity exists according to criteria, if yes, returns it, if no, creates
[ "https", ":", "//", "bitbucket", ".", "org", "/", "zzzeek", "/", "sqlalchemy", "/", "wiki", "/", "UsageRecipes", "/", "UniqueObject", "Checks", "if", "ORM", "entity", "exists", "according", "to", "criteria", "if", "yes", "returns", "it", "if", "no", "creat...
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/orm_tools.py#L19-L32
tilde-lab/tilde
tilde/core/orm_tools.py
_unique_todict
def _unique_todict(session, cls, queryfunc, arg, kw): ''' Checks if ORM entity exists according to criteria, if yes, returns it, if no, returns dict representation (required for further DB replication and syncing) ''' q = session.query(cls) q = queryfunc(q, *arg, **kw) obj = q.first() ...
python
def _unique_todict(session, cls, queryfunc, arg, kw): ''' Checks if ORM entity exists according to criteria, if yes, returns it, if no, returns dict representation (required for further DB replication and syncing) ''' q = session.query(cls) q = queryfunc(q, *arg, **kw) obj = q.first() ...
[ "def", "_unique_todict", "(", "session", ",", "cls", ",", "queryfunc", ",", "arg", ",", "kw", ")", ":", "q", "=", "session", ".", "query", "(", "cls", ")", "q", "=", "queryfunc", "(", "q", ",", "*", "arg", ",", "*", "*", "kw", ")", "obj", "=", ...
Checks if ORM entity exists according to criteria, if yes, returns it, if no, returns dict representation (required for further DB replication and syncing)
[ "Checks", "if", "ORM", "entity", "exists", "according", "to", "criteria", "if", "yes", "returns", "it", "if", "no", "returns", "dict", "representation", "(", "required", "for", "further", "DB", "replication", "and", "syncing", ")" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/orm_tools.py#L34-L46
oscarlazoarjona/fast
build/lib/fast/symbolic.py
define_density_matrix
def define_density_matrix(Ne, explicitly_hermitian=False, normalized=False, variables=None): r"""Return a symbolic density matrix. The arguments are Ne (integer): The number of atomic states. explicitly_hermitian (boolean): Whether to make $\rho_{ij}=\bar{\rho...
python
def define_density_matrix(Ne, explicitly_hermitian=False, normalized=False, variables=None): r"""Return a symbolic density matrix. The arguments are Ne (integer): The number of atomic states. explicitly_hermitian (boolean): Whether to make $\rho_{ij}=\bar{\rho...
[ "def", "define_density_matrix", "(", "Ne", ",", "explicitly_hermitian", "=", "False", ",", "normalized", "=", "False", ",", "variables", "=", "None", ")", ":", "if", "Ne", ">", "9", ":", "comma", "=", "\",\"", "name", "=", "r\"\\rho\"", "open_brace", "=", ...
r"""Return a symbolic density matrix. The arguments are Ne (integer): The number of atomic states. explicitly_hermitian (boolean): Whether to make $\rho_{ij}=\bar{\rho}_{ij}$ for $i<j$ normalized (boolean): Whether to make $\rho_{11}=1-\sum_{i>1} \rho_{ii}$ A very simple e...
[ "r", "Return", "a", "symbolic", "density", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/symbolic.py#L72-L150
oscarlazoarjona/fast
build/lib/fast/symbolic.py
define_laser_variables
def define_laser_variables(Nl, real_amplitudes=False, variables=None): r"""Return the amplitudes and frequencies of Nl fields. >>> E0, omega_laser = define_laser_variables(2) >>> E0, omega_laser ([E_0^1, E_0^2], [varpi_1, varpi_2]) The amplitudes are complex by default: >>> conjugate(E0[0]) ...
python
def define_laser_variables(Nl, real_amplitudes=False, variables=None): r"""Return the amplitudes and frequencies of Nl fields. >>> E0, omega_laser = define_laser_variables(2) >>> E0, omega_laser ([E_0^1, E_0^2], [varpi_1, varpi_2]) The amplitudes are complex by default: >>> conjugate(E0[0]) ...
[ "def", "define_laser_variables", "(", "Nl", ",", "real_amplitudes", "=", "False", ",", "variables", "=", "None", ")", ":", "if", "variables", "is", "None", ":", "E0", "=", "[", "Symbol", "(", "r\"E_0^\"", "+", "str", "(", "l", "+", "1", ")", ",", "re...
r"""Return the amplitudes and frequencies of Nl fields. >>> E0, omega_laser = define_laser_variables(2) >>> E0, omega_laser ([E_0^1, E_0^2], [varpi_1, varpi_2]) The amplitudes are complex by default: >>> conjugate(E0[0]) conjugate(E_0^1) But they can optionally be made real: >>> E0, o...
[ "r", "Return", "the", "amplitudes", "and", "frequencies", "of", "Nl", "fields", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/symbolic.py#L153-L186
oscarlazoarjona/fast
build/lib/fast/symbolic.py
polarization_vector
def polarization_vector(phi, theta, alpha, beta, p): r"""This function returns a unitary vector describing the polarization of plane waves. It recieves as arguments: phi .- The spherical coordinates azimuthal angle of the wave vector k. theta .- The spherical coordinates polar angle of the wave vecto...
python
def polarization_vector(phi, theta, alpha, beta, p): r"""This function returns a unitary vector describing the polarization of plane waves. It recieves as arguments: phi .- The spherical coordinates azimuthal angle of the wave vector k. theta .- The spherical coordinates polar angle of the wave vecto...
[ "def", "polarization_vector", "(", "phi", ",", "theta", ",", "alpha", ",", "beta", ",", "p", ")", ":", "epsilon", "=", "Matrix", "(", "[", "cos", "(", "2", "*", "beta", ")", ",", "p", "*", "I", "*", "sin", "(", "2", "*", "beta", ")", ",", "0"...
r"""This function returns a unitary vector describing the polarization of plane waves. It recieves as arguments: phi .- The spherical coordinates azimuthal angle of the wave vector k. theta .- The spherical coordinates polar angle of the wave vector k. alpha .- The rotation of a half-wave plate. ...
[ "r", "This", "function", "returns", "a", "unitary", "vector", "describing", "the", "polarization", "of", "plane", "waves", ".", "It", "recieves", "as", "arguments", ":" ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/symbolic.py#L189-L251
oscarlazoarjona/fast
build/lib/fast/symbolic.py
lindblad_operator
def lindblad_operator(A, rho): r"""This function returns the action of a Lindblad operator A on a density matrix rho. This is defined as : L(A,rho) = A*rho*A.adjoint() - (A.adjoint()*A*rho + rho*A.adjoint()*A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operator( ketbra(1,...
python
def lindblad_operator(A, rho): r"""This function returns the action of a Lindblad operator A on a density matrix rho. This is defined as : L(A,rho) = A*rho*A.adjoint() - (A.adjoint()*A*rho + rho*A.adjoint()*A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operator( ketbra(1,...
[ "def", "lindblad_operator", "(", "A", ",", "rho", ")", ":", "return", "A", "*", "rho", "*", "A", ".", "adjoint", "(", ")", "-", "(", "A", ".", "adjoint", "(", ")", "*", "A", "*", "rho", "+", "rho", "*", "A", ".", "adjoint", "(", ")", "*", "...
r"""This function returns the action of a Lindblad operator A on a density matrix rho. This is defined as : L(A,rho) = A*rho*A.adjoint() - (A.adjoint()*A*rho + rho*A.adjoint()*A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operator( ketbra(1,2,3) ,rho ) Matrix([ [ rh...
[ "r", "This", "function", "returns", "the", "action", "of", "a", "Lindblad", "operator", "A", "on", "a", "density", "matrix", "rho", ".", "This", "is", "defined", "as", ":", "L", "(", "A", "rho", ")", "=", "A", "*", "rho", "*", "A", ".", "adjoint", ...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/symbolic.py#L551-L565
deployed/django-emailtemplates
emailtemplates/helpers.py
mass_mailing_recipients
def mass_mailing_recipients(): """ Returns iterable of all mass email recipients. Default behavior will be to return list of all active users' emails. This can be changed by providing callback in settings return some other list of users, when user emails are stored in many, non default models. T...
python
def mass_mailing_recipients(): """ Returns iterable of all mass email recipients. Default behavior will be to return list of all active users' emails. This can be changed by providing callback in settings return some other list of users, when user emails are stored in many, non default models. T...
[ "def", "mass_mailing_recipients", "(", ")", ":", "if", "hasattr", "(", "settings", ",", "'MASS_EMAIL_RECIPIENTS'", ")", ":", "callback_name", "=", "settings", ".", "MASS_EMAIL_RECIPIENTS", ".", "split", "(", "'.'", ")", "module_name", "=", "'.'", ".", "join", ...
Returns iterable of all mass email recipients. Default behavior will be to return list of all active users' emails. This can be changed by providing callback in settings return some other list of users, when user emails are stored in many, non default models. To accomplish that add constant MASS_EMAIL_R...
[ "Returns", "iterable", "of", "all", "mass", "email", "recipients", ".", "Default", "behavior", "will", "be", "to", "return", "list", "of", "all", "active", "users", "emails", ".", "This", "can", "be", "changed", "by", "providing", "callback", "in", "settings...
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/helpers.py#L47-L69
oscarlazoarjona/fast
fast/graphic.py
complex_matrix_plot
def complex_matrix_plot(A, logA=False, normalize=False, plot=True, **kwds): r"""A function to plot complex matrices.""" N = len(A[0]) if logA: Anew = [] for i in range(N): row = [] for j in range(N): if A[i][j] != 0: row +=...
python
def complex_matrix_plot(A, logA=False, normalize=False, plot=True, **kwds): r"""A function to plot complex matrices.""" N = len(A[0]) if logA: Anew = [] for i in range(N): row = [] for j in range(N): if A[i][j] != 0: row +=...
[ "def", "complex_matrix_plot", "(", "A", ",", "logA", "=", "False", ",", "normalize", "=", "False", ",", "plot", "=", "True", ",", "*", "*", "kwds", ")", ":", "N", "=", "len", "(", "A", "[", "0", "]", ")", "if", "logA", ":", "Anew", "=", "[", ...
r"""A function to plot complex matrices.
[ "r", "A", "function", "to", "plot", "complex", "matrices", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L64-L109
oscarlazoarjona/fast
fast/graphic.py
bar_chart_mf
def bar_chart_mf(data, path_name): """Make a bar chart for data on MF quantities.""" N = len(data) ind = np.arange(N) # the x locations for the groups width = 0.8 # the width of the bars fig, ax = pyplot.subplots() rects1 = ax.bar(ind, data, width, color='g') # add some t...
python
def bar_chart_mf(data, path_name): """Make a bar chart for data on MF quantities.""" N = len(data) ind = np.arange(N) # the x locations for the groups width = 0.8 # the width of the bars fig, ax = pyplot.subplots() rects1 = ax.bar(ind, data, width, color='g') # add some t...
[ "def", "bar_chart_mf", "(", "data", ",", "path_name", ")", ":", "N", "=", "len", "(", "data", ")", "ind", "=", "np", ".", "arange", "(", "N", ")", "# the x locations for the groups\r", "width", "=", "0.8", "# the width of the bars\r", "fig", ",", "ax", "="...
Make a bar chart for data on MF quantities.
[ "Make", "a", "bar", "chart", "for", "data", "on", "MF", "quantities", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L476-L499
oscarlazoarjona/fast
fast/graphic.py
draw_plane_wave_3d
def draw_plane_wave_3d(ax, beam, dist_to_center=0): """Draw the polarization of a plane wave.""" Ex = []; Ey = []; Ez = [] k = [cos(beam.phi)*sin(beam.theta), sin(beam.phi)*sin(beam.theta), cos(beam.theta)] kx, ky, kz = k Nt = 1000 tstep = 7*pi/4/(Nt-1) alpha...
python
def draw_plane_wave_3d(ax, beam, dist_to_center=0): """Draw the polarization of a plane wave.""" Ex = []; Ey = []; Ez = [] k = [cos(beam.phi)*sin(beam.theta), sin(beam.phi)*sin(beam.theta), cos(beam.theta)] kx, ky, kz = k Nt = 1000 tstep = 7*pi/4/(Nt-1) alpha...
[ "def", "draw_plane_wave_3d", "(", "ax", ",", "beam", ",", "dist_to_center", "=", "0", ")", ":", "Ex", "=", "[", "]", "Ey", "=", "[", "]", "Ez", "=", "[", "]", "k", "=", "[", "cos", "(", "beam", ".", "phi", ")", "*", "sin", "(", "beam", ".", ...
Draw the polarization of a plane wave.
[ "Draw", "the", "polarization", "of", "a", "plane", "wave", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L528-L574
oscarlazoarjona/fast
fast/graphic.py
draw_lasers_3d
def draw_lasers_3d(ax, lasers, name=None, distances=None, lim=None): """Draw MOT lasers in 3d.""" if distances is None: distances = [1.0 for i in range(len(lasers))] for i in range(len(lasers)): if type(lasers[i]) == PlaneWave: draw_plane_wave_3d(ax, lasers[i], distances[i]) ...
python
def draw_lasers_3d(ax, lasers, name=None, distances=None, lim=None): """Draw MOT lasers in 3d.""" if distances is None: distances = [1.0 for i in range(len(lasers))] for i in range(len(lasers)): if type(lasers[i]) == PlaneWave: draw_plane_wave_3d(ax, lasers[i], distances[i]) ...
[ "def", "draw_lasers_3d", "(", "ax", ",", "lasers", ",", "name", "=", "None", ",", "distances", "=", "None", ",", "lim", "=", "None", ")", ":", "if", "distances", "is", "None", ":", "distances", "=", "[", "1.0", "for", "i", "in", "range", "(", "len"...
Draw MOT lasers in 3d.
[ "Draw", "MOT", "lasers", "in", "3d", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L583-L604
oscarlazoarjona/fast
fast/graphic.py
plot_populations
def plot_populations(path, name, Ne, states=None, filename='a.png', fontsize=12, absolute_frequency=True, save_path='', use_netcdf=True): r"""Plot the populations of a density matrix.""" pyplot.close("all") dat = read_result(path, name, N=Ne, use_netcdf=use_net...
python
def plot_populations(path, name, Ne, states=None, filename='a.png', fontsize=12, absolute_frequency=True, save_path='', use_netcdf=True): r"""Plot the populations of a density matrix.""" pyplot.close("all") dat = read_result(path, name, N=Ne, use_netcdf=use_net...
[ "def", "plot_populations", "(", "path", ",", "name", ",", "Ne", ",", "states", "=", "None", ",", "filename", "=", "'a.png'", ",", "fontsize", "=", "12", ",", "absolute_frequency", "=", "True", ",", "save_path", "=", "''", ",", "use_netcdf", "=", "True", ...
r"""Plot the populations of a density matrix.
[ "r", "Plot", "the", "populations", "of", "a", "density", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L624-L729
oscarlazoarjona/fast
fast/graphic.py
rotate_and_traslate
def rotate_and_traslate(cur, alpha, v0): r"""Rotate and translate a curve.""" if len(cur) > 2 or (type(cur[0][0]) in [list, tuple]): cur_list = cur[:] for i in range(len(cur_list)): curi = cur_list[i] curi = rotate_and_traslate(curi, alpha, v0) cur_list...
python
def rotate_and_traslate(cur, alpha, v0): r"""Rotate and translate a curve.""" if len(cur) > 2 or (type(cur[0][0]) in [list, tuple]): cur_list = cur[:] for i in range(len(cur_list)): curi = cur_list[i] curi = rotate_and_traslate(curi, alpha, v0) cur_list...
[ "def", "rotate_and_traslate", "(", "cur", ",", "alpha", ",", "v0", ")", ":", "if", "len", "(", "cur", ")", ">", "2", "or", "(", "type", "(", "cur", "[", "0", "]", "[", "0", "]", ")", "in", "[", "list", ",", "tuple", "]", ")", ":", "cur_list",...
r"""Rotate and translate a curve.
[ "r", "Rotate", "and", "translate", "a", "curve", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L736-L755
oscarlazoarjona/fast
fast/graphic.py
mirror
def mirror(ax, p0, alpha=0, size=2.54, width=0.5, format=None): r"""Draw a mirror.""" if format is None: format = 'k-' x0 = [size/2, -size/2, -size/2, size/2, size/2] y0 = [0, 0, -width, -width, 0] x1 = [size/2, size/2-width]; y1 = [0, -width] x2 = [-size/2+width, -size/2]; y2 = [0, -w...
python
def mirror(ax, p0, alpha=0, size=2.54, width=0.5, format=None): r"""Draw a mirror.""" if format is None: format = 'k-' x0 = [size/2, -size/2, -size/2, size/2, size/2] y0 = [0, 0, -width, -width, 0] x1 = [size/2, size/2-width]; y1 = [0, -width] x2 = [-size/2+width, -size/2]; y2 = [0, -w...
[ "def", "mirror", "(", "ax", ",", "p0", ",", "alpha", "=", "0", ",", "size", "=", "2.54", ",", "width", "=", "0.5", ",", "format", "=", "None", ")", ":", "if", "format", "is", "None", ":", "format", "=", "'k-'", "x0", "=", "[", "size", "/", "2...
r"""Draw a mirror.
[ "r", "Draw", "a", "mirror", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L758-L771
oscarlazoarjona/fast
fast/graphic.py
eye
def eye(ax, p0, size=1.0, alpha=0, format=None, **kwds): r"""Draw an eye.""" if format is None: format = 'k-' N = 100 ang0 = pi-3*pi/16; angf = pi+3*pi/16 angstep = (angf-ang0)/(N-1) x1 = [size*(cos(i*angstep+ang0)+1) for i in range(N)] y1 = [size*sin(i*angstep+ang0) for i in range(...
python
def eye(ax, p0, size=1.0, alpha=0, format=None, **kwds): r"""Draw an eye.""" if format is None: format = 'k-' N = 100 ang0 = pi-3*pi/16; angf = pi+3*pi/16 angstep = (angf-ang0)/(N-1) x1 = [size*(cos(i*angstep+ang0)+1) for i in range(N)] y1 = [size*sin(i*angstep+ang0) for i in range(...
[ "def", "eye", "(", "ax", ",", "p0", ",", "size", "=", "1.0", ",", "alpha", "=", "0", ",", "format", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "format", "=", "'k-'", "N", "=", "100", "ang0", "=", "pi", ...
r"""Draw an eye.
[ "r", "Draw", "an", "eye", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L853-L877
oscarlazoarjona/fast
fast/graphic.py
beam_splitter
def beam_splitter(ax, p0, size=2.54, alpha=0, format=None, **kwds): r"""Draw a beam splitter.""" if format is None: format = 'k-' a = size/2 x0 = [a, -a, -a, a, a, -a] y0 = [a, a, -a, -a, a, -a] cur_list = [(x0, y0)] cur_list = rotate_and_traslate(cur_list, alpha, p0) for cur...
python
def beam_splitter(ax, p0, size=2.54, alpha=0, format=None, **kwds): r"""Draw a beam splitter.""" if format is None: format = 'k-' a = size/2 x0 = [a, -a, -a, a, a, -a] y0 = [a, a, -a, -a, a, -a] cur_list = [(x0, y0)] cur_list = rotate_and_traslate(cur_list, alpha, p0) for cur...
[ "def", "beam_splitter", "(", "ax", ",", "p0", ",", "size", "=", "2.54", ",", "alpha", "=", "0", ",", "format", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "format", "=", "'k-'", "a", "=", "size", "/", "2", ...
r"""Draw a beam splitter.
[ "r", "Draw", "a", "beam", "splitter", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L880-L890
oscarlazoarjona/fast
fast/graphic.py
draw_beam
def draw_beam(ax, p1, p2, width=0, beta1=None, beta2=None, format=None, **kwds): r"""Draw a laser beam.""" if format is None: format = 'k-' if width == 0: x0 = [p1[0], p2[0]] y0 = [p1[1], p2[1]] ax.plot(x0, y0, format, **kwds) else: a = width/2 ...
python
def draw_beam(ax, p1, p2, width=0, beta1=None, beta2=None, format=None, **kwds): r"""Draw a laser beam.""" if format is None: format = 'k-' if width == 0: x0 = [p1[0], p2[0]] y0 = [p1[1], p2[1]] ax.plot(x0, y0, format, **kwds) else: a = width/2 ...
[ "def", "draw_beam", "(", "ax", ",", "p1", ",", "p2", ",", "width", "=", "0", ",", "beta1", "=", "None", ",", "beta2", "=", "None", ",", "format", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "format", "=", ...
r"""Draw a laser beam.
[ "r", "Draw", "a", "laser", "beam", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L893-L922
oscarlazoarjona/fast
fast/graphic.py
simple_beam_splitter
def simple_beam_splitter(ax, p0, size=2.54, width=0.1, alpha=0, format=None, **kwds): r"""Draw a simple beam splitter.""" if format is None: format = 'k-' a = size/2 b = width/2 x0 = [a, -a, -a, a, a] y0 = [b, b, -b, -b, b] cur_list = [(x0, y0)] cur_li...
python
def simple_beam_splitter(ax, p0, size=2.54, width=0.1, alpha=0, format=None, **kwds): r"""Draw a simple beam splitter.""" if format is None: format = 'k-' a = size/2 b = width/2 x0 = [a, -a, -a, a, a] y0 = [b, b, -b, -b, b] cur_list = [(x0, y0)] cur_li...
[ "def", "simple_beam_splitter", "(", "ax", ",", "p0", ",", "size", "=", "2.54", ",", "width", "=", "0.1", ",", "alpha", "=", "0", ",", "format", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "format", "=", "'k-'"...
r"""Draw a simple beam splitter.
[ "r", "Draw", "a", "simple", "beam", "splitter", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L925-L937
oscarlazoarjona/fast
fast/graphic.py
draw_arith
def draw_arith(ax, p0, size=1, alpha=0, arith=None, format=None, fontsize=10, **kwds): r"""Draw an arithmetic operator.""" if format is None: format = 'k-' a = size/2.0 x0 = [0, 2.5*a, 0, 0] y0 = [a, 0, -a, a] cur_list = [(x0, y0)] cur_list = rotate_and_traslate(cur_...
python
def draw_arith(ax, p0, size=1, alpha=0, arith=None, format=None, fontsize=10, **kwds): r"""Draw an arithmetic operator.""" if format is None: format = 'k-' a = size/2.0 x0 = [0, 2.5*a, 0, 0] y0 = [a, 0, -a, a] cur_list = [(x0, y0)] cur_list = rotate_and_traslate(cur_...
[ "def", "draw_arith", "(", "ax", ",", "p0", ",", "size", "=", "1", ",", "alpha", "=", "0", ",", "arith", "=", "None", ",", "format", "=", "None", ",", "fontsize", "=", "10", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "...
r"""Draw an arithmetic operator.
[ "r", "Draw", "an", "arithmetic", "operator", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L1018-L1033
oscarlazoarjona/fast
fast/graphic.py
draw_state
def draw_state(ax, p, text='', l=0.5, alignment='left', label_displacement=1.0, fontsize=25, atoms=None, atoms_h=0.125, atoms_size=5, **kwds): r"""Draw a quantum state for energy level diagrams.""" ax.plot([p[0]-l/2.0, p[0]+l/2.0], [p[1], p[1]], color='black', **kwds) if text...
python
def draw_state(ax, p, text='', l=0.5, alignment='left', label_displacement=1.0, fontsize=25, atoms=None, atoms_h=0.125, atoms_size=5, **kwds): r"""Draw a quantum state for energy level diagrams.""" ax.plot([p[0]-l/2.0, p[0]+l/2.0], [p[1], p[1]], color='black', **kwds) if text...
[ "def", "draw_state", "(", "ax", ",", "p", ",", "text", "=", "''", ",", "l", "=", "0.5", ",", "alignment", "=", "'left'", ",", "label_displacement", "=", "1.0", ",", "fontsize", "=", "25", ",", "atoms", "=", "None", ",", "atoms_h", "=", "0.125", ","...
r"""Draw a quantum state for energy level diagrams.
[ "r", "Draw", "a", "quantum", "state", "for", "energy", "level", "diagrams", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L1041-L1061
oscarlazoarjona/fast
fast/graphic.py
draw_multiplet
def draw_multiplet(ax, fine_state, p, hmin, w, fside='right', label_separation=1, label_fontsize=15, fsize=10, deltanu_fontsize=6, proportional=False, text='', text_pos='top', magnetic_lines=False, **kwds): r"""We draw a multiplet.""" # We determine ...
python
def draw_multiplet(ax, fine_state, p, hmin, w, fside='right', label_separation=1, label_fontsize=15, fsize=10, deltanu_fontsize=6, proportional=False, text='', text_pos='top', magnetic_lines=False, **kwds): r"""We draw a multiplet.""" # We determine ...
[ "def", "draw_multiplet", "(", "ax", ",", "fine_state", ",", "p", ",", "hmin", ",", "w", ",", "fside", "=", "'right'", ",", "label_separation", "=", "1", ",", "label_fontsize", "=", "15", ",", "fsize", "=", "10", ",", "deltanu_fontsize", "=", "6", ",", ...
r"""We draw a multiplet.
[ "r", "We", "draw", "a", "multiplet", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L1064-L1145
oscarlazoarjona/fast
fast/graphic.py
decay
def decay(ax, p0, pf, A, n, format=None, **kwds): r"""Draw a spontaneous decay as a wavy line.""" if format is None: format = 'k-' T = sqrt((p0[0]-pf[0])**2+(p0[1]-pf[1])**2) alpha = atan2(pf[1]-p0[1], pf[0]-p0[0]) x = [i*T/400.0 for i in range(401)] y = [A*sin(xi * 2*pi*n/T) for xi in x...
python
def decay(ax, p0, pf, A, n, format=None, **kwds): r"""Draw a spontaneous decay as a wavy line.""" if format is None: format = 'k-' T = sqrt((p0[0]-pf[0])**2+(p0[1]-pf[1])**2) alpha = atan2(pf[1]-p0[1], pf[0]-p0[0]) x = [i*T/400.0 for i in range(401)] y = [A*sin(xi * 2*pi*n/T) for xi in x...
[ "def", "decay", "(", "ax", ",", "p0", ",", "pf", ",", "A", ",", "n", ",", "format", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "format", "is", "None", ":", "format", "=", "'k-'", "T", "=", "sqrt", "(", "(", "p0", "[", "0", "]", "...
r"""Draw a spontaneous decay as a wavy line.
[ "r", "Draw", "a", "spontaneous", "decay", "as", "a", "wavy", "line", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/graphic.py#L1159-L1172
minrk/wurlitzer
wurlitzer.py
dup2
def dup2(a, b, timeout=3): """Like os.dup2, but retry on EBUSY""" dup_err = None # give FDs 3 seconds to not be busy anymore for i in range(int(10 * timeout)): try: return os.dup2(a, b) except OSError as e: dup_err = e if e.errno == errno.EBUSY: ...
python
def dup2(a, b, timeout=3): """Like os.dup2, but retry on EBUSY""" dup_err = None # give FDs 3 seconds to not be busy anymore for i in range(int(10 * timeout)): try: return os.dup2(a, b) except OSError as e: dup_err = e if e.errno == errno.EBUSY: ...
[ "def", "dup2", "(", "a", ",", "b", ",", "timeout", "=", "3", ")", ":", "dup_err", "=", "None", "# give FDs 3 seconds to not be busy anymore", "for", "i", "in", "range", "(", "int", "(", "10", "*", "timeout", ")", ")", ":", "try", ":", "return", "os", ...
Like os.dup2, but retry on EBUSY
[ "Like", "os", ".", "dup2", "but", "retry", "on", "EBUSY" ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L52-L66
minrk/wurlitzer
wurlitzer.py
pipes
def pipes(stdout=PIPE, stderr=PIPE, encoding=_default_encoding): """Capture C-level stdout/stderr in a context manager. The return value for the context manager is (stdout, stderr). Examples -------- >>> with capture() as (stdout, stderr): ... printf("C-level stdout") ... output = std...
python
def pipes(stdout=PIPE, stderr=PIPE, encoding=_default_encoding): """Capture C-level stdout/stderr in a context manager. The return value for the context manager is (stdout, stderr). Examples -------- >>> with capture() as (stdout, stderr): ... printf("C-level stdout") ... output = std...
[ "def", "pipes", "(", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ",", "encoding", "=", "_default_encoding", ")", ":", "stdout_pipe", "=", "stderr_pipe", "=", "False", "# setup stdout", "if", "stdout", "==", "PIPE", ":", "stdout_r", ",", "stdout_w", ...
Capture C-level stdout/stderr in a context manager. The return value for the context manager is (stdout, stderr). Examples -------- >>> with capture() as (stdout, stderr): ... printf("C-level stdout") ... output = stdout.read()
[ "Capture", "C", "-", "level", "stdout", "/", "stderr", "in", "a", "context", "manager", "." ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L254-L305
minrk/wurlitzer
wurlitzer.py
sys_pipes
def sys_pipes(encoding=_default_encoding): """Redirect C-level stdout/stderr to sys.stdout/stderr This is useful of sys.sdout/stderr are already being forwarded somewhere. DO NOT USE THIS if sys.stdout and sys.stderr are not already being forwarded. """ return pipes(sys.stdout, sys.stderr,...
python
def sys_pipes(encoding=_default_encoding): """Redirect C-level stdout/stderr to sys.stdout/stderr This is useful of sys.sdout/stderr are already being forwarded somewhere. DO NOT USE THIS if sys.stdout and sys.stderr are not already being forwarded. """ return pipes(sys.stdout, sys.stderr,...
[ "def", "sys_pipes", "(", "encoding", "=", "_default_encoding", ")", ":", "return", "pipes", "(", "sys", ".", "stdout", ",", "sys", ".", "stderr", ",", "encoding", "=", "encoding", ")" ]
Redirect C-level stdout/stderr to sys.stdout/stderr This is useful of sys.sdout/stderr are already being forwarded somewhere. DO NOT USE THIS if sys.stdout and sys.stderr are not already being forwarded.
[ "Redirect", "C", "-", "level", "stdout", "/", "stderr", "to", "sys", ".", "stdout", "/", "stderr", "This", "is", "useful", "of", "sys", ".", "sdout", "/", "stderr", "are", "already", "being", "forwarded", "somewhere", ".", "DO", "NOT", "USE", "THIS", "...
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L308-L315
minrk/wurlitzer
wurlitzer.py
sys_pipes_forever
def sys_pipes_forever(encoding=_default_encoding): """Redirect all C output to sys.stdout/err This is not a context manager; it turns on C-forwarding permanently. """ global _mighty_wurlitzer if _mighty_wurlitzer is None: _mighty_wurlitzer = sys_pipes(encoding) _mighty_wurlitzer.__e...
python
def sys_pipes_forever(encoding=_default_encoding): """Redirect all C output to sys.stdout/err This is not a context manager; it turns on C-forwarding permanently. """ global _mighty_wurlitzer if _mighty_wurlitzer is None: _mighty_wurlitzer = sys_pipes(encoding) _mighty_wurlitzer.__e...
[ "def", "sys_pipes_forever", "(", "encoding", "=", "_default_encoding", ")", ":", "global", "_mighty_wurlitzer", "if", "_mighty_wurlitzer", "is", "None", ":", "_mighty_wurlitzer", "=", "sys_pipes", "(", "encoding", ")", "_mighty_wurlitzer", ".", "__enter__", "(", ")"...
Redirect all C output to sys.stdout/err This is not a context manager; it turns on C-forwarding permanently.
[ "Redirect", "all", "C", "output", "to", "sys", ".", "stdout", "/", "err", "This", "is", "not", "a", "context", "manager", ";", "it", "turns", "on", "C", "-", "forwarding", "permanently", "." ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L320-L328
minrk/wurlitzer
wurlitzer.py
load_ipython_extension
def load_ipython_extension(ip): """Register me as an IPython extension Captures all C output during execution and forwards to sys. Does nothing on terminal IPython. Use: %load_ext wurlitzer """ if not getattr(ip, 'kernel'): warnings.warn( "wurlitzer extension d...
python
def load_ipython_extension(ip): """Register me as an IPython extension Captures all C output during execution and forwards to sys. Does nothing on terminal IPython. Use: %load_ext wurlitzer """ if not getattr(ip, 'kernel'): warnings.warn( "wurlitzer extension d...
[ "def", "load_ipython_extension", "(", "ip", ")", ":", "if", "not", "getattr", "(", "ip", ",", "'kernel'", ")", ":", "warnings", ".", "warn", "(", "\"wurlitzer extension doesn't do anything in terminal IPython\"", ")", "return", "ip", ".", "events", ".", "register"...
Register me as an IPython extension Captures all C output during execution and forwards to sys. Does nothing on terminal IPython. Use: %load_ext wurlitzer
[ "Register", "me", "as", "an", "IPython", "extension", "Captures", "all", "C", "output", "during", "execution", "and", "forwards", "to", "sys", ".", "Does", "nothing", "on", "terminal", "IPython", ".", "Use", ":", "%load_ext", "wurlitzer" ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L339-L354
minrk/wurlitzer
wurlitzer.py
unload_ipython_extension
def unload_ipython_extension(ip): """Unload me as an IPython extension Use: %unload_ext wurlitzer """ if not getattr(ip, 'kernel'): return ip.events.unregister('pre_execute', sys_pipes_forever) ip.events.unregister('post_execute', stop_sys_pipes)
python
def unload_ipython_extension(ip): """Unload me as an IPython extension Use: %unload_ext wurlitzer """ if not getattr(ip, 'kernel'): return ip.events.unregister('pre_execute', sys_pipes_forever) ip.events.unregister('post_execute', stop_sys_pipes)
[ "def", "unload_ipython_extension", "(", "ip", ")", ":", "if", "not", "getattr", "(", "ip", ",", "'kernel'", ")", ":", "return", "ip", ".", "events", ".", "unregister", "(", "'pre_execute'", ",", "sys_pipes_forever", ")", "ip", ".", "events", ".", "unregist...
Unload me as an IPython extension Use: %unload_ext wurlitzer
[ "Unload", "me", "as", "an", "IPython", "extension", "Use", ":", "%unload_ext", "wurlitzer" ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L357-L365
minrk/wurlitzer
wurlitzer.py
Wurlitzer._decode
def _decode(self, data): """Decode data, if any Called before passing to stdout/stderr streams """ if self.encoding: data = data.decode(self.encoding, 'replace') return data
python
def _decode(self, data): """Decode data, if any Called before passing to stdout/stderr streams """ if self.encoding: data = data.decode(self.encoding, 'replace') return data
[ "def", "_decode", "(", "self", ",", "data", ")", ":", "if", "self", ".", "encoding", ":", "data", "=", "data", ".", "decode", "(", "self", ".", "encoding", ",", "'replace'", ")", "return", "data" ]
Decode data, if any Called before passing to stdout/stderr streams
[ "Decode", "data", "if", "any", "Called", "before", "passing", "to", "stdout", "/", "stderr", "streams" ]
train
https://github.com/minrk/wurlitzer/blob/088bb9957396afea21a88b35999267a9c6e239d5/wurlitzer.py#L114-L121
sphinx-contrib/spelling
sphinxcontrib/spelling/checker.py
SpellingChecker.push_filters
def push_filters(self, new_filters): """Add a filter to the tokenizer chain. """ t = self.tokenizer for f in new_filters: t = f(t) self.tokenizer = t
python
def push_filters(self, new_filters): """Add a filter to the tokenizer chain. """ t = self.tokenizer for f in new_filters: t = f(t) self.tokenizer = t
[ "def", "push_filters", "(", "self", ",", "new_filters", ")", ":", "t", "=", "self", ".", "tokenizer", "for", "f", "in", "new_filters", ":", "t", "=", "f", "(", "t", ")", "self", ".", "tokenizer", "=", "t" ]
Add a filter to the tokenizer chain.
[ "Add", "a", "filter", "to", "the", "tokenizer", "chain", "." ]
train
https://github.com/sphinx-contrib/spelling/blob/3108cd86b5935f458ec80e87f8e37f924725d15f/sphinxcontrib/spelling/checker.py#L28-L34
sphinx-contrib/spelling
sphinxcontrib/spelling/checker.py
SpellingChecker.check
def check(self, text): """Yields bad words and suggested alternate spellings. """ for word, pos in self.tokenizer(text): correct = self.dictionary.check(word) if correct: continue yield word, self.dictionary.suggest(word) if self.suggest else [...
python
def check(self, text): """Yields bad words and suggested alternate spellings. """ for word, pos in self.tokenizer(text): correct = self.dictionary.check(word) if correct: continue yield word, self.dictionary.suggest(word) if self.suggest else [...
[ "def", "check", "(", "self", ",", "text", ")", ":", "for", "word", ",", "pos", "in", "self", ".", "tokenizer", "(", "text", ")", ":", "correct", "=", "self", ".", "dictionary", ".", "check", "(", "word", ")", "if", "correct", ":", "continue", "yiel...
Yields bad words and suggested alternate spellings.
[ "Yields", "bad", "words", "and", "suggested", "alternate", "spellings", "." ]
train
https://github.com/sphinx-contrib/spelling/blob/3108cd86b5935f458ec80e87f8e37f924725d15f/sphinxcontrib/spelling/checker.py#L41-L49
Yelp/service_configuration_lib
service_configuration_lib/__init__.py
get_service_from_port
def get_service_from_port(port, all_services=None): """Gets the name of the service from the port all_services allows you to feed in the services to look through, pass in a dict of service names to service information eg. { 'service_name': { 'port': port_number } } ...
python
def get_service_from_port(port, all_services=None): """Gets the name of the service from the port all_services allows you to feed in the services to look through, pass in a dict of service names to service information eg. { 'service_name': { 'port': port_number } } ...
[ "def", "get_service_from_port", "(", "port", ",", "all_services", "=", "None", ")", ":", "if", "port", "is", "None", "or", "not", "isinstance", "(", "port", ",", "int", ")", ":", "return", "None", "if", "all_services", "is", "None", ":", "all_services", ...
Gets the name of the service from the port all_services allows you to feed in the services to look through, pass in a dict of service names to service information eg. { 'service_name': { 'port': port_number } } Returns the name of the service
[ "Gets", "the", "name", "of", "the", "service", "from", "the", "port", "all_services", "allows", "you", "to", "feed", "in", "the", "services", "to", "look", "through", "pass", "in", "a", "dict", "of", "service", "names", "to", "service", "information", "eg"...
train
https://github.com/Yelp/service_configuration_lib/blob/83ac2872f95dd204e9f83ec95b4296a9501bf82d/service_configuration_lib/__init__.py#L165-L191
Yelp/service_configuration_lib
service_configuration_lib/__init__.py
all_nodes_that_receive
def all_nodes_that_receive(service, service_configuration=None, run_only=False, deploy_to_only=False): """If run_only, returns only the services that are in the runs_on list. If deploy_to_only, returns only the services in the deployed_to list. If neither, both are returned, duplicates stripped. Results...
python
def all_nodes_that_receive(service, service_configuration=None, run_only=False, deploy_to_only=False): """If run_only, returns only the services that are in the runs_on list. If deploy_to_only, returns only the services in the deployed_to list. If neither, both are returned, duplicates stripped. Results...
[ "def", "all_nodes_that_receive", "(", "service", ",", "service_configuration", "=", "None", ",", "run_only", "=", "False", ",", "deploy_to_only", "=", "False", ")", ":", "assert", "not", "(", "run_only", "and", "deploy_to_only", ")", "if", "service_configuration",...
If run_only, returns only the services that are in the runs_on list. If deploy_to_only, returns only the services in the deployed_to list. If neither, both are returned, duplicates stripped. Results are always sorted.
[ "If", "run_only", "returns", "only", "the", "services", "that", "are", "in", "the", "runs_on", "list", ".", "If", "deploy_to_only", "returns", "only", "the", "services", "in", "the", "deployed_to", "list", ".", "If", "neither", "both", "are", "returned", "du...
train
https://github.com/Yelp/service_configuration_lib/blob/83ac2872f95dd204e9f83ec95b4296a9501bf82d/service_configuration_lib/__init__.py#L246-L268
Yelp/service_configuration_lib
service_configuration_lib/__init__.py
all_nodes_that_run_in_env
def all_nodes_that_run_in_env(service, env, service_configuration=None): """ Returns all nodes that run in an environment. This needs to be specified in field named 'env_runs_on' one level under services in the configuration, and needs to contain an object which maps strings to lists (environments to no...
python
def all_nodes_that_run_in_env(service, env, service_configuration=None): """ Returns all nodes that run in an environment. This needs to be specified in field named 'env_runs_on' one level under services in the configuration, and needs to contain an object which maps strings to lists (environments to no...
[ "def", "all_nodes_that_run_in_env", "(", "service", ",", "env", ",", "service_configuration", "=", "None", ")", ":", "if", "service_configuration", "is", "None", ":", "service_configuration", "=", "read_services_configuration", "(", ")", "env_runs_on", "=", "service_c...
Returns all nodes that run in an environment. This needs to be specified in field named 'env_runs_on' one level under services in the configuration, and needs to contain an object which maps strings to lists (environments to nodes). :param service: A string specifying which service to look up nodes for...
[ "Returns", "all", "nodes", "that", "run", "in", "an", "environment", ".", "This", "needs", "to", "be", "specified", "in", "field", "named", "env_runs_on", "one", "level", "under", "services", "in", "the", "configuration", "and", "needs", "to", "contain", "an...
train
https://github.com/Yelp/service_configuration_lib/blob/83ac2872f95dd204e9f83ec95b4296a9501bf82d/service_configuration_lib/__init__.py#L270-L290
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
precision_and_scale
def precision_and_scale(x): """ From a float, decide what precision and scale are needed to represent it. >>> precision_and_scale(54.2) (3, 1) >>> precision_and_scale(9) (1, 0) Thanks to Mark Ransom, http://stackoverflow.com/questions/3018758/determine-precision-and-scale-of-particular...
python
def precision_and_scale(x): """ From a float, decide what precision and scale are needed to represent it. >>> precision_and_scale(54.2) (3, 1) >>> precision_and_scale(9) (1, 0) Thanks to Mark Ransom, http://stackoverflow.com/questions/3018758/determine-precision-and-scale-of-particular...
[ "def", "precision_and_scale", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "Decimal", ")", ":", "precision", "=", "len", "(", "x", ".", "as_tuple", "(", ")", ".", "digits", ")", "scale", "=", "-", "1", "*", "x", ".", "as_tuple", "(", ")...
From a float, decide what precision and scale are needed to represent it. >>> precision_and_scale(54.2) (3, 1) >>> precision_and_scale(9) (1, 0) Thanks to Mark Ransom, http://stackoverflow.com/questions/3018758/determine-precision-and-scale-of-particular-number-in-python
[ "From", "a", "float", "decide", "what", "precision", "and", "scale", "are", "needed", "to", "represent", "it", "." ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L17-L47
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
coerce_to_specific
def coerce_to_specific(datum): """ Coerces datum to the most specific data type possible Order of preference: datetime, boolean, integer, decimal, float, string >>> coerce_to_specific('-000000001854.60') Decimal('-1854.60') >>> coerce_to_specific(7.2) Decimal('7.2') >>> coerce_to_specif...
python
def coerce_to_specific(datum): """ Coerces datum to the most specific data type possible Order of preference: datetime, boolean, integer, decimal, float, string >>> coerce_to_specific('-000000001854.60') Decimal('-1854.60') >>> coerce_to_specific(7.2) Decimal('7.2') >>> coerce_to_specif...
[ "def", "coerce_to_specific", "(", "datum", ")", ":", "if", "datum", "is", "None", ":", "return", "None", "try", ":", "result", "=", "dateutil", ".", "parser", ".", "parse", "(", "datum", ")", "# but even if this does not raise an exception, may", "# not be a date ...
Coerces datum to the most specific data type possible Order of preference: datetime, boolean, integer, decimal, float, string >>> coerce_to_specific('-000000001854.60') Decimal('-1854.60') >>> coerce_to_specific(7.2) Decimal('7.2') >>> coerce_to_specific("Jan 17 2012") datetime.datetime(201...
[ "Coerces", "datum", "to", "the", "most", "specific", "data", "type", "possible", "Order", "of", "preference", ":", "datetime", "boolean", "integer", "decimal", "float", "string" ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L51-L112
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
_places_b4_and_after_decimal
def _places_b4_and_after_decimal(d): """ >>> _places_b4_and_after_decimal(Decimal('54.212')) (2, 3) """ tup = d.as_tuple() return (len(tup.digits) + tup.exponent, max(-1*tup.exponent, 0))
python
def _places_b4_and_after_decimal(d): """ >>> _places_b4_and_after_decimal(Decimal('54.212')) (2, 3) """ tup = d.as_tuple() return (len(tup.digits) + tup.exponent, max(-1*tup.exponent, 0))
[ "def", "_places_b4_and_after_decimal", "(", "d", ")", ":", "tup", "=", "d", ".", "as_tuple", "(", ")", "return", "(", "len", "(", "tup", ".", "digits", ")", "+", "tup", ".", "exponent", ",", "max", "(", "-", "1", "*", "tup", ".", "exponent", ",", ...
>>> _places_b4_and_after_decimal(Decimal('54.212')) (2, 3)
[ ">>>", "_places_b4_and_after_decimal", "(", "Decimal", "(", "54", ".", "212", "))", "(", "2", "3", ")" ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L114-L120
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
worst_decimal
def worst_decimal(d1, d2): """ Given two Decimals, return a 9-filled decimal representing both enough > 0 digits and enough < 0 digits (scale) to accomodate numbers like either. >>> worst_decimal(Decimal('762.1'), Decimal('-1.983')) Decimal('999.999') """ (d1b4, d1after) = _places_b4_and_af...
python
def worst_decimal(d1, d2): """ Given two Decimals, return a 9-filled decimal representing both enough > 0 digits and enough < 0 digits (scale) to accomodate numbers like either. >>> worst_decimal(Decimal('762.1'), Decimal('-1.983')) Decimal('999.999') """ (d1b4, d1after) = _places_b4_and_af...
[ "def", "worst_decimal", "(", "d1", ",", "d2", ")", ":", "(", "d1b4", ",", "d1after", ")", "=", "_places_b4_and_after_decimal", "(", "d1", ")", "(", "d2b4", ",", "d2after", ")", "=", "_places_b4_and_after_decimal", "(", "d2", ")", "return", "Decimal", "(", ...
Given two Decimals, return a 9-filled decimal representing both enough > 0 digits and enough < 0 digits (scale) to accomodate numbers like either. >>> worst_decimal(Decimal('762.1'), Decimal('-1.983')) Decimal('999.999')
[ "Given", "two", "Decimals", "return", "a", "9", "-", "filled", "decimal", "representing", "both", "enough", ">", "0", "digits", "and", "enough", "<", "0", "digits", "(", "scale", ")", "to", "accomodate", "numbers", "like", "either", "." ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L122-L132
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
set_worst
def set_worst(old_worst, new_worst): """ Pad new_worst with zeroes to prevent it being shorter than old_worst. >>> set_worst(311920, '48-49') '48-490' >>> set_worst(98, -2) -20 """ if isinstance(new_worst, bool): return new_worst # Negative numbers confuse the lengt...
python
def set_worst(old_worst, new_worst): """ Pad new_worst with zeroes to prevent it being shorter than old_worst. >>> set_worst(311920, '48-49') '48-490' >>> set_worst(98, -2) -20 """ if isinstance(new_worst, bool): return new_worst # Negative numbers confuse the lengt...
[ "def", "set_worst", "(", "old_worst", ",", "new_worst", ")", ":", "if", "isinstance", "(", "new_worst", ",", "bool", ")", ":", "return", "new_worst", "# Negative numbers confuse the length calculation. ", "negative", "=", "(", "(", "hasattr", "(", "old_worst", ","...
Pad new_worst with zeroes to prevent it being shorter than old_worst. >>> set_worst(311920, '48-49') '48-490' >>> set_worst(98, -2) -20
[ "Pad", "new_worst", "with", "zeroes", "to", "prevent", "it", "being", "shorter", "than", "old_worst", ".", ">>>", "set_worst", "(", "311920", "48", "-", "49", ")", "48", "-", "490", ">>>", "set_worst", "(", "98", "-", "2", ")", "-", "20" ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L134-L170
catherinedevlin/ddl-generator
ddlgenerator/typehelpers.py
best_representative
def best_representative(d1, d2): """ Given two objects each coerced to the most specific type possible, return the one of the least restrictive type. >>> best_representative(Decimal('-37.5'), Decimal('0.9999')) Decimal('-99.9999') >>> best_representative(None, Decimal('6.1')) Decimal('6.1')...
python
def best_representative(d1, d2): """ Given two objects each coerced to the most specific type possible, return the one of the least restrictive type. >>> best_representative(Decimal('-37.5'), Decimal('0.9999')) Decimal('-99.9999') >>> best_representative(None, Decimal('6.1')) Decimal('6.1')...
[ "def", "best_representative", "(", "d1", ",", "d2", ")", ":", "if", "hasattr", "(", "d2", ",", "'strip'", ")", "and", "not", "d2", ".", "strip", "(", ")", ":", "return", "d1", "if", "d1", "is", "None", ":", "return", "d2", "elif", "d2", "is", "No...
Given two objects each coerced to the most specific type possible, return the one of the least restrictive type. >>> best_representative(Decimal('-37.5'), Decimal('0.9999')) Decimal('-99.9999') >>> best_representative(None, Decimal('6.1')) Decimal('6.1') >>> best_representative(311920, '48-49')...
[ "Given", "two", "objects", "each", "coerced", "to", "the", "most", "specific", "type", "possible", "return", "the", "one", "of", "the", "least", "restrictive", "type", "." ]
train
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/typehelpers.py#L172-L213