nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
missionpinball/mpf
8e6b74cff4ba06d2fec9445742559c1068b88582
mpf/platforms/spike/spike.py
python
SpikeStepper.stop
(self)
Stop the stepper.
Stop the stepper.
[ "Stop", "the", "stepper", "." ]
def stop(self): """Stop the stepper.""" # reconfiguring seems to be used to stop the stepper self._configure()
[ "def", "stop", "(", "self", ")", ":", "# reconfiguring seems to be used to stop the stepper", "self", ".", "_configure", "(", ")" ]
https://github.com/missionpinball/mpf/blob/8e6b74cff4ba06d2fec9445742559c1068b88582/mpf/platforms/spike/spike.py#L436-L439
hyperledger/aries-cloudagent-python
2f36776e99f6053ae92eed8123b5b1b2e891c02a
aries_cloudagent/protocols/present_proof/v2_0/routes.py
python
V20PresRequestByFormatSchema.validate_fields
(self, data, **kwargs)
Validate schema fields: data must have at least one format. Args: data: The data to validate Raises: ValidationError: if data has no formats
Validate schema fields: data must have at least one format.
[ "Validate", "schema", "fields", ":", "data", "must", "have", "at", "least", "one", "format", "." ]
def validate_fields(self, data, **kwargs): """ Validate schema fields: data must have at least one format. Args: data: The data to validate Raises: ValidationError: if data has no formats """ if not any(f.api in data for f in V20PresFormat.Format): raise ValidationError( "V20PresRequestByFormatSchema requires indy, dif, or both" )
[ "def", "validate_fields", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "if", "not", "any", "(", "f", ".", "api", "in", "data", "for", "f", "in", "V20PresFormat", ".", "Format", ")", ":", "raise", "ValidationError", "(", "\"V20PresReques...
https://github.com/hyperledger/aries-cloudagent-python/blob/2f36776e99f6053ae92eed8123b5b1b2e891c02a/aries_cloudagent/protocols/present_proof/v2_0/routes.py#L189-L203
chribsen/simple-machine-learning-examples
dc94e52a4cebdc8bb959ff88b81ff8cfeca25022
venv/lib/python2.7/site-packages/pip/utils/__init__.py
python
dist_is_local
(dist)
return is_local(dist_location(dist))
Return True if given Distribution object is installed locally (i.e. within current virtualenv). Always True if we're not in a virtualenv.
Return True if given Distribution object is installed locally (i.e. within current virtualenv).
[ "Return", "True", "if", "given", "Distribution", "object", "is", "installed", "locally", "(", "i", ".", "e", ".", "within", "current", "virtualenv", ")", "." ]
def dist_is_local(dist): """ Return True if given Distribution object is installed locally (i.e. within current virtualenv). Always True if we're not in a virtualenv. """ return is_local(dist_location(dist))
[ "def", "dist_is_local", "(", "dist", ")", ":", "return", "is_local", "(", "dist_location", "(", "dist", ")", ")" ]
https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/pip/utils/__init__.py#L289-L297
bbc/brave
88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5
brave/inputs/input.py
python
Input.dest_connections
(self)
return self.session().connections.get_all_for_source(self)
Returns an array of Connections, describing what this input is connected to. (An input can have any number of connections, each going to a Mixer or Output.)
Returns an array of Connections, describing what this input is connected to. (An input can have any number of connections, each going to a Mixer or Output.)
[ "Returns", "an", "array", "of", "Connections", "describing", "what", "this", "input", "is", "connected", "to", ".", "(", "An", "input", "can", "have", "any", "number", "of", "connections", "each", "going", "to", "a", "Mixer", "or", "Output", ".", ")" ]
def dest_connections(self): ''' Returns an array of Connections, describing what this input is connected to. (An input can have any number of connections, each going to a Mixer or Output.) ''' return self.session().connections.get_all_for_source(self)
[ "def", "dest_connections", "(", "self", ")", ":", "return", "self", ".", "session", "(", ")", ".", "connections", ".", "get_all_for_source", "(", "self", ")" ]
https://github.com/bbc/brave/blob/88d4454412ee5acfa5ecf2ac5bc8cf75766c7be5/brave/inputs/input.py#L24-L29
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/input_datetime/reproduce_state.py
python
is_valid_date
(string: str)
return dt_util.parse_date(string) is not None
Test if string dt is a valid date.
Test if string dt is a valid date.
[ "Test", "if", "string", "dt", "is", "a", "valid", "date", "." ]
def is_valid_date(string: str) -> bool: """Test if string dt is a valid date.""" return dt_util.parse_date(string) is not None
[ "def", "is_valid_date", "(", "string", ":", "str", ")", "->", "bool", ":", "return", "dt_util", ".", "parse_date", "(", "string", ")", "is", "not", "None" ]
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/input_datetime/reproduce_state.py#L26-L28
kanzure/nanoengineer
874e4c9f8a9190f093625b267f9767e19f82e6c4
cad/src/model/chunk.py
python
Chunk.copy_full_in_mapping
(self, mapping)
return numol
#doc; overrides Node method; only some atom copies get recorded in mapping (if we think it might need them)
#doc; overrides Node method; only some atom copies get recorded in mapping (if we think it might need them)
[ "#doc", ";", "overrides", "Node", "method", ";", "only", "some", "atom", "copies", "get", "recorded", "in", "mapping", "(", "if", "we", "think", "it", "might", "need", "them", ")" ]
def copy_full_in_mapping(self, mapping): # in class Chunk """ #doc; overrides Node method; only some atom copies get recorded in mapping (if we think it might need them) """ # bruce 050526; 060308 major rewrite numol = self._copy_empty_shell_in_mapping( mapping) # now copy the atoms, all at once (including all their existing # singlets, even though those might get revised) # note: the following code is very similar to # copy_in_mapping_with_specified_atoms, but not identical. pairlis = [] ndix = {} # maps old-atom key to corresponding new atom nuatoms = {} for a in self.atlist: # note: self.atlist is now in order of atom.key; # it might get recomputed right now (along with atpos & basepos if so) na = a.copy() # inlined addatom, optimized (maybe put this in a new variant of obs copy_for_mol_copy?) na.molecule = numol # no need for _changed_parent_Atoms[na.key] = na #bruce 060322 nuatoms[na.key] = na pairlis.append((a, na)) ndix[a.key] = na numol.invalidate_atom_lists() numol.atoms = nuatoms # note: we don't bother copying atlist, atpos, basepos, # since it's hard to do correctly (e.g. not copying everything # which depends on them would cause inval bugs), and it's wasted work # for callers which plan to move all the atoms after # the copy self._copy_atoms_handle_bonds_jigs( pairlis, ndix, mapping) # note: no way to handle hotspot yet, since how to do that might depend on whether # extern bonds are broken... so let's copy an explicit one, and tell the mapping # if we have an implicit one... or, register a cleanup function with the mapping. copied_hotspot = self.hotspot # might be None (this uses __getattr__ to ensure the stored one is valid) if copied_hotspot is not None: numol.set_hotspot( ndix[copied_hotspot.key]) elif len(self.singlets) == 1: #e someday it might also work if there are two singlets on the same base atom! # we have an implicit but unambiguous hotspot: # might need to make it explicit in the copy [bruce 041123, revised 050524] copy_of_hotspot = ndix[self.singlets[0].key] mapping.do_at_end( lambda ch = copy_of_hotspot, numol = numol: numol._f_preserve_implicit_hotspot(ch) ) return numol
[ "def", "copy_full_in_mapping", "(", "self", ",", "mapping", ")", ":", "# in class Chunk", "# bruce 050526; 060308 major rewrite", "numol", "=", "self", ".", "_copy_empty_shell_in_mapping", "(", "mapping", ")", "# now copy the atoms, all at once (including all their existing", "...
https://github.com/kanzure/nanoengineer/blob/874e4c9f8a9190f093625b267f9767e19f82e6c4/cad/src/model/chunk.py#L2744-L2790
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/Django-1.11.29/django/db/backends/mysql/base.py
python
DatabaseWrapper.check_constraints
(self, table_names=None)
Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint checks were off. Raises an IntegrityError on the first invalid foreign key reference encountered (if any) and provides detailed information about the invalid reference in the error message. Backends can override this method if they can more directly apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE")
Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint checks were off.
[ "Checks", "each", "table", "name", "in", "table_names", "for", "rows", "with", "invalid", "foreign", "key", "references", ".", "This", "method", "is", "intended", "to", "be", "used", "in", "conjunction", "with", "disable_constraint_checking", "()", "and", "enabl...
def check_constraints(self, table_names=None): """ Checks each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint checks were off. Raises an IntegrityError on the first invalid foreign key reference encountered (if any) and provides detailed information about the invalid reference in the error message. Backends can override this method if they can more directly apply constraint checking (e.g. via "SET CONSTRAINTS ALL IMMEDIATE") """ cursor = self.cursor() if table_names is None: table_names = self.introspection.table_names(cursor) for table_name in table_names: primary_key_column_name = self.introspection.get_primary_key_column(cursor, table_name) if not primary_key_column_name: continue key_columns = self.introspection.get_key_columns(cursor, table_name) for column_name, referenced_table_name, referenced_column_name in key_columns: cursor.execute( """ SELECT REFERRING.`%s`, REFERRING.`%s` FROM `%s` as REFERRING LEFT JOIN `%s` as REFERRED ON (REFERRING.`%s` = REFERRED.`%s`) WHERE REFERRING.`%s` IS NOT NULL AND REFERRED.`%s` IS NULL """ % ( primary_key_column_name, column_name, table_name, referenced_table_name, column_name, referenced_column_name, column_name, referenced_column_name, ) ) for bad_row in cursor.fetchall(): raise utils.IntegrityError( "The row in table '%s' with primary key '%s' has an invalid " "foreign key: %s.%s contains a value '%s' that does not have a corresponding value in %s.%s." % ( table_name, bad_row[0], table_name, column_name, bad_row[1], referenced_table_name, referenced_column_name, ) )
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "cursor", "=", "self", ".", "cursor", "(", ")", "if", "table_names", "is", "None", ":", "table_names", "=", "self", ".", "introspection", ".", "table_names", "(", "cursor",...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/Django-1.11.29/django/db/backends/mysql/base.py#L329-L373
deepgully/me
f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0
libs/sqlalchemy/engine/reflection.py
python
Inspector.get_table_names
(self, schema=None, order_by=None)
return tnames
Return all table names in referred to within a particular schema. The names are expected to be real tables only, not views. Views are instead returned using the :meth:`.Inspector.get_view_names` method. :param schema: Schema name. If ``schema`` is left at ``None``, the database's default schema is used, else the named schema is searched. If the database does not support named schemas, behavior is undefined if ``schema`` is not passed as ``None``. For special quoting, use :class:`.quoted_name`. :param order_by: Optional, may be the string "foreign_key" to sort the result on foreign key dependencies. .. versionchanged:: 0.8 the "foreign_key" sorting sorts tables in order of dependee to dependent; that is, in creation order, rather than in drop order. This is to maintain consistency with similar features such as :attr:`.MetaData.sorted_tables` and :func:`.util.sort_tables`. .. seealso:: :attr:`.MetaData.sorted_tables`
Return all table names in referred to within a particular schema.
[ "Return", "all", "table", "names", "in", "referred", "to", "within", "a", "particular", "schema", "." ]
def get_table_names(self, schema=None, order_by=None): """Return all table names in referred to within a particular schema. The names are expected to be real tables only, not views. Views are instead returned using the :meth:`.Inspector.get_view_names` method. :param schema: Schema name. If ``schema`` is left at ``None``, the database's default schema is used, else the named schema is searched. If the database does not support named schemas, behavior is undefined if ``schema`` is not passed as ``None``. For special quoting, use :class:`.quoted_name`. :param order_by: Optional, may be the string "foreign_key" to sort the result on foreign key dependencies. .. versionchanged:: 0.8 the "foreign_key" sorting sorts tables in order of dependee to dependent; that is, in creation order, rather than in drop order. This is to maintain consistency with similar features such as :attr:`.MetaData.sorted_tables` and :func:`.util.sort_tables`. .. seealso:: :attr:`.MetaData.sorted_tables` """ if hasattr(self.dialect, 'get_table_names'): tnames = self.dialect.get_table_names(self.bind, schema, info_cache=self.info_cache) else: tnames = self.engine.table_names(schema) if order_by == 'foreign_key': tuples = [] for tname in tnames: for fkey in self.get_foreign_keys(tname, schema): if tname != fkey['referred_table']: tuples.append((fkey['referred_table'], tname)) tnames = list(topological.sort(tuples, tnames)) return tnames
[ "def", "get_table_names", "(", "self", ",", "schema", "=", "None", ",", "order_by", "=", "None", ")", ":", "if", "hasattr", "(", "self", ".", "dialect", ",", "'get_table_names'", ")", ":", "tnames", "=", "self", ".", "dialect", ".", "get_table_names", "(...
https://github.com/deepgully/me/blob/f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0/libs/sqlalchemy/engine/reflection.py#L160-L201
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/ma/core.py
python
_recursive_fill_value
(dtype, f)
Recursively produce a fill value for `dtype`, calling f on scalar dtypes
Recursively produce a fill value for `dtype`, calling f on scalar dtypes
[ "Recursively", "produce", "a", "fill", "value", "for", "dtype", "calling", "f", "on", "scalar", "dtypes" ]
def _recursive_fill_value(dtype, f): """ Recursively produce a fill value for `dtype`, calling f on scalar dtypes """ if dtype.names is not None: vals = tuple(_recursive_fill_value(dtype[name], f) for name in dtype.names) return np.array(vals, dtype=dtype)[()] # decay to void scalar from 0d elif dtype.subdtype: subtype, shape = dtype.subdtype subval = _recursive_fill_value(subtype, f) return np.full(shape, subval) else: return f(dtype)
[ "def", "_recursive_fill_value", "(", "dtype", ",", "f", ")", ":", "if", "dtype", ".", "names", "is", "not", "None", ":", "vals", "=", "tuple", "(", "_recursive_fill_value", "(", "dtype", "[", "name", "]", ",", "f", ")", "for", "name", "in", "dtype", ...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/numpy-1.16.0-py3.7-macosx-10.9-x86_64.egg/numpy/ma/core.py#L211-L223
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/ip_messaging/v2/__init__.py
python
V2.services
(self)
return self._services
:rtype: twilio.rest.ip_messaging.v2.service.ServiceList
:rtype: twilio.rest.ip_messaging.v2.service.ServiceList
[ ":", "rtype", ":", "twilio", ".", "rest", ".", "ip_messaging", ".", "v2", ".", "service", ".", "ServiceList" ]
def services(self): """ :rtype: twilio.rest.ip_messaging.v2.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services
[ "def", "services", "(", "self", ")", ":", "if", "self", ".", "_services", "is", "None", ":", "self", ".", "_services", "=", "ServiceList", "(", "self", ")", "return", "self", ".", "_services" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/ip_messaging/v2/__init__.py#L38-L44
sahana/eden
1696fa50e90ce967df69f66b571af45356cc18da
modules/templates/locations/FI/config.py
python
config
(settings)
Template settings for Finland - designed to be used in a Cascade with an application template
Template settings for Finland - designed to be used in a Cascade with an application template
[ "Template", "settings", "for", "Finland", "-", "designed", "to", "be", "used", "in", "a", "Cascade", "with", "an", "application", "template" ]
def config(settings): """ Template settings for Finland - designed to be used in a Cascade with an application template """ #T = current.T # Pre-Populate settings.base.prepopulate.append("locations/FI") # Uncomment to restrict to specific country/countries settings.gis.countries.append("FI") # ------------------------------------------------------------------------- # L10n (Localization) settings settings.L10n.languages["fi"] = "Finnish" settings.L10n.languages["sv"] = "Swedish" settings.L10n.languages["smi"] = "Sámi" # Default Language (put this in custom template if-required) #settings.L10n.default_language = "fi" # Default timezone for users settings.L10n.timezone = "Europe/Helsinki" # Default Country Code for telephone numbers settings.L10n.default_country_code = 358 settings.fin.currencies["EUR"] = "Euro" settings.fin.currency_default = "EUR"
[ "def", "config", "(", "settings", ")", ":", "#T = current.T", "# Pre-Populate", "settings", ".", "base", ".", "prepopulate", ".", "append", "(", "\"locations/FI\"", ")", "# Uncomment to restrict to specific country/countries", "settings", ".", "gis", ".", "countries", ...
https://github.com/sahana/eden/blob/1696fa50e90ce967df69f66b571af45356cc18da/modules/templates/locations/FI/config.py#L5-L32
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
dist/lib/python2.7/SimpleHTTPServer.py
python
SimpleHTTPRequestHandler.guess_type
(self, path)
Guess the type of a file. Argument is a PATH (a filename). Return value is a string of the form type/subtype, usable for a MIME Content-type header. The default implementation looks the file's extension up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess.
Guess the type of a file.
[ "Guess", "the", "type", "of", "a", "file", "." ]
def guess_type(self, path): """Guess the type of a file. Argument is a PATH (a filename). Return value is a string of the form type/subtype, usable for a MIME Content-type header. The default implementation looks the file's extension up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess. """ base, ext = posixpath.splitext(path) if ext in self.extensions_map: return self.extensions_map[ext] ext = ext.lower() if ext in self.extensions_map: return self.extensions_map[ext] else: return self.extensions_map['']
[ "def", "guess_type", "(", "self", ",", "path", ")", ":", "base", ",", "ext", "=", "posixpath", ".", "splitext", "(", "path", ")", "if", "ext", "in", "self", ".", "extensions_map", ":", "return", "self", ".", "extensions_map", "[", "ext", "]", "ext", ...
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/dist/lib/python2.7/SimpleHTTPServer.py#L179-L201
apachecn/AiLearning
228b62a905a2a9bf6066f65c16d53056b10ec610
src/py3.x/dl/bp.py
python
ConstNode.append_downstream_connection
(self, conn)
Desc: 添加一个到下游节点的连接 Args: conn --- 到下游节点的连接 Returns: None
Desc: 添加一个到下游节点的连接 Args: conn --- 到下游节点的连接 Returns: None
[ "Desc", ":", "添加一个到下游节点的连接", "Args", ":", "conn", "---", "到下游节点的连接", "Returns", ":", "None" ]
def append_downstream_connection(self, conn): ''' Desc: 添加一个到下游节点的连接 Args: conn --- 到下游节点的连接 Returns: None ''' # 使用 list 的 append 方法将包含下游节点的 conn 添加到 downstream 中 self.downstream.append(conn)
[ "def", "append_downstream_connection", "(", "self", ",", "conn", ")", ":", "# 使用 list 的 append 方法将包含下游节点的 conn 添加到 downstream 中 ", "self", ".", "downstream", ".", "append", "(", "conn", ")" ]
https://github.com/apachecn/AiLearning/blob/228b62a905a2a9bf6066f65c16d53056b10ec610/src/py3.x/dl/bp.py#L166-L176
adamchainz/django-mysql
389594dc078f73c9f204306014332344fe4b6d04
src/django_mysql/models/fields/dynamic.py
python
KeyTransform.as_sql
( self, compiler: SQLCompiler, connection: BaseDatabaseWrapper )
return ( f"COLUMN_GET({lhs}, %s AS {self.data_type})", tuple(params) + (self.key_name,), )
[]
def as_sql( self, compiler: SQLCompiler, connection: BaseDatabaseWrapper ) -> Tuple[str, Iterable[Any]]: lhs, params = compiler.compile(self.lhs) return ( f"COLUMN_GET({lhs}, %s AS {self.data_type})", tuple(params) + (self.key_name,), )
[ "def", "as_sql", "(", "self", ",", "compiler", ":", "SQLCompiler", ",", "connection", ":", "BaseDatabaseWrapper", ")", "->", "Tuple", "[", "str", ",", "Iterable", "[", "Any", "]", "]", ":", "lhs", ",", "params", "=", "compiler", ".", "compile", "(", "s...
https://github.com/adamchainz/django-mysql/blob/389594dc078f73c9f204306014332344fe4b6d04/src/django_mysql/models/fields/dynamic.py#L355-L362
dropbox/dropbox-sdk-python
015437429be224732990041164a21a0501235db1
dropbox/team_log.py
python
EventTypeArg.is_folder_overview_item_unpinned
(self)
return self._tag == 'folder_overview_item_unpinned'
Check if the union tag is ``folder_overview_item_unpinned``. :rtype: bool
Check if the union tag is ``folder_overview_item_unpinned``.
[ "Check", "if", "the", "union", "tag", "is", "folder_overview_item_unpinned", "." ]
def is_folder_overview_item_unpinned(self): """ Check if the union tag is ``folder_overview_item_unpinned``. :rtype: bool """ return self._tag == 'folder_overview_item_unpinned'
[ "def", "is_folder_overview_item_unpinned", "(", "self", ")", ":", "return", "self", ".", "_tag", "==", "'folder_overview_item_unpinned'" ]
https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/team_log.py#L40679-L40685
huawei-noah/vega
d9f13deede7f2b584e4b1d32ffdb833856129989
vega/networks/pytorch/customs/modnas/arch_space/torch/pyramidnet.py
python
BottleneckBlock.forward
(self, x)
return out
Compute network output.
Compute network output.
[ "Compute", "network", "output", "." ]
def forward(self, x): """Compute network output.""" out = self.bottle_in(x) out = self.cell(out) out = self.bottle_out(out) out = self.bn(out) if self.downsample is not None: shortcut = self.downsample(x) featuremap_size = shortcut.size()[2:4] else: shortcut = x featuremap_size = out.size()[2:4] batch_size = out.size()[0] residual_channel = out.size()[1] shortcut_channel = shortcut.size()[1] if residual_channel != shortcut_channel: padding = torch.zeros(batch_size, residual_channel - shortcut_channel, featuremap_size[0], featuremap_size[1]).to(device=x.device) out += torch.cat((shortcut, padding), 1) else: out += shortcut return out
[ "def", "forward", "(", "self", ",", "x", ")", ":", "out", "=", "self", ".", "bottle_in", "(", "x", ")", "out", "=", "self", ".", "cell", "(", "out", ")", "out", "=", "self", ".", "bottle_out", "(", "out", ")", "out", "=", "self", ".", "bn", "...
https://github.com/huawei-noah/vega/blob/d9f13deede7f2b584e4b1d32ffdb833856129989/vega/networks/pytorch/customs/modnas/arch_space/torch/pyramidnet.py#L54-L78
frappe/frappe
b64cab6867dfd860f10ccaf41a4ec04bc890b583
frappe/modules/utils.py
python
sync_customizations
(app=None)
Sync custom fields and property setters from custom folder in each app module
Sync custom fields and property setters from custom folder in each app module
[ "Sync", "custom", "fields", "and", "property", "setters", "from", "custom", "folder", "in", "each", "app", "module" ]
def sync_customizations(app=None): '''Sync custom fields and property setters from custom folder in each app module''' if app: apps = [app] else: apps = frappe.get_installed_apps() for app_name in apps: for module_name in frappe.local.app_modules.get(app_name) or []: folder = frappe.get_app_path(app_name, module_name, 'custom') if os.path.exists(folder): for fname in os.listdir(folder): if fname.endswith('.json'): with open(os.path.join(folder, fname), 'r') as f: data = json.loads(f.read()) if data.get('sync_on_migrate'): sync_customizations_for_doctype(data, folder)
[ "def", "sync_customizations", "(", "app", "=", "None", ")", ":", "if", "app", ":", "apps", "=", "[", "app", "]", "else", ":", "apps", "=", "frappe", ".", "get_installed_apps", "(", ")", "for", "app_name", "in", "apps", ":", "for", "module_name", "in", ...
https://github.com/frappe/frappe/blob/b64cab6867dfd860f10ccaf41a4ec04bc890b583/frappe/modules/utils.py#L78-L95
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/modules/zoneadm.py
python
clone
(zone, source, snapshot=None)
return ret
Install a zone by copying an existing installed zone. zone : string name of the zone source : string zone to clone from snapshot : string optional name of snapshot to use as source CLI Example: .. code-block:: bash salt '*' zoneadm.clone clementine dolores
Install a zone by copying an existing installed zone.
[ "Install", "a", "zone", "by", "copying", "an", "existing", "installed", "zone", "." ]
def clone(zone, source, snapshot=None): """ Install a zone by copying an existing installed zone. zone : string name of the zone source : string zone to clone from snapshot : string optional name of snapshot to use as source CLI Example: .. code-block:: bash salt '*' zoneadm.clone clementine dolores """ ret = {"status": True} ## install zone res = __salt__["cmd.run_all"]( "zoneadm -z {zone} clone {snapshot}{source}".format( zone=zone, source=source, snapshot="-s {} ".format(snapshot) if snapshot else "", ) ) ret["status"] = res["retcode"] == 0 ret["message"] = res["stdout"] if ret["status"] else res["stderr"] ret["message"] = ret["message"].replace("zoneadm: ", "") if ret["message"] == "": del ret["message"] return ret
[ "def", "clone", "(", "zone", ",", "source", ",", "snapshot", "=", "None", ")", ":", "ret", "=", "{", "\"status\"", ":", "True", "}", "## install zone", "res", "=", "__salt__", "[", "\"cmd.run_all\"", "]", "(", "\"zoneadm -z {zone} clone {snapshot}{source}\"", ...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/zoneadm.py#L539-L572
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/labs/drkit/run_dualencoder_lsf.py
python
_copy_model
(in_path, out_path)
Copy model checkpoint for future use.
Copy model checkpoint for future use.
[ "Copy", "model", "checkpoint", "for", "future", "use", "." ]
def _copy_model(in_path, out_path): """Copy model checkpoint for future use.""" tf.logging.info("Copying checkpoint from %s to %s.", in_path, out_path) tf.gfile.Copy( in_path + ".data-00000-of-00001", out_path + ".data-00000-of-00001", overwrite=True) tf.gfile.Copy(in_path + ".index", out_path + ".index", overwrite=True) tf.gfile.Copy(in_path + ".meta", out_path + ".meta", overwrite=True)
[ "def", "_copy_model", "(", "in_path", ",", "out_path", ")", ":", "tf", ".", "logging", ".", "info", "(", "\"Copying checkpoint from %s to %s.\"", ",", "in_path", ",", "out_path", ")", "tf", ".", "gfile", ".", "Copy", "(", "in_path", "+", "\".data-00000-of-0000...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/labs/drkit/run_dualencoder_lsf.py#L2135-L2143
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/cloud/clouds/profitbricks.py
python
stop
(name, call=None)
return True
stop a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a stop vm_name
stop a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful
[ "stop", "a", "machine", "by", "name", ":", "param", "name", ":", "name", "given", "to", "the", "machine", ":", "param", "call", ":", "call", "value", "in", "this", "case", "is", "action", ":", "return", ":", "true", "if", "successful" ]
def stop(name, call=None): """ stop a machine by name :param name: name given to the machine :param call: call value in this case is 'action' :return: true if successful CLI Example: .. code-block:: bash salt-cloud -a stop vm_name """ datacenter_id = get_datacenter_id() conn = get_conn() node = get_node(conn, name) conn.stop_server(datacenter_id=datacenter_id, server_id=node["id"]) return True
[ "def", "stop", "(", "name", ",", "call", "=", "None", ")", ":", "datacenter_id", "=", "get_datacenter_id", "(", ")", "conn", "=", "get_conn", "(", ")", "node", "=", "get_node", "(", "conn", ",", "name", ")", "conn", ".", "stop_server", "(", "datacenter...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/cloud/clouds/profitbricks.py#L1011-L1030
TheAlgorithms/Python
9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c
project_euler/problem_206/sol1.py
python
solution
()
return num * 10
Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0
Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0
[ "Returns", "the", "first", "integer", "whose", "square", "is", "of", "the", "form", "1_2_3_4_5_6_7_8_9_0" ]
def solution() -> int: """ Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0 """ num = 138902663 while not is_square_form(num * num): if num % 10 == 3: num -= 6 # (3 - 6) % 10 = 7 else: num -= 4 # (7 - 4) % 10 = 3 return num * 10
[ "def", "solution", "(", ")", "->", "int", ":", "num", "=", "138902663", "while", "not", "is_square_form", "(", "num", "*", "num", ")", ":", "if", "num", "%", "10", "==", "3", ":", "num", "-=", "6", "# (3 - 6) % 10 = 7", "else", ":", "num", "-=", "4...
https://github.com/TheAlgorithms/Python/blob/9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c/project_euler/problem_206/sol1.py#L58-L70
evilhero/mylar
dbee01d7e48e8c717afa01b2de1946c5d0b956cb
lib/cherrypy/wsgiserver/wsgiserver2.py
python
read_headers
(rfile, hdict=None)
return hdict
Read headers from the given stream into the given header dict. If hdict is None, a new header dict is created. Returns the populated header dict. Headers which are repeated are folded together using a comma if their specification so dictates. This function raises ValueError when the read bytes violate the HTTP spec. You should probably return "400 Bad Request" if this happens.
Read headers from the given stream into the given header dict.
[ "Read", "headers", "from", "the", "given", "stream", "into", "the", "given", "header", "dict", "." ]
def read_headers(rfile, hdict=None): """Read headers from the given stream into the given header dict. If hdict is None, a new header dict is created. Returns the populated header dict. Headers which are repeated are folded together using a comma if their specification so dictates. This function raises ValueError when the read bytes violate the HTTP spec. You should probably return "400 Bad Request" if this happens. """ if hdict is None: hdict = {} while True: line = rfile.readline() if not line: # No more data--illegal end of headers raise ValueError("Illegal end of headers.") if line == CRLF: # Normal end of headers break if not line.endswith(CRLF): raise ValueError("HTTP requires CRLF terminators") if line[0] in (SPACE, TAB): # It's a continuation line. v = line.strip() else: try: k, v = line.split(COLON, 1) except ValueError: raise ValueError("Illegal header line.") # TODO: what about TE and WWW-Authenticate? k = k.strip().title() v = v.strip() hname = k if k in comma_separated_headers: existing = hdict.get(hname) if existing: v = ", ".join((existing, v)) hdict[hname] = v return hdict
[ "def", "read_headers", "(", "rfile", ",", "hdict", "=", "None", ")", ":", "if", "hdict", "is", "None", ":", "hdict", "=", "{", "}", "while", "True", ":", "line", "=", "rfile", ".", "readline", "(", ")", "if", "not", "line", ":", "# No more data--ille...
https://github.com/evilhero/mylar/blob/dbee01d7e48e8c717afa01b2de1946c5d0b956cb/lib/cherrypy/wsgiserver/wsgiserver2.py#L218-L264
Kismuz/btgym
7fb3316e67f1d7a17c620630fb62fb29428b2cec
btgym/research/model_based/model/rec.py
python
OUEstimator.__init__
(self, alpha)
Args: alpha: float in [0, 1], decaying window factor. Notes: alpha ~ 1 / effective_window_length; parameters fitted are: Mu, Log_Theta, Log_Sigma, for process: dX = -Theta *(X - Mu) + Sigma * dW;
[]
def __init__(self, alpha): """ Args: alpha: float in [0, 1], decaying window factor. Notes: alpha ~ 1 / effective_window_length; parameters fitted are: Mu, Log_Theta, Log_Sigma, for process: dX = -Theta *(X - Mu) + Sigma * dW; """ self.alpha = alpha self.covariance_estimator = Covariance(2, alpha) self.residuals_stat = Zscore(1, alpha) self.residuals = None self.ls_a = None self.ls_b = None self.mu = None self.log_theta = None self.log_sigma = None self.x_prev = 0.0
[ "def", "__init__", "(", "self", ",", "alpha", ")", ":", "self", ".", "alpha", "=", "alpha", "self", ".", "covariance_estimator", "=", "Covariance", "(", "2", ",", "alpha", ")", "self", ".", "residuals_stat", "=", "Zscore", "(", "1", ",", "alpha", ")", ...
https://github.com/Kismuz/btgym/blob/7fb3316e67f1d7a17c620630fb62fb29428b2cec/btgym/research/model_based/model/rec.py#L545-L564
p5py/p5
4ef1580b26179f1973c1669751da4522c5823f17
p5/sketch/Vispy2DRenderer/base.py
python
VispySketch._save_buffer
(self)
Save the renderer buffer to the given file.
Save the renderer buffer to the given file.
[ "Save", "the", "renderer", "buffer", "to", "the", "given", "file", "." ]
def _save_buffer(self): """Save the renderer buffer to the given file. """ img_data = p5.renderer.fbuffer.read(mode='color', alpha=False) img = Image.fromarray(img_data) img.save(self._save_fname) self._save_flag = False
[ "def", "_save_buffer", "(", "self", ")", ":", "img_data", "=", "p5", ".", "renderer", ".", "fbuffer", ".", "read", "(", "mode", "=", "'color'", ",", "alpha", "=", "False", ")", "img", "=", "Image", ".", "fromarray", "(", "img_data", ")", "img", ".", ...
https://github.com/p5py/p5/blob/4ef1580b26179f1973c1669751da4522c5823f17/p5/sketch/Vispy2DRenderer/base.py#L127-L133
beeware/ouroboros
a29123c6fab6a807caffbb7587cf548e0c370296
ouroboros/imp.py
python
get_magic
()
return util.MAGIC_NUMBER
**DEPRECATED** Return the magic number for .pyc or .pyo files.
**DEPRECATED**
[ "**", "DEPRECATED", "**" ]
def get_magic(): """**DEPRECATED** Return the magic number for .pyc or .pyo files. """ return util.MAGIC_NUMBER
[ "def", "get_magic", "(", ")", ":", "return", "util", ".", "MAGIC_NUMBER" ]
https://github.com/beeware/ouroboros/blob/a29123c6fab6a807caffbb7587cf548e0c370296/ouroboros/imp.py#L58-L63
elyra-ai/elyra
5bb2009a7c475bda63f1cc2767eb8c4dfba9a239
elyra/cli/pipeline_app.py
python
run
(json_option, pipeline_path)
Run a pipeline in your local environment
Run a pipeline in your local environment
[ "Run", "a", "pipeline", "in", "your", "local", "environment" ]
def run(json_option, pipeline_path): """ Run a pipeline in your local environment """ click.echo() print_banner("Elyra Pipeline Local Run") _validate_pipeline_file_extension(pipeline_path) pipeline_definition = \ _preprocess_pipeline(pipeline_path, runtime='local', runtime_config='local') _validate_pipeline_definition(pipeline_definition) response = _execute_pipeline(pipeline_definition) if not json_option: click.echo() print_banner("Elyra Pipeline Local Run Complete") else: click.echo() if response: print(json.dumps(response.to_json(), indent=4))
[ "def", "run", "(", "json_option", ",", "pipeline_path", ")", ":", "click", ".", "echo", "(", ")", "print_banner", "(", "\"Elyra Pipeline Local Run\"", ")", "_validate_pipeline_file_extension", "(", "pipeline_path", ")", "pipeline_definition", "=", "_preprocess_pipeline"...
https://github.com/elyra-ai/elyra/blob/5bb2009a7c475bda63f1cc2767eb8c4dfba9a239/elyra/cli/pipeline_app.py#L317-L340
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
core/error.py
python
_ControlFlow.IsBreak
(self)
return self.token.id == Id.ControlFlow_Break
[]
def IsBreak(self): # type: () -> bool from _devbuild.gen.id_kind_asdl import Id # TODO: fix circular dep return self.token.id == Id.ControlFlow_Break
[ "def", "IsBreak", "(", "self", ")", ":", "# type: () -> bool", "from", "_devbuild", ".", "gen", ".", "id_kind_asdl", "import", "Id", "# TODO: fix circular dep", "return", "self", ".", "token", ".", "id", "==", "Id", ".", "ControlFlow_Break" ]
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/core/error.py#L49-L53
BillBillBillBill/Tickeys-linux
2df31b8665004c58a5d4ab05277f245267d96364
tickeys/kivy_32/kivy/lang.py
python
BuilderBase.sync
(self)
Execute all the waiting operations, such as the execution of all the expressions related to the canvas. .. versionadded:: 1.7.0
Execute all the waiting operations, such as the execution of all the expressions related to the canvas.
[ "Execute", "all", "the", "waiting", "operations", "such", "as", "the", "execution", "of", "all", "the", "expressions", "related", "to", "the", "canvas", "." ]
def sync(self): '''Execute all the waiting operations, such as the execution of all the expressions related to the canvas. .. versionadded:: 1.7.0 ''' global _delayed_start next_args = _delayed_start if next_args is None: return while next_args is not StopIteration: # is this try/except still needed? yes, in case widget died in this # frame after the call was scheduled try: call_fn(next_args[:-1], None, None) except ReferenceError: pass args = next_args next_args = args[-1] args[-1] = None _delayed_start = None
[ "def", "sync", "(", "self", ")", ":", "global", "_delayed_start", "next_args", "=", "_delayed_start", "if", "next_args", "is", "None", ":", "return", "while", "next_args", "is", "not", "StopIteration", ":", "# is this try/except still needed? yes, in case widget died in...
https://github.com/BillBillBillBill/Tickeys-linux/blob/2df31b8665004c58a5d4ab05277f245267d96364/tickeys/kivy_32/kivy/lang.py#L2067-L2088
roglew/guppy-proxy
01df16be71dd9f23d7de415a315821659c29bc63
guppyproxy/hexteditor.py
python
PrettyPrintWidget.__init__
(self, *args, **kwargs)
[]
def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.headers = Headers() self.data = b'' self.view = 0 self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.stack = QStackedLayout() self.stack.setContentsMargins(0, 0, 0, 0) self.nopp_widg = QLabel("No pretty version available") self.stack.addWidget(self.nopp_widg) self.highlighted_widg = QTextEdit() self.highlighted_widg.setReadOnly(True) self.stack.addWidget(self.highlighted_widg) self.json_widg = QTextEdit() self.json_widg.setReadOnly(True) self.stack.addWidget(self.json_widg) self.htmlxml_widg = QTextEdit() self.htmlxml_widg.setReadOnly(True) self.stack.addWidget(self.htmlxml_widg) self.selector = QComboBox() self.selector.addItem("Manually Select Printer", self.VIEW_NONE) self.selector.addItem("Highlighted", self.VIEW_HIGHLIGHTED) self.selector.addItem("JSON", self.VIEW_JSON) self.selector.addItem("HTML/XML", self.VIEW_HTMLXML) self.selector.currentIndexChanged.connect(self._combo_changed) self.layout().addWidget(self.selector) self.layout().addLayout(self.stack)
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "QWidget", ".", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "headers", "=", "Headers", "(", ")", "self", ".", "data", ...
https://github.com/roglew/guppy-proxy/blob/01df16be71dd9f23d7de415a315821659c29bc63/guppyproxy/hexteditor.py#L21-L51
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/bokeh-1.4.0-py3.7.egg/bokeh/document/events.py
python
ModelChangedEvent.__init__
(self, document, model, attr, old, new, serializable_new, hint=None, setter=None, callback_invoker=None)
Args: document (Document) : A Bokeh document that is to be updated. model (Model) : A Model to update attr (str) : The name of the attribute to update on the model. old (object) : The old value of the attribute new (object) : The new value of the attribute serializable_new (object) : A serialized (JSON) version of the new value. It may be ``None`` if a hint is supplied. hint (DocumentPatchedEvent, optional) : When appropriate, a secondary event may be supplied that modifies the normal update process. For example, in order to stream or patch data more efficiently than the standard update mechanism. setter (ClientSession or ServerSession or None, optional) : This is used to prevent "boomerang" updates to Bokeh apps. (default: None) See :class:`~bokeh.document.events.DocumentChangedEvent` for more details. callback_invoker (callable, optional) : A callable that will invoke any Model callbacks that should be executed in response to the change that triggered this event. (default: None)
[]
def __init__(self, document, model, attr, old, new, serializable_new, hint=None, setter=None, callback_invoker=None): ''' Args: document (Document) : A Bokeh document that is to be updated. model (Model) : A Model to update attr (str) : The name of the attribute to update on the model. old (object) : The old value of the attribute new (object) : The new value of the attribute serializable_new (object) : A serialized (JSON) version of the new value. It may be ``None`` if a hint is supplied. hint (DocumentPatchedEvent, optional) : When appropriate, a secondary event may be supplied that modifies the normal update process. For example, in order to stream or patch data more efficiently than the standard update mechanism. setter (ClientSession or ServerSession or None, optional) : This is used to prevent "boomerang" updates to Bokeh apps. (default: None) See :class:`~bokeh.document.events.DocumentChangedEvent` for more details. callback_invoker (callable, optional) : A callable that will invoke any Model callbacks that should be executed in response to the change that triggered this event. (default: None) ''' if setter is None and isinstance(hint, (ColumnsStreamedEvent, ColumnsPatchedEvent)): setter = hint.setter super(ModelChangedEvent, self).__init__(document, setter, callback_invoker) self.model = model self.attr = attr self.old = old self.new = new self.serializable_new = serializable_new self.hint = hint
[ "def", "__init__", "(", "self", ",", "document", ",", "model", ",", "attr", ",", "old", ",", "new", ",", "serializable_new", ",", "hint", "=", "None", ",", "setter", "=", "None", ",", "callback_invoker", "=", "None", ")", ":", "if", "setter", "is", "...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/bokeh-1.4.0-py3.7.egg/bokeh/document/events.py#L162-L213
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tcaplusdb/v20190823/models.py
python
VerifyIdlFilesResponse.__init__
(self)
r""" :param IdlFiles: 本次上传校验所有的IDL文件信息列表 :type IdlFiles: list of IdlFileInfo :param TotalCount: 读取IDL描述文件后解析出的合法表数量,不包含已经创建的表 :type TotalCount: int :param TableInfos: 读取IDL描述文件后解析出的合法表列表,不包含已经创建的表 :type TableInfos: list of ParsedTableInfoNew :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param IdlFiles: 本次上传校验所有的IDL文件信息列表 :type IdlFiles: list of IdlFileInfo :param TotalCount: 读取IDL描述文件后解析出的合法表数量,不包含已经创建的表 :type TotalCount: int :param TableInfos: 读取IDL描述文件后解析出的合法表列表,不包含已经创建的表 :type TableInfos: list of ParsedTableInfoNew :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "IdlFiles", ":", "本次上传校验所有的IDL文件信息列表", ":", "type", "IdlFiles", ":", "list", "of", "IdlFileInfo", ":", "param", "TotalCount", ":", "读取IDL描述文件后解析出的合法表数量,不包含已经创建的表", ":", "type", "TotalCount", ":", "int", ":", "param", "TableInfos", ":", "读取IDL描...
def __init__(self): r""" :param IdlFiles: 本次上传校验所有的IDL文件信息列表 :type IdlFiles: list of IdlFileInfo :param TotalCount: 读取IDL描述文件后解析出的合法表数量,不包含已经创建的表 :type TotalCount: int :param TableInfos: 读取IDL描述文件后解析出的合法表列表,不包含已经创建的表 :type TableInfos: list of ParsedTableInfoNew :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.IdlFiles = None self.TotalCount = None self.TableInfos = None self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "IdlFiles", "=", "None", "self", ".", "TotalCount", "=", "None", "self", ".", "TableInfos", "=", "None", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tcaplusdb/v20190823/models.py#L5155-L5169
FabriceSalvaire/PySpice
1fb97dc21abcf04cfd78802671322eef5c0de00b
PySpice/Spice/NgSpice/Server.py
python
SpiceServer._parse_stdout
(self, stdout)
Parse stdout for errors.
Parse stdout for errors.
[ "Parse", "stdout", "for", "errors", "." ]
def _parse_stdout(self, stdout): """Parse stdout for errors.""" # self._logger.debug(os.linesep + stdout) error_found = False # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 870: invalid start byte # lines = stdout.decode('utf-8').splitlines() lines = stdout.splitlines() for line_index, line in enumerate(lines): if line.startswith(b'Error '): error_found = True self._logger.error(os.linesep + line.decode('utf-8') + os.linesep + lines[line_index+1].decode('utf-8')) if error_found: raise NameError("Errors was found by Spice")
[ "def", "_parse_stdout", "(", "self", ",", "stdout", ")", ":", "# self._logger.debug(os.linesep + stdout)", "error_found", "=", "False", "# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 870: invalid start byte", "# lines = stdout.decode('utf-8').splitlines()", "line...
https://github.com/FabriceSalvaire/PySpice/blob/1fb97dc21abcf04cfd78802671322eef5c0de00b/PySpice/Spice/NgSpice/Server.py#L98-L113
limodou/uliweb
8bc827fa6bf7bf58aa8136b6c920fe2650c52422
uliweb/lib/colorama/ansitowin32.py
python
AnsiToWin32.should_wrap
(self)
return self.convert or self.strip or self.autoreset
True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionality like autoreset has been requested using kwargs to init()
True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionality like autoreset has been requested using kwargs to init()
[ "True", "if", "this", "class", "is", "actually", "needed", ".", "If", "false", "then", "the", "output", "stream", "will", "not", "be", "affected", "nor", "will", "win32", "calls", "be", "issued", "so", "wrapping", "stdout", "is", "not", "actually", "requir...
def should_wrap(self): ''' True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionality like autoreset has been requested using kwargs to init() ''' return self.convert or self.strip or self.autoreset
[ "def", "should_wrap", "(", "self", ")", ":", "return", "self", ".", "convert", "or", "self", ".", "strip", "or", "self", ".", "autoreset" ]
https://github.com/limodou/uliweb/blob/8bc827fa6bf7bf58aa8136b6c920fe2650c52422/uliweb/lib/colorama/ansitowin32.py#L74-L82
deepgully/me
f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0
libs/simplejson/decoder.py
python
JSONDecoder.__init__
(self, encoding=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
*encoding* determines the encoding used to interpret any :class:`str` objects decoded by this instance (``'utf-8'`` by default). It has no effect when decoding :class:`unicode` objects. Note that currently only encodings that are a superset of ASCII work, strings of other encodings should be passed in as :class:`unicode`. *object_hook*, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given :class:`dict`. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting). *object_pairs_hook* is an optional function that will be called with the result of any object literal decode with an ordered list of pairs. The return value of *object_pairs_hook* will be used instead of the :class:`dict`. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, :func:`collections.OrderedDict` will remember the order of insertion). If *object_hook* is also defined, the *object_pairs_hook* takes priority. *parse_float*, if specified, will be called with the string of every JSON float to be decoded. By default, this is equivalent to ``float(num_str)``. This can be used to use another datatype or parser for JSON floats (e.g. :class:`decimal.Decimal`). *parse_int*, if specified, will be called with the string of every JSON int to be decoded. By default, this is equivalent to ``int(num_str)``. This can be used to use another datatype or parser for JSON integers (e.g. :class:`float`). *parse_constant*, if specified, will be called with one of the following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to raise an exception if invalid JSON numbers are encountered. *strict* controls the parser's behavior when it encounters an invalid control character in a string. The default setting of ``True`` means that unescaped control characters are parse errors, if ``False`` then control characters will be allowed in strings.
*encoding* determines the encoding used to interpret any :class:`str` objects decoded by this instance (``'utf-8'`` by default). It has no effect when decoding :class:`unicode` objects.
[ "*", "encoding", "*", "determines", "the", "encoding", "used", "to", "interpret", "any", ":", "class", ":", "str", "objects", "decoded", "by", "this", "instance", "(", "utf", "-", "8", "by", "default", ")", ".", "It", "has", "no", "effect", "when", "de...
def __init__(self, encoding=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None): """ *encoding* determines the encoding used to interpret any :class:`str` objects decoded by this instance (``'utf-8'`` by default). It has no effect when decoding :class:`unicode` objects. Note that currently only encodings that are a superset of ASCII work, strings of other encodings should be passed in as :class:`unicode`. *object_hook*, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given :class:`dict`. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting). *object_pairs_hook* is an optional function that will be called with the result of any object literal decode with an ordered list of pairs. The return value of *object_pairs_hook* will be used instead of the :class:`dict`. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, :func:`collections.OrderedDict` will remember the order of insertion). If *object_hook* is also defined, the *object_pairs_hook* takes priority. *parse_float*, if specified, will be called with the string of every JSON float to be decoded. By default, this is equivalent to ``float(num_str)``. This can be used to use another datatype or parser for JSON floats (e.g. :class:`decimal.Decimal`). *parse_int*, if specified, will be called with the string of every JSON int to be decoded. By default, this is equivalent to ``int(num_str)``. This can be used to use another datatype or parser for JSON integers (e.g. :class:`float`). *parse_constant*, if specified, will be called with one of the following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to raise an exception if invalid JSON numbers are encountered. *strict* controls the parser's behavior when it encounters an invalid control character in a string. The default setting of ``True`` means that unescaped control characters are parse errors, if ``False`` then control characters will be allowed in strings. """ if encoding is None: encoding = DEFAULT_ENCODING self.encoding = encoding self.object_hook = object_hook self.object_pairs_hook = object_pairs_hook self.parse_float = parse_float or float self.parse_int = parse_int or int self.parse_constant = parse_constant or _CONSTANTS.__getitem__ self.strict = strict self.parse_object = JSONObject self.parse_array = JSONArray self.parse_string = scanstring self.memo = {} self.scan_once = make_scanner(self)
[ "def", "__init__", "(", "self", ",", "encoding", "=", "None", ",", "object_hook", "=", "None", ",", "parse_float", "=", "None", ",", "parse_int", "=", "None", ",", "parse_constant", "=", "None", ",", "strict", "=", "True", ",", "object_pairs_hook", "=", ...
https://github.com/deepgully/me/blob/f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0/libs/simplejson/decoder.py#L302-L361
RenYurui/StructureFlow
1ac8f559475452e6b674699671c6b34f000d9ebd
src/network.py
python
Get_image.forward
(self, x)
return self.conv(x)
[]
def forward(self, x): return self.conv(x)
[ "def", "forward", "(", "self", ",", "x", ")", ":", "return", "self", ".", "conv", "(", "x", ")" ]
https://github.com/RenYurui/StructureFlow/blob/1ac8f559475452e6b674699671c6b34f000d9ebd/src/network.py#L234-L235
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/pi_hole/__init__.py
python
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
return unload_ok
Unload Pi-hole entry.
Unload Pi-hole entry.
[ "Unload", "Pi", "-", "hole", "entry", "." ]
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload Pi-hole entry.""" unload_ok = await hass.config_entries.async_unload_platforms( entry, _async_platforms(entry) ) if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "entry", ",", "_async_platforms", "("...
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/pi_hole/__init__.py#L143-L150
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/agw/knobctrl.py
python
KnobCtrlEvent.SetValue
(self, value)
Sets the new :class:`KnobCtrl` value for this event. :param `value`: an integer representing the new value.
Sets the new :class:`KnobCtrl` value for this event.
[ "Sets", "the", "new", ":", "class", ":", "KnobCtrl", "value", "for", "this", "event", "." ]
def SetValue(self, value): """ Sets the new :class:`KnobCtrl` value for this event. :param `value`: an integer representing the new value. """ self._value = value
[ "def", "SetValue", "(", "self", ",", "value", ")", ":", "self", ".", "_value", "=", "value" ]
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/knobctrl.py#L200-L207
nooperpudd/chinastock
bad839f1177bba21cacbf448ef20391702dbcf01
httpGet.py
python
httpGetContent
(url, headers=None, charset=None)
httplib2处理请求
httplib2处理请求
[ "httplib2处理请求" ]
def httpGetContent(url, headers=None, charset=None): "httplib2处理请求" try: http = httplib2.Http() request, content = http.request(uri=url, headers=headers) if request.status == 200 and content: if charset: return content.decode(charset).encode('utf8') else: return content except Exception as e: raise e
[ "def", "httpGetContent", "(", "url", ",", "headers", "=", "None", ",", "charset", "=", "None", ")", ":", "try", ":", "http", "=", "httplib2", ".", "Http", "(", ")", "request", ",", "content", "=", "http", ".", "request", "(", "uri", "=", "url", ","...
https://github.com/nooperpudd/chinastock/blob/bad839f1177bba21cacbf448ef20391702dbcf01/httpGet.py#L12-L23
geometalab/Vector-Tiles-Reader-QGIS-Plugin
a31ae86959c8f3b7d6f332f84191cd7ca4683e1d
ext-libs/shapely/geos.py
python
WKBWriter.__setattr__
(self, name, value)
Limit setting attributes
Limit setting attributes
[ "Limit", "setting", "attributes" ]
def __setattr__(self, name, value): """Limit setting attributes""" if hasattr(self, name): object.__setattr__(self, name, value) else: raise AttributeError('%r object has no attribute %r' % (self.__class__.__name__, name))
[ "def", "__setattr__", "(", "self", ",", "name", ",", "value", ")", ":", "if", "hasattr", "(", "self", ",", "name", ")", ":", "object", ".", "__setattr__", "(", "self", ",", "name", ",", "value", ")", "else", ":", "raise", "AttributeError", "(", "'%r ...
https://github.com/geometalab/Vector-Tiles-Reader-QGIS-Plugin/blob/a31ae86959c8f3b7d6f332f84191cd7ca4683e1d/ext-libs/shapely/geos.py#L468-L474
vadmium/python-altium
9e3cf5a16150e74ba2b7e6d1f2895e0ce16b9a05
vector/svg.py
python
Renderer.hline
(self, a, b=None, *, width=None, offset=None, colour=None)
[]
def hline(self, a, b=None, *, width=None, offset=None, colour=None): a = format(a) if b is None: attrs = {"x2": a} else: attrs = {"x1": a, "x2": format(b)} self._line(attrs, width=width, offset=offset, colour=colour)
[ "def", "hline", "(", "self", ",", "a", ",", "b", "=", "None", ",", "*", ",", "width", "=", "None", ",", "offset", "=", "None", ",", "colour", "=", "None", ")", ":", "a", "=", "format", "(", "a", ")", "if", "b", "is", "None", ":", "attrs", "...
https://github.com/vadmium/python-altium/blob/9e3cf5a16150e74ba2b7e6d1f2895e0ce16b9a05/vector/svg.py#L101-L108
pavelliavonau/cmakeconverter
ef7afd3c7d8046a25754d679b5b7b97706b7eee4
cmake_converter/visual_studio/vcxproj/flags.py
python
CPPFlags.__set_calling_convention
(context, flag_name, node)
return flag_values
Set CallingConvention flag: /G**
Set CallingConvention flag: /G**
[ "Set", "CallingConvention", "flag", ":", "/", "G", "**" ]
def __set_calling_convention(context, flag_name, node): """ Set CallingConvention flag: /G** """ del context, flag_name, node flag_values = { 'Cdecl': {cl_flags: '/Gd'}, 'FastCall': {cl_flags: '/Gr'}, 'StdCall': {cl_flags: '/Gz'}, 'VectorCall': {cl_flags: '/Gv'}, default_value: {} } return flag_values
[ "def", "__set_calling_convention", "(", "context", ",", "flag_name", ",", "node", ")", ":", "del", "context", ",", "flag_name", ",", "node", "flag_values", "=", "{", "'Cdecl'", ":", "{", "cl_flags", ":", "'/Gd'", "}", ",", "'FastCall'", ":", "{", "cl_flags...
https://github.com/pavelliavonau/cmakeconverter/blob/ef7afd3c7d8046a25754d679b5b7b97706b7eee4/cmake_converter/visual_studio/vcxproj/flags.py#L700-L714
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/http/cookies.py
python
BaseCookie.output
(self, attrs=None, header="Set-Cookie:", sep="\015\012")
return sep.join(result)
Return a string suitable for HTTP.
Return a string suitable for HTTP.
[ "Return", "a", "string", "suitable", "for", "HTTP", "." ]
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"): """Return a string suitable for HTTP.""" result = [] items = sorted(self.items()) for key, value in items: result.append(value.output(attrs, header)) return sep.join(result)
[ "def", "output", "(", "self", ",", "attrs", "=", "None", ",", "header", "=", "\"Set-Cookie:\"", ",", "sep", "=", "\"\\015\\012\"", ")", ":", "result", "=", "[", "]", "items", "=", "sorted", "(", "self", ".", "items", "(", ")", ")", "for", "key", ",...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/http/cookies.py#L497-L503
hak5/nano-tetra-modules
aa43cb5e2338b8dbd12a75314104a34ba608263b
PortalAuth/includes/scripts/libs/email/header.py
python
Header.encode
(self, splitchars=';, ')
return value
Encode a message header into an RFC-compliant format. There are many issues involved in converting a given string for use in an email header. Only certain character sets are readable in most email clients, and as header strings can only contain a subset of 7-bit ASCII, care must be taken to properly convert and encode (with Base64 or quoted-printable) header strings. In addition, there is a 75-character length limit on any given encoded header field, so line-wrapping must be performed, even with double-byte character sets. This method will do its best to convert the string to the correct character set used in email, and encode and line wrap it safely with the appropriate scheme for that character set. If the given charset is not known or an error occurs during conversion, this function will return the header untouched. Optional splitchars is a string containing characters to split long ASCII lines on, in rough support of RFC 2822's `highest level syntactic breaks'. This doesn't affect RFC 2047 encoded lines.
Encode a message header into an RFC-compliant format.
[ "Encode", "a", "message", "header", "into", "an", "RFC", "-", "compliant", "format", "." ]
def encode(self, splitchars=';, '): """Encode a message header into an RFC-compliant format. There are many issues involved in converting a given string for use in an email header. Only certain character sets are readable in most email clients, and as header strings can only contain a subset of 7-bit ASCII, care must be taken to properly convert and encode (with Base64 or quoted-printable) header strings. In addition, there is a 75-character length limit on any given encoded header field, so line-wrapping must be performed, even with double-byte character sets. This method will do its best to convert the string to the correct character set used in email, and encode and line wrap it safely with the appropriate scheme for that character set. If the given charset is not known or an error occurs during conversion, this function will return the header untouched. Optional splitchars is a string containing characters to split long ASCII lines on, in rough support of RFC 2822's `highest level syntactic breaks'. This doesn't affect RFC 2047 encoded lines. """ newchunks = [] maxlinelen = self._firstlinelen lastlen = 0 for s, charset in self._chunks: # The first bit of the next chunk should be just long enough to # fill the next line. Don't forget the space separating the # encoded words. targetlen = maxlinelen - lastlen - 1 if targetlen < charset.encoded_header_len(''): # Stick it on the next line targetlen = maxlinelen newchunks += self._split(s, charset, targetlen, splitchars) lastchunk, lastcharset = newchunks[-1] lastlen = lastcharset.encoded_header_len(lastchunk) value = self._encode_chunks(newchunks, maxlinelen) if _embeded_header.search(value): raise HeaderParseError("header value appears to contain " "an embedded header: {!r}".format(value)) return value
[ "def", "encode", "(", "self", ",", "splitchars", "=", "';, '", ")", ":", "newchunks", "=", "[", "]", "maxlinelen", "=", "self", ".", "_firstlinelen", "lastlen", "=", "0", "for", "s", ",", "charset", "in", "self", ".", "_chunks", ":", "# The first bit of ...
https://github.com/hak5/nano-tetra-modules/blob/aa43cb5e2338b8dbd12a75314104a34ba608263b/PortalAuth/includes/scripts/libs/email/header.py#L374-L414
LuxCoreRender/BlendLuxCore
bf31ca58501d54c02acd97001b6db7de81da7cbf
ui/lol/panel.py
python
VIEW3D_PT_LUXCORE_ONLINE_LIBRARY_SCAN_RESULT.draw_addlist
(self, layout, asset, idx)
[]
def draw_addlist(self, layout, asset, idx): col = layout.column(align=True) # Upper row (enable/disable, name, remove) box = col.box() row = box.row() col = row.column() col.prop(asset, "show_settings", icon=settings_toggle_icon(asset.show_settings), icon_only=True, emboss=False) col = row.column() col.prop(asset, "name", text="") # op = row.operator("scene.luxcore_ol_remove_asset", # text="", icon=icons.CLEAR, emboss=False) # op.index = idx if asset.show_settings: col = box.column(align=True) col.prop(asset, "category") col = box.column(align=True) col.label(text="Thumbnail:") col.prop(asset, "show_thumbnail", icon=icons.IMAGE) if asset.show_thumbnail: col.template_ID_preview(asset, "thumbnail", open="image.open") else: col.template_ID(asset, "thumbnail", open="image.open") col = box.column(align=True) col.enabled = (asset.thumbnail is not None) op = col.operator("scene.luxcore_ol_add_local", text="Add asset...") op.asset_index = idx
[ "def", "draw_addlist", "(", "self", ",", "layout", ",", "asset", ",", "idx", ")", ":", "col", "=", "layout", ".", "column", "(", "align", "=", "True", ")", "# Upper row (enable/disable, name, remove)", "box", "=", "col", ".", "box", "(", ")", "row", "=",...
https://github.com/LuxCoreRender/BlendLuxCore/blob/bf31ca58501d54c02acd97001b6db7de81da7cbf/ui/lol/panel.py#L352-L384
jayleicn/scipy-lecture-notes-zh-CN
cc87204fcc4bd2f4702f7c29c83cb8ed5c94b7d6
packages/traits/reservoir_state_property_view.py
python
ReservoirState._get_spillage
(self)
return max(overflow, 0)
[]
def _get_spillage(self): new_storage = self._storage - self.release + self.inflows overflow = new_storage - self.max_storage return max(overflow, 0)
[ "def", "_get_spillage", "(", "self", ")", ":", "new_storage", "=", "self", ".", "_storage", "-", "self", ".", "release", "+", "self", ".", "inflows", "overflow", "=", "new_storage", "-", "self", ".", "max_storage", "return", "max", "(", "overflow", ",", ...
https://github.com/jayleicn/scipy-lecture-notes-zh-CN/blob/cc87204fcc4bd2f4702f7c29c83cb8ed5c94b7d6/packages/traits/reservoir_state_property_view.py#L49-L52
python-telegram-bot/python-telegram-bot
ade1529986f5b6d394a65372d6a27045a70725b2
telegram/user.py
python
User.copy_message
( self, chat_id: Union[int, str], message_id: int, caption: str = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Union[Tuple['MessageEntity', ...], List['MessageEntity']] = None, disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: int = None, allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: 'ReplyMarkup' = None, timeout: ODVInput[float] = DEFAULT_NONE, api_kwargs: JSONDict = None, protect_content: bool = None, )
return self.bot.copy_message( from_chat_id=self.id, chat_id=chat_id, message_id=message_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, timeout=timeout, api_kwargs=api_kwargs, protect_content=protect_content, )
Shortcut for:: bot.copy_message(from_chat_id=update.effective_user.id, *args, **kwargs) For the documentation of the arguments, please see :meth:`telegram.Bot.copy_message`. Returns: :class:`telegram.Message`: On success, instance representing the message posted.
Shortcut for::
[ "Shortcut", "for", "::" ]
def copy_message( self, chat_id: Union[int, str], message_id: int, caption: str = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Union[Tuple['MessageEntity', ...], List['MessageEntity']] = None, disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: int = None, allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: 'ReplyMarkup' = None, timeout: ODVInput[float] = DEFAULT_NONE, api_kwargs: JSONDict = None, protect_content: bool = None, ) -> 'MessageId': """Shortcut for:: bot.copy_message(from_chat_id=update.effective_user.id, *args, **kwargs) For the documentation of the arguments, please see :meth:`telegram.Bot.copy_message`. Returns: :class:`telegram.Message`: On success, instance representing the message posted. """ return self.bot.copy_message( from_chat_id=self.id, chat_id=chat_id, message_id=message_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, timeout=timeout, api_kwargs=api_kwargs, protect_content=protect_content, )
[ "def", "copy_message", "(", "self", ",", "chat_id", ":", "Union", "[", "int", ",", "str", "]", ",", "message_id", ":", "int", ",", "caption", ":", "str", "=", "None", ",", "parse_mode", ":", "ODVInput", "[", "str", "]", "=", "DEFAULT_NONE", ",", "cap...
https://github.com/python-telegram-bot/python-telegram-bot/blob/ade1529986f5b6d394a65372d6a27045a70725b2/telegram/user.py#L1158-L1197
conansherry/detectron2
72c935d9aad8935406b1038af408aa06077d950a
detectron2/engine/hooks.py
python
PeriodicWriter.__init__
(self, writers, period=20)
Args: writers (list[EventWriter]): a list of EventWriter objects period (int):
Args: writers (list[EventWriter]): a list of EventWriter objects period (int):
[ "Args", ":", "writers", "(", "list", "[", "EventWriter", "]", ")", ":", "a", "list", "of", "EventWriter", "objects", "period", "(", "int", ")", ":" ]
def __init__(self, writers, period=20): """ Args: writers (list[EventWriter]): a list of EventWriter objects period (int): """ self._writers = writers for w in writers: assert isinstance(w, EventWriter), w self._period = period
[ "def", "__init__", "(", "self", ",", "writers", ",", "period", "=", "20", ")", ":", "self", ".", "_writers", "=", "writers", "for", "w", "in", "writers", ":", "assert", "isinstance", "(", "w", ",", "EventWriter", ")", ",", "w", "self", ".", "_period"...
https://github.com/conansherry/detectron2/blob/72c935d9aad8935406b1038af408aa06077d950a/detectron2/engine/hooks.py#L150-L159
datastax/python-driver
5fdb0061f56f53b9d8d8ad67b99110899653ad77
cassandra/cqlengine/management.py
python
_get_index_name_by_column
(table, column_name)
Find the index name for a given table and column.
Find the index name for a given table and column.
[ "Find", "the", "index", "name", "for", "a", "given", "table", "and", "column", "." ]
def _get_index_name_by_column(table, column_name): """ Find the index name for a given table and column. """ protected_name = metadata.protect_name(column_name) possible_index_values = [protected_name, "values(%s)" % protected_name] for index_metadata in table.indexes.values(): options = dict(index_metadata.index_options) if options.get('target') in possible_index_values: return index_metadata.name
[ "def", "_get_index_name_by_column", "(", "table", ",", "column_name", ")", ":", "protected_name", "=", "metadata", ".", "protect_name", "(", "column_name", ")", "possible_index_values", "=", "[", "protected_name", ",", "\"values(%s)\"", "%", "protected_name", "]", "...
https://github.com/datastax/python-driver/blob/5fdb0061f56f53b9d8d8ad67b99110899653ad77/cassandra/cqlengine/management.py#L152-L161
osmr/imgclsmob
f2993d3ce73a2f7ddba05da3891defb08547d504
tensorflow2/tf2cv/models/mobilenet_cub.py
python
fdmobilenet_w1_cub
(classes=200, **kwargs)
return get_fdmobilenet(classes=classes, width_scale=1.0, model_name="fdmobilenet_w1_cub", **kwargs)
FD-MobileNet 1.0x model for CUB-200-2011 from 'FD-MobileNet: Improved MobileNet with A Fast Downsampling Strategy,' https://arxiv.org/abs/1802.03750. Parameters: ---------- classes : int, default 200 Number of classification classes. pretrained : bool, default False Whether to load the pretrained weights for model. root : str, default '~/.tensorflow/models' Location for keeping the model parameters.
FD-MobileNet 1.0x model for CUB-200-2011 from 'FD-MobileNet: Improved MobileNet with A Fast Downsampling Strategy,' https://arxiv.org/abs/1802.03750.
[ "FD", "-", "MobileNet", "1", ".", "0x", "model", "for", "CUB", "-", "200", "-", "2011", "from", "FD", "-", "MobileNet", ":", "Improved", "MobileNet", "with", "A", "Fast", "Downsampling", "Strategy", "https", ":", "//", "arxiv", ".", "org", "/", "abs", ...
def fdmobilenet_w1_cub(classes=200, **kwargs): """ FD-MobileNet 1.0x model for CUB-200-2011 from 'FD-MobileNet: Improved MobileNet with A Fast Downsampling Strategy,' https://arxiv.org/abs/1802.03750. Parameters: ---------- classes : int, default 200 Number of classification classes. pretrained : bool, default False Whether to load the pretrained weights for model. root : str, default '~/.tensorflow/models' Location for keeping the model parameters. """ return get_fdmobilenet(classes=classes, width_scale=1.0, model_name="fdmobilenet_w1_cub", **kwargs)
[ "def", "fdmobilenet_w1_cub", "(", "classes", "=", "200", ",", "*", "*", "kwargs", ")", ":", "return", "get_fdmobilenet", "(", "classes", "=", "classes", ",", "width_scale", "=", "1.0", ",", "model_name", "=", "\"fdmobilenet_w1_cub\"", ",", "*", "*", "kwargs"...
https://github.com/osmr/imgclsmob/blob/f2993d3ce73a2f7ddba05da3891defb08547d504/tensorflow2/tf2cv/models/mobilenet_cub.py#L85-L99
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Lib/mailbox.py
python
Maildir.add
(self, message)
return uniq
Add message and return assigned key.
Add message and return assigned key.
[ "Add", "message", "and", "return", "assigned", "key", "." ]
def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) except BaseException: tmp_file.close() os.remove(tmp_file.name) raise _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' else: subdir = 'new' suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) if isinstance(message, MaildirMessage): os.utime(tmp_file.name, (os.path.getatime(tmp_file.name), message.get_date())) # No file modification should be done after the file is moved to its # final position in order to prevent race conditions with changes # from other programs try: if hasattr(os, 'link'): os.link(tmp_file.name, dest) os.remove(tmp_file.name) else: os.rename(tmp_file.name, dest) except OSError, e: os.remove(tmp_file.name) if e.errno == errno.EEXIST: raise ExternalClashError('Name clash with existing message: %s' % dest) else: raise return uniq
[ "def", "add", "(", "self", ",", "message", ")", ":", "tmp_file", "=", "self", ".", "_create_tmp", "(", ")", "try", ":", "self", ".", "_dump_message", "(", "message", ",", "tmp_file", ")", "except", "BaseException", ":", "tmp_file", ".", "close", "(", "...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/mailbox.py#L267-L306
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/scf/v20180416/scf_client.py
python
ScfClient.UpdateNamespace
(self, request)
更新命名空间 :param request: Request instance for UpdateNamespace. :type request: :class:`tencentcloud.scf.v20180416.models.UpdateNamespaceRequest` :rtype: :class:`tencentcloud.scf.v20180416.models.UpdateNamespaceResponse`
更新命名空间
[ "更新命名空间" ]
def UpdateNamespace(self, request): """更新命名空间 :param request: Request instance for UpdateNamespace. :type request: :class:`tencentcloud.scf.v20180416.models.UpdateNamespaceRequest` :rtype: :class:`tencentcloud.scf.v20180416.models.UpdateNamespaceResponse` """ try: params = request._serialize() body = self.call("UpdateNamespace", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.UpdateNamespaceResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "UpdateNamespace", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"UpdateNamespace\"", ",", "params", ")", "response", "=", "json", ".", "loads", ...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/scf/v20180416/scf_client.py#L1240-L1265
holoviz/datashader
25578abde75c7fa28c6633b33cb8d8a1e433da67
datashader/utils.py
python
compute_coords
(width, height, x_range, y_range, res)
return xs, ys
Computes DataArray coordinates at bin centers Parameters ---------- width : int Number of coordinates along the x-axis height : int Number of coordinates along the y-axis x_range : tuple Left and right edge of the coordinates y_range : tuple Bottom and top edges of the coordinates res : tuple Two-tuple (int, int) which includes x and y resolutions (aka "grid/cell sizes"), respectively. Used to determine coordinate orientation. Returns ------- xs : numpy.ndarray 1D array of x-coordinates ys : numpy.ndarray 1D array of y-coordinates
Computes DataArray coordinates at bin centers
[ "Computes", "DataArray", "coordinates", "at", "bin", "centers" ]
def compute_coords(width, height, x_range, y_range, res): """ Computes DataArray coordinates at bin centers Parameters ---------- width : int Number of coordinates along the x-axis height : int Number of coordinates along the y-axis x_range : tuple Left and right edge of the coordinates y_range : tuple Bottom and top edges of the coordinates res : tuple Two-tuple (int, int) which includes x and y resolutions (aka "grid/cell sizes"), respectively. Used to determine coordinate orientation. Returns ------- xs : numpy.ndarray 1D array of x-coordinates ys : numpy.ndarray 1D array of y-coordinates """ (x0, x1), (y0, y1) = x_range, y_range xd = (x1-x0)/float(width) yd = (y1-y0)/float(height) xpad, ypad = abs(xd/2.), abs(yd/2.) x0, x1 = x0+xpad, x1-xpad y0, y1 = y0+ypad, y1-ypad xs = np.linspace(x0, x1, width) ys = np.linspace(y0, y1, height) if res[0] < 0: xs = xs[::-1] if res[1] > 0: ys = ys[::-1] return xs, ys
[ "def", "compute_coords", "(", "width", ",", "height", ",", "x_range", ",", "y_range", ",", "res", ")", ":", "(", "x0", ",", "x1", ")", ",", "(", "y0", ",", "y1", ")", "=", "x_range", ",", "y_range", "xd", "=", "(", "x1", "-", "x0", ")", "/", ...
https://github.com/holoviz/datashader/blob/25578abde75c7fa28c6633b33cb8d8a1e433da67/datashader/utils.py#L289-L324
rytilahti/python-miio
b6e53dd16fac77915426e7592e2528b78ef65190
miio/toiletlid.py
python
Toiletlid.get_all_user_info
(self)
return users
Get All bind user.
Get All bind user.
[ "Get", "All", "bind", "user", "." ]
def get_all_user_info(self) -> List[Dict]: """Get All bind user.""" users = self.send("get_all_user_info") return users
[ "def", "get_all_user_info", "(", "self", ")", "->", "List", "[", "Dict", "]", ":", "users", "=", "self", ".", "send", "(", "\"get_all_user_info\"", ")", "return", "users" ]
https://github.com/rytilahti/python-miio/blob/b6e53dd16fac77915426e7592e2528b78ef65190/miio/toiletlid.py#L131-L134
numba/numba
bf480b9e0da858a65508c2b17759a72ee6a44c51
numba/cuda/cudadrv/driver.py
python
_pin_finalizer
(memory_manager, ptr, alloc_key, mapped)
return core
Finalize temporary page-locking of host memory by `context.mempin`. This applies to memory not otherwise managed by CUDA. Page-locking can be requested multiple times on the same memory, and must therefore be lifted as soon as finalization is requested, otherwise subsequent calls to `mempin` may fail with `CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED`, leading to unexpected behavior for the context managers `cuda.{pinned,mapped}`. This function therefore carries out finalization immediately, bypassing the `context.deallocations` queue.
Finalize temporary page-locking of host memory by `context.mempin`.
[ "Finalize", "temporary", "page", "-", "locking", "of", "host", "memory", "by", "context", ".", "mempin", "." ]
def _pin_finalizer(memory_manager, ptr, alloc_key, mapped): """ Finalize temporary page-locking of host memory by `context.mempin`. This applies to memory not otherwise managed by CUDA. Page-locking can be requested multiple times on the same memory, and must therefore be lifted as soon as finalization is requested, otherwise subsequent calls to `mempin` may fail with `CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED`, leading to unexpected behavior for the context managers `cuda.{pinned,mapped}`. This function therefore carries out finalization immediately, bypassing the `context.deallocations` queue. """ allocations = memory_manager.allocations def core(): if mapped and allocations: del allocations[alloc_key] driver.cuMemHostUnregister(ptr) return core
[ "def", "_pin_finalizer", "(", "memory_manager", ",", "ptr", ",", "alloc_key", ",", "mapped", ")", ":", "allocations", "=", "memory_manager", ".", "allocations", "def", "core", "(", ")", ":", "if", "mapped", "and", "allocations", ":", "del", "allocations", "[...
https://github.com/numba/numba/blob/bf480b9e0da858a65508c2b17759a72ee6a44c51/numba/cuda/cudadrv/driver.py#L1625-L1645
airbnb/streamalert
26cf1d08432ca285fd4f7410511a6198ca104bbb
streamalert/classifier/payload/payload_base.py
python
PayloadRecord.__bool__
(self)
return self._parser is not None
Valid if there is a parser, and the parser itself is valid ParserBase implements __nonzero__ as well, so return the result of it
Valid if there is a parser, and the parser itself is valid
[ "Valid", "if", "there", "is", "a", "parser", "and", "the", "parser", "itself", "is", "valid" ]
def __bool__(self): """Valid if there is a parser, and the parser itself is valid ParserBase implements __nonzero__ as well, so return the result of it """ return self._parser is not None
[ "def", "__bool__", "(", "self", ")", ":", "return", "self", ".", "_parser", "is", "not", "None" ]
https://github.com/airbnb/streamalert/blob/26cf1d08432ca285fd4f7410511a6198ca104bbb/streamalert/classifier/payload/payload_base.py#L47-L52
bashtage/linearmodels
9256269f01ff8c5f85e65342d66149a5636661b6
linearmodels/iv/model.py
python
_IVModelBase.predict
( self, params: ArrayLike, *, exog: Optional[IVDataLike] = None, endog: Optional[IVDataLike] = None, data: DataFrame = None, eval_env: int = 4, )
return pred
Predict values for additional data Parameters ---------- params : array_like Model parameters (nvar by 1) exog : array_like Exogenous regressors (nobs by nexog) endog : array_like Endogenous regressors (nobs by nendog) data : DataFrame Values to use when making predictions from a model constructed from a formula eval_env : int Depth of use when evaluating formulas. Returns ------- DataFrame Fitted values from supplied data and parameters Notes ----- The number of parameters must satisfy nvar = nexog + nendog. When using `exog` and `endog`, regressor matrix is constructed as `[exog, endog]` and so parameters must be aligned to this structure. The the the same structure used in model estimation. If `data` is not none, then `exog` and `endog` must be none. Predictions from models constructed using formulas can be computed using either `exog` and `endog`, which will treat these are arrays of values corresponding to the formula-processed data, or using `data` which will be processed using the formula used to construct the values corresponding to the original model specification.
Predict values for additional data
[ "Predict", "values", "for", "additional", "data" ]
def predict( self, params: ArrayLike, *, exog: Optional[IVDataLike] = None, endog: Optional[IVDataLike] = None, data: DataFrame = None, eval_env: int = 4, ) -> DataFrame: """ Predict values for additional data Parameters ---------- params : array_like Model parameters (nvar by 1) exog : array_like Exogenous regressors (nobs by nexog) endog : array_like Endogenous regressors (nobs by nendog) data : DataFrame Values to use when making predictions from a model constructed from a formula eval_env : int Depth of use when evaluating formulas. Returns ------- DataFrame Fitted values from supplied data and parameters Notes ----- The number of parameters must satisfy nvar = nexog + nendog. When using `exog` and `endog`, regressor matrix is constructed as `[exog, endog]` and so parameters must be aligned to this structure. The the the same structure used in model estimation. If `data` is not none, then `exog` and `endog` must be none. Predictions from models constructed using formulas can be computed using either `exog` and `endog`, which will treat these are arrays of values corresponding to the formula-processed data, or using `data` which will be processed using the formula used to construct the values corresponding to the original model specification. """ if data is not None and self.formula is None: raise ValueError( "Unable to use data when the model was not " "created using a formula." ) if data is not None and (exog is not None or endog is not None): raise ValueError( "Predictions can only be constructed using one " "of exog/endog or data, but not both." ) if exog is not None or endog is not None: exog = IVData(exog).pandas endog = IVData(endog).pandas elif data is not None: parser = IVFormulaParser(self.formula, data, eval_env=eval_env) exog = parser.exog endog = parser.endog exog_endog = concat([exog, endog], axis=1) x = asarray(exog_endog) params = atleast_2d(asarray(params)) if params.shape[0] == 1: params = params.T pred = DataFrame(x @ params, index=exog_endog.index, columns=["predictions"]) return pred
[ "def", "predict", "(", "self", ",", "params", ":", "ArrayLike", ",", "*", ",", "exog", ":", "Optional", "[", "IVDataLike", "]", "=", "None", ",", "endog", ":", "Optional", "[", "IVDataLike", "]", "=", "None", ",", "data", ":", "DataFrame", "=", "None...
https://github.com/bashtage/linearmodels/blob/9256269f01ff8c5f85e65342d66149a5636661b6/linearmodels/iv/model.py#L237-L306
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
ext/requests/utils.py
python
add_dict_to_cookiejar
(cj, cookie_dict)
return cookiejar_from_dict(cookie_dict, cj)
Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. :rtype: CookieJar
Returns a CookieJar from a key/value dictionary.
[ "Returns", "a", "CookieJar", "from", "a", "key", "/", "value", "dictionary", "." ]
def add_dict_to_cookiejar(cj, cookie_dict): """Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. :rtype: CookieJar """ return cookiejar_from_dict(cookie_dict, cj)
[ "def", "add_dict_to_cookiejar", "(", "cj", ",", "cookie_dict", ")", ":", "return", "cookiejar_from_dict", "(", "cookie_dict", ",", "cj", ")" ]
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/requests/utils.py#L430-L438
nilmtk/nilmtk
d183c8bde7a5d3465ba72b38b7964d57d84f53c2
nilmtk/elecmeter.py
python
ElecMeter.total_energy
(self, **loader_kwargs)
return self._get_stat_from_cache_or_compute( nodes, TotalEnergy.results_class(), loader_kwargs)
Parameters ---------- full_results : bool, default=False **loader_kwargs : key word arguments for DataStore.load() Returns ------- if `full_results` is True then return TotalEnergyResults object else returns a pd.Series with a row for each AC type.
Parameters ---------- full_results : bool, default=False **loader_kwargs : key word arguments for DataStore.load()
[ "Parameters", "----------", "full_results", ":", "bool", "default", "=", "False", "**", "loader_kwargs", ":", "key", "word", "arguments", "for", "DataStore", ".", "load", "()" ]
def total_energy(self, **loader_kwargs): """ Parameters ---------- full_results : bool, default=False **loader_kwargs : key word arguments for DataStore.load() Returns ------- if `full_results` is True then return TotalEnergyResults object else returns a pd.Series with a row for each AC type. """ nodes = [Clip, TotalEnergy] return self._get_stat_from_cache_or_compute( nodes, TotalEnergy.results_class(), loader_kwargs)
[ "def", "total_energy", "(", "self", ",", "*", "*", "loader_kwargs", ")", ":", "nodes", "=", "[", "Clip", ",", "TotalEnergy", "]", "return", "self", ".", "_get_stat_from_cache_or_compute", "(", "nodes", ",", "TotalEnergy", ".", "results_class", "(", ")", ",",...
https://github.com/nilmtk/nilmtk/blob/d183c8bde7a5d3465ba72b38b7964d57d84f53c2/nilmtk/elecmeter.py#L581-L595
linxid/Machine_Learning_Study_Path
558e82d13237114bbb8152483977806fc0c222af
Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/encodings/iso8859_13.py
python
IncrementalDecoder.decode
(self, input, final=False)
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
[]
def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_table)[0]
[ "def", "decode", "(", "self", ",", "input", ",", "final", "=", "False", ")", ":", "return", "codecs", ".", "charmap_decode", "(", "input", ",", "self", ".", "errors", ",", "decoding_table", ")", "[", "0", "]" ]
https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/encodings/iso8859_13.py#L22-L23
readthedocs/sphinx-autoapi
71c6ceebe0b02c34027fcd3d56c8641e9b94c7af
autoapi/mappers/python/objects.py
python
PythonClass.docstring
(self)
return docstring
[]
def docstring(self): docstring = super().docstring if not self._docstring_resolved and self._class_content in ("both", "init"): constructor_docstring = self.constructor_docstring if constructor_docstring: if self._class_content == "both": docstring = "{0}\n{1}".format(docstring, constructor_docstring) else: docstring = constructor_docstring return docstring
[ "def", "docstring", "(", "self", ")", ":", "docstring", "=", "super", "(", ")", ".", "docstring", "if", "not", "self", ".", "_docstring_resolved", "and", "self", ".", "_class_content", "in", "(", "\"both\"", ",", "\"init\"", ")", ":", "constructor_docstring"...
https://github.com/readthedocs/sphinx-autoapi/blob/71c6ceebe0b02c34027fcd3d56c8641e9b94c7af/autoapi/mappers/python/objects.py#L390-L402
openai/baselines
ea25b9e8b234e6ee1bca43083f8f3cf974143998
baselines/deepq/replay_buffer.py
python
ReplayBuffer.sample
(self, batch_size)
return self._encode_sample(idxes)
Sample a batch of experiences. Parameters ---------- batch_size: int How many transitions to sample. Returns ------- obs_batch: np.array batch of observations act_batch: np.array batch of actions executed given obs_batch rew_batch: np.array rewards received as results of executing act_batch next_obs_batch: np.array next set of observations seen after executing act_batch done_mask: np.array done_mask[i] = 1 if executing act_batch[i] resulted in the end of an episode and 0 otherwise.
Sample a batch of experiences.
[ "Sample", "a", "batch", "of", "experiences", "." ]
def sample(self, batch_size): """Sample a batch of experiences. Parameters ---------- batch_size: int How many transitions to sample. Returns ------- obs_batch: np.array batch of observations act_batch: np.array batch of actions executed given obs_batch rew_batch: np.array rewards received as results of executing act_batch next_obs_batch: np.array next set of observations seen after executing act_batch done_mask: np.array done_mask[i] = 1 if executing act_batch[i] resulted in the end of an episode and 0 otherwise. """ idxes = [random.randint(0, len(self._storage) - 1) for _ in range(batch_size)] return self._encode_sample(idxes)
[ "def", "sample", "(", "self", ",", "batch_size", ")", ":", "idxes", "=", "[", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "_storage", ")", "-", "1", ")", "for", "_", "in", "range", "(", "batch_size", ")", "]", "return", "sel...
https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/deepq/replay_buffer.py#L45-L68
quantOS-org/JAQS
959762a518c22592f96433c573d1f99ec0c89152
jaqs/trade/livetrade.py
python
EventLiveTradeInstance.run
(self)
Listen to certain events and run the EventEngine. Events include: 1. market_data are from DataService 2. trades & orders indications are from TradeApi. 3. etc.
Listen to certain events and run the EventEngine. Events include: 1. market_data are from DataService 2. trades & orders indications are from TradeApi. 3. etc.
[ "Listen", "to", "certain", "events", "and", "run", "the", "EventEngine", ".", "Events", "include", ":", "1", ".", "market_data", "are", "from", "DataService", "2", ".", "trades", "&", "orders", "indications", "are", "from", "TradeApi", ".", "3", ".", "etc"...
def run(self): """ Listen to certain events and run the EventEngine. Events include: 1. market_data are from DataService 2. trades & orders indications are from TradeApi. 3. etc. """ self.register(EVENT_TYPE.MARKET_DATA, self.on_bar) self.register(EVENT_TYPE.TASK_STATUS_IND, self.on_task_status) self.register(EVENT_TYPE.ORDER_RSP, self.on_order_rsp) self.register(EVENT_TYPE.TASK_RSP, self.on_task_rsp) self.register(EVENT_TYPE.TRADE_IND, self.on_trade) self.register(EVENT_TYPE.ORDER_STATUS_IND, self.on_order_status) self.start(timer=False)
[ "def", "run", "(", "self", ")", ":", "self", ".", "register", "(", "EVENT_TYPE", ".", "MARKET_DATA", ",", "self", ".", "on_bar", ")", "self", ".", "register", "(", "EVENT_TYPE", ".", "TASK_STATUS_IND", ",", "self", ".", "on_task_status", ")", "self", "."...
https://github.com/quantOS-org/JAQS/blob/959762a518c22592f96433c573d1f99ec0c89152/jaqs/trade/livetrade.py#L288-L306
ales-tsurko/cells
4cf7e395cd433762bea70cdc863a346f3a6fe1d0
packaging/macos/python/lib/python3.7/site-packages/pip/_vendor/requests/help.py
python
info
()
return { 'platform': platform_info, 'implementation': implementation_info, 'system_ssl': system_ssl_info, 'using_pyopenssl': pyopenssl is not None, 'pyOpenSSL': pyopenssl_info, 'urllib3': urllib3_info, 'chardet': chardet_info, 'cryptography': cryptography_info, 'idna': idna_info, 'requests': { 'version': requests_version, }, }
Generate information for a bug report.
Generate information for a bug report.
[ "Generate", "information", "for", "a", "bug", "report", "." ]
def info(): """Generate information for a bug report.""" try: platform_info = { 'system': platform.system(), 'release': platform.release(), } except IOError: platform_info = { 'system': 'Unknown', 'release': 'Unknown', } implementation_info = _implementation() urllib3_info = {'version': urllib3.__version__} chardet_info = {'version': chardet.__version__} pyopenssl_info = { 'version': None, 'openssl_version': '', } if OpenSSL: pyopenssl_info = { 'version': OpenSSL.__version__, 'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER, } cryptography_info = { 'version': getattr(cryptography, '__version__', ''), } idna_info = { 'version': getattr(idna, '__version__', ''), } system_ssl = ssl.OPENSSL_VERSION_NUMBER system_ssl_info = { 'version': '%x' % system_ssl if system_ssl is not None else '' } return { 'platform': platform_info, 'implementation': implementation_info, 'system_ssl': system_ssl_info, 'using_pyopenssl': pyopenssl is not None, 'pyOpenSSL': pyopenssl_info, 'urllib3': urllib3_info, 'chardet': chardet_info, 'cryptography': cryptography_info, 'idna': idna_info, 'requests': { 'version': requests_version, }, }
[ "def", "info", "(", ")", ":", "try", ":", "platform_info", "=", "{", "'system'", ":", "platform", ".", "system", "(", ")", ",", "'release'", ":", "platform", ".", "release", "(", ")", ",", "}", "except", "IOError", ":", "platform_info", "=", "{", "'s...
https://github.com/ales-tsurko/cells/blob/4cf7e395cd433762bea70cdc863a346f3a6fe1d0/packaging/macos/python/lib/python3.7/site-packages/pip/_vendor/requests/help.py#L59-L110
aws-samples/aws-kube-codesuite
ab4e5ce45416b83bffb947ab8d234df5437f4fca
src/kubernetes/client/models/v1_node_system_info.py
python
V1NodeSystemInfo.kernel_version
(self, kernel_version)
Sets the kernel_version of this V1NodeSystemInfo. Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64). :param kernel_version: The kernel_version of this V1NodeSystemInfo. :type: str
Sets the kernel_version of this V1NodeSystemInfo. Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).
[ "Sets", "the", "kernel_version", "of", "this", "V1NodeSystemInfo", ".", "Kernel", "Version", "reported", "by", "the", "node", "from", "uname", "-", "r", "(", "e", ".", "g", ".", "3", ".", "16", ".", "0", "-", "0", ".", "bpo", ".", "4", "-", "amd64"...
def kernel_version(self, kernel_version): """ Sets the kernel_version of this V1NodeSystemInfo. Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64). :param kernel_version: The kernel_version of this V1NodeSystemInfo. :type: str """ if kernel_version is None: raise ValueError("Invalid value for `kernel_version`, must not be `None`") self._kernel_version = kernel_version
[ "def", "kernel_version", "(", "self", ",", "kernel_version", ")", ":", "if", "kernel_version", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `kernel_version`, must not be `None`\"", ")", "self", ".", "_kernel_version", "=", "kernel_version" ]
https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/kubernetes/client/models/v1_node_system_info.py#L157-L168
PINTO0309/PINTO_model_zoo
2924acda7a7d541d8712efd7cc4fd1c61ef5bddd
119_M-LSD/demo/demo_mlsd-lines_tflite.py
python
main
()
[]
def main(): args = get_args() cap_device = args.device filepath = args.file model = args.model input_shape = [int(i) for i in args.input_shape.split(',')] score_thr = args.score_thr dist_thr = args.dist_thr # Initialize video capture cap = None if filepath is None: cap = cv.VideoCapture(cap_device) else: cap = cv.VideoCapture(filepath) # Load model interpreter = tf.lite.Interpreter(model_path=model, num_threads=2) interpreter.allocate_tensors() input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() while True: start_time = time.time() # Capture read ret, frame = cap.read() if not ret: break debug_image = copy.deepcopy(frame) # Inference execution lines = pred_lines( frame, interpreter, input_details, output_details, input_shape=input_shape, score_thr=score_thr, dist_thr=dist_thr, ) elapsed_time = time.time() - start_time # Draw debug_image = draw_debug( debug_image, elapsed_time, lines, ) cv.imshow('M-LSD(Lines) Demo', debug_image) key = cv.waitKey(1) if key == 27: # ESC break cap.release() cv.destroyAllWindows()
[ "def", "main", "(", ")", ":", "args", "=", "get_args", "(", ")", "cap_device", "=", "args", ".", "device", "filepath", "=", "args", ".", "file", "model", "=", "args", ".", "model", "input_shape", "=", "[", "int", "(", "i", ")", "for", "i", "in", ...
https://github.com/PINTO0309/PINTO_model_zoo/blob/2924acda7a7d541d8712efd7cc4fd1c61ef5bddd/119_M-LSD/demo/demo_mlsd-lines_tflite.py#L34-L93
apache/incubator-spot
2d60a2adae7608b43e90ce1b9ec0adf24f6cc8eb
spot-oa/api/resources/configurator.py
python
SecHead.__init__
(self, fp)
[]
def __init__(self, fp): self.fp = fp self.sechead = '[conf]\n'
[ "def", "__init__", "(", "self", ",", "fp", ")", ":", "self", ".", "fp", "=", "fp", "self", ".", "sechead", "=", "'[conf]\\n'" ]
https://github.com/apache/incubator-spot/blob/2d60a2adae7608b43e90ce1b9ec0adf24f6cc8eb/spot-oa/api/resources/configurator.py#L90-L92
lazylibrarian/LazyLibrarian
ae3c14e9db9328ce81765e094ab2a14ed7155624
cherrypy/lib/auth_digest.py
python
get_ha1_dict
(user_ha1_dict)
return get_ha1
Returns a get_ha1 function which obtains a HA1 password hash from a dictionary of the form: {username : HA1}. If you want a dictionary-based authentication scheme, but with pre-computed HA1 hashes instead of plain-text passwords, use get_ha1_dict(my_userha1_dict) as the value for the get_ha1 argument to digest_auth().
Returns a get_ha1 function which obtains a HA1 password hash from a dictionary of the form: {username : HA1}.
[ "Returns", "a", "get_ha1", "function", "which", "obtains", "a", "HA1", "password", "hash", "from", "a", "dictionary", "of", "the", "form", ":", "{", "username", ":", "HA1", "}", "." ]
def get_ha1_dict(user_ha1_dict): """Returns a get_ha1 function which obtains a HA1 password hash from a dictionary of the form: {username : HA1}. If you want a dictionary-based authentication scheme, but with pre-computed HA1 hashes instead of plain-text passwords, use get_ha1_dict(my_userha1_dict) as the value for the get_ha1 argument to digest_auth(). """ def get_ha1(realm, username): return user_ha1_dict.get(username) return get_ha1
[ "def", "get_ha1_dict", "(", "user_ha1_dict", ")", ":", "def", "get_ha1", "(", "realm", ",", "username", ")", ":", "return", "user_ha1_dict", ".", "get", "(", "username", ")", "return", "get_ha1" ]
https://github.com/lazylibrarian/LazyLibrarian/blob/ae3c14e9db9328ce81765e094ab2a14ed7155624/cherrypy/lib/auth_digest.py#L63-L75
salesforce/hassh
7e7658819d9722875316ca591d1a09f9fd21ed8c
python/hassh.py
python
server_hassh
(packet)
return record
returns HASSHServer (i.e. SSH Server Fingerprint) HASSHServer = md5(KEX;EASTC;MASTC;CASTC)
returns HASSHServer (i.e. SSH Server Fingerprint) HASSHServer = md5(KEX;EASTC;MASTC;CASTC)
[ "returns", "HASSHServer", "(", "i", ".", "e", ".", "SSH", "Server", "Fingerprint", ")", "HASSHServer", "=", "md5", "(", "KEX", ";", "EASTC", ";", "MASTC", ";", "CASTC", ")" ]
def server_hassh(packet): """returns HASSHServer (i.e. SSH Server Fingerprint) HASSHServer = md5(KEX;EASTC;MASTC;CASTC) """ srcip = packet.ip.src dstip = packet.ip.dst sport = packet.tcp.srcport dport = packet.tcp.srcport protocol = None key = '{}:{}_{}:{}'.format(srcip, sport, dstip, dport) if key in protocol_dict: protocol = protocol_dict[key] # hasshServer fields skex = seastc = smastc = scastc = "" if 'kex_algorithms' in packet.ssh.field_names: skex = packet.ssh.kex_algorithms if 'encryption_algorithms_server_to_client' in packet.ssh.field_names: seastc = packet.ssh.encryption_algorithms_server_to_client if 'mac_algorithms_server_to_client' in packet.ssh.field_names: smastc = packet.ssh.mac_algorithms_server_to_client if 'compression_algorithms_server_to_client' in packet.ssh.field_names: scastc = packet.ssh.compression_algorithms_server_to_client # Log other kexinit fields (only in JSON) slcts = slstc = seacts = smacts = scacts = sshka = "" if 'languages_client_to_server' in packet.ssh.field_names: slcts = packet.ssh.languages_client_to_server if 'languages_server_to_client' in packet.ssh.field_names: slstc = packet.ssh.languages_server_to_client if 'encryption_algorithms_client_to_server' in packet.ssh.field_names: seacts = packet.ssh.encryption_algorithms_client_to_server if 'mac_algorithms_client_to_server' in packet.ssh.field_names: smacts = packet.ssh.mac_algorithms_client_to_server if 'compression_algorithms_client_to_server' in packet.ssh.field_names: scacts = packet.ssh.compression_algorithms_client_to_server if 'server_host_key_algorithms' in packet.ssh.field_names: sshka = packet.ssh.server_host_key_algorithms # Create hasshServer hasshs_str = ';'.join([skex, seastc, smastc, scastc]) hasshs = md5(hasshs_str.encode()).hexdigest() record = {"timestamp": packet.sniff_time.isoformat(), "sourceIp": packet.ip.src, "destinationIp": packet.ip.dst, "sourcePort": packet.tcp.srcport, "destinationPort": packet.tcp.dstport, "server": protocol, "hasshServer": hasshs, "hasshServerAlgorithms": hasshs_str, "hasshVersion": HASSH_VERSION, "skex": skex, "seastc": seastc, "smastc": smastc, "scastc": scastc, "slcts": slcts, "slstc": slstc, "seacts": seacts, "smacts": smacts, "scacts": scacts, "sshka": sshka} return record
[ "def", "server_hassh", "(", "packet", ")", ":", "srcip", "=", "packet", ".", "ip", ".", "src", "dstip", "=", "packet", ".", "ip", ".", "dst", "sport", "=", "packet", ".", "tcp", ".", "srcport", "dport", "=", "packet", ".", "tcp", ".", "srcport", "p...
https://github.com/salesforce/hassh/blob/7e7658819d9722875316ca591d1a09f9fd21ed8c/python/hassh.py#L208-L266
pyparallel/pyparallel
11e8c6072d48c8f13641925d17b147bf36ee0ba3
Lib/site-packages/pandas-0.17.0-py3.3-win-amd64.egg/pandas/core/index.py
python
Index.to_native_types
(self, slicer=None, **kwargs)
return values._format_native_types(**kwargs)
slice and dice then format
slice and dice then format
[ "slice", "and", "dice", "then", "format" ]
def to_native_types(self, slicer=None, **kwargs): """ slice and dice then format """ values = self if slicer is not None: values = values[slicer] return values._format_native_types(**kwargs)
[ "def", "to_native_types", "(", "self", ",", "slicer", "=", "None", ",", "*", "*", "kwargs", ")", ":", "values", "=", "self", "if", "slicer", "is", "not", "None", ":", "values", "=", "values", "[", "slicer", "]", "return", "values", ".", "_format_native...
https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/site-packages/pandas-0.17.0-py3.3-win-amd64.egg/pandas/core/index.py#L1287-L1292
Mendeley/mrec
d299e3b9490703843b041e6585643b7e42e229f0
mrec/__init__.py
python
read_recommender_description
(filepath)
return BaseRecommender.read_recommender_description(filepath)
Read a recommender model description from file after it has been saved by save_recommender(), without loading all the associated data into memory. Parameters ---------- filepath : str The filepath to read from.
Read a recommender model description from file after it has been saved by save_recommender(), without loading all the associated data into memory.
[ "Read", "a", "recommender", "model", "description", "from", "file", "after", "it", "has", "been", "saved", "by", "save_recommender", "()", "without", "loading", "all", "the", "associated", "data", "into", "memory", "." ]
def read_recommender_description(filepath): """ Read a recommender model description from file after it has been saved by save_recommender(), without loading all the associated data into memory. Parameters ---------- filepath : str The filepath to read from. """ return BaseRecommender.read_recommender_description(filepath)
[ "def", "read_recommender_description", "(", "filepath", ")", ":", "return", "BaseRecommender", ".", "read_recommender_description", "(", "filepath", ")" ]
https://github.com/Mendeley/mrec/blob/d299e3b9490703843b041e6585643b7e42e229f0/mrec/__init__.py#L133-L144
beville/ComicStreamer
62eb914652695ea41a5e1f0cfbd044cbc6854e84
libs/comictaggerlib/utils.py
python
getLanguageFromISO
( iso )
[]
def getLanguageFromISO( iso ): if iso == None: return None else: return lang_dict[ iso ]
[ "def", "getLanguageFromISO", "(", "iso", ")", ":", "if", "iso", "==", "None", ":", "return", "None", "else", ":", "return", "lang_dict", "[", "iso", "]" ]
https://github.com/beville/ComicStreamer/blob/62eb914652695ea41a5e1f0cfbd044cbc6854e84/libs/comictaggerlib/utils.py#L581-L585
django/django
0a17666045de6739ae1c2ac695041823d5f827f7
django/utils/cache.py
python
get_cache_key
(request, key_prefix=None, method='GET', cache=None)
Return a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against. If there isn't a headerlist stored, return None, indicating that the page needs to be rebuilt.
Return a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against.
[ "Return", "a", "cache", "key", "based", "on", "the", "request", "URL", "and", "query", ".", "It", "can", "be", "used", "in", "the", "request", "phase", "because", "it", "pulls", "the", "list", "of", "headers", "to", "take", "into", "account", "from", "...
def get_cache_key(request, key_prefix=None, method='GET', cache=None): """ Return a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against. If there isn't a headerlist stored, return None, indicating that the page needs to be rebuilt. """ if key_prefix is None: key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX cache_key = _generate_cache_header_key(key_prefix, request) if cache is None: cache = caches[settings.CACHE_MIDDLEWARE_ALIAS] headerlist = cache.get(cache_key) if headerlist is not None: return _generate_cache_key(request, method, headerlist, key_prefix) else: return None
[ "def", "get_cache_key", "(", "request", ",", "key_prefix", "=", "None", ",", "method", "=", "'GET'", ",", "cache", "=", "None", ")", ":", "if", "key_prefix", "is", "None", ":", "key_prefix", "=", "settings", ".", "CACHE_MIDDLEWARE_KEY_PREFIX", "cache_key", "...
https://github.com/django/django/blob/0a17666045de6739ae1c2ac695041823d5f827f7/django/utils/cache.py#L349-L368
tav/pylibs
3c16b843681f54130ee6a022275289cadb2f2a69
pycrypto/lib/Crypto/Random/_UserFriendlyRNG.py
python
RNGFile.__exit__
(self)
PEP 343 support
PEP 343 support
[ "PEP", "343", "support" ]
def __exit__(self): """PEP 343 support""" self.close()
[ "def", "__exit__", "(", "self", ")", ":", "self", ".", "close", "(", ")" ]
https://github.com/tav/pylibs/blob/3c16b843681f54130ee6a022275289cadb2f2a69/pycrypto/lib/Crypto/Random/_UserFriendlyRNG.py#L173-L175
omriher/CapTipper
3fb2836c0afe60eb6bd5902b4214f564268e9b4d
jsontemplate/jsontemplate.py
python
expand
(template_str, dictionary, **kwargs)
return t.expand(dictionary)
Free function to expands a template string with a data dictionary. This is useful for cases where you don't care about saving the result of compilation (similar to re.match('.*', s) vs DOT_STAR.match(s))
Free function to expands a template string with a data dictionary.
[ "Free", "function", "to", "expands", "a", "template", "string", "with", "a", "data", "dictionary", "." ]
def expand(template_str, dictionary, **kwargs): """Free function to expands a template string with a data dictionary. This is useful for cases where you don't care about saving the result of compilation (similar to re.match('.*', s) vs DOT_STAR.match(s)) """ t = Template(template_str, **kwargs) return t.expand(dictionary)
[ "def", "expand", "(", "template_str", ",", "dictionary", ",", "*", "*", "kwargs", ")", ":", "t", "=", "Template", "(", "template_str", ",", "*", "*", "kwargs", ")", "return", "t", ".", "expand", "(", "dictionary", ")" ]
https://github.com/omriher/CapTipper/blob/3fb2836c0afe60eb6bd5902b4214f564268e9b4d/jsontemplate/jsontemplate.py#L1219-L1226
pypr/pysph
9cb9a859934939307c65a25cbf73e4ecc83fea4a
pysph/solver/controller.py
python
CommandManager.cont
(self)
continue after a pause command
continue after a pause command
[ "continue", "after", "a", "pause", "command" ]
def cont(self): ''' continue after a pause command ''' if self.comm.Get_size() > 1: logger.debug('pause/continue noy yet supported in parallel runs') return with self.plock: self.pause.remove(threading.current_thread().ident) self.plock.notify() with self.qlock: self.qlock.notify_all()
[ "def", "cont", "(", "self", ")", ":", "if", "self", ".", "comm", ".", "Get_size", "(", ")", ">", "1", ":", "logger", ".", "debug", "(", "'pause/continue noy yet supported in parallel runs'", ")", "return", "with", "self", ".", "plock", ":", "self", ".", ...
https://github.com/pypr/pysph/blob/9cb9a859934939307c65a25cbf73e4ecc83fea4a/pysph/solver/controller.py#L320-L329
eirannejad/pyRevit
49c0b7eb54eb343458ce1365425e6552d0c47d44
site-packages/sqlalchemy/sql/selectable.py
python
HasPrefixes.prefix_with
(self, *expr, **kw)
r"""Add one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative. This is used to support backend-specific prefix keywords such as those provided by MySQL. E.g.:: stmt = table.insert().prefix_with("LOW_PRIORITY", dialect="mysql") Multiple prefixes can be specified by multiple calls to :meth:`.prefix_with`. :param \*expr: textual or :class:`.ClauseElement` construct which will be rendered following the INSERT, UPDATE, or DELETE keyword. :param \**kw: A single keyword 'dialect' is accepted. This is an optional string dialect name which will limit rendering of this prefix to only that dialect.
r"""Add one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative.
[ "r", "Add", "one", "or", "more", "expressions", "following", "the", "statement", "keyword", "i", ".", "e", ".", "SELECT", "INSERT", "UPDATE", "or", "DELETE", ".", "Generative", "." ]
def prefix_with(self, *expr, **kw): r"""Add one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative. This is used to support backend-specific prefix keywords such as those provided by MySQL. E.g.:: stmt = table.insert().prefix_with("LOW_PRIORITY", dialect="mysql") Multiple prefixes can be specified by multiple calls to :meth:`.prefix_with`. :param \*expr: textual or :class:`.ClauseElement` construct which will be rendered following the INSERT, UPDATE, or DELETE keyword. :param \**kw: A single keyword 'dialect' is accepted. This is an optional string dialect name which will limit rendering of this prefix to only that dialect. """ dialect = kw.pop('dialect', None) if kw: raise exc.ArgumentError("Unsupported argument(s): %s" % ",".join(kw)) self._setup_prefixes(expr, dialect)
[ "def", "prefix_with", "(", "self", ",", "*", "expr", ",", "*", "*", "kw", ")", ":", "dialect", "=", "kw", ".", "pop", "(", "'dialect'", ",", "None", ")", "if", "kw", ":", "raise", "exc", ".", "ArgumentError", "(", "\"Unsupported argument(s): %s\"", "%"...
https://github.com/eirannejad/pyRevit/blob/49c0b7eb54eb343458ce1365425e6552d0c47d44/site-packages/sqlalchemy/sql/selectable.py#L246-L272
liuyubobobo/Play-with-Linear-Algebra
e86175adb908b03756618fbeeeadb448a3551321
03-More-about-Vectors/05-Implementations-of-Dot-Product/playLA/Vector.py
python
Vector.norm
(self)
return math.sqrt(sum(e**2 for e in self))
返回向量的模
返回向量的模
[ "返回向量的模" ]
def norm(self): """返回向量的模""" return math.sqrt(sum(e**2 for e in self))
[ "def", "norm", "(", "self", ")", ":", "return", "math", ".", "sqrt", "(", "sum", "(", "e", "**", "2", "for", "e", "in", "self", ")", ")" ]
https://github.com/liuyubobobo/Play-with-Linear-Algebra/blob/e86175adb908b03756618fbeeeadb448a3551321/03-More-about-Vectors/05-Implementations-of-Dot-Product/playLA/Vector.py#L29-L31
etetoolkit/ete
2b207357dc2a40ccad7bfd8f54964472c72e4726
ete3/tools/ete_build_lib/curses_gui.py
python
main
(scr)
return
[]
def main(scr): curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(6, curses.COLOR_RED, curses.COLOR_WHITE) dbg_h = 40 WIN = {} WIN[0] = scr h, w = WIN[0].getmaxyx() WIN[1] = curses.newwin(h-2, w/2, 1,1) WIN[2] = curses.newwin(h-dbg_h, (w/2)-1, 1, (w/2)+2) WIN[3] = curses.newwin(dbg_h, (w/2)-1, h-dbg_h-1, (w/2)-2) p = curses.newpad(1000, 1000) p.addstr("HOLA\n") p.addstr("AMIGO\n") p.addstr("DE VIGO") p.refresh(0, 0, 5, 30, 5, 35) key = p.getch() return for w in list(WIN.values()): w.keypad(1) w.idlok(True) w.scrollok(True) p.refresh(0, 0, 10, 10, 20, 20) return C = CursesList(WIN[2]) for line in open("/var/log/Xorg.0.log"): C.add_item(line.strip()) C.refresh() #WIN[1].addstr("(%d)" %len(C._items)) while 1: key = WIN[2].getch() WIN[1].addstr("%s (%d)" %(key, C._top)) WIN[1].refresh() if key == 113: break elif key == curses.KEY_UP: C.scroll(-1) elif key == curses.KEY_DOWN: C.scroll(1) elif key == curses.KEY_NPAGE: C.scroll(10) elif key == curses.KEY_PPAGE: C.scroll(-10) elif key == curses.KEY_END: C.goto_end() elif key == curses.KEY_HOME: C.goto_start() else: C.refresh()
[ "def", "main", "(", "scr", ")", ":", "curses", ".", "init_pair", "(", "1", ",", "curses", ".", "COLOR_WHITE", ",", "curses", ".", "COLOR_BLACK", ")", "curses", ".", "init_pair", "(", "2", ",", "curses", ".", "COLOR_MAGENTA", ",", "curses", ".", "COLOR_...
https://github.com/etetoolkit/ete/blob/2b207357dc2a40ccad7bfd8f54964472c72e4726/ete3/tools/ete_build_lib/curses_gui.py#L88-L150
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/serene/wiki_index.py
python
ShardedEmbPaths.files
(self, tmp = False)
return sharded_files
Return the files for the sharded embeddings. Args: tmp: Whether to return paths in /tmp or not Returns: Paths of all sharded files.
Return the files for the sharded embeddings.
[ "Return", "the", "files", "for", "the", "sharded", "embeddings", "." ]
def files(self, tmp = False): """Return the files for the sharded embeddings. Args: tmp: Whether to return paths in /tmp or not Returns: Paths of all sharded files. """ sharded_files = [] for shard in range(self._n_shards): sharded_files.extend(self.shard_files(shard, tmp=tmp)) return sharded_files
[ "def", "files", "(", "self", ",", "tmp", "=", "False", ")", ":", "sharded_files", "=", "[", "]", "for", "shard", "in", "range", "(", "self", ".", "_n_shards", ")", ":", "sharded_files", ".", "extend", "(", "self", ".", "shard_files", "(", "shard", ",...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/serene/wiki_index.py#L79-L92
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Lib/timeit.py
python
Timer.repeat
(self, repeat=default_repeat, number=default_number)
return r
Call timeit() a few times. This is a convenience function that calls the timeit() repeatedly, returning a list of results. The first argument specifies how many times to call timeit(), defaulting to 3; the second argument specifies the timer argument, defaulting to one million. Note: it's tempting to calculate mean and standard deviation from the result vector and report these. However, this is not very useful. In a typical case, the lowest value gives a lower bound for how fast your machine can run the given code snippet; higher values in the result vector are typically not caused by variability in Python's speed, but by other processes interfering with your timing accuracy. So the min() of the result is probably the only number you should be interested in. After that, you should look at the entire vector and apply common sense rather than statistics.
Call timeit() a few times.
[ "Call", "timeit", "()", "a", "few", "times", "." ]
def repeat(self, repeat=default_repeat, number=default_number): """Call timeit() a few times. This is a convenience function that calls the timeit() repeatedly, returning a list of results. The first argument specifies how many times to call timeit(), defaulting to 3; the second argument specifies the timer argument, defaulting to one million. Note: it's tempting to calculate mean and standard deviation from the result vector and report these. However, this is not very useful. In a typical case, the lowest value gives a lower bound for how fast your machine can run the given code snippet; higher values in the result vector are typically not caused by variability in Python's speed, but by other processes interfering with your timing accuracy. So the min() of the result is probably the only number you should be interested in. After that, you should look at the entire vector and apply common sense rather than statistics. """ r = [] for i in range(repeat): t = self.timeit(number) r.append(t) return r
[ "def", "repeat", "(", "self", ",", "repeat", "=", "default_repeat", ",", "number", "=", "default_number", ")", ":", "r", "=", "[", "]", "for", "i", "in", "range", "(", "repeat", ")", ":", "t", "=", "self", ".", "timeit", "(", "number", ")", "r", ...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/timeit.py#L201-L225
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials
5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e
Projects/Word2Word/make.py
python
normalize
(tokens, ignore_first_word)
return tokens
If ignore_firs_word is True, We drop the first word or token because its true case is unclear.
If ignore_firs_word is True, We drop the first word or token because its true case is unclear.
[ "If", "ignore_firs_word", "is", "True", "We", "drop", "the", "first", "word", "or", "token", "because", "its", "true", "case", "is", "unclear", "." ]
def normalize(tokens, ignore_first_word): '''If ignore_firs_word is True, We drop the first word or token because its true case is unclear.''' if ignore_first_word: tokens = tokens[1:] return tokens
[ "def", "normalize", "(", "tokens", ",", "ignore_first_word", ")", ":", "if", "ignore_first_word", ":", "tokens", "=", "tokens", "[", "1", ":", "]", "return", "tokens" ]
https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/Projects/Word2Word/make.py#L30-L36
ivre/ivre
5728855b51c0ae2e59450a1c3a782febcad2128b
ivre/web/app.py
python
post_nmap
(subdb)
return {"count": count}
Add records to Nmap & View databases :param str subdb: database to query (must be "scans" or "view") :form categories: a coma-separated list of categories :form source: the source of the scan results (mandatory) :form result: scan results (as XML or JSON files) :status 200: no error :status 400: invalid referer, source or username missing :>json int count: number of inserted results
Add records to Nmap & View databases
[ "Add", "records", "to", "Nmap", "&", "View", "databases" ]
def post_nmap(subdb): """Add records to Nmap & View databases :param str subdb: database to query (must be "scans" or "view") :form categories: a coma-separated list of categories :form source: the source of the scan results (mandatory) :form result: scan results (as XML or JSON files) :status 200: no error :status 400: invalid referer, source or username missing :>json int count: number of inserted results """ referer, source, categories, files = parse_form() count = import_files(subdb, source, categories, files) if request.params.get("output") == "html": response.set_header("Refresh", "5;url=%s" % referer) return """<html> <head> <title>IVRE Web UI</title> </head> <body style="padding-top: 2%%; padding-left: 2%%"> <h1>%d result%s uploaded</h1> </body> </html>""" % ( count, "s" if count > 1 else "", ) return {"count": count}
[ "def", "post_nmap", "(", "subdb", ")", ":", "referer", ",", "source", ",", "categories", ",", "files", "=", "parse_form", "(", ")", "count", "=", "import_files", "(", "subdb", ",", "source", ",", "categories", ",", "files", ")", "if", "request", ".", "...
https://github.com/ivre/ivre/blob/5728855b51c0ae2e59450a1c3a782febcad2128b/ivre/web/app.py#L763-L790
kalliope-project/kalliope
7b2bb4671c8fbfa0ea9f768c84994fe75da974eb
kalliope/core/ConfigurationManager/SettingLoader.py
python
SettingLoader._get_settings
(self)
return setting_object
Class Methods which loads default or the provided YAML file and return a Settings Object :return: The loaded Settings :rtype: Settings :Example: settings = SettingLoader.get_settings(file_path="/var/tmp/settings.yml") .. seealso:: Settings .. warnings:: Class Method
Class Methods which loads default or the provided YAML file and return a Settings Object
[ "Class", "Methods", "which", "loads", "default", "or", "the", "provided", "YAML", "file", "and", "return", "a", "Settings", "Object" ]
def _get_settings(self): """ Class Methods which loads default or the provided YAML file and return a Settings Object :return: The loaded Settings :rtype: Settings :Example: settings = SettingLoader.get_settings(file_path="/var/tmp/settings.yml") .. seealso:: Settings .. warnings:: Class Method """ # create a new setting setting_object = Settings() # Get the setting parameters settings = self._get_yaml_config() default_stt_name = self._get_default_speech_to_text(settings) default_tts_name = self._get_default_text_to_speech(settings) default_trigger_name = self._get_default_trigger(settings) default_player_name = self._get_default_player(settings) stts = self._get_stts(settings) ttss = self._get_ttss(settings) triggers = self._get_triggers(settings) players = self._get_players(settings) rest_api = self._get_rest_api(settings) cache_path = self._get_cache_path(settings) resources = self._get_resources(settings) variables = self._get_variables(settings) options = self._get_options(settings) hooks = self._get_hooks(settings) tracker_anonymous_usage_stats_id = self._get_anonymous_usage_stats(settings) # Load the setting singleton with the parameters setting_object.default_tts_name = default_tts_name setting_object.default_stt_name = default_stt_name setting_object.default_trigger_name = default_trigger_name setting_object.default_player_name = default_player_name setting_object.stts = stts setting_object.ttss = ttss setting_object.triggers = triggers setting_object.players = players setting_object.rest_api = rest_api setting_object.cache_path = cache_path setting_object.resources = resources setting_object.variables = variables setting_object.options = options setting_object.hooks = hooks setting_object.tracker_anonymous_usage_stats_id = tracker_anonymous_usage_stats_id return setting_object
[ "def", "_get_settings", "(", "self", ")", ":", "# create a new setting", "setting_object", "=", "Settings", "(", ")", "# Get the setting parameters", "settings", "=", "self", ".", "_get_yaml_config", "(", ")", "default_stt_name", "=", "self", ".", "_get_default_speech...
https://github.com/kalliope-project/kalliope/blob/7b2bb4671c8fbfa0ea9f768c84994fe75da974eb/kalliope/core/ConfigurationManager/SettingLoader.py#L84-L137
aws/aws-iot-device-sdk-python
90d7b05749e2da7a13193024c720e3c8d9bf1157
AWSIoTPythonSDK/core/protocol/paho/client.py
python
Client.reconnect
(self)
return self._send_connect(self._keepalive, self._clean_session)
Reconnect the client after a disconnect. Can only be called after connect()/connect_async().
Reconnect the client after a disconnect. Can only be called after connect()/connect_async().
[ "Reconnect", "the", "client", "after", "a", "disconnect", ".", "Can", "only", "be", "called", "after", "connect", "()", "/", "connect_async", "()", "." ]
def reconnect(self): """Reconnect the client after a disconnect. Can only be called after connect()/connect_async().""" if len(self._host) == 0: raise ValueError('Invalid host.') if self._port <= 0: raise ValueError('Invalid port number.') self._in_packet = { "command": 0, "have_remaining": 0, "remaining_count": [], "remaining_mult": 1, "remaining_length": 0, "packet": b"", "to_process": 0, "pos": 0} self._out_packet_mutex.acquire() self._out_packet = [] self._out_packet_mutex.release() self._current_out_packet_mutex.acquire() self._current_out_packet = None self._current_out_packet_mutex.release() self._msgtime_mutex.acquire() self._last_msg_in = time.time() self._last_msg_out = time.time() self._msgtime_mutex.release() self._ping_t = 0 self._state_mutex.acquire() self._state = mqtt_cs_new self._state_mutex.release() if self._ssl: self._ssl.close() self._ssl = None self._sock = None elif self._sock: self._sock.close() self._sock = None # Put messages in progress in a valid state. self._messages_reconnect_reset() try: if self._socket_factory: sock = self._socket_factory() elif (sys.version_info[0] == 2 and sys.version_info[1] < 7) or (sys.version_info[0] == 3 and sys.version_info[1] < 2): sock = socket.create_connection((self._host, self._port)) else: sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) except socket.error as err: if err.errno != errno.EINPROGRESS and err.errno != errno.EWOULDBLOCK and err.errno != EAGAIN: raise verify_hostname = self._tls_insecure is False # Decide whether we need to verify hostname if self._tls_ca_certs is not None: if self._useSecuredWebsocket: # Never assign to ._ssl before wss handshake is finished # Non-None value for ._ssl will allow ops before wss-MQTT connection is established rawSSL = ssl.wrap_socket(sock, ca_certs=self._tls_ca_certs, cert_reqs=ssl.CERT_REQUIRED) # Add server certificate verification rawSSL.setblocking(0) # Non-blocking socket self._ssl = SecuredWebSocketCore(rawSSL, self._host, self._port, self._AWSAccessKeyIDCustomConfig, self._AWSSecretAccessKeyCustomConfig, self._AWSSessionTokenCustomConfig) # Override the _ssl socket # self._ssl.enableDebug() elif self._alpn_protocols is not None: # SSLContext is required to enable ALPN support # Assuming Python 2.7.10+/3.5+ till the end of this elif branch ssl_context = SSLContextBuilder()\ .with_ca_certs(self._tls_ca_certs)\ .with_cert_key_pair(self._tls_certfile, self._tls_keyfile)\ .with_cert_reqs(self._tls_cert_reqs)\ .with_check_hostname(True)\ .with_ciphers(self._tls_ciphers)\ .with_alpn_protocols(self._alpn_protocols)\ .build() self._ssl = ssl_context.wrap_socket(sock, server_hostname=self._host, do_handshake_on_connect=False) verify_hostname = False # Since check_hostname in SSLContext is already set to True, no need to verify it again self._ssl.do_handshake() else: self._ssl = ssl.wrap_socket( sock, certfile=self._tls_certfile, keyfile=self._tls_keyfile, ca_certs=self._tls_ca_certs, cert_reqs=self._tls_cert_reqs, ssl_version=self._tls_version, ciphers=self._tls_ciphers) if verify_hostname: if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 5): # No IP host match before 3.5.x self._tls_match_hostname() else: ssl.match_hostname(self._ssl.getpeercert(), self._host) self._sock = sock if self._ssl and not self._useSecuredWebsocket: self._ssl.setblocking(0) # For X.509 cert mutual auth. elif not self._ssl: self._sock.setblocking(0) # For plain socket else: pass # For MQTT over WebSocket return self._send_connect(self._keepalive, self._clean_session)
[ "def", "reconnect", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_host", ")", "==", "0", ":", "raise", "ValueError", "(", "'Invalid host.'", ")", "if", "self", ".", "_port", "<=", "0", ":", "raise", "ValueError", "(", "'Invalid port number.'", ...
https://github.com/aws/aws-iot-device-sdk-python/blob/90d7b05749e2da7a13193024c720e3c8d9bf1157/AWSIoTPythonSDK/core/protocol/paho/client.py#L737-L843
rspivak/lsbasi
07e1a14516156a21ebe2d82e0bae4bba5ad73dd6
part16/spi.py
python
Parser.parse
(self)
return node
program : PROGRAM variable SEMI block DOT block : declarations compound_statement declarations : (VAR (variable_declaration SEMI)+)? procedure_declaration* variable_declaration : ID (COMMA ID)* COLON type_spec procedure_declaration : PROCEDURE ID (LPAREN formal_parameter_list RPAREN)? SEMI block SEMI formal_params_list : formal_parameters | formal_parameters SEMI formal_parameter_list formal_parameters : ID (COMMA ID)* COLON type_spec type_spec : INTEGER | REAL compound_statement : BEGIN statement_list END statement_list : statement | statement SEMI statement_list statement : compound_statement | proccall_statement | assignment_statement | empty proccall_statement : ID LPAREN (expr (COMMA expr)*)? RPAREN assignment_statement : variable ASSIGN expr empty : expr : term ((PLUS | MINUS) term)* term : factor ((MUL | INTEGER_DIV | FLOAT_DIV) factor)* factor : PLUS factor | MINUS factor | INTEGER_CONST | REAL_CONST | LPAREN expr RPAREN | variable variable: ID
program : PROGRAM variable SEMI block DOT
[ "program", ":", "PROGRAM", "variable", "SEMI", "block", "DOT" ]
def parse(self): """ program : PROGRAM variable SEMI block DOT block : declarations compound_statement declarations : (VAR (variable_declaration SEMI)+)? procedure_declaration* variable_declaration : ID (COMMA ID)* COLON type_spec procedure_declaration : PROCEDURE ID (LPAREN formal_parameter_list RPAREN)? SEMI block SEMI formal_params_list : formal_parameters | formal_parameters SEMI formal_parameter_list formal_parameters : ID (COMMA ID)* COLON type_spec type_spec : INTEGER | REAL compound_statement : BEGIN statement_list END statement_list : statement | statement SEMI statement_list statement : compound_statement | proccall_statement | assignment_statement | empty proccall_statement : ID LPAREN (expr (COMMA expr)*)? RPAREN assignment_statement : variable ASSIGN expr empty : expr : term ((PLUS | MINUS) term)* term : factor ((MUL | INTEGER_DIV | FLOAT_DIV) factor)* factor : PLUS factor | MINUS factor | INTEGER_CONST | REAL_CONST | LPAREN expr RPAREN | variable variable: ID """ node = self.program() if self.current_token.type != TokenType.EOF: self.error( error_code=ErrorCode.UNEXPECTED_TOKEN, token=self.current_token, ) return node
[ "def", "parse", "(", "self", ")", ":", "node", "=", "self", ".", "program", "(", ")", "if", "self", ".", "current_token", ".", "type", "!=", "TokenType", ".", "EOF", ":", "self", ".", "error", "(", "error_code", "=", "ErrorCode", ".", "UNEXPECTED_TOKEN...
https://github.com/rspivak/lsbasi/blob/07e1a14516156a21ebe2d82e0bae4bba5ad73dd6/part16/spi.py#L699-L755
hankcs/HanLP
6c02812969c4827d74b404c3ad4207f71ca9165a
hanlp/common/torch_component.py
python
TorchComponent.save
(self, save_dir: str, **kwargs)
Save this component to a directory. Args: save_dir: The directory to save this component. **kwargs: Not used.
Save this component to a directory.
[ "Save", "this", "component", "to", "a", "directory", "." ]
def save(self, save_dir: str, **kwargs): """Save this component to a directory. Args: save_dir: The directory to save this component. **kwargs: Not used. """ self.save_config(save_dir) self.save_vocabs(save_dir) self.save_weights(save_dir)
[ "def", "save", "(", "self", ",", "save_dir", ":", "str", ",", "*", "*", "kwargs", ")", ":", "self", ".", "save_config", "(", "save_dir", ")", "self", ".", "save_vocabs", "(", "save_dir", ")", "self", ".", "save_weights", "(", "save_dir", ")" ]
https://github.com/hankcs/HanLP/blob/6c02812969c4827d74b404c3ad4207f71ca9165a/hanlp/common/torch_component.py#L149-L158
geometalab/Vector-Tiles-Reader-QGIS-Plugin
a31ae86959c8f3b7d6f332f84191cd7ca4683e1d
ext-libs/google/protobuf/descriptor_pool.py
python
DescriptorPool.FindEnumTypeByName
(self, full_name)
return self._enum_descriptors[full_name]
Loads the named enum descriptor from the pool. Args: full_name: The full name of the enum descriptor to load. Returns: The enum descriptor for the named type.
Loads the named enum descriptor from the pool.
[ "Loads", "the", "named", "enum", "descriptor", "from", "the", "pool", "." ]
def FindEnumTypeByName(self, full_name): """Loads the named enum descriptor from the pool. Args: full_name: The full name of the enum descriptor to load. Returns: The enum descriptor for the named type. """ full_name = _NormalizeFullyQualifiedName(full_name) if full_name not in self._enum_descriptors: self.FindFileContainingSymbol(full_name) return self._enum_descriptors[full_name]
[ "def", "FindEnumTypeByName", "(", "self", ",", "full_name", ")", ":", "full_name", "=", "_NormalizeFullyQualifiedName", "(", "full_name", ")", "if", "full_name", "not", "in", "self", ".", "_enum_descriptors", ":", "self", ".", "FindFileContainingSymbol", "(", "ful...
https://github.com/geometalab/Vector-Tiles-Reader-QGIS-Plugin/blob/a31ae86959c8f3b7d6f332f84191cd7ca4683e1d/ext-libs/google/protobuf/descriptor_pool.py#L324-L337
PokemonGoF/PokemonGo-Bot-Desktop
4bfa94f0183406c6a86f93645eff7abd3ad4ced8
build/pywin/Lib/mutex.py
python
mutex.lock
(self, function, argument)
Lock a mutex, call the function with supplied argument when it is acquired. If the mutex is already locked, place function and argument in the queue.
Lock a mutex, call the function with supplied argument when it is acquired. If the mutex is already locked, place function and argument in the queue.
[ "Lock", "a", "mutex", "call", "the", "function", "with", "supplied", "argument", "when", "it", "is", "acquired", ".", "If", "the", "mutex", "is", "already", "locked", "place", "function", "and", "argument", "in", "the", "queue", "." ]
def lock(self, function, argument): """Lock a mutex, call the function with supplied argument when it is acquired. If the mutex is already locked, place function and argument in the queue.""" if self.testandset(): function(argument) else: self.queue.append((function, argument))
[ "def", "lock", "(", "self", ",", "function", ",", "argument", ")", ":", "if", "self", ".", "testandset", "(", ")", ":", "function", "(", "argument", ")", "else", ":", "self", ".", "queue", ".", "append", "(", "(", "function", ",", "argument", ")", ...
https://github.com/PokemonGoF/PokemonGo-Bot-Desktop/blob/4bfa94f0183406c6a86f93645eff7abd3ad4ced8/build/pywin/Lib/mutex.py#L39-L46
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/scatterpolar/marker/colorbar/_title.py
python
Title.__init__
(self, arg=None, font=None, side=None, text=None, **kwargs)
Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatterpolar.m arker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- Title
Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatterpolar.m arker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.
[ "Construct", "a", "new", "Title", "object", "Parameters", "----------", "arg", "dict", "of", "properties", "compatible", "with", "this", "constructor", "or", "an", "instance", "of", ":", "class", ":", "plotly", ".", "graph_objs", ".", "scatterpolar", ".", "m",...
def __init__(self, arg=None, font=None, side=None, text=None, **kwargs): """ Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatterpolar.m arker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- Title """ super(Title, self).__init__("title") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.scatterpolar.marker.colorbar.Title constructor must be a dict or an instance of :class:`plotly.graph_objs.scatterpolar.marker.colorbar.Title`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("font", None) _v = font if font is not None else _v if _v is not None: self["font"] = _v _v = arg.pop("side", None) _v = side if side is not None else _v if _v is not None: self["side"] = _v _v = arg.pop("text", None) _v = text if text is not None else _v if _v is not None: self["text"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "font", "=", "None", ",", "side", "=", "None", ",", "text", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Title", ",", "self", ")", ".", "__init__", "(", "\"title\"", ...
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/scatterpolar/marker/colorbar/_title.py#L131-L210
ChintanTrivedi/DeepGamingAI_FIFA
b79a5b670756056b7b6aedd2c5c84fd5f59d569e
utils/dataset_util.py
python
read_examples_list
(path)
return [line.strip().split(' ')[0] for line in lines]
Read list of training or validation examples. The file is assumed to contain a single example per line where the first token in the line is an identifier that allows us to find the image and annotation xml for that example. For example, the line: xyz 3 would allow us to find files xyz.jpg and xyz.xml (the 3 would be ignored). Args: path: absolute path to examples list file. Returns: list of example identifiers (strings).
Read list of training or validation examples.
[ "Read", "list", "of", "training", "or", "validation", "examples", "." ]
def read_examples_list(path): """Read list of training or validation examples. The file is assumed to contain a single example per line where the first token in the line is an identifier that allows us to find the image and annotation xml for that example. For example, the line: xyz 3 would allow us to find files xyz.jpg and xyz.xml (the 3 would be ignored). Args: path: absolute path to examples list file. Returns: list of example identifiers (strings). """ with tf.gfile.GFile(path) as fid: lines = fid.readlines() return [line.strip().split(' ')[0] for line in lines]
[ "def", "read_examples_list", "(", "path", ")", ":", "with", "tf", ".", "gfile", ".", "GFile", "(", "path", ")", "as", "fid", ":", "lines", "=", "fid", ".", "readlines", "(", ")", "return", "[", "line", ".", "strip", "(", ")", ".", "split", "(", "...
https://github.com/ChintanTrivedi/DeepGamingAI_FIFA/blob/b79a5b670756056b7b6aedd2c5c84fd5f59d569e/utils/dataset_util.py#L41-L60
FitMachineLearning/FitML
a60f49fce1799ca4b11b48307441325b6272719a
ParameterNoising/Tensorflow/BipedalWalker_v1.0.py
python
actor_experience_replay
(memSA,memR,memS,memA,memW,num_epoch=1)
train_B = train_B[tW.flatten()>0] #print("%8d were better results than pr"%np.alen(tX_train)) tX = tX[train_B,:] tY = tY[train_B,:] tW = tW[train_B,:] tR = tR[train_B,:] #print("tW",tW)
train_B = train_B[tW.flatten()>0]
[ "train_B", "=", "train_B", "[", "tW", ".", "flatten", "()", ">", "0", "]" ]
def actor_experience_replay(memSA,memR,memS,memA,memW,num_epoch=1): tSA = (memSA) tR = (memR) tX = (memS) tY = (memA) tW = (memW) target = tR.mean() #+ math.fabs( tR.mean() - tR.max() )/2 #+ math.fabs( tR.mean() - tR.max() )/4 train_C = np.arange(np.alen(tR)) train_C = train_C[tR.flatten()>target] tX = tX[train_C,:] tY = tY[train_C,:] tW = tW[train_C,:] tR = tR[train_C,:] train_A = np.random.randint(tY.shape[0],size=int(min(experience_replay_size,np.alen(tR) ))) tX = tX[train_A,:] tY = tY[train_A,:] tW = tW[train_A,:] tR = tR[train_A,:] train_B = np.arange(np.alen(tR)) tX_train = np.zeros(shape=(1,num_env_variables)) tY_train = np.zeros(shape=(1,num_env_actions)) for i in range(np.alen(train_B)): #pr = predictTotalRewards(tX[i],tY[i]) ''' YOU CAN"T USE predictTotalRewards IF YOU DON"T TRAIN THE QMODEL if tR[i][0] < pr: tW[i][0] = -1 else: ''' d = math.fabs( memoryR.max() - target) tW[i] = math.fabs(tR[i]-(target+0.000000000005)) / d #tW[i] = math.exp(1-(1/tW[i]**2)) tW[i]= 0.0000000000000005 if (tR[i]>target): tW[i]=0.5 if (tR[i]>max_game_average): tW[i] = 1 if tW[i]> np.random.rand(1): tX_train = np.vstack((tX_train,tX[i])) tY_train = np.vstack((tY_train,tY[i])) #print ("tW",tW[i],"exp", math.exp(1-(1/tW[i]**2))) #tW[i] = math.exp(1-(1/tW[i]**2)) #tW[i] = 1 #print("tW[i] %3.1f tR %3.2f target %3.2f max_game_average %3.2f "%(tW[i],tR[i],target,max_game_average)) ''' train_B = train_B[tW.flatten()>0] #print("%8d were better results than pr"%np.alen(tX_train)) tX = tX[train_B,:] tY = tY[train_B,:] tW = tW[train_B,:] tR = tR[train_B,:] #print("tW",tW) ''' #print("%8d were better results than pr"%np.alen(tX_train)) ''' REMOVE FIRST ELEMENT BEFORE TRAINING ''' tX_train = tX_train[1:] tY_train = tY_train[1:] #print("%8d were better After removing first element"%np.alen(tX_train)) if np.alen(tX_train)>0: #tW = scale_weights(tR,tW) #print("# setps short listed ", np.alen(tR)) #action_predictor_model.fit(tX_train,tY_train, batch_size=mini_batch, nb_epoch=num_epochs,verbose=0) for num_epoch in range(training_epochs): sess.run(aptrain_op, feed_dict={apdataX: tX_train, apdataY: tY_train})
[ "def", "actor_experience_replay", "(", "memSA", ",", "memR", ",", "memS", ",", "memA", ",", "memW", ",", "num_epoch", "=", "1", ")", ":", "tSA", "=", "(", "memSA", ")", "tR", "=", "(", "memR", ")", "tX", "=", "(", "memS", ")", "tY", "=", "(", "...
https://github.com/FitMachineLearning/FitML/blob/a60f49fce1799ca4b11b48307441325b6272719a/ParameterNoising/Tensorflow/BipedalWalker_v1.0.py#L408-L485
OpenMDAO/OpenMDAO-Framework
f2e37b7de3edeaaeb2d251b375917adec059db9b
openmdao.main/src/openmdao/main/datatypes/array.py
python
Array.validate
(self, obj, name, value)
return new_val
Validates that a specified value is valid for this trait. Units are converted as needed.
Validates that a specified value is valid for this trait. Units are converted as needed.
[ "Validates", "that", "a", "specified", "value", "is", "valid", "for", "this", "trait", ".", "Units", "are", "converted", "as", "needed", "." ]
def validate(self, obj, name, value): """ Validates that a specified value is valid for this trait. Units are converted as needed. """ try: new_val = super(Array, self).validate(obj, name, value) except Exception: self.error(obj, name, value) return new_val
[ "def", "validate", "(", "self", ",", "obj", ",", "name", ",", "value", ")", ":", "try", ":", "new_val", "=", "super", "(", "Array", ",", "self", ")", ".", "validate", "(", "obj", ",", "name", ",", "value", ")", "except", "Exception", ":", "self", ...
https://github.com/OpenMDAO/OpenMDAO-Framework/blob/f2e37b7de3edeaaeb2d251b375917adec059db9b/openmdao.main/src/openmdao/main/datatypes/array.py#L109-L119
edfungus/Crouton
ada98b3930192938a48909072b45cb84b945f875
clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/vcs/__init__.py
python
VersionControl.get_url
(self, location)
Return the url used at location Used in get_info or check_destination
Return the url used at location Used in get_info or check_destination
[ "Return", "the", "url", "used", "at", "location", "Used", "in", "get_info", "or", "check_destination" ]
def get_url(self, location): """ Return the url used at location Used in get_info or check_destination """ raise NotImplementedError
[ "def", "get_url", "(", "self", ",", "location", ")", ":", "raise", "NotImplementedError" ]
https://github.com/edfungus/Crouton/blob/ada98b3930192938a48909072b45cb84b945f875/clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/vcs/__init__.py#L287-L292
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/v5_1/git/git_client_base.py
python
GitClientBase.create_annotated_tag
(self, tag_object, project, repository_id)
return self._deserialize('GitAnnotatedTag', response)
CreateAnnotatedTag. [Preview API] Create an annotated tag. :param :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>` tag_object: Object containing details of tag to be created. :param str project: Project ID or project name :param str repository_id: ID or name of the repository. :rtype: :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>`
CreateAnnotatedTag. [Preview API] Create an annotated tag. :param :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>` tag_object: Object containing details of tag to be created. :param str project: Project ID or project name :param str repository_id: ID or name of the repository. :rtype: :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>`
[ "CreateAnnotatedTag", ".", "[", "Preview", "API", "]", "Create", "an", "annotated", "tag", ".", ":", "param", ":", "class", ":", "<GitAnnotatedTag", ">", "<azure", ".", "devops", ".", "v5_1", ".", "git", ".", "models", ".", "GitAnnotatedTag", ">", "tag_obj...
def create_annotated_tag(self, tag_object, project, repository_id): """CreateAnnotatedTag. [Preview API] Create an annotated tag. :param :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>` tag_object: Object containing details of tag to be created. :param str project: Project ID or project name :param str repository_id: ID or name of the repository. :rtype: :class:`<GitAnnotatedTag> <azure.devops.v5_1.git.models.GitAnnotatedTag>` """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if repository_id is not None: route_values['repositoryId'] = self._serialize.url('repository_id', repository_id, 'str') content = self._serialize.body(tag_object, 'GitAnnotatedTag') response = self._send(http_method='POST', location_id='5e8a8081-3851-4626-b677-9891cc04102e', version='5.1-preview.1', route_values=route_values, content=content) return self._deserialize('GitAnnotatedTag', response)
[ "def", "create_annotated_tag", "(", "self", ",", "tag_object", ",", "project", ",", "repository_id", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "]", "=", "self", ".", "_serialize", ...
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/git/git_client_base.py#L28-L47
meetbill/zabbix_manager
739e5b51facf19cc6bda2b50f29108f831cf833e
ZabbixTool/lib_zabbix/w_lib/mylib/xlwt/Cell.py
python
FormulaCell.__init__
(self, rowx, colx, xf_idx, frmla, calc_flags=0)
[]
def __init__(self, rowx, colx, xf_idx, frmla, calc_flags=0): self.rowx = rowx self.colx = colx self.xf_idx = xf_idx self.frmla = frmla self.calc_flags = calc_flags
[ "def", "__init__", "(", "self", ",", "rowx", ",", "colx", ",", "xf_idx", ",", "frmla", ",", "calc_flags", "=", "0", ")", ":", "self", ".", "rowx", "=", "rowx", "self", ".", "colx", "=", "colx", "self", ".", "xf_idx", "=", "xf_idx", "self", ".", "...
https://github.com/meetbill/zabbix_manager/blob/739e5b51facf19cc6bda2b50f29108f831cf833e/ZabbixTool/lib_zabbix/w_lib/mylib/xlwt/Cell.py#L159-L164
hzlzh/AlfredWorkflow.com
7055f14f6922c80ea5943839eb0caff11ae57255
Sources/Workflows/Toggl-Time-Tracking/alp/request/requests/packages/oauthlib/oauth2/draft25/parameters.py
python
parse_authorization_code_response
(uri, state=None)
return params
Parse authorization grant response URI into a dict. If the resource owner grants the access request, the authorization server issues an authorization code and delivers it to the client by adding the following parameters to the query component of the redirection URI using the "application/x-www-form-urlencoded" format: code REQUIRED. The authorization code generated by the authorization server. The authorization code MUST expire shortly after it is issued to mitigate the risk of leaks. A maximum authorization code lifetime of 10 minutes is RECOMMENDED. The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request and SHOULD revoke (when possible) all tokens previously issued based on that authorization code. The authorization code is bound to the client identifier and redirection URI. state REQUIRED if the "state" parameter was present in the client authorization request. The exact value received from the client. For example, the authorization server redirects the user-agent by sending the following HTTP response: HTTP/1.1 302 Found Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA &state=xyz
Parse authorization grant response URI into a dict.
[ "Parse", "authorization", "grant", "response", "URI", "into", "a", "dict", "." ]
def parse_authorization_code_response(uri, state=None): """Parse authorization grant response URI into a dict. If the resource owner grants the access request, the authorization server issues an authorization code and delivers it to the client by adding the following parameters to the query component of the redirection URI using the "application/x-www-form-urlencoded" format: code REQUIRED. The authorization code generated by the authorization server. The authorization code MUST expire shortly after it is issued to mitigate the risk of leaks. A maximum authorization code lifetime of 10 minutes is RECOMMENDED. The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request and SHOULD revoke (when possible) all tokens previously issued based on that authorization code. The authorization code is bound to the client identifier and redirection URI. state REQUIRED if the "state" parameter was present in the client authorization request. The exact value received from the client. For example, the authorization server redirects the user-agent by sending the following HTTP response: HTTP/1.1 302 Found Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA &state=xyz """ query = urlparse.urlparse(uri).query params = dict(urlparse.parse_qsl(query)) if not u'code' in params: raise KeyError("Missing code parameter in response.") if state and params.get(u'state', None) != state: raise ValueError("Mismatching or missing state in response.") return params
[ "def", "parse_authorization_code_response", "(", "uri", ",", "state", "=", "None", ")", ":", "query", "=", "urlparse", ".", "urlparse", "(", "uri", ")", ".", "query", "params", "=", "dict", "(", "urlparse", ".", "parse_qsl", "(", "query", ")", ")", "if",...
https://github.com/hzlzh/AlfredWorkflow.com/blob/7055f14f6922c80ea5943839eb0caff11ae57255/Sources/Workflows/Toggl-Time-Tracking/alp/request/requests/packages/oauthlib/oauth2/draft25/parameters.py#L95-L136
naftaliharris/tauthon
5587ceec329b75f7caf6d65a036db61ac1bae214
Lib/logging/__init__.py
python
exception
(msg, *args, **kwargs)
Log a message with severity 'ERROR' on the root logger, with exception information.
Log a message with severity 'ERROR' on the root logger, with exception information.
[ "Log", "a", "message", "with", "severity", "ERROR", "on", "the", "root", "logger", "with", "exception", "information", "." ]
def exception(msg, *args, **kwargs): """ Log a message with severity 'ERROR' on the root logger, with exception information. """ kwargs['exc_info'] = 1 error(msg, *args, **kwargs)
[ "def", "exception", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'exc_info'", "]", "=", "1", "error", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
https://github.com/naftaliharris/tauthon/blob/5587ceec329b75f7caf6d65a036db61ac1bae214/Lib/logging/__init__.py#L1612-L1618
yuantiku/fairseq-gec
10aafebc482706346f768e4f18a9813153cb1ecc
fairseq/optim/lr_scheduler/fairseq_lr_scheduler.py
python
FairseqLRScheduler.step_update
(self, num_updates)
return self.optimizer.get_lr()
Update the learning rate after each update.
Update the learning rate after each update.
[ "Update", "the", "learning", "rate", "after", "each", "update", "." ]
def step_update(self, num_updates): """Update the learning rate after each update.""" return self.optimizer.get_lr()
[ "def", "step_update", "(", "self", ",", "num_updates", ")", ":", "return", "self", ".", "optimizer", ".", "get_lr", "(", ")" ]
https://github.com/yuantiku/fairseq-gec/blob/10aafebc482706346f768e4f18a9813153cb1ecc/fairseq/optim/lr_scheduler/fairseq_lr_scheduler.py#L42-L44
timkpaine/tributary
90acb236d96a23c0c4794fd0f2da82c66060f737
tributary/lazy/node.py
python
Node.__call__
(self, node_tweaks=None, *positional_tweaks, **keyword_tweaks)
return self.value()
Lazily re-evaluate the node Args: node_tweaks (dict): A dict mapping node to tweaked value positional_tweaks (VAR_POSITIONAL): A tuple of positional tweaks to apply keyword_tweaks (VAR_KEYWORD): A dict of keyword tweaks to apply How it works: The "original caller" is the node being evaluted w/ tweaks. It will consume the positional_tweaks` and `keyword_tweaks`, which look like: (1, 2,) , {"a": 5, "b": 10} and join them with `node_tweaks` in a dict mapping node->tweaked value, e.g. {Node1: 1, Node2: 2, NodeA: 5, NodeB: 10} and pass this dict up the call tree in `node_tweaks`. This dict is carried through all node operations through the entire call tree. If a node is being evaluated and is in `node_tweaks`, it ignores recalculation and returns the tweaked value. Returns: Any: the value, either via re-evaluation (if self or upstream dirty), or the previously computed value
Lazily re-evaluate the node
[ "Lazily", "re", "-", "evaluate", "the", "node" ]
def __call__(self, node_tweaks=None, *positional_tweaks, **keyword_tweaks): """Lazily re-evaluate the node Args: node_tweaks (dict): A dict mapping node to tweaked value positional_tweaks (VAR_POSITIONAL): A tuple of positional tweaks to apply keyword_tweaks (VAR_KEYWORD): A dict of keyword tweaks to apply How it works: The "original caller" is the node being evaluted w/ tweaks. It will consume the positional_tweaks` and `keyword_tweaks`, which look like: (1, 2,) , {"a": 5, "b": 10} and join them with `node_tweaks` in a dict mapping node->tweaked value, e.g. {Node1: 1, Node2: 2, NodeA: 5, NodeB: 10} and pass this dict up the call tree in `node_tweaks`. This dict is carried through all node operations through the entire call tree. If a node is being evaluated and is in `node_tweaks`, it ignores recalculation and returns the tweaked value. Returns: Any: the value, either via re-evaluation (if self or upstream dirty), or the previously computed value """ node_tweaks = node_tweaks or {} if not isinstance(node_tweaks, dict): # treat node_tweak argument as positional tweak positional_tweaks = list(positional_tweaks) + [node_tweaks] node_tweaks = {} # instantiate tweaks tweaks = {} # update with provided tweaks.update(node_tweaks) for i, positional_tweak in enumerate(positional_tweaks): tweaks[self._get_arg(i)] = positional_tweak for k, keyword_tweak in keyword_tweaks.items(): tweaks[self._get_kwarg(k)] = keyword_tweak # tweak self if tweaks: self._tweak(tweaks) # calculate new value computed = self._recompute(tweaks) if tweaks: # untweak self self._untweak() # return the calculation result, not my current value return computed # otherwise return my permanent value, should equal computed # assert self.value() == computed return self.value()
[ "def", "__call__", "(", "self", ",", "node_tweaks", "=", "None", ",", "*", "positional_tweaks", ",", "*", "*", "keyword_tweaks", ")", ":", "node_tweaks", "=", "node_tweaks", "or", "{", "}", "if", "not", "isinstance", "(", "node_tweaks", ",", "dict", ")", ...
https://github.com/timkpaine/tributary/blob/90acb236d96a23c0c4794fd0f2da82c66060f737/tributary/lazy/node.py#L615-L671
OpenMDAO/OpenMDAO1
791a6fbbb7d266f3dcbc1f7bde3ae03a70dc1317
openmdao/components/exec_comp.py
python
ExecComp.solve_nonlinear
(self, params, unknowns, resids)
Executes this component's assignment statemens. Args ---- params : `VecWrapper`, optional `VecWrapper` containing parameters. (p) unknowns : `VecWrapper`, optional `VecWrapper` containing outputs and states. (u) resids : `VecWrapper`, optional `VecWrapper` containing residuals. (r)
Executes this component's assignment statemens.
[ "Executes", "this", "component", "s", "assignment", "statemens", "." ]
def solve_nonlinear(self, params, unknowns, resids): """ Executes this component's assignment statemens. Args ---- params : `VecWrapper`, optional `VecWrapper` containing parameters. (p) unknowns : `VecWrapper`, optional `VecWrapper` containing outputs and states. (u) resids : `VecWrapper`, optional `VecWrapper` containing residuals. (r) """ for expr in self._codes: exec(expr, _expr_dict, _UPDict(unknowns, params, self._to_colons))
[ "def", "solve_nonlinear", "(", "self", ",", "params", ",", "unknowns", ",", "resids", ")", ":", "for", "expr", "in", "self", ".", "_codes", ":", "exec", "(", "expr", ",", "_expr_dict", ",", "_UPDict", "(", "unknowns", ",", "params", ",", "self", ".", ...
https://github.com/OpenMDAO/OpenMDAO1/blob/791a6fbbb7d266f3dcbc1f7bde3ae03a70dc1317/openmdao/components/exec_comp.py#L197-L213