repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L172-L187
def _is_bval_type_a(grouped_dicoms): """ Check if the bvals are stored in the first of 2 currently known ways for single frame dti """ bval_tag = Tag(0x2001, 0x1003) bvec_x_tag = Tag(0x2005, 0x10b0) bvec_y_tag = Tag(0x2005, 0x10b1) bvec_z_tag = Tag(0x2005, 0x10b2) for group in grouped_di...
[ "def", "_is_bval_type_a", "(", "grouped_dicoms", ")", ":", "bval_tag", "=", "Tag", "(", "0x2001", ",", "0x1003", ")", "bvec_x_tag", "=", "Tag", "(", "0x2005", ",", "0x10b0", ")", "bvec_y_tag", "=", "Tag", "(", "0x2005", ",", "0x10b1", ")", "bvec_z_tag", ...
Check if the bvals are stored in the first of 2 currently known ways for single frame dti
[ "Check", "if", "the", "bvals", "are", "stored", "in", "the", "first", "of", "2", "currently", "known", "ways", "for", "single", "frame", "dti" ]
python
train
dropbox/pyannotate
pyannotate_tools/annotations/parse.py
https://github.com/dropbox/pyannotate/blob/d128c76b8a86f208e5c78716f2a917003650cebc/pyannotate_tools/annotations/parse.py#L96-L133
def parse_json(path): # type: (str) -> List[FunctionInfo] """Deserialize a JSON file containing runtime collected types. The input JSON is expected to to have a list of RawEntry items. """ with open(path) as f: data = json.load(f) # type: List[RawEntry] result = [] def assert_type...
[ "def", "parse_json", "(", "path", ")", ":", "# type: (str) -> List[FunctionInfo]", "with", "open", "(", "path", ")", "as", "f", ":", "data", "=", "json", ".", "load", "(", "f", ")", "# type: List[RawEntry]", "result", "=", "[", "]", "def", "assert_type", "...
Deserialize a JSON file containing runtime collected types. The input JSON is expected to to have a list of RawEntry items.
[ "Deserialize", "a", "JSON", "file", "containing", "runtime", "collected", "types", "." ]
python
train
CartoDB/cartoframes
cartoframes/layer.py
https://github.com/CartoDB/cartoframes/blob/c94238a545f3dec45963dac3892540942b6f0df8/cartoframes/layer.py#L369-L397
def _parse_time(self, time): """Parse time inputs""" if time is None: return None if isinstance(time, dict): if 'column' not in time: raise ValueError("`time` must include a 'column' key/value") time_column = time['column'] time_op...
[ "def", "_parse_time", "(", "self", ",", "time", ")", ":", "if", "time", "is", "None", ":", "return", "None", "if", "isinstance", "(", "time", ",", "dict", ")", ":", "if", "'column'", "not", "in", "time", ":", "raise", "ValueError", "(", "\"`time` must ...
Parse time inputs
[ "Parse", "time", "inputs" ]
python
train
niolabs/python-xbee
xbee/tornado/base.py
https://github.com/niolabs/python-xbee/blob/b91be3d0ee7ccaa1990120b5b5490999d8e6cbc7/xbee/tornado/base.py#L127-L167
def _process_input(self, data, events): """ _process_input: _process_input will be notified when there is data ready on the serial connection to be read. It will read and process the data into an API Frame and then either resolve a frame future, or push the frame into t...
[ "def", "_process_input", "(", "self", ",", "data", ",", "events", ")", ":", "frame", "=", "APIFrame", "(", "escaped", "=", "self", ".", "_escaped", ")", "byte", "=", "self", ".", "serial", ".", "read", "(", ")", "if", "byte", "!=", "APIFrame", ".", ...
_process_input: _process_input will be notified when there is data ready on the serial connection to be read. It will read and process the data into an API Frame and then either resolve a frame future, or push the frame into the queue of frames needing to be processed
[ "_process_input", ":" ]
python
train
moralrecordings/mrcrowbar
mrcrowbar/refs.py
https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/refs.py#L115-L132
def property_set( prop, instance, value, **kwargs ): """Wrapper for property writes which auto-deferences Refs. prop A Ref (which gets dereferenced and the target value set). instance The context object used to dereference the Ref. value The value to set the property to. ...
[ "def", "property_set", "(", "prop", ",", "instance", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "prop", ",", "Ref", ")", ":", "return", "prop", ".", "set", "(", "instance", ",", "value", ",", "*", "*", "kwargs", ")", ...
Wrapper for property writes which auto-deferences Refs. prop A Ref (which gets dereferenced and the target value set). instance The context object used to dereference the Ref. value The value to set the property to. Throws AttributeError if prop is not a Ref.
[ "Wrapper", "for", "property", "writes", "which", "auto", "-", "deferences", "Refs", "." ]
python
train
zalando/patroni
patroni/ctl.py
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/ctl.py#L585-L680
def _do_failover_or_switchover(obj, action, cluster_name, master, candidate, force, scheduled=None): """ We want to trigger a failover or switchover for the specified cluster name. We verify that the cluster name, master name and candidate name are correct. If so, we trigger an action and k...
[ "def", "_do_failover_or_switchover", "(", "obj", ",", "action", ",", "cluster_name", ",", "master", ",", "candidate", ",", "force", ",", "scheduled", "=", "None", ")", ":", "dcs", "=", "get_dcs", "(", "obj", ",", "cluster_name", ")", "cluster", "=", "dcs",...
We want to trigger a failover or switchover for the specified cluster name. We verify that the cluster name, master name and candidate name are correct. If so, we trigger an action and keep the client up to date.
[ "We", "want", "to", "trigger", "a", "failover", "or", "switchover", "for", "the", "specified", "cluster", "name", "." ]
python
train
opennode/waldur-core
waldur_core/structure/utils.py
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/utils.py#L130-L150
def handle_resource_update_success(resource): """ Recover resource if its state is ERRED and clear error message. """ update_fields = [] if resource.state == resource.States.ERRED: resource.recover() update_fields.append('state') if resource.state in (resource.States.UPDATING, r...
[ "def", "handle_resource_update_success", "(", "resource", ")", ":", "update_fields", "=", "[", "]", "if", "resource", ".", "state", "==", "resource", ".", "States", ".", "ERRED", ":", "resource", ".", "recover", "(", ")", "update_fields", ".", "append", "(",...
Recover resource if its state is ERRED and clear error message.
[ "Recover", "resource", "if", "its", "state", "is", "ERRED", "and", "clear", "error", "message", "." ]
python
train
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L244-L265
def _get_fault_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_f...
[ "def", "_get_fault_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "for", "rupt", "in", "list", "(", "source", ".", "iter_ruptures", "(", ")", ")", ":", "valid_rupt", "=", "(", "rupt", ".", "mag", ">="...
Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_fault.ComplexFaultSource
[ "Adds", "the", "rates", "for", "a", "simple", "or", "complex", "fault", "source" ]
python
train
DistrictDataLabs/yellowbrick
yellowbrick/features/jointplot.py
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/features/jointplot.py#L208-L235
def _layout(self): """ Creates the grid layout for the joint plot, adding new axes for the histograms if necessary and modifying the aspect ratio. Does not modify the axes or the layout if self.hist is False or None. """ # Ensure the axes are created if not hist, then ret...
[ "def", "_layout", "(", "self", ")", ":", "# Ensure the axes are created if not hist, then return.", "if", "not", "self", ".", "hist", ":", "self", ".", "ax", "return", "# Ensure matplotlib version compatibility", "if", "make_axes_locatable", "is", "None", ":", "raise", ...
Creates the grid layout for the joint plot, adding new axes for the histograms if necessary and modifying the aspect ratio. Does not modify the axes or the layout if self.hist is False or None.
[ "Creates", "the", "grid", "layout", "for", "the", "joint", "plot", "adding", "new", "axes", "for", "the", "histograms", "if", "necessary", "and", "modifying", "the", "aspect", "ratio", ".", "Does", "not", "modify", "the", "axes", "or", "the", "layout", "if...
python
train
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L17867-L17882
def get_default_io_cache_setting_for_storage_controller(self, controller_type): """Returns the default I/O cache setting for the given storage controller in controller_type of type :class:`StorageControllerType` The storage controller type to get the setting for. return ena...
[ "def", "get_default_io_cache_setting_for_storage_controller", "(", "self", ",", "controller_type", ")", ":", "if", "not", "isinstance", "(", "controller_type", ",", "StorageControllerType", ")", ":", "raise", "TypeError", "(", "\"controller_type can only be an instance of typ...
Returns the default I/O cache setting for the given storage controller in controller_type of type :class:`StorageControllerType` The storage controller type to get the setting for. return enabled of type bool Returned flag indicating the default value
[ "Returns", "the", "default", "I", "/", "O", "cache", "setting", "for", "the", "given", "storage", "controller" ]
python
train
spacetelescope/pysynphot
pysynphot/graphtab.py
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/graphtab.py#L242-L271
def validate(self): """ Simulataneously checks for loops and unreachable nodes """ msg = list() previously_seen = set() currently_seen = set([1]) problemset = set() while currently_seen: node = currently_seen.pop() if node in previously_see...
[ "def", "validate", "(", "self", ")", ":", "msg", "=", "list", "(", ")", "previously_seen", "=", "set", "(", ")", "currently_seen", "=", "set", "(", "[", "1", "]", ")", "problemset", "=", "set", "(", ")", "while", "currently_seen", ":", "node", "=", ...
Simulataneously checks for loops and unreachable nodes
[ "Simulataneously", "checks", "for", "loops", "and", "unreachable", "nodes" ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_ras.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_ras.py#L126-L139
def logging_syslog_server_secure(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") logging = ET.SubElement(config, "logging", xmlns="urn:brocade.com:mgmt:brocade-ras") syslog_server = ET.SubElement(logging, "syslog-server") syslogip_key = ET.SubEle...
[ "def", "logging_syslog_server_secure", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "logging", "=", "ET", ".", "SubElement", "(", "config", ",", "\"logging\"", ",", "xmlns", "=", "\"urn:brocad...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L934-L965
def get_postmortem_exclusion_list(cls, bits = None): """ Returns the exclusion list for the postmortem debugger. @see: L{get_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} fo...
[ "def", "get_postmortem_exclusion_list", "(", "cls", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "(", "32", ",", "64", ")", ":", "raise", "NotImplementedError", "(", ...
Returns the exclusion list for the postmortem debugger. @see: L{get_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: list( str ) @re...
[ "Returns", "the", "exclusion", "list", "for", "the", "postmortem", "debugger", "." ]
python
train
hydpy-dev/hydpy
hydpy/auxs/anntools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/anntools.py#L1323-L1370
def refresh(self) -> None: """Prepare the actual |anntools.SeasonalANN| object for calculations. Dispite all automated refreshings explained in the general documentation on class |anntools.SeasonalANN|, it is still possible to destroy the inner consistency of a |anntools.SeasonalANN| in...
[ "def", "refresh", "(", "self", ")", "->", "None", ":", "# pylint: disable=unsupported-assignment-operation", "if", "self", ".", "_do_refresh", ":", "if", "self", ".", "anns", ":", "self", ".", "__sann", "=", "annutils", ".", "SeasonalANN", "(", "self", ".", ...
Prepare the actual |anntools.SeasonalANN| object for calculations. Dispite all automated refreshings explained in the general documentation on class |anntools.SeasonalANN|, it is still possible to destroy the inner consistency of a |anntools.SeasonalANN| instance, as it stores its |annt...
[ "Prepare", "the", "actual", "|anntools", ".", "SeasonalANN|", "object", "for", "calculations", "." ]
python
train
dmwm/DBS
Client/src/python/dbs/apis/dbsClient.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Client/src/python/dbs/apis/dbsClient.py#L212-L228
def __parseForException(self, http_error): """ An internal method, should not be used by clients :param httperror: Thrown httperror by the server """ data = http_error.body try: if isinstance(data, str): data = cjson.decode(data) excep...
[ "def", "__parseForException", "(", "self", ",", "http_error", ")", ":", "data", "=", "http_error", ".", "body", "try", ":", "if", "isinstance", "(", "data", ",", "str", ")", ":", "data", "=", "cjson", ".", "decode", "(", "data", ")", "except", ":", "...
An internal method, should not be used by clients :param httperror: Thrown httperror by the server
[ "An", "internal", "method", "should", "not", "be", "used", "by", "clients" ]
python
train
mapillary/mapillary_tools
mapillary_tools/exif_aux.py
https://github.com/mapillary/mapillary_tools/blob/816785e90c589cae6e8e34a5530ce8417d29591c/mapillary_tools/exif_aux.py#L35-L44
def verify_exif(filename): ''' Check that image file has the required EXIF fields. Incompatible files will be ignored server side. ''' # required tags in IFD name convention required_exif = required_fields() exif = ExifRead(filename) required_exif_exist = exif.fields_exist(required_exif)...
[ "def", "verify_exif", "(", "filename", ")", ":", "# required tags in IFD name convention", "required_exif", "=", "required_fields", "(", ")", "exif", "=", "ExifRead", "(", "filename", ")", "required_exif_exist", "=", "exif", ".", "fields_exist", "(", "required_exif", ...
Check that image file has the required EXIF fields. Incompatible files will be ignored server side.
[ "Check", "that", "image", "file", "has", "the", "required", "EXIF", "fields", ".", "Incompatible", "files", "will", "be", "ignored", "server", "side", "." ]
python
train
saltstack/salt
salt/client/ssh/wrapper/grains.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/wrapper/grains.py#L177-L286
def filter_by(lookup_dict, grain='os_family', merge=None, default='default', base=None): ''' .. versionadded:: 0.17.0 Look up the given grain in a given dictionary for the current OS and return the result Although this may occasionally be use...
[ "def", "filter_by", "(", "lookup_dict", ",", "grain", "=", "'os_family'", ",", "merge", "=", "None", ",", "default", "=", "'default'", ",", "base", "=", "None", ")", ":", "ret", "=", "lookup_dict", ".", "get", "(", "__grains__", ".", "get", "(", "grain...
.. versionadded:: 0.17.0 Look up the given grain in a given dictionary for the current OS and return the result Although this may occasionally be useful at the CLI, the primary intent of this function is for use in Jinja to make short work of creating lookup tables for OS-specific data. For exampl...
[ "..", "versionadded", "::", "0", ".", "17", ".", "0" ]
python
train
twisted/txacme
src/txacme/client.py
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L322-L328
def _check_authorization(cls, authzr, identifier): """ Check that the authorization we got is the one we expected. """ if authzr.body.identifier != identifier: raise errors.UnexpectedUpdate(authzr) return authzr
[ "def", "_check_authorization", "(", "cls", ",", "authzr", ",", "identifier", ")", ":", "if", "authzr", ".", "body", ".", "identifier", "!=", "identifier", ":", "raise", "errors", ".", "UnexpectedUpdate", "(", "authzr", ")", "return", "authzr" ]
Check that the authorization we got is the one we expected.
[ "Check", "that", "the", "authorization", "we", "got", "is", "the", "one", "we", "expected", "." ]
python
train
jenisys/parse_type
parse_type/builder.py
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/builder.py#L83-L95
def make_list(cls, item_converter=None, listsep=','): """ Create a type converter for a list of items (many := 1..*). The parser accepts anything and the converter needs to fail on errors. :param item_converter: Type converter for an item. :param listsep: List separator to use...
[ "def", "make_list", "(", "cls", ",", "item_converter", "=", "None", ",", "listsep", "=", "','", ")", ":", "if", "not", "item_converter", ":", "item_converter", "=", "parse_anything", "return", "cls", ".", "with_cardinality", "(", "Cardinality", ".", "many", ...
Create a type converter for a list of items (many := 1..*). The parser accepts anything and the converter needs to fail on errors. :param item_converter: Type converter for an item. :param listsep: List separator to use (as string). :return: Type converter function object for the list...
[ "Create", "a", "type", "converter", "for", "a", "list", "of", "items", "(", "many", ":", "=", "1", "..", "*", ")", ".", "The", "parser", "accepts", "anything", "and", "the", "converter", "needs", "to", "fail", "on", "errors", "." ]
python
train
jeroyang/txttk
txttk/retools.py
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L159-L175
def parallel(regex_list, sort=False): """ Join the given regexes using r'|' if the sort=True, regexes will be sorted by lenth before processing >>> parallel([r'abc', r'def']) 'abc|def' >>> parallel([r'abc', r'd|ef']) 'abc|def' >>> parallel([r'abc', r'(d|ef)']) 'abc|d|ef' >>>...
[ "def", "parallel", "(", "regex_list", ",", "sort", "=", "False", ")", ":", "if", "sort", ":", "regex_list", "=", "sorted", "(", "regex_list", ",", "key", "=", "len", ",", "reverse", "=", "True", ")", "return", "'|'", ".", "join", "(", "[", "unpack", ...
Join the given regexes using r'|' if the sort=True, regexes will be sorted by lenth before processing >>> parallel([r'abc', r'def']) 'abc|def' >>> parallel([r'abc', r'd|ef']) 'abc|def' >>> parallel([r'abc', r'(d|ef)']) 'abc|d|ef' >>> parallel([r'abc', r'defg']) 'defg|abc'
[ "Join", "the", "given", "regexes", "using", "r", "|", "if", "the", "sort", "=", "True", "regexes", "will", "be", "sorted", "by", "lenth", "before", "processing", ">>>", "parallel", "(", "[", "r", "abc", "r", "def", "]", ")", "abc|def", ">>>", "parallel...
python
train
Chilipp/psy-simple
psy_simple/plotters.py
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/plotters.py#L4596-L4603
def get_xyz_1d(self, xcoord, x, ycoord, y, u, v): """Get closest x, y and z for the given `x` and `y` in `data` for 1d coords""" xclose = xcoord.indexes[xcoord.name].get_loc(x, method='nearest') yclose = ycoord.indexes[ycoord.name].get_loc(y, method='nearest') uval = u[yclose, xc...
[ "def", "get_xyz_1d", "(", "self", ",", "xcoord", ",", "x", ",", "ycoord", ",", "y", ",", "u", ",", "v", ")", ":", "xclose", "=", "xcoord", ".", "indexes", "[", "xcoord", ".", "name", "]", ".", "get_loc", "(", "x", ",", "method", "=", "'nearest'",...
Get closest x, y and z for the given `x` and `y` in `data` for 1d coords
[ "Get", "closest", "x", "y", "and", "z", "for", "the", "given", "x", "and", "y", "in", "data", "for", "1d", "coords" ]
python
train
django-treebeard/django-treebeard
treebeard/mp_tree.py
https://github.com/django-treebeard/django-treebeard/blob/8042ee939cb45394909237da447f8925e3cc6aa3/treebeard/mp_tree.py#L542-L568
def update_move_to_child_vars(self): """Update preliminar vars in :meth:`move` when moving to a child""" newdepth = self.target.depth newpos = None siblings = [] if self.pos in ('first-child', 'last-child', 'sorted-child'): # moving to a child parent = sel...
[ "def", "update_move_to_child_vars", "(", "self", ")", ":", "newdepth", "=", "self", ".", "target", ".", "depth", "newpos", "=", "None", "siblings", "=", "[", "]", "if", "self", ".", "pos", "in", "(", "'first-child'", ",", "'last-child'", ",", "'sorted-chil...
Update preliminar vars in :meth:`move` when moving to a child
[ "Update", "preliminar", "vars", "in", ":", "meth", ":", "move", "when", "moving", "to", "a", "child" ]
python
train
DataKitchen/DKCloudCommand
DKCloudCommand/modules/DKCloudCommandRunner.py
https://github.com/DataKitchen/DKCloudCommand/blob/1cf9cb08ab02f063eef6b5c4b327af142991daa3/DKCloudCommand/modules/DKCloudCommandRunner.py#L566-L588
def is_subdirectory(potential_subdirectory, expected_parent_directory): """ Is the first argument a sub-directory of the second argument? :param potential_subdirectory: :param expected_parent_directory: :return: True if the potential_subdirectory is a child of the expected paren...
[ "def", "is_subdirectory", "(", "potential_subdirectory", ",", "expected_parent_directory", ")", ":", "def", "_get_normalized_parts", "(", "path", ")", ":", "return", "DKCloudCommandRunner", ".", "os_path_split_asunder", "(", "os", ".", "path", ".", "realpath", "(", ...
Is the first argument a sub-directory of the second argument? :param potential_subdirectory: :param expected_parent_directory: :return: True if the potential_subdirectory is a child of the expected parent directory
[ "Is", "the", "first", "argument", "a", "sub", "-", "directory", "of", "the", "second", "argument?" ]
python
train
softlayer/softlayer-python
SoftLayer/CLI/object_storage/credential/create.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/object_storage/credential/create.py#L14-L28
def cli(env, identifier): """Create credentials for an IBM Cloud Object Storage Account""" mgr = SoftLayer.ObjectStorageManager(env.client) credential = mgr.create_credential(identifier) table = formatting.Table(['id', 'password', 'username', 'type_name']) table.sortby = 'id' table.add_row([ ...
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "ObjectStorageManager", "(", "env", ".", "client", ")", "credential", "=", "mgr", ".", "create_credential", "(", "identifier", ")", "table", "=", "formatting", ".", "Table...
Create credentials for an IBM Cloud Object Storage Account
[ "Create", "credentials", "for", "an", "IBM", "Cloud", "Object", "Storage", "Account" ]
python
train
facelessuser/soupsieve
soupsieve/css_match.py
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/css_match.py#L652-L674
def match_past_relations(self, el, relation): """Match past relationship.""" found = False if relation[0].rel_type == REL_PARENT: parent = self.get_parent(el, no_iframe=self.iframe_restrict) while not found and parent: found = self.match_selectors(parent,...
[ "def", "match_past_relations", "(", "self", ",", "el", ",", "relation", ")", ":", "found", "=", "False", "if", "relation", "[", "0", "]", ".", "rel_type", "==", "REL_PARENT", ":", "parent", "=", "self", ".", "get_parent", "(", "el", ",", "no_iframe", "...
Match past relationship.
[ "Match", "past", "relationship", "." ]
python
train
vtemian/buffpy
buffpy/managers/updates.py
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/managers/updates.py#L79-L99
def reorder(self, updates_ids, offset=None, utc=None): ''' Edit the order at which statuses for the specified social media profile will be sent out of the buffer. ''' url = PATHS['REORDER'] % self.profile_id order_format = "order[]=%s&" post_data = '' if offset: post_data +=...
[ "def", "reorder", "(", "self", ",", "updates_ids", ",", "offset", "=", "None", ",", "utc", "=", "None", ")", ":", "url", "=", "PATHS", "[", "'REORDER'", "]", "%", "self", ".", "profile_id", "order_format", "=", "\"order[]=%s&\"", "post_data", "=", "''", ...
Edit the order at which statuses for the specified social media profile will be sent out of the buffer.
[ "Edit", "the", "order", "at", "which", "statuses", "for", "the", "specified", "social", "media", "profile", "will", "be", "sent", "out", "of", "the", "buffer", "." ]
python
valid
tanghaibao/jcvi
jcvi/utils/progressbar.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/progressbar.py#L592-L618
def start(self): '''Starts measuring time, and prints the bar at 0%. It returns self so you can use it like this: >>> pbar = ProgressBar().start() >>> for i in range(100): ... # do something ... pbar.update(i+1) ... >>> pbar.finish() ''' ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "maxval", "is", "None", ":", "self", ".", "maxval", "=", "self", ".", "_DEFAULT_MAXVAL", "self", ".", "num_intervals", "=", "max", "(", "100", ",", "self", ".", "term_width", ")", "self", ".",...
Starts measuring time, and prints the bar at 0%. It returns self so you can use it like this: >>> pbar = ProgressBar().start() >>> for i in range(100): ... # do something ... pbar.update(i+1) ... >>> pbar.finish()
[ "Starts", "measuring", "time", "and", "prints", "the", "bar", "at", "0%", "." ]
python
train
zyga/json-schema-validator
json_schema_validator/schema.py
https://github.com/zyga/json-schema-validator/blob/0504605da5c0a9a5b5b05c41b37661aec9652144/json_schema_validator/schema.py#L236-L257
def pattern(self): """ Regular expression describing valid objects. .. note:: JSON schema specifications says that this value SHOULD follow the ``EMCA 262/Perl 5`` format. We cannot support this so we support python regular expressions instead. This ...
[ "def", "pattern", "(", "self", ")", ":", "value", "=", "self", ".", "_schema", ".", "get", "(", "\"pattern\"", ",", "None", ")", "if", "value", "is", "None", ":", "return", "try", ":", "return", "re", ".", "compile", "(", "value", ")", "except", "r...
Regular expression describing valid objects. .. note:: JSON schema specifications says that this value SHOULD follow the ``EMCA 262/Perl 5`` format. We cannot support this so we support python regular expressions instead. This is still valid but should be noted f...
[ "Regular", "expression", "describing", "valid", "objects", "." ]
python
train
JensAstrup/pyOutlook
pyOutlook/core/folder.py
https://github.com/JensAstrup/pyOutlook/blob/f4ca9d4a8629c0a41f78102ce84fab702a841167/pyOutlook/core/folder.py#L90-L102
def delete(self): """Deletes this Folder. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token. """ headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id r = r...
[ "def", "delete", "(", "self", ")", ":", "headers", "=", "self", ".", "headers", "endpoint", "=", "'https://outlook.office.com/api/v2.0/me/MailFolders/'", "+", "self", ".", "id", "r", "=", "requests", ".", "delete", "(", "endpoint", ",", "headers", "=", "header...
Deletes this Folder. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token.
[ "Deletes", "this", "Folder", "." ]
python
train
pingali/dgit
dgitcore/config.py
https://github.com/pingali/dgit/blob/ecde01f40b98f0719dbcfb54452270ed2f86686d/dgitcore/config.py#L110-L211
def update(globalvars): """ Update the profile """ global config profileini = getprofileini() config = configparser.ConfigParser() config.read(profileini) defaults = {} if globalvars is not None: defaults = {a[0]: a[1] for a in globalvars } # Generic variables to be ca...
[ "def", "update", "(", "globalvars", ")", ":", "global", "config", "profileini", "=", "getprofileini", "(", ")", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "config", ".", "read", "(", "profileini", ")", "defaults", "=", "{", "}", "if", ...
Update the profile
[ "Update", "the", "profile" ]
python
valid
ellmetha/django-machina
machina/apps/forum_moderation/views.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_moderation/views.py#L301-L303
def perform_permissions_check(self, user, obj, perms): """ Performs the permissions check. """ return self.request.forum_permission_handler.can_update_topics_to_normal_topics(obj, user)
[ "def", "perform_permissions_check", "(", "self", ",", "user", ",", "obj", ",", "perms", ")", ":", "return", "self", ".", "request", ".", "forum_permission_handler", ".", "can_update_topics_to_normal_topics", "(", "obj", ",", "user", ")" ]
Performs the permissions check.
[ "Performs", "the", "permissions", "check", "." ]
python
train
sirfoga/pyhal
hal/help.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/help.py#L76-L84
def as_sql(self): """Gets report as json :return: json-formatted report """ labels, data = self._get_table() table = SqlTable(labels, data, "{:.3f}", "\n") return str(table)
[ "def", "as_sql", "(", "self", ")", ":", "labels", ",", "data", "=", "self", ".", "_get_table", "(", ")", "table", "=", "SqlTable", "(", "labels", ",", "data", ",", "\"{:.3f}\"", ",", "\"\\n\"", ")", "return", "str", "(", "table", ")" ]
Gets report as json :return: json-formatted report
[ "Gets", "report", "as", "json" ]
python
train
cloud-custodian/cloud-custodian
tools/c7n_policystream/policystream.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_policystream/policystream.py#L901-L949
def stream(repo_uri, stream_uri, verbose, assume, sort, before=None, after=None): """Stream git history policy changes to destination. Default stream destination is a summary of the policy changes to stdout, one per line. Also supported for stdout streaming is `jsonline`. AWS Kinesis and SQS destinat...
[ "def", "stream", "(", "repo_uri", ",", "stream_uri", ",", "verbose", ",", "assume", ",", "sort", ",", "before", "=", "None", ",", "after", "=", "None", ")", ":", "logging", ".", "basicConfig", "(", "format", "=", "\"%(asctime)s: %(name)s:%(levelname)s %(messag...
Stream git history policy changes to destination. Default stream destination is a summary of the policy changes to stdout, one per line. Also supported for stdout streaming is `jsonline`. AWS Kinesis and SQS destinations are specified by providing the ARN. Database destinations are supported by prov...
[ "Stream", "git", "history", "policy", "changes", "to", "destination", "." ]
python
train
crossbario/txaio-etcd
txaioetcd/_lease.py
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_lease.py#L146-L173
def revoke(self): """ Revokes a lease. All keys attached to the lease will expire and be deleted. :returns: Response header. :rtype: instance of :class:`txaioetcd.Header` """ if self._expired: raise Expired() obj = { # ID is the l...
[ "def", "revoke", "(", "self", ")", ":", "if", "self", ".", "_expired", ":", "raise", "Expired", "(", ")", "obj", "=", "{", "# ID is the lease ID to revoke. When the ID is revoked, all", "# associated keys will be deleted.", "u'ID'", ":", "self", ".", "lease_id", ","...
Revokes a lease. All keys attached to the lease will expire and be deleted. :returns: Response header. :rtype: instance of :class:`txaioetcd.Header`
[ "Revokes", "a", "lease", ".", "All", "keys", "attached", "to", "the", "lease", "will", "expire", "and", "be", "deleted", "." ]
python
train
google/dotty
efilter/transforms/solve.py
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L463-L475
def solve_filter(expr, vars): """Filter values on the LHS by evaluating RHS with each value. Returns any LHS values for which RHS evaluates to a true value. """ lhs_values, _ = __solve_for_repeated(expr.lhs, vars) def lazy_filter(): for lhs_value in repeated.getvalues(lhs_values): ...
[ "def", "solve_filter", "(", "expr", ",", "vars", ")", ":", "lhs_values", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "def", "lazy_filter", "(", ")", ":", "for", "lhs_value", "in", "repeated", ".", "getvalues", "(", ...
Filter values on the LHS by evaluating RHS with each value. Returns any LHS values for which RHS evaluates to a true value.
[ "Filter", "values", "on", "the", "LHS", "by", "evaluating", "RHS", "with", "each", "value", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10751-L10775
def position_target_global_int_send(self, time_boot_ms, coordinate_frame, type_mask, lat_int, lon_int, alt, vx, vy, vz, afx, afy, afz, yaw, yaw_rate, force_mavlink1=False): ''' Reports the current commanded vehicle position, velocity, and acceleration as specified by the ...
[ "def", "position_target_global_int_send", "(", "self", ",", "time_boot_ms", ",", "coordinate_frame", ",", "type_mask", ",", "lat_int", ",", "lon_int", ",", "alt", ",", "vx", ",", "vy", ",", "vz", ",", "afx", ",", "afy", ",", "afz", ",", "yaw", ",", "yaw_...
Reports the current commanded vehicle position, velocity, and acceleration as specified by the autopilot. This should match the commands sent in SET_POSITION_TARGET_GLOBAL_INT if the vehicle is being controlled this way. time_boot_ms ...
[ "Reports", "the", "current", "commanded", "vehicle", "position", "velocity", "and", "acceleration", "as", "specified", "by", "the", "autopilot", ".", "This", "should", "match", "the", "commands", "sent", "in", "SET_POSITION_TARGET_GLOBAL_INT", "if", "the", "vehicle"...
python
train
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L522-L564
def _parseStylesheet(self, src): """stylesheet : [ CHARSET_SYM S* STRING S* ';' ]? [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* [ [ ruleset | media | page | font_face ] [S|CDO|CDC]* ]* ; """ # FIXME: BYTES to STR if type(src) == six.binary_type: ...
[ "def", "_parseStylesheet", "(", "self", ",", "src", ")", ":", "# FIXME: BYTES to STR ", "if", "type", "(", "src", ")", "==", "six", ".", "binary_type", ":", "src", "=", "six", ".", "text_type", "(", "src", ")", "# Get rid of the comments", "src", "=", "sel...
stylesheet : [ CHARSET_SYM S* STRING S* ';' ]? [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* [ [ ruleset | media | page | font_face ] [S|CDO|CDC]* ]* ;
[ "stylesheet", ":", "[", "CHARSET_SYM", "S", "*", "STRING", "S", "*", ";", "]", "?", "[", "S|CDO|CDC", "]", "*", "[", "import", "[", "S|CDO|CDC", "]", "*", "]", "*", "[", "[", "ruleset", "|", "media", "|", "page", "|", "font_face", "]", "[", "S|CD...
python
train
ninuxorg/nodeshot
nodeshot/core/websockets/handlers.py
https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/handlers.py#L43-L48
def broadcast(cls, message): """ broadcast message to all connected clients """ clients = cls.get_clients() # loop over every client and send message for id, client in clients.iteritems(): client.send_message(message)
[ "def", "broadcast", "(", "cls", ",", "message", ")", ":", "clients", "=", "cls", ".", "get_clients", "(", ")", "# loop over every client and send message", "for", "id", ",", "client", "in", "clients", ".", "iteritems", "(", ")", ":", "client", ".", "send_mes...
broadcast message to all connected clients
[ "broadcast", "message", "to", "all", "connected", "clients" ]
python
train
TrafficSenseMSD/SumoTools
traci/_person.py
https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/traci/_person.py#L336-L342
def setHeight(self, personID, height): """setHeight(string, double) -> None Sets the height in m for this person. """ self._connection._sendDoubleCmd( tc.CMD_SET_PERSON_VARIABLE, tc.VAR_HEIGHT, personID, height)
[ "def", "setHeight", "(", "self", ",", "personID", ",", "height", ")", ":", "self", ".", "_connection", ".", "_sendDoubleCmd", "(", "tc", ".", "CMD_SET_PERSON_VARIABLE", ",", "tc", ".", "VAR_HEIGHT", ",", "personID", ",", "height", ")" ]
setHeight(string, double) -> None Sets the height in m for this person.
[ "setHeight", "(", "string", "double", ")", "-", ">", "None" ]
python
train
azogue/i2csense
i2csense/bme280.py
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bme280.py#L61-L79
def _compensate_temperature(self, adc_t): """Compensate temperature. Formula from datasheet Bosch BME280 Environmental sensor. 8.1 Compensation formulas in double precision floating point Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015 """ var_1 = ((adc_t / 16384.0...
[ "def", "_compensate_temperature", "(", "self", ",", "adc_t", ")", ":", "var_1", "=", "(", "(", "adc_t", "/", "16384.0", "-", "self", ".", "_calibration_t", "[", "0", "]", "/", "1024.0", ")", "*", "self", ".", "_calibration_t", "[", "1", "]", ")", "va...
Compensate temperature. Formula from datasheet Bosch BME280 Environmental sensor. 8.1 Compensation formulas in double precision floating point Edition BST-BME280-DS001-10 | Revision 1.1 | May 2015
[ "Compensate", "temperature", "." ]
python
train
MartinThoma/hwrt
hwrt/partitions.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/partitions.py#L20-L32
def prepare_table(table): """Make the table 'symmetric' where the lower left part of the matrix is the reverse probability """ n = len(table) for i, row in enumerate(table): assert len(row) == n for j, el in enumerate(row): if i == j: table[i][i] = 0.0 ...
[ "def", "prepare_table", "(", "table", ")", ":", "n", "=", "len", "(", "table", ")", "for", "i", ",", "row", "in", "enumerate", "(", "table", ")", ":", "assert", "len", "(", "row", ")", "==", "n", "for", "j", ",", "el", "in", "enumerate", "(", "...
Make the table 'symmetric' where the lower left part of the matrix is the reverse probability
[ "Make", "the", "table", "symmetric", "where", "the", "lower", "left", "part", "of", "the", "matrix", "is", "the", "reverse", "probability" ]
python
train
log2timeline/plaso
plaso/cli/helpers/profiling.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/helpers/profiling.py#L70-L117
def ParseOptions(cls, options, configuration_object): """Parses and validates options. Args: options (argparse.Namespace): parser options. configuration_object (CLITool): object to be configured by the argument helper. Raises: BadConfigObject: when the configuration object is o...
[ "def", "ParseOptions", "(", "cls", ",", "options", ",", "configuration_object", ")", ":", "if", "not", "isinstance", "(", "configuration_object", ",", "tools", ".", "CLITool", ")", ":", "raise", "errors", ".", "BadConfigObject", "(", "'Configuration object is not ...
Parses and validates options. Args: options (argparse.Namespace): parser options. configuration_object (CLITool): object to be configured by the argument helper. Raises: BadConfigObject: when the configuration object is of the wrong type.
[ "Parses", "and", "validates", "options", "." ]
python
train
yandex/yandex-tank
yandextank/stepper/main.py
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L159-L191
def read_config(self): ''' stepper part of reading options ''' self.log.info("Configuring StepperWrapper...") self.ammo_file = self.get_option(self.OPTION_AMMOFILE) self.ammo_type = self.get_option('ammo_type') if self.ammo_file: self.ammo_file = os.path.expanduser(se...
[ "def", "read_config", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Configuring StepperWrapper...\"", ")", "self", ".", "ammo_file", "=", "self", ".", "get_option", "(", "self", ".", "OPTION_AMMOFILE", ")", "self", ".", "ammo_type", "=", ...
stepper part of reading options
[ "stepper", "part", "of", "reading", "options" ]
python
test
Phylliade/ikpy
src/ikpy/geometry_utils.py
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L46-L48
def rotation_matrix(phi, theta, psi): """Retourne la matrice de rotation décrite par les angles d'Euler donnés en paramètres""" return np.dot(Rz_matrix(phi), np.dot(Rx_matrix(theta), Rz_matrix(psi)))
[ "def", "rotation_matrix", "(", "phi", ",", "theta", ",", "psi", ")", ":", "return", "np", ".", "dot", "(", "Rz_matrix", "(", "phi", ")", ",", "np", ".", "dot", "(", "Rx_matrix", "(", "theta", ")", ",", "Rz_matrix", "(", "psi", ")", ")", ")" ]
Retourne la matrice de rotation décrite par les angles d'Euler donnés en paramètres
[ "Retourne", "la", "matrice", "de", "rotation", "décrite", "par", "les", "angles", "d", "Euler", "donnés", "en", "paramètres" ]
python
train
agoragames/kairos
kairos/cassandra_backend.py
https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/cassandra_backend.py#L145-L166
def _connection(self): ''' Return a connection from the pool ''' try: return self._pool.get(False) except Empty: args = [ self._host, self._port, self._keyspace ] kwargs = { 'user' : None, 'password' : None, 'cql_version' ...
[ "def", "_connection", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_pool", ".", "get", "(", "False", ")", "except", "Empty", ":", "args", "=", "[", "self", ".", "_host", ",", "self", ".", "_port", ",", "self", ".", "_keyspace", "]", ...
Return a connection from the pool
[ "Return", "a", "connection", "from", "the", "pool" ]
python
train
scanny/python-pptx
pptx/opc/pkgwriter.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/opc/pkgwriter.py#L39-L47
def _write_content_types_stream(phys_writer, parts): """ Write ``[Content_Types].xml`` part to the physical package with an appropriate content type lookup target for each part in *parts*. """ content_types_blob = serialize_part_xml( _ContentTypesItem.xml_for(parts) ...
[ "def", "_write_content_types_stream", "(", "phys_writer", ",", "parts", ")", ":", "content_types_blob", "=", "serialize_part_xml", "(", "_ContentTypesItem", ".", "xml_for", "(", "parts", ")", ")", "phys_writer", ".", "write", "(", "CONTENT_TYPES_URI", ",", "content_...
Write ``[Content_Types].xml`` part to the physical package with an appropriate content type lookup target for each part in *parts*.
[ "Write", "[", "Content_Types", "]", ".", "xml", "part", "to", "the", "physical", "package", "with", "an", "appropriate", "content", "type", "lookup", "target", "for", "each", "part", "in", "*", "parts", "*", "." ]
python
train
gazpachoking/jsonref
jsonref.py
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L70-L130
def replace_refs(cls, obj, _recursive=False, **kwargs): """ Returns a deep copy of `obj` with all contained JSON reference objects replaced with :class:`JsonRef` instances. :param obj: If this is a JSON reference object, a :class:`JsonRef` instance will be created. If `obj` ...
[ "def", "replace_refs", "(", "cls", ",", "obj", ",", "_recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "store", "=", "kwargs", ".", "setdefault", "(", "\"_store\"", ",", "_URIDict", "(", ")", ")", "base_uri", ",", "frag", "=", "urlparse", ...
Returns a deep copy of `obj` with all contained JSON reference objects replaced with :class:`JsonRef` instances. :param obj: If this is a JSON reference object, a :class:`JsonRef` instance will be created. If `obj` is not a JSON reference object, a deep copy of it will be create...
[ "Returns", "a", "deep", "copy", "of", "obj", "with", "all", "contained", "JSON", "reference", "objects", "replaced", "with", ":", "class", ":", "JsonRef", "instances", "." ]
python
train
apache/spark
python/pyspark/sql/dataframe.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/dataframe.py#L1603-L1665
def fillna(self, value, subset=None): """Replace null values, alias for ``na.fill()``. :func:`DataFrame.fillna` and :func:`DataFrameNaFunctions.fill` are aliases of each other. :param value: int, long, float, string, bool or dict. Value to replace null values with. If th...
[ "def", "fillna", "(", "self", ",", "value", ",", "subset", "=", "None", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "float", ",", "int", ",", "long", ",", "basestring", ",", "bool", ",", "dict", ")", ")", ":", "raise", "ValueError"...
Replace null values, alias for ``na.fill()``. :func:`DataFrame.fillna` and :func:`DataFrameNaFunctions.fill` are aliases of each other. :param value: int, long, float, string, bool or dict. Value to replace null values with. If the value is a dict, then `subset` is ignored and `...
[ "Replace", "null", "values", "alias", "for", "na", ".", "fill", "()", ".", ":", "func", ":", "DataFrame", ".", "fillna", "and", ":", "func", ":", "DataFrameNaFunctions", ".", "fill", "are", "aliases", "of", "each", "other", "." ]
python
train
saltstack/salt
salt/utils/event.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L341-L354
def subscribe(self, tag=None, match_type=None): ''' Subscribe to events matching the passed tag. If you do not subscribe to a tag, events will be discarded by calls to get_event that request a different tag. In contexts where many different jobs are outstanding it is important t...
[ "def", "subscribe", "(", "self", ",", "tag", "=", "None", ",", "match_type", "=", "None", ")", ":", "if", "tag", "is", "None", ":", "return", "match_func", "=", "self", ".", "_get_match_func", "(", "match_type", ")", "self", ".", "pending_tags", ".", "...
Subscribe to events matching the passed tag. If you do not subscribe to a tag, events will be discarded by calls to get_event that request a different tag. In contexts where many different jobs are outstanding it is important to subscribe to prevent one call to get_event from discarding...
[ "Subscribe", "to", "events", "matching", "the", "passed", "tag", "." ]
python
train
c0ntrol-x/p4rr0t007
p4rr0t007/lib/core.py
https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L102-L112
def rpad(s, N, char='\0'): """pads a string to the right with null-bytes or any other given character. ..note:: This is used by the :py:func:`xor` function. :param s: the string :param N: an integer of how much padding should be done :returns: the original bytes """ assert isinstance(char,...
[ "def", "rpad", "(", "s", ",", "N", ",", "char", "=", "'\\0'", ")", ":", "assert", "isinstance", "(", "char", ",", "bytes", ")", "and", "len", "(", "char", ")", "==", "1", ",", "'char should be a string with length 1'", "return", "s", ".", "ljust", "(",...
pads a string to the right with null-bytes or any other given character. ..note:: This is used by the :py:func:`xor` function. :param s: the string :param N: an integer of how much padding should be done :returns: the original bytes
[ "pads", "a", "string", "to", "the", "right", "with", "null", "-", "bytes", "or", "any", "other", "given", "character", "." ]
python
train
abarker/pdfCropMargins
src/pdfCropMargins/main_pdfCropMargins.py
https://github.com/abarker/pdfCropMargins/blob/55aca874613750ebf4ae69fd8851bdbb7696d6ac/src/pdfCropMargins/main_pdfCropMargins.py#L112-L123
def intersect_boxes(box1, box2): """Takes two pyPdf boxes (such as page.mediaBox) and returns the pyPdf box which is their intersection.""" if not box1 and not box2: return None if not box1: return box2 if not box2: return box1 intersect = RectangleObject([0, 0, 0, 0]) # Note [llx,lly,urx,ury] =...
[ "def", "intersect_boxes", "(", "box1", ",", "box2", ")", ":", "if", "not", "box1", "and", "not", "box2", ":", "return", "None", "if", "not", "box1", ":", "return", "box2", "if", "not", "box2", ":", "return", "box1", "intersect", "=", "RectangleObject", ...
Takes two pyPdf boxes (such as page.mediaBox) and returns the pyPdf box which is their intersection.
[ "Takes", "two", "pyPdf", "boxes", "(", "such", "as", "page", ".", "mediaBox", ")", "and", "returns", "the", "pyPdf", "box", "which", "is", "their", "intersection", "." ]
python
train
ggaughan/pipe2py
pipe2py/modules/pipetail.py
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipetail.py#L14-L32
def pipe_tail(context=None, _INPUT=None, conf=None, **kwargs): """Returns a specified number of items from the bottom of a feed. Parameters ---------- context : pipe2py.Context object _INPUT : pipe2py.modules pipe like object (iterable of items) kwargs -- terminal, if the truncation value is wi...
[ "def", "pipe_tail", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "conf", "=", "DotDict", "(", "conf", ")", "limit", "=", "conf", ".", "get", "(", "'count'", ",", "func", "="...
Returns a specified number of items from the bottom of a feed. Parameters ---------- context : pipe2py.Context object _INPUT : pipe2py.modules pipe like object (iterable of items) kwargs -- terminal, if the truncation value is wired in conf : count -- length of the truncated feed, if specified ...
[ "Returns", "a", "specified", "number", "of", "items", "from", "the", "bottom", "of", "a", "feed", "." ]
python
train
ejeschke/ginga
ginga/Bindings.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/Bindings.py#L1113-L1122
def kp_pan_zoom_set(self, viewer, event, data_x, data_y, msg=True): """Sets the pan position under the cursor.""" if self.canpan: reg = 1 with viewer.suppress_redraw: viewer.panset_xy(data_x, data_y) scale_x, scale_y = self._save.get((viewer, 'scal...
[ "def", "kp_pan_zoom_set", "(", "self", ",", "viewer", ",", "event", ",", "data_x", ",", "data_y", ",", "msg", "=", "True", ")", ":", "if", "self", ".", "canpan", ":", "reg", "=", "1", "with", "viewer", ".", "suppress_redraw", ":", "viewer", ".", "pan...
Sets the pan position under the cursor.
[ "Sets", "the", "pan", "position", "under", "the", "cursor", "." ]
python
train
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAData/base_datastruct.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAData/base_datastruct.py#L1264-L1278
def get_bar(self, code, time): """ 获取一个bar的数据 返回一个series 如果不存在,raise ValueError """ try: return self.data.loc[(pd.Timestamp(time), code)] except: raise ValueError( 'DATASTRUCT CURRENTLY CANNOT FIND THIS BAR WITH {} {}'.forma...
[ "def", "get_bar", "(", "self", ",", "code", ",", "time", ")", ":", "try", ":", "return", "self", ".", "data", ".", "loc", "[", "(", "pd", ".", "Timestamp", "(", "time", ")", ",", "code", ")", "]", "except", ":", "raise", "ValueError", "(", "'DATA...
获取一个bar的数据 返回一个series 如果不存在,raise ValueError
[ "获取一个bar的数据", "返回一个series", "如果不存在", "raise", "ValueError" ]
python
train
mcs07/PubChemPy
pubchempy.py
https://github.com/mcs07/PubChemPy/blob/e3c4f4a9b6120433e5cc3383464c7a79e9b2b86e/pubchempy.py#L296-L302
def get_json(identifier, namespace='cid', domain='compound', operation=None, searchtype=None, **kwargs): """Request wrapper that automatically parses JSON response and supresses NotFoundError.""" try: return json.loads(get(identifier, namespace, domain, operation, 'JSON', searchtype, **kwargs).decode())...
[ "def", "get_json", "(", "identifier", ",", "namespace", "=", "'cid'", ",", "domain", "=", "'compound'", ",", "operation", "=", "None", ",", "searchtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "json", ".", "loads", "(", ...
Request wrapper that automatically parses JSON response and supresses NotFoundError.
[ "Request", "wrapper", "that", "automatically", "parses", "JSON", "response", "and", "supresses", "NotFoundError", "." ]
python
train
jjjake/internetarchive
internetarchive/cli/ia.py
https://github.com/jjjake/internetarchive/blob/7c0c71bfe52490927a37ade15bd09b2733fea660/internetarchive/cli/ia.py#L107-L167
def main(): """This is the CLI driver for ia-wrapper.""" args = docopt(__doc__, version=__version__, options_first=True) # Validate args. s = Schema({ six.text_type: bool, '--config-file': Or(None, str), '<args>': list, '<command>': Or(str, lambda _: 'help'), }) ...
[ "def", "main", "(", ")", ":", "args", "=", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ",", "options_first", "=", "True", ")", "# Validate args.", "s", "=", "Schema", "(", "{", "six", ".", "text_type", ":", "bool", ",", "'--config-file'...
This is the CLI driver for ia-wrapper.
[ "This", "is", "the", "CLI", "driver", "for", "ia", "-", "wrapper", "." ]
python
train
SheffieldML/GPy
GPy/kern/src/todo/eq_ode1.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/kern/src/todo/eq_ode1.py#L292-L309
def _K_compute_eq(self): """Compute covariance for latent covariance.""" t_eq = self._t[self._index==0] if self._t2 is None: if t_eq.size==0: self._K_eq = np.zeros((0, 0)) return self._dist2 = np.square(t_eq[:, None] - t_eq[None, :]) ...
[ "def", "_K_compute_eq", "(", "self", ")", ":", "t_eq", "=", "self", ".", "_t", "[", "self", ".", "_index", "==", "0", "]", "if", "self", ".", "_t2", "is", "None", ":", "if", "t_eq", ".", "size", "==", "0", ":", "self", ".", "_K_eq", "=", "np", ...
Compute covariance for latent covariance.
[ "Compute", "covariance", "for", "latent", "covariance", "." ]
python
train
SectorLabs/django-postgres-extra
psqlextra/manager/manager.py
https://github.com/SectorLabs/django-postgres-extra/blob/eef2ed5504d225858d4e4f5d77a838082ca6053e/psqlextra/manager/manager.py#L197-L236
def insert_and_get(self, **fields): """Creates a new record in the database and then gets the entire row. This allows specifying custom conflict behavior using .on_conflict(). If no special behavior was specified, this uses the normal Django create(..) Arguments: fi...
[ "def", "insert_and_get", "(", "self", ",", "*", "*", "fields", ")", ":", "if", "not", "self", ".", "conflict_target", "and", "not", "self", ".", "conflict_action", ":", "# no special action required, use the standard Django create(..)", "return", "super", "(", ")", ...
Creates a new record in the database and then gets the entire row. This allows specifying custom conflict behavior using .on_conflict(). If no special behavior was specified, this uses the normal Django create(..) Arguments: fields: The fields of the row to ...
[ "Creates", "a", "new", "record", "in", "the", "database", "and", "then", "gets", "the", "entire", "row", "." ]
python
test
portfors-lab/sparkle
sparkle/gui/stim/auto_parameters_editor.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/auto_parameters_editor.py#L71-L91
def showEvent(self, event): """When this widget is shown it has an effect of putting other widgets in the parent widget into different editing modes, emits signal to notify other widgets. Restores the previous selection the last time this widget was visible""" selected = self.par...
[ "def", "showEvent", "(", "self", ",", "event", ")", ":", "selected", "=", "self", ".", "paramList", ".", "selectedIndexes", "(", ")", "model", "=", "self", ".", "paramList", ".", "model", "(", ")", "self", ".", "visibilityChanged", ".", "emit", "(", "1...
When this widget is shown it has an effect of putting other widgets in the parent widget into different editing modes, emits signal to notify other widgets. Restores the previous selection the last time this widget was visible
[ "When", "this", "widget", "is", "shown", "it", "has", "an", "effect", "of", "putting", "other", "widgets", "in", "the", "parent", "widget", "into", "different", "editing", "modes", "emits", "signal", "to", "notify", "other", "widgets", ".", "Restores", "the"...
python
train
databio/pypiper
pypiper/utils.py
https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L313-L357
def get_first_value(param, param_pools, on_missing=None, error=True): """ Get the value for a particular parameter from the first pool in the provided priority list of parameter pools. :param str param: Name of parameter for which to determine/fetch value. :param Sequence[Mapping[str, object]] para...
[ "def", "get_first_value", "(", "param", ",", "param_pools", ",", "on_missing", "=", "None", ",", "error", "=", "True", ")", ":", "# Search for the requested parameter.", "for", "pool", "in", "param_pools", ":", "if", "param", "in", "pool", ":", "return", "pool...
Get the value for a particular parameter from the first pool in the provided priority list of parameter pools. :param str param: Name of parameter for which to determine/fetch value. :param Sequence[Mapping[str, object]] param_pools: Ordered (priority) collection of mapping from parameter name to v...
[ "Get", "the", "value", "for", "a", "particular", "parameter", "from", "the", "first", "pool", "in", "the", "provided", "priority", "list", "of", "parameter", "pools", "." ]
python
train
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/configfieldlists.py
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/configfieldlists.py#L1127-L1150
def create_configfield_ref_target_node(target_id, env, lineno): """Create a ``target`` node that marks a configuration field. Internally, this also adds to the ``lsst_configfields`` attribute of the environment that is consumed by `documenteer.sphinxext.lssttasks. crossrefs.process_pending_configfield_...
[ "def", "create_configfield_ref_target_node", "(", "target_id", ",", "env", ",", "lineno", ")", ":", "target_node", "=", "nodes", ".", "target", "(", "''", ",", "''", ",", "ids", "=", "[", "target_id", "]", ")", "# Store these task/configurable topic nodes in the e...
Create a ``target`` node that marks a configuration field. Internally, this also adds to the ``lsst_configfields`` attribute of the environment that is consumed by `documenteer.sphinxext.lssttasks. crossrefs.process_pending_configfield_xref_nodes`. See also -------- `documenteer.sphinxext.lsst...
[ "Create", "a", "target", "node", "that", "marks", "a", "configuration", "field", "." ]
python
train
apache/incubator-mxnet
example/ssd/dataset/pycocotools/coco.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L217-L226
def loadImgs(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects """ if type(ids) == list: return [self.imgs[id] for id in ids] elif type(ids) ...
[ "def", "loadImgs", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "type", "(", "ids", ")", "==", "list", ":", "return", "[", "self", ".", "imgs", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", ...
Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects
[ "Load", "anns", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "img", ":", "return", ":", "imgs", "(", "object", "array", ")", ":", "loaded", "img", "objects" ]
python
train
DataDog/integrations-core
sqlserver/datadog_checks/sqlserver/sqlserver.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/sqlserver/datadog_checks/sqlserver/sqlserver.py#L620-L673
def open_db_connections(self, instance, db_key, db_name=None): """ We open the db connections explicitly, so we can ensure they are open before we use them, and are closable, once we are finished. Open db connections keep locks on the db, presenting issues such as the SQL Server ...
[ "def", "open_db_connections", "(", "self", ",", "instance", ",", "db_key", ",", "db_name", "=", "None", ")", ":", "conn_key", "=", "self", ".", "_conn_key", "(", "instance", ",", "db_key", ",", "db_name", ")", "timeout", "=", "int", "(", "instance", ".",...
We open the db connections explicitly, so we can ensure they are open before we use them, and are closable, once we are finished. Open db connections keep locks on the db, presenting issues such as the SQL Server Agent being unable to stop.
[ "We", "open", "the", "db", "connections", "explicitly", "so", "we", "can", "ensure", "they", "are", "open", "before", "we", "use", "them", "and", "are", "closable", "once", "we", "are", "finished", ".", "Open", "db", "connections", "keep", "locks", "on", ...
python
train
vitiral/gpio
gpio.py
https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L158-L165
def set(pin, value): '''set the pin value to 0 or 1''' if value is LOW: value = 0 value = int(bool(value)) log.debug("Write {0}: {1}".format(pin, value)) f = _open[pin].value _write(f, value)
[ "def", "set", "(", "pin", ",", "value", ")", ":", "if", "value", "is", "LOW", ":", "value", "=", "0", "value", "=", "int", "(", "bool", "(", "value", ")", ")", "log", ".", "debug", "(", "\"Write {0}: {1}\"", ".", "format", "(", "pin", ",", "value...
set the pin value to 0 or 1
[ "set", "the", "pin", "value", "to", "0", "or", "1" ]
python
train
philipsoutham/py-mysql2pgsql
mysql2pgsql/lib/postgres_file_writer.py
https://github.com/philipsoutham/py-mysql2pgsql/blob/66dc2a3a3119263b3fe77300fb636346509787ef/mysql2pgsql/lib/postgres_file_writer.py#L93-L101
def write_constraints(self, table): """Write DDL of `table` constraints to the output file :Parameters: - `table`: an instance of a :py:class:`mysql2pgsql.lib.mysql_reader.MysqlReader.Table` object that represents the table to read/write. Returns None """ self.f.write...
[ "def", "write_constraints", "(", "self", ",", "table", ")", ":", "self", ".", "f", ".", "write", "(", "'\\n'", ".", "join", "(", "super", "(", "PostgresFileWriter", ",", "self", ")", ".", "write_constraints", "(", "table", ")", ")", ")" ]
Write DDL of `table` constraints to the output file :Parameters: - `table`: an instance of a :py:class:`mysql2pgsql.lib.mysql_reader.MysqlReader.Table` object that represents the table to read/write. Returns None
[ "Write", "DDL", "of", "table", "constraints", "to", "the", "output", "file" ]
python
test
ejeschke/ginga
ginga/rv/plugins/SaveImage.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/SaveImage.py#L259-L293
def update_channels(self): """Update the GUI to reflect channels and image listing. """ if not self.gui_up: return self.logger.debug("channel configuration has changed--updating gui") try: channel = self.fv.get_channel(self.chname) except KeyErro...
[ "def", "update_channels", "(", "self", ")", ":", "if", "not", "self", ".", "gui_up", ":", "return", "self", ".", "logger", ".", "debug", "(", "\"channel configuration has changed--updating gui\"", ")", "try", ":", "channel", "=", "self", ".", "fv", ".", "get...
Update the GUI to reflect channels and image listing.
[ "Update", "the", "GUI", "to", "reflect", "channels", "and", "image", "listing", "." ]
python
train
nathforge/pydentifier
src/pydentifier/__init__.py
https://github.com/nathforge/pydentifier/blob/b8d27076254c65cfd7893c1401e2a198abd6afb4/src/pydentifier/__init__.py#L32-L51
def upper_underscore(string, prefix='', suffix=''): """ Generate an underscore-separated upper-case identifier. Useful for constants. Takes a string, prefix, and optional suffix. `prefix` can be set to `''`, though be careful - without a prefix, the function will throw `InvalidIdentifier` when...
[ "def", "upper_underscore", "(", "string", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ")", ":", "return", "require_valid", "(", "append_underscore_if_keyword", "(", "'_'", ".", "join", "(", "word", ".", "upper", "(", ")", "for", "word", "in", "en...
Generate an underscore-separated upper-case identifier. Useful for constants. Takes a string, prefix, and optional suffix. `prefix` can be set to `''`, though be careful - without a prefix, the function will throw `InvalidIdentifier` when your string starts with a number. Example: >>>...
[ "Generate", "an", "underscore", "-", "separated", "upper", "-", "case", "identifier", ".", "Useful", "for", "constants", "." ]
python
train
davenquinn/Attitude
docs/scripts/generate-json.py
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/docs/scripts/generate-json.py#L11-L26
def serialize(pca, **kwargs): """ Serialize an orientation object to a dict suitable for JSON """ strike, dip, rake = pca.strike_dip_rake() hyp_axes = sampling_axes(pca) return dict( **kwargs, principal_axes = pca.axes.tolist(), hyperbolic_axes = hyp_axes.tolist(), ...
[ "def", "serialize", "(", "pca", ",", "*", "*", "kwargs", ")", ":", "strike", ",", "dip", ",", "rake", "=", "pca", ".", "strike_dip_rake", "(", ")", "hyp_axes", "=", "sampling_axes", "(", "pca", ")", "return", "dict", "(", "*", "*", "kwargs", ",", "...
Serialize an orientation object to a dict suitable for JSON
[ "Serialize", "an", "orientation", "object", "to", "a", "dict", "suitable", "for", "JSON" ]
python
train
occrp-attic/exactitude
exactitude/country.py
https://github.com/occrp-attic/exactitude/blob/9fe13aa70f1aac644dbc999e0b21683db507f02d/exactitude/country.py#L35-L45
def clean_text(self, country, guess=False, **kwargs): """Determine a two-letter country code based on an input. The input may be a country code, a country name, etc. """ code = country.lower().strip() if code in self.names: return code country = countrynames....
[ "def", "clean_text", "(", "self", ",", "country", ",", "guess", "=", "False", ",", "*", "*", "kwargs", ")", ":", "code", "=", "country", ".", "lower", "(", ")", ".", "strip", "(", ")", "if", "code", "in", "self", ".", "names", ":", "return", "cod...
Determine a two-letter country code based on an input. The input may be a country code, a country name, etc.
[ "Determine", "a", "two", "-", "letter", "country", "code", "based", "on", "an", "input", "." ]
python
train
yvesalexandre/bandicoot
bandicoot/helper/stops.py
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/helper/stops.py#L37-L43
def get_neighbors(distance_matrix, source, eps): """ Given a matrix of distance between couples of points, return the list of every point closer than eps from a certain point. """ return [dest for dest, distance in enumerate(distance_matrix[source]) if distance < eps]
[ "def", "get_neighbors", "(", "distance_matrix", ",", "source", ",", "eps", ")", ":", "return", "[", "dest", "for", "dest", ",", "distance", "in", "enumerate", "(", "distance_matrix", "[", "source", "]", ")", "if", "distance", "<", "eps", "]" ]
Given a matrix of distance between couples of points, return the list of every point closer than eps from a certain point.
[ "Given", "a", "matrix", "of", "distance", "between", "couples", "of", "points", "return", "the", "list", "of", "every", "point", "closer", "than", "eps", "from", "a", "certain", "point", "." ]
python
train
HazyResearch/fonduer
src/fonduer/learning/classifier.py
https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/learning/classifier.py#L488-L516
def save(self, model_file, save_dir, verbose=True): """Save current model. :param model_file: Saved model file name. :type model_file: str :param save_dir: Saved model directory. :type save_dir: str :param verbose: Print log or not :type verbose: bool """...
[ "def", "save", "(", "self", ",", "model_file", ",", "save_dir", ",", "verbose", "=", "True", ")", ":", "# Check existence of model saving directory and create if does not exist.", "if", "not", "os", ".", "path", ".", "exists", "(", "save_dir", ")", ":", "os", "....
Save current model. :param model_file: Saved model file name. :type model_file: str :param save_dir: Saved model directory. :type save_dir: str :param verbose: Print log or not :type verbose: bool
[ "Save", "current", "model", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1367-L1371
def p_sens_all(self, p): 'senslist : AT TIMES' p[0] = SensList( (Sens(None, 'all', lineno=p.lineno(1)),), lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_sens_all", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "SensList", "(", "(", "Sens", "(", "None", ",", "'all'", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", ",", ")", ",", "lineno", "=", "p", ".", "lin...
senslist : AT TIMES
[ "senslist", ":", "AT", "TIMES" ]
python
train
aaugustin/websockets
src/websockets/handshake.py
https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/handshake.py#L126-L135
def build_response(headers: Headers, key: str) -> None: """ Build a handshake response to send to the client. ``key`` comes from :func:`check_request`. """ headers["Upgrade"] = "websocket" headers["Connection"] = "Upgrade" headers["Sec-WebSocket-Accept"] = accept(key)
[ "def", "build_response", "(", "headers", ":", "Headers", ",", "key", ":", "str", ")", "->", "None", ":", "headers", "[", "\"Upgrade\"", "]", "=", "\"websocket\"", "headers", "[", "\"Connection\"", "]", "=", "\"Upgrade\"", "headers", "[", "\"Sec-WebSocket-Accep...
Build a handshake response to send to the client. ``key`` comes from :func:`check_request`.
[ "Build", "a", "handshake", "response", "to", "send", "to", "the", "client", "." ]
python
train
tanghaibao/goatools
goatools/grouper/aart_geneproducts_all.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_all.py#L49-L88
def prt_mrks(self, name_marks_list, prt=sys.stdout): """Print summary of all GOEAs. Example: Key for GO sections: A immune B viral/bacteria C neuro D cell death E lipid F adhesion G cell cycle ...
[ "def", "prt_mrks", "(", "self", ",", "name_marks_list", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "if", "not", "name_marks_list", ":", "return", "# prt.write(\"\\nKey for GO sections:\\n\")", "# self.prt_section_key(prt)", "prt", ".", "write", "(", "\"\\n{HDR...
Print summary of all GOEAs. Example: Key for GO sections: A immune B viral/bacteria C neuro D cell death E lipid F adhesion G cell cycle H chromosome I development J ...
[ "Print", "summary", "of", "all", "GOEAs", ".", "Example", ":", "Key", "for", "GO", "sections", ":", "A", "immune", "B", "viral", "/", "bacteria", "C", "neuro", "D", "cell", "death", "E", "lipid", "F", "adhesion", "G", "cell", "cycle", "H", "chromosome"...
python
train
proteanhq/protean
src/protean/core/usecase/generic.py
https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/core/usecase/generic.py#L119-L123
def process_request(self, request_object): """Process Create Resource Request""" resource = request_object.entity_cls.create(**request_object.data) return ResponseSuccessCreated(resource)
[ "def", "process_request", "(", "self", ",", "request_object", ")", ":", "resource", "=", "request_object", ".", "entity_cls", ".", "create", "(", "*", "*", "request_object", ".", "data", ")", "return", "ResponseSuccessCreated", "(", "resource", ")" ]
Process Create Resource Request
[ "Process", "Create", "Resource", "Request" ]
python
train
ANTsX/ANTsPy
ants/registration/make_points_image.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/make_points_image.py#L11-L60
def make_points_image(pts, mask, radius=5): """ Create label image from physical space points Creates spherical points in the coordinate space of the target image based on the n-dimensional matrix of points that the user supplies. The image defines the dimensionality of the data so if the input ima...
[ "def", "make_points_image", "(", "pts", ",", "mask", ",", "radius", "=", "5", ")", ":", "powers_lblimg", "=", "mask", "*", "0", "npts", "=", "len", "(", "pts", ")", "dim", "=", "mask", ".", "dimension", "if", "pts", ".", "shape", "[", "1", "]", "...
Create label image from physical space points Creates spherical points in the coordinate space of the target image based on the n-dimensional matrix of points that the user supplies. The image defines the dimensionality of the data so if the input image is 3D then the input points should be 2D or 3D. ...
[ "Create", "label", "image", "from", "physical", "space", "points" ]
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/batch_v2alpha1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/batch_v2alpha1_api.py#L283-L310
def delete_namespaced_cron_job(self, name, namespace, **kwargs): # noqa: E501 """delete_namespaced_cron_job # noqa: E501 delete a CronJob # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>>...
[ "def", "delete_namespaced_cron_job", "(", "self", ",", "name", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return...
delete_namespaced_cron_job # noqa: E501 delete a CronJob # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_namespaced_cron_job(name, namespace, async_req=True) >>> resu...
[ "delete_namespaced_cron_job", "#", "noqa", ":", "E501" ]
python
train
pandas-dev/pandas
pandas/io/parsers.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2858-L2892
def _next_iter_line(self, row_num): """ Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- ...
[ "def", "_next_iter_line", "(", "self", ",", "row_num", ")", ":", "try", ":", "return", "next", "(", "self", ".", "data", ")", "except", "csv", ".", "Error", "as", "e", ":", "if", "self", ".", "warn_bad_lines", "or", "self", ".", "error_bad_lines", ":",...
Wrapper around iterating through `self.data` (CSV source). When a CSV error is raised, we check for specific error messages that allow us to customize the error message displayed to the user. Parameters ---------- row_num : The row number of the line being parsed.
[ "Wrapper", "around", "iterating", "through", "self", ".", "data", "(", "CSV", "source", ")", "." ]
python
train
saltstack/salt
salt/modules/runit.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/runit.py#L651-L687
def disable(name, stop=False, **kwargs): ''' Don't start service ``name`` at boot Returns ``True`` if operation is successful name the service's name stop if True, also stops the service CLI Example: .. code-block:: bash salt '*' service.disable <name> [stop=True...
[ "def", "disable", "(", "name", ",", "stop", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# non-existent as registrered service", "if", "not", "enabled", "(", "name", ")", ":", "return", "False", "# down_file: file that prevent sv autostart", "svc_realpath", "...
Don't start service ``name`` at boot Returns ``True`` if operation is successful name the service's name stop if True, also stops the service CLI Example: .. code-block:: bash salt '*' service.disable <name> [stop=True]
[ "Don", "t", "start", "service", "name", "at", "boot", "Returns", "True", "if", "operation", "is", "successful" ]
python
train
xolox/python-qpass
qpass/__init__.py
https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L104-L108
def filtered_entries(self): """A list of :class:`PasswordEntry` objects that don't match the exclude list.""" return [ e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list) ]
[ "def", "filtered_entries", "(", "self", ")", ":", "return", "[", "e", "for", "e", "in", "self", ".", "entries", "if", "not", "any", "(", "fnmatch", ".", "fnmatch", "(", "e", ".", "name", ".", "lower", "(", ")", ",", "p", ".", "lower", "(", ")", ...
A list of :class:`PasswordEntry` objects that don't match the exclude list.
[ "A", "list", "of", ":", "class", ":", "PasswordEntry", "objects", "that", "don", "t", "match", "the", "exclude", "list", "." ]
python
train
matllubos/django-is-core
is_core/utils/__init__.py
https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/utils/__init__.py#L44-L56
def flatten_fieldsets(fieldsets): """Returns a list of field names from an admin fieldsets structure.""" field_names = [] for _, opts in fieldsets or (): if 'fieldsets' in opts: field_names += flatten_fieldsets(opts.get('fieldsets')) else: for field in opts.get('field...
[ "def", "flatten_fieldsets", "(", "fieldsets", ")", ":", "field_names", "=", "[", "]", "for", "_", ",", "opts", "in", "fieldsets", "or", "(", ")", ":", "if", "'fieldsets'", "in", "opts", ":", "field_names", "+=", "flatten_fieldsets", "(", "opts", ".", "ge...
Returns a list of field names from an admin fieldsets structure.
[ "Returns", "a", "list", "of", "field", "names", "from", "an", "admin", "fieldsets", "structure", "." ]
python
train
MacHu-GWU/angora-project
angora/algorithm/iterable.py
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L83-L97
def flatten_all(list_of_list): """Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object. Usage:: >>> flatten_all([[0, 1], [2, 3, [4, 5], [6, 7, 8]], [9,]]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] """ for i in list_of_list: if hasattr(i, "__iter__"): ...
[ "def", "flatten_all", "(", "list_of_list", ")", ":", "for", "i", "in", "list_of_list", ":", "if", "hasattr", "(", "i", ",", "\"__iter__\"", ")", ":", "for", "j", "in", "flatten_all", "(", "i", ")", ":", "yield", "j", "else", ":", "yield", "i" ]
Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object. Usage:: >>> flatten_all([[0, 1], [2, 3, [4, 5], [6, 7, 8]], [9,]]) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[ "Flatten", "arbitrary", "depth", "of", "nesting", ".", "Good", "for", "unknown", "nesting", "structure", "iterable", "object", "." ]
python
train
pysathq/pysat
examples/hitman.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/hitman.py#L317-L338
def hit(self, to_hit): """ This method adds a new set to hit to the hitting set solver. This is done by translating the input iterable of objects into a list of Boolean variables in the MaxSAT problem formulation. :param to_hit: a new set to hit :type...
[ "def", "hit", "(", "self", ",", "to_hit", ")", ":", "# translating objects to variables", "to_hit", "=", "list", "(", "map", "(", "lambda", "obj", ":", "self", ".", "idpool", ".", "id", "(", "obj", ")", ",", "to_hit", ")", ")", "# a soft clause should be a...
This method adds a new set to hit to the hitting set solver. This is done by translating the input iterable of objects into a list of Boolean variables in the MaxSAT problem formulation. :param to_hit: a new set to hit :type to_hit: iterable(obj)
[ "This", "method", "adds", "a", "new", "set", "to", "hit", "to", "the", "hitting", "set", "solver", ".", "This", "is", "done", "by", "translating", "the", "input", "iterable", "of", "objects", "into", "a", "list", "of", "Boolean", "variables", "in", "the"...
python
train
cocaine/cocaine-framework-python
cocaine/detail/headers.py
https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L145-L163
def get_by_index(self, index): """ Returns the entry specified by index Note that the table is 1-based ie an index of 0 is invalid. This is due to the fact that a zero value index signals that a completely unindexed header follows. The entry will either be from...
[ "def", "get_by_index", "(", "self", ",", "index", ")", ":", "index", "-=", "1", "if", "0", "<=", "index", "<", "len", "(", "CocaineHeaders", ".", "STATIC_TABLE", ")", ":", "return", "CocaineHeaders", ".", "STATIC_TABLE", "[", "index", "]", "index", "-=",...
Returns the entry specified by index Note that the table is 1-based ie an index of 0 is invalid. This is due to the fact that a zero value index signals that a completely unindexed header follows. The entry will either be from the static table or the dynamic table depe...
[ "Returns", "the", "entry", "specified", "by", "index" ]
python
train
bfontaine/term2048
term2048/board.py
https://github.com/bfontaine/term2048/blob/8b5ce8b65f44f20a7ad36022a34dce56184070af/term2048/board.py#L95-L97
def setCell(self, x, y, v): """set the cell value at x,y""" self.cells[y][x] = v
[ "def", "setCell", "(", "self", ",", "x", ",", "y", ",", "v", ")", ":", "self", ".", "cells", "[", "y", "]", "[", "x", "]", "=", "v" ]
set the cell value at x,y
[ "set", "the", "cell", "value", "at", "x", "y" ]
python
train
Jajcus/pyxmpp2
pyxmpp2/roster.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/roster.py#L729-L741
def handle_got_features_event(self, event): """Check for roster related features in the stream features received and set `server_features` accordingly. """ server_features = set() logger.debug("Checking roster-related features") if event.features.find(FEATURE_ROSTERVER) i...
[ "def", "handle_got_features_event", "(", "self", ",", "event", ")", ":", "server_features", "=", "set", "(", ")", "logger", ".", "debug", "(", "\"Checking roster-related features\"", ")", "if", "event", ".", "features", ".", "find", "(", "FEATURE_ROSTERVER", ")"...
Check for roster related features in the stream features received and set `server_features` accordingly.
[ "Check", "for", "roster", "related", "features", "in", "the", "stream", "features", "received", "and", "set", "server_features", "accordingly", "." ]
python
valid
OpenAgInitiative/openag_python
openag/cli/firmware/__init__.py
https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L386-L413
def load_plugin(plugin_name): """ Given a plugin name, load plugin cls from plugin directory. Will throw an exception if no plugin can be found. """ plugin_cls = plugin_map.get(plugin_name, None) if not plugin_cls: try: plugin_module_name, plugin_cls_name = plugin_name.split(...
[ "def", "load_plugin", "(", "plugin_name", ")", ":", "plugin_cls", "=", "plugin_map", ".", "get", "(", "plugin_name", ",", "None", ")", "if", "not", "plugin_cls", ":", "try", ":", "plugin_module_name", ",", "plugin_cls_name", "=", "plugin_name", ".", "split", ...
Given a plugin name, load plugin cls from plugin directory. Will throw an exception if no plugin can be found.
[ "Given", "a", "plugin", "name", "load", "plugin", "cls", "from", "plugin", "directory", ".", "Will", "throw", "an", "exception", "if", "no", "plugin", "can", "be", "found", "." ]
python
train
dmlc/gluon-nlp
src/gluonnlp/data/utils.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/data/utils.py#L152-L187
def slice_sequence(sequence, length, pad_last=False, pad_val=C.PAD_TOKEN, overlap=0): """Slice a flat sequence of tokens into sequences tokens, with each inner sequence's length equal to the specified `length`, taking into account the requested sequence overlap. Parameters ---------- sequence :...
[ "def", "slice_sequence", "(", "sequence", ",", "length", ",", "pad_last", "=", "False", ",", "pad_val", "=", "C", ".", "PAD_TOKEN", ",", "overlap", "=", "0", ")", ":", "if", "length", "<=", "overlap", ":", "raise", "ValueError", "(", "'length needs to be l...
Slice a flat sequence of tokens into sequences tokens, with each inner sequence's length equal to the specified `length`, taking into account the requested sequence overlap. Parameters ---------- sequence : list of object A flat list of tokens. length : int The length of each of...
[ "Slice", "a", "flat", "sequence", "of", "tokens", "into", "sequences", "tokens", "with", "each", "inner", "sequence", "s", "length", "equal", "to", "the", "specified", "length", "taking", "into", "account", "the", "requested", "sequence", "overlap", "." ]
python
train
rwl/pylon
pylon/case.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/case.py#L751-L779
def d2Sbr_dV2(self, Cbr, Ybr, V, lam): """ Based on d2Sbr_dV2.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more information. @rtype: tuple @return: The 2nd derivatives of complex power flow w.r.t. voltage. ...
[ "def", "d2Sbr_dV2", "(", "self", ",", "Cbr", ",", "Ybr", ",", "V", ",", "lam", ")", ":", "nb", "=", "len", "(", "V", ")", "nl", "=", "len", "(", "lam", ")", "ib", "=", "range", "(", "nb", ")", "il", "=", "range", "(", "nl", ")", "diaglam", ...
Based on d2Sbr_dV2.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more information. @rtype: tuple @return: The 2nd derivatives of complex power flow w.r.t. voltage.
[ "Based", "on", "d2Sbr_dV2", ".", "m", "from", "MATPOWER", "by", "Ray", "Zimmerman", "developed", "at", "PSERC", "Cornell", ".", "See", "U", "{", "http", ":", "//", "www", ".", "pserc", ".", "cornell", ".", "edu", "/", "matpower", "/", "}", "for", "mo...
python
train
sorgerlab/indra
indra/assemblers/kami/assembler.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/kami/assembler.py#L172-L183
def add_node(self, name_base, attrs=None): """Add a node with a given base name to the Nugget and return ID.""" if name_base not in self.counters: node_id = name_base else: node_id = '%s_%d' % (name_base, self.counters[name_base]) node = {'id': node_id} if...
[ "def", "add_node", "(", "self", ",", "name_base", ",", "attrs", "=", "None", ")", ":", "if", "name_base", "not", "in", "self", ".", "counters", ":", "node_id", "=", "name_base", "else", ":", "node_id", "=", "'%s_%d'", "%", "(", "name_base", ",", "self"...
Add a node with a given base name to the Nugget and return ID.
[ "Add", "a", "node", "with", "a", "given", "base", "name", "to", "the", "Nugget", "and", "return", "ID", "." ]
python
train
jantman/awslimitchecker
awslimitchecker/services/elasticbeanstalk.py
https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/elasticbeanstalk.py#L54-L68
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
[ "def", "find_usage", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Checking usage for service %s\"", ",", "self", ".", "service_name", ")", "self", ".", "connect", "(", ")", "for", "lim", "in", "self", ".", "limits", ".", "values", "(", ")", ":"...
Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`.
[ "Determine", "the", "current", "usage", "for", "each", "limit", "of", "this", "service", "and", "update", "corresponding", "Limit", "via", ":", "py", ":", "meth", ":", "~", ".", "AwsLimit", ".", "_add_current_usage", "." ]
python
train
barrust/mediawiki
mediawiki/mediawiki.py
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L575-L591
def summary(self, title, sentences=0, chars=0, auto_suggest=True, redirect=True): """ Get the summary for the title in question Args: title (str): Page title to summarize sentences (int): Number of sentences to return in summary chars (int): Number of...
[ "def", "summary", "(", "self", ",", "title", ",", "sentences", "=", "0", ",", "chars", "=", "0", ",", "auto_suggest", "=", "True", ",", "redirect", "=", "True", ")", ":", "page_info", "=", "self", ".", "page", "(", "title", ",", "auto_suggest", "=", ...
Get the summary for the title in question Args: title (str): Page title to summarize sentences (int): Number of sentences to return in summary chars (int): Number of characters to return in summary auto_suggest (bool): Run auto-suggest on titl...
[ "Get", "the", "summary", "for", "the", "title", "in", "question" ]
python
train
XuShaohua/bcloud
bcloud/DownloadPage.py
https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/DownloadPage.py#L607-L619
def start_task(self, row, scan=True): '''启动下载任务. 将任务状态设定为Downloading, 如果没有超过最大任务数的话; 否则将它设定为Waiting. ''' if not row or row[STATE_COL] in RUNNING_STATES : return row[STATE_COL] = State.WAITING row[STATENAME_COL] = StateNames[State.WAITING] self...
[ "def", "start_task", "(", "self", ",", "row", ",", "scan", "=", "True", ")", ":", "if", "not", "row", "or", "row", "[", "STATE_COL", "]", "in", "RUNNING_STATES", ":", "return", "row", "[", "STATE_COL", "]", "=", "State", ".", "WAITING", "row", "[", ...
启动下载任务. 将任务状态设定为Downloading, 如果没有超过最大任务数的话; 否则将它设定为Waiting.
[ "启动下载任务", "." ]
python
train
eyurtsev/FlowCytometryTools
FlowCytometryTools/core/bases.py
https://github.com/eyurtsev/FlowCytometryTools/blob/4355632508b875273d68c7e2972c17668bcf7b40/FlowCytometryTools/core/bases.py#L246-L255
def set_data(self, data=None, **kwargs): ''' Read data into memory, applying all actions in queue. Additionally, update queue and history. ''' if data is None: data = self.get_data(**kwargs) setattr(self, '_data', data) self.history += self.queue ...
[ "def", "set_data", "(", "self", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "data", "is", "None", ":", "data", "=", "self", ".", "get_data", "(", "*", "*", "kwargs", ")", "setattr", "(", "self", ",", "'_data'", ",", "data",...
Read data into memory, applying all actions in queue. Additionally, update queue and history.
[ "Read", "data", "into", "memory", "applying", "all", "actions", "in", "queue", ".", "Additionally", "update", "queue", "and", "history", "." ]
python
train
jxtech/wechatpy
wechatpy/client/api/invoice.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/invoice.py#L232-L249
def update_status(self, card_id, code, reimburse_status): """ 更新发票卡券的状态 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param card_id: 发票卡券模板的编号 :param code: 发票卡券的编号 :param reimburse_status: 发票报销状态 """ return self._post( 'pl...
[ "def", "update_status", "(", "self", ",", "card_id", ",", "code", ",", "reimburse_status", ")", ":", "return", "self", ".", "_post", "(", "'platform/updatestatus'", ",", "data", "=", "{", "'card_id'", ":", "card_id", ",", "'code'", ":", "code", ",", "'reim...
更新发票卡券的状态 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param card_id: 发票卡券模板的编号 :param code: 发票卡券的编号 :param reimburse_status: 发票报销状态
[ "更新发票卡券的状态", "详情请参考", "https", ":", "//", "mp", ".", "weixin", ".", "qq", ".", "com", "/", "wiki?id", "=", "mp1497082828_r1cI2" ]
python
train
saltstack/salt
salt/modules/win_pkg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_pkg.py#L257-L314
def list_available(*names, **kwargs): ''' Return a list of available versions of the specified package. Args: names (str): One or more package names Kwargs: saltenv (str): The salt environment to use. Default ``base``. refresh (bool): Refresh package metadata. Default ``False...
[ "def", "list_available", "(", "*", "names", ",", "*", "*", "kwargs", ")", ":", "if", "not", "names", ":", "return", "''", "saltenv", "=", "kwargs", ".", "get", "(", "'saltenv'", ",", "'base'", ")", "refresh", "=", "salt", ".", "utils", ".", "data", ...
Return a list of available versions of the specified package. Args: names (str): One or more package names Kwargs: saltenv (str): The salt environment to use. Default ``base``. refresh (bool): Refresh package metadata. Default ``False``. return_dict_always (bool): ...
[ "Return", "a", "list", "of", "available", "versions", "of", "the", "specified", "package", "." ]
python
train
choderalab/pymbar
examples/heat-capacity/heat-capacity.py
https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/examples/heat-capacity/heat-capacity.py#L75-L108
def read_total_energies(pathname,colnum): """Reads in the TEMP#/ener_box#.output file and parses it, returning an array of energies ARGUMENTS filename (string) - the path to the folder of the simulation colnum (integer) column the energy is found in """ print("--Reading total energies from %s...
[ "def", "read_total_energies", "(", "pathname", ",", "colnum", ")", ":", "print", "(", "\"--Reading total energies from %s/...\"", "%", "pathname", ")", "# Initialize Return variables", "E_kn", "=", "numpy", ".", "zeros", "(", "[", "NumTemps", ",", "NumIterations", "...
Reads in the TEMP#/ener_box#.output file and parses it, returning an array of energies ARGUMENTS filename (string) - the path to the folder of the simulation colnum (integer) column the energy is found in
[ "Reads", "in", "the", "TEMP#", "/", "ener_box#", ".", "output", "file", "and", "parses", "it", "returning", "an", "array", "of", "energies" ]
python
train
sthysel/knobs
src/knobs.py
https://github.com/sthysel/knobs/blob/1d01f50f643068076e38118a93fed9375ea3ac81/src/knobs.py#L225-L250
def get(self): """ convert json env variable if set to list """ self._cast = type([]) source_value = os.getenv(self.env_name) # set the environment if it is not set if source_value is None: os.environ[self.env_name] = json.dumps(self.default) ...
[ "def", "get", "(", "self", ")", ":", "self", ".", "_cast", "=", "type", "(", "[", "]", ")", "source_value", "=", "os", ".", "getenv", "(", "self", ".", "env_name", ")", "# set the environment if it is not set", "if", "source_value", "is", "None", ":", "o...
convert json env variable if set to list
[ "convert", "json", "env", "variable", "if", "set", "to", "list" ]
python
train
numenta/nupic
src/nupic/encoders/scalar.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L421-L468
def encodeIntoArray(self, input, output, learn=True): """ See method description in base.py """ if input is not None and not isinstance(input, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(input)) if type(input) is float and math.isnan(input): ...
[ "def", "encodeIntoArray", "(", "self", ",", "input", ",", "output", ",", "learn", "=", "True", ")", ":", "if", "input", "is", "not", "None", "and", "not", "isinstance", "(", "input", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", ...
See method description in base.py
[ "See", "method", "description", "in", "base", ".", "py" ]
python
valid
mamrhein/identifiers
identifiers/banking.py
https://github.com/mamrhein/identifiers/blob/93ab2609e461faff245d1f582411bf831b428eef/identifiers/banking.py#L155-L158
def bank_account_number(self): """Return the IBAN's Bank Account Number.""" start = get_iban_spec(self.country_code).bban_split_pos + 4 return self._id[start:]
[ "def", "bank_account_number", "(", "self", ")", ":", "start", "=", "get_iban_spec", "(", "self", ".", "country_code", ")", ".", "bban_split_pos", "+", "4", "return", "self", ".", "_id", "[", "start", ":", "]" ]
Return the IBAN's Bank Account Number.
[ "Return", "the", "IBAN", "s", "Bank", "Account", "Number", "." ]
python
train