id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,800 | mabuchilab/QNET | src/qnet/printing/_unicode_mappings.py | _translate_symbols | def _translate_symbols(string):
"""Given a description of a Greek letter or other special character,
return the appropriate unicode letter."""
res = []
string = str(string)
for s in re.split(r'(\W+)', string, flags=re.UNICODE):
tex_str = _GREEK_DICTIONARY.get(s)
if tex_str:
... | python | def _translate_symbols(string):
"""Given a description of a Greek letter or other special character,
return the appropriate unicode letter."""
res = []
string = str(string)
for s in re.split(r'(\W+)', string, flags=re.UNICODE):
tex_str = _GREEK_DICTIONARY.get(s)
if tex_str:
... | [
"def",
"_translate_symbols",
"(",
"string",
")",
":",
"res",
"=",
"[",
"]",
"string",
"=",
"str",
"(",
"string",
")",
"for",
"s",
"in",
"re",
".",
"split",
"(",
"r'(\\W+)'",
",",
"string",
",",
"flags",
"=",
"re",
".",
"UNICODE",
")",
":",
"tex_str... | Given a description of a Greek letter or other special character,
return the appropriate unicode letter. | [
"Given",
"a",
"description",
"of",
"a",
"Greek",
"letter",
"or",
"other",
"special",
"character",
"return",
"the",
"appropriate",
"unicode",
"letter",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_unicode_mappings.py#L140-L153 |
45,801 | niloch/iplotter | iplotter/c3_plotter.py | C3Plotter.plot_and_save | def plot_and_save(self,
data,
w=800,
h=420,
filename='chart',
overwrite=True):
"""Save the rendered html to a file and returns an IFrame to display the plot in the notebook."""
self.save(data, f... | python | def plot_and_save(self,
data,
w=800,
h=420,
filename='chart',
overwrite=True):
"""Save the rendered html to a file and returns an IFrame to display the plot in the notebook."""
self.save(data, f... | [
"def",
"plot_and_save",
"(",
"self",
",",
"data",
",",
"w",
"=",
"800",
",",
"h",
"=",
"420",
",",
"filename",
"=",
"'chart'",
",",
"overwrite",
"=",
"True",
")",
":",
"self",
".",
"save",
"(",
"data",
",",
"filename",
",",
"overwrite",
")",
"retur... | Save the rendered html to a file and returns an IFrame to display the plot in the notebook. | [
"Save",
"the",
"rendered",
"html",
"to",
"a",
"file",
"and",
"returns",
"an",
"IFrame",
"to",
"display",
"the",
"plot",
"in",
"the",
"notebook",
"."
] | 0403486d8633f601a33c4d2b9c9fa3ec88e9327b | https://github.com/niloch/iplotter/blob/0403486d8633f601a33c4d2b9c9fa3ec88e9327b/iplotter/c3_plotter.py#L46-L54 |
45,802 | mabuchilab/QNET | src/qnet/printing/sreprprinter.py | IndentedSReprPrinter._get_from_cache | def _get_from_cache(self, expr):
"""Obtain cached result, prepend with the keyname if necessary, and
indent for the current level"""
is_cached, res = super()._get_from_cache(expr)
if is_cached:
indent_str = " " * self._print_level
return True, indent(res, inden... | python | def _get_from_cache(self, expr):
"""Obtain cached result, prepend with the keyname if necessary, and
indent for the current level"""
is_cached, res = super()._get_from_cache(expr)
if is_cached:
indent_str = " " * self._print_level
return True, indent(res, inden... | [
"def",
"_get_from_cache",
"(",
"self",
",",
"expr",
")",
":",
"is_cached",
",",
"res",
"=",
"super",
"(",
")",
".",
"_get_from_cache",
"(",
"expr",
")",
"if",
"is_cached",
":",
"indent_str",
"=",
"\" \"",
"*",
"self",
".",
"_print_level",
"return",
"T... | Obtain cached result, prepend with the keyname if necessary, and
indent for the current level | [
"Obtain",
"cached",
"result",
"prepend",
"with",
"the",
"keyname",
"if",
"necessary",
"and",
"indent",
"for",
"the",
"current",
"level"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/sreprprinter.py#L59-L67 |
45,803 | mabuchilab/QNET | src/qnet/printing/sreprprinter.py | IndentedSReprPrinter._write_to_cache | def _write_to_cache(self, expr, res):
"""Store the cached result without indentation, and without the
keyname"""
res = dedent(res)
super()._write_to_cache(expr, res) | python | def _write_to_cache(self, expr, res):
"""Store the cached result without indentation, and without the
keyname"""
res = dedent(res)
super()._write_to_cache(expr, res) | [
"def",
"_write_to_cache",
"(",
"self",
",",
"expr",
",",
"res",
")",
":",
"res",
"=",
"dedent",
"(",
"res",
")",
"super",
"(",
")",
".",
"_write_to_cache",
"(",
"expr",
",",
"res",
")"
] | Store the cached result without indentation, and without the
keyname | [
"Store",
"the",
"cached",
"result",
"without",
"indentation",
"and",
"without",
"the",
"keyname"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/sreprprinter.py#L69-L73 |
45,804 | mabuchilab/QNET | src/qnet/printing/latexprinter.py | _translate_symbols | def _translate_symbols(string):
"""Given a description of a Greek letter or other special character,
return the appropriate latex."""
res = []
for s in re.split(r'([,.:\s=]+)', string):
tex_str = _TEX_GREEK_DICTIONARY.get(s)
if tex_str:
res.append(tex_str)
elif s.lowe... | python | def _translate_symbols(string):
"""Given a description of a Greek letter or other special character,
return the appropriate latex."""
res = []
for s in re.split(r'([,.:\s=]+)', string):
tex_str = _TEX_GREEK_DICTIONARY.get(s)
if tex_str:
res.append(tex_str)
elif s.lowe... | [
"def",
"_translate_symbols",
"(",
"string",
")",
":",
"res",
"=",
"[",
"]",
"for",
"s",
"in",
"re",
".",
"split",
"(",
"r'([,.:\\s=]+)'",
",",
"string",
")",
":",
"tex_str",
"=",
"_TEX_GREEK_DICTIONARY",
".",
"get",
"(",
"s",
")",
"if",
"tex_str",
":",... | Given a description of a Greek letter or other special character,
return the appropriate latex. | [
"Given",
"a",
"description",
"of",
"a",
"Greek",
"letter",
"or",
"other",
"special",
"character",
"return",
"the",
"appropriate",
"latex",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/latexprinter.py#L422-L439 |
45,805 | mabuchilab/QNET | src/qnet/printing/latexprinter.py | QnetLatexPrinter._render_str | def _render_str(self, string):
"""Returned a texified version of the string"""
if isinstance(string, StrLabel):
string = string._render(string.expr)
string = str(string)
if len(string) == 0:
return ''
name, supers, subs = split_super_sub(string)
re... | python | def _render_str(self, string):
"""Returned a texified version of the string"""
if isinstance(string, StrLabel):
string = string._render(string.expr)
string = str(string)
if len(string) == 0:
return ''
name, supers, subs = split_super_sub(string)
re... | [
"def",
"_render_str",
"(",
"self",
",",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"StrLabel",
")",
":",
"string",
"=",
"string",
".",
"_render",
"(",
"string",
".",
"expr",
")",
"string",
"=",
"str",
"(",
"string",
")",
"if",
"len",... | Returned a texified version of the string | [
"Returned",
"a",
"texified",
"version",
"of",
"the",
"string"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/latexprinter.py#L74-L83 |
45,806 | gunthercox/mathparse | mathparse/mathparse.py | is_symbol | def is_symbol(string):
"""
Return true if the string is a mathematical symbol.
"""
return (
is_int(string) or is_float(string) or
is_constant(string) or is_unary(string) or
is_binary(string) or
(string == '(') or (string == ')')
) | python | def is_symbol(string):
"""
Return true if the string is a mathematical symbol.
"""
return (
is_int(string) or is_float(string) or
is_constant(string) or is_unary(string) or
is_binary(string) or
(string == '(') or (string == ')')
) | [
"def",
"is_symbol",
"(",
"string",
")",
":",
"return",
"(",
"is_int",
"(",
"string",
")",
"or",
"is_float",
"(",
"string",
")",
"or",
"is_constant",
"(",
"string",
")",
"or",
"is_unary",
"(",
"string",
")",
"or",
"is_binary",
"(",
"string",
")",
"or",
... | Return true if the string is a mathematical symbol. | [
"Return",
"true",
"if",
"the",
"string",
"is",
"a",
"mathematical",
"symbol",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L61-L70 |
45,807 | gunthercox/mathparse | mathparse/mathparse.py | find_word_groups | def find_word_groups(string, words):
"""
Find matches for words in the format "3 thousand 6 hundred 2".
The words parameter should be the list of words to check for
such as "hundred".
"""
scale_pattern = '|'.join(words)
# For example:
# (?:(?:\d+)\s+(?:hundred|thousand)*\s*)+(?:\d+|hundr... | python | def find_word_groups(string, words):
"""
Find matches for words in the format "3 thousand 6 hundred 2".
The words parameter should be the list of words to check for
such as "hundred".
"""
scale_pattern = '|'.join(words)
# For example:
# (?:(?:\d+)\s+(?:hundred|thousand)*\s*)+(?:\d+|hundr... | [
"def",
"find_word_groups",
"(",
"string",
",",
"words",
")",
":",
"scale_pattern",
"=",
"'|'",
".",
"join",
"(",
"words",
")",
"# For example:",
"# (?:(?:\\d+)\\s+(?:hundred|thousand)*\\s*)+(?:\\d+|hundred|thousand)+",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'(?:(?... | Find matches for words in the format "3 thousand 6 hundred 2".
The words parameter should be the list of words to check for
such as "hundred". | [
"Find",
"matches",
"for",
"words",
"in",
"the",
"format",
"3",
"thousand",
"6",
"hundred",
"2",
".",
"The",
"words",
"parameter",
"should",
"be",
"the",
"list",
"of",
"words",
"to",
"check",
"for",
"such",
"as",
"hundred",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L82-L98 |
45,808 | gunthercox/mathparse | mathparse/mathparse.py | replace_word_tokens | def replace_word_tokens(string, language):
"""
Given a string and an ISO 639-2 language code,
return the string with the words replaced with
an operational equivalent.
"""
words = mathwords.word_groups_for_language(language)
# Replace operator words with numeric operators
operators = wo... | python | def replace_word_tokens(string, language):
"""
Given a string and an ISO 639-2 language code,
return the string with the words replaced with
an operational equivalent.
"""
words = mathwords.word_groups_for_language(language)
# Replace operator words with numeric operators
operators = wo... | [
"def",
"replace_word_tokens",
"(",
"string",
",",
"language",
")",
":",
"words",
"=",
"mathwords",
".",
"word_groups_for_language",
"(",
"language",
")",
"# Replace operator words with numeric operators",
"operators",
"=",
"words",
"[",
"'binary_operators'",
"]",
".",
... | Given a string and an ISO 639-2 language code,
return the string with the words replaced with
an operational equivalent. | [
"Given",
"a",
"string",
"and",
"an",
"ISO",
"639",
"-",
"2",
"language",
"code",
"return",
"the",
"string",
"with",
"the",
"words",
"replaced",
"with",
"an",
"operational",
"equivalent",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L101-L157 |
45,809 | gunthercox/mathparse | mathparse/mathparse.py | to_postfix | def to_postfix(tokens):
"""
Convert a list of evaluatable tokens to postfix format.
"""
precedence = {
'/': 4,
'*': 4,
'+': 3,
'-': 3,
'^': 2,
'(': 1
}
postfix = []
opstack = []
for token in tokens:
if is_int(token):
p... | python | def to_postfix(tokens):
"""
Convert a list of evaluatable tokens to postfix format.
"""
precedence = {
'/': 4,
'*': 4,
'+': 3,
'-': 3,
'^': 2,
'(': 1
}
postfix = []
opstack = []
for token in tokens:
if is_int(token):
p... | [
"def",
"to_postfix",
"(",
"tokens",
")",
":",
"precedence",
"=",
"{",
"'/'",
":",
"4",
",",
"'*'",
":",
"4",
",",
"'+'",
":",
"3",
",",
"'-'",
":",
"3",
",",
"'^'",
":",
"2",
",",
"'('",
":",
"1",
"}",
"postfix",
"=",
"[",
"]",
"opstack",
"... | Convert a list of evaluatable tokens to postfix format. | [
"Convert",
"a",
"list",
"of",
"evaluatable",
"tokens",
"to",
"postfix",
"format",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L160-L202 |
45,810 | gunthercox/mathparse | mathparse/mathparse.py | evaluate_postfix | def evaluate_postfix(tokens):
"""
Given a list of evaluatable tokens in postfix format,
calculate a solution.
"""
stack = []
for token in tokens:
total = None
if is_int(token) or is_float(token) or is_constant(token):
stack.append(token)
elif is_unary(token)... | python | def evaluate_postfix(tokens):
"""
Given a list of evaluatable tokens in postfix format,
calculate a solution.
"""
stack = []
for token in tokens:
total = None
if is_int(token) or is_float(token) or is_constant(token):
stack.append(token)
elif is_unary(token)... | [
"def",
"evaluate_postfix",
"(",
"tokens",
")",
":",
"stack",
"=",
"[",
"]",
"for",
"token",
"in",
"tokens",
":",
"total",
"=",
"None",
"if",
"is_int",
"(",
"token",
")",
"or",
"is_float",
"(",
"token",
")",
"or",
"is_constant",
"(",
"token",
")",
":"... | Given a list of evaluatable tokens in postfix format,
calculate a solution. | [
"Given",
"a",
"list",
"of",
"evaluatable",
"tokens",
"in",
"postfix",
"format",
"calculate",
"a",
"solution",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L205-L250 |
45,811 | gunthercox/mathparse | mathparse/mathparse.py | tokenize | def tokenize(string, language=None, escape='___'):
"""
Given a string, return a list of math symbol tokens
"""
# Set all words to lowercase
string = string.lower()
# Ignore punctuation
if len(string) and not string[-1].isalnum():
character = string[-1]
string = string[:-1] +... | python | def tokenize(string, language=None, escape='___'):
"""
Given a string, return a list of math symbol tokens
"""
# Set all words to lowercase
string = string.lower()
# Ignore punctuation
if len(string) and not string[-1].isalnum():
character = string[-1]
string = string[:-1] +... | [
"def",
"tokenize",
"(",
"string",
",",
"language",
"=",
"None",
",",
"escape",
"=",
"'___'",
")",
":",
"# Set all words to lowercase",
"string",
"=",
"string",
".",
"lower",
"(",
")",
"# Ignore punctuation",
"if",
"len",
"(",
"string",
")",
"and",
"not",
"... | Given a string, return a list of math symbol tokens | [
"Given",
"a",
"string",
"return",
"a",
"list",
"of",
"math",
"symbol",
"tokens"
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L253-L281 |
45,812 | gunthercox/mathparse | mathparse/mathparse.py | parse | def parse(string, language=None):
"""
Return a solution to the equation in the input string.
"""
if language:
string = replace_word_tokens(string, language)
tokens = tokenize(string)
postfix = to_postfix(tokens)
return evaluate_postfix(postfix) | python | def parse(string, language=None):
"""
Return a solution to the equation in the input string.
"""
if language:
string = replace_word_tokens(string, language)
tokens = tokenize(string)
postfix = to_postfix(tokens)
return evaluate_postfix(postfix) | [
"def",
"parse",
"(",
"string",
",",
"language",
"=",
"None",
")",
":",
"if",
"language",
":",
"string",
"=",
"replace_word_tokens",
"(",
"string",
",",
"language",
")",
"tokens",
"=",
"tokenize",
"(",
"string",
")",
"postfix",
"=",
"to_postfix",
"(",
"to... | Return a solution to the equation in the input string. | [
"Return",
"a",
"solution",
"to",
"the",
"equation",
"in",
"the",
"input",
"string",
"."
] | 8aadd40e7238febbfea19b29023583720e374ac0 | https://github.com/gunthercox/mathparse/blob/8aadd40e7238febbfea19b29023583720e374ac0/mathparse/mathparse.py#L284-L294 |
45,813 | mabuchilab/QNET | src/qnet/utils/ordering.py | expr_order_key | def expr_order_key(expr):
"""A default order key for arbitrary expressions"""
if hasattr(expr, '_order_key'):
return expr._order_key
try:
if isinstance(expr.kwargs, OrderedDict):
key_vals = expr.kwargs.values()
else:
key_vals = [expr.kwargs[key] for key in sor... | python | def expr_order_key(expr):
"""A default order key for arbitrary expressions"""
if hasattr(expr, '_order_key'):
return expr._order_key
try:
if isinstance(expr.kwargs, OrderedDict):
key_vals = expr.kwargs.values()
else:
key_vals = [expr.kwargs[key] for key in sor... | [
"def",
"expr_order_key",
"(",
"expr",
")",
":",
"if",
"hasattr",
"(",
"expr",
",",
"'_order_key'",
")",
":",
"return",
"expr",
".",
"_order_key",
"try",
":",
"if",
"isinstance",
"(",
"expr",
".",
"kwargs",
",",
"OrderedDict",
")",
":",
"key_vals",
"=",
... | A default order key for arbitrary expressions | [
"A",
"default",
"order",
"key",
"for",
"arbitrary",
"expressions"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/utils/ordering.py#L64-L77 |
45,814 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | Sum | def Sum(idx, *args, **kwargs):
"""Instantiator for an arbitrary indexed sum.
This returns a function that instantiates the appropriate
:class:`QuantumIndexedSum` subclass for a given term expression. It is the
preferred way to "manually" create indexed sum expressions, closely
resembling the normal... | python | def Sum(idx, *args, **kwargs):
"""Instantiator for an arbitrary indexed sum.
This returns a function that instantiates the appropriate
:class:`QuantumIndexedSum` subclass for a given term expression. It is the
preferred way to "manually" create indexed sum expressions, closely
resembling the normal... | [
"def",
"Sum",
"(",
"idx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"qnet",
".",
"algebra",
".",
"core",
".",
"hilbert_space_algebra",
"import",
"LocalSpace",
"from",
"qnet",
".",
"algebra",
".",
"core",
".",
"scalar_algebra",
"import"... | Instantiator for an arbitrary indexed sum.
This returns a function that instantiates the appropriate
:class:`QuantumIndexedSum` subclass for a given term expression. It is the
preferred way to "manually" create indexed sum expressions, closely
resembling the normal mathematical notation for sums.
... | [
"Instantiator",
"for",
"an",
"arbitrary",
"indexed",
"sum",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L923-L1020 |
45,815 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | QuantumExpression.diff | def diff(self, sym: Symbol, n: int = 1, expand_simplify: bool = True):
"""Differentiate by scalar parameter `sym`.
Args:
sym: What to differentiate by.
n: How often to differentiate
expand_simplify: Whether to simplify the result.
Returns:
The n-... | python | def diff(self, sym: Symbol, n: int = 1, expand_simplify: bool = True):
"""Differentiate by scalar parameter `sym`.
Args:
sym: What to differentiate by.
n: How often to differentiate
expand_simplify: Whether to simplify the result.
Returns:
The n-... | [
"def",
"diff",
"(",
"self",
",",
"sym",
":",
"Symbol",
",",
"n",
":",
"int",
"=",
"1",
",",
"expand_simplify",
":",
"bool",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"sym",
",",
"sympy",
".",
"Basic",
")",
":",
"raise",
"TypeError",
... | Differentiate by scalar parameter `sym`.
Args:
sym: What to differentiate by.
n: How often to differentiate
expand_simplify: Whether to simplify the result.
Returns:
The n-th derivative. | [
"Differentiate",
"by",
"scalar",
"parameter",
"sym",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L127-L153 |
45,816 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | QuantumExpression.series_expand | def series_expand(
self, param: Symbol, about, order: int) -> tuple:
r"""Expand the expression as a truncated power series in a
scalar parameter.
When expanding an expr for a parameter $x$ about the point $x_0$ up to
order $N$, the resulting coefficients $(c_1, \dots, c_N)$ ... | python | def series_expand(
self, param: Symbol, about, order: int) -> tuple:
r"""Expand the expression as a truncated power series in a
scalar parameter.
When expanding an expr for a parameter $x$ about the point $x_0$ up to
order $N$, the resulting coefficients $(c_1, \dots, c_N)$ ... | [
"def",
"series_expand",
"(",
"self",
",",
"param",
":",
"Symbol",
",",
"about",
",",
"order",
":",
"int",
")",
"->",
"tuple",
":",
"expansion",
"=",
"self",
".",
"_series_expand",
"(",
"param",
",",
"about",
",",
"order",
")",
"# _series_expand is generall... | r"""Expand the expression as a truncated power series in a
scalar parameter.
When expanding an expr for a parameter $x$ about the point $x_0$ up to
order $N$, the resulting coefficients $(c_1, \dots, c_N)$ fulfill
.. math::
\text{expr} = \sum_{n=0}^{N} c_n (x - x_0)^n + O(... | [
"r",
"Expand",
"the",
"expression",
"as",
"a",
"truncated",
"power",
"series",
"in",
"a",
"scalar",
"parameter",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L159-L201 |
45,817 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | QuantumTimes.factor_for_space | def factor_for_space(self, spc):
"""Return a tuple of two products, where the first product contains the
given Hilbert space, and the second product is disjunct from it."""
if spc == TrivialSpace:
ops_on_spc = [
o for o in self.operands if o.space is TrivialSpace]
... | python | def factor_for_space(self, spc):
"""Return a tuple of two products, where the first product contains the
given Hilbert space, and the second product is disjunct from it."""
if spc == TrivialSpace:
ops_on_spc = [
o for o in self.operands if o.space is TrivialSpace]
... | [
"def",
"factor_for_space",
"(",
"self",
",",
"spc",
")",
":",
"if",
"spc",
"==",
"TrivialSpace",
":",
"ops_on_spc",
"=",
"[",
"o",
"for",
"o",
"in",
"self",
".",
"operands",
"if",
"o",
".",
"space",
"is",
"TrivialSpace",
"]",
"ops_not_on_spc",
"=",
"["... | Return a tuple of two products, where the first product contains the
given Hilbert space, and the second product is disjunct from it. | [
"Return",
"a",
"tuple",
"of",
"two",
"products",
"where",
"the",
"first",
"product",
"contains",
"the",
"given",
"Hilbert",
"space",
"and",
"the",
"second",
"product",
"is",
"disjunct",
"from",
"it",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L515-L530 |
45,818 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | QuantumDerivative.evaluate_at | def evaluate_at(self, vals):
"""Evaluate the derivative at a specific point"""
new_vals = self._vals.copy()
new_vals.update(vals)
return self.__class__(self.operand, derivs=self._derivs, vals=new_vals) | python | def evaluate_at(self, vals):
"""Evaluate the derivative at a specific point"""
new_vals = self._vals.copy()
new_vals.update(vals)
return self.__class__(self.operand, derivs=self._derivs, vals=new_vals) | [
"def",
"evaluate_at",
"(",
"self",
",",
"vals",
")",
":",
"new_vals",
"=",
"self",
".",
"_vals",
".",
"copy",
"(",
")",
"new_vals",
".",
"update",
"(",
"vals",
")",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"operand",
",",
"derivs",
"=",
... | Evaluate the derivative at a specific point | [
"Evaluate",
"the",
"derivative",
"at",
"a",
"specific",
"point"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L759-L763 |
45,819 | mabuchilab/QNET | src/qnet/algebra/core/abstract_quantum_algebra.py | QuantumDerivative.bound_symbols | def bound_symbols(self):
"""Set of Sympy symbols that are eliminated by evaluation."""
if self._bound_symbols is None:
res = set()
self._bound_symbols = res.union(
*[sym.free_symbols for sym in self._vals.keys()])
return self._bound_symbols | python | def bound_symbols(self):
"""Set of Sympy symbols that are eliminated by evaluation."""
if self._bound_symbols is None:
res = set()
self._bound_symbols = res.union(
*[sym.free_symbols for sym in self._vals.keys()])
return self._bound_symbols | [
"def",
"bound_symbols",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bound_symbols",
"is",
"None",
":",
"res",
"=",
"set",
"(",
")",
"self",
".",
"_bound_symbols",
"=",
"res",
".",
"union",
"(",
"*",
"[",
"sym",
".",
"free_symbols",
"for",
"sym",
"in"... | Set of Sympy symbols that are eliminated by evaluation. | [
"Set",
"of",
"Sympy",
"symbols",
"that",
"are",
"eliminated",
"by",
"evaluation",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_quantum_algebra.py#L803-L809 |
45,820 | mabuchilab/QNET | docs/_extensions/graphviz_ext.py | render_dot | def render_dot(self, code, options, format, prefix='graphviz'):
# type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode]
"""Render graphviz code into a PNG or PDF output file."""
graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
hashkey = (code +... | python | def render_dot(self, code, options, format, prefix='graphviz'):
# type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode]
"""Render graphviz code into a PNG or PDF output file."""
graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
hashkey = (code +... | [
"def",
"render_dot",
"(",
"self",
",",
"code",
",",
"options",
",",
"format",
",",
"prefix",
"=",
"'graphviz'",
")",
":",
"# type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode]",
"graphviz_dot",
"=",
"options",
".",
"get",
"(",
"'graphv... | Render graphviz code into a PNG or PDF output file. | [
"Render",
"graphviz",
"code",
"into",
"a",
"PNG",
"or",
"PDF",
"output",
"file",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/graphviz_ext.py#L210-L267 |
45,821 | mabuchilab/QNET | docs/_extensions/graphviz_ext.py | ClickableMapDefinition.generate_clickable_map | def generate_clickable_map(self):
# type: () -> unicode
"""Generate clickable map tags if clickable item exists.
If not exists, this only returns empty string.
"""
if self.clickable:
return '\n'.join([self.content[0]] + self.clickable + [self.content[-1]])
el... | python | def generate_clickable_map(self):
# type: () -> unicode
"""Generate clickable map tags if clickable item exists.
If not exists, this only returns empty string.
"""
if self.clickable:
return '\n'.join([self.content[0]] + self.clickable + [self.content[-1]])
el... | [
"def",
"generate_clickable_map",
"(",
"self",
")",
":",
"# type: () -> unicode",
"if",
"self",
".",
"clickable",
":",
"return",
"'\\n'",
".",
"join",
"(",
"[",
"self",
".",
"content",
"[",
"0",
"]",
"]",
"+",
"self",
".",
"clickable",
"+",
"[",
"self",
... | Generate clickable map tags if clickable item exists.
If not exists, this only returns empty string. | [
"Generate",
"clickable",
"map",
"tags",
"if",
"clickable",
"item",
"exists",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/graphviz_ext.py#L76-L85 |
45,822 | mabuchilab/QNET | src/qnet/algebra/library/spin_algebra.py | SpinSpace.next_basis_label_or_index | def next_basis_label_or_index(self, label_or_index, n=1):
"""Given the label or index of a basis state, return the label
the next basis state.
More generally, if `n` is given, return the `n`'th next basis state
label/index; `n` may also be negative to obtain previous basis state
... | python | def next_basis_label_or_index(self, label_or_index, n=1):
"""Given the label or index of a basis state, return the label
the next basis state.
More generally, if `n` is given, return the `n`'th next basis state
label/index; `n` may also be negative to obtain previous basis state
... | [
"def",
"next_basis_label_or_index",
"(",
"self",
",",
"label_or_index",
",",
"n",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"label_or_index",
",",
"int",
")",
":",
"new_index",
"=",
"label_or_index",
"+",
"n",
"if",
"new_index",
"<",
"0",
":",
"raise",
... | Given the label or index of a basis state, return the label
the next basis state.
More generally, if `n` is given, return the `n`'th next basis state
label/index; `n` may also be negative to obtain previous basis state
labels. Returns a :class:`str` label if `label_or_index` is a
... | [
"Given",
"the",
"label",
"or",
"index",
"of",
"a",
"basis",
"state",
"return",
"the",
"label",
"the",
"next",
"basis",
"state",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/library/spin_algebra.py#L116-L163 |
45,823 | mabuchilab/QNET | docs/_extensions/inheritance_diagram.py | texinfo_visit_inheritance_diagram | def texinfo_visit_inheritance_diagram(self, node):
# type: (nodes.NodeVisitor, inheritance_diagram) -> None
"""
Output the graph for Texinfo. This will insert a PNG.
"""
graph = node['graph']
graph_hash = get_graph_hash(node)
name = 'inheritance%s' % graph_hash
dotcode = graph.generat... | python | def texinfo_visit_inheritance_diagram(self, node):
# type: (nodes.NodeVisitor, inheritance_diagram) -> None
"""
Output the graph for Texinfo. This will insert a PNG.
"""
graph = node['graph']
graph_hash = get_graph_hash(node)
name = 'inheritance%s' % graph_hash
dotcode = graph.generat... | [
"def",
"texinfo_visit_inheritance_diagram",
"(",
"self",
",",
"node",
")",
":",
"# type: (nodes.NodeVisitor, inheritance_diagram) -> None",
"graph",
"=",
"node",
"[",
"'graph'",
"]",
"graph_hash",
"=",
"get_graph_hash",
"(",
"node",
")",
"name",
"=",
"'inheritance%s'",
... | Output the graph for Texinfo. This will insert a PNG. | [
"Output",
"the",
"graph",
"for",
"Texinfo",
".",
"This",
"will",
"insert",
"a",
"PNG",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/inheritance_diagram.py#L492-L505 |
45,824 | mabuchilab/QNET | docs/_extensions/inheritance_diagram.py | InheritanceGraph.class_name | def class_name(self, cls, parts=0, aliases=None):
# type: (Any, int, Optional[Dict[unicode, unicode]]) -> unicode
"""Given a class object, return a fully-qualified name.
This works for things I've tested in matplotlib so far, but may not be
completely general.
"""
module... | python | def class_name(self, cls, parts=0, aliases=None):
# type: (Any, int, Optional[Dict[unicode, unicode]]) -> unicode
"""Given a class object, return a fully-qualified name.
This works for things I've tested in matplotlib so far, but may not be
completely general.
"""
module... | [
"def",
"class_name",
"(",
"self",
",",
"cls",
",",
"parts",
"=",
"0",
",",
"aliases",
"=",
"None",
")",
":",
"# type: (Any, int, Optional[Dict[unicode, unicode]]) -> unicode",
"module",
"=",
"cls",
".",
"__module__",
"if",
"module",
"in",
"(",
"'__builtin__'",
"... | Given a class object, return a fully-qualified name.
This works for things I've tested in matplotlib so far, but may not be
completely general. | [
"Given",
"a",
"class",
"object",
"return",
"a",
"fully",
"-",
"qualified",
"name",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/inheritance_diagram.py#L238-L257 |
45,825 | sveetch/djangocodemirror | djangocodemirror/helper.py | codemirror_settings_update | def codemirror_settings_update(configs, parameters, on=None, names=None):
"""
Return a new dictionnary of configs updated with given parameters.
You may use ``on`` and ``names`` arguments to select config or filter out
some configs from returned dict.
Arguments:
configs (dict): Dictionnary... | python | def codemirror_settings_update(configs, parameters, on=None, names=None):
"""
Return a new dictionnary of configs updated with given parameters.
You may use ``on`` and ``names`` arguments to select config or filter out
some configs from returned dict.
Arguments:
configs (dict): Dictionnary... | [
"def",
"codemirror_settings_update",
"(",
"configs",
",",
"parameters",
",",
"on",
"=",
"None",
",",
"names",
"=",
"None",
")",
":",
"# Deep copy of given config",
"output",
"=",
"copy",
".",
"deepcopy",
"(",
"configs",
")",
"# Optionnaly filtering config from given... | Return a new dictionnary of configs updated with given parameters.
You may use ``on`` and ``names`` arguments to select config or filter out
some configs from returned dict.
Arguments:
configs (dict): Dictionnary of configurations to update.
parameters (dict): Dictionnary of parameters to ... | [
"Return",
"a",
"new",
"dictionnary",
"of",
"configs",
"updated",
"with",
"given",
"parameters",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/helper.py#L52-L88 |
45,826 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.lhs | def lhs(self):
"""The left-hand-side of the equation"""
lhs = self._lhs
i = 0
while lhs is None:
i -= 1
lhs = self._prev_lhs[i]
return lhs | python | def lhs(self):
"""The left-hand-side of the equation"""
lhs = self._lhs
i = 0
while lhs is None:
i -= 1
lhs = self._prev_lhs[i]
return lhs | [
"def",
"lhs",
"(",
"self",
")",
":",
"lhs",
"=",
"self",
".",
"_lhs",
"i",
"=",
"0",
"while",
"lhs",
"is",
"None",
":",
"i",
"-=",
"1",
"lhs",
"=",
"self",
".",
"_prev_lhs",
"[",
"i",
"]",
"return",
"lhs"
] | The left-hand-side of the equation | [
"The",
"left",
"-",
"hand",
"-",
"side",
"of",
"the",
"equation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L73-L80 |
45,827 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.set_tag | def set_tag(self, tag):
"""Return a copy of the equation with a new `tag`"""
return Eq(
self._lhs, self._rhs, tag=tag,
_prev_lhs=self._prev_lhs, _prev_rhs=self._prev_rhs,
_prev_tags=self._prev_tags) | python | def set_tag(self, tag):
"""Return a copy of the equation with a new `tag`"""
return Eq(
self._lhs, self._rhs, tag=tag,
_prev_lhs=self._prev_lhs, _prev_rhs=self._prev_rhs,
_prev_tags=self._prev_tags) | [
"def",
"set_tag",
"(",
"self",
",",
"tag",
")",
":",
"return",
"Eq",
"(",
"self",
".",
"_lhs",
",",
"self",
".",
"_rhs",
",",
"tag",
"=",
"tag",
",",
"_prev_lhs",
"=",
"self",
".",
"_prev_lhs",
",",
"_prev_rhs",
"=",
"self",
".",
"_prev_rhs",
",",
... | Return a copy of the equation with a new `tag` | [
"Return",
"a",
"copy",
"of",
"the",
"equation",
"with",
"a",
"new",
"tag"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L93-L98 |
45,828 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.apply | def apply(self, func, *args, cont=False, tag=None, **kwargs):
"""Apply `func` to both sides of the equation
Returns a new equation where the left-hand-side and right-hand side
are replaced by the application of `func`::
lhs=func(lhs, *args, **kwargs)
rhs=func(rhs, *args... | python | def apply(self, func, *args, cont=False, tag=None, **kwargs):
"""Apply `func` to both sides of the equation
Returns a new equation where the left-hand-side and right-hand side
are replaced by the application of `func`::
lhs=func(lhs, *args, **kwargs)
rhs=func(rhs, *args... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"cont",
"=",
"False",
",",
"tag",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"new_lhs",
"=",
"func",
"(",
"self",
".",
"lhs",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"... | Apply `func` to both sides of the equation
Returns a new equation where the left-hand-side and right-hand side
are replaced by the application of `func`::
lhs=func(lhs, *args, **kwargs)
rhs=func(rhs, *args, **kwargs)
If ``cont=True``, the resulting equation will keep a... | [
"Apply",
"func",
"to",
"both",
"sides",
"of",
"the",
"equation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L109-L129 |
45,829 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.apply_mtd | def apply_mtd(self, mtd, *args, cont=False, tag=None, **kwargs):
"""Call the method `mtd` on both sides of the equation
That is, the left-hand-side and right-hand-side are replaced by::
lhs=lhs.<mtd>(*args, **kwargs)
rhs=rhs.<mtd>(*args, **kwargs)
The `cont` and `tag` ... | python | def apply_mtd(self, mtd, *args, cont=False, tag=None, **kwargs):
"""Call the method `mtd` on both sides of the equation
That is, the left-hand-side and right-hand-side are replaced by::
lhs=lhs.<mtd>(*args, **kwargs)
rhs=rhs.<mtd>(*args, **kwargs)
The `cont` and `tag` ... | [
"def",
"apply_mtd",
"(",
"self",
",",
"mtd",
",",
"*",
"args",
",",
"cont",
"=",
"False",
",",
"tag",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"new_lhs",
"=",
"getattr",
"(",
"self",
".",
"lhs",
",",
"mtd",
")",
"(",
"*",
"args",
",",
... | Call the method `mtd` on both sides of the equation
That is, the left-hand-side and right-hand-side are replaced by::
lhs=lhs.<mtd>(*args, **kwargs)
rhs=rhs.<mtd>(*args, **kwargs)
The `cont` and `tag` parameters are as in :meth:`apply`. | [
"Call",
"the",
"method",
"mtd",
"on",
"both",
"sides",
"of",
"the",
"equation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L154-L169 |
45,830 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.substitute | def substitute(self, var_map, cont=False, tag=None):
"""Substitute sub-expressions both on the lhs and rhs
Args:
var_map (dict): Dictionary with entries of the form
``{expr: substitution}``
"""
return self.apply(substitute, var_map=var_map, cont=cont, tag=tag... | python | def substitute(self, var_map, cont=False, tag=None):
"""Substitute sub-expressions both on the lhs and rhs
Args:
var_map (dict): Dictionary with entries of the form
``{expr: substitution}``
"""
return self.apply(substitute, var_map=var_map, cont=cont, tag=tag... | [
"def",
"substitute",
"(",
"self",
",",
"var_map",
",",
"cont",
"=",
"False",
",",
"tag",
"=",
"None",
")",
":",
"return",
"self",
".",
"apply",
"(",
"substitute",
",",
"var_map",
"=",
"var_map",
",",
"cont",
"=",
"cont",
",",
"tag",
"=",
"tag",
")"... | Substitute sub-expressions both on the lhs and rhs
Args:
var_map (dict): Dictionary with entries of the form
``{expr: substitution}`` | [
"Substitute",
"sub",
"-",
"expressions",
"both",
"on",
"the",
"lhs",
"and",
"rhs"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L193-L200 |
45,831 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.verify | def verify(self, func=None, *args, **kwargs):
"""Subtract the rhs from the lhs of the equation
Before the substraction, each side is expanded and any scalars are
simplified. If given, `func` with the positional arguments `args` and
keyword-arguments `kwargs` is applied to the result bef... | python | def verify(self, func=None, *args, **kwargs):
"""Subtract the rhs from the lhs of the equation
Before the substraction, each side is expanded and any scalars are
simplified. If given, `func` with the positional arguments `args` and
keyword-arguments `kwargs` is applied to the result bef... | [
"def",
"verify",
"(",
"self",
",",
"func",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"(",
"self",
".",
"lhs",
".",
"expand",
"(",
")",
".",
"simplify_scalar",
"(",
")",
"-",
"self",
".",
"rhs",
".",
"expand",... | Subtract the rhs from the lhs of the equation
Before the substraction, each side is expanded and any scalars are
simplified. If given, `func` with the positional arguments `args` and
keyword-arguments `kwargs` is applied to the result before returning
it.
You may complete the v... | [
"Subtract",
"the",
"rhs",
"from",
"the",
"lhs",
"of",
"the",
"equation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L219-L236 |
45,832 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.copy | def copy(self):
"""Return a copy of the equation"""
return Eq(
self._lhs, self._rhs, tag=self._tag,
_prev_lhs=self._prev_lhs, _prev_rhs=self._prev_rhs,
_prev_tags=self._prev_tags) | python | def copy(self):
"""Return a copy of the equation"""
return Eq(
self._lhs, self._rhs, tag=self._tag,
_prev_lhs=self._prev_lhs, _prev_rhs=self._prev_rhs,
_prev_tags=self._prev_tags) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Eq",
"(",
"self",
".",
"_lhs",
",",
"self",
".",
"_rhs",
",",
"tag",
"=",
"self",
".",
"_tag",
",",
"_prev_lhs",
"=",
"self",
".",
"_prev_lhs",
",",
"_prev_rhs",
"=",
"self",
".",
"_prev_rhs",
",",
... | Return a copy of the equation | [
"Return",
"a",
"copy",
"of",
"the",
"equation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L238-L243 |
45,833 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.free_symbols | def free_symbols(self):
"""Set of free SymPy symbols contained within the equation."""
try:
lhs_syms = self.lhs.free_symbols
except AttributeError:
lhs_syms = set()
try:
rhs_syms = self.rhs.free_symbols
except AttributeError:
rhs_sy... | python | def free_symbols(self):
"""Set of free SymPy symbols contained within the equation."""
try:
lhs_syms = self.lhs.free_symbols
except AttributeError:
lhs_syms = set()
try:
rhs_syms = self.rhs.free_symbols
except AttributeError:
rhs_sy... | [
"def",
"free_symbols",
"(",
"self",
")",
":",
"try",
":",
"lhs_syms",
"=",
"self",
".",
"lhs",
".",
"free_symbols",
"except",
"AttributeError",
":",
"lhs_syms",
"=",
"set",
"(",
")",
"try",
":",
"rhs_syms",
"=",
"self",
".",
"rhs",
".",
"free_symbols",
... | Set of free SymPy symbols contained within the equation. | [
"Set",
"of",
"free",
"SymPy",
"symbols",
"contained",
"within",
"the",
"equation",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L246-L256 |
45,834 | mabuchilab/QNET | src/qnet/algebra/toolbox/equation.py | Eq.bound_symbols | def bound_symbols(self):
"""Set of bound SymPy symbols contained within the equation."""
try:
lhs_syms = self.lhs.bound_symbols
except AttributeError:
lhs_syms = set()
try:
rhs_syms = self.rhs.bound_symbols
except AttributeError:
rh... | python | def bound_symbols(self):
"""Set of bound SymPy symbols contained within the equation."""
try:
lhs_syms = self.lhs.bound_symbols
except AttributeError:
lhs_syms = set()
try:
rhs_syms = self.rhs.bound_symbols
except AttributeError:
rh... | [
"def",
"bound_symbols",
"(",
"self",
")",
":",
"try",
":",
"lhs_syms",
"=",
"self",
".",
"lhs",
".",
"bound_symbols",
"except",
"AttributeError",
":",
"lhs_syms",
"=",
"set",
"(",
")",
"try",
":",
"rhs_syms",
"=",
"self",
".",
"rhs",
".",
"bound_symbols"... | Set of bound SymPy symbols contained within the equation. | [
"Set",
"of",
"bound",
"SymPy",
"symbols",
"contained",
"within",
"the",
"equation",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/toolbox/equation.py#L259-L269 |
45,835 | mabuchilab/QNET | src/qnet/convert/to_sympy_matrix.py | SympyCreate | def SympyCreate(n):
"""Creation operator for a Hilbert space of dimension `n`, as an instance
of `sympy.Matrix`"""
a = sympy.zeros(n)
for i in range(1, n):
a += sympy.sqrt(i) * basis_state(i, n) * basis_state(i-1, n).H
return a | python | def SympyCreate(n):
"""Creation operator for a Hilbert space of dimension `n`, as an instance
of `sympy.Matrix`"""
a = sympy.zeros(n)
for i in range(1, n):
a += sympy.sqrt(i) * basis_state(i, n) * basis_state(i-1, n).H
return a | [
"def",
"SympyCreate",
"(",
"n",
")",
":",
"a",
"=",
"sympy",
".",
"zeros",
"(",
"n",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"n",
")",
":",
"a",
"+=",
"sympy",
".",
"sqrt",
"(",
"i",
")",
"*",
"basis_state",
"(",
"i",
",",
"n",
")",
... | Creation operator for a Hilbert space of dimension `n`, as an instance
of `sympy.Matrix` | [
"Creation",
"operator",
"for",
"a",
"Hilbert",
"space",
"of",
"dimension",
"n",
"as",
"an",
"instance",
"of",
"sympy",
".",
"Matrix"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/convert/to_sympy_matrix.py#L27-L33 |
45,836 | django-fluent/django-fluent-blogs | fluent_blogs/admin/abstractbase.py | AbstractEntryBaseAdmin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Allow formfield_overrides to contain field names too.
"""
overrides = self.formfield_overrides.get(db_field.name)
if overrides:
kwargs.update(overrides)
field = super(AbstractEntryBaseAdmin, self).formf... | python | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Allow formfield_overrides to contain field names too.
"""
overrides = self.formfield_overrides.get(db_field.name)
if overrides:
kwargs.update(overrides)
field = super(AbstractEntryBaseAdmin, self).formf... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"overrides",
"=",
"self",
".",
"formfield_overrides",
".",
"get",
"(",
"db_field",
".",
"name",
")",
"if",
"overrides",
":",
"kwargs",
".",
"update",
"(",
"o... | Allow formfield_overrides to contain field names too. | [
"Allow",
"formfield_overrides",
"to",
"contain",
"field",
"names",
"too",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/admin/abstractbase.py#L72-L85 |
45,837 | mabuchilab/QNET | src/qnet/printing/asciiprinter.py | QnetAsciiPrinter._split_op | def _split_op(
self, identifier, hs_label=None, dagger=False, args=None):
"""Return `name`, total `subscript`, total `superscript` and
`arguments` str. All of the returned strings are fully rendered.
Args:
identifier (str or SymbolicLabelBase): A (non-rendered/ascii)
... | python | def _split_op(
self, identifier, hs_label=None, dagger=False, args=None):
"""Return `name`, total `subscript`, total `superscript` and
`arguments` str. All of the returned strings are fully rendered.
Args:
identifier (str or SymbolicLabelBase): A (non-rendered/ascii)
... | [
"def",
"_split_op",
"(",
"self",
",",
"identifier",
",",
"hs_label",
"=",
"None",
",",
"dagger",
"=",
"False",
",",
"args",
"=",
"None",
")",
":",
"if",
"self",
".",
"_isinstance",
"(",
"identifier",
",",
"'SymbolicLabelBase'",
")",
":",
"identifier",
"=... | Return `name`, total `subscript`, total `superscript` and
`arguments` str. All of the returned strings are fully rendered.
Args:
identifier (str or SymbolicLabelBase): A (non-rendered/ascii)
identifier that may include a subscript. The output `name` will
be t... | [
"Return",
"name",
"total",
"subscript",
"total",
"superscript",
"and",
"arguments",
"str",
".",
"All",
"of",
"the",
"returned",
"strings",
"are",
"fully",
"rendered",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/asciiprinter.py#L66-L106 |
45,838 | mabuchilab/QNET | src/qnet/printing/asciiprinter.py | QnetAsciiPrinter._render_hs_label | def _render_hs_label(self, hs):
"""Return the label of the given Hilbert space as a string"""
if isinstance(hs.__class__, Singleton):
return self._render_str(hs.label)
else:
return self._tensor_sym.join(
[self._render_str(ls.label) for ls in hs.local_facto... | python | def _render_hs_label(self, hs):
"""Return the label of the given Hilbert space as a string"""
if isinstance(hs.__class__, Singleton):
return self._render_str(hs.label)
else:
return self._tensor_sym.join(
[self._render_str(ls.label) for ls in hs.local_facto... | [
"def",
"_render_hs_label",
"(",
"self",
",",
"hs",
")",
":",
"if",
"isinstance",
"(",
"hs",
".",
"__class__",
",",
"Singleton",
")",
":",
"return",
"self",
".",
"_render_str",
"(",
"hs",
".",
"label",
")",
"else",
":",
"return",
"self",
".",
"_tensor_s... | Return the label of the given Hilbert space as a string | [
"Return",
"the",
"label",
"of",
"the",
"given",
"Hilbert",
"space",
"as",
"a",
"string"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/asciiprinter.py#L112-L118 |
45,839 | mabuchilab/QNET | src/qnet/printing/asciiprinter.py | QnetAsciiPrinter.parenthesize | def parenthesize(self, expr, level, *args, strict=False, **kwargs):
"""Render `expr` and wrap the result in parentheses if the precedence
of `expr` is below the given `level` (or at the given `level` if
`strict` is True. Extra `args` and `kwargs` are passed to the internal
`doit` rendere... | python | def parenthesize(self, expr, level, *args, strict=False, **kwargs):
"""Render `expr` and wrap the result in parentheses if the precedence
of `expr` is below the given `level` (or at the given `level` if
`strict` is True. Extra `args` and `kwargs` are passed to the internal
`doit` rendere... | [
"def",
"parenthesize",
"(",
"self",
",",
"expr",
",",
"level",
",",
"*",
"args",
",",
"strict",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"needs_parenths",
"=",
"(",
"(",
"precedence",
"(",
"expr",
")",
"<",
"level",
")",
"or",
"(",
"strict"... | Render `expr` and wrap the result in parentheses if the precedence
of `expr` is below the given `level` (or at the given `level` if
`strict` is True. Extra `args` and `kwargs` are passed to the internal
`doit` renderer | [
"Render",
"expr",
"and",
"wrap",
"the",
"result",
"in",
"parentheses",
"if",
"the",
"precedence",
"of",
"expr",
"is",
"below",
"the",
"given",
"level",
"(",
"or",
"at",
"the",
"given",
"level",
"if",
"strict",
"is",
"True",
".",
"Extra",
"args",
"and",
... | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/asciiprinter.py#L180-L193 |
45,840 | mabuchilab/QNET | src/qnet/visualization/circuit_pyx.py | draw_circuit | def draw_circuit(circuit, filename, direction = 'lr',
hunit = HUNIT, vunit = VUNIT,
rhmargin = RHMARGIN, rvmargin = RVMARGIN,
rpermutation_length = RPLENGTH,
draw_boxes = True,
permutation_arrows = False):
"""
Generate a graphic representation of circu... | python | def draw_circuit(circuit, filename, direction = 'lr',
hunit = HUNIT, vunit = VUNIT,
rhmargin = RHMARGIN, rvmargin = RVMARGIN,
rpermutation_length = RPLENGTH,
draw_boxes = True,
permutation_arrows = False):
"""
Generate a graphic representation of circu... | [
"def",
"draw_circuit",
"(",
"circuit",
",",
"filename",
",",
"direction",
"=",
"'lr'",
",",
"hunit",
"=",
"HUNIT",
",",
"vunit",
"=",
"VUNIT",
",",
"rhmargin",
"=",
"RHMARGIN",
",",
"rvmargin",
"=",
"RVMARGIN",
",",
"rpermutation_length",
"=",
"RPLENGTH",
... | Generate a graphic representation of circuit and store them in a file.
The graphics format is determined from the file extension.
:param circuit: The circuit expression
:type circuit: ca.Circuit
:param filename: A filepath to store the output image under. The file name suffix determines the output grap... | [
"Generate",
"a",
"graphic",
"representation",
"of",
"circuit",
"and",
"store",
"them",
"in",
"a",
"file",
".",
"The",
"graphics",
"format",
"is",
"determined",
"from",
"the",
"file",
"extension",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/visualization/circuit_pyx.py#L266-L326 |
45,841 | mabuchilab/QNET | src/qnet/utils/containers.py | nested_tuple | def nested_tuple(container):
"""Recursively transform a container structure to a nested tuple.
The function understands container types inheriting from the selected abstract base
classes in `collections.abc`, and performs the following replacements:
`Mapping`
`tuple` of key-value pair `tuple`s.... | python | def nested_tuple(container):
"""Recursively transform a container structure to a nested tuple.
The function understands container types inheriting from the selected abstract base
classes in `collections.abc`, and performs the following replacements:
`Mapping`
`tuple` of key-value pair `tuple`s.... | [
"def",
"nested_tuple",
"(",
"container",
")",
":",
"if",
"isinstance",
"(",
"container",
",",
"OrderedDict",
")",
":",
"return",
"tuple",
"(",
"map",
"(",
"nested_tuple",
",",
"container",
".",
"items",
"(",
")",
")",
")",
"if",
"isinstance",
"(",
"conta... | Recursively transform a container structure to a nested tuple.
The function understands container types inheriting from the selected abstract base
classes in `collections.abc`, and performs the following replacements:
`Mapping`
`tuple` of key-value pair `tuple`s. The order is preserved in the case ... | [
"Recursively",
"transform",
"a",
"container",
"structure",
"to",
"a",
"nested",
"tuple",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/utils/containers.py#L40-L84 |
45,842 | mabuchilab/QNET | src/qnet/printing/_precedence.py | precedence | def precedence(item):
"""Returns the precedence of a given object."""
try:
mro = item.__class__.__mro__
except AttributeError:
return PRECEDENCE["Atom"]
for i in mro:
n = i.__name__
if n in PRECEDENCE_FUNCTIONS:
return PRECEDENCE_FUNCTIONS[n](item)
eli... | python | def precedence(item):
"""Returns the precedence of a given object."""
try:
mro = item.__class__.__mro__
except AttributeError:
return PRECEDENCE["Atom"]
for i in mro:
n = i.__name__
if n in PRECEDENCE_FUNCTIONS:
return PRECEDENCE_FUNCTIONS[n](item)
eli... | [
"def",
"precedence",
"(",
"item",
")",
":",
"try",
":",
"mro",
"=",
"item",
".",
"__class__",
".",
"__mro__",
"except",
"AttributeError",
":",
"return",
"PRECEDENCE",
"[",
"\"Atom\"",
"]",
"for",
"i",
"in",
"mro",
":",
"n",
"=",
"i",
".",
"__name__",
... | Returns the precedence of a given object. | [
"Returns",
"the",
"precedence",
"of",
"a",
"given",
"object",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_precedence.py#L96-L108 |
45,843 | takluyver/backcall | backcall/backcall.py | callback_prototype | def callback_prototype(prototype):
"""Decorator to process a callback prototype.
A callback prototype is a function whose signature includes all the values
that will be passed by the callback API in question.
The original function will be returned, with a ``prototype.adapt`` attribute
whic... | python | def callback_prototype(prototype):
"""Decorator to process a callback prototype.
A callback prototype is a function whose signature includes all the values
that will be passed by the callback API in question.
The original function will be returned, with a ``prototype.adapt`` attribute
whic... | [
"def",
"callback_prototype",
"(",
"prototype",
")",
":",
"protosig",
"=",
"signature",
"(",
"prototype",
")",
"positional",
",",
"keyword",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"name",
",",
"param",
"in",
"protosig",
".",
"parameters",
".",
"items",
"(",... | Decorator to process a callback prototype.
A callback prototype is a function whose signature includes all the values
that will be passed by the callback API in question.
The original function will be returned, with a ``prototype.adapt`` attribute
which can be used to prepare third party callb... | [
"Decorator",
"to",
"process",
"a",
"callback",
"prototype",
".",
"A",
"callback",
"prototype",
"is",
"a",
"function",
"whose",
"signature",
"includes",
"all",
"the",
"values",
"that",
"will",
"be",
"passed",
"by",
"the",
"callback",
"API",
"in",
"question",
... | cff13f5e4bd2a2af82fc5174e38cca0f9b7c21d2 | https://github.com/takluyver/backcall/blob/cff13f5e4bd2a2af82fc5174e38cca0f9b7c21d2/backcall/backcall.py#L27-L109 |
45,844 | django-fluent/django-fluent-blogs | fluent_blogs/managers.py | EntryQuerySet.published | def published(self, for_user=None):
"""
Return only published entries for the current site.
"""
if appsettings.FLUENT_BLOGS_FILTER_SITE_ID:
qs = self.parent_site(settings.SITE_ID)
else:
qs = self
if for_user is not None and for_user.is_staff:
... | python | def published(self, for_user=None):
"""
Return only published entries for the current site.
"""
if appsettings.FLUENT_BLOGS_FILTER_SITE_ID:
qs = self.parent_site(settings.SITE_ID)
else:
qs = self
if for_user is not None and for_user.is_staff:
... | [
"def",
"published",
"(",
"self",
",",
"for_user",
"=",
"None",
")",
":",
"if",
"appsettings",
".",
"FLUENT_BLOGS_FILTER_SITE_ID",
":",
"qs",
"=",
"self",
".",
"parent_site",
"(",
"settings",
".",
"SITE_ID",
")",
"else",
":",
"qs",
"=",
"self",
"if",
"for... | Return only published entries for the current site. | [
"Return",
"only",
"published",
"entries",
"for",
"the",
"current",
"site",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/managers.py#L26-L46 |
45,845 | django-fluent/django-fluent-blogs | fluent_blogs/managers.py | EntryQuerySet.authors | def authors(self, *usernames):
"""
Return the entries written by the given usernames
When multiple tags are provided, they operate as "OR" query.
"""
if len(usernames) == 1:
return self.filter(**{"author__{}".format(User.USERNAME_FIELD): usernames[0]})
else:
... | python | def authors(self, *usernames):
"""
Return the entries written by the given usernames
When multiple tags are provided, they operate as "OR" query.
"""
if len(usernames) == 1:
return self.filter(**{"author__{}".format(User.USERNAME_FIELD): usernames[0]})
else:
... | [
"def",
"authors",
"(",
"self",
",",
"*",
"usernames",
")",
":",
"if",
"len",
"(",
"usernames",
")",
"==",
"1",
":",
"return",
"self",
".",
"filter",
"(",
"*",
"*",
"{",
"\"author__{}\"",
".",
"format",
"(",
"User",
".",
"USERNAME_FIELD",
")",
":",
... | Return the entries written by the given usernames
When multiple tags are provided, they operate as "OR" query. | [
"Return",
"the",
"entries",
"written",
"by",
"the",
"given",
"usernames",
"When",
"multiple",
"tags",
"are",
"provided",
"they",
"operate",
"as",
"OR",
"query",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/managers.py#L48-L56 |
45,846 | django-fluent/django-fluent-blogs | fluent_blogs/managers.py | EntryQuerySet.categories | def categories(self, *category_slugs):
"""
Return the entries with the given category slugs.
When multiple tags are provided, they operate as "OR" query.
"""
categories_field = getattr(self.model, 'categories', None)
if categories_field is None:
raise Attribut... | python | def categories(self, *category_slugs):
"""
Return the entries with the given category slugs.
When multiple tags are provided, they operate as "OR" query.
"""
categories_field = getattr(self.model, 'categories', None)
if categories_field is None:
raise Attribut... | [
"def",
"categories",
"(",
"self",
",",
"*",
"category_slugs",
")",
":",
"categories_field",
"=",
"getattr",
"(",
"self",
".",
"model",
",",
"'categories'",
",",
"None",
")",
"if",
"categories_field",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"The ... | Return the entries with the given category slugs.
When multiple tags are provided, they operate as "OR" query. | [
"Return",
"the",
"entries",
"with",
"the",
"given",
"category",
"slugs",
".",
"When",
"multiple",
"tags",
"are",
"provided",
"they",
"operate",
"as",
"OR",
"query",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/managers.py#L58-L83 |
45,847 | django-fluent/django-fluent-blogs | fluent_blogs/managers.py | EntryQuerySet.tagged | def tagged(self, *tag_slugs):
"""
Return the items which are tagged with a specific tag.
When multiple tags are provided, they operate as "OR" query.
"""
if getattr(self.model, 'tags', None) is None:
raise AttributeError("The {0} does not include TagsEntryMixin".forma... | python | def tagged(self, *tag_slugs):
"""
Return the items which are tagged with a specific tag.
When multiple tags are provided, they operate as "OR" query.
"""
if getattr(self.model, 'tags', None) is None:
raise AttributeError("The {0} does not include TagsEntryMixin".forma... | [
"def",
"tagged",
"(",
"self",
",",
"*",
"tag_slugs",
")",
":",
"if",
"getattr",
"(",
"self",
".",
"model",
",",
"'tags'",
",",
"None",
")",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"The {0} does not include TagsEntryMixin\"",
".",
"format",
"(",
... | Return the items which are tagged with a specific tag.
When multiple tags are provided, they operate as "OR" query. | [
"Return",
"the",
"items",
"which",
"are",
"tagged",
"with",
"a",
"specific",
"tag",
".",
"When",
"multiple",
"tags",
"are",
"provided",
"they",
"operate",
"as",
"OR",
"query",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/managers.py#L85-L96 |
45,848 | mabuchilab/QNET | src/qnet/printing/unicodeprinter.py | SubSupFmt.format | def format(self, **kwargs):
"""Format and combine the name, subscript, and superscript"""
name = self.name.format(**kwargs)
subs = []
if self.sub is not None:
subs = [self.sub.format(**kwargs)]
supers = []
if self.sup is not None:
supers = [self.s... | python | def format(self, **kwargs):
"""Format and combine the name, subscript, and superscript"""
name = self.name.format(**kwargs)
subs = []
if self.sub is not None:
subs = [self.sub.format(**kwargs)]
supers = []
if self.sup is not None:
supers = [self.s... | [
"def",
"format",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"self",
".",
"name",
".",
"format",
"(",
"*",
"*",
"kwargs",
")",
"subs",
"=",
"[",
"]",
"if",
"self",
".",
"sub",
"is",
"not",
"None",
":",
"subs",
"=",
"[",
"self... | Format and combine the name, subscript, and superscript | [
"Format",
"and",
"combine",
"the",
"name",
"subscript",
"and",
"superscript"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/unicodeprinter.py#L31-L44 |
45,849 | mabuchilab/QNET | src/qnet/printing/unicodeprinter.py | QnetUnicodePrinter._render_str | def _render_str(self, string):
"""Returned a unicodified version of the string"""
if isinstance(string, StrLabel):
string = string._render(string.expr)
string = str(string)
if len(string) == 0:
return ''
name, supers, subs = split_super_sub(string)
... | python | def _render_str(self, string):
"""Returned a unicodified version of the string"""
if isinstance(string, StrLabel):
string = string._render(string.expr)
string = str(string)
if len(string) == 0:
return ''
name, supers, subs = split_super_sub(string)
... | [
"def",
"_render_str",
"(",
"self",
",",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"StrLabel",
")",
":",
"string",
"=",
"string",
".",
"_render",
"(",
"string",
".",
"expr",
")",
"string",
"=",
"str",
"(",
"string",
")",
"if",
"len",... | Returned a unicodified version of the string | [
"Returned",
"a",
"unicodified",
"version",
"of",
"the",
"string"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/unicodeprinter.py#L78-L88 |
45,850 | mabuchilab/QNET | src/qnet/algebra/library/pauli_matrices.py | PauliX | def PauliX(local_space, states=None):
r"""Pauli-type X-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}
on an arbitrary two-level system.
Args:
local_space (str or int or .LocalSpace): Associated Hilbert space.
... | python | def PauliX(local_space, states=None):
r"""Pauli-type X-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}
on an arbitrary two-level system.
Args:
local_space (str or int or .LocalSpace): Associated Hilbert space.
... | [
"def",
"PauliX",
"(",
"local_space",
",",
"states",
"=",
"None",
")",
":",
"local_space",
",",
"states",
"=",
"_get_pauli_args",
"(",
"local_space",
",",
"states",
")",
"g",
",",
"e",
"=",
"states",
"return",
"(",
"LocalSigma",
".",
"create",
"(",
"g",
... | r"""Pauli-type X-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}
on an arbitrary two-level system.
Args:
local_space (str or int or .LocalSpace): Associated Hilbert space.
If :class:`str` or :class:`int`, a :cla... | [
"r",
"Pauli",
"-",
"type",
"X",
"-",
"operator"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/library/pauli_matrices.py#L22-L50 |
45,851 | mabuchilab/QNET | src/qnet/algebra/library/pauli_matrices.py | PauliY | def PauliY(local_space, states=None):
r""" Pauli-type Y-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & -i \\
i & 0
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX`
"""
local_space, states = _get_pauli_args(local_space, state... | python | def PauliY(local_space, states=None):
r""" Pauli-type Y-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & -i \\
i & 0
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX`
"""
local_space, states = _get_pauli_args(local_space, state... | [
"def",
"PauliY",
"(",
"local_space",
",",
"states",
"=",
"None",
")",
":",
"local_space",
",",
"states",
"=",
"_get_pauli_args",
"(",
"local_space",
",",
"states",
")",
"g",
",",
"e",
"=",
"states",
"return",
"I",
"*",
"(",
"-",
"LocalSigma",
".",
"cre... | r""" Pauli-type Y-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
0 & -i \\
i & 0
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX` | [
"r",
"Pauli",
"-",
"type",
"Y",
"-",
"operator"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/library/pauli_matrices.py#L53-L71 |
45,852 | mabuchilab/QNET | src/qnet/algebra/library/pauli_matrices.py | PauliZ | def PauliZ(local_space, states=None):
r"""Pauli-type Z-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
1 & 0 \\
0 & -1
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX`
"""
local_space, states = _get_pauli_args(local_space, states)... | python | def PauliZ(local_space, states=None):
r"""Pauli-type Z-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
1 & 0 \\
0 & -1
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX`
"""
local_space, states = _get_pauli_args(local_space, states)... | [
"def",
"PauliZ",
"(",
"local_space",
",",
"states",
"=",
"None",
")",
":",
"local_space",
",",
"states",
"=",
"_get_pauli_args",
"(",
"local_space",
",",
"states",
")",
"g",
",",
"e",
"=",
"states",
"return",
"(",
"LocalProjector",
"(",
"g",
",",
"hs",
... | r"""Pauli-type Z-operator
.. math::
\hat{\sigma}_x = \begin{pmatrix}
1 & 0 \\
0 & -1
\end{pmatrix}
on an arbitrary two-level system.
See :func:`PauliX` | [
"r",
"Pauli",
"-",
"type",
"Z",
"-",
"operator"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/library/pauli_matrices.py#L74-L91 |
45,853 | mabuchilab/QNET | src/qnet/printing/_render_head_repr.py | render_head_repr | def render_head_repr(
expr: Any, sub_render=None, key_sub_render=None) -> str:
"""Render a textual representation of `expr` using
Positional and keyword arguments are recursively
rendered using `sub_render`, which defaults to `render_head_repr` by
default. If desired, a different renderer may b... | python | def render_head_repr(
expr: Any, sub_render=None, key_sub_render=None) -> str:
"""Render a textual representation of `expr` using
Positional and keyword arguments are recursively
rendered using `sub_render`, which defaults to `render_head_repr` by
default. If desired, a different renderer may b... | [
"def",
"render_head_repr",
"(",
"expr",
":",
"Any",
",",
"sub_render",
"=",
"None",
",",
"key_sub_render",
"=",
"None",
")",
"->",
"str",
":",
"head_repr_fmt",
"=",
"r'{head}({args}{kwargs})'",
"if",
"sub_render",
"is",
"None",
":",
"sub_render",
"=",
"render_... | Render a textual representation of `expr` using
Positional and keyword arguments are recursively
rendered using `sub_render`, which defaults to `render_head_repr` by
default. If desired, a different renderer may be used for keyword
arguments by giving `key_sub_renderer`
Raises:
AttributeEr... | [
"Render",
"a",
"textual",
"representation",
"of",
"expr",
"using",
"Positional",
"and",
"keyword",
"arguments",
"are",
"recursively",
"rendered",
"using",
"sub_render",
"which",
"defaults",
"to",
"render_head_repr",
"by",
"default",
".",
"If",
"desired",
"a",
"dif... | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_render_head_repr.py#L10-L59 |
45,854 | mabuchilab/QNET | src/qnet/utils/check_rules.py | check_rules_dict | def check_rules_dict(rules):
"""Verify the `rules` that classes may use for the `_rules` or
`_binary_rules` class attribute.
Specifically, `rules` must be a
:class:`~collections.OrderedDict`-compatible object
(list of key-value tuples, :class:`dict`,
:class:`~collections.OrderedDict`)
that ... | python | def check_rules_dict(rules):
"""Verify the `rules` that classes may use for the `_rules` or
`_binary_rules` class attribute.
Specifically, `rules` must be a
:class:`~collections.OrderedDict`-compatible object
(list of key-value tuples, :class:`dict`,
:class:`~collections.OrderedDict`)
that ... | [
"def",
"check_rules_dict",
"(",
"rules",
")",
":",
"from",
"qnet",
".",
"algebra",
".",
"pattern_matching",
"import",
"Pattern",
",",
"ProtoExpr",
"if",
"hasattr",
"(",
"rules",
",",
"'items'",
")",
":",
"items",
"=",
"rules",
".",
"items",
"(",
")",
"# ... | Verify the `rules` that classes may use for the `_rules` or
`_binary_rules` class attribute.
Specifically, `rules` must be a
:class:`~collections.OrderedDict`-compatible object
(list of key-value tuples, :class:`dict`,
:class:`~collections.OrderedDict`)
that maps a rule name (:class:`str`) to a... | [
"Verify",
"the",
"rules",
"that",
"classes",
"may",
"use",
"for",
"the",
"_rules",
"or",
"_binary_rules",
"class",
"attribute",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/utils/check_rules.py#L9-L76 |
45,855 | mabuchilab/QNET | src/qnet/printing/sympy.py | derationalize_denom | def derationalize_denom(expr):
"""Try to de-rationalize the denominator of the given expression.
The purpose is to allow to reconstruct e.g. ``1/sqrt(2)`` from
``sqrt(2)/2``.
Specifically, this matches `expr` against the following pattern::
Mul(..., Rational(n, d), Pow(d, Rational(1, 2)), ...... | python | def derationalize_denom(expr):
"""Try to de-rationalize the denominator of the given expression.
The purpose is to allow to reconstruct e.g. ``1/sqrt(2)`` from
``sqrt(2)/2``.
Specifically, this matches `expr` against the following pattern::
Mul(..., Rational(n, d), Pow(d, Rational(1, 2)), ...... | [
"def",
"derationalize_denom",
"(",
"expr",
")",
":",
"r_pos",
"=",
"-",
"1",
"p_pos",
"=",
"-",
"1",
"numerator",
"=",
"S",
".",
"Zero",
"denom_sq",
"=",
"S",
".",
"One",
"post_factors",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"expr",
",",
"Mul",
"... | Try to de-rationalize the denominator of the given expression.
The purpose is to allow to reconstruct e.g. ``1/sqrt(2)`` from
``sqrt(2)/2``.
Specifically, this matches `expr` against the following pattern::
Mul(..., Rational(n, d), Pow(d, Rational(1, 2)), ...)
and returns a tuple ``(numerato... | [
"Try",
"to",
"de",
"-",
"rationalize",
"the",
"denominator",
"of",
"the",
"given",
"expression",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/sympy.py#L50-L93 |
45,856 | django-fluent/django-fluent-blogs | fluent_blogs/pagetypes/blogpage/models.py | BlogPage.entries | def entries(self):
"""
Return the entries that are published under this node.
"""
# Since there is currently no filtering in place, return all entries.
EntryModel = get_entry_model()
qs = get_entry_model().objects.order_by('-publication_date')
# Only limit to cur... | python | def entries(self):
"""
Return the entries that are published under this node.
"""
# Since there is currently no filtering in place, return all entries.
EntryModel = get_entry_model()
qs = get_entry_model().objects.order_by('-publication_date')
# Only limit to cur... | [
"def",
"entries",
"(",
"self",
")",
":",
"# Since there is currently no filtering in place, return all entries.",
"EntryModel",
"=",
"get_entry_model",
"(",
")",
"qs",
"=",
"get_entry_model",
"(",
")",
".",
"objects",
".",
"order_by",
"(",
"'-publication_date'",
")",
... | Return the entries that are published under this node. | [
"Return",
"the",
"entries",
"that",
"are",
"published",
"under",
"this",
"node",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/pagetypes/blogpage/models.py#L16-L29 |
45,857 | django-fluent/django-fluent-blogs | fluent_blogs/pagetypes/blogpage/models.py | BlogPage.get_entry_url | def get_entry_url(self, entry):
"""
Return the URL of a blog entry, relative to this page.
"""
# It could be possible this page is fetched as fallback, while the 'entry' does have a translation.
# - Currently django-fluent-pages 1.0b3 `Page.objects.get_for_path()` assigns the lan... | python | def get_entry_url(self, entry):
"""
Return the URL of a blog entry, relative to this page.
"""
# It could be possible this page is fetched as fallback, while the 'entry' does have a translation.
# - Currently django-fluent-pages 1.0b3 `Page.objects.get_for_path()` assigns the lan... | [
"def",
"get_entry_url",
"(",
"self",
",",
"entry",
")",
":",
"# It could be possible this page is fetched as fallback, while the 'entry' does have a translation.",
"# - Currently django-fluent-pages 1.0b3 `Page.objects.get_for_path()` assigns the language of retrieval",
"# as current object la... | Return the URL of a blog entry, relative to this page. | [
"Return",
"the",
"URL",
"of",
"a",
"blog",
"entry",
"relative",
"to",
"this",
"page",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/pagetypes/blogpage/models.py#L31-L41 |
45,858 | django-fluent/django-fluent-blogs | fluent_blogs/base_models.py | ContentsEntryMixin.create_placeholder | def create_placeholder(self, slot="blog_contents", role='m', title=None):
"""
Create a placeholder on this blog entry.
To fill the content items, use
:func:`ContentItemModel.objects.create_for_placeholder() <fluent_contents.models.managers.ContentItemManager.create_for_placeholder>`.
... | python | def create_placeholder(self, slot="blog_contents", role='m', title=None):
"""
Create a placeholder on this blog entry.
To fill the content items, use
:func:`ContentItemModel.objects.create_for_placeholder() <fluent_contents.models.managers.ContentItemManager.create_for_placeholder>`.
... | [
"def",
"create_placeholder",
"(",
"self",
",",
"slot",
"=",
"\"blog_contents\"",
",",
"role",
"=",
"'m'",
",",
"title",
"=",
"None",
")",
":",
"return",
"Placeholder",
".",
"objects",
".",
"create_for_object",
"(",
"self",
",",
"slot",
",",
"role",
"=",
... | Create a placeholder on this blog entry.
To fill the content items, use
:func:`ContentItemModel.objects.create_for_placeholder() <fluent_contents.models.managers.ContentItemManager.create_for_placeholder>`.
:rtype: :class:`~fluent_contents.models.Placeholder` | [
"Create",
"a",
"placeholder",
"on",
"this",
"blog",
"entry",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/base_models.py#L256-L265 |
45,859 | niloch/iplotter | iplotter/export.py | VirtualBrowser.save_as_png | def save_as_png(self, filename, width=300, height=250, render_time=1):
"""Open saved html file in an virtual browser and save a screen shot to PNG format."""
self.driver.set_window_size(width, height)
self.driver.get('file://{path}/{filename}'.format(
path=os.getcwd(), filename=filen... | python | def save_as_png(self, filename, width=300, height=250, render_time=1):
"""Open saved html file in an virtual browser and save a screen shot to PNG format."""
self.driver.set_window_size(width, height)
self.driver.get('file://{path}/{filename}'.format(
path=os.getcwd(), filename=filen... | [
"def",
"save_as_png",
"(",
"self",
",",
"filename",
",",
"width",
"=",
"300",
",",
"height",
"=",
"250",
",",
"render_time",
"=",
"1",
")",
":",
"self",
".",
"driver",
".",
"set_window_size",
"(",
"width",
",",
"height",
")",
"self",
".",
"driver",
"... | Open saved html file in an virtual browser and save a screen shot to PNG format. | [
"Open",
"saved",
"html",
"file",
"in",
"an",
"virtual",
"browser",
"and",
"save",
"a",
"screen",
"shot",
"to",
"PNG",
"format",
"."
] | 0403486d8633f601a33c4d2b9c9fa3ec88e9327b | https://github.com/niloch/iplotter/blob/0403486d8633f601a33c4d2b9c9fa3ec88e9327b/iplotter/export.py#L16-L22 |
45,860 | mabuchilab/QNET | setup.py | get_version | def get_version(filename):
"""Extract the package version"""
with open(filename) as in_fh:
for line in in_fh:
if line.startswith('__version__'):
return line.split('=')[1].strip()[1:-1]
raise ValueError("Cannot extract version from %s" % filename) | python | def get_version(filename):
"""Extract the package version"""
with open(filename) as in_fh:
for line in in_fh:
if line.startswith('__version__'):
return line.split('=')[1].strip()[1:-1]
raise ValueError("Cannot extract version from %s" % filename) | [
"def",
"get_version",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"in_fh",
":",
"for",
"line",
"in",
"in_fh",
":",
"if",
"line",
".",
"startswith",
"(",
"'__version__'",
")",
":",
"return",
"line",
".",
"split",
"(",
"'='",
... | Extract the package version | [
"Extract",
"the",
"package",
"version"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/setup.py#L10-L16 |
45,861 | django-fluent/django-fluent-blogs | fluent_blogs/templatetags/fluent_blogs_tags.py | format_year | def format_year(year):
"""
Format the year value of the ``YearArchiveView``,
which can be a integer or date object.
This tag is no longer needed, but exists for template compatibility.
It was a compatibility tag for Django 1.4.
"""
if isinstance(year, (date, datetime)):
# Django 1.5... | python | def format_year(year):
"""
Format the year value of the ``YearArchiveView``,
which can be a integer or date object.
This tag is no longer needed, but exists for template compatibility.
It was a compatibility tag for Django 1.4.
"""
if isinstance(year, (date, datetime)):
# Django 1.5... | [
"def",
"format_year",
"(",
"year",
")",
":",
"if",
"isinstance",
"(",
"year",
",",
"(",
"date",
",",
"datetime",
")",
")",
":",
"# Django 1.5 and up, 'year' is a date object, consistent with month+day views.",
"return",
"unicode",
"(",
"year",
".",
"year",
")",
"e... | Format the year value of the ``YearArchiveView``,
which can be a integer or date object.
This tag is no longer needed, but exists for template compatibility.
It was a compatibility tag for Django 1.4. | [
"Format",
"the",
"year",
"value",
"of",
"the",
"YearArchiveView",
"which",
"can",
"be",
"a",
"integer",
"or",
"date",
"object",
"."
] | 86b148549a010eaca9a2ea987fe43be250e06c50 | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/templatetags/fluent_blogs_tags.py#L70-L83 |
45,862 | mabuchilab/QNET | src/qnet/algebra/core/indexed_operations.py | IndexedSum.free_symbols | def free_symbols(self):
"""Set of all free symbols"""
return set([
sym for sym in self.term.free_symbols
if sym not in self.bound_symbols]) | python | def free_symbols(self):
"""Set of all free symbols"""
return set([
sym for sym in self.term.free_symbols
if sym not in self.bound_symbols]) | [
"def",
"free_symbols",
"(",
"self",
")",
":",
"return",
"set",
"(",
"[",
"sym",
"for",
"sym",
"in",
"self",
".",
"term",
".",
"free_symbols",
"if",
"sym",
"not",
"in",
"self",
".",
"bound_symbols",
"]",
")"
] | Set of all free symbols | [
"Set",
"of",
"all",
"free",
"symbols"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/indexed_operations.py#L64-L68 |
45,863 | mabuchilab/QNET | src/qnet/algebra/core/indexed_operations.py | IndexedSum.terms | def terms(self):
"""Iterator over the terms of the sum
Yield from the (possibly) infinite list of terms of the indexed sum, if
the sum was written out explicitly. Each yielded term in an instance of
:class:`.Expression`
"""
from qnet.algebra.core.scalar_algebra import Sc... | python | def terms(self):
"""Iterator over the terms of the sum
Yield from the (possibly) infinite list of terms of the indexed sum, if
the sum was written out explicitly. Each yielded term in an instance of
:class:`.Expression`
"""
from qnet.algebra.core.scalar_algebra import Sc... | [
"def",
"terms",
"(",
"self",
")",
":",
"from",
"qnet",
".",
"algebra",
".",
"core",
".",
"scalar_algebra",
"import",
"ScalarValue",
"for",
"mapping",
"in",
"yield_from_ranges",
"(",
"self",
".",
"ranges",
")",
":",
"term",
"=",
"self",
".",
"term",
".",
... | Iterator over the terms of the sum
Yield from the (possibly) infinite list of terms of the indexed sum, if
the sum was written out explicitly. Each yielded term in an instance of
:class:`.Expression` | [
"Iterator",
"over",
"the",
"terms",
"of",
"the",
"sum"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/indexed_operations.py#L75-L88 |
45,864 | mabuchilab/QNET | src/qnet/algebra/core/indexed_operations.py | IndexedSum.doit | def doit(
self, classes=None, recursive=True, indices=None, max_terms=None,
**kwargs):
"""Write out the indexed sum explicitly
If `classes` is None or :class:`IndexedSum` is in `classes`,
(partially) write out the indexed sum in to an explicit sum of terms.
If `r... | python | def doit(
self, classes=None, recursive=True, indices=None, max_terms=None,
**kwargs):
"""Write out the indexed sum explicitly
If `classes` is None or :class:`IndexedSum` is in `classes`,
(partially) write out the indexed sum in to an explicit sum of terms.
If `r... | [
"def",
"doit",
"(",
"self",
",",
"classes",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"indices",
"=",
"None",
",",
"max_terms",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"doit",
"(",
"classes",
",",
... | Write out the indexed sum explicitly
If `classes` is None or :class:`IndexedSum` is in `classes`,
(partially) write out the indexed sum in to an explicit sum of terms.
If `recursive` is True, write out each of the new sum's summands by
calling its :meth:`doit` method.
Args:
... | [
"Write",
"out",
"the",
"indexed",
"sum",
"explicitly"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/indexed_operations.py#L100-L124 |
45,865 | mabuchilab/QNET | src/qnet/algebra/core/indexed_operations.py | IndexedSum.make_disjunct_indices | def make_disjunct_indices(self, *others):
"""Return a copy with modified indices to ensure disjunct indices with
`others`.
Each element in `others` may be an index symbol (:class:`.IdxSym`),
a index-range object (:class:`.IndexRangeBase`) or list of index-range
objects, or an in... | python | def make_disjunct_indices(self, *others):
"""Return a copy with modified indices to ensure disjunct indices with
`others`.
Each element in `others` may be an index symbol (:class:`.IdxSym`),
a index-range object (:class:`.IndexRangeBase`) or list of index-range
objects, or an in... | [
"def",
"make_disjunct_indices",
"(",
"self",
",",
"*",
"others",
")",
":",
"new",
"=",
"self",
"other_index_symbols",
"=",
"set",
"(",
")",
"for",
"other",
"in",
"others",
":",
"try",
":",
"if",
"isinstance",
"(",
"other",
",",
"IdxSym",
")",
":",
"oth... | Return a copy with modified indices to ensure disjunct indices with
`others`.
Each element in `others` may be an index symbol (:class:`.IdxSym`),
a index-range object (:class:`.IndexRangeBase`) or list of index-range
objects, or an indexed operation (something with a ``ranges`` attribut... | [
"Return",
"a",
"copy",
"with",
"modified",
"indices",
"to",
"ensure",
"disjunct",
"indices",
"with",
"others",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/indexed_operations.py#L194-L234 |
45,866 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_field_js_assets | def codemirror_field_js_assets(*args):
"""
Tag to render CodeMirror Javascript assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_js_assets form.myfield1 form.myfield2 %}
"""
manifesto = CodemirrorAssetTagRender()
manife... | python | def codemirror_field_js_assets(*args):
"""
Tag to render CodeMirror Javascript assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_js_assets form.myfield1 form.myfield2 %}
"""
manifesto = CodemirrorAssetTagRender()
manife... | [
"def",
"codemirror_field_js_assets",
"(",
"*",
"args",
")",
":",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"manifesto",
".",
"register_from_fields",
"(",
"*",
"args",
")",
"return",
"mark_safe",
"(",
"manifesto",
".",
"js_html",
"(",
")",
")"
] | Tag to render CodeMirror Javascript assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_js_assets form.myfield1 form.myfield2 %} | [
"Tag",
"to",
"render",
"CodeMirror",
"Javascript",
"assets",
"needed",
"for",
"all",
"given",
"fields",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L152-L165 |
45,867 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_field_css_assets | def codemirror_field_css_assets(*args):
"""
Tag to render CodeMirror CSS assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_css_assets form.myfield1 form.myfield2 %}
"""
manifesto = CodemirrorAssetTagRender()
manifesto.r... | python | def codemirror_field_css_assets(*args):
"""
Tag to render CodeMirror CSS assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_css_assets form.myfield1 form.myfield2 %}
"""
manifesto = CodemirrorAssetTagRender()
manifesto.r... | [
"def",
"codemirror_field_css_assets",
"(",
"*",
"args",
")",
":",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"manifesto",
".",
"register_from_fields",
"(",
"*",
"args",
")",
"return",
"mark_safe",
"(",
"manifesto",
".",
"css_html",
"(",
")",
")"
] | Tag to render CodeMirror CSS assets needed for all given fields.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror_field_css_assets form.myfield1 form.myfield2 %} | [
"Tag",
"to",
"render",
"CodeMirror",
"CSS",
"assets",
"needed",
"for",
"all",
"given",
"fields",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L169-L182 |
45,868 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_field_js_bundle | def codemirror_field_js_bundle(field):
"""
Filter to get CodeMirror Javascript bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_js_bundle }}
Arguments:
field (django.forms.fields.Field): A form field t... | python | def codemirror_field_js_bundle(field):
"""
Filter to get CodeMirror Javascript bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_js_bundle }}
Arguments:
field (django.forms.fields.Field): A form field t... | [
"def",
"codemirror_field_js_bundle",
"(",
"field",
")",
":",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"manifesto",
".",
"register_from_fields",
"(",
"field",
")",
"try",
":",
"bundle_name",
"=",
"manifesto",
".",
"js_bundle_names",
"(",
")",
"[",
... | Filter to get CodeMirror Javascript bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_js_bundle }}
Arguments:
field (django.forms.fields.Field): A form field that contains a widget
:class:`djangocod... | [
"Filter",
"to",
"get",
"CodeMirror",
"Javascript",
"bundle",
"name",
"needed",
"for",
"a",
"single",
"field",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L186-L217 |
45,869 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_field_css_bundle | def codemirror_field_css_bundle(field):
"""
Filter to get CodeMirror CSS bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_css_bundle }}
Arguments:
field (djangocodemirror.fields.CodeMirrorField): A for... | python | def codemirror_field_css_bundle(field):
"""
Filter to get CodeMirror CSS bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_css_bundle }}
Arguments:
field (djangocodemirror.fields.CodeMirrorField): A for... | [
"def",
"codemirror_field_css_bundle",
"(",
"field",
")",
":",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"manifesto",
".",
"register_from_fields",
"(",
"field",
")",
"try",
":",
"bundle_name",
"=",
"manifesto",
".",
"css_bundle_names",
"(",
")",
"[",
... | Filter to get CodeMirror CSS bundle name needed for a single field.
Example:
::
{% load djangocodemirror_tags %}
{{ form.myfield|codemirror_field_css_bundle }}
Arguments:
field (djangocodemirror.fields.CodeMirrorField): A form field.
Raises:
CodeMirrorFieldBundleE... | [
"Filter",
"to",
"get",
"CodeMirror",
"CSS",
"bundle",
"name",
"needed",
"for",
"a",
"single",
"field",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L221-L251 |
45,870 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_parameters | def codemirror_parameters(field):
"""
Filter to include CodeMirror parameters as a JSON string for a single
field.
This must be called only on an allready rendered field, meaning you must
not use this filter on a field before a form. Else, the field widget won't
be correctly initialized.
E... | python | def codemirror_parameters(field):
"""
Filter to include CodeMirror parameters as a JSON string for a single
field.
This must be called only on an allready rendered field, meaning you must
not use this filter on a field before a form. Else, the field widget won't
be correctly initialized.
E... | [
"def",
"codemirror_parameters",
"(",
"field",
")",
":",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"names",
"=",
"manifesto",
".",
"register_from_fields",
"(",
"field",
")",
"config",
"=",
"manifesto",
".",
"get_codemirror_parameters",
"(",
"names",
"... | Filter to include CodeMirror parameters as a JSON string for a single
field.
This must be called only on an allready rendered field, meaning you must
not use this filter on a field before a form. Else, the field widget won't
be correctly initialized.
Example:
::
{% load django... | [
"Filter",
"to",
"include",
"CodeMirror",
"parameters",
"as",
"a",
"JSON",
"string",
"for",
"a",
"single",
"field",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L255-L281 |
45,871 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | codemirror_instance | def codemirror_instance(config_name, varname, element_id, assets=True):
"""
Return HTML to init a CodeMirror instance for an element.
This will output the whole HTML needed to initialize a CodeMirror instance
with needed assets loading. Assets can be omitted with the ``assets``
option.
Example... | python | def codemirror_instance(config_name, varname, element_id, assets=True):
"""
Return HTML to init a CodeMirror instance for an element.
This will output the whole HTML needed to initialize a CodeMirror instance
with needed assets loading. Assets can be omitted with the ``assets``
option.
Example... | [
"def",
"codemirror_instance",
"(",
"config_name",
",",
"varname",
",",
"element_id",
",",
"assets",
"=",
"True",
")",
":",
"output",
"=",
"io",
".",
"StringIO",
"(",
")",
"manifesto",
"=",
"CodemirrorAssetTagRender",
"(",
")",
"manifesto",
".",
"register",
"... | Return HTML to init a CodeMirror instance for an element.
This will output the whole HTML needed to initialize a CodeMirror instance
with needed assets loading. Assets can be omitted with the ``assets``
option.
Example:
::
{% load djangocodemirror_tags %}
{% codemirror... | [
"Return",
"HTML",
"to",
"init",
"a",
"CodeMirror",
"instance",
"for",
"an",
"element",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L285-L328 |
45,872 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | CodemirrorAssetTagRender.resolve_widget | def resolve_widget(self, field):
"""
Given a Field or BoundField, return widget instance.
Todo:
Raise an exception if given field object does not have a
widget.
Arguments:
field (Field or BoundField): A field instance.
Returns:
d... | python | def resolve_widget(self, field):
"""
Given a Field or BoundField, return widget instance.
Todo:
Raise an exception if given field object does not have a
widget.
Arguments:
field (Field or BoundField): A field instance.
Returns:
d... | [
"def",
"resolve_widget",
"(",
"self",
",",
"field",
")",
":",
"# When filter is used within template we have to reach the field",
"# instance through the BoundField.",
"if",
"hasattr",
"(",
"field",
",",
"'field'",
")",
":",
"widget",
"=",
"field",
".",
"field",
".",
... | Given a Field or BoundField, return widget instance.
Todo:
Raise an exception if given field object does not have a
widget.
Arguments:
field (Field or BoundField): A field instance.
Returns:
django.forms.widgets.Widget: Retrieved widget from giv... | [
"Given",
"a",
"Field",
"or",
"BoundField",
"return",
"widget",
"instance",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L26-L48 |
45,873 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | CodemirrorAssetTagRender.register_from_fields | def register_from_fields(self, *args):
"""
Register config name from field widgets
Arguments:
*args: Fields that contains widget
:class:`djangocodemirror.widget.CodeMirrorWidget`.
Returns:
list: List of registered config names from fields.
... | python | def register_from_fields(self, *args):
"""
Register config name from field widgets
Arguments:
*args: Fields that contains widget
:class:`djangocodemirror.widget.CodeMirrorWidget`.
Returns:
list: List of registered config names from fields.
... | [
"def",
"register_from_fields",
"(",
"self",
",",
"*",
"args",
")",
":",
"names",
"=",
"[",
"]",
"for",
"field",
"in",
"args",
":",
"widget",
"=",
"self",
".",
"resolve_widget",
"(",
"field",
")",
"self",
".",
"register",
"(",
"widget",
".",
"config_nam... | Register config name from field widgets
Arguments:
*args: Fields that contains widget
:class:`djangocodemirror.widget.CodeMirrorWidget`.
Returns:
list: List of registered config names from fields. | [
"Register",
"config",
"name",
"from",
"field",
"widgets"
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L50-L68 |
45,874 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | CodemirrorAssetTagRender.render_asset_html | def render_asset_html(self, path, tag_template):
"""
Render HTML tag for a given path.
Arguments:
path (string): Relative path from static directory.
tag_template (string): Template string for HTML tag.
Returns:
string: HTML tag with url from given p... | python | def render_asset_html(self, path, tag_template):
"""
Render HTML tag for a given path.
Arguments:
path (string): Relative path from static directory.
tag_template (string): Template string for HTML tag.
Returns:
string: HTML tag with url from given p... | [
"def",
"render_asset_html",
"(",
"self",
",",
"path",
",",
"tag_template",
")",
":",
"url",
"=",
"os",
".",
"path",
".",
"join",
"(",
"settings",
".",
"STATIC_URL",
",",
"path",
")",
"return",
"tag_template",
".",
"format",
"(",
"url",
"=",
"url",
")"
... | Render HTML tag for a given path.
Arguments:
path (string): Relative path from static directory.
tag_template (string): Template string for HTML tag.
Returns:
string: HTML tag with url from given path. | [
"Render",
"HTML",
"tag",
"for",
"a",
"given",
"path",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L70-L83 |
45,875 | sveetch/djangocodemirror | djangocodemirror/templatetags/djangocodemirror_tags.py | CodemirrorAssetTagRender.codemirror_html | def codemirror_html(self, config_name, varname, element_id):
"""
Render HTML for a CodeMirror instance.
Since a CodeMirror instance have to be attached to a HTML element, this
method requires a HTML element identifier with or without the ``#``
prefix, it depends from template in... | python | def codemirror_html(self, config_name, varname, element_id):
"""
Render HTML for a CodeMirror instance.
Since a CodeMirror instance have to be attached to a HTML element, this
method requires a HTML element identifier with or without the ``#``
prefix, it depends from template in... | [
"def",
"codemirror_html",
"(",
"self",
",",
"config_name",
",",
"varname",
",",
"element_id",
")",
":",
"parameters",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"get_codemirror_parameters",
"(",
"config_name",
")",
",",
"sort_keys",
"=",
"True",
")",
"retu... | Render HTML for a CodeMirror instance.
Since a CodeMirror instance have to be attached to a HTML element, this
method requires a HTML element identifier with or without the ``#``
prefix, it depends from template in
``settings.CODEMIRROR_FIELD_INIT_JS`` (default one require to not
... | [
"Render",
"HTML",
"for",
"a",
"CodeMirror",
"instance",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/templatetags/djangocodemirror_tags.py#L123-L148 |
45,876 | mabuchilab/QNET | docs/conf.py | run_apidoc | def run_apidoc(_):
"""Generage API documentation"""
import better_apidoc
better_apidoc.main([
'better-apidoc',
'-t',
os.path.join('.', '_templates'),
'--force',
'--no-toc',
'--separate',
'-o',
os.path.join('.', 'API'),
os.path.join('..'... | python | def run_apidoc(_):
"""Generage API documentation"""
import better_apidoc
better_apidoc.main([
'better-apidoc',
'-t',
os.path.join('.', '_templates'),
'--force',
'--no-toc',
'--separate',
'-o',
os.path.join('.', 'API'),
os.path.join('..'... | [
"def",
"run_apidoc",
"(",
"_",
")",
":",
"import",
"better_apidoc",
"better_apidoc",
".",
"main",
"(",
"[",
"'better-apidoc'",
",",
"'-t'",
",",
"os",
".",
"path",
".",
"join",
"(",
"'.'",
",",
"'_templates'",
")",
",",
"'--force'",
",",
"'--no-toc'",
",... | Generage API documentation | [
"Generage",
"API",
"documentation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/conf.py#L22-L35 |
45,877 | mabuchilab/QNET | src/qnet/printing/treeprinting.py | _shorten_render | def _shorten_render(renderer, max_len):
"""Return a modified that returns the representation of expr, or '...' if
that representation is longer than `max_len`"""
def short_renderer(expr):
res = renderer(expr)
if len(res) > max_len:
return '...'
else:
return r... | python | def _shorten_render(renderer, max_len):
"""Return a modified that returns the representation of expr, or '...' if
that representation is longer than `max_len`"""
def short_renderer(expr):
res = renderer(expr)
if len(res) > max_len:
return '...'
else:
return r... | [
"def",
"_shorten_render",
"(",
"renderer",
",",
"max_len",
")",
":",
"def",
"short_renderer",
"(",
"expr",
")",
":",
"res",
"=",
"renderer",
"(",
"expr",
")",
"if",
"len",
"(",
"res",
")",
">",
"max_len",
":",
"return",
"'...'",
"else",
":",
"return",
... | Return a modified that returns the representation of expr, or '...' if
that representation is longer than `max_len` | [
"Return",
"a",
"modified",
"that",
"returns",
"the",
"representation",
"of",
"expr",
"or",
"...",
"if",
"that",
"representation",
"is",
"longer",
"than",
"max_len"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/treeprinting.py#L11-L22 |
45,878 | mabuchilab/QNET | src/qnet/algebra/__init__.py | init_algebra | def init_algebra(*, default_hs_cls='LocalSpace'):
"""Initialize the algebra system
Args:
default_hs_cls (str): The name of the :class:`.LocalSpace` subclass
that should be used when implicitly creating Hilbert spaces, e.g.
in :class:`.OperatorSymbol`
"""
from qnet.algeb... | python | def init_algebra(*, default_hs_cls='LocalSpace'):
"""Initialize the algebra system
Args:
default_hs_cls (str): The name of the :class:`.LocalSpace` subclass
that should be used when implicitly creating Hilbert spaces, e.g.
in :class:`.OperatorSymbol`
"""
from qnet.algeb... | [
"def",
"init_algebra",
"(",
"*",
",",
"default_hs_cls",
"=",
"'LocalSpace'",
")",
":",
"from",
"qnet",
".",
"algebra",
".",
"core",
".",
"hilbert_space_algebra",
"import",
"LocalSpace",
"from",
"qnet",
".",
"algebra",
".",
"core",
".",
"abstract_quantum_algebra"... | Initialize the algebra system
Args:
default_hs_cls (str): The name of the :class:`.LocalSpace` subclass
that should be used when implicitly creating Hilbert spaces, e.g.
in :class:`.OperatorSymbol` | [
"Initialize",
"the",
"algebra",
"system"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/__init__.py#L7-L22 |
45,879 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.register | def register(self, name):
"""
Register configuration for an editor instance.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.
Raises:
UnknowConfigError: If given config name does not exist in
... | python | def register(self, name):
"""
Register configuration for an editor instance.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.
Raises:
UnknowConfigError: If given config name does not exist in
... | [
"def",
"register",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"settings",
".",
"CODEMIRROR_SETTINGS",
":",
"msg",
"=",
"(",
"\"Given config name '{}' does not exists in \"",
"\"'settings.CODEMIRROR_SETTINGS'.\"",
")",
"raise",
"UnknowConfigError",
... | Register configuration for an editor instance.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.
Raises:
UnknowConfigError: If given config name does not exist in
``settings.CODEMIRROR_SETTINGS``.
... | [
"Register",
"configuration",
"for",
"an",
"editor",
"instance",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L49-L88 |
45,880 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.register_many | def register_many(self, *args):
"""
Register many configuration names.
Arguments:
*args: Config names as strings.
Returns:
list: List of registered configs.
"""
params = []
for name in args:
params.append(self.register(name))
... | python | def register_many(self, *args):
"""
Register many configuration names.
Arguments:
*args: Config names as strings.
Returns:
list: List of registered configs.
"""
params = []
for name in args:
params.append(self.register(name))
... | [
"def",
"register_many",
"(",
"self",
",",
"*",
"args",
")",
":",
"params",
"=",
"[",
"]",
"for",
"name",
"in",
"args",
":",
"params",
".",
"append",
"(",
"self",
".",
"register",
"(",
"name",
")",
")",
"return",
"params"
] | Register many configuration names.
Arguments:
*args: Config names as strings.
Returns:
list: List of registered configs. | [
"Register",
"many",
"configuration",
"names",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L90-L104 |
45,881 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.resolve_mode | def resolve_mode(self, name):
"""
From given mode name, return mode file path from
``settings.CODEMIRROR_MODES`` map.
Arguments:
name (string): Mode name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_MODES``.
... | python | def resolve_mode(self, name):
"""
From given mode name, return mode file path from
``settings.CODEMIRROR_MODES`` map.
Arguments:
name (string): Mode name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_MODES``.
... | [
"def",
"resolve_mode",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"settings",
".",
"CODEMIRROR_MODES",
":",
"msg",
"=",
"(",
"\"Given config name '{}' does not exists in \"",
"\"'settings.CODEMIRROR_MODES'.\"",
")",
"raise",
"UnknowModeError",
"(",... | From given mode name, return mode file path from
``settings.CODEMIRROR_MODES`` map.
Arguments:
name (string): Mode name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_MODES``.
Returns:
string: Mode file pa... | [
"From",
"given",
"mode",
"name",
"return",
"mode",
"file",
"path",
"from",
"settings",
".",
"CODEMIRROR_MODES",
"map",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L114-L134 |
45,882 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.resolve_theme | def resolve_theme(self, name):
"""
From given theme name, return theme file path from
``settings.CODEMIRROR_THEMES`` map.
Arguments:
name (string): Theme name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_THEM... | python | def resolve_theme(self, name):
"""
From given theme name, return theme file path from
``settings.CODEMIRROR_THEMES`` map.
Arguments:
name (string): Theme name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_THEM... | [
"def",
"resolve_theme",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"settings",
".",
"CODEMIRROR_THEMES",
":",
"msg",
"=",
"(",
"\"Given theme name '{}' does not exists in \"",
"\"'settings.CODEMIRROR_THEMES'.\"",
")",
"raise",
"UnknowThemeError",
"... | From given theme name, return theme file path from
``settings.CODEMIRROR_THEMES`` map.
Arguments:
name (string): Theme name.
Raises:
KeyError: When given name does not exist in
``settings.CODEMIRROR_THEMES``.
Returns:
string: Theme f... | [
"From",
"given",
"theme",
"name",
"return",
"theme",
"file",
"path",
"from",
"settings",
".",
"CODEMIRROR_THEMES",
"map",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L136-L156 |
45,883 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.get_configs | def get_configs(self, name=None):
"""
Returns registred configurations.
* If ``name`` argument is not given, default behavior is to return
every config from all registred config;
* If ``name`` argument is given, just return its config and nothing
else;
Keywo... | python | def get_configs(self, name=None):
"""
Returns registred configurations.
* If ``name`` argument is not given, default behavior is to return
every config from all registred config;
* If ``name`` argument is given, just return its config and nothing
else;
Keywo... | [
"def",
"get_configs",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"if",
"name",
"not",
"in",
"self",
".",
"registry",
":",
"msg",
"=",
"\"Given config name '{}' is not registered.\"",
"raise",
"NotRegisteredError",
"(",
"msg",
".",
"f... | Returns registred configurations.
* If ``name`` argument is not given, default behavior is to return
every config from all registred config;
* If ``name`` argument is given, just return its config and nothing
else;
Keyword Arguments:
name (string): Specific conf... | [
"Returns",
"registred",
"configurations",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L158-L183 |
45,884 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.get_config | def get_config(self, name):
"""
Return a registred configuration for given config name.
Arguments:
name (string): A registred config name.
Raises:
NotRegisteredError: If given config name does not exist in
registry.
Returns:
dict... | python | def get_config(self, name):
"""
Return a registred configuration for given config name.
Arguments:
name (string): A registred config name.
Raises:
NotRegisteredError: If given config name does not exist in
registry.
Returns:
dict... | [
"def",
"get_config",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"registry",
":",
"msg",
"=",
"\"Given config name '{}' is not registered.\"",
"raise",
"NotRegisteredError",
"(",
"msg",
".",
"format",
"(",
"name",
")",
")",
"r... | Return a registred configuration for given config name.
Arguments:
name (string): A registred config name.
Raises:
NotRegisteredError: If given config name does not exist in
registry.
Returns:
dict: Configuration. | [
"Return",
"a",
"registred",
"configuration",
"for",
"given",
"config",
"name",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L185-L203 |
45,885 | sveetch/djangocodemirror | djangocodemirror/manifest.py | CodeMirrorManifest.get_codemirror_parameters | def get_codemirror_parameters(self, name):
"""
Return CodeMirror parameters for given configuration name.
This is a reduced configuration from internal parameters.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.... | python | def get_codemirror_parameters(self, name):
"""
Return CodeMirror parameters for given configuration name.
This is a reduced configuration from internal parameters.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.... | [
"def",
"get_codemirror_parameters",
"(",
"self",
",",
"name",
")",
":",
"config",
"=",
"self",
".",
"get_config",
"(",
"name",
")",
"return",
"{",
"k",
":",
"config",
"[",
"k",
"]",
"for",
"k",
"in",
"config",
"if",
"k",
"not",
"in",
"self",
".",
"... | Return CodeMirror parameters for given configuration name.
This is a reduced configuration from internal parameters.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.
Returns:
dict: Parameters. | [
"Return",
"CodeMirror",
"parameters",
"for",
"given",
"configuration",
"name",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/djangocodemirror/manifest.py#L205-L220 |
45,886 | mabuchilab/QNET | src/qnet/algebra/core/super_operator_algebra.py | commutator | def commutator(A, B=None):
"""Commutator of `A` and `B`
If ``B != None``, return the commutator :math:`[A,B]`, otherwise return
the super-operator :math:`[A,\cdot]`. The super-operator :math:`[A,\cdot]`
maps any other operator ``B`` to the commutator :math:`[A, B] = A B - B A`.
Args:
A: T... | python | def commutator(A, B=None):
"""Commutator of `A` and `B`
If ``B != None``, return the commutator :math:`[A,B]`, otherwise return
the super-operator :math:`[A,\cdot]`. The super-operator :math:`[A,\cdot]`
maps any other operator ``B`` to the commutator :math:`[A, B] = A B - B A`.
Args:
A: T... | [
"def",
"commutator",
"(",
"A",
",",
"B",
"=",
"None",
")",
":",
"if",
"B",
":",
"return",
"A",
"*",
"B",
"-",
"B",
"*",
"A",
"return",
"SPre",
"(",
"A",
")",
"-",
"SPost",
"(",
"A",
")"
] | Commutator of `A` and `B`
If ``B != None``, return the commutator :math:`[A,B]`, otherwise return
the super-operator :math:`[A,\cdot]`. The super-operator :math:`[A,\cdot]`
maps any other operator ``B`` to the commutator :math:`[A, B] = A B - B A`.
Args:
A: The first operator to form the comm... | [
"Commutator",
"of",
"A",
"and",
"B"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/super_operator_algebra.py#L331-L348 |
45,887 | mabuchilab/QNET | src/qnet/algebra/core/super_operator_algebra.py | liouvillian | def liouvillian(H, Ls=None):
r"""Return the Liouvillian super-operator associated with `H` and `Ls`
The Liouvillian :math:`\mathcal{L}` generates the Markovian-dynamics of a
system via the Master equation:
.. math::
\dot{\rho} = \mathcal{L}\rho
= -i[H,\rho] + \sum_{j=1}^n \mathcal{... | python | def liouvillian(H, Ls=None):
r"""Return the Liouvillian super-operator associated with `H` and `Ls`
The Liouvillian :math:`\mathcal{L}` generates the Markovian-dynamics of a
system via the Master equation:
.. math::
\dot{\rho} = \mathcal{L}\rho
= -i[H,\rho] + \sum_{j=1}^n \mathcal{... | [
"def",
"liouvillian",
"(",
"H",
",",
"Ls",
"=",
"None",
")",
":",
"if",
"Ls",
"is",
"None",
":",
"Ls",
"=",
"[",
"]",
"elif",
"isinstance",
"(",
"Ls",
",",
"Matrix",
")",
":",
"Ls",
"=",
"Ls",
".",
"matrix",
".",
"ravel",
"(",
")",
".",
"toli... | r"""Return the Liouvillian super-operator associated with `H` and `Ls`
The Liouvillian :math:`\mathcal{L}` generates the Markovian-dynamics of a
system via the Master equation:
.. math::
\dot{\rho} = \mathcal{L}\rho
= -i[H,\rho] + \sum_{j=1}^n \mathcal{D}[L_j] \rho
Args:
H... | [
"r",
"Return",
"the",
"Liouvillian",
"super",
"-",
"operator",
"associated",
"with",
"H",
"and",
"Ls"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/super_operator_algebra.py#L396-L419 |
45,888 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | block_matrix | def block_matrix(A, B, C, D):
r"""Generate the operator matrix with quadrants
.. math::
\begin{pmatrix} A B \\ C D \end{pmatrix}
Args:
A (Matrix): Matrix of shape ``(n, m)``
B (Matrix): Matrix of shape ``(n, k)``
C (Matrix): Matrix of shape ``(l, m)``
D (Matrix): Ma... | python | def block_matrix(A, B, C, D):
r"""Generate the operator matrix with quadrants
.. math::
\begin{pmatrix} A B \\ C D \end{pmatrix}
Args:
A (Matrix): Matrix of shape ``(n, m)``
B (Matrix): Matrix of shape ``(n, k)``
C (Matrix): Matrix of shape ``(l, m)``
D (Matrix): Ma... | [
"def",
"block_matrix",
"(",
"A",
",",
"B",
",",
"C",
",",
"D",
")",
":",
"return",
"vstackm",
"(",
"(",
"hstackm",
"(",
"(",
"A",
",",
"B",
")",
")",
",",
"hstackm",
"(",
"(",
"C",
",",
"D",
")",
")",
")",
")"
] | r"""Generate the operator matrix with quadrants
.. math::
\begin{pmatrix} A B \\ C D \end{pmatrix}
Args:
A (Matrix): Matrix of shape ``(n, m)``
B (Matrix): Matrix of shape ``(n, k)``
C (Matrix): Matrix of shape ``(l, m)``
D (Matrix): Matrix of shape ``(l, k)``
Retu... | [
"r",
"Generate",
"the",
"operator",
"matrix",
"with",
"quadrants"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L388-L404 |
45,889 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | permutation_matrix | def permutation_matrix(permutation):
r"""Return orthogonal permutation matrix for permutation tuple
Return an orthogonal permutation matrix :math:`M_\sigma`
for a permutation :math:`\sigma` defined by the image tuple
:math:`(\sigma(1), \sigma(2),\dots \sigma(n))`,
such that
.. math::
... | python | def permutation_matrix(permutation):
r"""Return orthogonal permutation matrix for permutation tuple
Return an orthogonal permutation matrix :math:`M_\sigma`
for a permutation :math:`\sigma` defined by the image tuple
:math:`(\sigma(1), \sigma(2),\dots \sigma(n))`,
such that
.. math::
... | [
"def",
"permutation_matrix",
"(",
"permutation",
")",
":",
"assert",
"check_permutation",
"(",
"permutation",
")",
"n",
"=",
"len",
"(",
"permutation",
")",
"op_matrix",
"=",
"np_zeros",
"(",
"(",
"n",
",",
"n",
")",
",",
"dtype",
"=",
"int",
")",
"for",... | r"""Return orthogonal permutation matrix for permutation tuple
Return an orthogonal permutation matrix :math:`M_\sigma`
for a permutation :math:`\sigma` defined by the image tuple
:math:`(\sigma(1), \sigma(2),\dots \sigma(n))`,
such that
.. math::
M_\sigma \vec{e}_i = \vec{e}_{\sigma(i)}
... | [
"r",
"Return",
"orthogonal",
"permutation",
"matrix",
"for",
"permutation",
"tuple"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L425-L461 |
45,890 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.is_zero | def is_zero(self):
"""Are all elements of the matrix zero?"""
for o in self.matrix.ravel():
try:
if not o.is_zero:
return False
except AttributeError:
if not o == 0:
return False
return True | python | def is_zero(self):
"""Are all elements of the matrix zero?"""
for o in self.matrix.ravel():
try:
if not o.is_zero:
return False
except AttributeError:
if not o == 0:
return False
return True | [
"def",
"is_zero",
"(",
"self",
")",
":",
"for",
"o",
"in",
"self",
".",
"matrix",
".",
"ravel",
"(",
")",
":",
"try",
":",
"if",
"not",
"o",
".",
"is_zero",
":",
"return",
"False",
"except",
"AttributeError",
":",
"if",
"not",
"o",
"==",
"0",
":"... | Are all elements of the matrix zero? | [
"Are",
"all",
"elements",
"of",
"the",
"matrix",
"zero?"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L100-L109 |
45,891 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.conjugate | def conjugate(self):
"""The element-wise conjugate matrix
This is defined only if all the entries in the matrix have a defined
conjugate (i.e., they have a `conjugate` method). This is *not* the
case for a matrix of operators. In such a case, only an
:meth:`elementwise` :func:`a... | python | def conjugate(self):
"""The element-wise conjugate matrix
This is defined only if all the entries in the matrix have a defined
conjugate (i.e., they have a `conjugate` method). This is *not* the
case for a matrix of operators. In such a case, only an
:meth:`elementwise` :func:`a... | [
"def",
"conjugate",
"(",
"self",
")",
":",
"try",
":",
"return",
"Matrix",
"(",
"np_conjugate",
"(",
"self",
".",
"matrix",
")",
")",
"except",
"AttributeError",
":",
"raise",
"NoConjugateMatrix",
"(",
"\"Matrix %s contains entries that have no defined \"",
"\"conju... | The element-wise conjugate matrix
This is defined only if all the entries in the matrix have a defined
conjugate (i.e., they have a `conjugate` method). This is *not* the
case for a matrix of operators. In such a case, only an
:meth:`elementwise` :func:`adjoint` would be applicable, but... | [
"The",
"element",
"-",
"wise",
"conjugate",
"matrix"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L167-L184 |
45,892 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.real | def real(self):
"""Element-wise real part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the real part
Note:
A mathematically equivalent way to obtain a real matrix from a
complex matrix ``M`` i... | python | def real(self):
"""Element-wise real part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the real part
Note:
A mathematically equivalent way to obtain a real matrix from a
complex matrix ``M`` i... | [
"def",
"real",
"(",
"self",
")",
":",
"def",
"re",
"(",
"val",
")",
":",
"if",
"hasattr",
"(",
"val",
",",
"'real'",
")",
":",
"return",
"val",
".",
"real",
"elif",
"hasattr",
"(",
"val",
",",
"'as_real_imag'",
")",
":",
"return",
"val",
".",
"as... | Element-wise real part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the real part
Note:
A mathematically equivalent way to obtain a real matrix from a
complex matrix ``M`` is::
(M.con... | [
"Element",
"-",
"wise",
"real",
"part"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L187-L220 |
45,893 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.imag | def imag(self):
"""Element-wise imaginary part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the imaginary part
Note:
A mathematically equivalent way to obtain an imaginary matrix from
a comple... | python | def imag(self):
"""Element-wise imaginary part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the imaginary part
Note:
A mathematically equivalent way to obtain an imaginary matrix from
a comple... | [
"def",
"imag",
"(",
"self",
")",
":",
"def",
"im",
"(",
"val",
")",
":",
"if",
"hasattr",
"(",
"val",
",",
"'imag'",
")",
":",
"return",
"val",
".",
"imag",
"elif",
"hasattr",
"(",
"val",
",",
"'as_real_imag'",
")",
":",
"return",
"val",
".",
"as... | Element-wise imaginary part
Raises:
NoConjugateMatrix: if entries have no `conjugate` method and no
other way to determine the imaginary part
Note:
A mathematically equivalent way to obtain an imaginary matrix from
a complex matrix ``M`` is::
... | [
"Element",
"-",
"wise",
"imaginary",
"part"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L223-L254 |
45,894 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.element_wise | def element_wise(self, func, *args, **kwargs):
"""Apply a function to each matrix element and return the result in a
new operator matrix of the same shape.
Args:
func (FunctionType): A function to be applied to each element. It
must take the element as its first argu... | python | def element_wise(self, func, *args, **kwargs):
"""Apply a function to each matrix element and return the result in a
new operator matrix of the same shape.
Args:
func (FunctionType): A function to be applied to each element. It
must take the element as its first argu... | [
"def",
"element_wise",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"s",
"=",
"self",
".",
"shape",
"emat",
"=",
"[",
"func",
"(",
"o",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"o",
"in",
"self"... | Apply a function to each matrix element and return the result in a
new operator matrix of the same shape.
Args:
func (FunctionType): A function to be applied to each element. It
must take the element as its first argument.
args: Additional positional arguments to... | [
"Apply",
"a",
"function",
"to",
"each",
"matrix",
"element",
"and",
"return",
"the",
"result",
"in",
"a",
"new",
"operator",
"matrix",
"of",
"the",
"same",
"shape",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L285-L300 |
45,895 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.series_expand | def series_expand(self, param: Symbol, about, order: int):
"""Expand the matrix expression as a truncated power series in a scalar
parameter.
Args:
param: Expansion parameter.
about (.Scalar): Point about which to expand.
order: Maximum order of expansion >= ... | python | def series_expand(self, param: Symbol, about, order: int):
"""Expand the matrix expression as a truncated power series in a scalar
parameter.
Args:
param: Expansion parameter.
about (.Scalar): Point about which to expand.
order: Maximum order of expansion >= ... | [
"def",
"series_expand",
"(",
"self",
",",
"param",
":",
"Symbol",
",",
"about",
",",
"order",
":",
"int",
")",
":",
"s",
"=",
"self",
".",
"shape",
"emats",
"=",
"zip",
"(",
"*",
"[",
"o",
".",
"series_expand",
"(",
"param",
",",
"about",
",",
"o... | Expand the matrix expression as a truncated power series in a scalar
parameter.
Args:
param: Expansion parameter.
about (.Scalar): Point about which to expand.
order: Maximum order of expansion >= 0
Returns:
tuple of length (order+1), where the e... | [
"Expand",
"the",
"matrix",
"expression",
"as",
"a",
"truncated",
"power",
"series",
"in",
"a",
"scalar",
"parameter",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L302-L318 |
45,896 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.expand | def expand(self):
"""Expand each matrix element distributively.
Returns:
Matrix: Expanded matrix.
"""
return self.element_wise(
lambda o: o.expand() if isinstance(o, QuantumExpression) else o) | python | def expand(self):
"""Expand each matrix element distributively.
Returns:
Matrix: Expanded matrix.
"""
return self.element_wise(
lambda o: o.expand() if isinstance(o, QuantumExpression) else o) | [
"def",
"expand",
"(",
"self",
")",
":",
"return",
"self",
".",
"element_wise",
"(",
"lambda",
"o",
":",
"o",
".",
"expand",
"(",
")",
"if",
"isinstance",
"(",
"o",
",",
"QuantumExpression",
")",
"else",
"o",
")"
] | Expand each matrix element distributively.
Returns:
Matrix: Expanded matrix. | [
"Expand",
"each",
"matrix",
"element",
"distributively",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L320-L327 |
45,897 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.space | def space(self):
"""Combined Hilbert space of all matrix elements."""
arg_spaces = [o.space for o in self.matrix.ravel()
if hasattr(o, 'space')]
if len(arg_spaces) == 0:
return TrivialSpace
else:
return ProductSpace.create(*arg_spaces) | python | def space(self):
"""Combined Hilbert space of all matrix elements."""
arg_spaces = [o.space for o in self.matrix.ravel()
if hasattr(o, 'space')]
if len(arg_spaces) == 0:
return TrivialSpace
else:
return ProductSpace.create(*arg_spaces) | [
"def",
"space",
"(",
"self",
")",
":",
"arg_spaces",
"=",
"[",
"o",
".",
"space",
"for",
"o",
"in",
"self",
".",
"matrix",
".",
"ravel",
"(",
")",
"if",
"hasattr",
"(",
"o",
",",
"'space'",
")",
"]",
"if",
"len",
"(",
"arg_spaces",
")",
"==",
"... | Combined Hilbert space of all matrix elements. | [
"Combined",
"Hilbert",
"space",
"of",
"all",
"matrix",
"elements",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L346-L353 |
45,898 | mabuchilab/QNET | src/qnet/algebra/core/matrix_algebra.py | Matrix.simplify_scalar | def simplify_scalar(self, func=sympy.simplify):
"""Simplify all scalar expressions appearing in the Matrix."""
def element_simplify(v):
if isinstance(v, sympy.Basic):
return func(v)
elif isinstance(v, QuantumExpression):
return v.simplify_scalar(f... | python | def simplify_scalar(self, func=sympy.simplify):
"""Simplify all scalar expressions appearing in the Matrix."""
def element_simplify(v):
if isinstance(v, sympy.Basic):
return func(v)
elif isinstance(v, QuantumExpression):
return v.simplify_scalar(f... | [
"def",
"simplify_scalar",
"(",
"self",
",",
"func",
"=",
"sympy",
".",
"simplify",
")",
":",
"def",
"element_simplify",
"(",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"sympy",
".",
"Basic",
")",
":",
"return",
"func",
"(",
"v",
")",
"elif",
... | Simplify all scalar expressions appearing in the Matrix. | [
"Simplify",
"all",
"scalar",
"expressions",
"appearing",
"in",
"the",
"Matrix",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L355-L366 |
45,899 | sveetch/djangocodemirror | sandbox/views.py | ModesSampleFormView.get_initial | def get_initial(self):
"""
Try to find a demo source for given mode if any, if finded use it to
fill the demo textarea.
"""
initial = {}
if self.kwargs.get('mode', None):
filename = "{}.txt".format(self.kwargs['mode'])
filepath = os.path.join(sett... | python | def get_initial(self):
"""
Try to find a demo source for given mode if any, if finded use it to
fill the demo textarea.
"""
initial = {}
if self.kwargs.get('mode', None):
filename = "{}.txt".format(self.kwargs['mode'])
filepath = os.path.join(sett... | [
"def",
"get_initial",
"(",
"self",
")",
":",
"initial",
"=",
"{",
"}",
"if",
"self",
".",
"kwargs",
".",
"get",
"(",
"'mode'",
",",
"None",
")",
":",
"filename",
"=",
"\"{}.txt\"",
".",
"format",
"(",
"self",
".",
"kwargs",
"[",
"'mode'",
"]",
")",... | Try to find a demo source for given mode if any, if finded use it to
fill the demo textarea. | [
"Try",
"to",
"find",
"a",
"demo",
"source",
"for",
"given",
"mode",
"if",
"any",
"if",
"finded",
"use",
"it",
"to",
"fill",
"the",
"demo",
"textarea",
"."
] | 7d556eec59861b2f619398e837bdd089b3a8a7d7 | https://github.com/sveetch/djangocodemirror/blob/7d556eec59861b2f619398e837bdd089b3a8a7d7/sandbox/views.py#L33-L47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.