repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
pantsbuild/pants
src/python/pants/reporting/invalidation_report.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/reporting/invalidation_report.py#L75-L84
def add_vts(self, task_name, targets, cache_key, valid, phase): """ Add a single VersionedTargetSet entry to the report. :param InvalidationCacheManager cache_manager: :param CacheKey cache_key: :param bool valid: :param string phase: """ if task_name not in self._task_reports: self.ad...
[ "def", "add_vts", "(", "self", ",", "task_name", ",", "targets", ",", "cache_key", ",", "valid", ",", "phase", ")", ":", "if", "task_name", "not", "in", "self", ".", "_task_reports", ":", "self", ".", "add_task", "(", "task_name", ")", "self", ".", "_t...
Add a single VersionedTargetSet entry to the report. :param InvalidationCacheManager cache_manager: :param CacheKey cache_key: :param bool valid: :param string phase:
[ "Add", "a", "single", "VersionedTargetSet", "entry", "to", "the", "report", ".", ":", "param", "InvalidationCacheManager", "cache_manager", ":", ":", "param", "CacheKey", "cache_key", ":", ":", "param", "bool", "valid", ":", ":", "param", "string", "phase", ":...
python
train
40
saltstack/salt
salt/states/icinga2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/icinga2.py#L242-L280
def node_setup(name, master, ticket): ''' Setup the icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ticket Authentication ticket generated on icinga2 master ''' ret = {'...
[ "def", "node_setup", "(", "name", ",", "master", ",", "ticket", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}", "cert", "=", "\"{0}{1}.crt.orig\"", "."...
Setup the icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ticket Authentication ticket generated on icinga2 master
[ "Setup", "the", "icinga2", "node", "." ]
python
train
31.102564
Metatab/geoid
geoid/core.py
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L428-L446
def make_classes(base_class, module): """Create derived classes and put them into the same module as the base class. This function is called at the end of each of the derived class modules, acs, census, civik and tiger. It will create a set of new derived class in the module, one for each of the enries in...
[ "def", "make_classes", "(", "base_class", ",", "module", ")", ":", "from", "functools", "import", "partial", "for", "k", "in", "names", ":", "cls", "=", "base_class", ".", "class_factory", "(", "k", ".", "capitalize", "(", ")", ")", "cls", ".", "augment"...
Create derived classes and put them into the same module as the base class. This function is called at the end of each of the derived class modules, acs, census, civik and tiger. It will create a set of new derived class in the module, one for each of the enries in the `summary_levels` dict.
[ "Create", "derived", "classes", "and", "put", "them", "into", "the", "same", "module", "as", "the", "base", "class", "." ]
python
train
30.736842
materialsproject/pymatgen
pymatgen/io/qchem/outputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/qchem/outputs.py#L569-L584
def _read_single_point_data(self): """ Parses final free energy information from single-point calculations. """ temp_dict = read_pattern( self.text, { "final_energy": r"\s*SCF\s+energy in the final basis set\s+=\s*([\d\-\.]+)" }...
[ "def", "_read_single_point_data", "(", "self", ")", ":", "temp_dict", "=", "read_pattern", "(", "self", ".", "text", ",", "{", "\"final_energy\"", ":", "r\"\\s*SCF\\s+energy in the final basis set\\s+=\\s*([\\d\\-\\.]+)\"", "}", ")", "if", "temp_dict", ".", "get", "("...
Parses final free energy information from single-point calculations.
[ "Parses", "final", "free", "energy", "information", "from", "single", "-", "point", "calculations", "." ]
python
train
37.75
saltstack/salt
salt/modules/iptables.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/iptables.py#L632-L654
def set_policy(table='filter', chain=None, policy=None, family='ipv4'): ''' Set the current policy for the specified table/chain CLI Example: .. code-block:: bash salt '*' iptables.set_policy filter INPUT ACCEPT IPv6: salt '*' iptables.set_policy filter INPUT ACCEPT family=ip...
[ "def", "set_policy", "(", "table", "=", "'filter'", ",", "chain", "=", "None", ",", "policy", "=", "None", ",", "family", "=", "'ipv4'", ")", ":", "if", "not", "chain", ":", "return", "'Error: Chain needs to be specified'", "if", "not", "policy", ":", "ret...
Set the current policy for the specified table/chain CLI Example: .. code-block:: bash salt '*' iptables.set_policy filter INPUT ACCEPT IPv6: salt '*' iptables.set_policy filter INPUT ACCEPT family=ipv6
[ "Set", "the", "current", "policy", "for", "the", "specified", "table", "/", "chain" ]
python
train
29.173913
twisted/mantissa
xmantissa/sharing.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/sharing.py#L879-L883
def unShare(sharedItem): """ Remove all instances of this item from public or shared view. """ sharedItem.store.query(Share, Share.sharedItem == sharedItem).deleteFromStore()
[ "def", "unShare", "(", "sharedItem", ")", ":", "sharedItem", ".", "store", ".", "query", "(", "Share", ",", "Share", ".", "sharedItem", "==", "sharedItem", ")", ".", "deleteFromStore", "(", ")" ]
Remove all instances of this item from public or shared view.
[ "Remove", "all", "instances", "of", "this", "item", "from", "public", "or", "shared", "view", "." ]
python
train
37.2
saltstack/salt
salt/modules/boto_iam.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_iam.py#L744-L773
def create_login_profile(user_name, password, region=None, key=None, keyid=None, profile=None): ''' Creates a login profile for the specified user, give the user the ability to access AWS services and the AWS Management Console. .. versionadded:: 2015.8.0 CLI Example: ...
[ "def", "create_login_profile", "(", "user_name", ",", "password", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "user", "=", "get_user", "(", "user_name", ",", "region", ",", "key...
Creates a login profile for the specified user, give the user the ability to access AWS services and the AWS Management Console. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.create_login_profile user_name password
[ "Creates", "a", "login", "profile", "for", "the", "specified", "user", "give", "the", "user", "the", "ability", "to", "access", "AWS", "services", "and", "the", "AWS", "Management", "Console", "." ]
python
train
35.866667
twilio/twilio-python
twilio/rest/taskrouter/v1/workspace/event.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/taskrouter/v1/workspace/event.py#L259-L268
def get_instance(self, payload): """ Build an instance of EventInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.event.EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance """ retur...
[ "def", "get_instance", "(", "self", ",", "payload", ")", ":", "return", "EventInstance", "(", "self", ".", "_version", ",", "payload", ",", "workspace_sid", "=", "self", ".", "_solution", "[", "'workspace_sid'", "]", ",", ")" ]
Build an instance of EventInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.event.EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance
[ "Build", "an", "instance", "of", "EventInstance" ]
python
train
39.9
saltstack/salt
salt/fileserver/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/__init__.py#L176-L186
def write_file_list_cache(opts, data, list_cache, w_lock): ''' Checks the cache file to see if there is a new enough file list cache, and returns the match (if found, along with booleans used by the fileserver backend to determine if the cache needs to be refreshed/written). ''' serial = salt.pa...
[ "def", "write_file_list_cache", "(", "opts", ",", "data", ",", "list_cache", ",", "w_lock", ")", ":", "serial", "=", "salt", ".", "payload", ".", "Serial", "(", "opts", ")", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "list_cache", "...
Checks the cache file to see if there is a new enough file list cache, and returns the match (if found, along with booleans used by the fileserver backend to determine if the cache needs to be refreshed/written).
[ "Checks", "the", "cache", "file", "to", "see", "if", "there", "is", "a", "new", "enough", "file", "list", "cache", "and", "returns", "the", "match", "(", "if", "found", "along", "with", "booleans", "used", "by", "the", "fileserver", "backend", "to", "det...
python
train
45.818182
apple/turicreate
src/unity/python/turicreate/toolkits/_mxnet/_mxnet_to_coreml/_layers.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_mxnet/_mxnet_to_coreml/_layers.py#L831-L875
def convert_embedding(net, node, model, builder): """Convert an embedding layer from mxnet to coreml. Parameters ---------- net: network A mxnet network object. node: layer Node to convert. model: model An model for MXNet builder: NeuralNetworkBuilder A ne...
[ "def", "convert_embedding", "(", "net", ",", "node", ",", "model", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "inputs", "=", "node", "[...
Convert an embedding layer from mxnet to coreml. Parameters ---------- net: network A mxnet network object. node: layer Node to convert. model: model An model for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "an", "embedding", "layer", "from", "mxnet", "to", "coreml", "." ]
python
train
30.244444
jobovy/galpy
galpy/df/streamdf.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/streamdf.py#L1737-L1768
def _find_closest_trackpointaA(self,Or,Op,Oz,ar,ap,az,interp=True): """ NAME: _find_closest_trackpointaA PURPOSE: find the closest point on the stream track to a given point in frequency-angle coordinates INPUT: Or,Op,Oz,ar,ap,az - phase-space ...
[ "def", "_find_closest_trackpointaA", "(", "self", ",", "Or", ",", "Op", ",", "Oz", ",", "ar", ",", "ap", ",", "az", ",", "interp", "=", "True", ")", ":", "#Calculate angle offset along the stream parallel to the stream track,", "# finding first the angle among a few wra...
NAME: _find_closest_trackpointaA PURPOSE: find the closest point on the stream track to a given point in frequency-angle coordinates INPUT: Or,Op,Oz,ar,ap,az - phase-space coordinates of the given point interp= (True), if True, return the index of t...
[ "NAME", ":", "_find_closest_trackpointaA", "PURPOSE", ":", "find", "the", "closest", "point", "on", "the", "stream", "track", "to", "a", "given", "point", "in", "frequency", "-", "angle", "coordinates", "INPUT", ":", "Or", "Op", "Oz", "ar", "ap", "az", "-"...
python
train
47.84375
gawel/panoramisk
panoramisk/fast_agi.py
https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L18-L50
def send_command(self, command): """Send a command for FastAGI request: :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds' :type command: String :Example: :: @asyncio.coroutine def call_waiting(request): ...
[ "def", "send_command", "(", "self", ",", "command", ")", ":", "command", "+=", "'\\n'", "self", ".", "writer", ".", "write", "(", "command", ".", "encode", "(", "self", ".", "encoding", ")", ")", "yield", "from", "self", ".", "writer", ".", "drain", ...
Send a command for FastAGI request: :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds' :type command: String :Example: :: @asyncio.coroutine def call_waiting(request): print(['AGI variables:', request.headers]) ...
[ "Send", "a", "command", "for", "FastAGI", "request", ":" ]
python
test
36.848485
richardkiss/pycoin
pycoin/key/Key.py
https://github.com/richardkiss/pycoin/blob/1e8d0d9fe20ce0347b97847bb529cd1bd84c7442/pycoin/key/Key.py#L137-L141
def address(self, is_compressed=None): """ Return the public address representation of this key, if available. """ return self._network.address.for_p2pkh(self.hash160(is_compressed=is_compressed))
[ "def", "address", "(", "self", ",", "is_compressed", "=", "None", ")", ":", "return", "self", ".", "_network", ".", "address", ".", "for_p2pkh", "(", "self", ".", "hash160", "(", "is_compressed", "=", "is_compressed", ")", ")" ]
Return the public address representation of this key, if available.
[ "Return", "the", "public", "address", "representation", "of", "this", "key", "if", "available", "." ]
python
train
44.8
romanz/trezor-agent
libagent/gpg/keyring.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/gpg/keyring.py#L243-L249
def export_public_keys(env=None, sp=subprocess): """Export all GPG public keys.""" args = gpg_command(['--export']) result = check_output(args=args, env=env, sp=sp) if not result: raise KeyError('No GPG public keys found at env: {!r}'.format(env)) return result
[ "def", "export_public_keys", "(", "env", "=", "None", ",", "sp", "=", "subprocess", ")", ":", "args", "=", "gpg_command", "(", "[", "'--export'", "]", ")", "result", "=", "check_output", "(", "args", "=", "args", ",", "env", "=", "env", ",", "sp", "=...
Export all GPG public keys.
[ "Export", "all", "GPG", "public", "keys", "." ]
python
train
40.428571
eqcorrscan/EQcorrscan
eqcorrscan/core/match_filter.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/core/match_filter.py#L743-L810
def read(self, filename=None, read_detection_catalog=True): """ Read a Party from a file. :type filename: str :param filename: File to read from - can be a list of files, and can contain wildcards. :type read_detection_catalog: bool :param read_de...
[ "def", "read", "(", "self", ",", "filename", "=", "None", ",", "read_detection_catalog", "=", "True", ")", ":", "tribe", "=", "Tribe", "(", ")", "families", "=", "[", "]", "if", "filename", "is", "None", ":", "# If there is no filename given, then read the exa...
Read a Party from a file. :type filename: str :param filename: File to read from - can be a list of files, and can contain wildcards. :type read_detection_catalog: bool :param read_detection_catalog: Whether to read the detection catalog or not, if Fa...
[ "Read", "a", "Party", "from", "a", "file", "." ]
python
train
41.897059
alex-kostirin/pyatomac
atomac/Clipboard.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/Clipboard.py#L99-L130
def copy(cls, data): """Set the clipboard data ('Copy'). Parameters: data to set (string) Optional: datatype if it's not a string Returns: True / False on successful copy, Any exception raised (like passes the NSPasteboardCommunicationError) should be caught ...
[ "def", "copy", "(", "cls", ",", "data", ")", ":", "pp", "=", "pprint", ".", "PrettyPrinter", "(", ")", "copy_data", "=", "'Data to copy (put in pasteboard): %s'", "logging", ".", "debug", "(", "copy_data", "%", "pp", ".", "pformat", "(", "data", ")", ")", ...
Set the clipboard data ('Copy'). Parameters: data to set (string) Optional: datatype if it's not a string Returns: True / False on successful copy, Any exception raised (like passes the NSPasteboardCommunicationError) should be caught by the caller.
[ "Set", "the", "clipboard", "data", "(", "Copy", ")", "." ]
python
valid
34.5625
mnooner256/pyqrcode
pyqrcode/builder.py
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L146-L158
def encode(self): """This method encodes the data into a binary string using the appropriate algorithm specified by the mode. """ if self.mode == tables.modes['alphanumeric']: encoded = self.encode_alphanumeric() elif self.mode == tables.modes['numeric']: ...
[ "def", "encode", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "tables", ".", "modes", "[", "'alphanumeric'", "]", ":", "encoded", "=", "self", ".", "encode_alphanumeric", "(", ")", "elif", "self", ".", "mode", "==", "tables", ".", "modes", ...
This method encodes the data into a binary string using the appropriate algorithm specified by the mode.
[ "This", "method", "encodes", "the", "data", "into", "a", "binary", "string", "using", "the", "appropriate", "algorithm", "specified", "by", "the", "mode", "." ]
python
train
41.923077
pandas-profiling/pandas-profiling
pandas_profiling/__init__.py
https://github.com/pandas-profiling/pandas-profiling/blob/003d236daee8b7aca39c62708b18d59bced0bc03/pandas_profiling/__init__.py#L86-L104
def get_rejected_variables(self, threshold=0.9): """Return a list of variable names being rejected for high correlation with one of remaining variables. Parameters: ---------- threshold : float Correlation value which is above the threshold are rejected ...
[ "def", "get_rejected_variables", "(", "self", ",", "threshold", "=", "0.9", ")", ":", "variable_profile", "=", "self", ".", "description_set", "[", "'variables'", "]", "result", "=", "[", "]", "if", "hasattr", "(", "variable_profile", ",", "'correlation'", ")"...
Return a list of variable names being rejected for high correlation with one of remaining variables. Parameters: ---------- threshold : float Correlation value which is above the threshold are rejected Returns ------- list The lis...
[ "Return", "a", "list", "of", "variable", "names", "being", "rejected", "for", "high", "correlation", "with", "one", "of", "remaining", "variables", "." ]
python
train
37.263158
jtwhite79/pyemu
pyemu/la.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/la.py#L245-L258
def __load_jco(self): """private method to set the jco attribute from a file or a matrix object """ if self.jco_arg is None: return None #raise Exception("linear_analysis.__load_jco(): jco_arg is None") if isinstance(self.jco_arg, Matrix): self.__jco =...
[ "def", "__load_jco", "(", "self", ")", ":", "if", "self", ".", "jco_arg", "is", "None", ":", "return", "None", "#raise Exception(\"linear_analysis.__load_jco(): jco_arg is None\")", "if", "isinstance", "(", "self", ".", "jco_arg", ",", "Matrix", ")", ":", "self", ...
private method to set the jco attribute from a file or a matrix object
[ "private", "method", "to", "set", "the", "jco", "attribute", "from", "a", "file", "or", "a", "matrix", "object" ]
python
train
45.357143
maceoutliner/django-fiction-outlines
fiction_outlines/receivers.py
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/receivers.py#L206-L253
def validate_generations_for_story_elements( sender, instance, action, target_node_type=None, target_node=None, pos=None, *args, **kwargs ): ''' Unlike arc nodes, for which we just warn about structure, the story tree allowed parent/child rules...
[ "def", "validate_generations_for_story_elements", "(", "sender", ",", "instance", ",", "action", ",", "target_node_type", "=", "None", ",", "target_node", "=", "None", ",", "pos", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "act...
Unlike arc nodes, for which we just warn about structure, the story tree allowed parent/child rules must be strictly enforced.
[ "Unlike", "arc", "nodes", "for", "which", "we", "just", "warn", "about", "structure", "the", "story", "tree", "allowed", "parent", "/", "child", "rules", "must", "be", "strictly", "enforced", "." ]
python
train
51.895833
funilrys/PyFunceble
PyFunceble/directory_structure.py
https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/directory_structure.py#L484-L607
def restore(self): """ Restore the 'output/' directory structure based on the `dir_structure.json` file. """ # We get the structure we have to create/apply. structure = self._get_structure() # We get the list of key which is implicitly the list of directory to recreate....
[ "def", "restore", "(", "self", ")", ":", "# We get the structure we have to create/apply.", "structure", "=", "self", ".", "_get_structure", "(", ")", "# We get the list of key which is implicitly the list of directory to recreate.", "list_of_key", "=", "list", "(", "structure"...
Restore the 'output/' directory structure based on the `dir_structure.json` file.
[ "Restore", "the", "output", "/", "directory", "structure", "based", "on", "the", "dir_structure", ".", "json", "file", "." ]
python
test
39.225806
CxAalto/gtfspy
gtfspy/gtfs.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1204-L1251
def get_tripIs_within_range_by_dsut(self, start_time_ut, end_time_ut): """ Obtain a list of trip_Is that take place during a time interval. The trip needs to be only partially overlapping with the given time interval...
[ "def", "get_tripIs_within_range_by_dsut", "(", "self", ",", "start_time_ut", ",", "end_time_ut", ")", ":", "cur", "=", "self", ".", "conn", ".", "cursor", "(", ")", "assert", "start_time_ut", "<=", "end_time_ut", "dst_ut", ",", "st_ds", ",", "et_ds", "=", "s...
Obtain a list of trip_Is that take place during a time interval. The trip needs to be only partially overlapping with the given time interval. The grouping by dsut (day_start_ut) is required as same trip_I could take place on multiple days. Parameters ---------- start_ti...
[ "Obtain", "a", "list", "of", "trip_Is", "that", "take", "place", "during", "a", "time", "interval", ".", "The", "trip", "needs", "to", "be", "only", "partially", "overlapping", "with", "the", "given", "time", "interval", ".", "The", "grouping", "by", "dsut...
python
valid
38.916667
GoogleCloudPlatform/python-repo-tools
gcp_devrel/tools/appengine.py
https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/appengine.py#L66-L86
def is_existing_up_to_date(destination, latest_version): """Returns False if there is no existing install or if the existing install is out of date. Otherwise, returns True.""" version_path = os.path.join( destination, 'google_appengine', 'VERSION') if not os.path.exists(version_path): ...
[ "def", "is_existing_up_to_date", "(", "destination", ",", "latest_version", ")", ":", "version_path", "=", "os", ".", "path", ".", "join", "(", "destination", ",", "'google_appengine'", ",", "'VERSION'", ")", "if", "not", "os", ".", "path", ".", "exists", "(...
Returns False if there is no existing install or if the existing install is out of date. Otherwise, returns True.
[ "Returns", "False", "if", "there", "is", "no", "existing", "install", "or", "if", "the", "existing", "install", "is", "out", "of", "date", ".", "Otherwise", "returns", "True", "." ]
python
train
30.619048
swharden/SWHLab
swhlab/core.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L300-L307
def get_protocol_sequence(self,sweep): """ given a sweep, return the protocol as condensed sequence. This is better for comparing similarities and determining steps. There should be no duplicate numbers. """ self.setsweep(sweep) return list(self.protoSeqX),list(se...
[ "def", "get_protocol_sequence", "(", "self", ",", "sweep", ")", ":", "self", ".", "setsweep", "(", "sweep", ")", "return", "list", "(", "self", ".", "protoSeqX", ")", ",", "list", "(", "self", ".", "protoSeqY", ")" ]
given a sweep, return the protocol as condensed sequence. This is better for comparing similarities and determining steps. There should be no duplicate numbers.
[ "given", "a", "sweep", "return", "the", "protocol", "as", "condensed", "sequence", ".", "This", "is", "better", "for", "comparing", "similarities", "and", "determining", "steps", ".", "There", "should", "be", "no", "duplicate", "numbers", "." ]
python
valid
40.75
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L1639-L1643
def at_depth(self, level): """ Locate the last config item at a specified depth """ return Zconfig(lib.zconfig_at_depth(self._as_parameter_, level), False)
[ "def", "at_depth", "(", "self", ",", "level", ")", ":", "return", "Zconfig", "(", "lib", ".", "zconfig_at_depth", "(", "self", ".", "_as_parameter_", ",", "level", ")", ",", "False", ")" ]
Locate the last config item at a specified depth
[ "Locate", "the", "last", "config", "item", "at", "a", "specified", "depth" ]
python
train
36.6
TissueMAPS/TmClient
src/python/tmclient/api.py
https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L486-L510
def delete_plate(self, name): '''Deletes a plate. Parameters ---------- name: str name of the plate that should be deleted See also -------- :func:`tmserver.api.plate.delete_plate` :class:`tmlib.models.plate.Plate` ''' logger....
[ "def", "delete_plate", "(", "self", ",", "name", ")", ":", "logger", ".", "info", "(", "'delete plate \"%s\" of experiment \"%s\"'", ",", "name", ",", "self", ".", "experiment_name", ")", "plate_id", "=", "self", ".", "_get_plate_id", "(", "name", ")", "url", ...
Deletes a plate. Parameters ---------- name: str name of the plate that should be deleted See also -------- :func:`tmserver.api.plate.delete_plate` :class:`tmlib.models.plate.Plate`
[ "Deletes", "a", "plate", "." ]
python
train
28.56
jmoiron/johnny-cache
johnny/cache.py
https://github.com/jmoiron/johnny-cache/blob/d96ea94c5dfcde517ff8f65d6ba4e435d8a0168c/johnny/cache.py#L178-L183
def gen_multi_key(self, values, db='default'): """Takes a list of generations (not table keys) and returns a key.""" db = settings.DB_CACHE_KEYS[db] if db and len(db) > 100: db = db[0:68] + self.gen_key(db[68:]) return '%s_%s_multi_%s' % (self.prefix, db, self.gen_key(*values...
[ "def", "gen_multi_key", "(", "self", ",", "values", ",", "db", "=", "'default'", ")", ":", "db", "=", "settings", ".", "DB_CACHE_KEYS", "[", "db", "]", "if", "db", "and", "len", "(", "db", ")", ">", "100", ":", "db", "=", "db", "[", "0", ":", "...
Takes a list of generations (not table keys) and returns a key.
[ "Takes", "a", "list", "of", "generations", "(", "not", "table", "keys", ")", "and", "returns", "a", "key", "." ]
python
train
52.833333
darkfeline/animanager
animanager/commands/unregister.py
https://github.com/darkfeline/animanager/blob/55d92e4cbdc12aac8ebe302420d2cff3fa9fa148/animanager/commands/unregister.py#L22-L32
def command(state, args): """Unregister watching regexp for an anime.""" args = parser.parse_args(args[1:]) if args.complete: query.files.delete_regexp_complete(state.db) else: if args.aid is None: parser.print_help() else: aid = state.results.parse_aid(ar...
[ "def", "command", "(", "state", ",", "args", ")", ":", "args", "=", "parser", ".", "parse_args", "(", "args", "[", "1", ":", "]", ")", "if", "args", ".", "complete", ":", "query", ".", "files", ".", "delete_regexp_complete", "(", "state", ".", "db", ...
Unregister watching regexp for an anime.
[ "Unregister", "watching", "regexp", "for", "an", "anime", "." ]
python
train
35.272727
jwkvam/plotlywrapper
plotlywrapper.py
https://github.com/jwkvam/plotlywrapper/blob/762b42912e824fecb1212c186900f2ebdd0ab12b/plotlywrapper.py#L345-L360
def ylim(self, low, high, index=1): """Set yaxis limits. Parameters ---------- low : number high : number index : int, optional Returns ------- Chart """ self.layout['yaxis' + str(index)]['range'] = [low, high] return sel...
[ "def", "ylim", "(", "self", ",", "low", ",", "high", ",", "index", "=", "1", ")", ":", "self", ".", "layout", "[", "'yaxis'", "+", "str", "(", "index", ")", "]", "[", "'range'", "]", "=", "[", "low", ",", "high", "]", "return", "self" ]
Set yaxis limits. Parameters ---------- low : number high : number index : int, optional Returns ------- Chart
[ "Set", "yaxis", "limits", "." ]
python
train
19.125
SectorLabs/django-postgres-extra
psqlextra/backend/hstore_required.py
https://github.com/SectorLabs/django-postgres-extra/blob/eef2ed5504d225858d4e4f5d77a838082ca6053e/psqlextra/backend/hstore_required.py#L134-L149
def _rename_hstore_required(self, old_table_name, new_table_name, old_field, new_field, key): """Renames an existing REQUIRED CONSTRAINT for the specified hstore key.""" old_name = self._required_constraint_name( old_table_name, old_field, key) ...
[ "def", "_rename_hstore_required", "(", "self", ",", "old_table_name", ",", "new_table_name", ",", "old_field", ",", "new_field", ",", "key", ")", ":", "old_name", "=", "self", ".", "_required_constraint_name", "(", "old_table_name", ",", "old_field", ",", "key", ...
Renames an existing REQUIRED CONSTRAINT for the specified hstore key.
[ "Renames", "an", "existing", "REQUIRED", "CONSTRAINT", "for", "the", "specified", "hstore", "key", "." ]
python
test
39.375
Jajcus/pyxmpp2
examples/echobot.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/examples/echobot.py#L96-L142
def main(): """Parse the command-line arguments and run the bot.""" parser = argparse.ArgumentParser(description = 'XMPP echo bot', parents = [XMPPSettings.get_arg_parser()]) parser.add_argument('jid', metavar = 'JID', help = 'The ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'XMPP echo bot'", ",", "parents", "=", "[", "XMPPSettings", ".", "get_arg_parser", "(", ")", "]", ")", "parser", ".", "add_argument", "(", "'jid'", ",...
Parse the command-line arguments and run the bot.
[ "Parse", "the", "command", "-", "line", "arguments", "and", "run", "the", "bot", "." ]
python
valid
39.255319
pudo/googlesheets
googlesheets/spreadsheet.py
https://github.com/pudo/googlesheets/blob/c38725d79bfe048c0519a674019ba313dfc5bfb0/googlesheets/spreadsheet.py#L92-L99
def by_id(cls, id, conn=None, google_user=None, google_password=None): """ Open a spreadsheet via its resource ID. This is more precise than opening a document by title, and should be used with preference. """ conn = Connection.connect(conn=conn, google_user=google_user, ...
[ "def", "by_id", "(", "cls", ",", "id", ",", "conn", "=", "None", ",", "google_user", "=", "None", ",", "google_password", "=", "None", ")", ":", "conn", "=", "Connection", ".", "connect", "(", "conn", "=", "conn", ",", "google_user", "=", "google_user"...
Open a spreadsheet via its resource ID. This is more precise than opening a document by title, and should be used with preference.
[ "Open", "a", "spreadsheet", "via", "its", "resource", "ID", ".", "This", "is", "more", "precise", "than", "opening", "a", "document", "by", "title", "and", "should", "be", "used", "with", "preference", "." ]
python
train
51.75
kgori/treeCl
treeCl/bootstrap.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/bootstrap.py#L442-L450
def _make_A_and_part_of_b_adjacent(self, ref_crds): """ Make A and part of b. See docstring of this class for answer to "What are A and b?" """ rot = self._rotate_rows(ref_crds) A = 2*(rot - ref_crds) partial_b = (rot**2 - ref_crds**2).sum(1) return A, par...
[ "def", "_make_A_and_part_of_b_adjacent", "(", "self", ",", "ref_crds", ")", ":", "rot", "=", "self", ".", "_rotate_rows", "(", "ref_crds", ")", "A", "=", "2", "*", "(", "rot", "-", "ref_crds", ")", "partial_b", "=", "(", "rot", "**", "2", "-", "ref_crd...
Make A and part of b. See docstring of this class for answer to "What are A and b?"
[ "Make", "A", "and", "part", "of", "b", ".", "See", "docstring", "of", "this", "class", "for", "answer", "to", "What", "are", "A", "and", "b?" ]
python
train
35.333333
romana/vpc-router
vpcrouter/vpc/__init__.py
https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/vpc/__init__.py#L651-L697
def process_route_spec_config(con, vpc_info, route_spec, failed_ips, questionable_ips): """ Look through the route spec and update routes accordingly. Idea: Make sure we have a route for each CIDR. If we have a route to any of the IP addresses for a given CIDR then we are...
[ "def", "process_route_spec_config", "(", "con", ",", "vpc_info", ",", "route_spec", ",", "failed_ips", ",", "questionable_ips", ")", ":", "if", "CURRENT_STATE", ".", "_stop_all", ":", "logging", ".", "debug", "(", "\"Routespec processing. Stop requested, abort operation...
Look through the route spec and update routes accordingly. Idea: Make sure we have a route for each CIDR. If we have a route to any of the IP addresses for a given CIDR then we are good. Otherwise, pick one (usually the first) IP and create a route to that IP. If a route points at a failed or que...
[ "Look", "through", "the", "route", "spec", "and", "update", "routes", "accordingly", "." ]
python
train
39.361702
iron-io/iron_mq_python
iron_mq.py
https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L126-L133
def get(self, max=None, timeout=None, wait=None): """Deprecated. Use Queue.reserve() instead. Executes an HTTP request to get a message off of a queue. Keyword arguments: max -- The maximum number of messages to pull. Defaults to 1. """ response = self.reserve(max, timeout, wait...
[ "def", "get", "(", "self", ",", "max", "=", "None", ",", "timeout", "=", "None", ",", "wait", "=", "None", ")", ":", "response", "=", "self", ".", "reserve", "(", "max", ",", "timeout", ",", "wait", ")", "return", "response" ]
Deprecated. Use Queue.reserve() instead. Executes an HTTP request to get a message off of a queue. Keyword arguments: max -- The maximum number of messages to pull. Defaults to 1.
[ "Deprecated", ".", "Use", "Queue", ".", "reserve", "()", "instead", ".", "Executes", "an", "HTTP", "request", "to", "get", "a", "message", "off", "of", "a", "queue", "." ]
python
train
42.25
the01/python-flotils
flotils/loadable.py
https://github.com/the01/python-flotils/blob/5954712776bb590107e5b2f4362d010bf74f77a1/flotils/loadable.py#L204-L257
def save_json_file( file, val, pretty=False, compact=True, sort=True, encoder=None ): """ Save data to json file :param file: Writable object or path to file :type file: FileIO | str | unicode :param val: Value or struct to save :type val: None | int | float | str | list | dict ...
[ "def", "save_json_file", "(", "file", ",", "val", ",", "pretty", "=", "False", ",", "compact", "=", "True", ",", "sort", "=", "True", ",", "encoder", "=", "None", ")", ":", "# TODO: make pretty/compact into one bool?", "if", "encoder", "is", "None", ":", "...
Save data to json file :param file: Writable object or path to file :type file: FileIO | str | unicode :param val: Value or struct to save :type val: None | int | float | str | list | dict :param pretty: Format data to be readable (default: False) :type pretty: bool :param compact: Format d...
[ "Save", "data", "to", "json", "file" ]
python
train
28.166667
galaxyproject/pulsar
pulsar/client/job_directory.py
https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/job_directory.py#L71-L76
def calculate_path(self, remote_relative_path, input_type): """ Only for used by Pulsar client, should override for managers to enforce security and make the directory if needed. """ directory, allow_nested_files = self._directory_for_file_type(input_type) return self.path_helper...
[ "def", "calculate_path", "(", "self", ",", "remote_relative_path", ",", "input_type", ")", ":", "directory", ",", "allow_nested_files", "=", "self", ".", "_directory_for_file_type", "(", "input_type", ")", "return", "self", ".", "path_helper", ".", "remote_join", ...
Only for used by Pulsar client, should override for managers to enforce security and make the directory if needed.
[ "Only", "for", "used", "by", "Pulsar", "client", "should", "override", "for", "managers", "to", "enforce", "security", "and", "make", "the", "directory", "if", "needed", "." ]
python
train
60
SpriteLink/NIPAP
nipap/nipap/authlib.py
https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap/nipap/authlib.py#L697-L705
def list_users(self): """ List all users. """ sql = "SELECT * FROM user ORDER BY username" self._db_curs.execute(sql) users = list() for row in self._db_curs: users.append(dict(row)) return users
[ "def", "list_users", "(", "self", ")", ":", "sql", "=", "\"SELECT * FROM user ORDER BY username\"", "self", ".", "_db_curs", ".", "execute", "(", "sql", ")", "users", "=", "list", "(", ")", "for", "row", "in", "self", ".", "_db_curs", ":", "users", ".", ...
List all users.
[ "List", "all", "users", "." ]
python
train
28.333333
gabstopper/smc-python
smc/elements/group.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/group.py#L53-L82
def update_members(self, members, append_lists=False, remove_members=False): """ Update group members with member list. Set append=True to append to existing members, or append=False to overwrite. :param list members: new members for group by href or Element :type members: list[...
[ "def", "update_members", "(", "self", ",", "members", ",", "append_lists", "=", "False", ",", "remove_members", "=", "False", ")", ":", "if", "members", ":", "elements", "=", "[", "element_resolver", "(", "element", ")", "for", "element", "in", "members", ...
Update group members with member list. Set append=True to append to existing members, or append=False to overwrite. :param list members: new members for group by href or Element :type members: list[str, Element] :param bool append_lists: whether to append :param bool remove_memb...
[ "Update", "group", "members", "with", "member", "list", ".", "Set", "append", "=", "True", "to", "append", "to", "existing", "members", "or", "append", "=", "False", "to", "overwrite", "." ]
python
train
40.4
fracpete/python-weka-wrapper3
python/weka/experiments.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/experiments.py#L550-L561
def set_stdev(self, col, row, stdev): """ Sets the standard deviation at this location (if valid location). :param col: the 0-based column index :type col: int :param row: the 0-based row index :type row: int :param stdev: the standard deviation to set :t...
[ "def", "set_stdev", "(", "self", ",", "col", ",", "row", ",", "stdev", ")", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setStdDev\"", ",", "\"(IID)V\"", ",", "col", ",", "row", ",", "stdev", ")" ]
Sets the standard deviation at this location (if valid location). :param col: the 0-based column index :type col: int :param row: the 0-based row index :type row: int :param stdev: the standard deviation to set :type stdev: float
[ "Sets", "the", "standard", "deviation", "at", "this", "location", "(", "if", "valid", "location", ")", "." ]
python
train
34.583333
Alignak-monitoring/alignak
alignak/http/client.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/client.py#L219-L247
def post(self, path, args, wait=False): """POST an HTTP request to a daemon :param path: path to do the request :type path: str :param args: args to add in the request :type args: dict :param wait: True for a long timeout :type wait: bool :return: Content...
[ "def", "post", "(", "self", ",", "path", ",", "args", ",", "wait", "=", "False", ")", ":", "uri", "=", "self", ".", "make_uri", "(", "path", ")", "timeout", "=", "self", ".", "make_timeout", "(", "wait", ")", "for", "(", "key", ",", "value", ")",...
POST an HTTP request to a daemon :param path: path to do the request :type path: str :param args: args to add in the request :type args: dict :param wait: True for a long timeout :type wait: bool :return: Content of the HTTP response if server returned 200 ...
[ "POST", "an", "HTTP", "request", "to", "a", "daemon" ]
python
train
44.586207
SoftwareDefinedBuildings/XBOS
apps/Data_quality_analysis/Wrapper.py
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Wrapper.py#L114-L128
def get_global_count(self): """ Return global count (used for naming of .json and .png files) Returns ------- int Global count """ # Check current number of json files in results directory and dump current json in new file path_to_json = se...
[ "def", "get_global_count", "(", "self", ")", ":", "# Check current number of json files in results directory and dump current json in new file", "path_to_json", "=", "self", ".", "results_folder_name", "+", "'/'", "json_files", "=", "[", "pos_json", "for", "pos_json", "in", ...
Return global count (used for naming of .json and .png files) Returns ------- int Global count
[ "Return", "global", "count", "(", "used", "for", "naming", "of", ".", "json", "and", ".", "png", "files", ")" ]
python
train
34.933333
incuna/incuna-auth
incuna_auth/middleware/permission_feincms.py
https://github.com/incuna/incuna-auth/blob/949ccd922da15a4b5de17b9595cc8f5114d5385c/incuna_auth/middleware/permission_feincms.py#L31-L41
def _get_page_from_path(self, path): """ Fetches the FeinCMS Page object that the path points to. Override this to deal with different types of object from Page. """ from feincms.module.page.models import Page try: return Page.objects.best_match_for_path(path...
[ "def", "_get_page_from_path", "(", "self", ",", "path", ")", ":", "from", "feincms", ".", "module", ".", "page", ".", "models", "import", "Page", "try", ":", "return", "Page", ".", "objects", ".", "best_match_for_path", "(", "path", ")", "except", "Page", ...
Fetches the FeinCMS Page object that the path points to. Override this to deal with different types of object from Page.
[ "Fetches", "the", "FeinCMS", "Page", "object", "that", "the", "path", "points", "to", "." ]
python
train
33.545455
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L3313-L3344
def restart_program(self): """Restart Alignak Format of the line that triggers function call:: RESTART_PROGRAM :return: None """ restart_cmd = self.commands.find_by_name('restart-alignak') if not restart_cmd: logger.error("Cannot restart Alignak : mi...
[ "def", "restart_program", "(", "self", ")", ":", "restart_cmd", "=", "self", ".", "commands", ".", "find_by_name", "(", "'restart-alignak'", ")", "if", "not", "restart_cmd", ":", "logger", ".", "error", "(", "\"Cannot restart Alignak : missing command named\"", "\" ...
Restart Alignak Format of the line that triggers function call:: RESTART_PROGRAM :return: None
[ "Restart", "Alignak", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
43.96875
jeffrimko/Qprompt
lib/qprompt.py
https://github.com/jeffrimko/Qprompt/blob/1887c53656dfecac49e0650e0f912328801cbb83/lib/qprompt.py#L657-L672
def wrap(item, args=None, krgs=None, **kwargs): """Wraps the given item content between horizontal lines. Item can be a string or a function. **Examples**: :: qprompt.wrap("Hi, this will be wrapped.") # String item. qprompt.wrap(myfunc, [arg1, arg2], {'krgk': krgv}) # Func item. "...
[ "def", "wrap", "(", "item", ",", "args", "=", "None", ",", "krgs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "Wrap", "(", "*", "*", "kwargs", ")", ":", "if", "callable", "(", "item", ")", ":", "args", "=", "args", "or", "[", "]"...
Wraps the given item content between horizontal lines. Item can be a string or a function. **Examples**: :: qprompt.wrap("Hi, this will be wrapped.") # String item. qprompt.wrap(myfunc, [arg1, arg2], {'krgk': krgv}) # Func item.
[ "Wraps", "the", "given", "item", "content", "between", "horizontal", "lines", ".", "Item", "can", "be", "a", "string", "or", "a", "function", "." ]
python
train
30.5
MAVENSDC/PyTplot
pytplot/staticplot_tavg.py
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/staticplot_tavg.py#L8-L108
def static2dplot_timeaveraged(var, time): """ If the static_taverage option is set in tplot, and is supplied with a time range, then the spectrogram plot(s) for which it is set will have another window pop up, where the displayed y and z values are averaged by the number of seconds between the specified tim...
[ "def", "static2dplot_timeaveraged", "(", "var", ",", "time", ")", ":", "# Grab names of data loaded in as tplot variables.", "names", "=", "list", "(", "pytplot", ".", "data_quants", ".", "keys", "(", ")", ")", "# Get data we'll actually work with here.", "valid_variables...
If the static_taverage option is set in tplot, and is supplied with a time range, then the spectrogram plot(s) for which it is set will have another window pop up, where the displayed y and z values are averaged by the number of seconds between the specified time range.
[ "If", "the", "static_taverage", "option", "is", "set", "in", "tplot", "and", "is", "supplied", "with", "a", "time", "range", "then", "the", "spectrogram", "plot", "(", "s", ")", "for", "which", "it", "is", "set", "will", "have", "another", "window", "pop...
python
train
51.613861
facebook/pyre-check
sapp/sapp/interactive.py
https://github.com/facebook/pyre-check/blob/4a9604d943d28ef20238505a51acfb1f666328d7/sapp/sapp/interactive.py#L1568-L1574
def callable(self) -> Optional[str]: """Show the name of the current callable in the trace""" if self.current_trace_frame_index != -1: return self._get_callable_from_trace_tuple( self.trace_tuples[self.current_trace_frame_index] )[0] return None
[ "def", "callable", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "current_trace_frame_index", "!=", "-", "1", ":", "return", "self", ".", "_get_callable_from_trace_tuple", "(", "self", ".", "trace_tuples", "[", "self", ".", "...
Show the name of the current callable in the trace
[ "Show", "the", "name", "of", "the", "current", "callable", "in", "the", "trace" ]
python
train
43.285714
googledatalab/pydatalab
google/datalab/ml/_metrics.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_metrics.py#L374-L404
def rmse(self): """Get RMSE for regression model evaluation results. Returns: the RMSE float number. Raises: Exception if the CSV headers do not include 'target' or 'predicted', or BigQuery does not return 'target' or 'predicted' column, or if target or predicted is not number. ...
[ "def", "rmse", "(", "self", ")", ":", "if", "self", ".", "_input_csv_files", ":", "df", "=", "self", ".", "_get_data_from_csv_files", "(", ")", "if", "'target'", "not", "in", "df", "or", "'predicted'", "not", "in", "df", ":", "raise", "ValueError", "(", ...
Get RMSE for regression model evaluation results. Returns: the RMSE float number. Raises: Exception if the CSV headers do not include 'target' or 'predicted', or BigQuery does not return 'target' or 'predicted' column, or if target or predicted is not number.
[ "Get", "RMSE", "for", "regression", "model", "evaluation", "results", "." ]
python
train
33.483871
SKA-ScienceDataProcessor/integration-prototype
sip/examples/flask_processing_controller/app/old.db/mock/client.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L32-L38
def clear_db(): """Clear the entire db.""" cursor = '0' while cursor != 0: cursor, keys = DB.scan(cursor, match='*', count=5000) if keys: DB.delete(*keys)
[ "def", "clear_db", "(", ")", ":", "cursor", "=", "'0'", "while", "cursor", "!=", "0", ":", "cursor", ",", "keys", "=", "DB", ".", "scan", "(", "cursor", ",", "match", "=", "'*'", ",", "count", "=", "5000", ")", "if", "keys", ":", "DB", ".", "de...
Clear the entire db.
[ "Clear", "the", "entire", "db", "." ]
python
train
26.857143
jason-weirather/py-seq-tools
seqtools/format/sam/bam/bamindex.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L123-L128
def get_coord_line_number(self,coord): """return the one-indexed line number given the coordinates""" if coord[0] in self._coords: if coord[1] in self._coords[coord[0]]: return self._coords[coord[0]][coord[1]] return None
[ "def", "get_coord_line_number", "(", "self", ",", "coord", ")", ":", "if", "coord", "[", "0", "]", "in", "self", ".", "_coords", ":", "if", "coord", "[", "1", "]", "in", "self", ".", "_coords", "[", "coord", "[", "0", "]", "]", ":", "return", "se...
return the one-indexed line number given the coordinates
[ "return", "the", "one", "-", "indexed", "line", "number", "given", "the", "coordinates" ]
python
train
40.333333
NearHuscarl/py-currency
currency/currency.py
https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L144-L150
def update_cache(from_currency, to_currency): """ update from_currency to_currency pair in cache if last update for that pair is over 30 minutes ago by request API info """ if check_update(from_currency, to_currency) is True: ccache[from_currency][to_currency]['value'] = convert_using_api(from_currency, to_currenc...
[ "def", "update_cache", "(", "from_currency", ",", "to_currency", ")", ":", "if", "check_update", "(", "from_currency", ",", "to_currency", ")", "is", "True", ":", "ccache", "[", "from_currency", "]", "[", "to_currency", "]", "[", "'value'", "]", "=", "conver...
update from_currency to_currency pair in cache if last update for that pair is over 30 minutes ago by request API info
[ "update", "from_currency", "to_currency", "pair", "in", "cache", "if", "last", "update", "for", "that", "pair", "is", "over", "30", "minutes", "ago", "by", "request", "API", "info" ]
python
train
57.714286
heikomuller/sco-datastore
scodata/modelrun.py
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/modelrun.py#L456-L522
def create_object(self, name, experiment_id, model_id, argument_defs, arguments=None, properties=None): """Create a model run object with the given list of arguments. The initial state of the object is RUNNING. Raises ValueError if given arguments are invalid. Parameters ------...
[ "def", "create_object", "(", "self", ",", "name", ",", "experiment_id", ",", "model_id", ",", "argument_defs", ",", "arguments", "=", "None", ",", "properties", "=", "None", ")", ":", "# Create a new object identifier.", "identifier", "=", "str", "(", "uuid", ...
Create a model run object with the given list of arguments. The initial state of the object is RUNNING. Raises ValueError if given arguments are invalid. Parameters ---------- name : string User-provided name for the model run experiment_id : string ...
[ "Create", "a", "model", "run", "object", "with", "the", "given", "list", "of", "arguments", ".", "The", "initial", "state", "of", "the", "object", "is", "RUNNING", "." ]
python
train
41.029851
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3801-L3821
def get_string_from_data(self, offset, data): """Get an ASCII string from within the data.""" # OC Patch b = None try: b = data[offset] except IndexError: return '' s = '' while ord(b): s += b ...
[ "def", "get_string_from_data", "(", "self", ",", "offset", ",", "data", ")", ":", "# OC Patch", "b", "=", "None", "try", ":", "b", "=", "data", "[", "offset", "]", "except", "IndexError", ":", "return", "''", "s", "=", "''", "while", "ord", "(", "b",...
Get an ASCII string from within the data.
[ "Get", "an", "ASCII", "string", "from", "within", "the", "data", "." ]
python
train
21.142857
mitsei/dlkit
dlkit/json_/repository/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L274-L299
def get_assets_by_genus_type(self, asset_genus_type): """Gets an ``AssetList`` corresponding to the given asset genus ``Type`` which does not include assets of types derived from the specified ``Type``. In plenary mode, the returned list contains all known assets or an error results. Otherwise,...
[ "def", "get_assets_by_genus_type", "(", "self", ",", "asset_genus_type", ")", ":", "# Implemented from template for", "# osid.resource.ResourceLookupSession.get_resources_by_genus_type", "# NOTE: This implementation currently ignores plenary view", "collection", "=", "JSONClientValidated",...
Gets an ``AssetList`` corresponding to the given asset genus ``Type`` which does not include assets of types derived from the specified ``Type``. In plenary mode, the returned list contains all known assets or an error results. Otherwise, the returned list may contain only those assets that are...
[ "Gets", "an", "AssetList", "corresponding", "to", "the", "given", "asset", "genus", "Type", "which", "does", "not", "include", "assets", "of", "types", "derived", "from", "the", "specified", "Type", "." ]
python
train
54.538462
ewiger/mlab
src/mlab/awmstools.py
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L2021-L2026
def drop(n, it, constructor=list): """ >>> first(10,drop(10,xrange(sys.maxint),iter)) [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] """ return constructor(itertools.islice(it,n,None))
[ "def", "drop", "(", "n", ",", "it", ",", "constructor", "=", "list", ")", ":", "return", "constructor", "(", "itertools", ".", "islice", "(", "it", ",", "n", ",", "None", ")", ")" ]
>>> first(10,drop(10,xrange(sys.maxint),iter)) [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[ ">>>", "first", "(", "10", "drop", "(", "10", "xrange", "(", "sys", ".", "maxint", ")", "iter", "))", "[", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "]" ]
python
train
32.166667
danielholmstrom/dictalchemy
dictalchemy/utils.py
https://github.com/danielholmstrom/dictalchemy/blob/038b8822b0ed66feef78a80b3af8f3a09f795b5a/dictalchemy/utils.py#L44-L183
def asdict(model, exclude=None, exclude_underscore=None, exclude_pk=None, follow=None, include=None, only=None, method='asdict', **kwargs): """Get a dict from a model Using the `method` parameter makes it possible to have multiple methods that formats the result. Additional keyword argument...
[ "def", "asdict", "(", "model", ",", "exclude", "=", "None", ",", "exclude_underscore", "=", "None", ",", "exclude_pk", "=", "None", ",", "follow", "=", "None", ",", "include", "=", "None", ",", "only", "=", "None", ",", "method", "=", "'asdict'", ",", ...
Get a dict from a model Using the `method` parameter makes it possible to have multiple methods that formats the result. Additional keyword arguments will be passed to all relationships that are followed. This can be used to pass on things like request or context. :param follow: List or dict of r...
[ "Get", "a", "dict", "from", "a", "model" ]
python
train
39.707143
guaix-ucm/numina
numina/array/wavecalib/resample.py
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/resample.py#L215-L225
def map_borders(wls): """Compute borders of pixels for interpolation. The border of the pixel is assumed to be midway of the wls """ midpt_wl = 0.5 * (wls[1:] + wls[:-1]) all_borders = np.zeros((wls.shape[0] + 1,)) all_borders[1:-1] = midpt_wl all_borders[0] = 2 * wls[0] - midpt_wl[0] a...
[ "def", "map_borders", "(", "wls", ")", ":", "midpt_wl", "=", "0.5", "*", "(", "wls", "[", "1", ":", "]", "+", "wls", "[", ":", "-", "1", "]", ")", "all_borders", "=", "np", ".", "zeros", "(", "(", "wls", ".", "shape", "[", "0", "]", "+", "1...
Compute borders of pixels for interpolation. The border of the pixel is assumed to be midway of the wls
[ "Compute", "borders", "of", "pixels", "for", "interpolation", "." ]
python
train
34.181818
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L1912-L1923
def disable_contactgroup_host_notifications(self, contactgroup): """Disable host notifications for a contactgroup Format of the line that triggers function call:: DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name> :param contactgroup: contactgroup to disable :type cont...
[ "def", "disable_contactgroup_host_notifications", "(", "self", ",", "contactgroup", ")", ":", "for", "contact_id", "in", "contactgroup", ".", "get_contacts", "(", ")", ":", "self", ".", "disable_contact_host_notifications", "(", "self", ".", "daemon", ".", "contacts...
Disable host notifications for a contactgroup Format of the line that triggers function call:: DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name> :param contactgroup: contactgroup to disable :type contactgroup: alignak.objects.contactgroup.Contactgroup :return: None
[ "Disable", "host", "notifications", "for", "a", "contactgroup", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
44.583333
Scoppio/RagnarokEngine3
RagnarokEngine3/RE3.py
https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/RagnarokEngine3/RE3.py#L3010-L3014
def get_movement_delta(self): """Get the amount the camera has moved since get_movement_delta was last called.""" pos = self.pan - self.previous_pos self.previous_pos = Vector2(self.pan.X, self.pan.Y) return pos
[ "def", "get_movement_delta", "(", "self", ")", ":", "pos", "=", "self", ".", "pan", "-", "self", ".", "previous_pos", "self", ".", "previous_pos", "=", "Vector2", "(", "self", ".", "pan", ".", "X", ",", "self", ".", "pan", ".", "Y", ")", "return", ...
Get the amount the camera has moved since get_movement_delta was last called.
[ "Get", "the", "amount", "the", "camera", "has", "moved", "since", "get_movement_delta", "was", "last", "called", "." ]
python
train
47.8
Azure/blobxfer
blobxfer/operations/azure/file.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/azure/file.py#L306-L329
def create_all_parent_directories(ase, dirs_created, timeout=None): # type: (blobxfer.models.azure.StorageEntity, dict, int) -> None """Create all parent directories for a file :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity :param dict dirs_created: directories already created map ...
[ "def", "create_all_parent_directories", "(", "ase", ",", "dirs_created", ",", "timeout", "=", "None", ")", ":", "# type: (blobxfer.models.azure.StorageEntity, dict, int) -> None", "dirs", "=", "pathlib", ".", "Path", "(", "ase", ".", "name", ")", ".", "parts", "if",...
Create all parent directories for a file :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity :param dict dirs_created: directories already created map :param int timeout: timeout
[ "Create", "all", "parent", "directories", "for", "a", "file", ":", "param", "blobxfer", ".", "models", ".", "azure", ".", "StorageEntity", "ase", ":", "Azure", "StorageEntity", ":", "param", "dict", "dirs_created", ":", "directories", "already", "created", "ma...
python
train
41.208333
pytorch/vision
torchvision/transforms/functional.py
https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L184-L209
def normalize(tensor, mean, std, inplace=False): """Normalize a tensor image with mean and standard deviation. .. note:: This transform acts out of place by default, i.e., it does not mutates the input tensor. See :class:`~torchvision.transforms.Normalize` for more details. Args: tens...
[ "def", "normalize", "(", "tensor", ",", "mean", ",", "std", ",", "inplace", "=", "False", ")", ":", "if", "not", "_is_tensor_image", "(", "tensor", ")", ":", "raise", "TypeError", "(", "'tensor is not a torch image.'", ")", "if", "not", "inplace", ":", "te...
Normalize a tensor image with mean and standard deviation. .. note:: This transform acts out of place by default, i.e., it does not mutates the input tensor. See :class:`~torchvision.transforms.Normalize` for more details. Args: tensor (Tensor): Tensor image of size (C, H, W) to be normal...
[ "Normalize", "a", "tensor", "image", "with", "mean", "and", "standard", "deviation", "." ]
python
test
35.807692
PythonCharmers/python-future
src/future/backports/http/cookiejar.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/cookiejar.py#L1790-L1814
def revert(self, filename=None, ignore_discard=False, ignore_expires=False): """Clear all cookies and reload cookies from a saved file. Raises LoadError (or IOError) if reversion is not successful; the object's state will not be altered if this happens. """ if fi...
[ "def", "revert", "(", "self", ",", "filename", "=", "None", ",", "ignore_discard", "=", "False", ",", "ignore_expires", "=", "False", ")", ":", "if", "filename", "is", "None", ":", "if", "self", ".", "filename", "is", "not", "None", ":", "filename", "=...
Clear all cookies and reload cookies from a saved file. Raises LoadError (or IOError) if reversion is not successful; the object's state will not be altered if this happens.
[ "Clear", "all", "cookies", "and", "reload", "cookies", "from", "a", "saved", "file", "." ]
python
train
32.84
gwastro/pycbc
pycbc/tmpltbank/lattice_utils.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/lattice_utils.py#L22-L86
def generate_hexagonal_lattice(maxv1, minv1, maxv2, minv2, mindist): """ This function generates a 2-dimensional lattice of points using a hexagonal lattice. Parameters ----------- maxv1 : float Largest value in the 1st dimension to cover minv1 : float Smallest value in the ...
[ "def", "generate_hexagonal_lattice", "(", "maxv1", ",", "minv1", ",", "maxv2", ",", "minv2", ",", "mindist", ")", ":", "if", "minv1", ">", "maxv1", ":", "raise", "ValueError", "(", "\"Invalid input to function.\"", ")", "if", "minv2", ">", "maxv2", ":", "rai...
This function generates a 2-dimensional lattice of points using a hexagonal lattice. Parameters ----------- maxv1 : float Largest value in the 1st dimension to cover minv1 : float Smallest value in the 1st dimension to cover maxv2 : float Largest value in the 2nd dimensi...
[ "This", "function", "generates", "a", "2", "-", "dimensional", "lattice", "of", "points", "using", "a", "hexagonal", "lattice", "." ]
python
train
31.615385
fermiPy/fermipy
fermipy/diffuse/source_factory.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L34-L41
def make_mapcube_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.MapCubeSource` object """ data = dict(Spatial_Filename=Spatial_Filename) if spectrum is not None: data.update(spectrum) return roi_model.MapCubeSource(name, data)
[ "def", "make_mapcube_source", "(", "name", ",", "Spatial_Filename", ",", "spectrum", ")", ":", "data", "=", "dict", "(", "Spatial_Filename", "=", "Spatial_Filename", ")", "if", "spectrum", "is", "not", "None", ":", "data", ".", "update", "(", "spectrum", ")"...
Construct and return a `fermipy.roi_model.MapCubeSource` object
[ "Construct", "and", "return", "a", "fermipy", ".", "roi_model", ".", "MapCubeSource", "object" ]
python
train
36
pydsigner/pygu
pygu/pygw.py
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L241-L250
def bind(self, func, etype): ''' Wraps around container.bind(). ''' if func not in self._event_cbs: wrapped = self._WrapCB(self, func) self._event_cbs[func] = wrapped else: wrapped = self._event_cbs[func] self.container.bind(wrapped, et...
[ "def", "bind", "(", "self", ",", "func", ",", "etype", ")", ":", "if", "func", "not", "in", "self", ".", "_event_cbs", ":", "wrapped", "=", "self", ".", "_WrapCB", "(", "self", ",", "func", ")", "self", ".", "_event_cbs", "[", "func", "]", "=", "...
Wraps around container.bind().
[ "Wraps", "around", "container", ".", "bind", "()", "." ]
python
train
31.5
Alignak-monitoring/alignak
alignak/daemons/arbiterdaemon.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemons/arbiterdaemon.py#L363-L819
def load_monitoring_config_file(self, clean=True): # pylint: disable=too-many-branches,too-many-statements, too-many-locals """Load main configuration file (alignak.cfg):: * Read all files given in the -c parameters * Read all .cfg files in cfg_dir * Read all files in cfg_file ...
[ "def", "load_monitoring_config_file", "(", "self", ",", "clean", "=", "True", ")", ":", "# pylint: disable=too-many-branches,too-many-statements, too-many-locals", "self", ".", "loading_configuration", "=", "True", "_t_configuration", "=", "time", ".", "time", "(", ")", ...
Load main configuration file (alignak.cfg):: * Read all files given in the -c parameters * Read all .cfg files in cfg_dir * Read all files in cfg_file * Create objects (Arbiter, Module) * Set HTTP links info (ssl etc) * Load its own modules * Execute read_configu...
[ "Load", "main", "configuration", "file", "(", "alignak", ".", "cfg", ")", "::" ]
python
train
48.308534
enkore/i3pystatus
i3pystatus/redshift.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/redshift.py#L94-L98
def set_inhibit(self, inhibit): """Set inhibition state""" if self._pid and inhibit != self._inhibited: os.kill(self._pid, signal.SIGUSR1) self._inhibited = inhibit
[ "def", "set_inhibit", "(", "self", ",", "inhibit", ")", ":", "if", "self", ".", "_pid", "and", "inhibit", "!=", "self", ".", "_inhibited", ":", "os", ".", "kill", "(", "self", ".", "_pid", ",", "signal", ".", "SIGUSR1", ")", "self", ".", "_inhibited"...
Set inhibition state
[ "Set", "inhibition", "state" ]
python
train
40
barrust/mediawiki
mediawiki/mediawikipage.py
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L412-L447
def section(self, section_title): """ Plain text section content Args: section_title (str): Name of the section to pull Returns: str: The content of the section Note: Returns **None** if section title is not found; only text \ ...
[ "def", "section", "(", "self", ",", "section_title", ")", ":", "section", "=", "\"== {0} ==\"", ".", "format", "(", "section_title", ")", "try", ":", "content", "=", "self", ".", "content", "index", "=", "content", ".", "index", "(", "section", ")", "+",...
Plain text section content Args: section_title (str): Name of the section to pull Returns: str: The content of the section Note: Returns **None** if section title is not found; only text \ between title and next section...
[ "Plain", "text", "section", "content" ]
python
train
33.916667
ionelmc/python-cogen
cogen/core/events.py
https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/events.py#L323-L330
def process(self, sched, coro): """Add the given coroutine in the scheduler.""" super(AddCoro, self).process(sched, coro) self.result = sched.add(self.coro, self.args, self.kwargs, self.prio & priority.OP) if self.prio & priority.CORO: return self, coro else: ...
[ "def", "process", "(", "self", ",", "sched", ",", "coro", ")", ":", "super", "(", "AddCoro", ",", "self", ")", ".", "process", "(", "sched", ",", "coro", ")", "self", ".", "result", "=", "sched", ".", "add", "(", "self", ".", "coro", ",", "self",...
Add the given coroutine in the scheduler.
[ "Add", "the", "given", "coroutine", "in", "the", "scheduler", "." ]
python
train
44.75
ph4r05/monero-serialize
monero_serialize/xmrserialize.py
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrserialize.py#L495-L511
async def _dump_container_size( self, writer, container_len, container_type, params=None ): """ Dumps container size - per element streaming :param writer: :param container_len: :param container_type: :param params: :return: """ if ...
[ "async", "def", "_dump_container_size", "(", "self", ",", "writer", ",", "container_len", ",", "container_type", ",", "params", "=", "None", ")", ":", "if", "not", "container_type", "or", "not", "container_type", ".", "FIX_SIZE", ":", "await", "dump_uvarint", ...
Dumps container size - per element streaming :param writer: :param container_len: :param container_type: :param params: :return:
[ "Dumps", "container", "size", "-", "per", "element", "streaming", ":", "param", "writer", ":", ":", "param", "container_len", ":", ":", "param", "container_type", ":", ":", "param", "params", ":", ":", "return", ":" ]
python
train
34.647059
adrn/gala
gala/coordinates/velocity_frame_transforms.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/velocity_frame_transforms.py#L48-L75
def vhel_to_vgsr(coordinate, vhel, vsun): """ Convert a velocity from a heliocentric radial velocity to the Galactic standard of rest (GSR). Parameters ---------- coordinate : :class:`~astropy.coordinates.SkyCoord` An Astropy SkyCoord object or anything object that can be passed ...
[ "def", "vhel_to_vgsr", "(", "coordinate", ",", "vhel", ",", "vsun", ")", ":", "if", "vsun", "is", "None", ":", "vsun", "=", "coord", ".", "Galactocentric", ".", "galcen_v_sun", ".", "to_cartesian", "(", ")", ".", "xyz", "return", "vhel", "+", "_get_vproj...
Convert a velocity from a heliocentric radial velocity to the Galactic standard of rest (GSR). Parameters ---------- coordinate : :class:`~astropy.coordinates.SkyCoord` An Astropy SkyCoord object or anything object that can be passed to the SkyCoord initializer. vhel : :class:`~astr...
[ "Convert", "a", "velocity", "from", "a", "heliocentric", "radial", "velocity", "to", "the", "Galactic", "standard", "of", "rest", "(", "GSR", ")", "." ]
python
train
32
juju/charm-helpers
charmhelpers/contrib/hardening/audits/file.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/hardening/audits/file.py#L190-L193
def comply(self, path): """Issues a chown and chmod to the file paths specified.""" utils.ensure_permissions(path, self.user.pw_name, self.group.gr_name, self.mode)
[ "def", "comply", "(", "self", ",", "path", ")", ":", "utils", ".", "ensure_permissions", "(", "path", ",", "self", ".", "user", ".", "pw_name", ",", "self", ".", "group", ".", "gr_name", ",", "self", ".", "mode", ")" ]
Issues a chown and chmod to the file paths specified.
[ "Issues", "a", "chown", "and", "chmod", "to", "the", "file", "paths", "specified", "." ]
python
train
52.5
ChristopherRabotin/bungiesearch
bungiesearch/__init__.py
https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/__init__.py#L132-L141
def get_models(cls, index, as_class=False): ''' Returns the list of models defined for this index. :param index: index name. :param as_class: set to True to return the model as a model object instead of as a string. ''' try: return cls._index_to_model[index] i...
[ "def", "get_models", "(", "cls", ",", "index", ",", "as_class", "=", "False", ")", ":", "try", ":", "return", "cls", ".", "_index_to_model", "[", "index", "]", "if", "as_class", "else", "cls", ".", "_idx_name_to_mdl_to_mdlidx", "[", "index", "]", ".", "k...
Returns the list of models defined for this index. :param index: index name. :param as_class: set to True to return the model as a model object instead of as a string.
[ "Returns", "the", "list", "of", "models", "defined", "for", "this", "index", ".", ":", "param", "index", ":", "index", "name", ".", ":", "param", "as_class", ":", "set", "to", "True", "to", "return", "the", "model", "as", "a", "model", "object", "inste...
python
train
52.5
renzon/gaepermission
gaepermission/facade.py
https://github.com/renzon/gaepermission/blob/1a3534a7ef150ba31fa8df3bc8445557cab3d79d/gaepermission/facade.py#L120-L130
def find_users_by_email_and_group(email_prefix=None, group=None, cursor=None, page_size=30): """ Returns a command that retrieves users by its email_prefix, ordered by email and by Group. If Group is None, only users without any group are going to be searched It returns a max number of users defined by ...
[ "def", "find_users_by_email_and_group", "(", "email_prefix", "=", "None", ",", "group", "=", "None", ",", "cursor", "=", "None", ",", "page_size", "=", "30", ")", ":", "email_prefix", "=", "email_prefix", "or", "''", "return", "ModelSearchCommand", "(", "MainU...
Returns a command that retrieves users by its email_prefix, ordered by email and by Group. If Group is None, only users without any group are going to be searched It returns a max number of users defined by page_size arg. Next result can be retrieved using cursor, in a next call. It is provided in cursor at...
[ "Returns", "a", "command", "that", "retrieves", "users", "by", "its", "email_prefix", "ordered", "by", "email", "and", "by", "Group", ".", "If", "Group", "is", "None", "only", "users", "without", "any", "group", "are", "going", "to", "be", "searched", "It"...
python
train
57.545455
ctuning/ck
ck/kernel.py
https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L7932-L8019
def compare_dicts(i): """ Input: { dict1 - dictionary 1 dict2 - dictionary 2 (ignore_case) - ignore case of letters Note that if dict1 and dict2 has lists, the results will be as follows: * dict1={"key":['a','b','c']} ...
[ "def", "compare_dicts", "(", "i", ")", ":", "d1", "=", "i", ".", "get", "(", "'dict1'", ",", "{", "}", ")", "d2", "=", "i", ".", "get", "(", "'dict2'", ",", "{", "}", ")", "equal", "=", "'yes'", "bic", "=", "False", "ic", "=", "i", ".", "ge...
Input: { dict1 - dictionary 1 dict2 - dictionary 2 (ignore_case) - ignore case of letters Note that if dict1 and dict2 has lists, the results will be as follows: * dict1={"key":['a','b','c']} dict2={"key":['a','b']}...
[ "Input", ":", "{", "dict1", "-", "dictionary", "1", "dict2", "-", "dictionary", "2", "(", "ignore_case", ")", "-", "ignore", "case", "of", "letters" ]
python
train
22.488636
assemblerflow/flowcraft
flowcraft/templates/integrity_coverage.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/templates/integrity_coverage.py#L183-L201
def get_qual_range(qual_str): """ Get range of the Unicode encode range for a given string of characters. The encoding is determined from the result of the :py:func:`ord` built-in. Parameters ---------- qual_str : str Arbitrary string. Returns ------- x : tuple (Minimu...
[ "def", "get_qual_range", "(", "qual_str", ")", ":", "vals", "=", "[", "ord", "(", "c", ")", "for", "c", "in", "qual_str", "]", "return", "min", "(", "vals", ")", ",", "max", "(", "vals", ")" ]
Get range of the Unicode encode range for a given string of characters. The encoding is determined from the result of the :py:func:`ord` built-in. Parameters ---------- qual_str : str Arbitrary string. Returns ------- x : tuple (Minimum Unicode code, Maximum Unicode code).
[ "Get", "range", "of", "the", "Unicode", "encode", "range", "for", "a", "given", "string", "of", "characters", "." ]
python
test
22.105263
chimera0/accel-brain-code
Reinforcement-Learning/pyqlearning/q_learning.py
https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/pyqlearning/q_learning.py#L163-L167
def get_r_df(self): ''' getter ''' if isinstance(self.__r_df, pd.DataFrame) is False and self.__r_df is not None: raise TypeError("The type of `__r_df` must be `pd.DataFrame`.") return self.__r_df
[ "def", "get_r_df", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "__r_df", ",", "pd", ".", "DataFrame", ")", "is", "False", "and", "self", ".", "__r_df", "is", "not", "None", ":", "raise", "TypeError", "(", "\"The type of `__r_df` must be `p...
getter
[ "getter" ]
python
train
45.6
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L832-L852
def setattr(self, name, value): """Set an attribute to a new value for all Parameters. For example, set grad_req to null if you don't need gradient w.r.t a model's Parameters:: model.collect_params().setattr('grad_req', 'null') or change the learning rate multiplier:: ...
[ "def", "setattr", "(", "self", ",", "name", ",", "value", ")", ":", "for", "i", "in", "self", ".", "values", "(", ")", ":", "setattr", "(", "i", ",", "name", ",", "value", ")" ]
Set an attribute to a new value for all Parameters. For example, set grad_req to null if you don't need gradient w.r.t a model's Parameters:: model.collect_params().setattr('grad_req', 'null') or change the learning rate multiplier:: model.collect_params().setattr('lr...
[ "Set", "an", "attribute", "to", "a", "new", "value", "for", "all", "Parameters", "." ]
python
train
29.47619
dereneaton/ipyrad
ipyrad/analysis/tetrad2.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/tetrad2.py#L516-L550
def _run_qmc(self, boot): """ Runs quartet max-cut QMC on the quartets qdump file. """ ## build command self._tmp = os.path.join(self.dirs, ".tmptre") cmd = [ip.bins.qmc, "qrtt="+self.files.qdump, "otre="+self._tmp] ## run it proc = subprocess.Popen(cmd,...
[ "def", "_run_qmc", "(", "self", ",", "boot", ")", ":", "## build command", "self", ".", "_tmp", "=", "os", ".", "path", ".", "join", "(", "self", ".", "dirs", ",", "\".tmptre\"", ")", "cmd", "=", "[", "ip", ".", "bins", ".", "qmc", ",", "\"qrtt=\""...
Runs quartet max-cut QMC on the quartets qdump file.
[ "Runs", "quartet", "max", "-", "cut", "QMC", "on", "the", "quartets", "qdump", "file", "." ]
python
valid
35
robinandeer/puzzle
puzzle/models/variant.py
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L58-L64
def display_name(self): """Readable name for the variant.""" if self.is_snv: gene_ids = self.gene_symbols[:2] return ', '.join(gene_ids) else: return "{this.cytoband_start} ({this.sv_len})".format(this=self)
[ "def", "display_name", "(", "self", ")", ":", "if", "self", ".", "is_snv", ":", "gene_ids", "=", "self", ".", "gene_symbols", "[", ":", "2", "]", "return", "', '", ".", "join", "(", "gene_ids", ")", "else", ":", "return", "\"{this.cytoband_start} ({this.sv...
Readable name for the variant.
[ "Readable", "name", "for", "the", "variant", "." ]
python
train
37.285714
djgagne/hagelslag
hagelslag/processing/STObject.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L452-L470
def calc_shape_statistics(self, stat_names): """ Calculate shape statistics using regionprops applied to the object mask. Args: stat_names: List of statistics to be extracted from those calculated by regionprops. Returns: Dictionary of shape statistics ...
[ "def", "calc_shape_statistics", "(", "self", ",", "stat_names", ")", ":", "stats", "=", "{", "}", "try", ":", "all_props", "=", "[", "regionprops", "(", "m", ")", "for", "m", "in", "self", ".", "masks", "]", "except", "TypeError", ":", "print", "(", ...
Calculate shape statistics using regionprops applied to the object mask. Args: stat_names: List of statistics to be extracted from those calculated by regionprops. Returns: Dictionary of shape statistics
[ "Calculate", "shape", "statistics", "using", "regionprops", "applied", "to", "the", "object", "mask", ".", "Args", ":", "stat_names", ":", "List", "of", "statistics", "to", "be", "extracted", "from", "those", "calculated", "by", "regionprops", "." ]
python
train
31.578947
scivision/pymap3d
pymap3d/los.py
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/los.py#L11-L83
def lookAtSpheroid(lat0: float, lon0: float, h0: float, az: float, tilt: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Calculates line-of-sight intersection with Earth (or other ellipsoid) surface from above surface / orbit Parameters ---------- ...
[ "def", "lookAtSpheroid", "(", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "az", ":", "float", ",", "tilt", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=", "True", ")", "->"...
Calculates line-of-sight intersection with Earth (or other ellipsoid) surface from above surface / orbit Parameters ---------- lat0 : float observer geodetic latitude lon0 : float observer geodetic longitude h0 : float observer altitude (meters) Must be non-negative ...
[ "Calculates", "line", "-", "of", "-", "sight", "intersection", "with", "Earth", "(", "or", "other", "ellipsoid", ")", "surface", "from", "above", "surface", "/", "orbit" ]
python
train
38.493151
monarch-initiative/dipper
dipper/models/assoc/Association.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/assoc/Association.py#L166-L184
def set_association_id(self, assoc_id=None): """ This will set the association ID based on the internal parts of the association. To be used in cases where an external association identifier should be used. :param assoc_id: :return: """ if assoc...
[ "def", "set_association_id", "(", "self", ",", "assoc_id", "=", "None", ")", ":", "if", "assoc_id", "is", "None", ":", "self", ".", "assoc_id", "=", "self", ".", "make_association_id", "(", "self", ".", "definedby", ",", "self", ".", "sub", ",", "self", ...
This will set the association ID based on the internal parts of the association. To be used in cases where an external association identifier should be used. :param assoc_id: :return:
[ "This", "will", "set", "the", "association", "ID", "based", "on", "the", "internal", "parts", "of", "the", "association", ".", "To", "be", "used", "in", "cases", "where", "an", "external", "association", "identifier", "should", "be", "used", "." ]
python
train
26.894737
saltstack/salt
salt/modules/zfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zfs.py#L810-L857
def bookmark(snapshot, bookmark): ''' Creates a bookmark of the given snapshot .. note:: Bookmarks mark the point in time when the snapshot was created, and can be used as the incremental source for a zfs send command. This feature must be enabled to be used. See zpool-features(5)...
[ "def", "bookmark", "(", "snapshot", ",", "bookmark", ")", ":", "# abort if we do not have feature flags", "if", "not", "__utils__", "[", "'zfs.has_feature_flags'", "]", "(", ")", ":", "return", "OrderedDict", "(", "[", "(", "'error'", ",", "'bookmarks are not suppor...
Creates a bookmark of the given snapshot .. note:: Bookmarks mark the point in time when the snapshot was created, and can be used as the incremental source for a zfs send command. This feature must be enabled to be used. See zpool-features(5) for details on ZFS feature flags and ...
[ "Creates", "a", "bookmark", "of", "the", "given", "snapshot" ]
python
train
25.333333
wummel/linkchecker
linkcheck/checker/httpurl.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/httpurl.py#L217-L225
def construct_auth (self): """Construct HTTP Basic authentication credentials if there is user/password information available. Does not overwrite if credentials have already been constructed.""" if self.auth: return _user, _password = self.get_user_password() ...
[ "def", "construct_auth", "(", "self", ")", ":", "if", "self", ".", "auth", ":", "return", "_user", ",", "_password", "=", "self", ".", "get_user_password", "(", ")", "if", "_user", "is", "not", "None", "and", "_password", "is", "not", "None", ":", "sel...
Construct HTTP Basic authentication credentials if there is user/password information available. Does not overwrite if credentials have already been constructed.
[ "Construct", "HTTP", "Basic", "authentication", "credentials", "if", "there", "is", "user", "/", "password", "information", "available", ".", "Does", "not", "overwrite", "if", "credentials", "have", "already", "been", "constructed", "." ]
python
train
44.666667
dnanexus/dx-toolkit
src/python/dxpy/api.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L1522-L1528
def workflow_set_stage_inputs(object_id, input_params={}, always_retry=True, **kwargs): """ Invokes the /workflow-xxxx/setStageInputs API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FsetStageInputs """ return ...
[ "def", "workflow_set_stage_inputs", "(", "object_id", ",", "input_params", "=", "{", "}", ",", "always_retry", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "DXHTTPRequest", "(", "'/%s/setStageInputs'", "%", "object_id", ",", "input_params", ",", "...
Invokes the /workflow-xxxx/setStageInputs API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FsetStageInputs
[ "Invokes", "the", "/", "workflow", "-", "xxxx", "/", "setStageInputs", "API", "method", "." ]
python
train
58.857143
dswah/pyGAM
pygam/distributions.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/distributions.py#L577-L598
def log_pdf(self, y, mu, weights=None): """ computes the log of the pdf or pmf of the values under the current distribution Parameters ---------- y : array-like of length n target values mu : array-like of length n expected values weights ...
[ "def", "log_pdf", "(", "self", ",", "y", ",", "mu", ",", "weights", "=", "None", ")", ":", "if", "weights", "is", "None", ":", "weights", "=", "np", ".", "ones_like", "(", "mu", ")", "gamma", "=", "weights", "/", "self", ".", "scale", "return", "...
computes the log of the pdf or pmf of the values under the current distribution Parameters ---------- y : array-like of length n target values mu : array-like of length n expected values weights : array-like shape (n,) or None, default: None c...
[ "computes", "the", "log", "of", "the", "pdf", "or", "pmf", "of", "the", "values", "under", "the", "current", "distribution" ]
python
train
30.954545
lucasmaystre/choix
choix/ep.py
https://github.com/lucasmaystre/choix/blob/05a57a10bb707338113a9d91601ca528ead7a881/choix/ep.py#L227-L237
def _init_ws(n_items, comparisons, prior_inv, tau, nu): """Initialize parameters in the weight space.""" prec = np.zeros((n_items, n_items)) xs = np.zeros(n_items) for i, (a, b) in enumerate(comparisons): prec[(a, a, b, b), (a, b, a, b)] += tau[i] * MAT_ONE_FLAT xs[a] += nu[i] x...
[ "def", "_init_ws", "(", "n_items", ",", "comparisons", ",", "prior_inv", ",", "tau", ",", "nu", ")", ":", "prec", "=", "np", ".", "zeros", "(", "(", "n_items", ",", "n_items", ")", ")", "xs", "=", "np", ".", "zeros", "(", "n_items", ")", "for", "...
Initialize parameters in the weight space.
[ "Initialize", "parameters", "in", "the", "weight", "space", "." ]
python
train
37.909091
hotdoc/hotdoc
hotdoc/utils/utils.py
https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/utils/utils.py#L103-L115
def flatten_list(list_): """ Banana banana """ res = [] for elem in list_: if isinstance(elem, list): res.extend(flatten_list(elem)) else: res.append(elem) return res
[ "def", "flatten_list", "(", "list_", ")", ":", "res", "=", "[", "]", "for", "elem", "in", "list_", ":", "if", "isinstance", "(", "elem", ",", "list", ")", ":", "res", ".", "extend", "(", "flatten_list", "(", "elem", ")", ")", "else", ":", "res", ...
Banana banana
[ "Banana", "banana" ]
python
train
16.923077
materialsproject/pymatgen
pymatgen/io/zeopp.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/zeopp.py#L456-L513
def get_void_volume_surfarea(structure, rad_dict=None, chan_rad=0.3, probe_rad=0.1): """ Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing v...
[ "def", "get_void_volume_surfarea", "(", "structure", ",", "rad_dict", "=", "None", ",", "chan_rad", "=", "0.3", ",", "probe_rad", "=", "0.1", ")", ":", "with", "ScratchDir", "(", "'.'", ")", ":", "name", "=", "\"temp_zeo\"", "zeo_inp_filename", "=", "name", ...
Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing vacancy rad_dict(optional): Dictionary with short name of elements and their radii. chan_rad(option...
[ "Computes", "the", "volume", "and", "surface", "area", "of", "isolated", "void", "using", "Zeo", "++", ".", "Useful", "to", "compute", "the", "volume", "and", "surface", "area", "of", "vacant", "site", "." ]
python
train
35.637931
SeattleTestbed/seash
pyreadline/lineeditor/history.py
https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/history.py#L122-L126
def next_history(self, current): # (C-n) u'''Move forward through the history list, fetching the next command. ''' if self.history_cursor < len(self.history) - 1: self.history_cursor += 1 current.set_line(self.history[self.history_cursor].get_line_text())
[ "def", "next_history", "(", "self", ",", "current", ")", ":", "# (C-n)\r", "if", "self", ".", "history_cursor", "<", "len", "(", "self", ".", "history", ")", "-", "1", ":", "self", ".", "history_cursor", "+=", "1", "current", ".", "set_line", "(", "sel...
u'''Move forward through the history list, fetching the next command.
[ "u", "Move", "forward", "through", "the", "history", "list", "fetching", "the", "next", "command", "." ]
python
train
59
btrevizan/pystrct
pystrct/pystrct.py
https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L209-L215
def truncate(self, n): """Erase [n] elements.""" # Current byte position - (n * data_size) size = self.size - n * self.__strct.size # Erase [size] bytes from file.tell() self.__file.truncate(size)
[ "def", "truncate", "(", "self", ",", "n", ")", ":", "# Current byte position - (n * data_size)", "size", "=", "self", ".", "size", "-", "n", "*", "self", ".", "__strct", ".", "size", "# Erase [size] bytes from file.tell()", "self", ".", "__file", ".", "truncate"...
Erase [n] elements.
[ "Erase", "[", "n", "]", "elements", "." ]
python
train
33
worldcompany/djangoembed
oembed/parsers/text.py
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/parsers/text.py#L75-L111
def parse_data(self, text, maxwidth, maxheight, template_dir, context, urlize_all_links): """ Parses a block of text rendering links that occur on their own line normally but rendering inline links using a special template dir """ block_parser = TextBlockParse...
[ "def", "parse_data", "(", "self", ",", "text", ",", "maxwidth", ",", "maxheight", ",", "template_dir", ",", "context", ",", "urlize_all_links", ")", ":", "block_parser", "=", "TextBlockParser", "(", ")", "lines", "=", "text", ".", "splitlines", "(", ")", "...
Parses a block of text rendering links that occur on their own line normally but rendering inline links using a special template dir
[ "Parses", "a", "block", "of", "text", "rendering", "links", "that", "occur", "on", "their", "own", "line", "normally", "but", "rendering", "inline", "links", "using", "a", "special", "template", "dir" ]
python
valid
42.432432
fossasia/knittingpattern
knittingpattern/convert/image_to_knittingpattern.py
https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/convert/image_to_knittingpattern.py#L12-L64
def convert_image_to_knitting_pattern(path, colors=("white", "black")): """Load a image file such as a png bitmap of jpeg file and convert it to a :ref:`knitting pattern file <FileFormatSpecification>`. :param list colors: a list of strings that should be used as :ref:`colors <png-color>`. :param...
[ "def", "convert_image_to_knitting_pattern", "(", "path", ",", "colors", "=", "(", "\"white\"", ",", "\"black\"", ")", ")", ":", "image", "=", "PIL", ".", "Image", ".", "open", "(", "path", ")", "pattern_id", "=", "os", ".", "path", ".", "splitext", "(", ...
Load a image file such as a png bitmap of jpeg file and convert it to a :ref:`knitting pattern file <FileFormatSpecification>`. :param list colors: a list of strings that should be used as :ref:`colors <png-color>`. :param str path: ignore this. It is fulfilled by the loeder. Example: .. co...
[ "Load", "a", "image", "file", "such", "as", "a", "png", "bitmap", "of", "jpeg", "file", "and", "convert", "it", "to", "a", ":", "ref", ":", "knitting", "pattern", "file", "<FileFormatSpecification", ">", "." ]
python
valid
31.245283
dlancer/django-pages-cms
pages/managers/pagemanager.py
https://github.com/dlancer/django-pages-cms/blob/441fad674d5ad4f6e05c953508950525dc0fa789/pages/managers/pagemanager.py#L10-L20
def get_queryset(self, *args, **kwargs): """ Ensures that this manager always returns nodes in tree order. """ qs = super(TreeManager, self).get_queryset(*args, **kwargs) # Restrict operations to pages on the current site if needed if settings.PAGES_HIDE_SITES and settin...
[ "def", "get_queryset", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "qs", "=", "super", "(", "TreeManager", ",", "self", ")", ".", "get_queryset", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# Restrict operations to pages on the...
Ensures that this manager always returns nodes in tree order.
[ "Ensures", "that", "this", "manager", "always", "returns", "nodes", "in", "tree", "order", "." ]
python
train
46.181818
materialsproject/pymatgen
pymatgen/analysis/structure_analyzer.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_analyzer.py#L366-L389
def solid_angle(center, coords): """ Helper method to calculate the solid angle of a set of coords from the center. Args: center (3x1 array): Center to measure solid angle from. coords (Nx3 array): List of coords to determine solid angle. Returns: The solid angle. """ ...
[ "def", "solid_angle", "(", "center", ",", "coords", ")", ":", "o", "=", "np", ".", "array", "(", "center", ")", "r", "=", "[", "np", ".", "array", "(", "c", ")", "-", "o", "for", "c", "in", "coords", "]", "r", ".", "append", "(", "r", "[", ...
Helper method to calculate the solid angle of a set of coords from the center. Args: center (3x1 array): Center to measure solid angle from. coords (Nx3 array): List of coords to determine solid angle. Returns: The solid angle.
[ "Helper", "method", "to", "calculate", "the", "solid", "angle", "of", "a", "set", "of", "coords", "from", "the", "center", "." ]
python
train
29.958333
exosite-labs/pyonep
pyonep/provision.py
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/provision.py#L263-L278
def content_upload(self, key, model, contentid, data, mimetype): """Store the given data as a result of a query for content id given the model. This method maps to https://github.com/exosite/docs/tree/master/provision#post---upload-content Args: key: The CIK or Token for th...
[ "def", "content_upload", "(", "self", ",", "key", ",", "model", ",", "contentid", ",", "data", ",", "mimetype", ")", ":", "headers", "=", "{", "\"Content-Type\"", ":", "mimetype", "}", "path", "=", "PROVISION_MANAGE_CONTENT", "+", "model", "+", "'/'", "+",...
Store the given data as a result of a query for content id given the model. This method maps to https://github.com/exosite/docs/tree/master/provision#post---upload-content Args: key: The CIK or Token for the device model: contentid: The ID used to name the e...
[ "Store", "the", "given", "data", "as", "a", "result", "of", "a", "query", "for", "content", "id", "given", "the", "model", "." ]
python
train
44.625
inveniosoftware/invenio-migrator
invenio_migrator/records.py
https://github.com/inveniosoftware/invenio-migrator/blob/6902c6968a39b747d15e32363f43b7dffe2622c2/invenio_migrator/records.py#L129-L140
def create_pids(cls, record_uuid, pids): """Create persistent identifiers.""" for p in pids: PersistentIdentifier.create( pid_type=p.pid_type, pid_value=p.pid_value, pid_provider=p.provider.pid_provider if p.provider else None, ...
[ "def", "create_pids", "(", "cls", ",", "record_uuid", ",", "pids", ")", ":", "for", "p", "in", "pids", ":", "PersistentIdentifier", ".", "create", "(", "pid_type", "=", "p", ".", "pid_type", ",", "pid_value", "=", "p", ".", "pid_value", ",", "pid_provide...
Create persistent identifiers.
[ "Create", "persistent", "identifiers", "." ]
python
test
37.916667
datasift/datasift-python
datasift/managed_sources.py
https://github.com/datasift/datasift-python/blob/bfaca1a47501a18e11065ecf630d9c31df818f65/datasift/managed_sources.py#L94-L129
def create(self, source_type, name, resources, auth=None, parameters=None, validate=True): """ Create a managed source Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/sourcecreate :param source_type: data source name e.g. facebook_page, googleplus, instagram,...
[ "def", "create", "(", "self", ",", "source_type", ",", "name", ",", "resources", ",", "auth", "=", "None", ",", "parameters", "=", "None", ",", "validate", "=", "True", ")", ":", "assert", "resources", ",", "\"Need at least one resource\"", "params", "=", ...
Create a managed source Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/sourcecreate :param source_type: data source name e.g. facebook_page, googleplus, instagram, yammer :type source_type: str :param name: name to use to identify the managed...
[ "Create", "a", "managed", "source" ]
python
train
42.916667
foremast/foremast
src/foremast/configs/prepare_configs.py
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/prepare_configs.py#L96-L114
def apply_region_configs(env_config): """Override default env configs with region specific configs and nest all values under a region Args: env_config (dict): The environment specific config. Return: dict: Newly updated dictionary with region overrides applied. """ new_config =...
[ "def", "apply_region_configs", "(", "env_config", ")", ":", "new_config", "=", "env_config", ".", "copy", "(", ")", "for", "region", "in", "env_config", ".", "get", "(", "'regions'", ",", "REGIONS", ")", ":", "if", "isinstance", "(", "env_config", ".", "ge...
Override default env configs with region specific configs and nest all values under a region Args: env_config (dict): The environment specific config. Return: dict: Newly updated dictionary with region overrides applied.
[ "Override", "default", "env", "configs", "with", "region", "specific", "configs", "and", "nest", "all", "values", "under", "a", "region" ]
python
train
38.368421