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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.edit_secondary_name_server
def edit_secondary_name_server(self, zone_name, primary=None, backup=None, second_backup=None): """Edit the axfr name servers of a secondary zone. Arguments: zone_name -- The name of the secondary zone being edited. primary -- The primary name server value. Keyword Arguments: ...
python
def edit_secondary_name_server(self, zone_name, primary=None, backup=None, second_backup=None): """Edit the axfr name servers of a secondary zone. Arguments: zone_name -- The name of the secondary zone being edited. primary -- The primary name server value. Keyword Arguments: ...
[ "def", "edit_secondary_name_server", "(", "self", ",", "zone_name", ",", "primary", "=", "None", ",", "backup", "=", "None", ",", "second_backup", "=", "None", ")", ":", "name_server_info", "=", "{", "}", "if", "primary", "is", "not", "None", ":", "name_se...
Edit the axfr name servers of a secondary zone. Arguments: zone_name -- The name of the secondary zone being edited. primary -- The primary name server value. Keyword Arguments: backup -- The backup name server if any. second_backup -- The second backup name server.
[ "Edit", "the", "axfr", "name", "servers", "of", "a", "secondary", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L203-L225
train
62,700
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.get_rrsets
def get_rrsets(self, zone_name, q=None, **kwargs): """Returns the list of RRSets in the specified zone. Arguments: zone_name -- The name of the zone. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: ttl - must match the TTL for the rrset ...
python
def get_rrsets(self, zone_name, q=None, **kwargs): """Returns the list of RRSets in the specified zone. Arguments: zone_name -- The name of the zone. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: ttl - must match the TTL for the rrset ...
[ "def", "get_rrsets", "(", "self", ",", "zone_name", ",", "q", "=", "None", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "\"/v1/zones/\"", "+", "zone_name", "+", "\"/rrsets\"", "params", "=", "build_params", "(", "q", ",", "kwargs", ")", "return", "se...
Returns the list of RRSets in the specified zone. Arguments: zone_name -- The name of the zone. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: ttl - must match the TTL for the rrset owner - substring match of the owner name ...
[ "Returns", "the", "list", "of", "RRSets", "in", "the", "specified", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L229-L251
train
62,701
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_rrset
def create_rrset(self, zone_name, rtype, owner_name, ttl, rdata): """Creates a new RRSet in the specified zone. Arguments: zone_name -- The zone that will contain the new RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or i...
python
def create_rrset(self, zone_name, rtype, owner_name, ttl, rdata): """Creates a new RRSet in the specified zone. Arguments: zone_name -- The zone that will contain the new RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or i...
[ "def", "create_rrset", "(", "self", ",", "zone_name", ",", "rtype", ",", "owner_name", ",", "ttl", ",", "rdata", ")", ":", "if", "type", "(", "rdata", ")", "is", "not", "list", ":", "rdata", "=", "[", "rdata", "]", "rrset", "=", "{", "\"ttl\"", ":"...
Creates a new RRSet in the specified zone. Arguments: zone_name -- The zone that will contain the new RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for the type (A), you can use it instead. ...
[ "Creates", "a", "new", "RRSet", "in", "the", "specified", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L311-L330
train
62,702
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.edit_rrset
def edit_rrset(self, zone_name, rtype, owner_name, ttl, rdata, profile=None): """Updates an existing RRSet in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or ...
python
def edit_rrset(self, zone_name, rtype, owner_name, ttl, rdata, profile=None): """Updates an existing RRSet in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or ...
[ "def", "edit_rrset", "(", "self", ",", "zone_name", ",", "rtype", ",", "owner_name", ",", "ttl", ",", "rdata", ",", "profile", "=", "None", ")", ":", "if", "type", "(", "rdata", ")", "is", "not", "list", ":", "rdata", "=", "[", "rdata", "]", "rrset...
Updates an existing RRSet in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for the type (A), you can use it instead. ...
[ "Updates", "an", "existing", "RRSet", "in", "the", "specified", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L333-L356
train
62,703
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.edit_rrset_rdata
def edit_rrset_rdata(self, zone_name, rtype, owner_name, rdata, profile=None): """Updates an existing RRSet's Rdata in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or...
python
def edit_rrset_rdata(self, zone_name, rtype, owner_name, rdata, profile=None): """Updates an existing RRSet's Rdata in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or...
[ "def", "edit_rrset_rdata", "(", "self", ",", "zone_name", ",", "rtype", ",", "owner_name", ",", "rdata", ",", "profile", "=", "None", ")", ":", "if", "type", "(", "rdata", ")", "is", "not", "list", ":", "rdata", "=", "[", "rdata", "]", "rrset", "=", ...
Updates an existing RRSet's Rdata in the specified zone. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for the type (A), you can use it instead...
[ "Updates", "an", "existing", "RRSet", "s", "Rdata", "in", "the", "specified", "zone", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L359-L383
train
62,704
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.delete_rrset
def delete_rrset(self, zone_name, rtype, owner_name): """Deletes an RRSet. Arguments: zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for...
python
def delete_rrset(self, zone_name, rtype, owner_name): """Deletes an RRSet. Arguments: zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for...
[ "def", "delete_rrset", "(", "self", ",", "zone_name", ",", "rtype", ",", "owner_name", ")", ":", "return", "self", ".", "rest_api_connection", ".", "delete", "(", "\"/v1/zones/\"", "+", "zone_name", "+", "\"/rrsets/\"", "+", "rtype", "+", "\"/\"", "+", "owne...
Deletes an RRSet. Arguments: zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional. rtype -- The type of the RRSet. This can be numeric (1) or if a well-known name is defined for the type (A), you can use it instead. owner_name -- The ...
[ "Deletes", "an", "RRSet", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L386-L398
train
62,705
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_web_forward
def create_web_forward(self, zone_name, request_to, redirect_to, forward_type): """Create a web forward record. Arguments: zone_name -- The zone in which the web forward is to be created. request_to -- The URL to be redirected. You may use http:// and ftp://. forward_type -- The...
python
def create_web_forward(self, zone_name, request_to, redirect_to, forward_type): """Create a web forward record. Arguments: zone_name -- The zone in which the web forward is to be created. request_to -- The URL to be redirected. You may use http:// and ftp://. forward_type -- The...
[ "def", "create_web_forward", "(", "self", ",", "zone_name", ",", "request_to", ",", "redirect_to", ",", "forward_type", ")", ":", "web_forward", "=", "{", "\"requestTo\"", ":", "request_to", ",", "\"defaultRedirectTo\"", ":", "redirect_to", ",", "\"defaultForwardTyp...
Create a web forward record. Arguments: zone_name -- The zone in which the web forward is to be created. request_to -- The URL to be redirected. You may use http:// and ftp://. forward_type -- The type of forward. Valid options include: Framed ...
[ "Create", "a", "web", "forward", "record", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L413-L428
train
62,706
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_sb_pool
def create_sb_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record_list): """Creates a new SB Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no tra...
python
def create_sb_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record_list): """Creates a new SB Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no tra...
[ "def", "create_sb_pool", "(", "self", ",", "zone_name", ",", "owner_name", ",", "ttl", ",", "pool_info", ",", "rdata_info", ",", "backup_record_list", ")", ":", "rrset", "=", "self", ".", "_build_sb_rrset", "(", "backup_record_list", ",", "pool_info", ",", "rd...
Creates a new SB Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no trailing dot is supplied, the owner_name is assumed to be relative (foo). If a trailing d...
[ "Creates", "a", "new", "SB", "Pool", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L551-L571
train
62,707
ultradns/python_rest_api_client
ultra_rest_client/ultra_rest_client.py
RestApiClient.create_tc_pool
def create_tc_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record): """Creates a new TC Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no trailing...
python
def create_tc_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record): """Creates a new TC Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no trailing...
[ "def", "create_tc_pool", "(", "self", ",", "zone_name", ",", "owner_name", ",", "ttl", ",", "pool_info", ",", "rdata_info", ",", "backup_record", ")", ":", "rrset", "=", "self", ".", "_build_tc_rrset", "(", "backup_record", ",", "pool_info", ",", "rdata_info",...
Creates a new TC Pool. Arguments: zone_name -- The zone that contains the RRSet. The trailing dot is optional. owner_name -- The owner name for the RRSet. If no trailing dot is supplied, the owner_name is assumed to be relative (foo). If a trailing d...
[ "Creates", "a", "new", "TC", "Pool", "." ]
e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec
https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L661-L681
train
62,708
mabuchilab/QNET
src/qnet/algebra/core/hilbert_space_algebra.py
ProductSpace.remove
def remove(self, other): """Remove a particular factor from a tensor product space.""" if other is FullSpace: return TrivialSpace if other is TrivialSpace: return self if isinstance(other, ProductSpace): oops = set(other.operands) else: ...
python
def remove(self, other): """Remove a particular factor from a tensor product space.""" if other is FullSpace: return TrivialSpace if other is TrivialSpace: return self if isinstance(other, ProductSpace): oops = set(other.operands) else: ...
[ "def", "remove", "(", "self", ",", "other", ")", ":", "if", "other", "is", "FullSpace", ":", "return", "TrivialSpace", "if", "other", "is", "TrivialSpace", ":", "return", "self", "if", "isinstance", "(", "other", ",", "ProductSpace", ")", ":", "oops", "=...
Remove a particular factor from a tensor product space.
[ "Remove", "a", "particular", "factor", "from", "a", "tensor", "product", "space", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/hilbert_space_algebra.py#L770-L781
train
62,709
mabuchilab/QNET
src/qnet/algebra/core/hilbert_space_algebra.py
ProductSpace.intersect
def intersect(self, other): """Find the mutual tensor factors of two Hilbert spaces.""" if other is FullSpace: return self if other is TrivialSpace: return TrivialSpace if isinstance(other, ProductSpace): other_ops = set(other.operands) else: ...
python
def intersect(self, other): """Find the mutual tensor factors of two Hilbert spaces.""" if other is FullSpace: return self if other is TrivialSpace: return TrivialSpace if isinstance(other, ProductSpace): other_ops = set(other.operands) else: ...
[ "def", "intersect", "(", "self", ",", "other", ")", ":", "if", "other", "is", "FullSpace", ":", "return", "self", "if", "other", "is", "TrivialSpace", ":", "return", "TrivialSpace", "if", "isinstance", "(", "other", ",", "ProductSpace", ")", ":", "other_op...
Find the mutual tensor factors of two Hilbert spaces.
[ "Find", "the", "mutual", "tensor", "factors", "of", "two", "Hilbert", "spaces", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/hilbert_space_algebra.py#L794-L805
train
62,710
mabuchilab/QNET
src/qnet/printing/base.py
QnetBasePrinter._isinstance
def _isinstance(expr, classname): """Check whether `expr` is an instance of the class with name `classname` This is like the builtin `isinstance`, but it take the `classname` a string, instead of the class directly. Useful for when we don't want to import the class for which we ...
python
def _isinstance(expr, classname): """Check whether `expr` is an instance of the class with name `classname` This is like the builtin `isinstance`, but it take the `classname` a string, instead of the class directly. Useful for when we don't want to import the class for which we ...
[ "def", "_isinstance", "(", "expr", ",", "classname", ")", ":", "for", "cls", "in", "type", "(", "expr", ")", ".", "__mro__", ":", "if", "cls", ".", "__name__", "==", "classname", ":", "return", "True", "return", "False" ]
Check whether `expr` is an instance of the class with name `classname` This is like the builtin `isinstance`, but it take the `classname` a string, instead of the class directly. Useful for when we don't want to import the class for which we want to check (also, remember that pr...
[ "Check", "whether", "expr", "is", "an", "instance", "of", "the", "class", "with", "name", "classname" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/base.py#L99-L112
train
62,711
mabuchilab/QNET
src/qnet/algebra/core/operator_algebra.py
decompose_space
def decompose_space(H, A): """Simplifies OperatorTrace expressions over tensor-product spaces by turning it into iterated partial traces. Args: H (ProductSpace): The full space. A (Operator): Returns: Operator: Iterative partial trace expression """ return OperatorTrace...
python
def decompose_space(H, A): """Simplifies OperatorTrace expressions over tensor-product spaces by turning it into iterated partial traces. Args: H (ProductSpace): The full space. A (Operator): Returns: Operator: Iterative partial trace expression """ return OperatorTrace...
[ "def", "decompose_space", "(", "H", ",", "A", ")", ":", "return", "OperatorTrace", ".", "create", "(", "OperatorTrace", ".", "create", "(", "A", ",", "over_space", "=", "H", ".", "operands", "[", "-", "1", "]", ")", ",", "over_space", "=", "ProductSpac...
Simplifies OperatorTrace expressions over tensor-product spaces by turning it into iterated partial traces. Args: H (ProductSpace): The full space. A (Operator): Returns: Operator: Iterative partial trace expression
[ "Simplifies", "OperatorTrace", "expressions", "over", "tensor", "-", "product", "spaces", "by", "turning", "it", "into", "iterated", "partial", "traces", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L872-L885
train
62,712
mabuchilab/QNET
src/qnet/algebra/core/operator_algebra.py
factor_coeff
def factor_coeff(cls, ops, kwargs): """Factor out coefficients of all factors.""" coeffs, nops = zip(*map(_coeff_term, ops)) coeff = 1 for c in coeffs: coeff *= c if coeff == 1: return nops, coeffs else: return coeff * cls.create(*nops, **kwargs)
python
def factor_coeff(cls, ops, kwargs): """Factor out coefficients of all factors.""" coeffs, nops = zip(*map(_coeff_term, ops)) coeff = 1 for c in coeffs: coeff *= c if coeff == 1: return nops, coeffs else: return coeff * cls.create(*nops, **kwargs)
[ "def", "factor_coeff", "(", "cls", ",", "ops", ",", "kwargs", ")", ":", "coeffs", ",", "nops", "=", "zip", "(", "*", "map", "(", "_coeff_term", ",", "ops", ")", ")", "coeff", "=", "1", "for", "c", "in", "coeffs", ":", "coeff", "*=", "c", "if", ...
Factor out coefficients of all factors.
[ "Factor", "out", "coefficients", "of", "all", "factors", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L932-L941
train
62,713
mabuchilab/QNET
src/qnet/algebra/core/operator_algebra.py
Commutator.doit
def doit(self, classes=None, recursive=True, **kwargs): """Write out commutator Write out the commutator according to its definition $[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$. See :meth:`.Expression.doit`. """ return super().doit(classes, recursive, **kwargs)
python
def doit(self, classes=None, recursive=True, **kwargs): """Write out commutator Write out the commutator according to its definition $[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$. See :meth:`.Expression.doit`. """ return super().doit(classes, recursive, **kwargs)
[ "def", "doit", "(", "self", ",", "classes", "=", "None", ",", "recursive", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", ")", ".", "doit", "(", "classes", ",", "recursive", ",", "*", "*", "kwargs", ")" ]
Write out commutator Write out the commutator according to its definition $[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$. See :meth:`.Expression.doit`.
[ "Write", "out", "commutator" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L559-L567
train
62,714
mabuchilab/QNET
src/qnet/printing/dot.py
_attrprint
def _attrprint(d, delimiter=', '): """Print a dictionary of attributes in the DOT format""" return delimiter.join(('"%s"="%s"' % item) for item in sorted(d.items()))
python
def _attrprint(d, delimiter=', '): """Print a dictionary of attributes in the DOT format""" return delimiter.join(('"%s"="%s"' % item) for item in sorted(d.items()))
[ "def", "_attrprint", "(", "d", ",", "delimiter", "=", "', '", ")", ":", "return", "delimiter", ".", "join", "(", "(", "'\"%s\"=\"%s\"'", "%", "item", ")", "for", "item", "in", "sorted", "(", "d", ".", "items", "(", ")", ")", ")" ]
Print a dictionary of attributes in the DOT format
[ "Print", "a", "dictionary", "of", "attributes", "in", "the", "DOT", "format" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/dot.py#L76-L78
train
62,715
mabuchilab/QNET
src/qnet/printing/dot.py
_styleof
def _styleof(expr, styles): """Merge style dictionaries in order""" style = dict() for expr_filter, sty in styles: if expr_filter(expr): style.update(sty) return style
python
def _styleof(expr, styles): """Merge style dictionaries in order""" style = dict() for expr_filter, sty in styles: if expr_filter(expr): style.update(sty) return style
[ "def", "_styleof", "(", "expr", ",", "styles", ")", ":", "style", "=", "dict", "(", ")", "for", "expr_filter", ",", "sty", "in", "styles", ":", "if", "expr_filter", "(", "expr", ")", ":", "style", ".", "update", "(", "sty", ")", "return", "style" ]
Merge style dictionaries in order
[ "Merge", "style", "dictionaries", "in", "order" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/dot.py#L81-L87
train
62,716
mabuchilab/QNET
src/qnet/__init__.py
_git_version
def _git_version(): """If installed with 'pip installe -e .' from inside a git repo, the current git revision as a string""" import subprocess import os def _minimal_ext_cmd(cmd): # construct minimal environment env = {} for k in ['SYSTEMROOT', 'PATH']: v = os.e...
python
def _git_version(): """If installed with 'pip installe -e .' from inside a git repo, the current git revision as a string""" import subprocess import os def _minimal_ext_cmd(cmd): # construct minimal environment env = {} for k in ['SYSTEMROOT', 'PATH']: v = os.e...
[ "def", "_git_version", "(", ")", ":", "import", "subprocess", "import", "os", "def", "_minimal_ext_cmd", "(", "cmd", ")", ":", "# construct minimal environment", "env", "=", "{", "}", "for", "k", "in", "[", "'SYSTEMROOT'", ",", "'PATH'", "]", ":", "v", "="...
If installed with 'pip installe -e .' from inside a git repo, the current git revision as a string
[ "If", "installed", "with", "pip", "installe", "-", "e", ".", "from", "inside", "a", "git", "repo", "the", "current", "git", "revision", "as", "a", "string" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/__init__.py#L23-L52
train
62,717
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
pad_with_identity
def pad_with_identity(circuit, k, n): """Pad a circuit by adding a `n`-channel identity circuit at index `k` That is, a circuit of channel dimension $N$ is extended to one of channel dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass through the system unaffected. E.g. let ``A``, ``...
python
def pad_with_identity(circuit, k, n): """Pad a circuit by adding a `n`-channel identity circuit at index `k` That is, a circuit of channel dimension $N$ is extended to one of channel dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass through the system unaffected. E.g. let ``A``, ``...
[ "def", "pad_with_identity", "(", "circuit", ",", "k", ",", "n", ")", ":", "circuit_n", "=", "circuit", ".", "cdim", "combined_circuit", "=", "circuit", "+", "circuit_identity", "(", "n", ")", "permutation", "=", "(", "list", "(", "range", "(", "k", ")", ...
Pad a circuit by adding a `n`-channel identity circuit at index `k` That is, a circuit of channel dimension $N$ is extended to one of channel dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass through the system unaffected. E.g. let ``A``, ``B`` be two single channel systems:: ...
[ "Pad", "a", "circuit", "by", "adding", "a", "n", "-", "channel", "identity", "circuit", "at", "index", "k" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1421-L1452
train
62,718
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
move_drive_to_H
def move_drive_to_H(slh, which=None, expand_simplify=True): r'''Move coherent drives from the Lindblad operators to the Hamiltonian. For the given SLH model, move inhomogeneities in the Lindblad operators (resulting from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the Hamiltonian...
python
def move_drive_to_H(slh, which=None, expand_simplify=True): r'''Move coherent drives from the Lindblad operators to the Hamiltonian. For the given SLH model, move inhomogeneities in the Lindblad operators (resulting from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the Hamiltonian...
[ "def", "move_drive_to_H", "(", "slh", ",", "which", "=", "None", ",", "expand_simplify", "=", "True", ")", ":", "if", "which", "is", "None", ":", "which", "=", "[", "]", "scalarcs", "=", "[", "]", "for", "jj", ",", "L", "in", "enumerate", "(", "slh...
r'''Move coherent drives from the Lindblad operators to the Hamiltonian. For the given SLH model, move inhomogeneities in the Lindblad operators (resulting from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the Hamiltonian. This exploits the invariance of the Lindblad master equat...
[ "r", "Move", "coherent", "drives", "from", "the", "Lindblad", "operators", "to", "the", "Hamiltonian", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1613-L1674
train
62,719
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
prepare_adiabatic_limit
def prepare_adiabatic_limit(slh, k=None): """Prepare the adiabatic elimination on an SLH object Args: slh: The SLH object to take the limit for k: The scaling parameter $k \rightarrow \infty$. The default is a positive symbol 'k' Returns: tuple: The objects ``Y, A, B, F...
python
def prepare_adiabatic_limit(slh, k=None): """Prepare the adiabatic elimination on an SLH object Args: slh: The SLH object to take the limit for k: The scaling parameter $k \rightarrow \infty$. The default is a positive symbol 'k' Returns: tuple: The objects ``Y, A, B, F...
[ "def", "prepare_adiabatic_limit", "(", "slh", ",", "k", "=", "None", ")", ":", "if", "k", "is", "None", ":", "k", "=", "symbols", "(", "'k'", ",", "positive", "=", "True", ")", "Ld", "=", "slh", ".", "L", ".", "dag", "(", ")", "LdL", "=", "(", ...
Prepare the adiabatic elimination on an SLH object Args: slh: The SLH object to take the limit for k: The scaling parameter $k \rightarrow \infty$. The default is a positive symbol 'k' Returns: tuple: The objects ``Y, A, B, F, G, N`` necessary to compute the limitin...
[ "Prepare", "the", "adiabatic", "elimination", "on", "an", "SLH", "object" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1677-L1698
train
62,720
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
eval_adiabatic_limit
def eval_adiabatic_limit(YABFGN, Ytilde, P0): """Compute the limiting SLH model for the adiabatic approximation Args: YABFGN: The tuple (Y, A, B, F, G, N) as returned by prepare_adiabatic_limit. Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0. P0: The projector o...
python
def eval_adiabatic_limit(YABFGN, Ytilde, P0): """Compute the limiting SLH model for the adiabatic approximation Args: YABFGN: The tuple (Y, A, B, F, G, N) as returned by prepare_adiabatic_limit. Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0. P0: The projector o...
[ "def", "eval_adiabatic_limit", "(", "YABFGN", ",", "Ytilde", ",", "P0", ")", ":", "Y", ",", "A", ",", "B", ",", "F", ",", "G", ",", "N", "=", "YABFGN", "Klim", "=", "(", "P0", "*", "(", "B", "-", "A", "*", "Ytilde", "*", "A", ")", "*", "P0"...
Compute the limiting SLH model for the adiabatic approximation Args: YABFGN: The tuple (Y, A, B, F, G, N) as returned by prepare_adiabatic_limit. Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0. P0: The projector onto the null-space of Y. Returns: SLH: L...
[ "Compute", "the", "limiting", "SLH", "model", "for", "the", "adiabatic", "approximation" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1701-L1723
train
62,721
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
try_adiabatic_elimination
def try_adiabatic_elimination(slh, k=None, fock_trunc=6, sub_P0=True): """Attempt to automatically do adiabatic elimination on an SLH object This will project the `Y` operator onto a truncated basis with dimension specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to replace the k...
python
def try_adiabatic_elimination(slh, k=None, fock_trunc=6, sub_P0=True): """Attempt to automatically do adiabatic elimination on an SLH object This will project the `Y` operator onto a truncated basis with dimension specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to replace the k...
[ "def", "try_adiabatic_elimination", "(", "slh", ",", "k", "=", "None", ",", "fock_trunc", "=", "6", ",", "sub_P0", "=", "True", ")", ":", "ops", "=", "prepare_adiabatic_limit", "(", "slh", ",", "k", ")", "Y", "=", "ops", "[", "0", "]", "if", "isinsta...
Attempt to automatically do adiabatic elimination on an SLH object This will project the `Y` operator onto a truncated basis with dimension specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to replace the kernel projector P0 by an :class:`.IdentityOperator`.
[ "Attempt", "to", "automatically", "do", "adiabatic", "elimination", "on", "an", "SLH", "object" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1726-L1775
train
62,722
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
Circuit.index_in_block
def index_in_block(self, channel_index: int) -> int: """Return the index a channel has within the subblock it belongs to I.e., only for reducible circuits, this gives a result different from the argument itself. Args: channel_index (int): The index of the external channel ...
python
def index_in_block(self, channel_index: int) -> int: """Return the index a channel has within the subblock it belongs to I.e., only for reducible circuits, this gives a result different from the argument itself. Args: channel_index (int): The index of the external channel ...
[ "def", "index_in_block", "(", "self", ",", "channel_index", ":", "int", ")", "->", "int", ":", "if", "channel_index", "<", "0", "or", "channel_index", ">=", "self", ".", "cdim", ":", "raise", "ValueError", "(", ")", "struct", "=", "self", ".", "block_str...
Return the index a channel has within the subblock it belongs to I.e., only for reducible circuits, this gives a result different from the argument itself. Args: channel_index (int): The index of the external channel Raises: ValueError: for an invalid `channel_...
[ "Return", "the", "index", "a", "channel", "has", "within", "the", "subblock", "it", "belongs", "to" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L102-L128
train
62,723
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
Circuit.get_blocks
def get_blocks(self, block_structure=None): """For a reducible circuit, get a sequence of subblocks that when concatenated again yield the original circuit. The block structure given has to be compatible with the circuits actual block structure, i.e. it can only be more coarse-grained. ...
python
def get_blocks(self, block_structure=None): """For a reducible circuit, get a sequence of subblocks that when concatenated again yield the original circuit. The block structure given has to be compatible with the circuits actual block structure, i.e. it can only be more coarse-grained. ...
[ "def", "get_blocks", "(", "self", ",", "block_structure", "=", "None", ")", ":", "if", "block_structure", "is", "None", ":", "block_structure", "=", "self", ".", "block_structure", "try", ":", "return", "self", ".", "_get_blocks", "(", "block_structure", ")", ...
For a reducible circuit, get a sequence of subblocks that when concatenated again yield the original circuit. The block structure given has to be compatible with the circuits actual block structure, i.e. it can only be more coarse-grained. Args: block_structure (tuple): The...
[ "For", "a", "reducible", "circuit", "get", "a", "sequence", "of", "subblocks", "that", "when", "concatenated", "again", "yield", "the", "original", "circuit", ".", "The", "block", "structure", "given", "has", "to", "be", "compatible", "with", "the", "circuits"...
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L130-L152
train
62,724
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
Circuit.show
def show(self): """Show the circuit expression in an IPython notebook.""" # noinspection PyPackageRequirements from IPython.display import Image, display fname = self.render() display(Image(filename=fname))
python
def show(self): """Show the circuit expression in an IPython notebook.""" # noinspection PyPackageRequirements from IPython.display import Image, display fname = self.render() display(Image(filename=fname))
[ "def", "show", "(", "self", ")", ":", "# noinspection PyPackageRequirements", "from", "IPython", ".", "display", "import", "Image", ",", "display", "fname", "=", "self", ".", "render", "(", ")", "display", "(", "Image", "(", "filename", "=", "fname", ")", ...
Show the circuit expression in an IPython notebook.
[ "Show", "the", "circuit", "expression", "in", "an", "IPython", "notebook", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L196-L203
train
62,725
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
Circuit.render
def render(self, fname=''): """Render the circuit expression and store the result in a file Args: fname (str): Path to an image file to store the result in. Returns: str: The path to the image file """ import qnet.visualization.circuit_pyx as circuit_vis...
python
def render(self, fname=''): """Render the circuit expression and store the result in a file Args: fname (str): Path to an image file to store the result in. Returns: str: The path to the image file """ import qnet.visualization.circuit_pyx as circuit_vis...
[ "def", "render", "(", "self", ",", "fname", "=", "''", ")", ":", "import", "qnet", ".", "visualization", ".", "circuit_pyx", "as", "circuit_visualization", "from", "tempfile", "import", "gettempdir", "from", "time", "import", "time", ",", "sleep", "if", "not...
Render the circuit expression and store the result in a file Args: fname (str): Path to an image file to store the result in. Returns: str: The path to the image file
[ "Render", "the", "circuit", "expression", "and", "store", "the", "result", "in", "a", "file" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L205-L235
train
62,726
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.space
def space(self): """Total Hilbert space""" args_spaces = (self.S.space, self.L.space, self.H.space) return ProductSpace.create(*args_spaces)
python
def space(self): """Total Hilbert space""" args_spaces = (self.S.space, self.L.space, self.H.space) return ProductSpace.create(*args_spaces)
[ "def", "space", "(", "self", ")", ":", "args_spaces", "=", "(", "self", ".", "S", ".", "space", ",", "self", ".", "L", ".", "space", ",", "self", ".", "H", ".", "space", ")", "return", "ProductSpace", ".", "create", "(", "*", "args_spaces", ")" ]
Total Hilbert space
[ "Total", "Hilbert", "space" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L368-L371
train
62,727
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.free_symbols
def free_symbols(self): """Set of all symbols occcuring in S, L, or H""" return set.union( self.S.free_symbols, self.L.free_symbols, self.H.free_symbols)
python
def free_symbols(self): """Set of all symbols occcuring in S, L, or H""" return set.union( self.S.free_symbols, self.L.free_symbols, self.H.free_symbols)
[ "def", "free_symbols", "(", "self", ")", ":", "return", "set", ".", "union", "(", "self", ".", "S", ".", "free_symbols", ",", "self", ".", "L", ".", "free_symbols", ",", "self", ".", "H", ".", "free_symbols", ")" ]
Set of all symbols occcuring in S, L, or H
[ "Set", "of", "all", "symbols", "occcuring", "in", "S", "L", "or", "H" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L374-L377
train
62,728
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.expand
def expand(self): """Expand out all operator expressions within S, L and H Return a new :class:`SLH` object with these expanded expressions. """ return SLH(self.S.expand(), self.L.expand(), self.H.expand())
python
def expand(self): """Expand out all operator expressions within S, L and H Return a new :class:`SLH` object with these expanded expressions. """ return SLH(self.S.expand(), self.L.expand(), self.H.expand())
[ "def", "expand", "(", "self", ")", ":", "return", "SLH", "(", "self", ".", "S", ".", "expand", "(", ")", ",", "self", ".", "L", ".", "expand", "(", ")", ",", "self", ".", "H", ".", "expand", "(", ")", ")" ]
Expand out all operator expressions within S, L and H Return a new :class:`SLH` object with these expanded expressions.
[ "Expand", "out", "all", "operator", "expressions", "within", "S", "L", "and", "H" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L419-L424
train
62,729
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.simplify_scalar
def simplify_scalar(self, func=sympy.simplify): """Simplify all scalar expressions within S, L and H Return a new :class:`SLH` object with the simplified expressions. See also: :meth:`.QuantumExpression.simplify_scalar` """ return SLH( self.S.simplify_scalar(func=fu...
python
def simplify_scalar(self, func=sympy.simplify): """Simplify all scalar expressions within S, L and H Return a new :class:`SLH` object with the simplified expressions. See also: :meth:`.QuantumExpression.simplify_scalar` """ return SLH( self.S.simplify_scalar(func=fu...
[ "def", "simplify_scalar", "(", "self", ",", "func", "=", "sympy", ".", "simplify", ")", ":", "return", "SLH", "(", "self", ".", "S", ".", "simplify_scalar", "(", "func", "=", "func", ")", ",", "self", ".", "L", ".", "simplify_scalar", "(", "func", "=...
Simplify all scalar expressions within S, L and H Return a new :class:`SLH` object with the simplified expressions. See also: :meth:`.QuantumExpression.simplify_scalar`
[ "Simplify", "all", "scalar", "expressions", "within", "S", "L", "and", "H" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L426-L436
train
62,730
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.symbolic_master_equation
def symbolic_master_equation(self, rho=None): """Compute the symbolic Liouvillian acting on a state rho If no rho is given, an OperatorSymbol is created in its place. This correspnds to the RHS of the master equation in which an average is taken over the external noise degrees of ...
python
def symbolic_master_equation(self, rho=None): """Compute the symbolic Liouvillian acting on a state rho If no rho is given, an OperatorSymbol is created in its place. This correspnds to the RHS of the master equation in which an average is taken over the external noise degrees of ...
[ "def", "symbolic_master_equation", "(", "self", ",", "rho", "=", "None", ")", ":", "L", ",", "H", "=", "self", ".", "L", ",", "self", ".", "H", "if", "rho", "is", "None", ":", "rho", "=", "OperatorSymbol", "(", "'rho'", ",", "hs", "=", "self", "....
Compute the symbolic Liouvillian acting on a state rho If no rho is given, an OperatorSymbol is created in its place. This correspnds to the RHS of the master equation in which an average is taken over the external noise degrees of freedom. Args: rho (Operator): A s...
[ "Compute", "the", "symbolic", "Liouvillian", "acting", "on", "a", "state", "rho" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L501-L522
train
62,731
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
SLH.symbolic_heisenberg_eom
def symbolic_heisenberg_eom( self, X=None, noises=None, expand_simplify=True): """Compute the symbolic Heisenberg equations of motion of a system operator X. If no X is given, an OperatorSymbol is created in its place. If no noises are given, this correspnds to the ensemble...
python
def symbolic_heisenberg_eom( self, X=None, noises=None, expand_simplify=True): """Compute the symbolic Heisenberg equations of motion of a system operator X. If no X is given, an OperatorSymbol is created in its place. If no noises are given, this correspnds to the ensemble...
[ "def", "symbolic_heisenberg_eom", "(", "self", ",", "X", "=", "None", ",", "noises", "=", "None", ",", "expand_simplify", "=", "True", ")", ":", "L", ",", "H", "=", "self", ".", "L", ",", "self", ".", "H", "if", "X", "is", "None", ":", "X", "=", ...
Compute the symbolic Heisenberg equations of motion of a system operator X. If no X is given, an OperatorSymbol is created in its place. If no noises are given, this correspnds to the ensemble-averaged Heisenberg equation of motion. Args: X (Operator): A system operator ...
[ "Compute", "the", "symbolic", "Heisenberg", "equations", "of", "motion", "of", "a", "system", "operator", "X", ".", "If", "no", "X", "is", "given", "an", "OperatorSymbol", "is", "created", "in", "its", "place", ".", "If", "no", "noises", "are", "given", ...
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L524-L566
train
62,732
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
CPermutation.block_perms
def block_perms(self): """If the circuit is reducible into permutations within subranges of the full range of channels, this yields a tuple with the internal permutations for each such block. :type: tuple """ if not self._block_perms: self._block_perms = perm...
python
def block_perms(self): """If the circuit is reducible into permutations within subranges of the full range of channels, this yields a tuple with the internal permutations for each such block. :type: tuple """ if not self._block_perms: self._block_perms = perm...
[ "def", "block_perms", "(", "self", ")", ":", "if", "not", "self", ".", "_block_perms", ":", "self", ".", "_block_perms", "=", "permutation_to_block_permutations", "(", "self", ".", "permutation", ")", "return", "self", ".", "_block_perms" ]
If the circuit is reducible into permutations within subranges of the full range of channels, this yields a tuple with the internal permutations for each such block. :type: tuple
[ "If", "the", "circuit", "is", "reducible", "into", "permutations", "within", "subranges", "of", "the", "full", "range", "of", "channels", "this", "yields", "a", "tuple", "with", "the", "internal", "permutations", "for", "each", "such", "block", "." ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L794-L804
train
62,733
mabuchilab/QNET
src/qnet/algebra/core/circuit_algebra.py
CPermutation.series_with_permutation
def series_with_permutation(self, other): """Compute the series product with another channel permutation circuit Args: other (CPermutation): Returns: Circuit: The composite permutation circuit (could also be the identity circuit for n channels) "...
python
def series_with_permutation(self, other): """Compute the series product with another channel permutation circuit Args: other (CPermutation): Returns: Circuit: The composite permutation circuit (could also be the identity circuit for n channels) "...
[ "def", "series_with_permutation", "(", "self", ",", "other", ")", ":", "combined_permutation", "=", "tuple", "(", "[", "self", ".", "permutation", "[", "p", "]", "for", "p", "in", "other", ".", "permutation", "]", ")", "return", "CPermutation", ".", "creat...
Compute the series product with another channel permutation circuit Args: other (CPermutation): Returns: Circuit: The composite permutation circuit (could also be the identity circuit for n channels)
[ "Compute", "the", "series", "product", "with", "another", "channel", "permutation", "circuit" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L822-L834
train
62,734
niloch/iplotter
iplotter/chartjs_plotter.py
ChartJSPlotter.save
def save(self, data, chart_type, options=None, filename='chart', w=800, h=420, overwrite=True): """Save the rendered html to a file in the same directory as the notebook.""" html = self.render( data=da...
python
def save(self, data, chart_type, options=None, filename='chart', w=800, h=420, overwrite=True): """Save the rendered html to a file in the same directory as the notebook.""" html = self.render( data=da...
[ "def", "save", "(", "self", ",", "data", ",", "chart_type", ",", "options", "=", "None", ",", "filename", "=", "'chart'", ",", "w", "=", "800", ",", "h", "=", "420", ",", "overwrite", "=", "True", ")", ":", "html", "=", "self", ".", "render", "("...
Save the rendered html to a file in the same directory as the notebook.
[ "Save", "the", "rendered", "html", "to", "a", "file", "in", "the", "same", "directory", "as", "the", "notebook", "." ]
0403486d8633f601a33c4d2b9c9fa3ec88e9327b
https://github.com/niloch/iplotter/blob/0403486d8633f601a33c4d2b9c9fa3ec88e9327b/iplotter/chartjs_plotter.py#L79-L105
train
62,735
mabuchilab/QNET
src/qnet/printing/_unicode_mappings.py
_unicode_sub_super
def _unicode_sub_super(string, mapping, max_len=None): """Try to render a subscript or superscript string in unicode, fall back on ascii if this is not possible""" string = str(string) if string.startswith('(') and string.endswith(')'): len_string = len(string) - 2 else: len_string =...
python
def _unicode_sub_super(string, mapping, max_len=None): """Try to render a subscript or superscript string in unicode, fall back on ascii if this is not possible""" string = str(string) if string.startswith('(') and string.endswith(')'): len_string = len(string) - 2 else: len_string =...
[ "def", "_unicode_sub_super", "(", "string", ",", "mapping", ",", "max_len", "=", "None", ")", ":", "string", "=", "str", "(", "string", ")", "if", "string", ".", "startswith", "(", "'('", ")", "and", "string", ".", "endswith", "(", "')'", ")", ":", "...
Try to render a subscript or superscript string in unicode, fall back on ascii if this is not possible
[ "Try", "to", "render", "a", "subscript", "or", "superscript", "string", "in", "unicode", "fall", "back", "on", "ascii", "if", "this", "is", "not", "possible" ]
cc20d26dad78691d34c67173e5cd67dcac94208a
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_unicode_mappings.py#L123-L137
train
62,736
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
train
62,737
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
train
62,738
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
train
62,739
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
train
62,740
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
train
62,741
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
train
62,742
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
train
62,743
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
train
62,744
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
train
62,745
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
train
62,746
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
train
62,747
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
train
62,748
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
train
62,749
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
train
62,750
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
train
62,751
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
train
62,752
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
train
62,753
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
train
62,754
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
train
62,755
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
train
62,756
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
train
62,757
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
train
62,758
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
train
62,759
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
train
62,760
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
train
62,761
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
train
62,762
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
train
62,763
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
train
62,764
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
train
62,765
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
train
62,766
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
train
62,767
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
train
62,768
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
train
62,769
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
train
62,770
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
train
62,771
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
train
62,772
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
train
62,773
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
train
62,774
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
train
62,775
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
train
62,776
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
train
62,777
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
train
62,778
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
train
62,779
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
train
62,780
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
train
62,781
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
train
62,782
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
train
62,783
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
train
62,784
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
train
62,785
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
train
62,786
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
train
62,787
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
train
62,788
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
train
62,789
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
train
62,790
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
train
62,791
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
train
62,792
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
train
62,793
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
train
62,794
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
train
62,795
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
train
62,796
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
train
62,797
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
train
62,798
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
train
62,799