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
smarie/python-parsyfiles
parsyfiles/parsing_registries.py
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_registries.py#L835-L862
def create(att_name: str, parsed_att: S, attribute_type: Type[T], caught_exec: Dict[Converter[S, T], Exception]): """ Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests https://github.com/nose-devs/nose/issues/725 :param att_name...
[ "def", "create", "(", "att_name", ":", "str", ",", "parsed_att", ":", "S", ",", "attribute_type", ":", "Type", "[", "T", "]", ",", "caught_exec", ":", "Dict", "[", "Converter", "[", "S", ",", "T", "]", ",", "Exception", "]", ")", ":", "base_msg", "...
Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests https://github.com/nose-devs/nose/issues/725 :param att_name: :param parsed_att: :param attribute_type: :param caught_exec: :return:
[ "Helper", "method", "provided", "because", "we", "actually", "can", "t", "put", "that", "in", "the", "constructor", "it", "creates", "a", "bug", "in", "Nose", "tests", "https", ":", "//", "github", ".", "com", "/", "nose", "-", "devs", "/", "nose", "/"...
python
train
48.214286
DataDog/integrations-core
openstack/datadog_checks/openstack/openstack.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack/datadog_checks/openstack/openstack.py#L1374-L1383
def get_my_hostname(self, split_hostname_on_first_period=False): """ Returns a best guess for the hostname registered with OpenStack for this host """ hostname = self.init_config.get("os_host") or self.hostname if split_hostname_on_first_period: hostname = hostname.s...
[ "def", "get_my_hostname", "(", "self", ",", "split_hostname_on_first_period", "=", "False", ")", ":", "hostname", "=", "self", ".", "init_config", ".", "get", "(", "\"os_host\"", ")", "or", "self", ".", "hostname", "if", "split_hostname_on_first_period", ":", "h...
Returns a best guess for the hostname registered with OpenStack for this host
[ "Returns", "a", "best", "guess", "for", "the", "hostname", "registered", "with", "OpenStack", "for", "this", "host" ]
python
train
34.8
Hackerfleet/hfos
hfos/ui/configurator.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L152-L176
def get(self, event): """Get a stored configuration""" try: comp = event.data['uuid'] except KeyError: comp = None if not comp: self.log('Invalid get request without schema or component', lvl=error) return se...
[ "def", "get", "(", "self", ",", "event", ")", ":", "try", ":", "comp", "=", "event", ".", "data", "[", "'uuid'", "]", "except", "KeyError", ":", "comp", "=", "None", "if", "not", "comp", ":", "self", ".", "log", "(", "'Invalid get request without schem...
Get a stored configuration
[ "Get", "a", "stored", "configuration" ]
python
train
27.68
eyurtsev/FlowCytometryTools
FlowCytometryTools/core/graph.py
https://github.com/eyurtsev/FlowCytometryTools/blob/4355632508b875273d68c7e2972c17668bcf7b40/FlowCytometryTools/core/graph.py#L23-L101
def plotFCM(data, channel_names, kind='histogram', ax=None, autolabel=True, xlabel_kwargs={}, ylabel_kwargs={}, colorbar=False, grid=False, **kwargs): """ Plots the sample on the current axis. Follow with a call to matplotlibs show() in order to see the plot. Parame...
[ "def", "plotFCM", "(", "data", ",", "channel_names", ",", "kind", "=", "'histogram'", ",", "ax", "=", "None", ",", "autolabel", "=", "True", ",", "xlabel_kwargs", "=", "{", "}", ",", "ylabel_kwargs", "=", "{", "}", ",", "colorbar", "=", "False", ",", ...
Plots the sample on the current axis. Follow with a call to matplotlibs show() in order to see the plot. Parameters ---------- data : DataFrame {graph_plotFCM_pars} {common_plot_ax} Returns ------- The output of the plot command used
[ "Plots", "the", "sample", "on", "the", "current", "axis", "." ]
python
train
33.987342
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/extensions/sympyprinting.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/extensions/sympyprinting.py#L54-L64
def print_png(o): """ A function to display sympy expression using inline style LaTeX in PNG. """ s = latex(o, mode='inline') # mathtext does not understand certain latex flags, so we try to replace # them with suitable subs. s = s.replace('\\operatorname','') s = s.replace('\\overline',...
[ "def", "print_png", "(", "o", ")", ":", "s", "=", "latex", "(", "o", ",", "mode", "=", "'inline'", ")", "# mathtext does not understand certain latex flags, so we try to replace", "# them with suitable subs.", "s", "=", "s", ".", "replace", "(", "'\\\\operatorname'", ...
A function to display sympy expression using inline style LaTeX in PNG.
[ "A", "function", "to", "display", "sympy", "expression", "using", "inline", "style", "LaTeX", "in", "PNG", "." ]
python
test
32.727273
zkbt/the-friendly-stars
thefriendlystars/constellations/gaia.py
https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/constellations/gaia.py#L85-L121
def from_sky(cls, distancelimit=15, magnitudelimit=18): ''' Create a Constellation from a criteria search of the whole sky. Parameters ---------- distancelimit : float Maximum distance (parsecs). magnitudelimit : float Maximum magnitude (for Gaia ...
[ "def", "from_sky", "(", "cls", ",", "distancelimit", "=", "15", ",", "magnitudelimit", "=", "18", ")", ":", "# define a query for cone search surrounding this center", "criteria", "=", "[", "]", "if", "distancelimit", "is", "not", "None", ":", "criteria", ".", "...
Create a Constellation from a criteria search of the whole sky. Parameters ---------- distancelimit : float Maximum distance (parsecs). magnitudelimit : float Maximum magnitude (for Gaia G).
[ "Create", "a", "Constellation", "from", "a", "criteria", "search", "of", "the", "whole", "sky", "." ]
python
train
34.783784
numenta/htmresearch
projects/sdr_paper/pytorch_experiments/analyze_experiment.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/sdr_paper/pytorch_experiments/analyze_experiment.py#L31-L62
def analyzeParameters(expName, suite): """ Analyze the impact of each list parameter in this experiment """ print("\n================",expName,"=====================") try: expParams = suite.get_params(expName) pprint.pprint(expParams) for p in ["boost_strength", "k", "learning_rate", "weight_spa...
[ "def", "analyzeParameters", "(", "expName", ",", "suite", ")", ":", "print", "(", "\"\\n================\"", ",", "expName", ",", "\"=====================\"", ")", "try", ":", "expParams", "=", "suite", ".", "get_params", "(", "expName", ")", "pprint", ".", "p...
Analyze the impact of each list parameter in this experiment
[ "Analyze", "the", "impact", "of", "each", "list", "parameter", "in", "this", "experiment" ]
python
train
37.125
Locu/chronology
kronos/kronos/utils/uuid.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/kronos/kronos/utils/uuid.py#L14-L20
def uuid_from_kronos_time(time, _type=UUIDType.RANDOM): """ Generate a UUID with the specified time. If `lowest` is true, return the lexicographically first UUID for the specified time. """ return timeuuid_from_time(int(time) + UUID_TIME_OFFSET, type=_type)
[ "def", "uuid_from_kronos_time", "(", "time", ",", "_type", "=", "UUIDType", ".", "RANDOM", ")", ":", "return", "timeuuid_from_time", "(", "int", "(", "time", ")", "+", "UUID_TIME_OFFSET", ",", "type", "=", "_type", ")" ]
Generate a UUID with the specified time. If `lowest` is true, return the lexicographically first UUID for the specified time.
[ "Generate", "a", "UUID", "with", "the", "specified", "time", ".", "If", "lowest", "is", "true", "return", "the", "lexicographically", "first", "UUID", "for", "the", "specified", "time", "." ]
python
train
37.571429
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_firmware_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_firmware_ext.py#L211-L225
def show_firmware_version_output_show_firmware_version_node_info_firmware_version_info_application_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") show_firmware_version = ET.Element("show_firmware_version") config = show_firmware_version out...
[ "def", "show_firmware_version_output_show_firmware_version_node_info_firmware_version_info_application_name", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "show_firmware_version", "=", "ET", ".", "Element", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
55.133333
themartorana/python-postmark
postmark/core.py
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L472-L552
def send(self, test=None): ''' Send the email through the Postmark system. Pass test=True to just print out the resulting JSON message being sent to Postmark ''' self._check_values() # Set up message dictionary json_message = self.to_json_message() ...
[ "def", "send", "(", "self", ",", "test", "=", "None", ")", ":", "self", ".", "_check_values", "(", ")", "# Set up message dictionary", "json_message", "=", "self", ".", "to_json_message", "(", ")", "# if (self.__html_body and not self.__text_body) and self.__multipart:"...
Send the email through the Postmark system. Pass test=True to just print out the resulting JSON message being sent to Postmark
[ "Send", "the", "email", "through", "the", "Postmark", "system", ".", "Pass", "test", "=", "True", "to", "just", "print", "out", "the", "resulting", "JSON", "message", "being", "sent", "to", "Postmark" ]
python
train
42.506173
saltstack/salt
salt/spm/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/spm/__init__.py#L995-L1013
def _list_files(self, args): ''' List files for an installed package ''' if len(args) < 2: raise SPMInvocationError('A package name must be specified') package = args[-1] files = self._pkgdb_fun('list_files', package, self.db_conn) if files is None: ...
[ "def", "_list_files", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "2", ":", "raise", "SPMInvocationError", "(", "'A package name must be specified'", ")", "package", "=", "args", "[", "-", "1", "]", "files", "=", "self", ".", ...
List files for an installed package
[ "List", "files", "for", "an", "installed", "package" ]
python
train
32.789474
stitchfix/pyxley
pyxley/charts/mg/line_chart.py
https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/line_chart.py#L58-L67
def to_json(df, x, y, timeseries=False): """Format output for json response.""" values = {k: [] for k in y} for i, row in df.iterrows(): for yy in y: values[yy].append({ "x": row[x], "y": row[yy] }) r...
[ "def", "to_json", "(", "df", ",", "x", ",", "y", ",", "timeseries", "=", "False", ")", ":", "values", "=", "{", "k", ":", "[", "]", "for", "k", "in", "y", "}", "for", "i", ",", "row", "in", "df", ".", "iterrows", "(", ")", ":", "for", "yy",...
Format output for json response.
[ "Format", "output", "for", "json", "response", "." ]
python
train
37.2
libtcod/python-tcod
tcod/libtcodpy.py
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L2775-L2791
def heightmap_get_normal( hm: np.ndarray, x: float, y: float, waterLevel: float ) -> Tuple[float, float, float]: """Return the map normal at given coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): The x coordinate. y (float): The y ...
[ "def", "heightmap_get_normal", "(", "hm", ":", "np", ".", "ndarray", ",", "x", ":", "float", ",", "y", ":", "float", ",", "waterLevel", ":", "float", ")", "->", "Tuple", "[", "float", ",", "float", ",", "float", "]", ":", "cn", "=", "ffi", ".", "...
Return the map normal at given coordinates. Args: hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions. x (float): The x coordinate. y (float): The y coordinate. waterLevel (float): The heightmap is considered flat below this value. Returns: Tuple[float...
[ "Return", "the", "map", "normal", "at", "given", "coordinates", "." ]
python
train
35.764706
a1ezzz/wasp-general
wasp_general/crypto/aes.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/aes.py#L491-L498
def cipher(self): """ Generate AES-cipher :return: Crypto.Cipher.AES.AESCipher """ #cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs()) cipher = Cipher(*self.mode().aes_args(), **self.mode().aes_kwargs()) return WAES.WAESCipher(cipher)
[ "def", "cipher", "(", "self", ")", ":", "#cipher = pyAES.new(*self.mode().aes_args(), **self.mode().aes_kwargs())", "cipher", "=", "Cipher", "(", "*", "self", ".", "mode", "(", ")", ".", "aes_args", "(", ")", ",", "*", "*", "self", ".", "mode", "(", ")", "."...
Generate AES-cipher :return: Crypto.Cipher.AES.AESCipher
[ "Generate", "AES", "-", "cipher" ]
python
train
32.625
hyperledger/indy-sdk
vcx/wrappers/python3/vcx/api/utils.py
https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/vcx/wrappers/python3/vcx/api/utils.py#L6-L37
async def vcx_agent_provision(config: str) -> None: """ Provision an agent in the agency, populate configuration and wallet for this agent. Example: import json enterprise_config = { 'agency_url': 'http://localhost:8080', 'agency_did': 'VsKV7grR1BUE29mG2Fm2kX', 'agency_verkey...
[ "async", "def", "vcx_agent_provision", "(", "config", ":", "str", ")", "->", "None", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "if", "not", "hasattr", "(", "vcx_agent_provision", ",", "\"cb\"", ")", ":", "logger", ".", "debug",...
Provision an agent in the agency, populate configuration and wallet for this agent. Example: import json enterprise_config = { 'agency_url': 'http://localhost:8080', 'agency_did': 'VsKV7grR1BUE29mG2Fm2kX', 'agency_verkey': "Hezce2UWMZ3wUhVkh2LfKSs8nDzWwzs2Win7EzNN3YaR", 'wall...
[ "Provision", "an", "agent", "in", "the", "agency", "populate", "configuration", "and", "wallet", "for", "this", "agent", ".", "Example", ":", "import", "json", "enterprise_config", "=", "{", "agency_url", ":", "http", ":", "//", "localhost", ":", "8080", "ag...
python
train
38.09375
crs4/pydoop
pydoop/hdfs/path.py
https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/hdfs/path.py#L304-L312
def exists(hdfs_path, user=None): """ Return :obj:`True` if ``hdfs_path`` exists in the default HDFS. """ hostname, port, path = split(hdfs_path, user=user) fs = hdfs_fs.hdfs(hostname, port) retval = fs.exists(path) fs.close() return retval
[ "def", "exists", "(", "hdfs_path", ",", "user", "=", "None", ")", ":", "hostname", ",", "port", ",", "path", "=", "split", "(", "hdfs_path", ",", "user", "=", "user", ")", "fs", "=", "hdfs_fs", ".", "hdfs", "(", "hostname", ",", "port", ")", "retva...
Return :obj:`True` if ``hdfs_path`` exists in the default HDFS.
[ "Return", ":", "obj", ":", "True", "if", "hdfs_path", "exists", "in", "the", "default", "HDFS", "." ]
python
train
29.333333
5j9/wikitextparser
wikitextparser/_wikitext.py
https://github.com/5j9/wikitextparser/blob/1347425814361d7955342c53212edbb27f0ff4b5/wikitextparser/_wikitext.py#L696-L702
def parser_functions(self) -> List['ParserFunction']: """Return a list of parser function objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ ParserFunction(_lststr, _type_to_spans, span, 'ParserFunction') for span in self._subspans('P...
[ "def", "parser_functions", "(", "self", ")", "->", "List", "[", "'ParserFunction'", "]", ":", "_lststr", "=", "self", ".", "_lststr", "_type_to_spans", "=", "self", ".", "_type_to_spans", "return", "[", "ParserFunction", "(", "_lststr", ",", "_type_to_spans", ...
Return a list of parser function objects.
[ "Return", "a", "list", "of", "parser", "function", "objects", "." ]
python
test
47.142857
ucbvislab/radiotool
radiotool/composer/track.py
https://github.com/ucbvislab/radiotool/blob/01c9d878a811cf400b1482896d641d9c95e83ded/radiotool/composer/track.py#L165-L182
def loudest_time(self, start=0, duration=0): """Find the loudest time in the window given by start and duration Returns frame number in context of entire track, not just the window. :param integer start: Start frame :param integer duration: Number of frames to consider from start ...
[ "def", "loudest_time", "(", "self", ",", "start", "=", "0", ",", "duration", "=", "0", ")", ":", "if", "duration", "==", "0", ":", "duration", "=", "self", ".", "sound", ".", "nframes", "self", ".", "current_frame", "=", "start", "arr", "=", "self", ...
Find the loudest time in the window given by start and duration Returns frame number in context of entire track, not just the window. :param integer start: Start frame :param integer duration: Number of frames to consider from start :returns: Frame number of loudest frame :rtype...
[ "Find", "the", "loudest", "time", "in", "the", "window", "given", "by", "start", "and", "duration", "Returns", "frame", "number", "in", "context", "of", "entire", "track", "not", "just", "the", "window", "." ]
python
train
43.444444
clalancette/pycdlib
pycdlib/rockridge.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L421-L476
def parse(self, rrstr): # type: (bytes) -> int ''' Parse a Rock Ridge POSIX File Attributes record out of a string. Parameters: rrstr - The string to parse the record out of. Returns: A string representing the RR version, either 1.09 or 1.12. ''' ...
[ "def", "parse", "(", "self", ",", "rrstr", ")", ":", "# type: (bytes) -> int", "if", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'PX record already initialized!'", ")", "(", "su_len", ",", "su_entry_version_unused"...
Parse a Rock Ridge POSIX File Attributes record out of a string. Parameters: rrstr - The string to parse the record out of. Returns: A string representing the RR version, either 1.09 or 1.12.
[ "Parse", "a", "Rock", "Ridge", "POSIX", "File", "Attributes", "record", "out", "of", "a", "string", "." ]
python
train
47.553571
jeffh/sniffer
sniffer/scanner/base.py
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L179-L192
def observe(self, event_name, func): """ event_name := {'created', 'modified', 'deleted'}, list, tuple Attaches a function to run to a particular event. The function must be unique to be removed cleanly. Alternatively, event_name can be an list/ tuple if any of the string possib...
[ "def", "observe", "(", "self", ",", "event_name", ",", "func", ")", ":", "if", "isinstance", "(", "event_name", ",", "list", ")", "or", "isinstance", "(", "event_name", ",", "tuple", ")", ":", "for", "name", "in", "event_name", ":", "self", ".", "obser...
event_name := {'created', 'modified', 'deleted'}, list, tuple Attaches a function to run to a particular event. The function must be unique to be removed cleanly. Alternatively, event_name can be an list/ tuple if any of the string possibilities to be added on multiple events
[ "event_name", ":", "=", "{", "created", "modified", "deleted", "}", "list", "tuple" ]
python
train
45.785714
redcap-tools/PyCap
redcap/project.py
https://github.com/redcap-tools/PyCap/blob/f44c9b62a4f62675aa609c06608663f37e12097e/redcap/project.py#L114-L123
def is_longitudinal(self): """ Returns ------- boolean : longitudinal status of this project """ return len(self.events) > 0 and \ len(self.arm_nums) > 0 and \ len(self.arm_names) > 0
[ "def", "is_longitudinal", "(", "self", ")", ":", "return", "len", "(", "self", ".", "events", ")", ">", "0", "and", "len", "(", "self", ".", "arm_nums", ")", ">", "0", "and", "len", "(", "self", ".", "arm_names", ")", ">", "0" ]
Returns ------- boolean : longitudinal status of this project
[ "Returns", "-------", "boolean", ":", "longitudinal", "status", "of", "this", "project" ]
python
train
25.8
MartinThoma/hwrt
hwrt/features.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/features.py#L34-L61
def get_features(model_description_features): """Get features from a list of dictionaries Parameters ---------- model_description_features : list of dictionaries Examples -------- >>> l = [{'StrokeCount': None}, \ {'ConstantPointCoordinates': \ [{'strokes': 4}, \...
[ "def", "get_features", "(", "model_description_features", ")", ":", "return", "utils", ".", "get_objectlist", "(", "model_description_features", ",", "config_key", "=", "'features'", ",", "module", "=", "sys", ".", "modules", "[", "__name__", "]", ")" ]
Get features from a list of dictionaries Parameters ---------- model_description_features : list of dictionaries Examples -------- >>> l = [{'StrokeCount': None}, \ {'ConstantPointCoordinates': \ [{'strokes': 4}, \ {'points_per_stroke': 81}, \ ...
[ "Get", "features", "from", "a", "list", "of", "dictionaries" ]
python
train
28.892857
dropbox/pyannotate
pyannotate_runtime/collect_types.py
https://github.com/dropbox/pyannotate/blob/d128c76b8a86f208e5c78716f2a917003650cebc/pyannotate_runtime/collect_types.py#L711-L727
def _make_sampling_sequence(n): # type: (int) -> List[int] """ Return a list containing the proposed call event sampling sequence. Return events are paired with call events and not counted separately. This is 0, 1, 2, ..., 4 plus 50, 100, 150, 200, etc. The total list size is n. """ s...
[ "def", "_make_sampling_sequence", "(", "n", ")", ":", "# type: (int) -> List[int]", "seq", "=", "list", "(", "range", "(", "5", ")", ")", "i", "=", "50", "while", "len", "(", "seq", ")", "<", "n", ":", "seq", ".", "append", "(", "i", ")", "i", "+="...
Return a list containing the proposed call event sampling sequence. Return events are paired with call events and not counted separately. This is 0, 1, 2, ..., 4 plus 50, 100, 150, 200, etc. The total list size is n.
[ "Return", "a", "list", "containing", "the", "proposed", "call", "event", "sampling", "sequence", "." ]
python
train
24.176471
casouri/launchdman
launchdman/__init__.py
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L894-L898
def minute(self): '''set unit to minute''' self.magnification = 60 self._update(self.baseNumber, self.magnification) return self
[ "def", "minute", "(", "self", ")", ":", "self", ".", "magnification", "=", "60", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to minute
[ "set", "unit", "to", "minute" ]
python
train
31.2
ultrabug/py3status
py3status/i3status.py
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/i3status.py#L131-L140
def run(self): """ updates the modules output. Currently only time and tztime need to do this """ if self.update_time_value(): self.i3status.py3_wrapper.notify_update(self.module_name) due_time = self.py3.time_in(sync_to=self.time_delta) self.i3status...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "update_time_value", "(", ")", ":", "self", ".", "i3status", ".", "py3_wrapper", ".", "notify_update", "(", "self", ".", "module_name", ")", "due_time", "=", "self", ".", "py3", ".", "time_in", "(...
updates the modules output. Currently only time and tztime need to do this
[ "updates", "the", "modules", "output", ".", "Currently", "only", "time", "and", "tztime", "need", "to", "do", "this" ]
python
train
35.7
flatangle/flatlib
flatlib/lists.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/lists.py#L63-L66
def getObjectsInHouse(self, house): """ Returns a list with all objects in a house. """ res = [obj for obj in self if house.hasObject(obj)] return ObjectList(res)
[ "def", "getObjectsInHouse", "(", "self", ",", "house", ")", ":", "res", "=", "[", "obj", "for", "obj", "in", "self", "if", "house", ".", "hasObject", "(", "obj", ")", "]", "return", "ObjectList", "(", "res", ")" ]
Returns a list with all objects in a house.
[ "Returns", "a", "list", "with", "all", "objects", "in", "a", "house", "." ]
python
train
45.75
simpleai-team/simpleai
samples/search/missioners.py
https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/samples/search/missioners.py#L36-L43
def result(self, s, a): '''Result of applying an action to a state.''' # result: boat on opposite side, and numbers of missioners and # cannibals updated according to the move if s[2] == 0: return (s[0] - a[1][0], s[1] - a[1][1], 1) else: return (s[0] + a[...
[ "def", "result", "(", "self", ",", "s", ",", "a", ")", ":", "# result: boat on opposite side, and numbers of missioners and", "# cannibals updated according to the move", "if", "s", "[", "2", "]", "==", "0", ":", "return", "(", "s", "[", "0", "]", "-", "a", "[...
Result of applying an action to a state.
[ "Result", "of", "applying", "an", "action", "to", "a", "state", "." ]
python
train
42.25
CEA-COSMIC/ModOpt
modopt/opt/linear.py
https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/opt/linear.py#L186-L233
def _check_inputs(self, operators, weights): """ Check Inputs This method cheks that the input operators and weights are correctly formatted Parameters ---------- operators : list, tuple or np.ndarray List of linear operator class instances weights :...
[ "def", "_check_inputs", "(", "self", ",", "operators", ",", "weights", ")", ":", "operators", "=", "self", ".", "_check_type", "(", "operators", ")", "for", "operator", "in", "operators", ":", "if", "not", "hasattr", "(", "operator", ",", "'op'", ")", ":...
Check Inputs This method cheks that the input operators and weights are correctly formatted Parameters ---------- operators : list, tuple or np.ndarray List of linear operator class instances weights : list, tuple or np.ndarray List of weights fo...
[ "Check", "Inputs" ]
python
train
32.375
neurodata/ndio
ndio/remote/neurodata.py
https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/remote/neurodata.py#L549-L600
def create_dataset(self, name, x_img_size, y_img_size, z_img_size, x_vox_res, y_vox_res, z_vox_res, x_offset=0, y...
[ "def", "create_dataset", "(", "self", ",", "name", ",", "x_img_size", ",", "y_img_size", ",", "z_img_size", ",", "x_vox_res", ",", "y_vox_res", ",", "z_vox_res", ",", "x_offset", "=", "0", ",", "y_offset", "=", "0", ",", "z_offset", "=", "0", ",", "scali...
Creates a dataset. Arguments: name (str): Name of dataset x_img_size (int): max x coordinate of image size y_img_size (int): max y coordinate of image size z_img_size (int): max z coordinate of image size x_vox_res (float): x voxel resolution ...
[ "Creates", "a", "dataset", "." ]
python
test
42.942308
estnltk/estnltk
estnltk/prettyprinter/marker.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/marker.py#L100-L132
def create_tags_with_concatenated_css_classes(tags): """Function that creates <mark> tags such that they are not overlapping. In order to do this, it concatenates the css classes and stores the concatenated result in new tags. """ current_classes = set() result = [] for pos, group in group_t...
[ "def", "create_tags_with_concatenated_css_classes", "(", "tags", ")", ":", "current_classes", "=", "set", "(", ")", "result", "=", "[", "]", "for", "pos", ",", "group", "in", "group_tags_at_same_position", "(", "tags", ")", ":", "opening", ",", "closing", "=",...
Function that creates <mark> tags such that they are not overlapping. In order to do this, it concatenates the css classes and stores the concatenated result in new tags.
[ "Function", "that", "creates", "<mark", ">", "tags", "such", "that", "they", "are", "not", "overlapping", ".", "In", "order", "to", "do", "this", "it", "concatenates", "the", "css", "classes", "and", "stores", "the", "concatenated", "result", "in", "new", ...
python
train
43.484848
hyperledger/sawtooth-core
rest_api/sawtooth_rest_api/route_handlers.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L351-L375
async def fetch_block(self, request): """Fetches a specific block from the validator, specified by id. Request: path: - block_id: The 128-character id of the block to be fetched Response: data: A JSON object with the data from the fully expanded Block ...
[ "async", "def", "fetch_block", "(", "self", ",", "request", ")", ":", "error_traps", "=", "[", "error_handlers", ".", "BlockNotFoundTrap", "]", "block_id", "=", "request", ".", "match_info", ".", "get", "(", "'block_id'", ",", "''", ")", "self", ".", "_val...
Fetches a specific block from the validator, specified by id. Request: path: - block_id: The 128-character id of the block to be fetched Response: data: A JSON object with the data from the fully expanded Block link: The link to this exact query
[ "Fetches", "a", "specific", "block", "from", "the", "validator", "specified", "by", "id", ".", "Request", ":", "path", ":", "-", "block_id", ":", "The", "128", "-", "character", "id", "of", "the", "block", "to", "be", "fetched" ]
python
train
37.24
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_nsh.py#L50-L68
def send(self, line): '''send some bytes''' line = line.strip() if line == ".": self.stop() return mav = self.master.mav if line != '+++': line += "\r\n" buf = [ord(x) for x in line] buf.extend([0]*(70-len(buf))) flags ...
[ "def", "send", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "\".\"", ":", "self", ".", "stop", "(", ")", "return", "mav", "=", "self", ".", "master", ".", "mav", "if", "line", "!=", "'+++'...
send some bytes
[ "send", "some", "bytes" ]
python
train
35.842105
saltstack/salt
salt/utils/sanitizers.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/sanitizers.py#L44-L51
def filename(value): ''' Remove everything that would affect paths in the filename :param value: :return: ''' return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))
[ "def", "filename", "(", "value", ")", ":", "return", "re", ".", "sub", "(", "'[^a-zA-Z0-9.-_ ]'", ",", "''", ",", "os", ".", "path", ".", "basename", "(", "InputSanitizer", ".", "trim", "(", "value", ")", ")", ")" ]
Remove everything that would affect paths in the filename :param value: :return:
[ "Remove", "everything", "that", "would", "affect", "paths", "in", "the", "filename" ]
python
train
29.375
tradenity/python-sdk
tradenity/resources/table_rate_shipping.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/table_rate_shipping.py#L561-L581
def delete_table_rate_shipping_by_id(cls, table_rate_shipping_id, **kwargs): """Delete TableRateShipping Delete an instance of TableRateShipping by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> t...
[ "def", "delete_table_rate_shipping_by_id", "(", "cls", ",", "table_rate_shipping_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", ...
Delete TableRateShipping Delete an instance of TableRateShipping by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_table_rate_shipping_by_id(table_rate_shipping_id, async=True) ...
[ "Delete", "TableRateShipping" ]
python
train
47.52381
pallets/werkzeug
src/werkzeug/datastructures.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2333-L2341
def to_header(self): """Converts the object back into an HTTP header.""" ranges = [] for begin, end in self.ranges: if end is None: ranges.append("%s-" % begin if begin >= 0 else str(begin)) else: ranges.append("%s-%s" % (begin, end - 1)) ...
[ "def", "to_header", "(", "self", ")", ":", "ranges", "=", "[", "]", "for", "begin", ",", "end", "in", "self", ".", "ranges", ":", "if", "end", "is", "None", ":", "ranges", ".", "append", "(", "\"%s-\"", "%", "begin", "if", "begin", ">=", "0", "el...
Converts the object back into an HTTP header.
[ "Converts", "the", "object", "back", "into", "an", "HTTP", "header", "." ]
python
train
40.666667
pyBookshelf/bookshelf
bookshelf/api_v2/pkg.py
https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/pkg.py#L241-L259
def yum_install_from_url(pkg_name, url): """ installs a pkg from a url p pkg_name: the name of the package to install p url: the full URL for the rpm package """ if is_package_installed(distribution='el', pkg=pkg_name) is False: log_green( "installing %s from %s" % (pkg_n...
[ "def", "yum_install_from_url", "(", "pkg_name", ",", "url", ")", ":", "if", "is_package_installed", "(", "distribution", "=", "'el'", ",", "pkg", "=", "pkg_name", ")", "is", "False", ":", "log_green", "(", "\"installing %s from %s\"", "%", "(", "pkg_name", ","...
installs a pkg from a url p pkg_name: the name of the package to install p url: the full URL for the rpm package
[ "installs", "a", "pkg", "from", "a", "url", "p", "pkg_name", ":", "the", "name", "of", "the", "package", "to", "install", "p", "url", ":", "the", "full", "URL", "for", "the", "rpm", "package" ]
python
train
38.263158
guaix-ucm/pyemir
emirdrp/processing/wavecal/islitlet_progress.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/islitlet_progress.py#L27-L45
def islitlet_progress(islitlet, islitlet_max): """Auxiliary function to print out progress in loop of slitlets. Parameters ---------- islitlet : int Current slitlet number. islitlet_max : int Maximum slitlet number. """ if islitlet % 10 == 0: cout = str(islitlet // ...
[ "def", "islitlet_progress", "(", "islitlet", ",", "islitlet_max", ")", ":", "if", "islitlet", "%", "10", "==", "0", ":", "cout", "=", "str", "(", "islitlet", "//", "10", ")", "else", ":", "cout", "=", "'.'", "sys", ".", "stdout", ".", "write", "(", ...
Auxiliary function to print out progress in loop of slitlets. Parameters ---------- islitlet : int Current slitlet number. islitlet_max : int Maximum slitlet number.
[ "Auxiliary", "function", "to", "print", "out", "progress", "in", "loop", "of", "slitlets", "." ]
python
train
23.578947
shoebot/shoebot
lib/web/cache.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/cache.py#L78-L89
def age(self, id): """ Returns the age of the cache entry, in days. """ path = self.hash(id) if os.path.exists(path): modified = datetime.datetime.fromtimestamp(os.stat(path)[8]) age = datetime.datetime.today() - modified return age.days else...
[ "def", "age", "(", "self", ",", "id", ")", ":", "path", "=", "self", ".", "hash", "(", "id", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "modified", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "os", ".", ...
Returns the age of the cache entry, in days.
[ "Returns", "the", "age", "of", "the", "cache", "entry", "in", "days", "." ]
python
valid
27.583333
Robpol86/terminaltables
terminaltables/github_table.py
https://github.com/Robpol86/terminaltables/blob/ad8f46e50afdbaea377fc1f713bc0e7a31c4fccc/terminaltables/github_table.py#L56-L70
def gen_table(self, inner_widths, inner_heights, outer_widths): """Combine everything and yield every line of the entire table with borders. :param iter inner_widths: List of widths (no padding) for each column. :param iter inner_heights: List of heights (no padding) for each row. :para...
[ "def", "gen_table", "(", "self", ",", "inner_widths", ",", "inner_heights", ",", "outer_widths", ")", ":", "for", "i", ",", "row", "in", "enumerate", "(", "self", ".", "table_data", ")", ":", "# Yield the row line by line (e.g. multi-line rows).", "for", "line", ...
Combine everything and yield every line of the entire table with borders. :param iter inner_widths: List of widths (no padding) for each column. :param iter inner_heights: List of heights (no padding) for each row. :param iter outer_widths: List of widths (with padding) for each column. ...
[ "Combine", "everything", "and", "yield", "every", "line", "of", "the", "entire", "table", "with", "borders", "." ]
python
train
50.6
b3j0f/utils
b3j0f/utils/ut.py
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/ut.py#L40-L54
def _subset(subset, superset): """True if subset is a subset of superset. :param dict subset: subset to compare. :param dict superset: superset to compare. :return: True iif all pairs (key, value) of subset are in superset. :rtype: bool """ result = True for k in subset: result...
[ "def", "_subset", "(", "subset", ",", "superset", ")", ":", "result", "=", "True", "for", "k", "in", "subset", ":", "result", "=", "k", "in", "superset", "and", "subset", "[", "k", "]", "==", "superset", "[", "k", "]", "if", "not", "result", ":", ...
True if subset is a subset of superset. :param dict subset: subset to compare. :param dict superset: superset to compare. :return: True iif all pairs (key, value) of subset are in superset. :rtype: bool
[ "True", "if", "subset", "is", "a", "subset", "of", "superset", "." ]
python
train
27.333333
shaunduncan/helga-facts
helga_facts.py
https://github.com/shaunduncan/helga-facts/blob/956b1d93abccdaaf318d7cac4451edc7e73bf5e9/helga_facts.py#L80-L86
def forget_fact(term): """ Forgets a fact by removing it from the database """ logger.info('Removing fact %s', term) db.facts.remove({'term': term_regex(term)}) return random.choice(ACKS)
[ "def", "forget_fact", "(", "term", ")", ":", "logger", ".", "info", "(", "'Removing fact %s'", ",", "term", ")", "db", ".", "facts", ".", "remove", "(", "{", "'term'", ":", "term_regex", "(", "term", ")", "}", ")", "return", "random", ".", "choice", ...
Forgets a fact by removing it from the database
[ "Forgets", "a", "fact", "by", "removing", "it", "from", "the", "database" ]
python
train
29.285714
honzamach/pydgets
pydgets/widgets.py
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1233-L1267
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ result = [] columns = settings[self.SETTING_COLUMNS] # Format each table cell into string. (columns, content) = self.table_format(columns, content) ...
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "result", "=", "[", "]", "columns", "=", "settings", "[", "self", ".", "SETTING_COLUMNS", "]", "# Format each table cell into string.", "(", "columns", ",", "content", ...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
python
train
45.685714
obriencj/python-javatools
javatools/__init__.py
https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/__init__.py#L1376-L1389
def get_arg_type_descriptors(self): """ The parameter type descriptor list for a method, or None for a field. Type descriptors are shorthand identifiers for the builtin java types. """ if not self.is_method: return tuple() tp = _typeseq(self.get_des...
[ "def", "get_arg_type_descriptors", "(", "self", ")", ":", "if", "not", "self", ".", "is_method", ":", "return", "tuple", "(", ")", "tp", "=", "_typeseq", "(", "self", ".", "get_descriptor", "(", ")", ")", "tp", "=", "_typeseq", "(", "tp", "[", "0", "...
The parameter type descriptor list for a method, or None for a field. Type descriptors are shorthand identifiers for the builtin java types.
[ "The", "parameter", "type", "descriptor", "list", "for", "a", "method", "or", "None", "for", "a", "field", ".", "Type", "descriptors", "are", "shorthand", "identifiers", "for", "the", "builtin", "java", "types", "." ]
python
train
26.5
OCHA-DAP/hdx-python-api
src/hdx/data/dataset.py
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L186-L200
def add_update_resources(self, resources, ignore_datasetid=False): # type: (List[Union[hdx.data.resource.Resource,Dict,str]], bool) -> None """Add new or update existing resources with new metadata to the dataset Args: resources (List[Union[hdx.data.resource.Resource,Dict,str]]): A ...
[ "def", "add_update_resources", "(", "self", ",", "resources", ",", "ignore_datasetid", "=", "False", ")", ":", "# type: (List[Union[hdx.data.resource.Resource,Dict,str]], bool) -> None", "if", "not", "isinstance", "(", "resources", ",", "list", ")", ":", "raise", "HDXEr...
Add new or update existing resources with new metadata to the dataset Args: resources (List[Union[hdx.data.resource.Resource,Dict,str]]): A list of either resource ids or resources metadata from either Resource objects or dictionaries ignore_datasetid (bool): Whether to ignore dataset i...
[ "Add", "new", "or", "update", "existing", "resources", "with", "new", "metadata", "to", "the", "dataset" ]
python
train
50.066667
matthewdeanmartin/jiggle_version
jiggle_version/commands.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/commands.py#L26-L47
def bump_version(project, source, force_init): # type: (str, str, bool, bool) ->int """ Entry point :return: """ file_opener = FileOpener() # logger.debug("Starting version jiggler...") jiggler = JiggleVersion(project, source, file_opener, force_init) logger.debug( "Current, ne...
[ "def", "bump_version", "(", "project", ",", "source", ",", "force_init", ")", ":", "# type: (str, str, bool, bool) ->int", "file_opener", "=", "FileOpener", "(", ")", "# logger.debug(\"Starting version jiggler...\")", "jiggler", "=", "JiggleVersion", "(", "project", ",", ...
Entry point :return:
[ "Entry", "point", ":", "return", ":" ]
python
train
35.454545
Calysto/calysto
calysto/ai/conx.py
https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3008-L3014
def loadTargetsFromFile(self, filename, cols = None, everyNrows = 1, delim = ' ', checkEven = 1): """ Loads targets from file. """ self.targets = self.loadVectors(filename, cols, everyNrows, delim, checkEven)
[ "def", "loadTargetsFromFile", "(", "self", ",", "filename", ",", "cols", "=", "None", ",", "everyNrows", "=", "1", ",", "delim", "=", "' '", ",", "checkEven", "=", "1", ")", ":", "self", ".", "targets", "=", "self", ".", "loadVectors", "(", "filename",...
Loads targets from file.
[ "Loads", "targets", "from", "file", "." ]
python
train
43.142857
ajbosco/dag-factory
dagfactory/utils.py
https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/utils.py#L39-L65
def get_time_delta(time_string: str) -> timedelta: """ Takes a time string (1 hours, 10 days, etc.) and returns a python timedelta object :param time_string: the time value to convert to a timedelta :type time_string: str :returns: datetime.timedelta for relative time :type datetime.timedel...
[ "def", "get_time_delta", "(", "time_string", ":", "str", ")", "->", "timedelta", ":", "rel_time", ":", "Pattern", "=", "re", ".", "compile", "(", "pattern", "=", "r\"((?P<hours>\\d+?)\\s+hour)?((?P<minutes>\\d+?)\\s+minute)?((?P<seconds>\\d+?)\\s+second)?((?P<days>\\d+?)\\s+d...
Takes a time string (1 hours, 10 days, etc.) and returns a python timedelta object :param time_string: the time value to convert to a timedelta :type time_string: str :returns: datetime.timedelta for relative time :type datetime.timedelta
[ "Takes", "a", "time", "string", "(", "1", "hours", "10", "days", "etc", ".", ")", "and", "returns", "a", "python", "timedelta", "object" ]
python
train
40.296296
hydpy-dev/hydpy
hydpy/core/sequencetools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L910-L914
def seriesshape(self): """Shape of the whole time series (time being the first dimension).""" seriesshape = [len(hydpy.pub.timegrids.init)] seriesshape.extend(self.shape) return tuple(seriesshape)
[ "def", "seriesshape", "(", "self", ")", ":", "seriesshape", "=", "[", "len", "(", "hydpy", ".", "pub", ".", "timegrids", ".", "init", ")", "]", "seriesshape", ".", "extend", "(", "self", ".", "shape", ")", "return", "tuple", "(", "seriesshape", ")" ]
Shape of the whole time series (time being the first dimension).
[ "Shape", "of", "the", "whole", "time", "series", "(", "time", "being", "the", "first", "dimension", ")", "." ]
python
train
44.8
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/decoders/validator.py
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L243-L270
def _convert_to_dict(data): """ Convert `data` to dictionary. Tries to get sense in multidimensional arrays. Args: data: List/dict/tuple of variable dimension. Returns: dict: If the data can be converted to dictionary. Raises: MetaParsingException: When the data are u...
[ "def", "_convert_to_dict", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "data", "if", "isinstance", "(", "data", ",", "list", ")", "or", "isinstance", "(", "data", ",", "tuple", ")", ":", "if", "_all_correct_...
Convert `data` to dictionary. Tries to get sense in multidimensional arrays. Args: data: List/dict/tuple of variable dimension. Returns: dict: If the data can be converted to dictionary. Raises: MetaParsingException: When the data are unconvertible to dict.
[ "Convert", "data", "to", "dictionary", "." ]
python
train
25.357143
saltstack/salt
salt/modules/mount.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L557-L568
def match(self, fsys_view): ''' Compare potentially partial criteria against built filesystems entry dictionary ''' evalue_dict = fsys_view[1] for key, value in six.viewitems(self.criteria): if key in evalue_dict: if evalue_dict[key] != value: ...
[ "def", "match", "(", "self", ",", "fsys_view", ")", ":", "evalue_dict", "=", "fsys_view", "[", "1", "]", "for", "key", ",", "value", "in", "six", ".", "viewitems", "(", "self", ".", "criteria", ")", ":", "if", "key", "in", "evalue_dict", ":", "if", ...
Compare potentially partial criteria against built filesystems entry dictionary
[ "Compare", "potentially", "partial", "criteria", "against", "built", "filesystems", "entry", "dictionary" ]
python
train
33.333333
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L4916-L4971
def doprinc(data): """ Gets principal components from data in form of a list of [dec,inc] data. Parameters ---------- data : nested list of dec, inc directions Returns ------- ppars : dictionary with the principal components dec : principal directiion declination inc : ...
[ "def", "doprinc", "(", "data", ")", ":", "ppars", "=", "{", "}", "rad", "=", "old_div", "(", "np", ".", "pi", ",", "180.", ")", "X", "=", "dir2cart", "(", "data", ")", "# for rec in data:", "# dir=[]", "# for c in rec: dir.append(c)", "# cart= (dir2...
Gets principal components from data in form of a list of [dec,inc] data. Parameters ---------- data : nested list of dec, inc directions Returns ------- ppars : dictionary with the principal components dec : principal directiion declination inc : principal direction inclination...
[ "Gets", "principal", "components", "from", "data", "in", "form", "of", "a", "list", "of", "[", "dec", "inc", "]", "data", "." ]
python
train
27.035714
benhoff/vexbot
vexbot/adapters/messaging.py
https://github.com/benhoff/vexbot/blob/9b844eb20e84eea92a0e7db7d86a90094956c38f/vexbot/adapters/messaging.py#L257-L270
def start(self) -> None: """ Start the internal control loop. Potentially blocking, depending on the value of `_run_control_loop` set by the initializer. """ self._setup() if self._run_control_loop: asyncio.set_event_loop(asyncio.new_event_loop()) ...
[ "def", "start", "(", "self", ")", "->", "None", ":", "self", ".", "_setup", "(", ")", "if", "self", ".", "_run_control_loop", ":", "asyncio", ".", "set_event_loop", "(", "asyncio", ".", "new_event_loop", "(", ")", ")", "self", ".", "_heartbeat_reciever", ...
Start the internal control loop. Potentially blocking, depending on the value of `_run_control_loop` set by the initializer.
[ "Start", "the", "internal", "control", "loop", ".", "Potentially", "blocking", "depending", "on", "the", "value", "of", "_run_control_loop", "set", "by", "the", "initializer", "." ]
python
train
35.5
kodexlab/reliure
reliure/pipeline.py
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L221-L231
def change_option_default(self, opt_name, default_val): """ Change the default value of an option :param opt_name: option name :type opt_name: str :param value: new default option value """ if not self.has_option(opt_name): raise ValueError("...
[ "def", "change_option_default", "(", "self", ",", "opt_name", ",", "default_val", ")", ":", "if", "not", "self", ".", "has_option", "(", "opt_name", ")", ":", "raise", "ValueError", "(", "\"Unknow option name (%s)\"", "%", "opt_name", ")", "self", ".", "_optio...
Change the default value of an option :param opt_name: option name :type opt_name: str :param value: new default option value
[ "Change", "the", "default", "value", "of", "an", "option", ":", "param", "opt_name", ":", "option", "name", ":", "type", "opt_name", ":", "str", ":", "param", "value", ":", "new", "default", "option", "value" ]
python
train
36.363636
Clinical-Genomics/scout
scout/parse/variant/frequency.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/parse/variant/frequency.py#L113-L147
def parse_sv_frequencies(variant): """Parsing of some custom sv frequencies These are very specific at the moment, this will hopefully get better over time when the field of structural variants is more developed. Args: variant(cyvcf2.Variant) Returns: sv_frequencies(dict) ...
[ "def", "parse_sv_frequencies", "(", "variant", ")", ":", "frequency_keys", "=", "[", "'clingen_cgh_benignAF'", ",", "'clingen_cgh_benign'", ",", "'clingen_cgh_pathogenicAF'", ",", "'clingen_cgh_pathogenic'", ",", "'clingen_ngi'", ",", "'clingen_ngiAF'", ",", "'swegen'", "...
Parsing of some custom sv frequencies These are very specific at the moment, this will hopefully get better over time when the field of structural variants is more developed. Args: variant(cyvcf2.Variant) Returns: sv_frequencies(dict)
[ "Parsing", "of", "some", "custom", "sv", "frequencies", "These", "are", "very", "specific", "at", "the", "moment", "this", "will", "hopefully", "get", "better", "over", "time", "when", "the", "field", "of", "structural", "variants", "is", "more", "developed", ...
python
test
24.685714
dsoprea/PySecure
pysecure/adapters/sftpa.py
https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/adapters/sftpa.py#L886-L912
def read(self, size=None): """Read a length of bytes. Return empty on EOF. If 'size' is omitted, return whole file. """ if size is not None: return self.__sf.read(size) block_size = self.__class__.__block_size b = bytearray() received_bytes = 0 ...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "not", "None", ":", "return", "self", ".", "__sf", ".", "read", "(", "size", ")", "block_size", "=", "self", ".", "__class__", ".", "__block_size", "b", "=", "bytea...
Read a length of bytes. Return empty on EOF. If 'size' is omitted, return whole file.
[ "Read", "a", "length", "of", "bytes", ".", "Return", "empty", "on", "EOF", ".", "If", "size", "is", "omitted", "return", "whole", "file", "." ]
python
train
28.740741
all-umass/graphs
graphs/mixins/analysis.py
https://github.com/all-umass/graphs/blob/4fbeb025dfe33340335f34300f58dd3809228822/graphs/mixins/analysis.py#L94-L97
def profile(self): """Measure of bandedness, also known as 'envelope size'.""" leftmost_idx = np.argmax(self.matrix('dense').astype(bool), axis=0) return (np.arange(self.num_vertices()) - leftmost_idx).sum()
[ "def", "profile", "(", "self", ")", ":", "leftmost_idx", "=", "np", ".", "argmax", "(", "self", ".", "matrix", "(", "'dense'", ")", ".", "astype", "(", "bool", ")", ",", "axis", "=", "0", ")", "return", "(", "np", ".", "arange", "(", "self", ".",...
Measure of bandedness, also known as 'envelope size'.
[ "Measure", "of", "bandedness", "also", "known", "as", "envelope", "size", "." ]
python
train
54
LudovicRousseau/pyscard
smartcard/CardConnection.py
https://github.com/LudovicRousseau/pyscard/blob/62e675028086c75656444cc21d563d9f08ebf8e7/smartcard/CardConnection.py#L129-L154
def transmit(self, bytes, protocol=None): """Transmit an apdu. Internally calls doTransmit() class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit() class method. @param bytes: list of bytes to transmit @param protocol...
[ "def", "transmit", "(", "self", ",", "bytes", ",", "protocol", "=", "None", ")", ":", "Observable", ".", "setChanged", "(", "self", ")", "Observable", ".", "notifyObservers", "(", "self", ",", "CardConnectionEvent", "(", "'command'", ",", "[", "bytes", ","...
Transmit an apdu. Internally calls doTransmit() class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit() class method. @param bytes: list of bytes to transmit @param protocol: the transmission protocol, from ...
[ "Transmit", "an", "apdu", ".", "Internally", "calls", "doTransmit", "()", "class", "method", "and", "notify", "observers", "upon", "command", "/", "response", "APDU", "events", ".", "Subclasses", "must", "override", "the", "doTransmit", "()", "class", "method", ...
python
train
44.769231
rosenbrockc/fortpy
fortpy/parsers/module.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/module.py#L260-L265
def _dict_increment(self, dictionary, key): """Increments the value of the dictionary at the specified key.""" if key in dictionary: dictionary[key] += 1 else: dictionary[key] = 1
[ "def", "_dict_increment", "(", "self", ",", "dictionary", ",", "key", ")", ":", "if", "key", "in", "dictionary", ":", "dictionary", "[", "key", "]", "+=", "1", "else", ":", "dictionary", "[", "key", "]", "=", "1" ]
Increments the value of the dictionary at the specified key.
[ "Increments", "the", "value", "of", "the", "dictionary", "at", "the", "specified", "key", "." ]
python
train
37
Jammy2211/PyAutoLens
autolens/model/inversion/pixelizations.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/pixelizations.py#L11-L39
def setup_image_plane_pixelization_grid_from_galaxies_and_grid_stack(galaxies, grid_stack): """An image-plane pixelization is one where its pixel centres are computed by tracing a sparse grid of pixels from \ the image's regular grid to other planes (e.g. the source-plane). Provided a galaxy has an image-p...
[ "def", "setup_image_plane_pixelization_grid_from_galaxies_and_grid_stack", "(", "galaxies", ",", "grid_stack", ")", ":", "if", "not", "isinstance", "(", "grid_stack", ".", "regular", ",", "grids", ".", "PaddedRegularGrid", ")", ":", "for", "galaxy", "in", "galaxies", ...
An image-plane pixelization is one where its pixel centres are computed by tracing a sparse grid of pixels from \ the image's regular grid to other planes (e.g. the source-plane). Provided a galaxy has an image-plane pixelization, this function returns a new *GridStack* instance where the \ image-plane pix...
[ "An", "image", "-", "plane", "pixelization", "is", "one", "where", "its", "pixel", "centres", "are", "computed", "by", "tracing", "a", "sparse", "grid", "of", "pixels", "from", "\\", "the", "image", "s", "regular", "grid", "to", "other", "planes", "(", "...
python
valid
57.586207
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L6538-L6570
def sbar(Ss): """ calculate average s,sigma from list of "s"s. """ if type(Ss) == list: Ss = np.array(Ss) npts = Ss.shape[0] Ss = Ss.transpose() avd, avs = [], [] # D=np.array([Ss[0],Ss[1],Ss[2],Ss[3]+0.5*(Ss[0]+Ss[1]),Ss[4]+0.5*(Ss[1]+Ss[2]),Ss[5]+0.5*(Ss[0]+Ss[2])]).transpose(...
[ "def", "sbar", "(", "Ss", ")", ":", "if", "type", "(", "Ss", ")", "==", "list", ":", "Ss", "=", "np", ".", "array", "(", "Ss", ")", "npts", "=", "Ss", ".", "shape", "[", "0", "]", "Ss", "=", "Ss", ".", "transpose", "(", ")", "avd", ",", "...
calculate average s,sigma from list of "s"s.
[ "calculate", "average", "s", "sigma", "from", "list", "of", "s", "s", "." ]
python
train
33
pip-services3-python/pip-services3-commons-python
pip_services3_commons/random/RandomString.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/random/RandomString.py#L74-L92
def next_string(min_size, max_size): """ Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols ("_,.:-/.[].{},#-!,$=%.+^.&*-() "). :param min_size: (optional) minimum string length. :param max_size: maximum st...
[ "def", "next_string", "(", "min_size", ",", "max_size", ")", ":", "result", "=", "''", "max_size", "=", "max_size", "if", "max_size", "!=", "None", "else", "min_size", "length", "=", "RandomInteger", ".", "next_integer", "(", "min_size", ",", "max_size", ")"...
Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols ("_,.:-/.[].{},#-!,$=%.+^.&*-() "). :param min_size: (optional) minimum string length. :param max_size: maximum string length. :return: a random string.
[ "Generates", "a", "random", "string", "consisting", "of", "upper", "and", "lower", "case", "letters", "(", "of", "the", "English", "alphabet", ")", "digits", "(", "0", "-", "9", ")", "and", "symbols", "(", "_", ".", ":", "-", "/", ".", "[]", ".", "...
python
train
32.368421
AguaClara/aguaclara
aguaclara/core/physchem.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L219-L230
def headloss_fric(FlowRate, Diam, Length, Nu, PipeRough): """Return the major head loss (due to wall shear) in a pipe. This equation applies to both laminar and turbulent flows. """ #Checking input validity - inputs not checked here are checked by #functions this function calls. ut.check_range(...
[ "def", "headloss_fric", "(", "FlowRate", ",", "Diam", ",", "Length", ",", "Nu", ",", "PipeRough", ")", ":", "#Checking input validity - inputs not checked here are checked by", "#functions this function calls.", "ut", ".", "check_range", "(", "[", "Length", ",", "\">0\"...
Return the major head loss (due to wall shear) in a pipe. This equation applies to both laminar and turbulent flows.
[ "Return", "the", "major", "head", "loss", "(", "due", "to", "wall", "shear", ")", "in", "a", "pipe", "." ]
python
train
41
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3568-L3572
def ticket_satisfaction_rating_create(self, ticket_id, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/satisfaction_ratings#create-a-satisfaction-rating" api_path = "/api/v2/tickets/{ticket_id}/satisfaction_rating.json" api_path = api_path.format(ticket_id=ticket_id) r...
[ "def", "ticket_satisfaction_rating_create", "(", "self", ",", "ticket_id", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/tickets/{ticket_id}/satisfaction_rating.json\"", "api_path", "=", "api_path", ".", "format", "(", "ticket_id", "=", ...
https://developer.zendesk.com/rest_api/docs/core/satisfaction_ratings#create-a-satisfaction-rating
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "satisfaction_ratings#create", "-", "a", "-", "satisfaction", "-", "rating" ]
python
train
75.4
projectatomic/atomic-reactor
atomic_reactor/util.py
https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/util.py#L947-L1001
def get_manifest_digests(image, registry, insecure=False, dockercfg_path=None, versions=('v1', 'v2', 'v2_list', 'oci', 'oci_index'), require_digest=True): """Return manifest digest for image. :param image: ImageName, the remote image to inspect :param registry: str, URI for registr...
[ "def", "get_manifest_digests", "(", "image", ",", "registry", ",", "insecure", "=", "False", ",", "dockercfg_path", "=", "None", ",", "versions", "=", "(", "'v1'", ",", "'v2'", ",", "'v2_list'", ",", "'oci'", ",", "'oci_index'", ")", ",", "require_digest", ...
Return manifest digest for image. :param image: ImageName, the remote image to inspect :param registry: str, URI for registry, if URI schema is not provided, https:// will be used :param insecure: bool, when True registry's cert is not verified :param dockercfg_path: str, dirn...
[ "Return", "manifest", "digest", "for", "image", "." ]
python
train
43.472727
zhmcclient/python-zhmcclient
zhmcclient_mock/_urihandler.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L368-L376
def post(method, hmc, uri, uri_parms, body, logon_required, wait_for_completion): """Operation: Update <resource> Properties.""" assert wait_for_completion is True # async not supported yet try: resource = hmc.lookup_by_uri(uri) except KeyError: rais...
[ "def", "post", "(", "method", ",", "hmc", ",", "uri", ",", "uri_parms", ",", "body", ",", "logon_required", ",", "wait_for_completion", ")", ":", "assert", "wait_for_completion", "is", "True", "# async not supported yet", "try", ":", "resource", "=", "hmc", "....
Operation: Update <resource> Properties.
[ "Operation", ":", "Update", "<resource", ">", "Properties", "." ]
python
train
41.888889
tensorflow/tensor2tensor
tensor2tensor/models/resnet.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L112-L188
def conv2d_fixed_padding(inputs, filters, kernel_size, strides, data_format="channels_first", use_td=False, targeting_rate=None, keep_prob=None, ...
[ "def", "conv2d_fixed_padding", "(", "inputs", ",", "filters", ",", "kernel_size", ",", "strides", ",", "data_format", "=", "\"channels_first\"", ",", "use_td", "=", "False", ",", "targeting_rate", "=", "None", ",", "keep_prob", "=", "None", ",", "is_training", ...
Strided 2-D convolution with explicit padding. The padding is consistent and is based only on `kernel_size`, not on the dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone). Args: inputs: `Tensor` of size `[batch, channels, height_in, width_in]`. filters: `int` number of filters in the ...
[ "Strided", "2", "-", "D", "convolution", "with", "explicit", "padding", "." ]
python
train
35.38961
ayust/kitnirc
kitnirc/client.py
https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L689-L704
def _parse_part(client, command, actor, args): """Parse a PART and update channel states, then dispatch events. Note that two events are dispatched here: - PART, because a user parted the channel - MEMBERS, because the channel's members changed """ actor = User(actor) channel, _, me...
[ "def", "_parse_part", "(", "client", ",", "command", ",", "actor", ",", "args", ")", ":", "actor", "=", "User", "(", "actor", ")", "channel", ",", "_", ",", "message", "=", "args", ".", "partition", "(", "' :'", ")", "channel", "=", "client", ".", ...
Parse a PART and update channel states, then dispatch events. Note that two events are dispatched here: - PART, because a user parted the channel - MEMBERS, because the channel's members changed
[ "Parse", "a", "PART", "and", "update", "channel", "states", "then", "dispatch", "events", "." ]
python
train
40.375
apache/incubator-mxnet
example/speech_recognition/stt_io_bucketingiter.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_io_bucketingiter.py#L132-L165
def next(self): """Returns the next batch of data.""" if self.curr_idx == len(self.idx): raise StopIteration i, j = self.idx[self.curr_idx] self.curr_idx += 1 audio_paths = [] texts = [] for duration, audio_path, text in self.data[i][j:j+self.batch_si...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "curr_idx", "==", "len", "(", "self", ".", "idx", ")", ":", "raise", "StopIteration", "i", ",", "j", "=", "self", ".", "idx", "[", "self", ".", "curr_idx", "]", "self", ".", "curr_idx", "+=...
Returns the next batch of data.
[ "Returns", "the", "next", "batch", "of", "data", "." ]
python
train
49.088235
useblocks/sphinxcontrib-needs
sphinxcontrib/needs/directives/needlist.py
https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/needlist.py#L69-L135
def process_needlist(app, doctree, fromdocname): """ Replace all needlist nodes with a list of the collected needs. Augment each need with a backlink to the original location. """ env = app.builder.env for node in doctree.traverse(Needlist): if not app.config.needs_include_needs: ...
[ "def", "process_needlist", "(", "app", ",", "doctree", ",", "fromdocname", ")", ":", "env", "=", "app", ".", "builder", ".", "env", "for", "node", "in", "doctree", ".", "traverse", "(", "Needlist", ")", ":", "if", "not", "app", ".", "config", ".", "n...
Replace all needlist nodes with a list of the collected needs. Augment each need with a backlink to the original location.
[ "Replace", "all", "needlist", "nodes", "with", "a", "list", "of", "the", "collected", "needs", ".", "Augment", "each", "need", "with", "a", "backlink", "to", "the", "original", "location", "." ]
python
train
40.149254
apache/incubator-mxnet
example/sparse/matrix_factorization/data.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/matrix_factorization/data.py#L29-L56
def get_movielens_iter(filename, batch_size): """Not particularly fast code to parse the text file and load into NDArrays. return two data iters, one for train, the other for validation. """ logging.info("Preparing data iterators for " + filename + " ... ") user = [] item = [] score = [] ...
[ "def", "get_movielens_iter", "(", "filename", ",", "batch_size", ")", ":", "logging", ".", "info", "(", "\"Preparing data iterators for \"", "+", "filename", "+", "\" ... \"", ")", "user", "=", "[", "]", "item", "=", "[", "]", "score", "=", "[", "]", "with...
Not particularly fast code to parse the text file and load into NDArrays. return two data iters, one for train, the other for validation.
[ "Not", "particularly", "fast", "code", "to", "parse", "the", "text", "file", "and", "load", "into", "NDArrays", ".", "return", "two", "data", "iters", "one", "for", "train", "the", "other", "for", "validation", "." ]
python
train
36.571429
hatemile/hatemile-for-python
hatemile/implementation/css.py
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/css.py#L635-L645
def _speak_normal_inherit(self, element): """ Speak the content of element and descendants. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement """ self._visit(element, self._speak_normal) element.normalize()
[ "def", "_speak_normal_inherit", "(", "self", ",", "element", ")", ":", "self", ".", "_visit", "(", "element", ",", "self", ".", "_speak_normal", ")", "element", ".", "normalize", "(", ")" ]
Speak the content of element and descendants. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
[ "Speak", "the", "content", "of", "element", "and", "descendants", "." ]
python
train
27.090909
pysathq/pysat
examples/rc2.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/rc2.py#L249-L304
def init(self, formula, incr=False): """ Initialize the internal SAT oracle. The oracle is used incrementally and so it is initialized only once when constructing an object of class :class:`RC2`. Given an input :class:`.WCNF` formula, the method bootstraps the ...
[ "def", "init", "(", "self", ",", "formula", ",", "incr", "=", "False", ")", ":", "# creating a solver object", "self", ".", "oracle", "=", "Solver", "(", "name", "=", "self", ".", "solver", ",", "bootstrap_with", "=", "formula", ".", "hard", ",", "incr",...
Initialize the internal SAT oracle. The oracle is used incrementally and so it is initialized only once when constructing an object of class :class:`RC2`. Given an input :class:`.WCNF` formula, the method bootstraps the oracle with its hard clauses. It also augments the s...
[ "Initialize", "the", "internal", "SAT", "oracle", ".", "The", "oracle", "is", "used", "incrementally", "and", "so", "it", "is", "initialized", "only", "once", "when", "constructing", "an", "object", "of", "class", ":", "class", ":", "RC2", ".", "Given", "a...
python
train
36.357143
noobermin/lspreader
lspreader/lspreader.py
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/lspreader.py#L43-L59
def get_list(file,fmt): '''makes a list out of the fmt from the LspOutput f using the format i for int f for float d for double s for string''' out=[] for i in fmt: if i == 'i': out.append(get_int(file)); elif i == 'f' or i == 'd': out.appe...
[ "def", "get_list", "(", "file", ",", "fmt", ")", ":", "out", "=", "[", "]", "for", "i", "in", "fmt", ":", "if", "i", "==", "'i'", ":", "out", ".", "append", "(", "get_int", "(", "file", ")", ")", "elif", "i", "==", "'f'", "or", "i", "==", "...
makes a list out of the fmt from the LspOutput f using the format i for int f for float d for double s for string
[ "makes", "a", "list", "out", "of", "the", "fmt", "from", "the", "LspOutput", "f", "using", "the", "format", "i", "for", "int", "f", "for", "float", "d", "for", "double", "s", "for", "string" ]
python
train
28.235294
CybOXProject/mixbox
mixbox/datautils.py
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L26-L42
def import_class(classpath): """Import the class referred to by the fully qualified class path. Args: classpath: A full "foo.bar.MyClass" path to a class definition. Returns: The class referred to by the classpath. Raises: ImportError: If an error occurs while importing the mo...
[ "def", "import_class", "(", "classpath", ")", ":", "modname", ",", "classname", "=", "classpath", ".", "rsplit", "(", "\".\"", ",", "1", ")", "module", "=", "importlib", ".", "import_module", "(", "modname", ")", "klass", "=", "getattr", "(", "module", "...
Import the class referred to by the fully qualified class path. Args: classpath: A full "foo.bar.MyClass" path to a class definition. Returns: The class referred to by the classpath. Raises: ImportError: If an error occurs while importing the module. AttributeError: IF the...
[ "Import", "the", "class", "referred", "to", "by", "the", "fully", "qualified", "class", "path", "." ]
python
train
32.117647
ratt-ru/PyMORESANE
pymoresane/iuwt_toolbox.py
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L292-L306
def snr_ratio(in1, in2): """ The following function simply calculates the signal to noise ratio between two signals. INPUTS: in1 (no default): Array containing values for signal 1. in2 (no default): Array containing values for signal 2. OUTPUTS: out1 ...
[ "def", "snr_ratio", "(", "in1", ",", "in2", ")", ":", "out1", "=", "20", "*", "(", "np", ".", "log10", "(", "np", ".", "linalg", ".", "norm", "(", "in1", ")", "/", "np", ".", "linalg", ".", "norm", "(", "in1", "-", "in2", ")", ")", ")", "re...
The following function simply calculates the signal to noise ratio between two signals. INPUTS: in1 (no default): Array containing values for signal 1. in2 (no default): Array containing values for signal 2. OUTPUTS: out1 The ratio of the signal to noise ...
[ "The", "following", "function", "simply", "calculates", "the", "signal", "to", "noise", "ratio", "between", "two", "signals", "." ]
python
train
30.733333
saltstack/salt
salt/modules/memcached.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/memcached.py#L51-L58
def _connect(host=DEFAULT_HOST, port=DEFAULT_PORT): ''' Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values. ''' if six.text_type(port).isdigit(): return memcache.Client(['{0}:{1}'.format(host, port)], debug=0) raise SaltInvocationError...
[ "def", "_connect", "(", "host", "=", "DEFAULT_HOST", ",", "port", "=", "DEFAULT_PORT", ")", ":", "if", "six", ".", "text_type", "(", "port", ")", ".", "isdigit", "(", ")", ":", "return", "memcache", ".", "Client", "(", "[", "'{0}:{1}'", ".", "format", ...
Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values.
[ "Returns", "a", "tuple", "of", "(", "user", "host", "port", ")", "with", "config", "pillar", "or", "default", "values", "assigned", "to", "missing", "values", "." ]
python
train
42.5
Metatab/metapack
metapack/terms.py
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/terms.py#L287-L306
def schema_columns(self): """Return column informatino only from this schema""" t = self.schema_term columns = [] if t: for i, c in enumerate(t.children): if c.term_is("Table.Column"): p = c.all_props p['pos'] = i ...
[ "def", "schema_columns", "(", "self", ")", ":", "t", "=", "self", ".", "schema_term", "columns", "=", "[", "]", "if", "t", ":", "for", "i", ",", "c", "in", "enumerate", "(", "t", ".", "children", ")", ":", "if", "c", ".", "term_is", "(", "\"Table...
Return column informatino only from this schema
[ "Return", "column", "informatino", "only", "from", "this", "schema" ]
python
train
24.3
sam-cox/pytides
pytides/tide.py
https://github.com/sam-cox/pytides/blob/63a2507299002f1979ea55a17a82561158d685f7/pytides/tide.py#L62-L96
def _prepare(constituents, t0, t = None, radians = True): """ Return constituent speed and equilibrium argument at a given time, and constituent node factors at given times. Arguments: constituents -- list of constituents to prepare t0 -- time at which to evaluate speed and equilibrium argument for each const...
[ "def", "_prepare", "(", "constituents", ",", "t0", ",", "t", "=", "None", ",", "radians", "=", "True", ")", ":", "#The equilibrium argument is constant and taken at the beginning of the", "#time series (t0). The speed of the equilibrium argument changes very", "#slowly, so again...
Return constituent speed and equilibrium argument at a given time, and constituent node factors at given times. Arguments: constituents -- list of constituents to prepare t0 -- time at which to evaluate speed and equilibrium argument for each constituent t -- list of times at which to evaluate node factors for ...
[ "Return", "constituent", "speed", "and", "equilibrium", "argument", "at", "a", "given", "time", "and", "constituent", "node", "factors", "at", "given", "times", ".", "Arguments", ":", "constituents", "--", "list", "of", "constituents", "to", "prepare", "t0", "...
python
train
40.114286
datasift/datasift-python
datasift/historics.py
https://github.com/datasift/datasift-python/blob/bfaca1a47501a18e11065ecf630d9c31df818f65/datasift/historics.py#L10-L39
def prepare(self, hash, start, end, name, sources, sample=None): """ Prepare a historics query which can later be started. Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/historicsprepare :param hash: The hash of a CSDL create the query for :type ...
[ "def", "prepare", "(", "self", ",", "hash", ",", "start", ",", "end", ",", "name", ",", "sources", ",", "sample", "=", "None", ")", ":", "if", "len", "(", "sources", ")", "==", "0", ":", "raise", "HistoricSourcesRequired", "(", ")", "if", "not", "i...
Prepare a historics query which can later be started. Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/historicsprepare :param hash: The hash of a CSDL create the query for :type hash: str :param start: when to start querying data from - unix t...
[ "Prepare", "a", "historics", "query", "which", "can", "later", "be", "started", "." ]
python
train
48.333333
reingart/gui2py
gui/controls/gridview.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/controls/gridview.py#L448-L455
def clear(self): "Remove all rows and reset internal structures" ## list has no clear ... remove items in reverse order for i in range(len(self)-1, -1, -1): del self[i] self._key = 0 if hasattr(self._grid_view, "wx_obj"): self._grid_view.wx_obj.Clea...
[ "def", "clear", "(", "self", ")", ":", "## list has no clear ... remove items in reverse order\r", "for", "i", "in", "range", "(", "len", "(", "self", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "del", "self", "[", "i", "]", "self", ".", "...
Remove all rows and reset internal structures
[ "Remove", "all", "rows", "and", "reset", "internal", "structures" ]
python
test
40
fedora-infra/fedmsg-atomic-composer
fedmsg_atomic_composer/composer.py
https://github.com/fedora-infra/fedmsg-atomic-composer/blob/9be9fd4955af0568f8743d7a1a243cd8f70020c3/fedmsg_atomic_composer/composer.py#L119-L126
def mock_cmd(self, release, *cmd, **kwargs): """Run a mock command in the chroot for a given release""" fmt = '{mock_cmd}' if kwargs.get('new_chroot') is True: fmt +=' --new-chroot' fmt += ' --configdir={mock_dir}' return self.call(fmt.format(**release).split() ...
[ "def", "mock_cmd", "(", "self", ",", "release", ",", "*", "cmd", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "'{mock_cmd}'", "if", "kwargs", ".", "get", "(", "'new_chroot'", ")", "is", "True", ":", "fmt", "+=", "' --new-chroot'", "fmt", "+=", "' -...
Run a mock command in the chroot for a given release
[ "Run", "a", "mock", "command", "in", "the", "chroot", "for", "a", "given", "release" ]
python
train
43
MacHu-GWU/sqlalchemy_mate-project
sqlalchemy_mate/pt.py
https://github.com/MacHu-GWU/sqlalchemy_mate-project/blob/946754744c8870f083fd7b4339fca15d1d6128b2/sqlalchemy_mate/pt.py#L34-L49
def from_stmt(stmt, engine, **kwargs): """ Execute a query in form of texture clause, return the result in form of :class:`PrettyTable`. :type stmt: TextClause :param stmt: :type engine: Engine :param engine: :rtype: PrettyTable """ result_proxy = engine.execute(stmt, **kwarg...
[ "def", "from_stmt", "(", "stmt", ",", "engine", ",", "*", "*", "kwargs", ")", ":", "result_proxy", "=", "engine", ".", "execute", "(", "stmt", ",", "*", "*", "kwargs", ")", "return", "from_db_cursor", "(", "result_proxy", ".", "cursor", ")" ]
Execute a query in form of texture clause, return the result in form of :class:`PrettyTable`. :type stmt: TextClause :param stmt: :type engine: Engine :param engine: :rtype: PrettyTable
[ "Execute", "a", "query", "in", "form", "of", "texture", "clause", "return", "the", "result", "in", "form", "of" ]
python
train
22.125
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/aggregation_edit.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/aggregation_edit.py#L21-L63
def get_user_lists(self, course, aggregationid=''): """ Get the available student and tutor lists for aggregation edition""" tutor_list = course.get_staff() # Determine student list and if they are grouped student_list = list(self.database.aggregations.aggregate([ {"$match":...
[ "def", "get_user_lists", "(", "self", ",", "course", ",", "aggregationid", "=", "''", ")", ":", "tutor_list", "=", "course", ".", "get_staff", "(", ")", "# Determine student list and if they are grouped", "student_list", "=", "list", "(", "self", ".", "database", ...
Get the available student and tutor lists for aggregation edition
[ "Get", "the", "available", "student", "and", "tutor", "lists", "for", "aggregation", "edition" ]
python
train
44.418605
retext-project/retext
ReText/window.py
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/window.py#L995-L1006
def getPageSizeByName(self, pageSizeName): """ Returns a validated PageSize instance corresponding to the given name. Returns None if the name is not a valid PageSize. """ pageSize = None lowerCaseNames = {pageSize.lower(): pageSize for pageSize in self.availablePageSizes()} if pageSize...
[ "def", "getPageSizeByName", "(", "self", ",", "pageSizeName", ")", ":", "pageSize", "=", "None", "lowerCaseNames", "=", "{", "pageSize", ".", "lower", "(", ")", ":", "pageSize", "for", "pageSize", "in", "self", ".", "availablePageSizes", "(", ")", "}", "if...
Returns a validated PageSize instance corresponding to the given name. Returns None if the name is not a valid PageSize.
[ "Returns", "a", "validated", "PageSize", "instance", "corresponding", "to", "the", "given", "name", ".", "Returns", "None", "if", "the", "name", "is", "not", "a", "valid", "PageSize", "." ]
python
train
36.5
jsommers/switchyard
switchyard/lib/packet/util.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/util.py#L14-L29
def create_ip_arp_request(srchw, srcip, targetip): ''' Create and return a packet containing an Ethernet header and ARP header. ''' ether = Ethernet() ether.src = srchw ether.dst = SpecialEthAddr.ETHER_BROADCAST.value ether.ethertype = EtherType.ARP arp = Arp() arp.operation = Ar...
[ "def", "create_ip_arp_request", "(", "srchw", ",", "srcip", ",", "targetip", ")", ":", "ether", "=", "Ethernet", "(", ")", "ether", ".", "src", "=", "srchw", "ether", ".", "dst", "=", "SpecialEthAddr", ".", "ETHER_BROADCAST", ".", "value", "ether", ".", ...
Create and return a packet containing an Ethernet header and ARP header.
[ "Create", "and", "return", "a", "packet", "containing", "an", "Ethernet", "header", "and", "ARP", "header", "." ]
python
train
31.375
geophysics-ubonn/reda
lib/reda/utils/data.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/data.py#L21-L66
def download_data(identifier, outdir): """Download data from a separate data repository for testing. Parameters ---------- identifier: string The identifier used to find the data set outdir: string unzip the data in this directory """ # determine target if use_local_data...
[ "def", "download_data", "(", "identifier", ",", "outdir", ")", ":", "# determine target", "if", "use_local_data_repository", "is", "not", "None", ":", "url_base", "=", "'file:'", "+", "request", ".", "pathname2url", "(", "use_local_data_repository", "+", "os", "."...
Download data from a separate data repository for testing. Parameters ---------- identifier: string The identifier used to find the data set outdir: string unzip the data in this directory
[ "Download", "data", "from", "a", "separate", "data", "repository", "for", "testing", "." ]
python
train
28.021739
DigitalGlobe/gbdxtools
gbdxtools/vector_styles.py
https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/vector_styles.py#L216-L232
def paint(self): """ Renders a javascript snippet suitable for use as a mapbox-gl fill-extrusion paint entry Returns: A dict that can be converted to a mapbox-gl javascript paint snippet """ snippet = { 'fill-extrusion-opacity': VectorStyle.get_style_valu...
[ "def", "paint", "(", "self", ")", ":", "snippet", "=", "{", "'fill-extrusion-opacity'", ":", "VectorStyle", ".", "get_style_value", "(", "self", ".", "opacity", ")", ",", "'fill-extrusion-color'", ":", "VectorStyle", ".", "get_style_value", "(", "self", ".", "...
Renders a javascript snippet suitable for use as a mapbox-gl fill-extrusion paint entry Returns: A dict that can be converted to a mapbox-gl javascript paint snippet
[ "Renders", "a", "javascript", "snippet", "suitable", "for", "use", "as", "a", "mapbox", "-", "gl", "fill", "-", "extrusion", "paint", "entry" ]
python
valid
39.764706
hammerlab/cohorts
cohorts/utils.py
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L210-L219
def set_attributes(obj, additional_data): """ Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters. """ for key, value in additional_data.items(): if hasattr(obj, key): ...
[ "def", "set_attributes", "(", "obj", ",", "additional_data", ")", ":", "for", "key", ",", "value", "in", "additional_data", ".", "items", "(", ")", ":", "if", "hasattr", "(", "obj", ",", "key", ")", ":", "raise", "ValueError", "(", "\"Key %s in additional_...
Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters.
[ "Given", "an", "object", "and", "a", "dictionary", "give", "the", "object", "new", "attributes", "from", "that", "dictionary", "." ]
python
train
44.7
MAVENSDC/PyTplot
pytplot/xlim.py
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/xlim.py#L10-L44
def xlim(min, max): """ This function will set the x axis range for all time series plots Parameters: min : flt The time to start all time series plots. Can be given in seconds since epoch, or as a string in the format "YYYY-MM-DD HH:MM:SS" max : flt ...
[ "def", "xlim", "(", "min", ",", "max", ")", ":", "if", "not", "isinstance", "(", "min", ",", "(", "int", ",", "float", ",", "complex", ")", ")", ":", "min", "=", "tplot_utilities", ".", "str_to_int", "(", "min", ")", "if", "not", "isinstance", "(",...
This function will set the x axis range for all time series plots Parameters: min : flt The time to start all time series plots. Can be given in seconds since epoch, or as a string in the format "YYYY-MM-DD HH:MM:SS" max : flt The time to end all time series...
[ "This", "function", "will", "set", "the", "x", "axis", "range", "for", "all", "time", "series", "plots", "Parameters", ":", "min", ":", "flt", "The", "time", "to", "start", "all", "time", "series", "plots", ".", "Can", "be", "given", "in", "seconds", "...
python
train
35.028571
assemblerflow/flowcraft
flowcraft/generator/inspect.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/inspect.py#L1356-L1373
def _get_log_lines(self, n=300): """Returns a list with the last ``n`` lines of the nextflow log file Parameters ---------- n : int Number of last lines from the log file Returns ------- list List of strings with the nextflow log ...
[ "def", "_get_log_lines", "(", "self", ",", "n", "=", "300", ")", ":", "with", "open", "(", "self", ".", "log_file", ")", "as", "fh", ":", "last_lines", "=", "fh", ".", "readlines", "(", ")", "[", "-", "n", ":", "]", "return", "last_lines" ]
Returns a list with the last ``n`` lines of the nextflow log file Parameters ---------- n : int Number of last lines from the log file Returns ------- list List of strings with the nextflow log
[ "Returns", "a", "list", "with", "the", "last", "n", "lines", "of", "the", "nextflow", "log", "file" ]
python
test
23.277778
michaeljohnbarr/django-timezone-utils
timezone_utils/fields.py
https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L179-L233
def _check_choices_attribute(self): # pragma: no cover """Checks to make sure that choices contains valid timezone choices.""" if self.choices: warning_params = { 'msg': ( "'choices' contains an invalid time zone value '{value}' " "w...
[ "def", "_check_choices_attribute", "(", "self", ")", ":", "# pragma: no cover", "if", "self", ".", "choices", ":", "warning_params", "=", "{", "'msg'", ":", "(", "\"'choices' contains an invalid time zone value '{value}' \"", "\"which was not found as a supported time zone by p...
Checks to make sure that choices contains valid timezone choices.
[ "Checks", "to", "make", "sure", "that", "choices", "contains", "valid", "timezone", "choices", "." ]
python
train
44.109091
gpoulter/python-ngram
ngram.py
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L267-L294
def items_sharing_ngrams(self, query): """Retrieve the subset of items that share n-grams the query string. :param query: look up items that share N-grams with this string. :return: mapping from matched string to the number of shared N-grams. >>> from ngram import NGram >>> n =...
[ "def", "items_sharing_ngrams", "(", "self", ",", "query", ")", ":", "# From matched string to number of N-grams shared with query string", "shared", "=", "{", "}", "# Dictionary mapping n-gram to string to number of occurrences of that", "# ngram in the string that remain to be matched."...
Retrieve the subset of items that share n-grams the query string. :param query: look up items that share N-grams with this string. :return: mapping from matched string to the number of shared N-grams. >>> from ngram import NGram >>> n = NGram(["ham","spam","eggs"]) >>> sorted(n...
[ "Retrieve", "the", "subset", "of", "items", "that", "share", "n", "-", "grams", "the", "query", "string", "." ]
python
train
43.785714
wonambi-python/wonambi
wonambi/widgets/notes.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/notes.py#L1892-L1927
def create_dialog(self): """Create the dialog.""" bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.idx_ok = bbox.button(QDialogButtonBox.Ok) self.idx_cancel = bbox.button(QDialogButtonBox.Cancel) filebutton = QPushButton() filebutton.setText('C...
[ "def", "create_dialog", "(", "self", ")", ":", "bbox", "=", "QDialogButtonBox", "(", "QDialogButtonBox", ".", "Ok", "|", "QDialogButtonBox", ".", "Cancel", ")", "self", ".", "idx_ok", "=", "bbox", ".", "button", "(", "QDialogButtonBox", ".", "Ok", ")", "se...
Create the dialog.
[ "Create", "the", "dialog", "." ]
python
train
34.555556
astropy/photutils
photutils/centroids/core.py
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/centroids/core.py#L325-L355
def centroid_2dg(data, error=None, mask=None): """ Calculate the centroid of a 2D array by fitting a 2D Gaussian (plus a constant) to the array. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combinati...
[ "def", "centroid_2dg", "(", "data", ",", "error", "=", "None", ",", "mask", "=", "None", ")", ":", "gfit", "=", "fit_2dgaussian", "(", "data", ",", "error", "=", "error", ",", "mask", "=", "mask", ")", "return", "np", ".", "array", "(", "[", "gfit"...
Calculate the centroid of a 2D array by fitting a 2D Gaussian (plus a constant) to the array. Invalid values (e.g. NaNs or infs) in the ``data`` or ``error`` arrays are automatically masked. The mask for invalid values represents the combination of the invalid-value masks for the ``data`` and ``er...
[ "Calculate", "the", "centroid", "of", "a", "2D", "array", "by", "fitting", "a", "2D", "Gaussian", "(", "plus", "a", "constant", ")", "to", "the", "array", "." ]
python
train
30.967742
GNS3/gns3-server
gns3server/compute/dynamips/__init__.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/__init__.py#L187-L207
def project_closing(self, project): """ Called when a project is about to be closed. :param project: Project instance """ yield from super().project_closing(project) # delete the Dynamips devices corresponding to the project tasks = [] for device in self...
[ "def", "project_closing", "(", "self", ",", "project", ")", ":", "yield", "from", "super", "(", ")", ".", "project_closing", "(", "project", ")", "# delete the Dynamips devices corresponding to the project", "tasks", "=", "[", "]", "for", "device", "in", "self", ...
Called when a project is about to be closed. :param project: Project instance
[ "Called", "when", "a", "project", "is", "about", "to", "be", "closed", "." ]
python
train
34.619048
pypa/pipenv
pipenv/vendor/requests/utils.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/utils.py#L344-L375
def parse_dict_header(value): """Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict: >>> d = parse_dict_header('foo="is a fish", bar="as well"') >>> type(d) is dict True >>> sorted(d.items()) [('bar', 'as well'), ('foo', 'is a fish')] ...
[ "def", "parse_dict_header", "(", "value", ")", ":", "result", "=", "{", "}", "for", "item", "in", "_parse_list_header", "(", "value", ")", ":", "if", "'='", "not", "in", "item", ":", "result", "[", "item", "]", "=", "None", "continue", "name", ",", "...
Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict: >>> d = parse_dict_header('foo="is a fish", bar="as well"') >>> type(d) is dict True >>> sorted(d.items()) [('bar', 'as well'), ('foo', 'is a fish')] If there is no value for a key it wi...
[ "Parse", "lists", "of", "key", "value", "pairs", "as", "described", "by", "RFC", "2068", "Section", "2", "and", "convert", "them", "into", "a", "python", "dict", ":" ]
python
train
29.375
nvdv/vprof
setup.py
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/setup.py#L112-L119
def get_vprof_version(filename): """Returns actual version specified in filename.""" with open(filename) as src_file: version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", src_file.read(), re.M) if version_match: return version_match.group...
[ "def", "get_vprof_version", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "src_file", ":", "version_match", "=", "re", ".", "search", "(", "r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ",", "src_file", ".", "read", "(", ")", ",", "r...
Returns actual version specified in filename.
[ "Returns", "actual", "version", "specified", "in", "filename", "." ]
python
test
46.875
zalando/patroni
patroni/ha.py
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/ha.py#L1153-L1190
def handle_starting_instance(self): """Starting up PostgreSQL may take a long time. In case we are the leader we may want to fail over to.""" # Check if we are in startup, when paused defer to main loop for manual failovers. if not self.state_handler.check_for_startup() or self.is_pause...
[ "def", "handle_starting_instance", "(", "self", ")", ":", "# Check if we are in startup, when paused defer to main loop for manual failovers.", "if", "not", "self", ".", "state_handler", ".", "check_for_startup", "(", ")", "or", "self", ".", "is_paused", "(", ")", ":", ...
Starting up PostgreSQL may take a long time. In case we are the leader we may want to fail over to.
[ "Starting", "up", "PostgreSQL", "may", "take", "a", "long", "time", ".", "In", "case", "we", "are", "the", "leader", "we", "may", "want", "to", "fail", "over", "to", "." ]
python
train
48.105263
automl/HpBandSter
hpbandster/optimizers/bohb.py
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/bohb.py#L119-L141
def get_next_iteration(self, iteration, iteration_kwargs={}): """ BO-HB uses (just like Hyperband) SuccessiveHalving for each iteration. See Li et al. (2016) for reference. Parameters ---------- iteration: int the index of the iteration to be instantiated Returns ------- SuccessiveHalving: t...
[ "def", "get_next_iteration", "(", "self", ",", "iteration", ",", "iteration_kwargs", "=", "{", "}", ")", ":", "# number of 'SH rungs'", "s", "=", "self", ".", "max_SH_iter", "-", "1", "-", "(", "iteration", "%", "self", ".", "max_SH_iter", ")", "# number of ...
BO-HB uses (just like Hyperband) SuccessiveHalving for each iteration. See Li et al. (2016) for reference. Parameters ---------- iteration: int the index of the iteration to be instantiated Returns ------- SuccessiveHalving: the SuccessiveHalving iteration with the corresponding number of co...
[ "BO", "-", "HB", "uses", "(", "just", "like", "Hyperband", ")", "SuccessiveHalving", "for", "each", "iteration", ".", "See", "Li", "et", "al", ".", "(", "2016", ")", "for", "reference", ".", "Parameters", "----------", "iteration", ":", "int", "the", "in...
python
train
35
chaoss/grimoirelab-elk
grimoire_elk/enriched/discourse.py
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/discourse.py#L148-L154
def __related_categories(self, category_id): """ Get all related categories to a given one """ related = [] for cat in self.categories_tree: if category_id in self.categories_tree[cat]: related.append(self.categories[cat]) return related
[ "def", "__related_categories", "(", "self", ",", "category_id", ")", ":", "related", "=", "[", "]", "for", "cat", "in", "self", ".", "categories_tree", ":", "if", "category_id", "in", "self", ".", "categories_tree", "[", "cat", "]", ":", "related", ".", ...
Get all related categories to a given one
[ "Get", "all", "related", "categories", "to", "a", "given", "one" ]
python
train
41.571429