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
UDST/osmnet
osmnet/utils.py
https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/utils.py#L17-L49
def great_circle_dist(lat1, lon1, lat2, lon2): """ Get the distance (in meters) between two lat/lon points via the Haversine formula. Parameters ---------- lat1, lon1, lat2, lon2 : float Latitude and longitude in degrees. Returns ------- dist : float Distance in met...
[ "def", "great_circle_dist", "(", "lat1", ",", "lon1", ",", "lat2", ",", "lon2", ")", ":", "radius", "=", "6372795", "# meters", "lat1", "=", "math", ".", "radians", "(", "lat1", ")", "lon1", "=", "math", ".", "radians", "(", "lon1", ")", "lat2", "=",...
Get the distance (in meters) between two lat/lon points via the Haversine formula. Parameters ---------- lat1, lon1, lat2, lon2 : float Latitude and longitude in degrees. Returns ------- dist : float Distance in meters.
[ "Get", "the", "distance", "(", "in", "meters", ")", "between", "two", "lat", "/", "lon", "points", "via", "the", "Haversine", "formula", "." ]
python
train
23.424242
gawel/panoramisk
panoramisk/utils.py
https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/utils.py#L18-L54
def parse_agi_result(line): """Parse AGI results using Regular expression. AGI Result examples:: 100 result=0 Trying... 200 result=0 200 result=-1 200 result=132456 200 result= (timeout) 510 Invalid or unknown command 520-Invalid command syntax. Pr...
[ "def", "parse_agi_result", "(", "line", ")", ":", "# print(\"--------------\\n\", line)", "if", "line", "==", "'HANGUP'", ":", "return", "{", "'error'", ":", "'AGIResultHangup'", ",", "'msg'", ":", "'User hungup during execution'", "}", "kwargs", "=", "dict", "(", ...
Parse AGI results using Regular expression. AGI Result examples:: 100 result=0 Trying... 200 result=0 200 result=-1 200 result=132456 200 result= (timeout) 510 Invalid or unknown command 520-Invalid command syntax. Proper usage follows: int() a...
[ "Parse", "AGI", "results", "using", "Regular", "expression", "." ]
python
test
22.459459
noobermin/lspreader
lspreader/pmovie.py
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L132-L151
def addhash(frame,**kw): ''' helper function to add hashes to the given frame given in the dictionary d returned from firsthash. Parameters: ----------- frame : frame to hash. Keywords: --------- same as genhash Returns frame with added hashes, although it will be add...
[ "def", "addhash", "(", "frame", ",", "*", "*", "kw", ")", ":", "hashes", "=", "genhash", "(", "frame", ",", "*", "*", "kw", ")", "frame", "[", "'data'", "]", "=", "rfn", ".", "rec_append_fields", "(", "frame", "[", "'data'", "]", ",", "'hash'", "...
helper function to add hashes to the given frame given in the dictionary d returned from firsthash. Parameters: ----------- frame : frame to hash. Keywords: --------- same as genhash Returns frame with added hashes, although it will be added in place.
[ "helper", "function", "to", "add", "hashes", "to", "the", "given", "frame", "given", "in", "the", "dictionary", "d", "returned", "from", "firsthash", "." ]
python
train
22.9
enkore/i3pystatus
i3pystatus/core/threading.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/core/threading.py#L51-L59
def should_execute(self, workload): """ If we have been suspended by i3bar, only execute those modules that set the keep_alive flag to a truthy value. See the docs on the suspend_signal_handler method of the io module for more information. """ if not self._suspended.is_set(): ...
[ "def", "should_execute", "(", "self", ",", "workload", ")", ":", "if", "not", "self", ".", "_suspended", ".", "is_set", "(", ")", ":", "return", "True", "workload", "=", "unwrap_workload", "(", "workload", ")", "return", "hasattr", "(", "workload", ",", ...
If we have been suspended by i3bar, only execute those modules that set the keep_alive flag to a truthy value. See the docs on the suspend_signal_handler method of the io module for more information.
[ "If", "we", "have", "been", "suspended", "by", "i3bar", "only", "execute", "those", "modules", "that", "set", "the", "keep_alive", "flag", "to", "a", "truthy", "value", ".", "See", "the", "docs", "on", "the", "suspend_signal_handler", "method", "of", "the", ...
python
train
51.111111
saltstack/salt
salt/states/win_certutil.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_certutil.py#L34-L73
def add_store(name, store, saltenv='base'): ''' Store a certificate to the given store name The certificate to store, this can use local paths or salt:// paths store The store to add the certificate to saltenv The salt environment to use, this is ignored if a local...
[ "def", "add_store", "(", "name", ",", "store", ",", "saltenv", "=", "'base'", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "cert_file", "=", "__sa...
Store a certificate to the given store name The certificate to store, this can use local paths or salt:// paths store The store to add the certificate to saltenv The salt environment to use, this is ignored if a local path is specified
[ "Store", "a", "certificate", "to", "the", "given", "store" ]
python
train
29
avelkoski/FRB
fred/helpers/__init__.py
https://github.com/avelkoski/FRB/blob/692bcf576e17bd1a81db2b7644f4f61aeb39e5c7/fred/helpers/__init__.py#L74-L83
def _data_frame(content): """ Helper funcation that converts text-based get response to a pandas dataframe for additional manipulation. """ response = loads(content) key = [x for x in response.keys() if x in c.response_data][0] frame = DataFrame(response[key]) final_frame = _convert(fram...
[ "def", "_data_frame", "(", "content", ")", ":", "response", "=", "loads", "(", "content", ")", "key", "=", "[", "x", "for", "x", "in", "response", ".", "keys", "(", ")", "if", "x", "in", "c", ".", "response_data", "]", "[", "0", "]", "frame", "="...
Helper funcation that converts text-based get response to a pandas dataframe for additional manipulation.
[ "Helper", "funcation", "that", "converts", "text", "-", "based", "get", "response", "to", "a", "pandas", "dataframe", "for", "additional", "manipulation", "." ]
python
train
33.6
tensorforce/tensorforce
tensorforce/core/baselines/baseline.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/baselines/baseline.py#L147-L157
def from_spec(spec, kwargs=None): """ Creates a baseline from a specification dict. """ baseline = util.get_object( obj=spec, predefined_objects=tensorforce.core.baselines.baselines, kwargs=kwargs ) assert isinstance(baseline, Baseline)...
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "baseline", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "baselines", ".", "baselines", ",", "kwargs", "="...
Creates a baseline from a specification dict.
[ "Creates", "a", "baseline", "from", "a", "specification", "dict", "." ]
python
valid
30.363636
tradenity/python-sdk
tradenity/resources/payment_token.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/payment_token.py#L474-L494
def get_payment_token_by_id(cls, payment_token_id, **kwargs): """Find PaymentToken Return single instance of PaymentToken by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get_payment...
[ "def", "get_payment_token_by_id", "(", "cls", ",", "payment_token_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_get_payment_t...
Find PaymentToken Return single instance of PaymentToken by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get_payment_token_by_id(payment_token_id, async=True) >>> result = thread.ge...
[ "Find", "PaymentToken" ]
python
train
44.095238
testedminds/sand
sand/graph.py
https://github.com/testedminds/sand/blob/234f0eedb0742920cdf26da9bc84bf3f863a2f02/sand/graph.py#L87-L98
def from_edges(edges, source_key='source', target_key='target', weight_key='weight', directed=True): """ Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph. """ raw = list(map(lambda x: [x[source_key], x[target_key], int(x[weight_key])], edges)) ...
[ "def", "from_edges", "(", "edges", ",", "source_key", "=", "'source'", ",", "target_key", "=", "'target'", ",", "weight_key", "=", "'weight'", ",", "directed", "=", "True", ")", ":", "raw", "=", "list", "(", "map", "(", "lambda", "x", ":", "[", "x", ...
Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph.
[ "Given", "a", "List", "of", "Dictionaries", "with", "source", "target", "and", "weight", "attributes", "return", "a", "weighted", "directed", "graph", "." ]
python
train
50
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py#L136-L156
def create_volume(self, volume_name: str, driver_spec: str = None): """Create new docker volumes. Only the manager nodes can create a volume Args: volume_name (string): Name for the new docker volume driver_spec (string): Driver for the docker volume """ ...
[ "def", "create_volume", "(", "self", ",", "volume_name", ":", "str", ",", "driver_spec", ":", "str", "=", "None", ")", ":", "# Default values", "if", "driver_spec", ":", "driver", "=", "driver_spec", "else", ":", "driver", "=", "'local'", "# Raise an exception...
Create new docker volumes. Only the manager nodes can create a volume Args: volume_name (string): Name for the new docker volume driver_spec (string): Driver for the docker volume
[ "Create", "new", "docker", "volumes", "." ]
python
train
32.904762
major/supernova
supernova/credentials.py
https://github.com/major/supernova/blob/4a217ae53c1c05567014b047c0b6b9dea2d383b3/supernova/credentials.py#L98-L109
def password_set(username=None, password=None): """ Stores a password in a keychain for a particular environment and configuration parameter pair. """ result = keyring.set_password('supernova', username, password) # NOTE: keyring returns None when the storage is successful. That's weird. i...
[ "def", "password_set", "(", "username", "=", "None", ",", "password", "=", "None", ")", ":", "result", "=", "keyring", ".", "set_password", "(", "'supernova'", ",", "username", ",", "password", ")", "# NOTE: keyring returns None when the storage is successful. That's...
Stores a password in a keychain for a particular environment and configuration parameter pair.
[ "Stores", "a", "password", "in", "a", "keychain", "for", "a", "particular", "environment", "and", "configuration", "parameter", "pair", "." ]
python
train
31.416667
senaite/senaite.core
bika/lims/content/worksheet.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/worksheet.py#L934-L954
def _apply_worksheet_template_duplicate_analyses(self, wst): """Add duplicate analyses to worksheet according to the worksheet template layout passed in w/o overwrite slots that are already filled. If the slot where the duplicate must be located is available, but the slot where the rout...
[ "def", "_apply_worksheet_template_duplicate_analyses", "(", "self", ",", "wst", ")", ":", "wst_layout", "=", "wst", ".", "getLayout", "(", ")", "for", "row", "in", "wst_layout", ":", "if", "row", "[", "'type'", "]", "!=", "'d'", ":", "continue", "src_pos", ...
Add duplicate analyses to worksheet according to the worksheet template layout passed in w/o overwrite slots that are already filled. If the slot where the duplicate must be located is available, but the slot where the routine analysis should be found is empty, no duplicate will be gene...
[ "Add", "duplicate", "analyses", "to", "worksheet", "according", "to", "the", "worksheet", "template", "layout", "passed", "in", "w", "/", "o", "overwrite", "slots", "that", "are", "already", "filled", "." ]
python
train
36.333333
proycon/pynlpl
pynlpl/formats/foliaset.py
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/foliaset.py#L371-L375
def orderedclasses(self, set_uri_or_id=None, nestedhierarchy=False): """Higher-order generator function that yields class information in the right order, combines calls to :meth:`SetDefinition.classes` and :meth:`SetDefinition.classorder`""" classes = self.classes(set_uri_or_id, nestedhierarchy) ...
[ "def", "orderedclasses", "(", "self", ",", "set_uri_or_id", "=", "None", ",", "nestedhierarchy", "=", "False", ")", ":", "classes", "=", "self", ".", "classes", "(", "set_uri_or_id", ",", "nestedhierarchy", ")", "for", "classid", "in", "self", ".", "classord...
Higher-order generator function that yields class information in the right order, combines calls to :meth:`SetDefinition.classes` and :meth:`SetDefinition.classorder`
[ "Higher", "-", "order", "generator", "function", "that", "yields", "class", "information", "in", "the", "right", "order", "combines", "calls", "to", ":", "meth", ":", "SetDefinition", ".", "classes", "and", ":", "meth", ":", "SetDefinition", ".", "classorder" ...
python
train
78.4
sentinel-hub/eo-learn
core/eolearn/core/plots.py
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/plots.py#L43-L54
def onscroll(self, event): """Action to be taken when an event is triggered. Event is scroll of the mouse's wheel. This leads to changing the temporal frame displayed. :param event: Scroll of mouse wheel """ if event.button == 'up': self.ind = (self.ind + 1)...
[ "def", "onscroll", "(", "self", ",", "event", ")", ":", "if", "event", ".", "button", "==", "'up'", ":", "self", ".", "ind", "=", "(", "self", ".", "ind", "+", "1", ")", "%", "self", ".", "slices", "else", ":", "self", ".", "ind", "=", "(", "...
Action to be taken when an event is triggered. Event is scroll of the mouse's wheel. This leads to changing the temporal frame displayed. :param event: Scroll of mouse wheel
[ "Action", "to", "be", "taken", "when", "an", "event", "is", "triggered", ".", "Event", "is", "scroll", "of", "the", "mouse", "s", "wheel", ".", "This", "leads", "to", "changing", "the", "temporal", "frame", "displayed", ".", ":", "param", "event", ":", ...
python
train
34.5
cloudendpoints/endpoints-python
endpoints/users_id_token.py
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L750-L794
def get_verified_jwt( providers, audiences, check_authorization_header=True, check_query_arg=True, request=None, cache=memcache): """ This function will extract, verify, and parse a JWT token from the Authorization header or access_token query argument. The JWT is assumed to contain an issuer and a...
[ "def", "get_verified_jwt", "(", "providers", ",", "audiences", ",", "check_authorization_header", "=", "True", ",", "check_query_arg", "=", "True", ",", "request", "=", "None", ",", "cache", "=", "memcache", ")", ":", "if", "not", "(", "check_authorization_heade...
This function will extract, verify, and parse a JWT token from the Authorization header or access_token query argument. The JWT is assumed to contain an issuer and audience claim, as well as issued-at and expiration timestamps. The signature will be cryptographically verified, the claims and timestamps will be...
[ "This", "function", "will", "extract", "verify", "and", "parse", "a", "JWT", "token", "from", "the", "Authorization", "header", "or", "access_token", "query", "argument", "." ]
python
train
40.133333
androguard/androguard
androguard/core/bytecodes/apk.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/apk.py#L986-L1009
def find_tags_from_xml( self, xml_name, tag_name, **attribute_filter ): """ Return a list of all the matched tags in a specific xml w :param str xml_name: specify from which xml to pick the tag from :param str tag_name: specify the tag name """ xml = s...
[ "def", "find_tags_from_xml", "(", "self", ",", "xml_name", ",", "tag_name", ",", "*", "*", "attribute_filter", ")", ":", "xml", "=", "self", ".", "xml", "[", "xml_name", "]", "if", "xml", "is", "None", ":", "return", "[", "]", "if", "xml", ".", "tag"...
Return a list of all the matched tags in a specific xml w :param str xml_name: specify from which xml to pick the tag from :param str tag_name: specify the tag name
[ "Return", "a", "list", "of", "all", "the", "matched", "tags", "in", "a", "specific", "xml", "w", ":", "param", "str", "xml_name", ":", "specify", "from", "which", "xml", "to", "pick", "the", "tag", "from", ":", "param", "str", "tag_name", ":", "specify...
python
train
30
lambdalisue/app_version
src/app_version/core.py
https://github.com/lambdalisue/app_version/blob/4b9f0acf44b5ed4230cb510edc15625151246611/src/app_version/core.py#L133-L174
def get_versions(name, default_string=DEFAULT_STRING_NOT_FOUND, default_tuple=DEFAULT_TUPLE_NOT_FOUND, allow_ambiguous=True): """ Get string and tuple versions from installed package information It will return :attr:`default_string` and :attr:`default_tupl...
[ "def", "get_versions", "(", "name", ",", "default_string", "=", "DEFAULT_STRING_NOT_FOUND", ",", "default_tuple", "=", "DEFAULT_TUPLE_NOT_FOUND", ",", "allow_ambiguous", "=", "True", ")", ":", "version_string", "=", "get_string_version", "(", "name", ",", "default_str...
Get string and tuple versions from installed package information It will return :attr:`default_string` and :attr:`default_tuple` values when the named package is not installed. Parameters ----------- name : string An application name used to install via setuptools. default : string ...
[ "Get", "string", "and", "tuple", "versions", "from", "installed", "package", "information" ]
python
train
32.547619
BD2KGenomics/toil-scripts
src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L46-L57
def reference_preprocessing(job, samples, config): """ Spawn the jobs that create index and dict file for reference :param JobFunctionWrappingJob job: passed automatically by Toil :param Namespace config: Argparse Namespace object containing argument inputs :param list[list] samples: A nested list ...
[ "def", "reference_preprocessing", "(", "job", ",", "samples", ",", "config", ")", ":", "job", ".", "fileStore", ".", "logToMaster", "(", "'Processed reference files'", ")", "config", ".", "fai", "=", "job", ".", "addChildJobFn", "(", "run_samtools_faidx", ",", ...
Spawn the jobs that create index and dict file for reference :param JobFunctionWrappingJob job: passed automatically by Toil :param Namespace config: Argparse Namespace object containing argument inputs :param list[list] samples: A nested list of samples containing sample information
[ "Spawn", "the", "jobs", "that", "create", "index", "and", "dict", "file", "for", "reference" ]
python
train
55
ConsenSys/mythril-classic
mythril/mythril/mythril_disassembler.py
https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/mythril/mythril_disassembler.py#L216-L303
def get_state_variable_from_storage( self, address: str, params: Optional[List[str]] = None ) -> str: """ Get variables from the storage :param address: The contract address :param params: The list of parameters param types: [position, length] or ["map...
[ "def", "get_state_variable_from_storage", "(", "self", ",", "address", ":", "str", ",", "params", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ")", "->", "str", ":", "params", "=", "params", "or", "[", "]", "(", "position", ",", "...
Get variables from the storage :param address: The contract address :param params: The list of parameters param types: [position, length] or ["mapping", position, key1, key2, ... ] or [position, length, array] :return: The corresponding storage sl...
[ "Get", "variables", "from", "the", "storage", ":", "param", "address", ":", "The", "contract", "address", ":", "param", "params", ":", "The", "list", "of", "parameters", "param", "types", ":", "[", "position", "length", "]", "or", "[", "mapping", "position...
python
train
38.602273
gawel/irc3
irc3/utils.py
https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L370-L388
def set_irc_targets(self, bot, *targets): """Add a irc Handler using bot and log to targets (can be nicks or channels: .. >>> bot = None .. code-block:: python >>> log = logging.getLogger('irc.mymodule') >>> log.set_irc_targets(bot, '#chan', 'admin'...
[ "def", "set_irc_targets", "(", "self", ",", "bot", ",", "*", "targets", ")", ":", "# get formatter initialized by config (usualy on a NullHandler)", "ll", "=", "logging", ".", "getLogger", "(", "'irc'", ")", "formatter", "=", "ll", ".", "handlers", "[", "0", "]"...
Add a irc Handler using bot and log to targets (can be nicks or channels: .. >>> bot = None .. code-block:: python >>> log = logging.getLogger('irc.mymodule') >>> log.set_irc_targets(bot, '#chan', 'admin')
[ "Add", "a", "irc", "Handler", "using", "bot", "and", "log", "to", "targets", "(", "can", "be", "nicks", "or", "channels", ":" ]
python
train
33
UCL-INGI/INGInious
inginious/frontend/plugin_manager.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/plugin_manager.py#L28-L38
def load(self, client, webpy_app, course_factory, task_factory, database, user_manager, submission_manager, config): """ Loads the plugin manager. Must be done after the initialisation of the client """ self._app = webpy_app self._task_factory = task_factory self._database = database ...
[ "def", "load", "(", "self", ",", "client", ",", "webpy_app", ",", "course_factory", ",", "task_factory", ",", "database", ",", "user_manager", ",", "submission_manager", ",", "config", ")", ":", "self", ".", "_app", "=", "webpy_app", "self", ".", "_task_fact...
Loads the plugin manager. Must be done after the initialisation of the client
[ "Loads", "the", "plugin", "manager", ".", "Must", "be", "done", "after", "the", "initialisation", "of", "the", "client" ]
python
train
53.545455
CalebBell/ht
ht/hx.py
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L1353-L1466
def temperature_effectiveness_TEMA_J(R1, NTU1, Ntp): r'''Returns temperature effectiveness `P1` of a TEMA J type heat exchanger with a specified heat capacity ratio, number of transfer units `NTU1`, and of number of tube passes `Ntp`. The supported cases are as follows: * One tube pass (shell...
[ "def", "temperature_effectiveness_TEMA_J", "(", "R1", ",", "NTU1", ",", "Ntp", ")", ":", "if", "Ntp", "==", "1", ":", "A", "=", "exp", "(", "NTU1", ")", "B", "=", "exp", "(", "-", "NTU1", "*", "R1", "/", "2.", ")", "if", "R1", "!=", "2", ":", ...
r'''Returns temperature effectiveness `P1` of a TEMA J type heat exchanger with a specified heat capacity ratio, number of transfer units `NTU1`, and of number of tube passes `Ntp`. The supported cases are as follows: * One tube pass (shell fluid mixed) * Two tube passes (shell fluid mixed, t...
[ "r", "Returns", "temperature", "effectiveness", "P1", "of", "a", "TEMA", "J", "type", "heat", "exchanger", "with", "a", "specified", "heat", "capacity", "ratio", "number", "of", "transfer", "units", "NTU1", "and", "of", "number", "of", "tube", "passes", "Ntp...
python
train
36.394737
KE-works/pykechain
pykechain/models/activity.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/activity.py#L141-L166
def associated_parts(self, *args, **kwargs): """Retrieve models and instances belonging to this activity. This is a convenience method for the :func:`Activity.parts()` method, which is used to retrieve both the `Category.MODEL` as well as the `Category.INSTANCE` in a tuple. This call o...
[ "def", "associated_parts", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "(", "self", ".", "parts", "(", "category", "=", "Category", ".", "MODEL", ",", "*", "args", ",", "*", "*", "kwargs", ")", ",", "self", ".", "p...
Retrieve models and instances belonging to this activity. This is a convenience method for the :func:`Activity.parts()` method, which is used to retrieve both the `Category.MODEL` as well as the `Category.INSTANCE` in a tuple. This call only returns the configured properties in an activity. So...
[ "Retrieve", "models", "and", "instances", "belonging", "to", "this", "activity", "." ]
python
train
41.153846
radujica/baloo
baloo/core/strings.py
https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/strings.py#L143-L169
def find(self, sub, start=0, end=None): """Test if elements contain substring. Parameters ---------- sub : str start : int, optional Index to start searching from. end : int, optional Index to stop searching from. Returns ------- ...
[ "def", "find", "(", "self", ",", "sub", ",", "start", "=", "0", ",", "end", "=", "None", ")", ":", "check_type", "(", "sub", ",", "str", ")", "check_type", "(", "start", ",", "int", ")", "check_type", "(", "end", ",", "int", ")", "if", "end", "...
Test if elements contain substring. Parameters ---------- sub : str start : int, optional Index to start searching from. end : int, optional Index to stop searching from. Returns ------- Series
[ "Test", "if", "elements", "contain", "substring", "." ]
python
train
26.925926
CI-WATER/gsshapy
gsshapy/orm/hmet.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/hmet.py#L56-L87
def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile): """ Read HMET WES from File Method """ # Set file extension property self.fileExtension = extension # Open file and parse into HmetRecords with op...
[ "def", "_read", "(", "self", ",", "directory", ",", "filename", ",", "session", ",", "path", ",", "name", ",", "extension", ",", "spatial", ",", "spatialReferenceID", ",", "replaceParamFile", ")", ":", "# Set file extension property", "self", ".", "fileExtension...
Read HMET WES from File Method
[ "Read", "HMET", "WES", "from", "File", "Method" ]
python
train
41.09375
gboeing/osmnx
osmnx/simplify.py
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L20-L88
def is_endpoint(G, node, strict=True): """ Return True if the node is a "real" endpoint of an edge in the network, \ otherwise False. OSM data includes lots of nodes that exist only as points \ to help streets bend around curves. An end point is a node that either: \ 1) is its own neighbor, ie, it s...
[ "def", "is_endpoint", "(", "G", ",", "node", ",", "strict", "=", "True", ")", ":", "neighbors", "=", "set", "(", "list", "(", "G", ".", "predecessors", "(", "node", ")", ")", "+", "list", "(", "G", ".", "successors", "(", "node", ")", ")", ")", ...
Return True if the node is a "real" endpoint of an edge in the network, \ otherwise False. OSM data includes lots of nodes that exist only as points \ to help streets bend around curves. An end point is a node that either: \ 1) is its own neighbor, ie, it self-loops. \ 2) or, has no incoming edges or no...
[ "Return", "True", "if", "the", "node", "is", "a", "real", "endpoint", "of", "an", "edge", "in", "the", "network", "\\", "otherwise", "False", ".", "OSM", "data", "includes", "lots", "of", "nodes", "that", "exist", "only", "as", "points", "\\", "to", "h...
python
train
35.942029
AndresMWeber/Nomenclate
nomenclate/core/nameparser.py
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/nameparser.py#L118-L132
def get_version(cls, name): """ Checks a string for a possible version of an object (no prefix, no suffix). Assumes only up to 4 digit padding :param name: str, string that represents a possible name of an object :return: (float, int, list(str), None), gets the version number then t...
[ "def", "get_version", "(", "cls", ",", "name", ")", ":", "# Dates can confuse th", "# is stuff, so we'll check for that first and remove it from the string if found", "try", ":", "date", "=", "cls", ".", "get_date", "(", "name", ")", "date", "=", "date", "[", "'dateti...
Checks a string for a possible version of an object (no prefix, no suffix). Assumes only up to 4 digit padding :param name: str, string that represents a possible name of an object :return: (float, int, list(str), None), gets the version number then the string matches
[ "Checks", "a", "string", "for", "a", "possible", "version", "of", "an", "object", "(", "no", "prefix", "no", "suffix", ")", ".", "Assumes", "only", "up", "to", "4", "digit", "padding" ]
python
train
44.8
Dallinger/Dallinger
dallinger/experiment.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L939-L956
def load(): """Load the active experiment.""" initialize_experiment_package(os.getcwd()) try: try: from dallinger_experiment import experiment except ImportError: from dallinger_experiment import dallinger_experiment as experiment classes = inspect.getmembers...
[ "def", "load", "(", ")", ":", "initialize_experiment_package", "(", "os", ".", "getcwd", "(", ")", ")", "try", ":", "try", ":", "from", "dallinger_experiment", "import", "experiment", "except", "ImportError", ":", "from", "dallinger_experiment", "import", "dalli...
Load the active experiment.
[ "Load", "the", "active", "experiment", "." ]
python
train
32.222222
pysathq/pysat
pysat/solvers.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1054-L1060
def prop_budget(self, budget): """ Set limit on the number of propagations. """ if self.glucose: pysolvers.glucose3_pbudget(self.glucose, budget)
[ "def", "prop_budget", "(", "self", ",", "budget", ")", ":", "if", "self", ".", "glucose", ":", "pysolvers", ".", "glucose3_pbudget", "(", "self", ".", "glucose", ",", "budget", ")" ]
Set limit on the number of propagations.
[ "Set", "limit", "on", "the", "number", "of", "propagations", "." ]
python
train
26.857143
tobami/littlechef
littlechef/lib.py
https://github.com/tobami/littlechef/blob/aab8c94081b38100a69cc100bc4278ae7419c58e/littlechef/lib.py#L357-L364
def get_recipes_in_node(node): """Gets the name of all recipes present in the run_list of a node""" recipes = [] for elem in node.get('run_list', []): if elem.startswith("recipe"): recipe = elem.split('[')[1].split(']')[0] recipes.append(recipe) return recipes
[ "def", "get_recipes_in_node", "(", "node", ")", ":", "recipes", "=", "[", "]", "for", "elem", "in", "node", ".", "get", "(", "'run_list'", ",", "[", "]", ")", ":", "if", "elem", ".", "startswith", "(", "\"recipe\"", ")", ":", "recipe", "=", "elem", ...
Gets the name of all recipes present in the run_list of a node
[ "Gets", "the", "name", "of", "all", "recipes", "present", "in", "the", "run_list", "of", "a", "node" ]
python
train
37.625
bitshares/uptick
uptick/committee.py
https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/committee.py#L52-L55
def createcommittee(ctx, url, account): """ Setup a committee account for your account """ print_tx(ctx.bitshares.create_committee_member(url, account=account))
[ "def", "createcommittee", "(", "ctx", ",", "url", ",", "account", ")", ":", "print_tx", "(", "ctx", ".", "bitshares", ".", "create_committee_member", "(", "url", ",", "account", "=", "account", ")", ")" ]
Setup a committee account for your account
[ "Setup", "a", "committee", "account", "for", "your", "account" ]
python
train
42.25
MatiasSM/fcb
fcb/processing/transformations/Cipher.py
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/transformations/Cipher.py#L27-L42
def do_heavy_work(self, block): """ Expects Compressor Block like objects """ cipher_key = self.gen_key(32) in_file_path = block.latest_file_info.path dst_file_path = block.processed_data_file_info.path + self.get_extension() self.log.debug("Encrypting file '%s' w...
[ "def", "do_heavy_work", "(", "self", ",", "block", ")", ":", "cipher_key", "=", "self", ".", "gen_key", "(", "32", ")", "in_file_path", "=", "block", ".", "latest_file_info", ".", "path", "dst_file_path", "=", "block", ".", "processed_data_file_info", ".", "...
Expects Compressor Block like objects
[ "Expects", "Compressor", "Block", "like", "objects" ]
python
train
45
RazerM/yourls-python
yourls/core.py
https://github.com/RazerM/yourls-python/blob/716845562a2bbb430de3c379c9481b195e451ccf/yourls/core.py#L83-L100
def expand(self, short): """Expand short URL or keyword to long URL. Parameters: short: Short URL (``http://example.com/abc``) or keyword (abc). :return: Expanded/long URL, e.g. ``https://www.youtube.com/watch?v=dQw4w9WgXcQ`` Raises: ~yourls.ex...
[ "def", "expand", "(", "self", ",", "short", ")", ":", "data", "=", "dict", "(", "action", "=", "'expand'", ",", "shorturl", "=", "short", ")", "jsondata", "=", "self", ".", "_api_request", "(", "params", "=", "data", ")", "return", "jsondata", "[", "...
Expand short URL or keyword to long URL. Parameters: short: Short URL (``http://example.com/abc``) or keyword (abc). :return: Expanded/long URL, e.g. ``https://www.youtube.com/watch?v=dQw4w9WgXcQ`` Raises: ~yourls.exceptions.YOURLSHTTPError: HTTP error...
[ "Expand", "short", "URL", "or", "keyword", "to", "long", "URL", "." ]
python
test
33.333333
mattlong/hermes
hermes/server.py
https://github.com/mattlong/hermes/blob/63a5afcafe90ca99aeb44edeee9ed6f90baae431/hermes/server.py#L78-L91
def _listen(sockets): """Main server loop. Listens for incoming events and dispatches them to appropriate chatroom""" while True: (i , o, e) = select.select(sockets.keys(),[],[],1) for socket in i: if isinstance(sockets[socket], Chatroom): data_len = sockets[socket].c...
[ "def", "_listen", "(", "sockets", ")", ":", "while", "True", ":", "(", "i", ",", "o", ",", "e", ")", "=", "select", ".", "select", "(", "sockets", ".", "keys", "(", ")", ",", "[", "]", ",", "[", "]", ",", "1", ")", "for", "socket", "in", "i...
Main server loop. Listens for incoming events and dispatches them to appropriate chatroom
[ "Main", "server", "loop", ".", "Listens", "for", "incoming", "events", "and", "dispatches", "them", "to", "appropriate", "chatroom" ]
python
train
50
gpoulter/fablib
fablib.py
https://github.com/gpoulter/fablib/blob/5d14c4d998f79dd1aa3207063c3d06e30e3e2bf9/fablib.py#L178-L189
def install_deb(pkgname, url): """Install package from custom deb hosted on S3. Return true if package was installed by this invocation.""" status = run("dpkg-query -W -f='${{Status}}' {p}; true".format(p=pkgname)) if ('installed' not in status) or ('not-installed' in status): deb = url.rpartiti...
[ "def", "install_deb", "(", "pkgname", ",", "url", ")", ":", "status", "=", "run", "(", "\"dpkg-query -W -f='${{Status}}' {p}; true\"", ".", "format", "(", "p", "=", "pkgname", ")", ")", "if", "(", "'installed'", "not", "in", "status", ")", "or", "(", "'not...
Install package from custom deb hosted on S3. Return true if package was installed by this invocation.
[ "Install", "package", "from", "custom", "deb", "hosted", "on", "S3", ".", "Return", "true", "if", "package", "was", "installed", "by", "this", "invocation", "." ]
python
train
45.75
quantum5/2048
_2048/game.py
https://github.com/quantum5/2048/blob/93ada2e3026eaf154e1bbee943d0500c9253e66f/_2048/game.py#L439-L508
def _shift_cells(self, get_cells, get_deltas): """Handles cell shifting.""" # Don't do anything when there is an overlay. if self.lost or self.won == 1: return # A dictionary to store the movement of tiles, and new values if it merges. tile_moved = {} for y, ...
[ "def", "_shift_cells", "(", "self", ",", "get_cells", ",", "get_deltas", ")", ":", "# Don't do anything when there is an overlay.", "if", "self", ".", "lost", "or", "self", ".", "won", "==", "1", ":", "return", "# A dictionary to store the movement of tiles, and new val...
Handles cell shifting.
[ "Handles", "cell", "shifting", "." ]
python
train
41.757143
quantopian/zipline
zipline/data/data_portal.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/data_portal.py#L1391-L1412
def get_current_future_chain(self, continuous_future, dt): """ Retrieves the future chain for the contract at the given `dt` according the `continuous_future` specification. Returns ------- future_chain : list[Future] A list of active futures, where the firs...
[ "def", "get_current_future_chain", "(", "self", ",", "continuous_future", ",", "dt", ")", ":", "rf", "=", "self", ".", "_roll_finders", "[", "continuous_future", ".", "roll_style", "]", "session", "=", "self", ".", "trading_calendar", ".", "minute_to_session_label...
Retrieves the future chain for the contract at the given `dt` according the `continuous_future` specification. Returns ------- future_chain : list[Future] A list of active futures, where the first index is the current contract specified by the continuous future ...
[ "Retrieves", "the", "future", "chain", "for", "the", "contract", "at", "the", "given", "dt", "according", "the", "continuous_future", "specification", "." ]
python
train
43.136364
Fantomas42/django-blog-zinnia
zinnia/admin/fields.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/admin/fields.py#L11-L19
def choice(self, obj): """ Overloads the choice method to add the position of the object in the tree for future sorting. """ tree_id = getattr(obj, self.queryset.model._mptt_meta.tree_id_attr, 0) left = getattr(obj, self.queryset.model._mptt_meta.left_attr, 0) ret...
[ "def", "choice", "(", "self", ",", "obj", ")", ":", "tree_id", "=", "getattr", "(", "obj", ",", "self", ".", "queryset", ".", "model", ".", "_mptt_meta", ".", "tree_id_attr", ",", "0", ")", "left", "=", "getattr", "(", "obj", ",", "self", ".", "que...
Overloads the choice method to add the position of the object in the tree for future sorting.
[ "Overloads", "the", "choice", "method", "to", "add", "the", "position", "of", "the", "object", "in", "the", "tree", "for", "future", "sorting", "." ]
python
train
45.111111
Xion/taipan
taipan/objective/modifiers.py
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/modifiers.py#L134-L170
def override(base=ABSENT): """Mark a method as overriding a corresponding method from superclass. :param base: Optional base class from which this method is being overridden. If provided, it can be a class itself, or its (qualified) name. .. note:: When overriding a :class:`class...
[ "def", "override", "(", "base", "=", "ABSENT", ")", ":", "arg", "=", "base", "# ``base`` is just for clean, user-facing argument name", "# direct application of the modifier through ``@override``", "if", "inspect", ".", "isfunction", "(", "arg", ")", "or", "isinstance", "...
Mark a method as overriding a corresponding method from superclass. :param base: Optional base class from which this method is being overridden. If provided, it can be a class itself, or its (qualified) name. .. note:: When overriding a :class:`classmethod`, remember to place ``@over...
[ "Mark", "a", "method", "as", "overriding", "a", "corresponding", "method", "from", "superclass", "." ]
python
train
34.054054
fastai/fastai
fastai/train.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/train.py#L24-L32
def lr_find(learn:Learner, start_lr:Floats=1e-7, end_lr:Floats=10, num_it:int=100, stop_div:bool=True, wd:float=None): "Explore lr from `start_lr` to `end_lr` over `num_it` iterations in `learn`. If `stop_div`, stops when loss diverges." start_lr = learn.lr_range(start_lr) start_lr = np.array(start_lr) if i...
[ "def", "lr_find", "(", "learn", ":", "Learner", ",", "start_lr", ":", "Floats", "=", "1e-7", ",", "end_lr", ":", "Floats", "=", "10", ",", "num_it", ":", "int", "=", "100", ",", "stop_div", ":", "bool", "=", "True", ",", "wd", ":", "float", "=", ...
Explore lr from `start_lr` to `end_lr` over `num_it` iterations in `learn`. If `stop_div`, stops when loss diverges.
[ "Explore", "lr", "from", "start_lr", "to", "end_lr", "over", "num_it", "iterations", "in", "learn", ".", "If", "stop_div", "stops", "when", "loss", "diverges", "." ]
python
train
68.444444
jeffrimko/Qprompt
lib/qprompt.py
https://github.com/jeffrimko/Qprompt/blob/1887c53656dfecac49e0650e0f912328801cbb83/lib/qprompt.py#L549-L552
def ask_captcha(length=4): """Prompts the user for a random string.""" captcha = "".join(random.choice(string.ascii_lowercase) for _ in range(length)) ask_str('Enter the following letters, "%s"' % (captcha), vld=[captcha, captcha.upper()], blk=False)
[ "def", "ask_captcha", "(", "length", "=", "4", ")", ":", "captcha", "=", "\"\"", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_lowercase", ")", "for", "_", "in", "range", "(", "length", ")", ")", "ask_str", "(", "'Enter the foll...
Prompts the user for a random string.
[ "Prompts", "the", "user", "for", "a", "random", "string", "." ]
python
train
64.75
tisimst/pyDOE
pyDOE/doe_star.py
https://github.com/tisimst/pyDOE/blob/436143702507a5c8ff87b361223eee8171d6a1d7/pyDOE/doe_star.py#L18-L79
def star(n, alpha='faced', center=(1, 1)): """ Create the star points of various design matrices Parameters ---------- n : int The number of variables in the design Optional -------- alpha : str Available values are 'faced' (default), 'orthogonal', o...
[ "def", "star", "(", "n", ",", "alpha", "=", "'faced'", ",", "center", "=", "(", "1", ",", "1", ")", ")", ":", "# Star points at the center of each face of the factorial\r", "if", "alpha", "==", "'faced'", ":", "a", "=", "1", "elif", "alpha", "==", "'orthog...
Create the star points of various design matrices Parameters ---------- n : int The number of variables in the design Optional -------- alpha : str Available values are 'faced' (default), 'orthogonal', or 'rotatable' center : array A 1-by-2 array...
[ "Create", "the", "star", "points", "of", "various", "design", "matrices", "Parameters", "----------", "n", ":", "int", "The", "number", "of", "variables", "in", "the", "design", "Optional", "--------", "alpha", ":", "str", "Available", "values", "are", "faced"...
python
train
28.580645
fastai/fastai
old/fastai/model.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/old/fastai/model.py#L88-L181
def fit(model, data, n_epochs, opt, crit, metrics=None, callbacks=None, stepper=Stepper, swa_model=None, swa_start=None, swa_eval_freq=None, visualize=False, **kwargs): """ Fits a model Arguments: model (model): any pytorch module net = to_gpu(net) data (ModelData): see ModelDa...
[ "def", "fit", "(", "model", ",", "data", ",", "n_epochs", ",", "opt", ",", "crit", ",", "metrics", "=", "None", ",", "callbacks", "=", "None", ",", "stepper", "=", "Stepper", ",", "swa_model", "=", "None", ",", "swa_start", "=", "None", ",", "swa_eva...
Fits a model Arguments: model (model): any pytorch module net = to_gpu(net) data (ModelData): see ModelData class and subclasses (can be a list) opts: an optimizer. Example: optim.Adam. If n_epochs is a list, it needs to be the layer_optimizer to get the optimizer as it chan...
[ "Fits", "a", "model" ]
python
train
47.595745
SBRG/ssbio
ssbio/pipeline/gempro.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/gempro.py#L1593-L1604
def save_protein_pickles_and_reset_protein(self): """Save all Proteins as pickle files -- currently development code for parallelization purposes. Also clears the protein attribute in all genes!""" self.gene_protein_pickles = {} for g in tqdm(self.genes): if g.protein.represe...
[ "def", "save_protein_pickles_and_reset_protein", "(", "self", ")", ":", "self", ".", "gene_protein_pickles", "=", "{", "}", "for", "g", "in", "tqdm", "(", "self", ".", "genes", ")", ":", "if", "g", ".", "protein", ".", "representative_sequence", ":", "initpr...
Save all Proteins as pickle files -- currently development code for parallelization purposes. Also clears the protein attribute in all genes!
[ "Save", "all", "Proteins", "as", "pickle", "files", "--", "currently", "development", "code", "for", "parallelization", "purposes", ".", "Also", "clears", "the", "protein", "attribute", "in", "all", "genes!" ]
python
train
53
ChrisBeaumont/soupy
soupy.py
https://github.com/ChrisBeaumont/soupy/blob/795f2f61f711f574d5218fc8a3375d02bda1104f/soupy.py#L608-L627
def takewhile(self, func=None): """ Return a new Collection with the last few items removed. Parameters: func : function(Node) -> Node Returns: A new Collection, discarding all items at and after the first item where bool(func(item)) == False ...
[ "def", "takewhile", "(", "self", ",", "func", "=", "None", ")", ":", "func", "=", "_make_callable", "(", "func", ")", "return", "Collection", "(", "takewhile", "(", "func", ",", "self", ".", "_items", ")", ")" ]
Return a new Collection with the last few items removed. Parameters: func : function(Node) -> Node Returns: A new Collection, discarding all items at and after the first item where bool(func(item)) == False Examples: node.find_all('tr').takew...
[ "Return", "a", "new", "Collection", "with", "the", "last", "few", "items", "removed", "." ]
python
test
24.6
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py#L1161-L1179
def hide_routemap_holder_route_map_content_set_metric_type_external(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") hide_routemap_holder = ET.SubElement(config, "hide-routemap-holder", xmlns="urn:brocade.com:mgmt:brocade-ip-policy") route_map = ET.SubEle...
[ "def", "hide_routemap_holder_route_map_content_set_metric_type_external", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "hide_routemap_holder", "=", "ET", ".", "SubElement", "(", "config", ",", "\"hide...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
50.789474
PythonCharmers/python-future
src/future/builtins/newround.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/builtins/newround.py#L12-L50
def newround(number, ndigits=None): """ See Python 3 documentation: uses Banker's Rounding. Delegates to the __round__ method if for some reason this exists. If not, rounds a number to a given precision in decimal digits (default 0 digits). This returns an int when called with one argument, ot...
[ "def", "newround", "(", "number", ",", "ndigits", "=", "None", ")", ":", "return_int", "=", "False", "if", "ndigits", "is", "None", ":", "return_int", "=", "True", "ndigits", "=", "0", "if", "hasattr", "(", "number", ",", "'__round__'", ")", ":", "retu...
See Python 3 documentation: uses Banker's Rounding. Delegates to the __round__ method if for some reason this exists. If not, rounds a number to a given precision in decimal digits (default 0 digits). This returns an int when called with one argument, otherwise the same type as the number. ndigits may...
[ "See", "Python", "3", "documentation", ":", "uses", "Banker", "s", "Rounding", "." ]
python
train
31.205128
datastore/datastore
datastore/core/query.py
https://github.com/datastore/datastore/blob/7ccf0cd4748001d3dbf5e6dda369b0f63e0269d3/datastore/core/query.py#L425-L441
def dict(self): '''Returns a dictionary representing this query.''' d = dict() d['key'] = str(self.key) if self.limit is not None: d['limit'] = self.limit if self.offset > 0: d['offset'] = self.offset if self.offset_key: d['offset_key'] = str(self.offset_key) if len(self.f...
[ "def", "dict", "(", "self", ")", ":", "d", "=", "dict", "(", ")", "d", "[", "'key'", "]", "=", "str", "(", "self", ".", "key", ")", "if", "self", ".", "limit", "is", "not", "None", ":", "d", "[", "'limit'", "]", "=", "self", ".", "limit", "...
Returns a dictionary representing this query.
[ "Returns", "a", "dictionary", "representing", "this", "query", "." ]
python
train
28.058824
Calysto/calysto
calysto/graphics.py
https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/graphics.py#L238-L246
def toPIL(self, **attribs): """ Convert canvas to a PIL image """ import PIL.Image bytes = self.convert("png") sfile = io.BytesIO(bytes) pil = PIL.Image.open(sfile) return pil
[ "def", "toPIL", "(", "self", ",", "*", "*", "attribs", ")", ":", "import", "PIL", ".", "Image", "bytes", "=", "self", ".", "convert", "(", "\"png\"", ")", "sfile", "=", "io", ".", "BytesIO", "(", "bytes", ")", "pil", "=", "PIL", ".", "Image", "."...
Convert canvas to a PIL image
[ "Convert", "canvas", "to", "a", "PIL", "image" ]
python
train
25.666667
tallero/trovotutto
trovotutto/__init__.py
https://github.com/tallero/trovotutto/blob/7afcfacf2bb3b642654153630c1ab7447ab10fae/trovotutto/__init__.py#L45-L54
def save(variable, filename): """Save variable on given path using Pickle Args: variable: what to save path (str): path of the output """ fileObj = open(filename, 'wb') pickle.dump(variable, fileObj) fileObj.close()
[ "def", "save", "(", "variable", ",", "filename", ")", ":", "fileObj", "=", "open", "(", "filename", ",", "'wb'", ")", "pickle", ".", "dump", "(", "variable", ",", "fileObj", ")", "fileObj", ".", "close", "(", ")" ]
Save variable on given path using Pickle Args: variable: what to save path (str): path of the output
[ "Save", "variable", "on", "given", "path", "using", "Pickle", "Args", ":", "variable", ":", "what", "to", "save", "path", "(", "str", ")", ":", "path", "of", "the", "output" ]
python
test
25.1
Locu/chronology
jia/scheduler/client.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/jia/scheduler/client.py#L21-L48
def _send_with_auth(values, secret_key, url): """Send dictionary of JSON serializable `values` as a POST body to `url` along with `auth_token` that's generated from `secret_key` and `values` scheduler.auth.create_token expects a JSON serializable payload, so we send a dictionary. On the receiving end of the...
[ "def", "_send_with_auth", "(", "values", ",", "secret_key", ",", "url", ")", ":", "data", "=", "urllib", ".", "urlencode", "(", "values", ")", "# Simulate a Flask request because that is what will be unpacked when the", "# request is received on the other side", "request", ...
Send dictionary of JSON serializable `values` as a POST body to `url` along with `auth_token` that's generated from `secret_key` and `values` scheduler.auth.create_token expects a JSON serializable payload, so we send a dictionary. On the receiving end of the POST request, the Flask view will have access to...
[ "Send", "dictionary", "of", "JSON", "serializable", "values", "as", "a", "POST", "body", "to", "url", "along", "with", "auth_token", "that", "s", "generated", "from", "secret_key", "and", "values" ]
python
train
41.392857
quantmind/pulsar
pulsar/async/mixins.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/mixins.py#L60-L77
def resume_writing(self, exc=None): '''Resume writing. Successive calls to this method will fails unless :meth:`pause_writing` is called first. ''' assert self._paused self._paused = False waiter = self._waiter if waiter is not None: self._wai...
[ "def", "resume_writing", "(", "self", ",", "exc", "=", "None", ")", ":", "assert", "self", ".", "_paused", "self", ".", "_paused", "=", "False", "waiter", "=", "self", ".", "_waiter", "if", "waiter", "is", "not", "None", ":", "self", ".", "_waiter", ...
Resume writing. Successive calls to this method will fails unless :meth:`pause_writing` is called first.
[ "Resume", "writing", "." ]
python
train
31.611111
isambard-uob/ampal
src/ampal/base_ampal.py
https://github.com/isambard-uob/ampal/blob/906e2afacb435ffb129b381f262ff8e7bfb324c5/src/ampal/base_ampal.py#L587-L597
def get_atoms(self, inc_alt_states=False): """Returns all atoms in the `Monomer`. Parameters ---------- inc_alt_states : bool, optional If `True`, will return `Atoms` for alternate states. """ if inc_alt_states: return itertools.chain(*[x[1].value...
[ "def", "get_atoms", "(", "self", ",", "inc_alt_states", "=", "False", ")", ":", "if", "inc_alt_states", ":", "return", "itertools", ".", "chain", "(", "*", "[", "x", "[", "1", "]", ".", "values", "(", ")", "for", "x", "in", "sorted", "(", "list", "...
Returns all atoms in the `Monomer`. Parameters ---------- inc_alt_states : bool, optional If `True`, will return `Atoms` for alternate states.
[ "Returns", "all", "atoms", "in", "the", "Monomer", "." ]
python
train
35.727273
tensorforce/tensorforce
tensorforce/core/explorations/exploration.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/explorations/exploration.py#L65-L74
def from_spec(spec): """ Creates an exploration object from a specification dict. """ exploration = util.get_object( obj=spec, predefined_objects=tensorforce.core.explorations.explorations ) assert isinstance(exploration, Exploration) retur...
[ "def", "from_spec", "(", "spec", ")", ":", "exploration", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "explorations", ".", "explorations", ")", "assert", "isinstance", "(", "explor...
Creates an exploration object from a specification dict.
[ "Creates", "an", "exploration", "object", "from", "a", "specification", "dict", "." ]
python
valid
32.4
spacetelescope/drizzlepac
drizzlepac/astrodrizzle.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/astrodrizzle.py#L59-L118
def AstroDrizzle(input=None, mdriztab=False, editpars=False, configobj=None, wcsmap=None, **input_dict): """ AstroDrizzle command-line interface """ # Support input of filenames from command-line without a parameter name # then copy this into input_dict for merging with TEAL ConfigObj #...
[ "def", "AstroDrizzle", "(", "input", "=", "None", ",", "mdriztab", "=", "False", ",", "editpars", "=", "False", ",", "configobj", "=", "None", ",", "wcsmap", "=", "None", ",", "*", "*", "input_dict", ")", ":", "# Support input of filenames from command-line wi...
AstroDrizzle command-line interface
[ "AstroDrizzle", "command", "-", "line", "interface" ]
python
train
41.1
spyder-ide/spyder-kernels
spyder_kernels/customize/spydercustomize.py
https://github.com/spyder-ide/spyder-kernels/blob/2c5b36cdb797b8aba77bc406ca96f5e079c4aaca/spyder_kernels/customize/spydercustomize.py#L658-L689
def activate_cython(self): """ Activate Cython support. We need to run this here because if the support is active, we don't to run the UMR at all. """ run_cython = os.environ.get("SPY_RUN_CYTHON") == "True" if run_cython: try: __impor...
[ "def", "activate_cython", "(", "self", ")", ":", "run_cython", "=", "os", ".", "environ", ".", "get", "(", "\"SPY_RUN_CYTHON\"", ")", "==", "\"True\"", "if", "run_cython", ":", "try", ":", "__import__", "(", "'Cython'", ")", "self", ".", "has_cython", "=",...
Activate Cython support. We need to run this here because if the support is active, we don't to run the UMR at all.
[ "Activate", "Cython", "support", "." ]
python
train
32.21875
IDSIA/sacred
sacred/ingredient.py
https://github.com/IDSIA/sacred/blob/72633776bed9b5bddf93ae7d215188e61970973a/sacred/ingredient.py#L28-L38
def gather_from_ingredients(wrapped, instance=None, args=None, kwargs=None): """ Decorator that calls `_gather` on the instance the wrapped function is bound to (should be an `Ingredient`) and yields from the returned generator. This function is necessary, because `Ingredient._gather` cannot direct...
[ "def", "gather_from_ingredients", "(", "wrapped", ",", "instance", "=", "None", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "for", "item", "in", "instance", ".", "_gather", "(", "wrapped", ")", ":", "yield", "item" ]
Decorator that calls `_gather` on the instance the wrapped function is bound to (should be an `Ingredient`) and yields from the returned generator. This function is necessary, because `Ingredient._gather` cannot directly be used as a decorator inside of `Ingredient`.
[ "Decorator", "that", "calls", "_gather", "on", "the", "instance", "the", "wrapped", "function", "is", "bound", "to", "(", "should", "be", "an", "Ingredient", ")", "and", "yields", "from", "the", "returned", "generator", "." ]
python
train
39.363636
juju/python-libjuju
juju/client/_client5.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client5.py#L448-L465
async def AddUnits(self, application, num_units, placement): ''' application : str num_units : int placement : typing.Sequence[~Placement] Returns -> typing.Sequence[str] ''' # map input types to rpc msg _params = dict() msg = dict(type='Applicatio...
[ "async", "def", "AddUnits", "(", "self", ",", "application", ",", "num_units", ",", "placement", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'Application'", ",", "request", "=", "'AddUnit...
application : str num_units : int placement : typing.Sequence[~Placement] Returns -> typing.Sequence[str]
[ "application", ":", "str", "num_units", ":", "int", "placement", ":", "typing", ".", "Sequence", "[", "~Placement", "]", "Returns", "-", ">", "typing", ".", "Sequence", "[", "str", "]" ]
python
train
33
CityOfZion/neo-python
neo/Core/State/ContractState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/ContractState.py#L179-L216
def ToJson(self): """ Convert object members to a dictionary that can be parsed as JSON. Returns: dict: """ name = 'Contract' try: name = self.Name.decode('utf-8') except Exception as e: pass jsn = {'version': self.S...
[ "def", "ToJson", "(", "self", ")", ":", "name", "=", "'Contract'", "try", ":", "name", "=", "self", ".", "Name", ".", "decode", "(", "'utf-8'", ")", "except", "Exception", "as", "e", ":", "pass", "jsn", "=", "{", "'version'", ":", "self", ".", "Sta...
Convert object members to a dictionary that can be parsed as JSON. Returns: dict:
[ "Convert", "object", "members", "to", "a", "dictionary", "that", "can", "be", "parsed", "as", "JSON", "." ]
python
train
25.421053
tonyfischetti/sake
sakelib/acts.py
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L557-L596
def clean_all(G, settings): """ Removes all the output files from all targets. Takes the graph as the only argument Args: The networkx graph object The settings dictionary Returns: 0 if successful 1 if removing even one file failed """ quiet = settings["quie...
[ "def", "clean_all", "(", "G", ",", "settings", ")", ":", "quiet", "=", "settings", "[", "\"quiet\"", "]", "recon", "=", "settings", "[", "\"recon\"", "]", "sprint", "=", "settings", "[", "\"sprint\"", "]", "error", "=", "settings", "[", "\"error\"", "]",...
Removes all the output files from all targets. Takes the graph as the only argument Args: The networkx graph object The settings dictionary Returns: 0 if successful 1 if removing even one file failed
[ "Removes", "all", "the", "output", "files", "from", "all", "targets", ".", "Takes", "the", "graph", "as", "the", "only", "argument" ]
python
valid
30.25
pyviz/holoviews
holoviews/core/util.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/util.py#L1476-L1491
def disable_constant(parameterized): """ Temporarily set parameters on Parameterized object to constant=False. """ params = parameterized.params().values() constants = [p.constant for p in params] for p in params: p.constant = False try: yield except: raise ...
[ "def", "disable_constant", "(", "parameterized", ")", ":", "params", "=", "parameterized", ".", "params", "(", ")", ".", "values", "(", ")", "constants", "=", "[", "p", ".", "constant", "for", "p", "in", "params", "]", "for", "p", "in", "params", ":", ...
Temporarily set parameters on Parameterized object to constant=False.
[ "Temporarily", "set", "parameters", "on", "Parameterized", "object", "to", "constant", "=", "False", "." ]
python
train
24.75
graphql-python/graphql-core-next
graphql/language/printer.py
https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/language/printer.py#L20-L27
def add_description(method): """Decorator adding the description to the output of a visitor method.""" @wraps(method) def wrapped(self, node, *args): return join([node.description, method(self, node, *args)], "\n") return wrapped
[ "def", "add_description", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "wrapped", "(", "self", ",", "node", ",", "*", "args", ")", ":", "return", "join", "(", "[", "node", ".", "description", ",", "method", "(", "self", ",", "n...
Decorator adding the description to the output of a visitor method.
[ "Decorator", "adding", "the", "description", "to", "the", "output", "of", "a", "visitor", "method", "." ]
python
train
31
bitcraze/crazyflie-lib-python
cflib/bootloader/cloader.py
https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/bootloader/cloader.py#L137-L184
def reset_to_bootloader1(self, cpu_id): """ Reset to the bootloader The parameter cpuid shall correspond to the device to reset. Return true if the reset has been done and the contact with the bootloader is established. """ # Send an echo request and wait for the answer ...
[ "def", "reset_to_bootloader1", "(", "self", ",", "cpu_id", ")", ":", "# Send an echo request and wait for the answer", "# Mainly aim to bypass a bug of the crazyflie firmware that prevents", "# reset before normal CRTP communication", "pk", "=", "CRTPPacket", "(", ")", "pk", ".", ...
Reset to the bootloader The parameter cpuid shall correspond to the device to reset. Return true if the reset has been done and the contact with the bootloader is established.
[ "Reset", "to", "the", "bootloader", "The", "parameter", "cpuid", "shall", "correspond", "to", "the", "device", "to", "reset", "." ]
python
train
30.375
numberoverzero/bloop
bloop/util.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/util.py#L125-L142
def dump_key(engine, obj): """dump the hash (and range, if there is one) key(s) of an object into a dynamo-friendly format. returns {dynamo_name: {type: value} for dynamo_name in hash/range keys} """ key = {} for key_column in obj.Meta.keys: key_value = getattr(obj, key_column.name, mis...
[ "def", "dump_key", "(", "engine", ",", "obj", ")", ":", "key", "=", "{", "}", "for", "key_column", "in", "obj", ".", "Meta", ".", "keys", ":", "key_value", "=", "getattr", "(", "obj", ",", "key_column", ".", "name", ",", "missing", ")", "if", "key_...
dump the hash (and range, if there is one) key(s) of an object into a dynamo-friendly format. returns {dynamo_name: {type: value} for dynamo_name in hash/range keys}
[ "dump", "the", "hash", "(", "and", "range", "if", "there", "is", "one", ")", "key", "(", "s", ")", "of", "an", "object", "into", "a", "dynamo", "-", "friendly", "format", "." ]
python
train
38.5
PeerAssets/pypeerassets
pypeerassets/pautils.py
https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/pautils.py#L242-L259
def parse_card_transfer_metainfo(protobuf: bytes, deck_version: int) -> dict: '''decode card_spawn protobuf message and validate it against deck.version :protobuf - bytes from op_return message :deck_version - integer ''' card = CardTransferProto() card.ParseFromString(protobuf) if not car...
[ "def", "parse_card_transfer_metainfo", "(", "protobuf", ":", "bytes", ",", "deck_version", ":", "int", ")", "->", "dict", ":", "card", "=", "CardTransferProto", "(", ")", "card", ".", "ParseFromString", "(", "protobuf", ")", "if", "not", "card", ".", "versio...
decode card_spawn protobuf message and validate it against deck.version :protobuf - bytes from op_return message :deck_version - integer
[ "decode", "card_spawn", "protobuf", "message", "and", "validate", "it", "against", "deck", ".", "version", ":", "protobuf", "-", "bytes", "from", "op_return", "message", ":", "deck_version", "-", "integer" ]
python
train
34.444444
arviz-devs/arviz
arviz/data/io_emcee.py
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_emcee.py#L75-L85
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" data = {} for idx, var_name in enumerate(self.var_names): # Use emcee3 syntax, else use emcee2 data[var_name] = ( self.sampler.get_chain()[(..., idx)].T if has...
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "data", "=", "{", "}", "for", "idx", ",", "var_name", "in", "enumerate", "(", "self", ".", "var_names", ")", ":", "# Use emcee3 syntax, else use emcee2", "data", "[", "var_name", "]", "=", "(", "self", "...
Convert the posterior to an xarray dataset.
[ "Convert", "the", "posterior", "to", "an", "xarray", "dataset", "." ]
python
train
45.454545
suds-community/suds
suds/sax/element.py
https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/sax/element.py#L104-L114
def rename(self, name): """ Rename the element. @param name: A new name for the element. @type name: basestring """ if name is None: raise Exception("name (%s) not-valid" % (name,)) self.prefix, self.name = splitPrefix(name)
[ "def", "rename", "(", "self", ",", "name", ")", ":", "if", "name", "is", "None", ":", "raise", "Exception", "(", "\"name (%s) not-valid\"", "%", "(", "name", ",", ")", ")", "self", ".", "prefix", ",", "self", ".", "name", "=", "splitPrefix", "(", "na...
Rename the element. @param name: A new name for the element. @type name: basestring
[ "Rename", "the", "element", "." ]
python
train
25.818182
apple/turicreate
deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/generate.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/generate.py#L134-L141
def instantiate(self, value_of_n): """Instantiates the template""" template = Cheetah.Template.Template( self.content, searchList={'n': value_of_n} ) template.random_string = random_string return str(template)
[ "def", "instantiate", "(", "self", ",", "value_of_n", ")", ":", "template", "=", "Cheetah", ".", "Template", ".", "Template", "(", "self", ".", "content", ",", "searchList", "=", "{", "'n'", ":", "value_of_n", "}", ")", "template", ".", "random_string", ...
Instantiates the template
[ "Instantiates", "the", "template" ]
python
train
33.25
watson-developer-cloud/python-sdk
ibm_watson/natural_language_understanding_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/natural_language_understanding_v1.py#L2644-L2655
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'sentence') and self.sentence is not None: _dict['sentence'] = self.sentence if hasattr(self, 'subject') and self.subject is not None: _dict['subject'] = self.s...
[ "def", "_to_dict", "(", "self", ")", ":", "_dict", "=", "{", "}", "if", "hasattr", "(", "self", ",", "'sentence'", ")", "and", "self", ".", "sentence", "is", "not", "None", ":", "_dict", "[", "'sentence'", "]", "=", "self", ".", "sentence", "if", "...
Return a json dictionary representing this model.
[ "Return", "a", "json", "dictionary", "representing", "this", "model", "." ]
python
train
48.416667
awacha/credolib
credolib/qualitycontrol.py
https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/qualitycontrol.py#L184-L236
def assess_fitting_results(basename, cormap_alpha=0.01): """Assess the results of a fit based on the .fit and .fir files created by various programs from the ATSAS suite.""" plt.figure(figsize=(12, 4)) plt.subplot2grid((1, 4), (0, 0), colspan=2) fir = np.loadtxt(basename + '.fir', skiprows=1) # q, ...
[ "def", "assess_fitting_results", "(", "basename", ",", "cormap_alpha", "=", "0.01", ")", ":", "plt", ".", "figure", "(", "figsize", "=", "(", "12", ",", "4", ")", ")", "plt", ".", "subplot2grid", "(", "(", "1", ",", "4", ")", ",", "(", "0", ",", ...
Assess the results of a fit based on the .fit and .fir files created by various programs from the ATSAS suite.
[ "Assess", "the", "results", "of", "a", "fit", "based", "on", "the", ".", "fit", "and", ".", "fir", "files", "created", "by", "various", "programs", "from", "the", "ATSAS", "suite", "." ]
python
train
46.962264
RLBot/RLBot
src/main/python/rlbot/matchconfig/match_config.py
https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/matchconfig/match_config.py#L38-L50
def bot_config(player_config_path: Path, team: Team) -> 'PlayerConfig': """ A function to cover the common case of creating a config for a bot. """ bot_config = PlayerConfig() bot_config.bot = True bot_config.rlbot_controlled = True bot_config.team = team.value ...
[ "def", "bot_config", "(", "player_config_path", ":", "Path", ",", "team", ":", "Team", ")", "->", "'PlayerConfig'", ":", "bot_config", "=", "PlayerConfig", "(", ")", "bot_config", ".", "bot", "=", "True", "bot_config", ".", "rlbot_controlled", "=", "True", "...
A function to cover the common case of creating a config for a bot.
[ "A", "function", "to", "cover", "the", "common", "case", "of", "creating", "a", "config", "for", "a", "bot", "." ]
python
train
50.153846
glenfant/openxmllib
openxmllib/__init__.py
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/__init__.py#L27-L75
def openXmlDocument(path=None, file_=None, data=None, url=None, mime_type=None): """**Factory function** Will guess what document type is best suited and return the appropriate document type. User must provide either ``path``, ``file_``, ``data`` or ``url`` parameter. :param path: file path in the...
[ "def", "openXmlDocument", "(", "path", "=", "None", ",", "file_", "=", "None", ",", "data", "=", "None", ",", "url", "=", "None", ",", "mime_type", "=", "None", ")", ":", "if", "path", "is", "not", "None", ":", "file_", "=", "open", "(", "path", ...
**Factory function** Will guess what document type is best suited and return the appropriate document type. User must provide either ``path``, ``file_``, ``data`` or ``url`` parameter. :param path: file path in the local filesystem to a document. :param file_: a file (like) object to a document (m...
[ "**", "Factory", "function", "**" ]
python
train
39.673469
intel-analytics/BigDL
pyspark/bigdl/nn/keras/layer.py
https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/layer.py#L41-L48
def get_input_shape(self): """ Return a list of shape tuples if there are multiple inputs. Return one shape tuple otherwise. """ input = callBigDlFunc(self.bigdl_type, "getInputShape", self.value) return self.__process_shape(input)
[ "def", "get_input_shape", "(", "self", ")", ":", "input", "=", "callBigDlFunc", "(", "self", ".", "bigdl_type", ",", "\"getInputShape\"", ",", "self", ".", "value", ")", "return", "self", ".", "__process_shape", "(", "input", ")" ]
Return a list of shape tuples if there are multiple inputs. Return one shape tuple otherwise.
[ "Return", "a", "list", "of", "shape", "tuples", "if", "there", "are", "multiple", "inputs", ".", "Return", "one", "shape", "tuple", "otherwise", "." ]
python
test
37.75
nion-software/nionswift
nion/swift/model/NDataHandler.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/NDataHandler.py#L113-L129
def write_end_of_directory(fp, dir_size, dir_offset, count): """ Write zip file end of directory header at the current file position :param fp: the file point to which to write the header :param dir_size: the total size of the directory :param dir_offset: the start of the first dire...
[ "def", "write_end_of_directory", "(", "fp", ",", "dir_size", ",", "dir_offset", ",", "count", ")", ":", "fp", ".", "write", "(", "struct", ".", "pack", "(", "'I'", ",", "0x06054b50", ")", ")", "# central directory header", "fp", ".", "write", "(", "struct"...
Write zip file end of directory header at the current file position :param fp: the file point to which to write the header :param dir_size: the total size of the directory :param dir_offset: the start of the first directory header :param count: the count of files
[ "Write", "zip", "file", "end", "of", "directory", "header", "at", "the", "current", "file", "position" ]
python
train
50
10gen/mongo-orchestration
mongo_orchestration/apps/links.py
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/apps/links.py#L181-L193
def all_sharded_cluster_links(cluster_id, shard_id=None, router_id=None, rel_to=None): """Get a list of all links to be included with ShardedClusters.""" return [ sharded_cluster_link(rel, cluster_id, shard_id, router_id, self_rel=(rel == rel_to...
[ "def", "all_sharded_cluster_links", "(", "cluster_id", ",", "shard_id", "=", "None", ",", "router_id", "=", "None", ",", "rel_to", "=", "None", ")", ":", "return", "[", "sharded_cluster_link", "(", "rel", ",", "cluster_id", ",", "shard_id", ",", "router_id", ...
Get a list of all links to be included with ShardedClusters.
[ "Get", "a", "list", "of", "all", "links", "to", "be", "included", "with", "ShardedClusters", "." ]
python
train
44.076923
ereOn/azmq
azmq/common.py
https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/common.py#L260-L271
def on_open(self, callback, timeout): """ Initialize a new timeout. :param callback: The callback to execute when the timeout reaches the end of its life. May be a coroutine function. :param timeout: The maximum time to wait for, in seconds. """ super().on_o...
[ "def", "on_open", "(", "self", ",", "callback", ",", "timeout", ")", ":", "super", "(", ")", ".", "on_open", "(", ")", "self", ".", "callback", "=", "callback", "self", ".", "timeout", "=", "timeout", "self", ".", "revive_event", "=", "asyncio", ".", ...
Initialize a new timeout. :param callback: The callback to execute when the timeout reaches the end of its life. May be a coroutine function. :param timeout: The maximum time to wait for, in seconds.
[ "Initialize", "a", "new", "timeout", "." ]
python
train
36.333333
gem/oq-engine
openquake/commonlib/logictree.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1365-L1382
def check_imts(self, imts): """ Make sure the IMTs are recognized by all GSIMs in the logic tree """ for trt in self.values: for gsim in self.values[trt]: for attr in dir(gsim): coeffs = getattr(gsim, attr) if not isinst...
[ "def", "check_imts", "(", "self", ",", "imts", ")", ":", "for", "trt", "in", "self", ".", "values", ":", "for", "gsim", "in", "self", ".", "values", "[", "trt", "]", ":", "for", "attr", "in", "dir", "(", "gsim", ")", ":", "coeffs", "=", "getattr"...
Make sure the IMTs are recognized by all GSIMs in the logic tree
[ "Make", "sure", "the", "IMTs", "are", "recognized", "by", "all", "GSIMs", "in", "the", "logic", "tree" ]
python
train
42.777778
pypa/pipenv
pipenv/patched/pipfile/api.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/pipfile/api.py#L183-L219
def assert_requirements(self): """"Asserts PEP 508 specifiers.""" # Support for 508's implementation_version. if hasattr(sys, 'implementation'): implementation_version = format_full_version(sys.implementation.version) else: implementation_version = "0" #...
[ "def", "assert_requirements", "(", "self", ")", ":", "# Support for 508's implementation_version.", "if", "hasattr", "(", "sys", ",", "'implementation'", ")", ":", "implementation_version", "=", "format_full_version", "(", "sys", ".", "implementation", ".", "version", ...
Asserts PEP 508 specifiers.
[ "Asserts", "PEP", "508", "specifiers", "." ]
python
train
39.864865
fabioz/PyDev.Debugger
_pydev_imps/_pydev_inspect.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_inspect.py#L148-L153
def isroutine(object): """Return true if the object is any kind of function or method.""" return (isbuiltin(object) or isfunction(object) or ismethod(object) or ismethoddescriptor(object))
[ "def", "isroutine", "(", "object", ")", ":", "return", "(", "isbuiltin", "(", "object", ")", "or", "isfunction", "(", "object", ")", "or", "ismethod", "(", "object", ")", "or", "ismethoddescriptor", "(", "object", ")", ")" ]
Return true if the object is any kind of function or method.
[ "Return", "true", "if", "the", "object", "is", "any", "kind", "of", "function", "or", "method", "." ]
python
train
37.833333
manns/pyspread
pyspread/src/gui/_grid.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L788-L799
def OnCellBorderColor(self, event): """Cell border color event handler""" with undo.group(_("Border color")): self.grid.actions.set_border_attr("bordercolor", event.color, event.borders) self.grid.ForceRefresh() self.grid.updat...
[ "def", "OnCellBorderColor", "(", "self", ",", "event", ")", ":", "with", "undo", ".", "group", "(", "_", "(", "\"Border color\"", ")", ")", ":", "self", ".", "grid", ".", "actions", ".", "set_border_attr", "(", "\"bordercolor\"", ",", "event", ".", "colo...
Cell border color event handler
[ "Cell", "border", "color", "event", "handler" ]
python
train
29.333333
calmjs/calmjs
src/calmjs/base.py
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L702-L711
def dumps(self, blob): """ Call json.dumps with the attributes of this instance as arguments. """ return json.dumps( blob, indent=self.indent, sort_keys=True, separators=self.separators, )
[ "def", "dumps", "(", "self", ",", "blob", ")", ":", "return", "json", ".", "dumps", "(", "blob", ",", "indent", "=", "self", ".", "indent", ",", "sort_keys", "=", "True", ",", "separators", "=", "self", ".", "separators", ",", ")" ]
Call json.dumps with the attributes of this instance as arguments.
[ "Call", "json", ".", "dumps", "with", "the", "attributes", "of", "this", "instance", "as", "arguments", "." ]
python
train
25.2
calmh/unifi-api
unifi/controller.py
https://github.com/calmh/unifi-api/blob/5562d9c7689ef3d08c2d2390fb83d66f65d1086e/unifi/controller.py#L335-L359
def authorize_guest(self, guest_mac, minutes, up_bandwidth=None, down_bandwidth=None, byte_quota=None, ap_mac=None): """ Authorize a guest based on his MAC address. Arguments: guest_mac -- the guest MAC address : aa:bb:cc:dd:ee:ff minutes -- duration of the aut...
[ "def", "authorize_guest", "(", "self", ",", "guest_mac", ",", "minutes", ",", "up_bandwidth", "=", "None", ",", "down_bandwidth", "=", "None", ",", "byte_quota", "=", "None", ",", "ap_mac", "=", "None", ")", ":", "cmd", "=", "'authorize-guest'", "js", "=",...
Authorize a guest based on his MAC address. Arguments: guest_mac -- the guest MAC address : aa:bb:cc:dd:ee:ff minutes -- duration of the authorization in minutes up_bandwith -- up speed allowed in kbps (optional) down_bandwith -- down speed allowed in...
[ "Authorize", "a", "guest", "based", "on", "his", "MAC", "address", "." ]
python
train
40.56
twilio/twilio-python
twilio/rest/autopilot/v1/assistant/task/sample.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/autopilot/v1/assistant/task/sample.py#L481-L493
def update(self, language=values.unset, tagged_text=values.unset, source_channel=values.unset): """ Update the SampleInstance :param unicode language: The ISO language-country string that specifies the language used for the sample :param unicode tagged_text: The text exam...
[ "def", "update", "(", "self", ",", "language", "=", "values", ".", "unset", ",", "tagged_text", "=", "values", ".", "unset", ",", "source_channel", "=", "values", ".", "unset", ")", ":", "return", "self", ".", "_proxy", ".", "update", "(", "language", ...
Update the SampleInstance :param unicode language: The ISO language-country string that specifies the language used for the sample :param unicode tagged_text: The text example of how end users might express the task :param unicode source_channel: The communication channel from which the sample ...
[ "Update", "the", "SampleInstance" ]
python
train
53.384615
apache/spark
python/pyspark/mllib/linalg/__init__.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1277-L1289
def toArray(self): """ Return an numpy.ndarray """ A = np.zeros((self.numRows, self.numCols), dtype=np.float64, order='F') for k in xrange(self.colPtrs.size - 1): startptr = self.colPtrs[k] endptr = self.colPtrs[k + 1] if self.isTransposed: ...
[ "def", "toArray", "(", "self", ")", ":", "A", "=", "np", ".", "zeros", "(", "(", "self", ".", "numRows", ",", "self", ".", "numCols", ")", ",", "dtype", "=", "np", ".", "float64", ",", "order", "=", "'F'", ")", "for", "k", "in", "xrange", "(", ...
Return an numpy.ndarray
[ "Return", "an", "numpy", ".", "ndarray" ]
python
train
39.307692
pybel/pybel
src/pybel/struct/query/seeding.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/query/seeding.py#L44-L55
def append_annotation(self, annotation: str, values: Set[str]) -> 'Seeding': """Add a seed induction method for single annotation's values. :param annotation: The annotation to filter by :param values: The values of the annotation to keep :returns: self for fluid API """ ...
[ "def", "append_annotation", "(", "self", ",", "annotation", ":", "str", ",", "values", ":", "Set", "[", "str", "]", ")", "->", "'Seeding'", ":", "return", "self", ".", "_append_seed", "(", "SEED_TYPE_ANNOTATION", ",", "{", "'annotations'", ":", "{", "annot...
Add a seed induction method for single annotation's values. :param annotation: The annotation to filter by :param values: The values of the annotation to keep :returns: self for fluid API
[ "Add", "a", "seed", "induction", "method", "for", "single", "annotation", "s", "values", "." ]
python
train
37.333333
pnegahdar/inenv
inenv/inenv.py
https://github.com/pnegahdar/inenv/blob/8f484e520892bf9eb59f91b4b5c92df9fbd9a4e6/inenv/inenv.py#L164-L181
def install_deps(self, virtualenv, skip_cached=True, always_exit=False, exit_if_failed=True, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): """ :type virtualenv: VirtualEnv """ config = self.registered_venvs[virtualenv.venv_name] configed_deps = conf...
[ "def", "install_deps", "(", "self", ",", "virtualenv", ",", "skip_cached", "=", "True", ",", "always_exit", "=", "False", ",", "exit_if_failed", "=", "True", ",", "stdin", "=", "sys", ".", "stdin", ",", "stdout", "=", "sys", ".", "stdout", ",", "stderr",...
:type virtualenv: VirtualEnv
[ ":", "type", "virtualenv", ":", "VirtualEnv" ]
python
train
59.888889
theno/fabsetup
fabsetup/fabfile/setup/service/__init__.py
https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/service/__init__.py#L273-L291
def samba(): '''Install smb server samba and create a share (common read-write-access). More infos: * https://wiki.ubuntuusers.de/Samba%20Server/ ''' username = env.user install_packages(['samba']) run(flo('sudo smbpasswd -a {username}')) path = '$HOME/shared' sharename = 'shared'...
[ "def", "samba", "(", ")", ":", "username", "=", "env", ".", "user", "install_packages", "(", "[", "'samba'", "]", ")", "run", "(", "flo", "(", "'sudo smbpasswd -a {username}'", ")", ")", "path", "=", "'$HOME/shared'", "sharename", "=", "'shared'", "comment",...
Install smb server samba and create a share (common read-write-access). More infos: * https://wiki.ubuntuusers.de/Samba%20Server/
[ "Install", "smb", "server", "samba", "and", "create", "a", "share", "(", "common", "read", "-", "write", "-", "access", ")", "." ]
python
train
31.736842
ellmetha/django-machina
machina/apps/forum_permission/handler.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_permission/handler.py#L312-L458
def _get_forums_for_user(self, user, perm_codenames, use_tree_hierarchy=False): """ Returns all the forums that satisfy the given list of permission codenames. User and group forum permissions are used. If the ``use_tree_hierarchy`` keyword argument is set the granted forums will be filtered s...
[ "def", "_get_forums_for_user", "(", "self", ",", "user", ",", "perm_codenames", ",", "use_tree_hierarchy", "=", "False", ")", ":", "granted_forums_cache_key", "=", "'{}__{}'", ".", "format", "(", "':'", ".", "join", "(", "perm_codenames", ")", ",", "user", "."...
Returns all the forums that satisfy the given list of permission codenames. User and group forum permissions are used. If the ``use_tree_hierarchy`` keyword argument is set the granted forums will be filtered so that a forum which has an ancestor which is not in the granted forums set will not...
[ "Returns", "all", "the", "forums", "that", "satisfy", "the", "given", "list", "of", "permission", "codenames", "." ]
python
train
50.92517
saltstack/salt
salt/modules/pip.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pip.py#L964-L1086
def uninstall(pkgs=None, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, user=None, cwd=None, saltenv='base', use_vt=False): ''' Uninstall packages individually or f...
[ "def", "uninstall", "(", "pkgs", "=", "None", ",", "requirements", "=", "None", ",", "bin_env", "=", "None", ",", "log", "=", "None", ",", "proxy", "=", "None", ",", "timeout", "=", "None", ",", "user", "=", "None", ",", "cwd", "=", "None", ",", ...
Uninstall packages individually or from a pip requirements file pkgs comma separated list of packages to install requirements Path to requirements file bin_env Path to pip (or to a virtualenv). This can be used to specify the path to the pip to use when more than one Pytho...
[ "Uninstall", "packages", "individually", "or", "from", "a", "pip", "requirements", "file" ]
python
train
30.845528
gregmuellegger/django-superform
django_superform/forms.py
https://github.com/gregmuellegger/django-superform/blob/5f389911ad38932b6dad184cc7fa81f27db752f9/django_superform/forms.py#L277-L307
def save(self, commit=True): """ When saving a super model form, the nested forms and formsets will be saved as well. The implementation of ``.save()`` looks like this: .. code:: python saved_obj = self.save_form() self.save_forms() self.sav...
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "saved_obj", "=", "self", ".", "save_form", "(", "commit", "=", "commit", ")", "self", ".", "save_forms", "(", "commit", "=", "commit", ")", "self", ".", "save_formsets", "(", "commit", ...
When saving a super model form, the nested forms and formsets will be saved as well. The implementation of ``.save()`` looks like this: .. code:: python saved_obj = self.save_form() self.save_forms() self.save_formsets() return saved_obj ...
[ "When", "saving", "a", "super", "model", "form", "the", "nested", "forms", "and", "formsets", "will", "be", "saved", "as", "well", "." ]
python
train
37.354839
SpriteLink/NIPAP
pynipap/pynipap.py
https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/pynipap/pynipap.py#L430-L455
def list(cls, vrf=None): """ List VRFs. Maps to the function :py:func:`nipap.backend.Nipap.list_vrf` in the backend. Please see the documentation for the backend function for information regarding input arguments and return values. """ if vrf is None: ...
[ "def", "list", "(", "cls", ",", "vrf", "=", "None", ")", ":", "if", "vrf", "is", "None", ":", "vrf", "=", "{", "}", "xmlrpc", "=", "XMLRPCConnection", "(", ")", "try", ":", "vrf_list", "=", "xmlrpc", ".", "connection", ".", "list_vrf", "(", "{", ...
List VRFs. Maps to the function :py:func:`nipap.backend.Nipap.list_vrf` in the backend. Please see the documentation for the backend function for information regarding input arguments and return values.
[ "List", "VRFs", "." ]
python
train
28.192308
williamjameshandley/fgivenx
fgivenx/_utils.py
https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/_utils.py#L105-L147
def _equally_weight_samples(samples, weights): """ Convert samples to be equally weighted. Samples are trimmed by discarding samples in accordance with a probability determined by the corresponding weight. This function has assumed you have normalised the weights properly. If in doubt, convert wei...
[ "def", "_equally_weight_samples", "(", "samples", ",", "weights", ")", ":", "if", "len", "(", "weights", ")", "!=", "len", "(", "samples", ")", ":", "raise", "ValueError", "(", "\"len(weights) = %i != len(samples) = %i\"", "%", "(", "len", "(", "weights", ")",...
Convert samples to be equally weighted. Samples are trimmed by discarding samples in accordance with a probability determined by the corresponding weight. This function has assumed you have normalised the weights properly. If in doubt, convert weights via: `weights /= weights.max()` Parameters ...
[ "Convert", "samples", "to", "be", "equally", "weighted", "." ]
python
train
26.906977
AdvancedClimateSystems/uModbus
umodbus/functions.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/functions.py#L1028-L1038
def request_pdu(self): """ Build request PDU to write single coil. :return: Byte array of 5 bytes with PDU. """ if None in [self.address, self.value]: # TODO Raise proper exception. raise Exception return struct.pack('>BHH', self.function_code, self.addr...
[ "def", "request_pdu", "(", "self", ")", ":", "if", "None", "in", "[", "self", ".", "address", ",", "self", ".", "value", "]", ":", "# TODO Raise proper exception.", "raise", "Exception", "return", "struct", ".", "pack", "(", "'>BHH'", ",", "self", ".", "...
Build request PDU to write single coil. :return: Byte array of 5 bytes with PDU.
[ "Build", "request", "PDU", "to", "write", "single", "coil", "." ]
python
train
32.181818
cebel/pyuniprot
src/pyuniprot/manager/database.py
https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L473-L485
def get_alternative_full_names(cls, entry): """ get list of models.AlternativeFullName objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects """ names = [] query = "./protein/altern...
[ "def", "get_alternative_full_names", "(", "cls", ",", "entry", ")", ":", "names", "=", "[", "]", "query", "=", "\"./protein/alternativeName/fullName\"", "for", "name", "in", "entry", ".", "iterfind", "(", "query", ")", ":", "names", ".", "append", "(", "mode...
get list of models.AlternativeFullName objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects
[ "get", "list", "of", "models", ".", "AlternativeFullName", "objects", "from", "XML", "node", "entry" ]
python
train
35.461538
Fizzadar/pyinfra
pyinfra/modules/vzctl.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/modules/vzctl.py#L91-L110
def create(state, host, ctid, template=None): ''' Create OpenVZ containers. + ctid: CTID of the container to create ''' # Check we don't already have a container with this CTID current_containers = host.fact.openvz_containers if ctid in current_containers: raise OperationError( ...
[ "def", "create", "(", "state", ",", "host", ",", "ctid", ",", "template", "=", "None", ")", ":", "# Check we don't already have a container with this CTID", "current_containers", "=", "host", ".", "fact", ".", "openvz_containers", "if", "ctid", "in", "current_contai...
Create OpenVZ containers. + ctid: CTID of the container to create
[ "Create", "OpenVZ", "containers", "." ]
python
train
27.25
dwavesystems/dwave-system
dwave/embedding/transforms.py
https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/embedding/transforms.py#L346-L441
def unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method=None, chain_break_fraction=False): """Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: ...
[ "def", "unembed_sampleset", "(", "target_sampleset", ",", "embedding", ",", "source_bqm", ",", "chain_break_method", "=", "None", ",", "chain_break_fraction", "=", "False", ")", ":", "if", "chain_break_method", "is", "None", ":", "chain_break_method", "=", "majority...
Unembed the samples set. Construct a sample set for the source binary quadratic model (BQM) by unembedding the given samples from the target BQM. Args: target_sampleset (:obj:`dimod.SampleSet`): SampleSet from the target BQM. embedding (dict): Mapping from source g...
[ "Unembed", "the", "samples", "set", "." ]
python
train
39.6875
pywbem/pywbem
docs/conf.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/docs/conf.py#L597-L620
def _get_def_class(self, class_obj, member_name): """ Return the class object in MRO order that defines a member. class_obj: Class object that exposes (but not necessarily defines) the member. I.e. starting point of the search. member_name: Name of the member (method or attri...
[ "def", "_get_def_class", "(", "self", ",", "class_obj", ",", "member_name", ")", ":", "member_obj", "=", "getattr", "(", "class_obj", ",", "member_name", ")", "for", "def_class_obj", "in", "inspect", ".", "getmro", "(", "class_obj", ")", ":", "if", "member_n...
Return the class object in MRO order that defines a member. class_obj: Class object that exposes (but not necessarily defines) the member. I.e. starting point of the search. member_name: Name of the member (method or attribute). Returns: Class object that defines the membe...
[ "Return", "the", "class", "object", "in", "MRO", "order", "that", "defines", "a", "member", "." ]
python
train
40.291667
edx/edx-enterprise
enterprise/tpa_pipeline.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/tpa_pipeline.py#L24-L31
def get_enterprise_customer_for_running_pipeline(request, pipeline): # pylint: disable=invalid-name """ Get the EnterpriseCustomer associated with a running pipeline. """ sso_provider_id = request.GET.get('tpa_hint') if pipeline: sso_provider_id = Registry.get_from_pipeline(pipeline).provid...
[ "def", "get_enterprise_customer_for_running_pipeline", "(", "request", ",", "pipeline", ")", ":", "# pylint: disable=invalid-name", "sso_provider_id", "=", "request", ".", "GET", ".", "get", "(", "'tpa_hint'", ")", "if", "pipeline", ":", "sso_provider_id", "=", "Regis...
Get the EnterpriseCustomer associated with a running pipeline.
[ "Get", "the", "EnterpriseCustomer", "associated", "with", "a", "running", "pipeline", "." ]
python
valid
47.25
nickoala/telepot
telepot/delegate.py
https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/delegate.py#L92-L107
def per_from_id_except(s, flavors=chat_flavors+inline_flavors): """ :param s: a list or set of from id :param flavors: ``all`` or a list of flavors :return: a seeder function that returns the from id only if the from id is *not* in ``s`` and message flavor is in ``flavo...
[ "def", "per_from_id_except", "(", "s", ",", "flavors", "=", "chat_flavors", "+", "inline_flavors", ")", ":", "return", "_wrap_none", "(", "lambda", "msg", ":", "msg", "[", "'from'", "]", "[", "'id'", "]", "if", "(", "flavors", "==", "'all'", "or", "flavo...
:param s: a list or set of from id :param flavors: ``all`` or a list of flavors :return: a seeder function that returns the from id only if the from id is *not* in ``s`` and message flavor is in ``flavors``.
[ ":", "param", "s", ":", "a", "list", "or", "set", "of", "from", "id" ]
python
train
33.625
brantai/python-rightscale
rightscale/commands.py
https://github.com/brantai/python-rightscale/blob/5fbf4089922917247be712d58645a7b1504f0944/rightscale/commands.py#L116-L144
def get_by_path(path, first=False): """ Search for resources using colon-separated path notation. E.g.:: path = 'deployments:production:servers:haproxy' haproxies = get_by_path(path) :param bool first: Always use the first returned match for all intermediate searches along the...
[ "def", "get_by_path", "(", "path", ",", "first", "=", "False", ")", ":", "api", "=", "get_api", "(", ")", "cur_res", "=", "api", "parts", "=", "path", ".", "split", "(", "':'", ")", "for", "part", "in", "parts", ":", "res", "=", "getattr", "(", "...
Search for resources using colon-separated path notation. E.g.:: path = 'deployments:production:servers:haproxy' haproxies = get_by_path(path) :param bool first: Always use the first returned match for all intermediate searches along the path. If this is ``False`` and an intermediate...
[ "Search", "for", "resources", "using", "colon", "-", "separated", "path", "notation", "." ]
python
train
27.034483