repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
Capitains/MyCapytain
MyCapytain/common/utils/_json_ld.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/_json_ld.py#L4-L19
def literal_to_dict(value): """ Transform an object value into a dict readable value :param value: Object of a triple which is not a BNode :type value: Literal or URIRef :return: dict or str or list """ if isinstance(value, Literal): if value.language is not None: return {"@...
[ "def", "literal_to_dict", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Literal", ")", ":", "if", "value", ".", "language", "is", "not", "None", ":", "return", "{", "\"@value\"", ":", "str", "(", "value", ")", ",", "\"@language\"", ":...
Transform an object value into a dict readable value :param value: Object of a triple which is not a BNode :type value: Literal or URIRef :return: dict or str or list
[ "Transform", "an", "object", "value", "into", "a", "dict", "readable", "value" ]
python
train
32.625
mongodb/mongo-python-driver
pymongo/client_session.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/client_session.py#L529-L573
def commit_transaction(self): """Commit a multi-statement transaction. .. versionadded:: 3.7 """ self._check_ended() retry = False state = self._transaction.state if state is _TxnState.NONE: raise InvalidOperation("No transaction started") eli...
[ "def", "commit_transaction", "(", "self", ")", ":", "self", ".", "_check_ended", "(", ")", "retry", "=", "False", "state", "=", "self", ".", "_transaction", ".", "state", "if", "state", "is", "_TxnState", ".", "NONE", ":", "raise", "InvalidOperation", "(",...
Commit a multi-statement transaction. .. versionadded:: 3.7
[ "Commit", "a", "multi", "-", "statement", "transaction", "." ]
python
train
46.088889
zooniverse/panoptes-python-client
panoptes_client/subject_set.py
https://github.com/zooniverse/panoptes-python-client/blob/138d93cb03378501a8d349428e381ad73f928680/panoptes_client/subject_set.py#L69-L82
def subjects(self): """ A generator which yields :py:class:`.Subject` objects which are in this subject set. Examples:: for subject in subject_set.subjects: print(subject.id) """ for sms in SetMemberSubject.where(subject_set_id=self.id): ...
[ "def", "subjects", "(", "self", ")", ":", "for", "sms", "in", "SetMemberSubject", ".", "where", "(", "subject_set_id", "=", "self", ".", "id", ")", ":", "yield", "sms", ".", "links", ".", "subject" ]
A generator which yields :py:class:`.Subject` objects which are in this subject set. Examples:: for subject in subject_set.subjects: print(subject.id)
[ "A", "generator", "which", "yields", ":", "py", ":", "class", ":", ".", "Subject", "objects", "which", "are", "in", "this", "subject", "set", "." ]
python
train
24.285714
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavextra.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavextra.py#L635-L640
def gps_velocity_body(GPS_RAW_INT, ATTITUDE): '''return GPS velocity vector in body frame''' r = rotation(ATTITUDE) return r.transposed() * Vector3(GPS_RAW_INT.vel*0.01*cos(radians(GPS_RAW_INT.cog*0.01)), GPS_RAW_INT.vel*0.01*sin(radians(GPS_RAW_INT.cog*0.01)), ...
[ "def", "gps_velocity_body", "(", "GPS_RAW_INT", ",", "ATTITUDE", ")", ":", "r", "=", "rotation", "(", "ATTITUDE", ")", "return", "r", ".", "transposed", "(", ")", "*", "Vector3", "(", "GPS_RAW_INT", ".", "vel", "*", "0.01", "*", "cos", "(", "radians", ...
return GPS velocity vector in body frame
[ "return", "GPS", "velocity", "vector", "in", "body", "frame" ]
python
train
63.833333
UCL-INGI/INGInious
inginious/agent/docker_agent/__init__.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/agent/docker_agent/__init__.py#L501-L627
async def handle_job_closing(self, container_id, retval): """ Handle a closing student container. Do some cleaning, verify memory limits, timeouts, ... and returns data to the backend """ try: self._logger.debug("Closing %s", container_id) try: mes...
[ "async", "def", "handle_job_closing", "(", "self", ",", "container_id", ",", "retval", ")", ":", "try", ":", "self", ".", "_logger", ".", "debug", "(", "\"Closing %s\"", ",", "container_id", ")", "try", ":", "message", ",", "container_path", ",", "future_res...
Handle a closing student container. Do some cleaning, verify memory limits, timeouts, ... and returns data to the backend
[ "Handle", "a", "closing", "student", "container", ".", "Do", "some", "cleaning", "verify", "memory", "limits", "timeouts", "...", "and", "returns", "data", "to", "the", "backend" ]
python
train
46.346457
zakdoek/django-simple-resizer
simple_resizer/__init__.py
https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/__init__.py#L147-L169
def resize(image, width=None, height=None, crop=False): """ Resize an image and return the resized file. """ # First normalize params to determine which file to get width, height, crop = _normalize_params(image, width, height, crop) try: # Check the image file state for clean close ...
[ "def", "resize", "(", "image", ",", "width", "=", "None", ",", "height", "=", "None", ",", "crop", "=", "False", ")", ":", "# First normalize params to determine which file to get", "width", ",", "height", ",", "crop", "=", "_normalize_params", "(", "image", "...
Resize an image and return the resized file.
[ "Resize", "an", "image", "and", "return", "the", "resized", "file", "." ]
python
train
27.869565
lepture/flask-oauthlib
flask_oauthlib/contrib/oauth2.py
https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L304-L322
def set(self, client_id, code, request, *args, **kwargs): """Creates Grant object with the given params :param client_id: ID of the client :param code: :param request: OAuthlib request object """ expires = datetime.utcnow() + timedelta(seconds=100) grant = self.m...
[ "def", "set", "(", "self", ",", "client_id", ",", "code", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "expires", "=", "datetime", ".", "utcnow", "(", ")", "+", "timedelta", "(", "seconds", "=", "100", ")", "grant", "=", "...
Creates Grant object with the given params :param client_id: ID of the client :param code: :param request: OAuthlib request object
[ "Creates", "Grant", "object", "with", "the", "given", "params" ]
python
test
32.421053
RRZE-HPC/kerncraft
kerncraft/iaca.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/iaca.py#L59-L217
def find_asm_blocks(asm_lines): """Find blocks probably corresponding to loops in assembly.""" blocks = [] last_labels = OrderedDict() packed_ctr = 0 avx_ctr = 0 xmm_references = [] ymm_references = [] zmm_references = [] gp_references = [] mem_references = [] increments = {...
[ "def", "find_asm_blocks", "(", "asm_lines", ")", ":", "blocks", "=", "[", "]", "last_labels", "=", "OrderedDict", "(", ")", "packed_ctr", "=", "0", "avx_ctr", "=", "0", "xmm_references", "=", "[", "]", "ymm_references", "=", "[", "]", "zmm_references", "="...
Find blocks probably corresponding to loops in assembly.
[ "Find", "blocks", "probably", "corresponding", "to", "loops", "in", "assembly", "." ]
python
test
48.119497
openp2pdesign/makerlabs
makerlabs/timeline.py
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/timeline.py#L24-L39
def get_multiple_data(): """Get data from all the platforms listed in makerlabs.""" # Get data from all the mapped platforms all_labs = {} all_labs["diybio_org"] = diybio_org.get_labs(format="dict") all_labs["fablabs_io"] = fablabs_io.get_labs(format="dict") all_labs["makeinitaly_foundation"] =...
[ "def", "get_multiple_data", "(", ")", ":", "# Get data from all the mapped platforms", "all_labs", "=", "{", "}", "all_labs", "[", "\"diybio_org\"", "]", "=", "diybio_org", ".", "get_labs", "(", "format", "=", "\"dict\"", ")", "all_labs", "[", "\"fablabs_io\"", "]...
Get data from all the platforms listed in makerlabs.
[ "Get", "data", "from", "all", "the", "platforms", "listed", "in", "makerlabs", "." ]
python
train
44.5
fabioz/PyDev.Debugger
third_party/pep8/pycodestyle.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/pycodestyle.py#L1597-L1607
def check_physical(self, line): """Run all physical checks on a raw input line.""" self.physical_line = line for name, check, argument_names in self._physical_checks: self.init_checker_state(name, argument_names) result = self.run_check(check, argument_names) ...
[ "def", "check_physical", "(", "self", ",", "line", ")", ":", "self", ".", "physical_line", "=", "line", "for", "name", ",", "check", ",", "argument_names", "in", "self", ".", "_physical_checks", ":", "self", ".", "init_checker_state", "(", "name", ",", "ar...
Run all physical checks on a raw input line.
[ "Run", "all", "physical", "checks", "on", "a", "raw", "input", "line", "." ]
python
train
48.272727
isislovecruft/python-gnupg
pretty_bad_protocol/gnupg.py
https://github.com/isislovecruft/python-gnupg/blob/784571449032e811587249743e183fc5e908a673/pretty_bad_protocol/gnupg.py#L504-L538
def sign_key(self, keyid, default_key=None, passphrase=None): """ sign (an imported) public key - keyid, with default secret key >>> import gnupg >>> gpg = gnupg.GPG(homedir="doctests") >>> key_input = gpg.gen_key_input() >>> key = gpg.gen_key(key_input) >>> gpg.sign_key...
[ "def", "sign_key", "(", "self", ",", "keyid", ",", "default_key", "=", "None", ",", "passphrase", "=", "None", ")", ":", "args", "=", "[", "]", "input_command", "=", "\"\"", "if", "passphrase", ":", "passphrase_arg", "=", "\"--passphrase-fd 0\"", "input_comm...
sign (an imported) public key - keyid, with default secret key >>> import gnupg >>> gpg = gnupg.GPG(homedir="doctests") >>> key_input = gpg.gen_key_input() >>> key = gpg.gen_key(key_input) >>> gpg.sign_key(key['fingerprint']) >>> gpg.list_sigs(key['fingerprint']) ...
[ "sign", "(", "an", "imported", ")", "public", "key", "-", "keyid", "with", "default", "secret", "key" ]
python
train
36.771429
ska-sa/katcp-python
katcp/core.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/core.py#L135-L159
def steal_docstring_from(obj): """Decorator that lets you steal a docstring from another object Example ------- :: @steal_docstring_from(superclass.meth) def meth(self, arg): "Extra subclass documentation" pass In this case the docstring of the new 'meth' will be copied f...
[ "def", "steal_docstring_from", "(", "obj", ")", ":", "def", "deco", "(", "fn", ")", ":", "docs", "=", "[", "obj", ".", "__doc__", "]", "if", "fn", ".", "__doc__", ":", "docs", ".", "append", "(", "fn", ".", "__doc__", ")", "fn", ".", "__doc__", "...
Decorator that lets you steal a docstring from another object Example ------- :: @steal_docstring_from(superclass.meth) def meth(self, arg): "Extra subclass documentation" pass In this case the docstring of the new 'meth' will be copied from superclass.meth, and if an add...
[ "Decorator", "that", "lets", "you", "steal", "a", "docstring", "from", "another", "object" ]
python
train
25.72
deschler/django-modeltranslation
modeltranslation/translator.py
https://github.com/deschler/django-modeltranslation/blob/18fec04a5105cbd83fc3759f4fda20135b3a848c/modeltranslation/translator.py#L196-L220
def add_manager(model): """ Monkey patches the original model to use MultilingualManager instead of default managers (not only ``objects``, but also every manager defined and inherited). Custom managers are merged with MultilingualManager. """ if model._meta.abstract: return # Make ...
[ "def", "add_manager", "(", "model", ")", ":", "if", "model", ".", "_meta", ".", "abstract", ":", "return", "# Make all managers local for this model to fix patching parent model managers", "model", ".", "_meta", ".", "local_managers", "=", "model", ".", "_meta", ".", ...
Monkey patches the original model to use MultilingualManager instead of default managers (not only ``objects``, but also every manager defined and inherited). Custom managers are merged with MultilingualManager.
[ "Monkey", "patches", "the", "original", "model", "to", "use", "MultilingualManager", "instead", "of", "default", "managers", "(", "not", "only", "objects", "but", "also", "every", "manager", "defined", "and", "inherited", ")", "." ]
python
train
46.2
pybel/pybel
src/pybel/struct/summary/edge_summary.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/summary/edge_summary.py#L83-L92
def count_relations(graph) -> Counter: """Return a histogram over all relationships in a graph. :param pybel.BELGraph graph: A BEL graph :return: A Counter from {relation type: frequency} """ return Counter( data[RELATION] for _, _, data in graph.edges(data=True) )
[ "def", "count_relations", "(", "graph", ")", "->", "Counter", ":", "return", "Counter", "(", "data", "[", "RELATION", "]", "for", "_", ",", "_", ",", "data", "in", "graph", ".", "edges", "(", "data", "=", "True", ")", ")" ]
Return a histogram over all relationships in a graph. :param pybel.BELGraph graph: A BEL graph :return: A Counter from {relation type: frequency}
[ "Return", "a", "histogram", "over", "all", "relationships", "in", "a", "graph", "." ]
python
train
29.7
googledatalab/pydatalab
google/datalab/bigquery/commands/_bigquery.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/commands/_bigquery.py#L325-L352
def _get_query_argument(args, cell, env): """ Get a query argument to a cell magic. The query is specified with args['query']. We look that up and if it is a BQ query object, just return it. If it is a string, build a query object out of it and return that Args: args: the dictionary of magic arguments. ...
[ "def", "_get_query_argument", "(", "args", ",", "cell", ",", "env", ")", ":", "sql_arg", "=", "args", ".", "get", "(", "'query'", ",", "None", ")", "if", "sql_arg", "is", "None", ":", "# Assume we have inline SQL in the cell", "if", "not", "isinstance", "(",...
Get a query argument to a cell magic. The query is specified with args['query']. We look that up and if it is a BQ query object, just return it. If it is a string, build a query object out of it and return that Args: args: the dictionary of magic arguments. cell: the cell contents which can be variabl...
[ "Get", "a", "query", "argument", "to", "a", "cell", "magic", "." ]
python
train
34.857143
mwickert/scikit-dsp-comm
sk_dsp_comm/iir_design_helper.py
https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/iir_design_helper.py#L301-L312
def freqz_cas(sos,w): """ Cascade frequency response Mark Wickert October 2016 """ Ns,Mcol = sos.shape w,Hcas = signal.freqz(sos[0,:3],sos[0,3:],w) for k in range(1,Ns): w,Htemp = signal.freqz(sos[k,:3],sos[k,3:],w) Hcas *= Htemp return w, Hcas
[ "def", "freqz_cas", "(", "sos", ",", "w", ")", ":", "Ns", ",", "Mcol", "=", "sos", ".", "shape", "w", ",", "Hcas", "=", "signal", ".", "freqz", "(", "sos", "[", "0", ",", ":", "3", "]", ",", "sos", "[", "0", ",", "3", ":", "]", ",", "w", ...
Cascade frequency response Mark Wickert October 2016
[ "Cascade", "frequency", "response", "Mark", "Wickert", "October", "2016" ]
python
valid
24.75
mjirik/imtools
imtools/show_segmentation.py
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/show_segmentation.py#L126-L135
def select_labels(self, labels=None): """ Prepare binar segmentation based on input segmentation and labels. :param labels: :return: """ self._resize_if_required() segmentation = self._select_labels(self.resized_segmentation, labels) # logger.debug("select labels...
[ "def", "select_labels", "(", "self", ",", "labels", "=", "None", ")", ":", "self", ".", "_resize_if_required", "(", ")", "segmentation", "=", "self", ".", "_select_labels", "(", "self", ".", "resized_segmentation", ",", "labels", ")", "# logger.debug(\"select la...
Prepare binar segmentation based on input segmentation and labels. :param labels: :return:
[ "Prepare", "binar", "segmentation", "based", "on", "input", "segmentation", "and", "labels", "." ]
python
train
43.6
scanny/python-pptx
pptx/text/fonts.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/fonts.py#L295-L306
def family_name(self): """ The name of the typeface family for this font, e.g. 'Arial'. """ def find_first(dict_, keys, default=None): for key in keys: value = dict_.get(key) if value is not None: return value re...
[ "def", "family_name", "(", "self", ")", ":", "def", "find_first", "(", "dict_", ",", "keys", ",", "default", "=", "None", ")", ":", "for", "key", "in", "keys", ":", "value", "=", "dict_", ".", "get", "(", "key", ")", "if", "value", "is", "not", "...
The name of the typeface family for this font, e.g. 'Arial'.
[ "The", "name", "of", "the", "typeface", "family", "for", "this", "font", "e", ".", "g", ".", "Arial", "." ]
python
train
38.083333
Rapptz/discord.py
examples/basic_voice.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_voice.py#L69-L75
async def play(self, ctx, *, query): """Plays a file from the local filesystem""" source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) await ctx.send('Now playing: {}'.format(que...
[ "async", "def", "play", "(", "self", ",", "ctx", ",", "*", ",", "query", ")", ":", "source", "=", "discord", ".", "PCMVolumeTransformer", "(", "discord", ".", "FFmpegPCMAudio", "(", "query", ")", ")", "ctx", ".", "voice_client", ".", "play", "(", "sour...
Plays a file from the local filesystem
[ "Plays", "a", "file", "from", "the", "local", "filesystem" ]
python
train
45.428571
pytroll/satpy
satpy/node.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/node.py#L279-L313
def _find_reader_dataset(self, dataset_key, **dfilter): """Attempt to find a `DatasetID` in the available readers. Args: dataset_key (str, float, DatasetID): Dataset name, wavelength, or a combination of `DatasetID` parameters to use in searching for the data...
[ "def", "_find_reader_dataset", "(", "self", ",", "dataset_key", ",", "*", "*", "dfilter", ")", ":", "too_many", "=", "False", "for", "reader_name", ",", "reader_instance", "in", "self", ".", "readers", ".", "items", "(", ")", ":", "try", ":", "ds_id", "=...
Attempt to find a `DatasetID` in the available readers. Args: dataset_key (str, float, DatasetID): Dataset name, wavelength, or a combination of `DatasetID` parameters to use in searching for the dataset from the available readers. **dfilt...
[ "Attempt", "to", "find", "a", "DatasetID", "in", "the", "available", "readers", "." ]
python
train
51.485714
WhyNotHugo/django-afip
django_afip/models.py
https://github.com/WhyNotHugo/django-afip/blob/5fb73213f1fe86ca52b501ffd0737911ef26ddb3/django_afip/models.py#L385-L414
def fetch_points_of_sales(self, ticket=None): """ Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,). """ ticket = ticket or self.get_or_create_ticke...
[ "def", "fetch_points_of_sales", "(", "self", ",", "ticket", "=", "None", ")", ":", "ticket", "=", "ticket", "or", "self", ".", "get_or_create_ticket", "(", "'wsfe'", ")", "client", "=", "clients", ".", "get_client", "(", "'wsfe'", ",", "self", ".", "is_san...
Fetch all point of sales objects. Fetch all point of sales from the WS and store (or update) them locally. Returns a list of tuples with the format (pos, created,).
[ "Fetch", "all", "point", "of", "sales", "objects", "." ]
python
train
32.766667
carsongee/flask-htpasswd
flask_htpasswd.py
https://github.com/carsongee/flask-htpasswd/blob/db6fe596dd167f33aeb3d77e975c861d0534cecf/flask_htpasswd.py#L76-L90
def check_basic_auth(self, username, password): """ This function is called to check if a username / password combination is valid via the htpasswd file. """ valid = self.users.check_password( username, password ) if not valid: log.warning(...
[ "def", "check_basic_auth", "(", "self", ",", "username", ",", "password", ")", ":", "valid", "=", "self", ".", "users", ".", "check_password", "(", "username", ",", "password", ")", "if", "not", "valid", ":", "log", ".", "warning", "(", "'Invalid login fro...
This function is called to check if a username / password combination is valid via the htpasswd file.
[ "This", "function", "is", "called", "to", "check", "if", "a", "username", "/", "password", "combination", "is", "valid", "via", "the", "htpasswd", "file", "." ]
python
train
28.866667
reingart/gui2py
gui/controls/listview.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/controls/listview.py#L183-L187
def clear_all(self): "Remove all items and column headings" self.clear() for ch in reversed(self.columns): del self[ch.name]
[ "def", "clear_all", "(", "self", ")", ":", "self", ".", "clear", "(", ")", "for", "ch", "in", "reversed", "(", "self", ".", "columns", ")", ":", "del", "self", "[", "ch", ".", "name", "]" ]
Remove all items and column headings
[ "Remove", "all", "items", "and", "column", "headings" ]
python
test
32
pandas-dev/pandas
pandas/core/dtypes/common.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L90-L114
def ensure_int64_or_float64(arr, copy=False): """ Ensure that an dtype array of some integer dtype has an int64 dtype if possible If it's not possible, potentially because of overflow, convert the array to float64 instead. Parameters ---------- arr : array-like The array whose...
[ "def", "ensure_int64_or_float64", "(", "arr", ",", "copy", "=", "False", ")", ":", "try", ":", "return", "arr", ".", "astype", "(", "'int64'", ",", "copy", "=", "copy", ",", "casting", "=", "'safe'", ")", "except", "TypeError", ":", "return", "arr", "....
Ensure that an dtype array of some integer dtype has an int64 dtype if possible If it's not possible, potentially because of overflow, convert the array to float64 instead. Parameters ---------- arr : array-like The array whose data type we want to enforce. copy: boolean ...
[ "Ensure", "that", "an", "dtype", "array", "of", "some", "integer", "dtype", "has", "an", "int64", "dtype", "if", "possible", "If", "it", "s", "not", "possible", "potentially", "because", "of", "overflow", "convert", "the", "array", "to", "float64", "instead"...
python
train
30.12
funkybob/knights-templater
knights/tags.py
https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L74-L93
def _create_with_scope(body, kwargs): ''' Helper function to wrap a block in a scope stack: with ContextScope(context, **kwargs) as context: ... body ... ''' return ast.With( items=[ ast.withitem( context_expr=_a.Call( _a.Name('Context...
[ "def", "_create_with_scope", "(", "body", ",", "kwargs", ")", ":", "return", "ast", ".", "With", "(", "items", "=", "[", "ast", ".", "withitem", "(", "context_expr", "=", "_a", ".", "Call", "(", "_a", ".", "Name", "(", "'ContextScope'", ")", ",", "["...
Helper function to wrap a block in a scope stack: with ContextScope(context, **kwargs) as context: ... body ...
[ "Helper", "function", "to", "wrap", "a", "block", "in", "a", "scope", "stack", ":" ]
python
train
26.2
python-bonobo/bonobo
bonobo/registry.py
https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/bonobo/registry.py#L94-L106
def create_reader(name, *args, format=None, registry=default_registry, **kwargs): """ Create a reader instance, guessing its factory using filename (and eventually format). :param name: :param args: :param format: :param registry: :param kwargs: :return: mixed """ return regist...
[ "def", "create_reader", "(", "name", ",", "*", "args", ",", "format", "=", "None", ",", "registry", "=", "default_registry", ",", "*", "*", "kwargs", ")", ":", "return", "registry", ".", "get_reader_factory_for", "(", "name", ",", "format", "=", "format", ...
Create a reader instance, guessing its factory using filename (and eventually format). :param name: :param args: :param format: :param registry: :param kwargs: :return: mixed
[ "Create", "a", "reader", "instance", "guessing", "its", "factory", "using", "filename", "(", "and", "eventually", "format", ")", "." ]
python
train
29
oemof/oemof.db
oemof/db/config.py
https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/config.py#L113-L125
def init(FILE): """ Read config file :param FILE: Absolute path to config file (incl. filename) :type FILE: str """ try: cfg.read(FILE) global _loaded _loaded = True except: file_not_found_message(FILE)
[ "def", "init", "(", "FILE", ")", ":", "try", ":", "cfg", ".", "read", "(", "FILE", ")", "global", "_loaded", "_loaded", "=", "True", "except", ":", "file_not_found_message", "(", "FILE", ")" ]
Read config file :param FILE: Absolute path to config file (incl. filename) :type FILE: str
[ "Read", "config", "file" ]
python
train
19.307692
ranaroussi/qtpylib
qtpylib/tools.py
https://github.com/ranaroussi/qtpylib/blob/0dbbc465fafd9cb9b0f4d10e1e07fae4e15032dd/qtpylib/tools.py#L447-L452
def after_third_friday(day=None): """ check if day is after month's 3rd friday """ day = day if day is not None else datetime.datetime.now() now = day.replace(day=1, hour=16, minute=0, second=0, microsecond=0) now += relativedelta.relativedelta(weeks=2, weekday=relativedelta.FR) return day > now
[ "def", "after_third_friday", "(", "day", "=", "None", ")", ":", "day", "=", "day", "if", "day", "is", "not", "None", "else", "datetime", ".", "datetime", ".", "now", "(", ")", "now", "=", "day", ".", "replace", "(", "day", "=", "1", ",", "hour", ...
check if day is after month's 3rd friday
[ "check", "if", "day", "is", "after", "month", "s", "3rd", "friday" ]
python
train
51.833333
ray-project/ray
python/ray/experimental/tf_utils.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L159-L169
def get_weights(self): """Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights. """ self._check_sess() return { k: v.eval(session=self.sess) for k, v in self.variables.items() ...
[ "def", "get_weights", "(", "self", ")", ":", "self", ".", "_check_sess", "(", ")", "return", "{", "k", ":", "v", ".", "eval", "(", "session", "=", "self", ".", "sess", ")", "for", "k", ",", "v", "in", "self", ".", "variables", ".", "items", "(", ...
Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights.
[ "Returns", "a", "dictionary", "containing", "the", "weights", "of", "the", "network", "." ]
python
train
29
has2k1/plotnine
plotnine/utils.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/utils.py#L342-L374
def join_keys(x, y, by=None): """ Join keys. Given two data frames, create a unique key for each row. Parameters ----------- x : dataframe y : dataframe by : list-like Column names to join by Returns ------- out : dict Dictionary with keys x and y. The valu...
[ "def", "join_keys", "(", "x", ",", "y", ",", "by", "=", "None", ")", ":", "if", "by", "is", "None", ":", "by", "=", "slice", "(", "None", ",", "None", ",", "None", ")", "if", "isinstance", "(", "by", ",", "tuple", ")", ":", "by", "=", "list",...
Join keys. Given two data frames, create a unique key for each row. Parameters ----------- x : dataframe y : dataframe by : list-like Column names to join by Returns ------- out : dict Dictionary with keys x and y. The values of both keys are arrays with in...
[ "Join", "keys", "." ]
python
train
24.666667
frawau/aiolifx
aiolifx/aiolifx.py
https://github.com/frawau/aiolifx/blob/9bd8c5e6d291f4c79314989402f7e2c6476d5851/aiolifx/aiolifx.py#L1168-L1222
def datagram_received(self, data, addr): """Method run when data is received from the devices This method will unpack the data according to the LIFX protocol. If a new device is found, the Light device will be created and started aa a DatagramProtocol and will be registered with the par...
[ "def", "datagram_received", "(", "self", ",", "data", ",", "addr", ")", ":", "response", "=", "unpack_lifx_message", "(", "data", ")", "response", ".", "ip_addr", "=", "addr", "[", "0", "]", "mac_addr", "=", "response", ".", "target_addr", "if", "mac_addr"...
Method run when data is received from the devices This method will unpack the data according to the LIFX protocol. If a new device is found, the Light device will be created and started aa a DatagramProtocol and will be registered with the parent. :param data: raw data ...
[ "Method", "run", "when", "data", "is", "received", "from", "the", "devices" ]
python
train
34.163636
joyent/python-manta
manta/cmdln.py
https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L851-L879
def _get_canonical_map(self): """Return a mapping of available command names and aliases to their canonical command name. """ cacheattr = "_token2canonical" if not hasattr(self, cacheattr): # Get the list of commands and their aliases, if any. token2canoni...
[ "def", "_get_canonical_map", "(", "self", ")", ":", "cacheattr", "=", "\"_token2canonical\"", "if", "not", "hasattr", "(", "self", ",", "cacheattr", ")", ":", "# Get the list of commands and their aliases, if any.", "token2canonical", "=", "{", "}", "cmd2funcname", "=...
Return a mapping of available command names and aliases to their canonical command name.
[ "Return", "a", "mapping", "of", "available", "command", "names", "and", "aliases", "to", "their", "canonical", "command", "name", "." ]
python
train
47.448276
pypa/setuptools
setuptools/command/bdist_egg.py
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/bdist_egg.py#L442-L451
def iter_symbols(code): """Yield names and strings used by `code` and its nested code objects""" for name in code.co_names: yield name for const in code.co_consts: if isinstance(const, six.string_types): yield const elif isinstance(const, CodeType): for name i...
[ "def", "iter_symbols", "(", "code", ")", ":", "for", "name", "in", "code", ".", "co_names", ":", "yield", "name", "for", "const", "in", "code", ".", "co_consts", ":", "if", "isinstance", "(", "const", ",", "six", ".", "string_types", ")", ":", "yield",...
Yield names and strings used by `code` and its nested code objects
[ "Yield", "names", "and", "strings", "used", "by", "code", "and", "its", "nested", "code", "objects" ]
python
train
36
brocade/pynos
pynos/versions/base/interface.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/interface.py#L3008-L3021
def get_port_chann_detail_request(last_aggregator_id): """ Creates a new Netconf request based on the last received aggregator id when the hasMore flag is true """ port_channel_ns = 'urn:brocade.com:mgmt:brocade-lag' request_port_channel = ET.Element('get-port-channel-detail', ...
[ "def", "get_port_chann_detail_request", "(", "last_aggregator_id", ")", ":", "port_channel_ns", "=", "'urn:brocade.com:mgmt:brocade-lag'", "request_port_channel", "=", "ET", ".", "Element", "(", "'get-port-channel-detail'", ",", "xmlns", "=", "port_channel_ns", ")", "if", ...
Creates a new Netconf request based on the last received aggregator id when the hasMore flag is true
[ "Creates", "a", "new", "Netconf", "request", "based", "on", "the", "last", "received", "aggregator", "id", "when", "the", "hasMore", "flag", "is", "true" ]
python
train
47.571429
materialsproject/pymatgen
pymatgen/analysis/quasiharmonic.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/quasiharmonic.py#L291-L312
def thermal_conductivity(self, temperature, volume): """ Eq(17) in 10.1103/PhysRevB.90.174107 Args: temperature (float): temperature in K volume (float): in Ang^3 Returns: float: thermal conductivity in W/K/m """ gamma = self.gruneise...
[ "def", "thermal_conductivity", "(", "self", ",", "temperature", ",", "volume", ")", ":", "gamma", "=", "self", ".", "gruneisen_parameter", "(", "temperature", ",", "volume", ")", "theta_d", "=", "self", ".", "debye_temperature", "(", "volume", ")", "# K", "t...
Eq(17) in 10.1103/PhysRevB.90.174107 Args: temperature (float): temperature in K volume (float): in Ang^3 Returns: float: thermal conductivity in W/K/m
[ "Eq", "(", "17", ")", "in", "10", ".", "1103", "/", "PhysRevB", ".", "90", ".", "174107" ]
python
train
38.454545
google/pyringe
pyringe/payload/gdb_service.py
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L313-L326
def _UnpackGdbVal(self, gdb_value): """Unpacks gdb.Value objects and returns the best-matched python object.""" val_type = gdb_value.type.code if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM: return int(gdb_value) if val_type == gdb.TYPE_CODE_VOID: return None if val_t...
[ "def", "_UnpackGdbVal", "(", "self", ",", "gdb_value", ")", ":", "val_type", "=", "gdb_value", ".", "type", ".", "code", "if", "val_type", "==", "gdb", ".", "TYPE_CODE_INT", "or", "val_type", "==", "gdb", ".", "TYPE_CODE_ENUM", ":", "return", "int", "(", ...
Unpacks gdb.Value objects and returns the best-matched python object.
[ "Unpacks", "gdb", ".", "Value", "objects", "and", "returns", "the", "best", "-", "matched", "python", "object", "." ]
python
train
38.642857
getpelican/pelican-plugins
liquid_tags/pygalcharts.py
https://github.com/getpelican/pelican-plugins/blob/cfc7a3f224f1743063b034561f89a6a712d13587/liquid_tags/pygalcharts.py#L149-L160
def pygal_parser(preprocessor, tag, markup): """ Simple pygal parser """ # Find JSON payload data = loads(markup) if tag == 'pygal' and data is not None: # Run generation of chart output = run_pygal(data) # Return embedded SVG image return '<div class="pygal" style="text-...
[ "def", "pygal_parser", "(", "preprocessor", ",", "tag", ",", "markup", ")", ":", "# Find JSON payload", "data", "=", "loads", "(", "markup", ")", "if", "tag", "==", "'pygal'", "and", "data", "is", "not", "None", ":", "# Run generation of chart", "output", "=...
Simple pygal parser
[ "Simple", "pygal", "parser" ]
python
train
41.916667
kiwiz/gkeepapi
gkeepapi/node.py
https://github.com/kiwiz/gkeepapi/blob/78aaae8b988b1cf616e3973f7f15d4c6d5e996cc/gkeepapi/node.py#L1140-L1151
def remove(self, node, dirty=True): """Remove the given child node. Args: node (gkeepapi.Node): Node to remove. dirty (bool): Whether this node should be marked dirty. """ if node.id in self._children: self._children[node.id].parent = None ...
[ "def", "remove", "(", "self", ",", "node", ",", "dirty", "=", "True", ")", ":", "if", "node", ".", "id", "in", "self", ".", "_children", ":", "self", ".", "_children", "[", "node", ".", "id", "]", ".", "parent", "=", "None", "del", "self", ".", ...
Remove the given child node. Args: node (gkeepapi.Node): Node to remove. dirty (bool): Whether this node should be marked dirty.
[ "Remove", "the", "given", "child", "node", "." ]
python
train
31.666667
saltstack/salt
salt/template.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/template.py#L142-L150
def compile_template_str(template, renderers, default, blacklist, whitelist): ''' Take template as a string and return the high data structure derived from the template. ''' fn_ = salt.utils.files.mkstemp() with salt.utils.files.fopen(fn_, 'wb') as ofile: ofile.write(SLS_ENCODER(template...
[ "def", "compile_template_str", "(", "template", ",", "renderers", ",", "default", ",", "blacklist", ",", "whitelist", ")", ":", "fn_", "=", "salt", ".", "utils", ".", "files", ".", "mkstemp", "(", ")", "with", "salt", ".", "utils", ".", "files", ".", "...
Take template as a string and return the high data structure derived from the template.
[ "Take", "template", "as", "a", "string", "and", "return", "the", "high", "data", "structure", "derived", "from", "the", "template", "." ]
python
train
43.555556
dpkp/kafka-python
kafka/consumer/base.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/base.py#L172-L182
def _auto_commit(self): """ Check if we have to commit based on number of messages and commit """ # Check if we are supposed to do an auto-commit if not self.auto_commit or self.auto_commit_every_n is None: return if self.count_since_commit >= self.auto_comm...
[ "def", "_auto_commit", "(", "self", ")", ":", "# Check if we are supposed to do an auto-commit", "if", "not", "self", ".", "auto_commit", "or", "self", ".", "auto_commit_every_n", "is", "None", ":", "return", "if", "self", ".", "count_since_commit", ">=", "self", ...
Check if we have to commit based on number of messages and commit
[ "Check", "if", "we", "have", "to", "commit", "based", "on", "number", "of", "messages", "and", "commit" ]
python
train
31.545455
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py#L46-L60
def delete_process_behavior(self, process_id, behavior_ref_name): """DeleteProcessBehavior. [Preview API] Removes a behavior in the process. :param str process_id: The ID of the process :param str behavior_ref_name: The reference name of the behavior """ route_values = {}...
[ "def", "delete_process_behavior", "(", "self", ",", "process_id", ",", "behavior_ref_name", ")", ":", "route_values", "=", "{", "}", "if", "process_id", "is", "not", "None", ":", "route_values", "[", "'processId'", "]", "=", "self", ".", "_serialize", ".", "...
DeleteProcessBehavior. [Preview API] Removes a behavior in the process. :param str process_id: The ID of the process :param str behavior_ref_name: The reference name of the behavior
[ "DeleteProcessBehavior", ".", "[", "Preview", "API", "]", "Removes", "a", "behavior", "in", "the", "process", ".", ":", "param", "str", "process_id", ":", "The", "ID", "of", "the", "process", ":", "param", "str", "behavior_ref_name", ":", "The", "reference",...
python
train
52.733333
cuzzo/iw_parse
iw_parse.py
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L212-L225
def match(line, keyword): """ If the first part of line (modulo blanks) matches keyword, returns the end of that line. Otherwise checks if keyword is anywhere in the line and returns that section, else returns None""" line = line.lstrip() length = len(keyword) if line[:length] == keyword: ...
[ "def", "match", "(", "line", ",", "keyword", ")", ":", "line", "=", "line", ".", "lstrip", "(", ")", "length", "=", "len", "(", "keyword", ")", "if", "line", "[", ":", "length", "]", "==", "keyword", ":", "return", "line", "[", "length", ":", "]"...
If the first part of line (modulo blanks) matches keyword, returns the end of that line. Otherwise checks if keyword is anywhere in the line and returns that section, else returns None
[ "If", "the", "first", "part", "of", "line", "(", "modulo", "blanks", ")", "matches", "keyword", "returns", "the", "end", "of", "that", "line", ".", "Otherwise", "checks", "if", "keyword", "is", "anywhere", "in", "the", "line", "and", "returns", "that", "...
python
train
32.285714
nooperpudd/weibopy
weibopy/auth.py
https://github.com/nooperpudd/weibopy/blob/61f3fb0502c1f07a591388aaa7526e74c63eaeb1/weibopy/auth.py#L125-L166
def auth_access(self, auth_code): """ verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值...
[ "def", "auth_access", "(", "self", ",", "auth_code", ")", ":", "data", "=", "{", "'client_id'", ":", "self", ".", "client_id", ",", "'client_secret'", ":", "self", ".", "client_secret", ",", "'grant_type'", ":", "'authorization_code'", ",", "'code'", ":", "a...
verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值里的UID 字段来做登录识别。 ...
[ "verify", "the", "fist", "authorization", "response", "url", "code" ]
python
train
33.428571
SmokinCaterpillar/pypet
pypet/naturalnaming.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/naturalnaming.py#L2647-L2658
def f_get_parent(self): """Returns the parent of the node. Raises a TypeError if current node is root. """ if self.v_is_root: raise TypeError('Root does not have a parent') elif self.v_location == '': return self.v_root else: return s...
[ "def", "f_get_parent", "(", "self", ")", ":", "if", "self", ".", "v_is_root", ":", "raise", "TypeError", "(", "'Root does not have a parent'", ")", "elif", "self", ".", "v_location", "==", "''", ":", "return", "self", ".", "v_root", "else", ":", "return", ...
Returns the parent of the node. Raises a TypeError if current node is root.
[ "Returns", "the", "parent", "of", "the", "node", "." ]
python
test
31.5
CZ-NIC/python-rt
rt.py
https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1391-L1405
def merge_ticket(self, ticket_id, into_id): """ Merge ticket into another (undocumented API feature). :param ticket_id: ID of ticket to be merged :param into: ID of destination ticket :returns: ``True`` Operation was successful ``False`` ...
[ "def", "merge_ticket", "(", "self", ",", "ticket_id", ",", "into_id", ")", ":", "msg", "=", "self", ".", "__request", "(", "'ticket/{}/merge/{}'", ".", "format", "(", "str", "(", "ticket_id", ")", ",", "str", "(", "into_id", ")", ")", ")", "state", "="...
Merge ticket into another (undocumented API feature). :param ticket_id: ID of ticket to be merged :param into: ID of destination ticket :returns: ``True`` Operation was successful ``False`` Either origin or destination ticket does no...
[ "Merge", "ticket", "into", "another", "(", "undocumented", "API", "feature", ")", "." ]
python
train
47.666667
mitsei/dlkit
dlkit/json_/repository/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/objects.py#L1100-L1112
def clear_created_date(self): """Removes the created date. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.asse...
[ "def", "clear_created_date", "(", "self", ")", ":", "# Implemented from template for osid.assessment.AssessmentOfferedForm.clear_start_time_template", "if", "(", "self", ".", "get_created_date_metadata", "(", ")", ".", "is_read_only", "(", ")", "or", "self", ".", "get_creat...
Removes the created date. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.*
[ "Removes", "the", "created", "date", "." ]
python
train
45.461538
agusmakmun/djipsum
djipsum/faker.py
https://github.com/agusmakmun/djipsum/blob/e7950556422b4039092db2083db7a83728230977/djipsum/faker.py#L90-L110
def fake_chars_or_choice(self, field_name): """ Return fake chars or choice it if the `field_name` has choices. Then, returning random value from it. This specially for `CharField`. Usage: faker.fake_chars_or_choice('field_name') Example for field: ...
[ "def", "fake_chars_or_choice", "(", "self", ",", "field_name", ")", ":", "return", "self", ".", "djipsum_fields", "(", ")", ".", "randomCharField", "(", "self", ".", "model_class", "(", ")", ",", "field_name", "=", "field_name", ")" ]
Return fake chars or choice it if the `field_name` has choices. Then, returning random value from it. This specially for `CharField`. Usage: faker.fake_chars_or_choice('field_name') Example for field: TYPE_CHOICES = ( ('project', 'I wanna to talk a...
[ "Return", "fake", "chars", "or", "choice", "it", "if", "the", "field_name", "has", "choices", ".", "Then", "returning", "random", "value", "from", "it", ".", "This", "specially", "for", "CharField", "." ]
python
train
34.904762
opendatateam/udata
udata/models/owned.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/models/owned.py#L41-L68
def owned_pre_save(sender, document, **kwargs): ''' Owned mongoengine.pre_save signal handler Need to fetch original owner before the new one erase it. ''' if not isinstance(document, Owned): return changed_fields = getattr(document, '_changed_fields', []) if 'organization' in change...
[ "def", "owned_pre_save", "(", "sender", ",", "document", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "document", ",", "Owned", ")", ":", "return", "changed_fields", "=", "getattr", "(", "document", ",", "'_changed_fields'", ",", "[",...
Owned mongoengine.pre_save signal handler Need to fetch original owner before the new one erase it.
[ "Owned", "mongoengine", ".", "pre_save", "signal", "handler", "Need", "to", "fetch", "original", "owner", "before", "the", "new", "one", "erase", "it", "." ]
python
train
41.607143
bukun/TorCMS
torcms/handlers/user_info_list_handler.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_info_list_handler.py#L36-L45
def list_app(self): ''' List the apps. ''' kwd = { 'pager': '', 'title': '' } self.render('user/info_list/list_app.html', kwd=kwd, userinfo=self.userinfo)
[ "def", "list_app", "(", "self", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "''", "}", "self", ".", "render", "(", "'user/info_list/list_app.html'", ",", "kwd", "=", "kwd", ",", "userinfo", "=", "self", ".", "userinfo", ")" ]
List the apps.
[ "List", "the", "apps", "." ]
python
train
23.7
yunojuno/elasticsearch-django
elasticsearch_django/index.py
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L119-L140
def scan_index(index, model): """ Yield all documents of model type in an index. This function calls the elasticsearch.helpers.scan function, and yields all the documents in the index that match the doc_type produced by a specific Django model. Args: index: string, the name of the inde...
[ "def", "scan_index", "(", "index", ",", "model", ")", ":", "# see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html", "query", "=", "{", "\"query\"", ":", "{", "\"type\"", ":", "{", "\"value\"", ":", "model", ".", "_meta", ".", ...
Yield all documents of model type in an index. This function calls the elasticsearch.helpers.scan function, and yields all the documents in the index that match the doc_type produced by a specific Django model. Args: index: string, the name of the index to scan, must be a configured ...
[ "Yield", "all", "documents", "of", "model", "type", "in", "an", "index", "." ]
python
train
38.090909
bpython/curtsies
curtsies/formatstring.py
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/formatstring.py#L494-L503
def shared_atts(self): """Gets atts shared among all nonzero length component Chunk""" #TODO cache this, could get ugly for large FmtStrs atts = {} first = self.chunks[0] for att in sorted(first.atts): #TODO how to write this without the '???'? if all(fs.a...
[ "def", "shared_atts", "(", "self", ")", ":", "#TODO cache this, could get ugly for large FmtStrs", "atts", "=", "{", "}", "first", "=", "self", ".", "chunks", "[", "0", "]", "for", "att", "in", "sorted", "(", "first", ".", "atts", ")", ":", "#TODO how to wri...
Gets atts shared among all nonzero length component Chunk
[ "Gets", "atts", "shared", "among", "all", "nonzero", "length", "component", "Chunk" ]
python
train
45.2
fermiPy/fermipy
fermipy/diffuse/fitting.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L33-L56
def build_srcdict(gta, prop): """Build a dictionary that maps from source name to the value of a source property Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object prop : str The name of the property we are mapping Returns ------- odict : dict ...
[ "def", "build_srcdict", "(", "gta", ",", "prop", ")", ":", "o", "=", "{", "}", "for", "s", "in", "gta", ".", "roi", ".", "sources", ":", "o", "[", "s", ".", "name", "]", "=", "s", "[", "prop", "]", "return", "o" ]
Build a dictionary that maps from source name to the value of a source property Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object prop : str The name of the property we are mapping Returns ------- odict : dict Dictionary that maps from source ...
[ "Build", "a", "dictionary", "that", "maps", "from", "source", "name", "to", "the", "value", "of", "a", "source", "property" ]
python
train
19.5
niklasf/python-chess
chess/pgn.py
https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/pgn.py#L710-L724
def parse_san(self, board: chess.Board, san: str) -> chess.Move: """ When the visitor is used by a parser, this is called to parse a move in standard algebraic notation. You can override the default implementation to work around specific quirks of your input format. """ ...
[ "def", "parse_san", "(", "self", ",", "board", ":", "chess", ".", "Board", ",", "san", ":", "str", ")", "->", "chess", ".", "Move", ":", "# Replace zeros with correct castling notation.", "if", "san", "==", "\"0-0\"", ":", "san", "=", "\"O-O\"", "elif", "s...
When the visitor is used by a parser, this is called to parse a move in standard algebraic notation. You can override the default implementation to work around specific quirks of your input format.
[ "When", "the", "visitor", "is", "used", "by", "a", "parser", "this", "is", "called", "to", "parse", "a", "move", "in", "standard", "algebraic", "notation", "." ]
python
train
33.466667
PyCQA/astroid
astroid/as_string.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/as_string.py#L351-L357
def visit_ifexp(self, node): """return an astroid.IfExp node as string""" return "%s if %s else %s" % ( self._precedence_parens(node, node.body, is_left=True), self._precedence_parens(node, node.test, is_left=True), self._precedence_parens(node, node.orelse, is_left=F...
[ "def", "visit_ifexp", "(", "self", ",", "node", ")", ":", "return", "\"%s if %s else %s\"", "%", "(", "self", ".", "_precedence_parens", "(", "node", ",", "node", ".", "body", ",", "is_left", "=", "True", ")", ",", "self", ".", "_precedence_parens", "(", ...
return an astroid.IfExp node as string
[ "return", "an", "astroid", ".", "IfExp", "node", "as", "string" ]
python
train
47.142857
boriel/zxbasic
zxbparser.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L1379-L1384
def p_if_then_part(p): """ if_then_part : IF expr then """ if is_number(p[2]): api.errmsg.warning_condition_is_always(p.lineno(1), bool(p[2].value)) p[0] = p[2]
[ "def", "p_if_then_part", "(", "p", ")", ":", "if", "is_number", "(", "p", "[", "2", "]", ")", ":", "api", ".", "errmsg", ".", "warning_condition_is_always", "(", "p", ".", "lineno", "(", "1", ")", ",", "bool", "(", "p", "[", "2", "]", ".", "value...
if_then_part : IF expr then
[ "if_then_part", ":", "IF", "expr", "then" ]
python
train
29.333333
h2oai/h2o-3
py2/h2o_ray.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/py2/h2o_ray.py#L410-L443
def validate_model_parameters(self, algo, training_frame, parameters, timeoutSecs=60, **kwargs): ''' Check a dictionary of model builder parameters on the h2o cluster using the given algorithm and model parameters. ''' assert algo is not None, '"algo" parameter is null' # Allow this now: assert...
[ "def", "validate_model_parameters", "(", "self", ",", "algo", ",", "training_frame", ",", "parameters", ",", "timeoutSecs", "=", "60", ",", "*", "*", "kwargs", ")", ":", "assert", "algo", "is", "not", "None", ",", "'\"algo\" parameter is null'", "# Allow this no...
Check a dictionary of model builder parameters on the h2o cluster using the given algorithm and model parameters.
[ "Check", "a", "dictionary", "of", "model", "builder", "parameters", "on", "the", "h2o", "cluster", "using", "the", "given", "algorithm", "and", "model", "parameters", "." ]
python
test
46.352941
saltstack/salt
salt/modules/portage_config.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/portage_config.py#L558-L599
def is_present(conf, atom): ''' Tell if a given package or DEPEND atom is present in the configuration files tree. Warning: This only works if the configuration files tree is in the correct format (the one enforced by enforce_nice_config) CLI Example: .. code-block:: bash salt '*'...
[ "def", "is_present", "(", "conf", ",", "atom", ")", ":", "if", "conf", "in", "SUPPORTED_CONFS", ":", "if", "not", "isinstance", "(", "atom", ",", "portage", ".", "dep", ".", "Atom", ")", ":", "atom", "=", "portage", ".", "dep", ".", "Atom", "(", "a...
Tell if a given package or DEPEND atom is present in the configuration files tree. Warning: This only works if the configuration files tree is in the correct format (the one enforced by enforce_nice_config) CLI Example: .. code-block:: bash salt '*' portage_config.is_present unmask salt
[ "Tell", "if", "a", "given", "package", "or", "DEPEND", "atom", "is", "present", "in", "the", "configuration", "files", "tree", ".", "Warning", ":", "This", "only", "works", "if", "the", "configuration", "files", "tree", "is", "in", "the", "correct", "forma...
python
train
33.666667
fboender/ansible-cmdb
lib/mako/ext/extract.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/lib/mako/ext/extract.py#L97-L101
def _split_comment(lineno, comment): """Return the multiline comment at lineno split into a list of comment line numbers and the accompanying comment line""" return [(lineno + index, line) for index, line in enumerate(comment.splitlines())]
[ "def", "_split_comment", "(", "lineno", ",", "comment", ")", ":", "return", "[", "(", "lineno", "+", "index", ",", "line", ")", "for", "index", ",", "line", "in", "enumerate", "(", "comment", ".", "splitlines", "(", ")", ")", "]" ]
Return the multiline comment at lineno split into a list of comment line numbers and the accompanying comment line
[ "Return", "the", "multiline", "comment", "at", "lineno", "split", "into", "a", "list", "of", "comment", "line", "numbers", "and", "the", "accompanying", "comment", "line" ]
python
train
55.2
InspectorMustache/base16-builder-python
pybase16_builder/injector.py
https://github.com/InspectorMustache/base16-builder-python/blob/586f1f87ee9f70696ab19c542af6ef55c6548a2e/pybase16_builder/injector.py#L42-L64
def get_colorscheme(self, scheme_file): """Return a string object with the colorscheme that is to be inserted.""" scheme = get_yaml_dict(scheme_file) scheme_slug = builder.slugify(scheme_file) builder.format_scheme(scheme, scheme_slug) try: temp_base, temp_su...
[ "def", "get_colorscheme", "(", "self", ",", "scheme_file", ")", ":", "scheme", "=", "get_yaml_dict", "(", "scheme_file", ")", "scheme_slug", "=", "builder", ".", "slugify", "(", "scheme_file", ")", "builder", ".", "format_scheme", "(", "scheme", ",", "scheme_s...
Return a string object with the colorscheme that is to be inserted.
[ "Return", "a", "string", "object", "with", "the", "colorscheme", "that", "is", "to", "be", "inserted", "." ]
python
train
37.913043
knipknap/exscript
Exscript/stdlib/ipv4.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/stdlib/ipv4.py#L28-L54
def in_network(scope, prefixes, destination, default_pfxlen=[24]): """ Returns True if the given destination is in the network range that is defined by the given prefix (e.g. 10.0.0.1/22). If the given prefix does not have a prefix length specified, the given default prefix length is applied. If no ...
[ "def", "in_network", "(", "scope", ",", "prefixes", ",", "destination", ",", "default_pfxlen", "=", "[", "24", "]", ")", ":", "needle", "=", "ipv4", ".", "ip2int", "(", "destination", "[", "0", "]", ")", "for", "prefix", "in", "prefixes", ":", "network...
Returns True if the given destination is in the network range that is defined by the given prefix (e.g. 10.0.0.1/22). If the given prefix does not have a prefix length specified, the given default prefix length is applied. If no such prefix length is given, the default length is /24. If a list of p...
[ "Returns", "True", "if", "the", "given", "destination", "is", "in", "the", "network", "range", "that", "is", "defined", "by", "the", "given", "prefix", "(", "e", ".", "g", ".", "10", ".", "0", ".", "0", ".", "1", "/", "22", ")", ".", "If", "the",...
python
train
40.962963
secdev/scapy
scapy/layers/tls/keyexchange.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L769-L787
def post_dissection(self, m): """ First we update the client DHParams. Then, we try to update the server DHParams generated during Server*DHParams building, with the shared secret. Finally, we derive the session keys and update the context. """ s = self.tls_session ...
[ "def", "post_dissection", "(", "self", ",", "m", ")", ":", "s", "=", "self", ".", "tls_session", "# if there are kx params and keys, we assume the crypto library is ok", "if", "s", ".", "client_kx_ffdh_params", ":", "y", "=", "pkcs_os2ip", "(", "self", ".", "dh_Yc",...
First we update the client DHParams. Then, we try to update the server DHParams generated during Server*DHParams building, with the shared secret. Finally, we derive the session keys and update the context.
[ "First", "we", "update", "the", "client", "DHParams", ".", "Then", "we", "try", "to", "update", "the", "server", "DHParams", "generated", "during", "Server", "*", "DHParams", "building", "with", "the", "shared", "secret", ".", "Finally", "we", "derive", "the...
python
train
45.631579
markovmodel/msmtools
msmtools/flux/reactive_flux.py
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/flux/reactive_flux.py#L111-L115
def I(self): r"""Returns the set of intermediate states """ return list(set(range(self.nstates)) - set(self._A) - set(self._B))
[ "def", "I", "(", "self", ")", ":", "return", "list", "(", "set", "(", "range", "(", "self", ".", "nstates", ")", ")", "-", "set", "(", "self", ".", "_A", ")", "-", "set", "(", "self", ".", "_B", ")", ")" ]
r"""Returns the set of intermediate states
[ "r", "Returns", "the", "set", "of", "intermediate", "states" ]
python
train
29.6
readbeyond/aeneas
aeneas/globalfunctions.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L649-L685
def time_to_hhmmssmmm(time_value, decimal_separator="."): """ Format the given time value into a ``HH:MM:SS.mmm`` string. Examples: :: 12 => 00:00:12.000 12.345 => 00:00:12.345 12.345432 => 00:00:12.345 12.345678 => 00:00:12.346 83 => 00:01:23.000 ...
[ "def", "time_to_hhmmssmmm", "(", "time_value", ",", "decimal_separator", "=", "\".\"", ")", ":", "if", "time_value", "is", "None", ":", "time_value", "=", "0", "tmp", "=", "time_value", "hours", "=", "int", "(", "math", ".", "floor", "(", "tmp", "/", "36...
Format the given time value into a ``HH:MM:SS.mmm`` string. Examples: :: 12 => 00:00:12.000 12.345 => 00:00:12.345 12.345432 => 00:00:12.345 12.345678 => 00:00:12.346 83 => 00:01:23.000 83.456 => 00:01:23.456 83.456789 => 00:01:23.456 ...
[ "Format", "the", "given", "time", "value", "into", "a", "HH", ":", "MM", ":", "SS", ".", "mmm", "string", "." ]
python
train
27.486486
pyblish/pyblish-qml
pyblish_qml/app.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/app.py#L273-L299
def main(demo=False, aschild=False, targets=[]): """Start the Qt-runtime and show the window Arguments: aschild (bool, optional): Run as child of parent process """ if aschild: print("Starting pyblish-qml") compat.main() app = Application(APP_PATH, targets) app...
[ "def", "main", "(", "demo", "=", "False", ",", "aschild", "=", "False", ",", "targets", "=", "[", "]", ")", ":", "if", "aschild", ":", "print", "(", "\"Starting pyblish-qml\"", ")", "compat", ".", "main", "(", ")", "app", "=", "Application", "(", "AP...
Start the Qt-runtime and show the window Arguments: aschild (bool, optional): Run as child of parent process
[ "Start", "the", "Qt", "-", "runtime", "and", "show", "the", "window" ]
python
train
26.296296
profitbricks/profitbricks-sdk-python
profitbricks/client.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/profitbricks/client.py#L1267-L1281
def list_servers(self, datacenter_id, depth=1): """ Retrieves a list of all servers bound to the specified data center. :param datacenter_id: The unique ID of the data center. :type datacenter_id: ``str`` :param depth: The depth of the response data. :ty...
[ "def", "list_servers", "(", "self", ",", "datacenter_id", ",", "depth", "=", "1", ")", ":", "response", "=", "self", ".", "_perform_request", "(", "'/datacenters/%s/servers?depth=%s'", "%", "(", "datacenter_id", ",", "str", "(", "depth", ")", ")", ")", "retu...
Retrieves a list of all servers bound to the specified data center. :param datacenter_id: The unique ID of the data center. :type datacenter_id: ``str`` :param depth: The depth of the response data. :type depth: ``int``
[ "Retrieves", "a", "list", "of", "all", "servers", "bound", "to", "the", "specified", "data", "center", "." ]
python
valid
32.466667
RRZE-HPC/kerncraft
kerncraft/kernel.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L852-L871
def conv_ast_to_sym(self, math_ast): """ Convert mathematical expressions to a sympy representation. May only contain paranthesis, addition, subtraction and multiplication from AST. """ if type(math_ast) is c_ast.ID: return symbol_pos_int(math_ast.name) elif ...
[ "def", "conv_ast_to_sym", "(", "self", ",", "math_ast", ")", ":", "if", "type", "(", "math_ast", ")", "is", "c_ast", ".", "ID", ":", "return", "symbol_pos_int", "(", "math_ast", ".", "name", ")", "elif", "type", "(", "math_ast", ")", "is", "c_ast", "."...
Convert mathematical expressions to a sympy representation. May only contain paranthesis, addition, subtraction and multiplication from AST.
[ "Convert", "mathematical", "expressions", "to", "a", "sympy", "representation", "." ]
python
test
35.75
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6258-L6268
def createSpatialAnchorFromDescriptor(self, pchDescriptor): """ Returns a handle for an spatial anchor described by "descriptor". On success, pHandle will contain a handle valid for this session. Caller can wait for an event or occasionally poll GetSpatialAnchorPose() to find the virtu...
[ "def", "createSpatialAnchorFromDescriptor", "(", "self", ",", "pchDescriptor", ")", ":", "fn", "=", "self", ".", "function_table", ".", "createSpatialAnchorFromDescriptor", "pHandleOut", "=", "SpatialAnchorHandle_t", "(", ")", "result", "=", "fn", "(", "pchDescriptor"...
Returns a handle for an spatial anchor described by "descriptor". On success, pHandle will contain a handle valid for this session. Caller can wait for an event or occasionally poll GetSpatialAnchorPose() to find the virtual coordinate associated with this anchor.
[ "Returns", "a", "handle", "for", "an", "spatial", "anchor", "described", "by", "descriptor", ".", "On", "success", "pHandle", "will", "contain", "a", "handle", "valid", "for", "this", "session", ".", "Caller", "can", "wait", "for", "an", "event", "or", "oc...
python
train
51.363636
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1712-L1728
def setStyles(self, styleUpdatesDict): ''' setStyles - Sets one or more style params. This all happens in one shot, so it is much much faster than calling setStyle for every value. To remove a style, set its value to empty string. When all styles are...
[ "def", "setStyles", "(", "self", ",", "styleUpdatesDict", ")", ":", "setStyleMethod", "=", "self", ".", "setStyle", "for", "newName", ",", "newValue", "in", "styleUpdatesDict", ".", "items", "(", ")", ":", "setStyleMethod", "(", "newName", ",", "newValue", "...
setStyles - Sets one or more style params. This all happens in one shot, so it is much much faster than calling setStyle for every value. To remove a style, set its value to empty string. When all styles are removed, the "style" attribute will be nullified. ...
[ "setStyles", "-", "Sets", "one", "or", "more", "style", "params", ".", "This", "all", "happens", "in", "one", "shot", "so", "it", "is", "much", "much", "faster", "than", "calling", "setStyle", "for", "every", "value", "." ]
python
train
40.941176
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2441-L2443
def HardwareInput(uMsg: int, param: int = 0) -> INPUT: """Create Win32 struct `HARDWAREINPUT` for `SendInput`.""" return _CreateInput(HARDWAREINPUT(uMsg, param & 0xFFFF, param >> 16 & 0xFFFF))
[ "def", "HardwareInput", "(", "uMsg", ":", "int", ",", "param", ":", "int", "=", "0", ")", "->", "INPUT", ":", "return", "_CreateInput", "(", "HARDWAREINPUT", "(", "uMsg", ",", "param", "&", "0xFFFF", ",", "param", ">>", "16", "&", "0xFFFF", ")", ")" ...
Create Win32 struct `HARDWAREINPUT` for `SendInput`.
[ "Create", "Win32", "struct", "HARDWAREINPUT", "for", "SendInput", "." ]
python
valid
66
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L2508-L2526
def dlafns(handle, descr): """ Find the segment following a specified segment in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlafns_c.html :param handle: Handle of open DLA file. :type handle: c_int :param descr: Descriptor of a DLA segment. :type descr: s...
[ "def", "dlafns", "(", "handle", ",", "descr", ")", ":", "assert", "isinstance", "(", "descr", ",", "stypes", ".", "SpiceDLADescr", ")", "handle", "=", "ctypes", ".", "c_int", "(", "handle", ")", "nxtdsc", "=", "stypes", ".", "SpiceDLADescr", "(", ")", ...
Find the segment following a specified segment in a DLA file. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dlafns_c.html :param handle: Handle of open DLA file. :type handle: c_int :param descr: Descriptor of a DLA segment. :type descr: spiceypy.utils.support_types.SpiceDLADes...
[ "Find", "the", "segment", "following", "a", "specified", "segment", "in", "a", "DLA", "file", ".", "https", ":", "//", "naif", ".", "jpl", ".", "nasa", ".", "gov", "/", "pub", "/", "naif", "/", "toolkit_docs", "/", "C", "/", "cspice", "/", "dlafns_c"...
python
train
38.842105
saltstack/salt
salt/modules/ansiblegate.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L68-L92
def _get_modules_map(self, path=None): ''' Get installed Ansible modules :return: ''' paths = {} root = ansible.modules.__path__[0] if not path: path = root for p_el in os.listdir(path): p_el_path = os.path.join(path, p_el) ...
[ "def", "_get_modules_map", "(", "self", ",", "path", "=", "None", ")", ":", "paths", "=", "{", "}", "root", "=", "ansible", ".", "modules", ".", "__path__", "[", "0", "]", "if", "not", "path", ":", "path", "=", "root", "for", "p_el", "in", "os", ...
Get installed Ansible modules :return:
[ "Get", "installed", "Ansible", "modules", ":", "return", ":" ]
python
train
36.88
twilio/twilio-python
twilio/rest/api/v2010/account/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/__init__.py#L357-L369
def authorized_connect_apps(self): """ Access the authorized_connect_apps :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ if self._authorized...
[ "def", "authorized_connect_apps", "(", "self", ")", ":", "if", "self", ".", "_authorized_connect_apps", "is", "None", ":", "self", ".", "_authorized_connect_apps", "=", "AuthorizedConnectAppList", "(", "self", ".", "_version", ",", "account_sid", "=", "self", ".",...
Access the authorized_connect_apps :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList
[ "Access", "the", "authorized_connect_apps" ]
python
train
41.615385
AshleySetter/optoanalysis
optoanalysis/optoanalysis/optoanalysis.py
https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/optoanalysis.py#L3992-L4038
def get_time_slice(time, z, zdot=None, timeStart=None, timeEnd=None): """ Get slice of time, z and (if provided) zdot from timeStart to timeEnd. Parameters ---------- time : ndarray array of time values z : ndarray array of z values zdot : ndarray, optional array of...
[ "def", "get_time_slice", "(", "time", ",", "z", ",", "zdot", "=", "None", ",", "timeStart", "=", "None", ",", "timeEnd", "=", "None", ")", ":", "if", "timeStart", "==", "None", ":", "timeStart", "=", "time", "[", "0", "]", "if", "timeEnd", "==", "N...
Get slice of time, z and (if provided) zdot from timeStart to timeEnd. Parameters ---------- time : ndarray array of time values z : ndarray array of z values zdot : ndarray, optional array of zdot (velocity) values. timeStart : float, optional time at which to ...
[ "Get", "slice", "of", "time", "z", "and", "(", "if", "provided", ")", "zdot", "from", "timeStart", "to", "timeEnd", "." ]
python
train
28.12766
pypa/pipenv
pipenv/vendor/docopt.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/docopt.py#L392-L401
def parse_seq(tokens, options): """seq ::= ( atom [ '...' ] )* ;""" result = [] while tokens.current() not in [None, ']', ')', '|']: atom = parse_atom(tokens, options) if tokens.current() == '...': atom = [OneOrMore(*atom)] tokens.move() result += atom ret...
[ "def", "parse_seq", "(", "tokens", ",", "options", ")", ":", "result", "=", "[", "]", "while", "tokens", ".", "current", "(", ")", "not", "in", "[", "None", ",", "']'", ",", "')'", ",", "'|'", "]", ":", "atom", "=", "parse_atom", "(", "tokens", "...
seq ::= ( atom [ '...' ] )* ;
[ "seq", "::", "=", "(", "atom", "[", "...", "]", ")", "*", ";" ]
python
train
32.1
quantopian/zipline
zipline/data/continuous_future_reader.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/continuous_future_reader.py#L204-L282
def load_raw_arrays(self, columns, start_date, end_date, assets): """ Parameters ---------- fields : list of str 'open', 'high', 'low', 'close', or 'volume' start_dt: Timestamp Beginning of the window range. end_dt: Timestamp End of the wi...
[ "def", "load_raw_arrays", "(", "self", ",", "columns", ",", "start_date", ",", "end_date", ",", "assets", ")", ":", "rolls_by_asset", "=", "{", "}", "tc", "=", "self", ".", "trading_calendar", "start_session", "=", "tc", ".", "minute_to_session_label", "(", ...
Parameters ---------- fields : list of str 'open', 'high', 'low', 'close', or 'volume' start_dt: Timestamp Beginning of the window range. end_dt: Timestamp End of the window range. sids : list of int The asset identifiers in the window....
[ "Parameters", "----------", "fields", ":", "list", "of", "str", "open", "high", "low", "close", "or", "volume", "start_dt", ":", "Timestamp", "Beginning", "of", "the", "window", "range", ".", "end_dt", ":", "Timestamp", "End", "of", "the", "window", "range",...
python
train
36.835443
DataDog/integrations-core
datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/prometheus/mixins.py#L437-L492
def process_metric(self, message, **kwargs): """ Handle a prometheus metric message according to the following flow: - search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping - call check method with the same name as the metric - log some info i...
[ "def", "process_metric", "(", "self", ",", "message", ",", "*", "*", "kwargs", ")", ":", "# If targeted metric, store labels", "self", ".", "store_labels", "(", "message", ")", "if", "message", ".", "name", "in", "self", ".", "ignore_metrics", ":", "return", ...
Handle a prometheus metric message according to the following flow: - search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping - call check method with the same name as the metric - log some info if none of the above worked `send_histograms_buckets` is ...
[ "Handle", "a", "prometheus", "metric", "message", "according", "to", "the", "following", "flow", ":", "-", "search", "self", ".", "metrics_mapper", "for", "a", "prometheus", ".", "metric", "<", "--", ">", "datadog", ".", "metric", "mapping", "-", "call", "...
python
train
46.910714
RPi-Distro/python-gpiozero
gpiozero/boards.py
https://github.com/RPi-Distro/python-gpiozero/blob/7b67374fd0c8c4fde5586d9bad9531f076db9c0c/gpiozero/boards.py#L480-L505
def toggle(self, *args): """ If no arguments are specified, toggle the state of all LEDs. If arguments are specified, they must be the indexes of the LEDs you wish to toggle. For example:: from gpiozero import LEDBoard leds = LEDBoard(2, 3, 4, 5) led...
[ "def", "toggle", "(", "self", ",", "*", "args", ")", ":", "self", ".", "_stop_blink", "(", ")", "if", "args", ":", "for", "index", "in", "args", ":", "self", "[", "index", "]", ".", "toggle", "(", ")", "else", ":", "super", "(", "LEDBoard", ",", ...
If no arguments are specified, toggle the state of all LEDs. If arguments are specified, they must be the indexes of the LEDs you wish to toggle. For example:: from gpiozero import LEDBoard leds = LEDBoard(2, 3, 4, 5) leds.toggle(0) # turn on the first LED (pin 2)...
[ "If", "no", "arguments", "are", "specified", "toggle", "the", "state", "of", "all", "LEDs", ".", "If", "arguments", "are", "specified", "they", "must", "be", "the", "indexes", "of", "the", "LEDs", "you", "wish", "to", "toggle", ".", "For", "example", "::...
python
train
35.346154
swevm/scaleio-py
scaleiopy/api/scaleio/provisioning/volume.py
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L195-L206
def get_volume_by_name(self, name): """ Get ScaleIO Volume object by its Name :param name: Name of volume :return: ScaleIO Volume object :raise KeyError: No Volume with specified name found :rtype: ScaleIO Volume object """ for vol in self.conn.volumes: ...
[ "def", "get_volume_by_name", "(", "self", ",", "name", ")", ":", "for", "vol", "in", "self", ".", "conn", ".", "volumes", ":", "if", "vol", ".", "name", "==", "name", ":", "return", "vol", "raise", "KeyError", "(", "\"Volume with NAME \"", "+", "name", ...
Get ScaleIO Volume object by its Name :param name: Name of volume :return: ScaleIO Volume object :raise KeyError: No Volume with specified name found :rtype: ScaleIO Volume object
[ "Get", "ScaleIO", "Volume", "object", "by", "its", "Name", ":", "param", "name", ":", "Name", "of", "volume", ":", "return", ":", "ScaleIO", "Volume", "object", ":", "raise", "KeyError", ":", "No", "Volume", "with", "specified", "name", "found", ":", "rt...
python
train
36
jjjake/internetarchive
internetarchive/api.py
https://github.com/jjjake/internetarchive/blob/7c0c71bfe52490927a37ade15bd09b2733fea660/internetarchive/api.py#L78-L116
def get_item(identifier, config=None, config_file=None, archive_session=None, debug=None, http_adapter_kwargs=None, request_kwargs=None): """Get an :class:`Item` object. :type identifier: str :param identifier: The globally uniqu...
[ "def", "get_item", "(", "identifier", ",", "config", "=", "None", ",", "config_file", "=", "None", ",", "archive_session", "=", "None", ",", "debug", "=", "None", ",", "http_adapter_kwargs", "=", "None", ",", "request_kwargs", "=", "None", ")", ":", "if", ...
Get an :class:`Item` object. :type identifier: str :param identifier: The globally unique Archive.org item identifier. :type config: dict :param config: (optional) A dictionary used to configure your session. :type config_file: str :param config_file: (optional) A path to a config file used t...
[ "Get", "an", ":", "class", ":", "Item", "object", "." ]
python
train
36.384615
shoebot/shoebot
lib/web/google.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/google.py#L138-L146
def _parse(self, str): """ Parses the text data from an XML element defined by tag. """ str = replace_entities(str) str = strip_tags(str) str = collapse_spaces(str) return str
[ "def", "_parse", "(", "self", ",", "str", ")", ":", "str", "=", "replace_entities", "(", "str", ")", "str", "=", "strip_tags", "(", "str", ")", "str", "=", "collapse_spaces", "(", "str", ")", "return", "str" ]
Parses the text data from an XML element defined by tag.
[ "Parses", "the", "text", "data", "from", "an", "XML", "element", "defined", "by", "tag", "." ]
python
valid
25.888889
ConsenSys/mythril-classic
mythril/laser/ethereum/plugins/plugin_factory.py
https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/laser/ethereum/plugins/plugin_factory.py#L26-L32
def build_instruction_coverage_plugin() -> LaserPlugin: """ Creates an instance of the instruction coverage plugin""" from mythril.laser.ethereum.plugins.implementations.coverage import ( InstructionCoveragePlugin, ) return InstructionCoveragePlugin()
[ "def", "build_instruction_coverage_plugin", "(", ")", "->", "LaserPlugin", ":", "from", "mythril", ".", "laser", ".", "ethereum", ".", "plugins", ".", "implementations", ".", "coverage", "import", "(", "InstructionCoveragePlugin", ",", ")", "return", "InstructionCov...
Creates an instance of the instruction coverage plugin
[ "Creates", "an", "instance", "of", "the", "instruction", "coverage", "plugin" ]
python
train
41.428571
django-blog-zinnia/wordpress2zinnia
zinnia_wordpress/management/commands/wp2zinnia.py
https://github.com/django-blog-zinnia/wordpress2zinnia/blob/656df6d431418a660f0e590d2226af5e6dd7a3e6/zinnia_wordpress/management/commands/wp2zinnia.py#L357-L387
def import_entries(self, items): """ Loops over items and find entry to import, an entry need to have 'post_type' set to 'post' and have content. """ self.write_out(self.style.STEP('- Importing entries\n')) for item_node in items: title = (item_node.f...
[ "def", "import_entries", "(", "self", ",", "items", ")", ":", "self", ".", "write_out", "(", "self", ".", "style", ".", "STEP", "(", "'- Importing entries\\n'", ")", ")", "for", "item_node", "in", "items", ":", "title", "=", "(", "item_node", ".", "find"...
Loops over items and find entry to import, an entry need to have 'post_type' set to 'post' and have content.
[ "Loops", "over", "items", "and", "find", "entry", "to", "import", "an", "entry", "need", "to", "have", "post_type", "set", "to", "post", "and", "have", "content", "." ]
python
train
44.935484
thorgate/django-esteid
esteid/digidocservice/service.py
https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/digidocservice/service.py#L299-L334
def mobile_sign(self, id_code, country, phone_nr, language=None, signing_profile='LT_TM'): """ This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session """ if not (self.container and isinstance(self.container, PreviouslyCrea...
[ "def", "mobile_sign", "(", "self", ",", "id_code", ",", "country", ",", "phone_nr", ",", "language", "=", "None", ",", "signing_profile", "=", "'LT_TM'", ")", ":", "if", "not", "(", "self", ".", "container", "and", "isinstance", "(", "self", ".", "contai...
This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session
[ "This", "can", "be", "used", "to", "add", "a", "signature", "to", "existing", "data", "files" ]
python
train
37.5
nicolargo/glances
glances/outputs/glances_curses.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L627-L652
def __display_header(self, stat_display): """Display the firsts lines (header) in the Curses interface. system + ip + uptime (cloud) """ # First line self.new_line() self.space_between_column = 0 l_uptime = (self.get_stats_display_width(stat_display["syst...
[ "def", "__display_header", "(", "self", ",", "stat_display", ")", ":", "# First line", "self", ".", "new_line", "(", ")", "self", ".", "space_between_column", "=", "0", "l_uptime", "=", "(", "self", ".", "get_stats_display_width", "(", "stat_display", "[", "\"...
Display the firsts lines (header) in the Curses interface. system + ip + uptime (cloud)
[ "Display", "the", "firsts", "lines", "(", "header", ")", "in", "the", "Curses", "interface", "." ]
python
train
38.730769
dereneaton/ipyrad
ipyrad/core/assembly.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/core/assembly.py#L1069-L1089
def _step4func(self, samples, force, ipyclient): """ hidden wrapped function to start step 4 """ if self._headers: print("\n Step 4: Joint estimation of error rate and heterozygosity") ## Get sample objects from list of strings samples = _get_samples(self, samples) ...
[ "def", "_step4func", "(", "self", ",", "samples", ",", "force", ",", "ipyclient", ")", ":", "if", "self", ".", "_headers", ":", "print", "(", "\"\\n Step 4: Joint estimation of error rate and heterozygosity\"", ")", "## Get sample objects from list of strings", "samples"...
hidden wrapped function to start step 4
[ "hidden", "wrapped", "function", "to", "start", "step", "4" ]
python
valid
35.380952
jonathf/chaospy
chaospy/distributions/operators/power.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/operators/power.py#L149-L186
def _ppf(self, q, left, right, cache): """ Point percentile function. Example: >>> print(chaospy.Uniform().inv([0.1, 0.2, 0.9])) [0.1 0.2 0.9] >>> print(chaospy.Pow(chaospy.Uniform(), 2).inv([0.1, 0.2, 0.9])) [0.01 0.04 0.81] >>> print...
[ "def", "_ppf", "(", "self", ",", "q", ",", "left", ",", "right", ",", "cache", ")", ":", "left", "=", "evaluation", ".", "get_inverse_cache", "(", "left", ",", "cache", ")", "right", "=", "evaluation", ".", "get_inverse_cache", "(", "right", ",", "cach...
Point percentile function. Example: >>> print(chaospy.Uniform().inv([0.1, 0.2, 0.9])) [0.1 0.2 0.9] >>> print(chaospy.Pow(chaospy.Uniform(), 2).inv([0.1, 0.2, 0.9])) [0.01 0.04 0.81] >>> print(chaospy.Pow(chaospy.Uniform(1, 2), -1).inv([0.1, 0.2, 0.9]...
[ "Point", "percentile", "function", "." ]
python
train
39.605263
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L641-L647
def decode(self, data): """ Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. """ return Zchunk(lib.zarmour_decode(self._as_parameter_, data), True)
[ "def", "decode", "(", "self", ",", "data", ")", ":", "return", "Zchunk", "(", "lib", ".", "zarmour_decode", "(", "self", ".", "_as_parameter_", ",", "data", ")", ",", "True", ")" ]
Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding.
[ "Decode", "an", "armoured", "string", "into", "a", "chunk", ".", "The", "decoded", "output", "is", "null", "-", "terminated", "so", "it", "may", "be", "treated", "as", "a", "string", "if", "that", "s", "what", "it", "was", "prior", "to", "encoding", "....
python
train
39.714286
jedie/DragonPy
dragonpy/core/machine.py
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/core/machine.py#L95-L111
def inject_basic_program(self, ascii_listing): """ save the given ASCII BASIC program listing into the emulator RAM. """ program_start = self.cpu.memory.read_word( self.machine_api.PROGRAM_START_ADDR ) tokens = self.machine_api.ascii_listing2program_dump(ascii...
[ "def", "inject_basic_program", "(", "self", ",", "ascii_listing", ")", ":", "program_start", "=", "self", ".", "cpu", ".", "memory", ".", "read_word", "(", "self", ".", "machine_api", ".", "PROGRAM_START_ADDR", ")", "tokens", "=", "self", ".", "machine_api", ...
save the given ASCII BASIC program listing into the emulator RAM.
[ "save", "the", "given", "ASCII", "BASIC", "program", "listing", "into", "the", "emulator", "RAM", "." ]
python
train
48.294118
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1134-L1161
def createmergerequest(self, project_id, sourcebranch, targetbranch, title, target_project_id=None, assignee_id=None): """ Create a new merge request. :param project_id: ID of the project originating the merge request :param sourcebranch: name of the branch to...
[ "def", "createmergerequest", "(", "self", ",", "project_id", ",", "sourcebranch", ",", "targetbranch", ",", "title", ",", "target_project_id", "=", "None", ",", "assignee_id", "=", "None", ")", ":", "data", "=", "{", "'source_branch'", ":", "sourcebranch", ","...
Create a new merge request. :param project_id: ID of the project originating the merge request :param sourcebranch: name of the branch to merge from :param targetbranch: name of the branch to merge to :param title: Title of the merge request :param assignee_id: Assignee user ID ...
[ "Create", "a", "new", "merge", "request", "." ]
python
train
38.535714
AASHE/django-constant-contact
django_constant_contact/models.py
https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L216-L219
def pre_save(cls, sender, instance, *args, **kwargs): """Pull constant_contact_id out of data. """ instance.constant_contact_id = str(instance.data['id'])
[ "def", "pre_save", "(", "cls", ",", "sender", ",", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "instance", ".", "constant_contact_id", "=", "str", "(", "instance", ".", "data", "[", "'id'", "]", ")" ]
Pull constant_contact_id out of data.
[ "Pull", "constant_contact_id", "out", "of", "data", "." ]
python
train
43.75
SeabornGames/Meta
seaborn_meta/calling_function.py
https://github.com/SeabornGames/Meta/blob/f2a38ad8bcc5ac177e537645853593225895df46/seaborn_meta/calling_function.py#L223-L249
def func_frame(function_index, function_name=None): """ This will return the class_name and function_name of the function traced back two functions. :param function_index: int of how many frames back the program should look (2 will give the parent of the caller) :param f...
[ "def", "func_frame", "(", "function_index", ",", "function_name", "=", "None", ")", ":", "frm", "=", "inspect", ".", "currentframe", "(", ")", "if", "function_name", "is", "not", "None", ":", "function_name", "=", "function_name", ".", "split", "(", "'*'", ...
This will return the class_name and function_name of the function traced back two functions. :param function_index: int of how many frames back the program should look (2 will give the parent of the caller) :param function_name: str of what function to look for (should ...
[ "This", "will", "return", "the", "class_name", "and", "function_name", "of", "the", "function", "traced", "back", "two", "functions", "." ]
python
train
40.259259
Jaymon/pout
pout/value.py
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/value.py#L393-L407
def _add_indent(self, val, indent_count): ''' add whitespace to the beginning of each line of val link -- http://code.activestate.com/recipes/66055-changing-the-indentation-of-a-multi-line-string/ val -- string indent -- integer -- how much whitespace we want in front of each l...
[ "def", "_add_indent", "(", "self", ",", "val", ",", "indent_count", ")", ":", "if", "isinstance", "(", "val", ",", "Value", ")", ":", "val", "=", "val", ".", "string_value", "(", ")", "return", "String", "(", "val", ")", ".", "indent", "(", "indent_c...
add whitespace to the beginning of each line of val link -- http://code.activestate.com/recipes/66055-changing-the-indentation-of-a-multi-line-string/ val -- string indent -- integer -- how much whitespace we want in front of each line of val return -- string -- val with more whitespa...
[ "add", "whitespace", "to", "the", "beginning", "of", "each", "line", "of", "val" ]
python
train
33.533333
iotile/coretools
iotilecore/iotile/core/hw/transport/adapter/mixin_notifications.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapter/mixin_notifications.py#L152-L196
async def _notify_event_internal(self, conn_string, name, event): """Notify that an event has occured. This method will send a notification and ensure that all callbacks registered for it have completed by the time it returns. In particular, if the callbacks are awaitable, this method ...
[ "async", "def", "_notify_event_internal", "(", "self", ",", "conn_string", ",", "name", ",", "event", ")", ":", "try", ":", "self", ".", "_currently_notifying", "=", "True", "conn_id", "=", "self", ".", "_get_conn_id", "(", "conn_string", ")", "event_maps", ...
Notify that an event has occured. This method will send a notification and ensure that all callbacks registered for it have completed by the time it returns. In particular, if the callbacks are awaitable, this method will await them before returning. The order in which the callbacks a...
[ "Notify", "that", "an", "event", "has", "occured", "." ]
python
train
45.866667
ssalentin/plip
plip/modules/preparation.py
https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L43-L117
def parse_pdb(self): """Extracts additional information from PDB files. I. When reading in a PDB file, OpenBabel numbers ATOMS and HETATOMS continously. In PDB files, TER records are also counted, leading to a different numbering system. This functions reads in a PDB file and provides a ...
[ "def", "parse_pdb", "(", "self", ")", ":", "if", "self", ".", "as_string", ":", "fil", "=", "self", ".", "pdbpath", ".", "rstrip", "(", "'\\n'", ")", ".", "split", "(", "'\\n'", ")", "# Removing trailing newline character", "else", ":", "f", "=", "read",...
Extracts additional information from PDB files. I. When reading in a PDB file, OpenBabel numbers ATOMS and HETATOMS continously. In PDB files, TER records are also counted, leading to a different numbering system. This functions reads in a PDB file and provides a mapping as a dictionary. ...
[ "Extracts", "additional", "information", "from", "PDB", "files", ".", "I", ".", "When", "reading", "in", "a", "PDB", "file", "OpenBabel", "numbers", "ATOMS", "and", "HETATOMS", "continously", ".", "In", "PDB", "files", "TER", "records", "are", "also", "count...
python
train
43.6
ejeschke/ginga
ginga/BaseImage.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/BaseImage.py#L167-L183
def set_data(self, data_np, metadata=None, order=None, astype=None): """Use this method to SHARE (not copy) the incoming array. """ if astype: data = data_np.astype(astype, copy=False) else: data = data_np self._data = data self._calc_order(order)...
[ "def", "set_data", "(", "self", ",", "data_np", ",", "metadata", "=", "None", ",", "order", "=", "None", ",", "astype", "=", "None", ")", ":", "if", "astype", ":", "data", "=", "data_np", ".", "astype", "(", "astype", ",", "copy", "=", "False", ")"...
Use this method to SHARE (not copy) the incoming array.
[ "Use", "this", "method", "to", "SHARE", "(", "not", "copy", ")", "the", "incoming", "array", "." ]
python
train
25.705882
cggh/scikit-allel
allel/stats/sf.py
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/sf.py#L37-L66
def sfs(dac, n=None): """Compute the site frequency spectrum given derived allele counts at a set of biallelic variants. Parameters ---------- dac : array_like, int, shape (n_variants,) Array of derived allele counts. n : int, optional The total number of chromosomes called. ...
[ "def", "sfs", "(", "dac", ",", "n", "=", "None", ")", ":", "# check input", "dac", ",", "n", "=", "_check_dac_n", "(", "dac", ",", "n", ")", "# need platform integer for bincount", "dac", "=", "dac", ".", "astype", "(", "int", ",", "copy", "=", "False"...
Compute the site frequency spectrum given derived allele counts at a set of biallelic variants. Parameters ---------- dac : array_like, int, shape (n_variants,) Array of derived allele counts. n : int, optional The total number of chromosomes called. Returns ------- sfs...
[ "Compute", "the", "site", "frequency", "spectrum", "given", "derived", "allele", "counts", "at", "a", "set", "of", "biallelic", "variants", "." ]
python
train
23.5
apache/incubator-mxnet
example/speech_recognition/stt_datagenerator.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_datagenerator.py#L80-L128
def load_metadata_from_desc_file(self, desc_file, partition='train', max_duration=16.0,): """ Read metadata from the description file (possibly takes long, depending on the filesize) Params: desc_file (str): Path to a JSON-line file that cont...
[ "def", "load_metadata_from_desc_file", "(", "self", ",", "desc_file", ",", "partition", "=", "'train'", ",", "max_duration", "=", "16.0", ",", ")", ":", "logger", "=", "logUtil", ".", "getlogger", "(", ")", "logger", ".", "info", "(", "'Reading description fil...
Read metadata from the description file (possibly takes long, depending on the filesize) Params: desc_file (str): Path to a JSON-line file that contains labels and paths to the audio files partition (str): One of 'train', 'validation' or 'test' ma...
[ "Read", "metadata", "from", "the", "description", "file", "(", "possibly", "takes", "long", "depending", "on", "the", "filesize", ")", "Params", ":", "desc_file", "(", "str", ")", ":", "Path", "to", "a", "JSON", "-", "line", "file", "that", "contains", "...
python
train
46.408163
elastic/elasticsearch-py
elasticsearch/client/xpack/sql.py
https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/sql.py#L33-L43
def translate(self, body, params=None): """ `<Translate SQL into Elasticsearch queries>`_ :arg body: Specify the query in the `query` element. """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") return self.tran...
[ "def", "translate", "(", "self", ",", "body", ",", "params", "=", "None", ")", ":", "if", "body", "in", "SKIP_IN_PATH", ":", "raise", "ValueError", "(", "\"Empty value passed for a required argument 'body'.\"", ")", "return", "self", ".", "transport", ".", "perf...
`<Translate SQL into Elasticsearch queries>`_ :arg body: Specify the query in the `query` element.
[ "<Translate", "SQL", "into", "Elasticsearch", "queries", ">", "_" ]
python
train
36.909091
klen/starter
starter/core.py
https://github.com/klen/starter/blob/24a65c10d4ac5a9ca8fc1d8b3d54b3fb13603f5f/starter/core.py#L180-L211
def copy(self): """ Prepare and paste self templates. """ templates = self.prepare_templates() if self.params.interactive: keys = list(self.parser.default) for key in keys: if key.startswith('_'): continue prompt = "{0} ...
[ "def", "copy", "(", "self", ")", ":", "templates", "=", "self", ".", "prepare_templates", "(", ")", "if", "self", ".", "params", ".", "interactive", ":", "keys", "=", "list", "(", "self", ".", "parser", ".", "default", ")", "for", "key", "in", "keys"...
Prepare and paste self templates.
[ "Prepare", "and", "paste", "self", "templates", "." ]
python
train
36.875
Geotab/mygeotab-python
mygeotab/api.py
https://github.com/Geotab/mygeotab-python/blob/baa678e7df90bdd15f5dc55c1374b5c048791a94/mygeotab/api.py#L336-L357
def server_call(method, server, timeout=DEFAULT_TIMEOUT, verify_ssl=True, **parameters): """Makes a call to an un-authenticated method on a server :param method: The method name. :type method: str :param server: The MyGeotab server. :type server: str :param timeout: The timeout to make the call...
[ "def", "server_call", "(", "method", ",", "server", ",", "timeout", "=", "DEFAULT_TIMEOUT", ",", "verify_ssl", "=", "True", ",", "*", "*", "parameters", ")", ":", "if", "method", "is", "None", ":", "raise", "Exception", "(", "\"A method name must be specified\...
Makes a call to an un-authenticated method on a server :param method: The method name. :type method: str :param server: The MyGeotab server. :type server: str :param timeout: The timeout to make the call, in seconds. By default, this is 300 seconds (or 5 minutes). :type timeout: float :para...
[ "Makes", "a", "call", "to", "an", "un", "-", "authenticated", "method", "on", "a", "server" ]
python
train
51.727273