nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
zatosource/zato
2a9d273f06f9d776fbfeb53e73855af6e40fa208
code/zato-server/src/zato/server/connection/cache.py
python
CacheAPI.sync_after_delete_by_suffix
(self, cache_type, data)
Synchronizes the state of this worker's cache after a .delete_by_suffix operation in another worker process.
Synchronizes the state of this worker's cache after a .delete_by_suffix operation in another worker process.
[ "Synchronizes", "the", "state", "of", "this", "worker", "s", "cache", "after", "a", ".", "delete_by_suffix", "operation", "in", "another", "worker", "process", "." ]
def sync_after_delete_by_suffix(self, cache_type, data): """ Synchronizes the state of this worker's cache after a .delete_by_suffix operation in another worker process. """ self.caches[cache_type][data.cache_name].sync_after_delete_by_suffix(data)
[ "def", "sync_after_delete_by_suffix", "(", "self", ",", "cache_type", ",", "data", ")", ":", "self", ".", "caches", "[", "cache_type", "]", "[", "data", ".", "cache_name", "]", ".", "sync_after_delete_by_suffix", "(", "data", ")" ]
https://github.com/zatosource/zato/blob/2a9d273f06f9d776fbfeb53e73855af6e40fa208/code/zato-server/src/zato/server/connection/cache.py#L1054-L1057
DamnWidget/anaconda
a9998fb362320f907d5ccbc6fcf5b62baca677c0
anaconda_server/commands/complete_parameters.py
python
CompleteParameters.run
(self)
Run the command
Run the command
[ "Run", "the", "command" ]
def run(self): """Run the command """ completions = [] complete_all = self.settings.get('complete_all_parameters', False) try: signatures = self.script.call_signatures()[0] except IndexError: signatures = None params = get_function_parameters(signatures) for i, p in enumerate(params): try: name, value = p except ValueError: name = p[0] value = None name = name.replace('param ', '') if value is None: completions.append('${%d:%s}' % (i + 1, name)) else: if complete_all is True: completions.append('%s=${%d:%s}' % (name, i + 1, value)) self.callback({ 'success': True, 'template': ', '.join(completions), 'uid': self.uid })
[ "def", "run", "(", "self", ")", ":", "completions", "=", "[", "]", "complete_all", "=", "self", ".", "settings", ".", "get", "(", "'complete_all_parameters'", ",", "False", ")", "try", ":", "signatures", "=", "self", ".", "script", ".", "call_signatures", ...
https://github.com/DamnWidget/anaconda/blob/a9998fb362320f907d5ccbc6fcf5b62baca677c0/anaconda_server/commands/complete_parameters.py#L18-L49
chipmuenk/pyfda
665310b8548a940a575c0e5ff4bba94608d9ac26
pyfda/input_widgets/freq_specs.py
python
FreqSpecs.sort_dict_freqs
(self)
- Sort visible filter dict frequency spec entries with ascending frequency if the sort button is activated - Update the visible QLineEdit frequency widgets The method is called when: - update_UI has been called after changing the filter design algorithm that the response type has been changed eg. from LP -> HP, requiring a different order of frequency entries - a frequency spec field has been edited - the sort button has been clicked (from filter_specs.py)
- Sort visible filter dict frequency spec entries with ascending frequency if the sort button is activated - Update the visible QLineEdit frequency widgets
[ "-", "Sort", "visible", "filter", "dict", "frequency", "spec", "entries", "with", "ascending", "frequency", "if", "the", "sort", "button", "is", "activated", "-", "Update", "the", "visible", "QLineEdit", "frequency", "widgets" ]
def sort_dict_freqs(self): """ - Sort visible filter dict frequency spec entries with ascending frequency if the sort button is activated - Update the visible QLineEdit frequency widgets The method is called when: - update_UI has been called after changing the filter design algorithm that the response type has been changed eg. from LP -> HP, requiring a different order of frequency entries - a frequency spec field has been edited - the sort button has been clicked (from filter_specs.py) """ f_specs = [fb.fil[0][str(self.qlineedit[i].objectName())] for i in range(self.n_cur_labels)] if fb.fil[0]['freq_specs_sort']: f_specs.sort() # Make sure normalized freqs are in the range ]0, 0.5[ and are different # by at least MIN_FREQ_STEP for i in range(self.n_cur_labels): if f_specs[i] <= MIN_FREQ: logger.warning("Frequencies must be > 0, changed {0} from {1:.4g} to {2:.4g}."\ .format(str(self.qlineedit[i].objectName()),f_specs[i]*fb.fil[0]['f_S'], (MIN_FREQ + MIN_FREQ_STEP)*fb.fil[0]['f_S'])) f_specs[i] = MIN_FREQ + MIN_FREQ_STEP if f_specs[i] >= MAX_FREQ: logger.warning("Frequencies must be < f_S /2, changed {0} from {1:.4g} to {2:.4g}."\ .format(str(self.qlineedit[i].objectName()),f_specs[i]*fb.fil[0]['f_S'], (MAX_FREQ - MIN_FREQ_STEP)*fb.fil[0]['f_S'])) f_specs[i] = MAX_FREQ - MIN_FREQ_STEP fb.fil[0][str(self.qlineedit[i].objectName())] = f_specs[i] # check for (nearly) identical elements: _, mult = unique_roots(f_specs, tol=MIN_FREQ_STEP) ident = [x for x in mult if x > 1] if ident: logger.warning("Frequencies must differ by at least {0:.4g}" .format(MIN_FREQ_STEP * fb.fil[0]['f_S'])) self.load_dict()
[ "def", "sort_dict_freqs", "(", "self", ")", ":", "f_specs", "=", "[", "fb", ".", "fil", "[", "0", "]", "[", "str", "(", "self", ".", "qlineedit", "[", "i", "]", ".", "objectName", "(", ")", ")", "]", "for", "i", "in", "range", "(", "self", ".",...
https://github.com/chipmuenk/pyfda/blob/665310b8548a940a575c0e5ff4bba94608d9ac26/pyfda/input_widgets/freq_specs.py#L334-L376
insarlab/MintPy
4357b8c726dec8a3f936770e3f3dda92882685b7
mintpy/simulation/simulation.py
python
sim_variable_timeseries_v1
(tbase, scale=3., display=False)
return ts_sim
Simulate time variable displacement time-series Parameters: tbase - 1D np.ndarray in size of (num_date,), temporal baseline in days Returns: ts_sim - 1D np.ndarray in size of (num_date,), displacement time-series in meters
Simulate time variable displacement time-series
[ "Simulate", "time", "variable", "displacement", "time", "-", "series" ]
def sim_variable_timeseries_v1(tbase, scale=3., display=False): """Simulate time variable displacement time-series Parameters: tbase - 1D np.ndarray in size of (num_date,), temporal baseline in days Returns: ts_sim - 1D np.ndarray in size of (num_date,), displacement time-series in meters """ # Opt 2 - Time variable num_date = len(tbase) ts_sim = np.zeros(num_date, np.float32) # comp 1 - exponential increase idx1 = int(0.2*num_date) ts_sim[idx1:] = 0.01 * np.log(tbase[idx1:] - tbase[idx1-1]) # comp 2 - step decrease + linear increase of 5 cm/yr idx2 = int(0.5*num_date) ts_sim[idx2:] = 0.03 + 0.05 * (tbase[idx2:] - tbase[idx2-1]) / 365.25 idx3 = int(0.8*num_date) ts_sim[idx3:] = 0. # comp 3 - overall linear descrease of 0.5 cm/yr ts_sim += tbase * -0.005 / 365.25 # scale and reference to the 1st image ts_sim *= 3. ts_sim -= ts_sim[0] if display: fig, ax = plt.subplots(figsize=[6, 3]) ax.plot(tbase, ts_sim * 100., '--') ax.set_xlabel('time [days]', fontsize=font_size) ax.set_ylabel('displacement [cm]', fontsize=font_size) ax.tick_params(direction='in', labelsize=font_size) plt.show() return ts_sim
[ "def", "sim_variable_timeseries_v1", "(", "tbase", ",", "scale", "=", "3.", ",", "display", "=", "False", ")", ":", "# Opt 2 - Time variable", "num_date", "=", "len", "(", "tbase", ")", "ts_sim", "=", "np", ".", "zeros", "(", "num_date", ",", "np", ".", ...
https://github.com/insarlab/MintPy/blob/4357b8c726dec8a3f936770e3f3dda92882685b7/mintpy/simulation/simulation.py#L97-L134
BigBrotherBot/big-brother-bot
848823c71413c86e7f1ff9584f43e08d40a7f2c0
b3/parsers/frontline/protocol.py
python
Client.login
(self, challenge)
Authenticate to the server from Frontline documentation : Open a TCP/IP streaming socket to the remote console port of the server All commands sent and received are separated with new line characters '\n' or 0x04 The server will send back a string (without the quotes): "WELCOME! Frontlines: Fuel of War (RCON) VER=2 CHALLENGE=38D384D07C" Note: Challenge string length is not fixed and will vary To generate a response use the MD5 algorithm to hash an ansi string: ResponseString = MD5Hash( ChallengeStringFromServer + Password ); The client will send this string to the server to login: "RESPONSE UserNameHere ResponseString" If the login was successful the client will receive: "Login Success!" If the login failed, the client will be disconnected immediately Once the client is logged in commands can be sent to be run and responses can come back
Authenticate to the server from Frontline documentation : Open a TCP/IP streaming socket to the remote console port of the server All commands sent and received are separated with new line characters '\n' or 0x04 The server will send back a string (without the quotes): "WELCOME! Frontlines: Fuel of War (RCON) VER=2 CHALLENGE=38D384D07C" Note: Challenge string length is not fixed and will vary To generate a response use the MD5 algorithm to hash an ansi string: ResponseString = MD5Hash( ChallengeStringFromServer + Password ); The client will send this string to the server to login: "RESPONSE UserNameHere ResponseString" If the login was successful the client will receive: "Login Success!" If the login failed, the client will be disconnected immediately Once the client is logged in commands can be sent to be run and responses can come back
[ "Authenticate", "to", "the", "server", "from", "Frontline", "documentation", ":", "Open", "a", "TCP", "/", "IP", "streaming", "socket", "to", "the", "remote", "console", "port", "of", "the", "server", "All", "commands", "sent", "and", "received", "are", "sep...
def login(self, challenge): """ Authenticate to the server from Frontline documentation : Open a TCP/IP streaming socket to the remote console port of the server All commands sent and received are separated with new line characters '\n' or 0x04 The server will send back a string (without the quotes): "WELCOME! Frontlines: Fuel of War (RCON) VER=2 CHALLENGE=38D384D07C" Note: Challenge string length is not fixed and will vary To generate a response use the MD5 algorithm to hash an ansi string: ResponseString = MD5Hash( ChallengeStringFromServer + Password ); The client will send this string to the server to login: "RESPONSE UserNameHere ResponseString" If the login was successful the client will receive: "Login Success!" If the login failed, the client will be disconnected immediately Once the client is logged in commands can be sent to be run and responses can come back """ self.console.info("logging to Frontline server with username %r" % self._username) hashed_password = md5.new("%s%s" % (challenge, self._password)).hexdigest() try: self.send('RESPONSE %s %s' % (self._username, hashed_password)) except socket.error, e: self.console.error(repr(e))
[ "def", "login", "(", "self", ",", "challenge", ")", ":", "self", ".", "console", ".", "info", "(", "\"logging to Frontline server with username %r\"", "%", "self", ".", "_username", ")", "hashed_password", "=", "md5", ".", "new", "(", "\"%s%s\"", "%", "(", "...
https://github.com/BigBrotherBot/big-brother-bot/blob/848823c71413c86e7f1ff9584f43e08d40a7f2c0/b3/parsers/frontline/protocol.py#L103-L136
machawk1/wail
199bd1bfbd5d1126f83b113ce5261c3312a7b9ef
bundledApps/WAIL.py
python
WAILStatusBar.__init__
(self, parent)
[]
def __init__(self, parent): wx.StatusBar.__init__(self, parent, -1) self.parent = parent self.SetFieldsCount(2) self.SetStatusWidths([-2, 30]) self.sb_button = wx.Button( self, wx.ID_ANY, "", style=wx.BU_EXACTFIT | wx.BORDER_NONE ) self.msg = '' self.sb_button.Bind(wx.EVT_BUTTON, self.press_button) self.reposition()
[ "def", "__init__", "(", "self", ",", "parent", ")", ":", "wx", ".", "StatusBar", ".", "__init__", "(", "self", ",", "parent", ",", "-", "1", ")", "self", ".", "parent", "=", "parent", "self", ".", "SetFieldsCount", "(", "2", ")", "self", ".", "SetS...
https://github.com/machawk1/wail/blob/199bd1bfbd5d1126f83b113ce5261c3312a7b9ef/bundledApps/WAIL.py#L2459-L2471
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/util.py
python
untilConcludes
(f, *a, **kw)
Call C{f} with the given arguments, handling C{EINTR} by retrying. @param f: A function to call. @param *a: Positional arguments to pass to C{f}. @param **kw: Keyword arguments to pass to C{f}. @return: Whatever C{f} returns. @raise: Whatever C{f} raises, except for C{IOError} or C{OSError} with C{errno} set to C{EINTR}.
Call C{f} with the given arguments, handling C{EINTR} by retrying.
[ "Call", "C", "{", "f", "}", "with", "the", "given", "arguments", "handling", "C", "{", "EINTR", "}", "by", "retrying", "." ]
def untilConcludes(f, *a, **kw): """ Call C{f} with the given arguments, handling C{EINTR} by retrying. @param f: A function to call. @param *a: Positional arguments to pass to C{f}. @param **kw: Keyword arguments to pass to C{f}. @return: Whatever C{f} returns. @raise: Whatever C{f} raises, except for C{IOError} or C{OSError} with C{errno} set to C{EINTR}. """ while True: try: return f(*a, **kw) except (IOError, OSError) as e: if e.args[0] == errno.EINTR: continue raise
[ "def", "untilConcludes", "(", "f", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "while", "True", ":", "try", ":", "return", "f", "(", "*", "a", ",", "*", "*", "kw", ")", "except", "(", "IOError", ",", "OSError", ")", "as", "e", ":", "if", ...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/util.py#L798-L819
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/django/contrib/gis/gdal/field.py
python
OFTInteger.type
(self)
return 0
GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal.
GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal.
[ "GDAL", "uses", "OFTReals", "to", "represent", "OFTIntegers", "in", "created", "shapefiles", "--", "forcing", "the", "type", "here", "since", "the", "underlying", "field", "type", "may", "actually", "be", "OFTReal", "." ]
def type(self): """ GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal. """ return 0
[ "def", "type", "(", "self", ")", ":", "return", "0" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/django/contrib/gis/gdal/field.py#L125-L131
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/musicbrainzngs/mbxml.py
python
parse_alias
(alias)
return result
[]
def parse_alias(alias): result = {} attribs = ["locale", "sort-name", "type", "primary", "begin-date", "end-date"] result.update(parse_attributes(attribs, alias)) result["alias"] = alias.text return result
[ "def", "parse_alias", "(", "alias", ")", ":", "result", "=", "{", "}", "attribs", "=", "[", "\"locale\"", ",", "\"sort-name\"", ",", "\"type\"", ",", "\"primary\"", ",", "\"begin-date\"", ",", "\"end-date\"", "]", "result", ".", "update", "(", "parse_attribu...
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/musicbrainzngs/mbxml.py#L735-L743
SpaceNetChallenge/SpaceNet_Off_Nadir_Solutions
014c4ca27a70b5907a183e942228004c989dcbe4
selim_sef/zoo/senet.py
python
SEBottleneck.__init__
(self, inplanes, planes, groups, reduction, stride=1, downsample=None)
[]
def __init__(self, inplanes, planes, groups, reduction, stride=1, downsample=None): super(SEBottleneck, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes * 2, kernel_size=1, bias=False) self.bn1 = BatchNorm2d(planes * 2) self.conv2 = nn.Conv2d(planes * 2, planes * 4, kernel_size=3, stride=stride, padding=1, groups=groups, bias=False) self.bn2 = BatchNorm2d(planes * 4) self.conv3 = nn.Conv2d(planes * 4, planes * 4, kernel_size=1, bias=False) self.bn3 = BatchNorm2d(planes * 4) self.relu = nn.ReLU(inplace=True) self.se_module = SEModule(planes * 4, reduction=reduction) self.downsample = downsample self.stride = stride
[ "def", "__init__", "(", "self", ",", "inplanes", ",", "planes", ",", "groups", ",", "reduction", ",", "stride", "=", "1", ",", "downsample", "=", "None", ")", ":", "super", "(", "SEBottleneck", ",", "self", ")", ".", "__init__", "(", ")", "self", "."...
https://github.com/SpaceNetChallenge/SpaceNet_Off_Nadir_Solutions/blob/014c4ca27a70b5907a183e942228004c989dcbe4/selim_sef/zoo/senet.py#L179-L194
hahwul/a2sv
cb24c4e8bd7c9f06eb74658039c20bbed4f8b2ef
module/M_heartbleed.py
python
parseresp
(s)
[]
def parseresp(s): while True: typ, ver, pay = recvmsg(s) if typ == None: zzzzz=1#showDisplay(displayMode,'Server closed connection without sending Server Hello.') return 0 # Look for server hello done message. if typ == 22 and ord(pay[0]) == 0x0E: return ver
[ "def", "parseresp", "(", "s", ")", ":", "while", "True", ":", "typ", ",", "ver", ",", "pay", "=", "recvmsg", "(", "s", ")", "if", "typ", "==", "None", ":", "zzzzz", "=", "1", "#showDisplay(displayMode,'Server closed connection without sending Server Hello.')", ...
https://github.com/hahwul/a2sv/blob/cb24c4e8bd7c9f06eb74658039c20bbed4f8b2ef/module/M_heartbleed.py#L134-L142
tweecode/twine
45e6350a2b813ec4282440b78f901cf377ead1a9
storyframe.py
python
StoryFrame.importFontDialog
(self, event=None)
Asks the user to choose a font file to import, then imports into the current story.
Asks the user to choose a font file to import, then imports into the current story.
[ "Asks", "the", "user", "to", "choose", "a", "font", "file", "to", "import", "then", "imports", "into", "the", "current", "story", "." ]
def importFontDialog(self, event=None): """Asks the user to choose a font file to import, then imports into the current story.""" dialog = wx.FileDialog(self, 'Import Font File', os.getcwd(), '', \ 'Web Font File (.ttf, .otf, .woff, .woff2, .svg)|*.ttf;*.otf;*.woff;*.woff2;*.svg|All Files (*.*)|*.*', wx.FD_OPEN | wx.FD_CHANGE_DIR) if dialog.ShowModal() == wx.ID_OK: self.importFont(dialog.GetPath())
[ "def", "importFontDialog", "(", "self", ",", "event", "=", "None", ")", ":", "dialog", "=", "wx", ".", "FileDialog", "(", "self", ",", "'Import Font File'", ",", "os", ".", "getcwd", "(", ")", ",", "''", ",", "'Web Font File (.ttf, .otf, .woff, .woff2, .svg)|*...
https://github.com/tweecode/twine/blob/45e6350a2b813ec4282440b78f901cf377ead1a9/storyframe.py#L706-L712
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/ex-submodules/pillowtop/reindexer/reindexer.py
python
ElasticPillowReindexer.__init__
(self, pillow_or_processor, change_provider, elasticsearch, index_info, in_place=False)
[]
def __init__(self, pillow_or_processor, change_provider, elasticsearch, index_info, in_place=False): super(ElasticPillowReindexer, self).__init__(pillow_or_processor, change_provider) self.es = elasticsearch self.index_info = index_info self.in_place = in_place
[ "def", "__init__", "(", "self", ",", "pillow_or_processor", ",", "change_provider", ",", "elasticsearch", ",", "index_info", ",", "in_place", "=", "False", ")", ":", "super", "(", "ElasticPillowReindexer", ",", "self", ")", ".", "__init__", "(", "pillow_or_proce...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/ex-submodules/pillowtop/reindexer/reindexer.py#L167-L171
tensorflow/benchmarks
16af178ad312e8c1213efb27a5f227044228bfdf
scripts/tf_cnn_benchmarks/variable_mgr.py
python
VariableMgr.create_outer_variable_scope
(self, device_num)
Create the tf.variable_scope around all model graph operations.
Create the tf.variable_scope around all model graph operations.
[ "Create", "the", "tf", ".", "variable_scope", "around", "all", "model", "graph", "operations", "." ]
def create_outer_variable_scope(self, device_num): """Create the tf.variable_scope around all model graph operations.""" del device_num # unused by this implementation assert False, 'Must be implemented in subclass'
[ "def", "create_outer_variable_scope", "(", "self", ",", "device_num", ")", ":", "del", "device_num", "# unused by this implementation", "assert", "False", ",", "'Must be implemented in subclass'" ]
https://github.com/tensorflow/benchmarks/blob/16af178ad312e8c1213efb27a5f227044228bfdf/scripts/tf_cnn_benchmarks/variable_mgr.py#L58-L61
caiiiac/Machine-Learning-with-Python
1a26c4467da41ca4ebc3d5bd789ea942ef79422f
MachineLearning/venv/lib/python3.5/site-packages/sklearn/svm/classes.py
python
LinearSVC.fit
(self, X, y, sample_weight=None)
return self
Fit the model according to the given training data. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Training vector, where n_samples in the number of samples and n_features is the number of features. y : array-like, shape = [n_samples] Target vector relative to X sample_weight : array-like, shape = [n_samples], optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- self : object Returns self.
Fit the model according to the given training data.
[ "Fit", "the", "model", "according", "to", "the", "given", "training", "data", "." ]
def fit(self, X, y, sample_weight=None): """Fit the model according to the given training data. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Training vector, where n_samples in the number of samples and n_features is the number of features. y : array-like, shape = [n_samples] Target vector relative to X sample_weight : array-like, shape = [n_samples], optional Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. Returns ------- self : object Returns self. """ # FIXME Remove l1/l2 support in 1.0 ----------------------------------- msg = ("loss='%s' has been deprecated in favor of " "loss='%s' as of 0.16. Backward compatibility" " for the loss='%s' will be removed in %s") if self.loss in ('l1', 'l2'): old_loss = self.loss self.loss = {'l1': 'hinge', 'l2': 'squared_hinge'}.get(self.loss) warnings.warn(msg % (old_loss, self.loss, old_loss, '1.0'), DeprecationWarning) # --------------------------------------------------------------------- if self.C < 0: raise ValueError("Penalty term must be positive; got (C=%r)" % self.C) X, y = check_X_y(X, y, accept_sparse='csr', dtype=np.float64, order="C") check_classification_targets(y) self.classes_ = np.unique(y) self.coef_, self.intercept_, self.n_iter_ = _fit_liblinear( X, y, self.C, self.fit_intercept, self.intercept_scaling, self.class_weight, self.penalty, self.dual, self.verbose, self.max_iter, self.tol, self.random_state, self.multi_class, self.loss, sample_weight=sample_weight) if self.multi_class == "crammer_singer" and len(self.classes_) == 2: self.coef_ = (self.coef_[1] - self.coef_[0]).reshape(1, -1) if self.fit_intercept: intercept = self.intercept_[1] - self.intercept_[0] self.intercept_ = np.array([intercept]) return self
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "sample_weight", "=", "None", ")", ":", "# FIXME Remove l1/l2 support in 1.0 -----------------------------------", "msg", "=", "(", "\"loss='%s' has been deprecated in favor of \"", "\"loss='%s' as of 0.16. Backward compatibil...
https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/sklearn/svm/classes.py#L168-L223
cuthbertLab/music21
bd30d4663e52955ed922c10fdf541419d8c67671
music21/meter/tools.py
python
slashMixedToFraction
(valueSrc: str)
return tuple(post), summedNumerator
Given a mixture if possible meter fraction representations, return a list of pairs. If originally given as a summed numerator; break into separate fractions and return True as the second element of the tuple >>> meter.tools.slashMixedToFraction('4/4') (((4, 4),), False) >>> meter.tools.slashMixedToFraction('3/8+2/8') (((3, 8), (2, 8)), False) >>> meter.tools.slashMixedToFraction('3+2/8') (((3, 8), (2, 8)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8') (((3, 8), (2, 8), (5, 8)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4') (((3, 8), (2, 8), (5, 8), (3, 4)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4+2+1+4/16') (((3, 8), (2, 8), (5, 8), (3, 4), (2, 16), (1, 16), (4, 16)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4+2+1+4') Traceback (most recent call last): music21.exceptions21.MeterException: cannot match denominator to numerator in: 3+2+5/8+3/4+2+1+4 >>> meter.tools.slashMixedToFraction('3.0/4.0') Traceback (most recent call last): music21.exceptions21.TimeSignatureException: Cannot create time signature from "3.0/4.0" Changed in v7 -- new location and returns a tuple as first value.
Given a mixture if possible meter fraction representations, return a list of pairs. If originally given as a summed numerator; break into separate fractions and return True as the second element of the tuple
[ "Given", "a", "mixture", "if", "possible", "meter", "fraction", "representations", "return", "a", "list", "of", "pairs", ".", "If", "originally", "given", "as", "a", "summed", "numerator", ";", "break", "into", "separate", "fractions", "and", "return", "True",...
def slashMixedToFraction(valueSrc: str) -> Tuple[NumDenomTuple, bool]: ''' Given a mixture if possible meter fraction representations, return a list of pairs. If originally given as a summed numerator; break into separate fractions and return True as the second element of the tuple >>> meter.tools.slashMixedToFraction('4/4') (((4, 4),), False) >>> meter.tools.slashMixedToFraction('3/8+2/8') (((3, 8), (2, 8)), False) >>> meter.tools.slashMixedToFraction('3+2/8') (((3, 8), (2, 8)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8') (((3, 8), (2, 8), (5, 8)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4') (((3, 8), (2, 8), (5, 8), (3, 4)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4+2+1+4/16') (((3, 8), (2, 8), (5, 8), (3, 4), (2, 16), (1, 16), (4, 16)), True) >>> meter.tools.slashMixedToFraction('3+2+5/8+3/4+2+1+4') Traceback (most recent call last): music21.exceptions21.MeterException: cannot match denominator to numerator in: 3+2+5/8+3/4+2+1+4 >>> meter.tools.slashMixedToFraction('3.0/4.0') Traceback (most recent call last): music21.exceptions21.TimeSignatureException: Cannot create time signature from "3.0/4.0" Changed in v7 -- new location and returns a tuple as first value. ''' pre = [] post = [] summedNumerator = False value = valueSrc.strip() # rem whitespace value = value.split('+') for part in value: if '/' in part: tup = slashToTuple(part) if tup is None: raise TimeSignatureException( f'Cannot create time signature from "{valueSrc}"') pre.append([tup.numerator, tup.denominator]) else: # its just a numerator try: pre.append([int(part), None]) except ValueError: raise Music21Exception( 'Cannot parse this file -- this error often comes ' + 'up if the musicxml pickled file is out of date after a change ' + 'in musicxml/__init__.py . ' + 'Clear your temp directory of .p and .p.gz files and try again...; ' + f'Time Signature: {valueSrc} ') # when encountering a missing denominator, find the first defined # and apply to all previous for i in range(len(pre)): if pre[i][1] is not None: # there is a denominator post.append(tuple(pre[i])) else: # search ahead for next defined denominator summedNumerator = True match = None for j in range(i, len(pre)): if pre[j][1] is not None: match = pre[j][1] break if match is None: raise MeterException(f'cannot match denominator to numerator in: {valueSrc}') pre[i][1] = match post.append(tuple(pre[i])) return tuple(post), summedNumerator
[ "def", "slashMixedToFraction", "(", "valueSrc", ":", "str", ")", "->", "Tuple", "[", "NumDenomTuple", ",", "bool", "]", ":", "pre", "=", "[", "]", "post", "=", "[", "]", "summedNumerator", "=", "False", "value", "=", "valueSrc", ".", "strip", "(", ")",...
https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/meter/tools.py#L98-L173
openstack/tempest
fe0ac89a5a1c43fa908a76759cd99eea3b1f9853
tempest/lib/services/placement/resource_providers_client.py
python
ResourceProvidersClient.list_resource_providers
(self, **params)
return rest_client.ResponseBody(resp, body)
List resource providers. For full list of available parameters, please refer to the official API reference: https://docs.openstack.org/api-ref/placement/#list-resource-providers
List resource providers.
[ "List", "resource", "providers", "." ]
def list_resource_providers(self, **params): """List resource providers. For full list of available parameters, please refer to the official API reference: https://docs.openstack.org/api-ref/placement/#list-resource-providers """ url = '/resource_providers' if params: url += '?%s' % urllib.urlencode(params) resp, body = self.get(url) self.expected_success(200, resp.status) body = json.loads(body) return rest_client.ResponseBody(resp, body)
[ "def", "list_resource_providers", "(", "self", ",", "*", "*", "params", ")", ":", "url", "=", "'/resource_providers'", "if", "params", ":", "url", "+=", "'?%s'", "%", "urllib", ".", "urlencode", "(", "params", ")", "resp", ",", "body", "=", "self", ".", ...
https://github.com/openstack/tempest/blob/fe0ac89a5a1c43fa908a76759cd99eea3b1f9853/tempest/lib/services/placement/resource_providers_client.py#L32-L45
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
ext/attr/_make.py
python
_ClassBuilder._patch_original_class
(self)
return cls
Apply accumulated methods and return the class.
Apply accumulated methods and return the class.
[ "Apply", "accumulated", "methods", "and", "return", "the", "class", "." ]
def _patch_original_class(self): """ Apply accumulated methods and return the class. """ cls = self._cls base_names = self._base_names # Clean class of attribute definitions (`attr.ib()`s). if self._delete_attribs: for name in self._attr_names: if ( name not in base_names and getattr(cls, name, None) is not None ): try: delattr(cls, name) except AttributeError: # This can happen if a base class defines a class # variable and we want to set an attribute with the # same name by using only a type annotation. pass # Attach our dunder methods. for name, value in self._cls_dict.items(): setattr(cls, name, value) return cls
[ "def", "_patch_original_class", "(", "self", ")", ":", "cls", "=", "self", ".", "_cls", "base_names", "=", "self", ".", "_base_names", "# Clean class of attribute definitions (`attr.ib()`s).", "if", "self", ".", "_delete_attribs", ":", "for", "name", "in", "self", ...
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/attr/_make.py#L507-L533
marcusva/py-sdl2
d549fc58de7aa204a119dc8dedef81b3cc888fb9
sdl2/ext/window.py
python
Window.refresh
(self)
Updates the window to reflect any changes made to its surface. .. note:: This only needs to be called if the window surface was acquired and modified using :meth:`get_surface`.
Updates the window to reflect any changes made to its surface.
[ "Updates", "the", "window", "to", "reflect", "any", "changes", "made", "to", "its", "surface", "." ]
def refresh(self): """Updates the window to reflect any changes made to its surface. .. note:: This only needs to be called if the window surface was acquired and modified using :meth:`get_surface`. """ video.SDL_UpdateWindowSurface(self.window)
[ "def", "refresh", "(", "self", ")", ":", "video", ".", "SDL_UpdateWindowSurface", "(", "self", ".", "window", ")" ]
https://github.com/marcusva/py-sdl2/blob/d549fc58de7aa204a119dc8dedef81b3cc888fb9/sdl2/ext/window.py#L215-L223
TryCatchHCF/DumpsterFire
43b46a274663ff694763db6e627975e160bc3597
FireModules/OSCommand/os_win_powershell_script.py
python
os_win_powershell_script.__init__
(self, moofStr)
return
[]
def __init__(self, moofStr): self.moofStr = moofStr self.commentsStr = "OSCommand/os_win_powershell_script" self.psScriptFilepathStr = "" return;
[ "def", "__init__", "(", "self", ",", "moofStr", ")", ":", "self", ".", "moofStr", "=", "moofStr", "self", ".", "commentsStr", "=", "\"OSCommand/os_win_powershell_script\"", "self", ".", "psScriptFilepathStr", "=", "\"\"", "return" ]
https://github.com/TryCatchHCF/DumpsterFire/blob/43b46a274663ff694763db6e627975e160bc3597/FireModules/OSCommand/os_win_powershell_script.py#L30-L34
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python3-alpha/python-libs/gdata/apps/emailsettings/client.py
python
EmailSettingsClient.update_imap
(self, username, enable, **kwargs)
return self.update(new_imap, **kwargs)
Update Google Mail IMAP settings. Args: username: string The name of the user. enable: Boolean Whether to enable IMAP access.language kwargs: The other parameters to pass to the update method. Returns: gdata.apps.emailsettings.data.EmailSettingsImap of the updated resource.
Update Google Mail IMAP settings. Args: username: string The name of the user. enable: Boolean Whether to enable IMAP access.language kwargs: The other parameters to pass to the update method.
[ "Update", "Google", "Mail", "IMAP", "settings", ".", "Args", ":", "username", ":", "string", "The", "name", "of", "the", "user", ".", "enable", ":", "Boolean", "Whether", "to", "enable", "IMAP", "access", ".", "language", "kwargs", ":", "The", "other", "...
def update_imap(self, username, enable, **kwargs): """Update Google Mail IMAP settings. Args: username: string The name of the user. enable: Boolean Whether to enable IMAP access.language kwargs: The other parameters to pass to the update method. Returns: gdata.apps.emailsettings.data.EmailSettingsImap of the updated resource. """ uri = self.MakeEmailSettingsUri(username=username, setting_id=SETTING_ID_IMAP) new_imap = gdata.apps.emailsettings.data.EmailSettingsImap( uri=uri, enable=enable) return self.update(new_imap, **kwargs)
[ "def", "update_imap", "(", "self", ",", "username", ",", "enable", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "self", ".", "MakeEmailSettingsUri", "(", "username", "=", "username", ",", "setting_id", "=", "SETTING_ID_IMAP", ")", "new_imap", "=", "gdata...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python3-alpha/python-libs/gdata/apps/emailsettings/client.py#L391-L406
JiYou/openstack
8607dd488bde0905044b303eb6e52bdea6806923
packages/source/cinder/cinder/image/glance.py
python
GlanceClientWrapper.call
(self, context, method, *args, **kwargs)
Call a glance client method. If we get a connection error, retry the request according to FLAGS.glance_num_retries.
Call a glance client method. If we get a connection error, retry the request according to FLAGS.glance_num_retries.
[ "Call", "a", "glance", "client", "method", ".", "If", "we", "get", "a", "connection", "error", "retry", "the", "request", "according", "to", "FLAGS", ".", "glance_num_retries", "." ]
def call(self, context, method, *args, **kwargs): """ Call a glance client method. If we get a connection error, retry the request according to FLAGS.glance_num_retries. """ version = self.version if version in kwargs: version = kwargs['version'] retry_excs = (glanceclient.exc.ServiceUnavailable, glanceclient.exc.InvalidEndpoint, glanceclient.exc.CommunicationError) num_attempts = 1 + FLAGS.glance_num_retries for attempt in xrange(1, num_attempts + 1): client = self.client or self._create_onetime_client(context, version) try: return getattr(client.images, method)(*args, **kwargs) except retry_excs as e: host = self.host port = self.port extra = "retrying" error_msg = _("Error contacting glance server " "'%(host)s:%(port)s' for '%(method)s', " "%(extra)s.") if attempt == num_attempts: extra = 'done trying' LOG.exception(error_msg, locals()) raise exception.GlanceConnectionFailed(host=host, port=port, reason=str(e)) LOG.exception(error_msg, locals()) time.sleep(1)
[ "def", "call", "(", "self", ",", "context", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "version", "=", "self", ".", "version", "if", "version", "in", "kwargs", ":", "version", "=", "kwargs", "[", "'version'", "]", "retry_excs...
https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/cinder/cinder/image/glance.py#L128-L161
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/conpono/create_pretrain_data/books_preproc_pipeline.py
python
books_pipeline
()
return pipeline
Read Books Corpus filenames and create Beam pipeline.
Read Books Corpus filenames and create Beam pipeline.
[ "Read", "Books", "Corpus", "filenames", "and", "create", "Beam", "pipeline", "." ]
def books_pipeline(): """Read Books Corpus filenames and create Beam pipeline.""" # set a random seed for reproducability rng = random.Random(FLAGS.random_seed) # BooksCorpus is organized into directories of genre and files of books # adventure-all.txt seems to contain all the adventure books in 1 file # romance-all.txt is the same. None of the other directories have this, # so we will skip it to not double count those books file_name_set = set() input_files_by_genre = collections.defaultdict(list) for path, _, fnames in tf.gfile.Walk(FLAGS.input_file): genre = path.split("/")[-1] for fname in fnames: if fname == "adventure-all.txt" or fname == "romance-all.txt": continue if fname in file_name_set: continue file_name_set.add(fname) input_files_by_genre[genre].append(path + "/" + fname) # Sort genres and iterate in order for reproducability train_files, dev_files, test_files = [], [], [] for genre, file_list in sorted(input_files_by_genre.items()): rng.shuffle(file_list) genre_size = len(file_list) test_size = int(FLAGS.test_size * genre_size) dev_size = int(FLAGS.dev_size * genre_size) test_files.extend(file_list[:test_size]) dev_files.extend(file_list[test_size:test_size + dev_size]) train_files.extend(file_list[test_size + dev_size:]) assert len(file_list[:test_size]) + \ len(file_list[test_size:test_size+dev_size]) + \ len(file_list[test_size+dev_size:]) == len(file_list) # make sure there is no test train overlap for filename in train_files: assert filename not in test_files assert filename not in dev_files for filename in dev_files: assert filename not in test_files rng.shuffle(train_files) rng.shuffle(dev_files) rng.shuffle(test_files) def pipeline(root): """Beam pipeline for converting Books Corpus files to TF Examples.""" _ = ( root | "Create test files" >> beam.Create(test_files) | "Read test files" >> beam.FlatMap(read_file) | "test Shuffle" >> beam.Reshuffle() | "Preproc test docs" >> beam.FlatMap(preproc_doc) | "record test Shuffle" >> beam.Reshuffle() | "Write to test tfrecord" >> beam.io.WriteToTFRecord( FLAGS.output_file + "." + FLAGS.format + ".test.tfrecord", num_shards=100)) _ = ( root | "Create dev files" >> beam.Create(dev_files) | "Read dev files" >> beam.FlatMap(read_file) | "dev Shuffle" >> beam.Reshuffle() | "Preproc dev docs" >> beam.FlatMap(preproc_doc) | "record dev Shuffle" >> beam.Reshuffle() | "Write to dev tfrecord" >> beam.io.WriteToTFRecord( FLAGS.output_file + "." + FLAGS.format + ".dev.tfrecord", num_shards=100)) _ = ( root | "Create train files" >> beam.Create(train_files) | "Read train files" >> beam.FlatMap(read_file) | "train Shuffle" >> beam.Reshuffle() | "Preproc train docs" >> beam.FlatMap(preproc_doc) | "record train Shuffle" >> beam.Reshuffle() | "Write to train tfrecord" >> beam.io.WriteToTFRecord( FLAGS.output_file + "." + FLAGS.format + ".train.tfrecord", num_shards=500)) return return pipeline
[ "def", "books_pipeline", "(", ")", ":", "# set a random seed for reproducability", "rng", "=", "random", ".", "Random", "(", "FLAGS", ".", "random_seed", ")", "# BooksCorpus is organized into directories of genre and files of books", "# adventure-all.txt seems to contain all the ad...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/conpono/create_pretrain_data/books_preproc_pipeline.py#L156-L234
oracle/oci-python-sdk
3c1604e4e212008fb6718e2f68cdb5ef71fd5793
examples/load_balancer_path_route_sets_example.py
python
create_vcn_and_subnets
(virtual_network, compartment_id, first_ad, second_ad)
return {'vcn': vcn, 'subnets': [subnet_one, subnet_two]}
[]
def create_vcn_and_subnets(virtual_network, compartment_id, first_ad, second_ad): # Create a VCN vcn_name = 'python_sdk_test_lb_vcn' cidr_block = "10.0.0.0/16" result = virtual_network.create_vcn( oci.core.models.CreateVcnDetails( cidr_block=cidr_block, display_name=vcn_name, compartment_id=compartment_id ) ) vcn = oci.wait_until( virtual_network, virtual_network.get_vcn(result.data.id), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300 ).data print('Created VCN') # Create a subnet subnet_name = 'python_sdk_test_lb_subnet1' subnet_cidr_block1 = "10.0.0.0/24" result = virtual_network.create_subnet( oci.core.models.CreateSubnetDetails( compartment_id=compartment_id, availability_domain=first_ad, display_name=subnet_name, vcn_id=vcn.id, cidr_block=subnet_cidr_block1 ) ) subnet_one = oci.wait_until( virtual_network, virtual_network.get_subnet(result.data.id), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300 ).data print('Created Subnet 1') # Create another subnet subnet_name = 'python_sdk_test_lb_subnet2' subnet_cidr_block2 = "10.0.1.0/24" result = virtual_network.create_subnet( oci.core.models.CreateSubnetDetails( compartment_id=compartment_id, availability_domain=second_ad, display_name=subnet_name, vcn_id=vcn.id, cidr_block=subnet_cidr_block2 ) ) subnet_two = oci.wait_until( virtual_network, virtual_network.get_subnet(result.data.id), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300 ).data print('Created Subnet 2') return {'vcn': vcn, 'subnets': [subnet_one, subnet_two]}
[ "def", "create_vcn_and_subnets", "(", "virtual_network", ",", "compartment_id", ",", "first_ad", ",", "second_ad", ")", ":", "# Create a VCN", "vcn_name", "=", "'python_sdk_test_lb_vcn'", "cidr_block", "=", "\"10.0.0.0/16\"", "result", "=", "virtual_network", ".", "crea...
https://github.com/oracle/oci-python-sdk/blob/3c1604e4e212008fb6718e2f68cdb5ef71fd5793/examples/load_balancer_path_route_sets_example.py#L23-L86
plaid/plaid-python
8c60fca608e426f3ff30da8857775946d29e122c
plaid/model/deductions.py
python
Deductions.__init__
(self, breakdown, total, *args, **kwargs)
Deductions - a model defined in OpenAPI Args: breakdown ([DeductionsBreakdown]): total (DeductionsTotal): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. Defaults to True _path_to_item (tuple/list): This is a list of keys or values to drill down to the model in received_data when deserializing a response _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. _visited_composed_classes (tuple): This stores a tuple of classes that we have traveled through so that if we see that class again we will not use its discriminator again. When traveling through a discriminator, the composed schema that is is traveled through is added to this set. For example if Animal has a discriminator petType and we pass in "Dog", and the class Dog allOf includes Animal, we move through Animal once using the discriminator, and pick Dog. Then in Dog, we will make an instance of the Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) subtotals ([Total]): [optional] # noqa: E501 totals ([Total]): [optional] # noqa: E501
Deductions - a model defined in OpenAPI
[ "Deductions", "-", "a", "model", "defined", "in", "OpenAPI" ]
def __init__(self, breakdown, total, *args, **kwargs): # noqa: E501 """Deductions - a model defined in OpenAPI Args: breakdown ([DeductionsBreakdown]): total (DeductionsTotal): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. Defaults to True _path_to_item (tuple/list): This is a list of keys or values to drill down to the model in received_data when deserializing a response _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. _visited_composed_classes (tuple): This stores a tuple of classes that we have traveled through so that if we see that class again we will not use its discriminator again. When traveling through a discriminator, the composed schema that is is traveled through is added to this set. For example if Animal has a discriminator petType and we pass in "Dog", and the class Dog allOf includes Animal, we move through Animal once using the discriminator, and pick Dog. Then in Dog, we will make an instance of the Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) subtotals ([Total]): [optional] # noqa: E501 totals ([Total]): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), path_to_item=_path_to_item, valid_classes=(self.__class__,), ) self._data_store = {} self._check_type = _check_type self._spec_property_naming = _spec_property_naming self._path_to_item = _path_to_item self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.breakdown = breakdown self.total = total for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value)
[ "def", "__init__", "(", "self", ",", "breakdown", ",", "total", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ...
https://github.com/plaid/plaid-python/blob/8c60fca608e426f3ff30da8857775946d29e122c/plaid/model/deductions.py#L119-L193
karanchahal/distiller
a17ec06cbeafcdd2aea19d7c7663033c951392f5
models/vision/inception.py
python
Inception3.forward
(self, x)
[]
def forward(self, x): x = self._transform_input(x) x, aux = self._forward(x) aux_defined = self.training and self.aux_logits if torch.jit.is_scripting(): if not aux_defined: warnings.warn("Scripted Inception3 always returns Inception3 Tuple") return InceptionOutputs(x, aux) else: return self.eager_outputs(x, aux)
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", "=", "self", ".", "_transform_input", "(", "x", ")", "x", ",", "aux", "=", "self", ".", "_forward", "(", "x", ")", "aux_defined", "=", "self", ".", "training", "and", "self", ".", "aux_logits"...
https://github.com/karanchahal/distiller/blob/a17ec06cbeafcdd2aea19d7c7663033c951392f5/models/vision/inception.py#L190-L199
alexmic/microtemplates
c45896b95bb577fdd831b54c7698e9856af7b170
microtemplates/base.py
python
_Variable.render
(self, context)
return resolve(self.name, context)
[]
def render(self, context): return resolve(self.name, context)
[ "def", "render", "(", "self", ",", "context", ")", ":", "return", "resolve", "(", "self", ".", "name", ",", "context", ")" ]
https://github.com/alexmic/microtemplates/blob/c45896b95bb577fdd831b54c7698e9856af7b170/microtemplates/base.py#L136-L137
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/scattergl/_error_y.py
python
ErrorY.array
(self)
return self["array"]
Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. The 'array' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray
Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. The 'array' property is an array that may be specified as a tuple, list, numpy array, or pandas Series
[ "Sets", "the", "data", "corresponding", "the", "length", "of", "each", "error", "bar", ".", "Values", "are", "plotted", "relative", "to", "the", "underlying", "data", ".", "The", "array", "property", "is", "an", "array", "that", "may", "be", "specified", "...
def array(self): """ Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. The 'array' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray """ return self["array"]
[ "def", "array", "(", "self", ")", ":", "return", "self", "[", "\"array\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/scattergl/_error_y.py#L31-L43
keiffster/program-y
8c99b56f8c32f01a7b9887b5daae9465619d0385
src/programy/parser/exceptions.py
python
MatcherException.__init__
(self, message)
[]
def __init__(self, message): Exception.__init__(self, message) self.message = message
[ "def", "__init__", "(", "self", ",", "message", ")", ":", "Exception", ".", "__init__", "(", "self", ",", "message", ")", "self", ".", "message", "=", "message" ]
https://github.com/keiffster/program-y/blob/8c99b56f8c32f01a7b9887b5daae9465619d0385/src/programy/parser/exceptions.py#L83-L85
carpedm20/LINE
501d1515cb84dc0c353ef33e345901de5bf5427c
line/client.py
python
LineClient.longPoll
(self, count=50, debug=False)
Receive a list of operations that have to be processed by original Line cleint. :param count: number of operations to get from :returns: a generator which returns operations >>> for op in client.longPoll(): sender = op[0] receiver = op[1] message = op[2] print "%s->%s : %s" % (sender, receiver, message)
Receive a list of operations that have to be processed by original Line cleint.
[ "Receive", "a", "list", "of", "operations", "that", "have", "to", "be", "processed", "by", "original", "Line", "cleint", "." ]
def longPoll(self, count=50, debug=False): """Receive a list of operations that have to be processed by original Line cleint. :param count: number of operations to get from :returns: a generator which returns operations >>> for op in client.longPoll(): sender = op[0] receiver = op[1] message = op[2] print "%s->%s : %s" % (sender, receiver, message) """ """Check is there any operations from LINE server""" OT = OperationType try: operations = self._fetchOperations(self.revision, count) except EOFError: return except TalkException as e: if e.code == 9: self.raise_error("user logged in to another machine") else: return for operation in operations: if debug: print operation if operation.type == OT.END_OF_OPERATION: pass elif operation.type == OT.SEND_MESSAGE: pass elif operation.type == OT.RECEIVE_MESSAGE: message = LineMessage(self, operation.message) raw_sender = operation.message._from raw_receiver = operation.message.to sender = self.getContactOrRoomOrGroupById(raw_sender) receiver = self.getContactOrRoomOrGroupById(raw_receiver) # If sender is not found, check member list of group chat sent to if sender is None: try: for m in receiver.members: if m.id == raw_sender: sender = m break except (AttributeError, TypeError): pass # If sender is not found, check member list of room chat sent to if sender is None: try: for m in receiver.contacts: if m.id == raw_sender: sender = m break except (AttributeError, TypeError): pass if sender is None or receiver is None: self.refreshGroups() self.refreshContacts() self.refreshActiveRooms() sender = self.getContactOrRoomOrGroupById(raw_sender) receiver = self.getContactOrRoomOrGroupById(raw_receiver) if sender is None or receiver is None: contacts = self._getContacts([raw_sender, raw_receiver]) if contacts: if len(contacts) == 2: sender = LineContact(self, contacts[0]) receiver = LineContact(self, contacts[1]) yield (sender, receiver, message) elif operation.type in [ 60, 61 ]: pass else: print "[*] %s" % OT._VALUES_TO_NAMES[operation.type] print operation self.revision = max(operation.revision, self.revision)
[ "def", "longPoll", "(", "self", ",", "count", "=", "50", ",", "debug", "=", "False", ")", ":", "\"\"\"Check is there any operations from LINE server\"\"\"", "OT", "=", "OperationType", "try", ":", "operations", "=", "self", ".", "_fetchOperations", "(", "self", ...
https://github.com/carpedm20/LINE/blob/501d1515cb84dc0c353ef33e345901de5bf5427c/line/client.py#L490-L574
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/mistune.py
python
InlineGrammar.hard_wrap
(self)
Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line.
Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line.
[ "Grammar", "for", "hard", "wrap", "linebreak", ".", "You", "don", "t", "need", "to", "add", "two", "spaces", "at", "the", "end", "of", "a", "line", "." ]
def hard_wrap(self): """Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line. """ self.linebreak = re.compile(r'^ *\n(?!\s*$)') self.text = re.compile( r'^[\s\S]+?(?=[\\<!\[_*`~]|https?://| *\n|$)' )
[ "def", "hard_wrap", "(", "self", ")", ":", "self", ".", "linebreak", "=", "re", ".", "compile", "(", "r'^ *\\n(?!\\s*$)'", ")", "self", ".", "text", "=", "re", ".", "compile", "(", "r'^[\\s\\S]+?(?=[\\\\<!\\[_*`~]|https?://| *\\n|$)'", ")" ]
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/mistune.py#L509-L516
wistbean/fxxkpython
88e16d79d8dd37236ba6ecd0d0ff11d63143968c
vip/qyxuan/projects/venv/lib/python3.6/site-packages/pygame/midi.py
python
Input.read
(self, num_events)
return self._input.Read(num_events)
reads num_events midi events from the buffer. Input.read(num_events): return midi_event_list Reads from the Input buffer and gives back midi events. [[[status,data1,data2,data3],timestamp], [[status,data1,data2,data3],timestamp],...]
reads num_events midi events from the buffer. Input.read(num_events): return midi_event_list
[ "reads", "num_events", "midi", "events", "from", "the", "buffer", ".", "Input", ".", "read", "(", "num_events", ")", ":", "return", "midi_event_list" ]
def read(self, num_events): """reads num_events midi events from the buffer. Input.read(num_events): return midi_event_list Reads from the Input buffer and gives back midi events. [[[status,data1,data2,data3],timestamp], [[status,data1,data2,data3],timestamp],...] """ _check_init() self._check_open() return self._input.Read(num_events)
[ "def", "read", "(", "self", ",", "num_events", ")", ":", "_check_init", "(", ")", "self", ".", "_check_open", "(", ")", "return", "self", ".", "_input", ".", "Read", "(", "num_events", ")" ]
https://github.com/wistbean/fxxkpython/blob/88e16d79d8dd37236ba6ecd0d0ff11d63143968c/vip/qyxuan/projects/venv/lib/python3.6/site-packages/pygame/midi.py#L315-L325
vincentbernat/snimpy
edfb4978fe3d1cbca15e98ebc1e0f009c613c9de
snimpy/mib.py
python
path
(path=None)
Set or get a search path to libsmi. When no path is provided, return the current path, unmodified. Otherwise, set the path to the specified value. :param path: The string to be used to change the search path or `None`
Set or get a search path to libsmi.
[ "Set", "or", "get", "a", "search", "path", "to", "libsmi", "." ]
def path(path=None): """Set or get a search path to libsmi. When no path is provided, return the current path, unmodified. Otherwise, set the path to the specified value. :param path: The string to be used to change the search path or `None` """ if path is None: # Get the path path = _smi.smiGetPath() if path == ffi.NULL: raise SMIException("unable to get current libsmi path") path = ffi.gc(path, _smi.free) result = ffi.string(path) return result.decode("utf8") # Set the path if not isinstance(path, bytes): path = path.encode("utf8") if _smi.smiSetPath(path) < 0: raise SMIException("unable to set the path {}".format(path))
[ "def", "path", "(", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "# Get the path", "path", "=", "_smi", ".", "smiGetPath", "(", ")", "if", "path", "==", "ffi", ".", "NULL", ":", "raise", "SMIException", "(", "\"unable to get current li...
https://github.com/vincentbernat/snimpy/blob/edfb4978fe3d1cbca15e98ebc1e0f009c613c9de/snimpy/mib.py#L477-L500
sympy/sympy
d822fcba181155b85ff2b29fe525adbafb22b448
sympy/liealgebras/type_e.py
python
TypeE.basic_root
(self, i, j)
return root
This is a method just to generate roots with a -1 in the ith position and a 1 in the jth position.
This is a method just to generate roots with a -1 in the ith position and a 1 in the jth position.
[ "This", "is", "a", "method", "just", "to", "generate", "roots", "with", "a", "-", "1", "in", "the", "ith", "position", "and", "a", "1", "in", "the", "jth", "position", "." ]
def basic_root(self, i, j): """ This is a method just to generate roots with a -1 in the ith position and a 1 in the jth position. """ root = [0]*8 root[i] = -1 root[j] = 1 return root
[ "def", "basic_root", "(", "self", ",", "i", ",", "j", ")", ":", "root", "=", "[", "0", "]", "*", "8", "root", "[", "i", "]", "=", "-", "1", "root", "[", "j", "]", "=", "1", "return", "root" ]
https://github.com/sympy/sympy/blob/d822fcba181155b85ff2b29fe525adbafb22b448/sympy/liealgebras/type_e.py#L26-L37
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/layout/polar/_radialaxis.py
python
RadialAxis.ticksuffix
(self)
return self["ticksuffix"]
Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string
[ "Sets", "a", "tick", "label", "suffix", ".", "The", "ticksuffix", "property", "is", "a", "string", "and", "must", "be", "specified", "as", ":", "-", "A", "string", "-", "A", "number", "that", "will", "be", "converted", "to", "a", "string" ]
def ticksuffix(self): """ Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["ticksuffix"]
[ "def", "ticksuffix", "(", "self", ")", ":", "return", "self", "[", "\"ticksuffix\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/polar/_radialaxis.py#L1222-L1234
NVIDIA/NeMo
5b0c0b4dec12d87d3cd960846de4105309ce938e
nemo/collections/asr/parts/submodules/conformer_modules.py
python
ConformerLayer.forward
(self, x, att_mask=None, pos_emb=None, pad_mask=None)
return x
Args: x (torch.Tensor): input signals (B, T, d_model) att_mask (torch.Tensor): attention masks(B, T, T) pos_emb (torch.Tensor): (L, 1, d_model) pad_mask (torch.tensor): padding mask Returns: x (torch.Tensor): (B, T, d_model)
Args: x (torch.Tensor): input signals (B, T, d_model) att_mask (torch.Tensor): attention masks(B, T, T) pos_emb (torch.Tensor): (L, 1, d_model) pad_mask (torch.tensor): padding mask Returns: x (torch.Tensor): (B, T, d_model)
[ "Args", ":", "x", "(", "torch", ".", "Tensor", ")", ":", "input", "signals", "(", "B", "T", "d_model", ")", "att_mask", "(", "torch", ".", "Tensor", ")", ":", "attention", "masks", "(", "B", "T", "T", ")", "pos_emb", "(", "torch", ".", "Tensor", ...
def forward(self, x, att_mask=None, pos_emb=None, pad_mask=None): """ Args: x (torch.Tensor): input signals (B, T, d_model) att_mask (torch.Tensor): attention masks(B, T, T) pos_emb (torch.Tensor): (L, 1, d_model) pad_mask (torch.tensor): padding mask Returns: x (torch.Tensor): (B, T, d_model) """ residual = x x = self.norm_feed_forward1(x) x = self.feed_forward1(x) x = self.fc_factor * self.dropout(x) + residual residual = x x = self.norm_self_att(x) if self.self_attention_model == 'rel_pos': x = self.self_attn(query=x, key=x, value=x, mask=att_mask, pos_emb=pos_emb) elif self.self_attention_model == 'abs_pos': x = self.self_attn(query=x, key=x, value=x, mask=att_mask) else: x = None x = self.dropout(x) + residual residual = x x = self.norm_conv(x) x = self.conv(x, pad_mask) x = self.dropout(x) + residual residual = x x = self.norm_feed_forward2(x) x = self.feed_forward2(x) x = self.fc_factor * self.dropout(x) + residual x = self.norm_out(x) return x
[ "def", "forward", "(", "self", ",", "x", ",", "att_mask", "=", "None", ",", "pos_emb", "=", "None", ",", "pad_mask", "=", "None", ")", ":", "residual", "=", "x", "x", "=", "self", ".", "norm_feed_forward1", "(", "x", ")", "x", "=", "self", ".", "...
https://github.com/NVIDIA/NeMo/blob/5b0c0b4dec12d87d3cd960846de4105309ce938e/nemo/collections/asr/parts/submodules/conformer_modules.py#L87-L123
deepmind/dm_control
806a10e896e7c887635328bfa8352604ad0fedae
dm_control/suite/dog.py
python
Physics.joint_velocities
(self)
return self.data.qvel[qvel_index].copy()
Returns the velocity of all hinge joints (skipping free joints).
Returns the velocity of all hinge joints (skipping free joints).
[ "Returns", "the", "velocity", "of", "all", "hinge", "joints", "(", "skipping", "free", "joints", ")", "." ]
def joint_velocities(self): """Returns the velocity of all hinge joints (skipping free joints).""" hinge_joints = self.model.jnt_type == _HINGE_TYPE qvel_index = self.model.jnt_dofadr[hinge_joints] return self.data.qvel[qvel_index].copy()
[ "def", "joint_velocities", "(", "self", ")", ":", "hinge_joints", "=", "self", ".", "model", ".", "jnt_type", "==", "_HINGE_TYPE", "qvel_index", "=", "self", ".", "model", ".", "jnt_dofadr", "[", "hinge_joints", "]", "return", "self", ".", "data", ".", "qv...
https://github.com/deepmind/dm_control/blob/806a10e896e7c887635328bfa8352604ad0fedae/dm_control/suite/dog.py#L195-L199
qiucheng025/zao-
3a5edf3607b3a523f95746bc69b688090c76d89a
tools/sort.py
python
Sort.splice_lists
(sorted_list, new_vals_list)
return new_list
This method replaces the value at index 1 in each sub-list in the sorted_list with the value that is calculated for the same img_path, but found in new_vals_list. Format of lists: [[img_path, value], [img_path2, value2], ...] :param sorted_list: list that has been sorted by one of the sort methods. :param new_vals_list: list that has been loaded by a different method than the sorted_list. :return: list that is sorted in the same way as the input sorted list but the values corresponding to each image are from new_vals_list.
This method replaces the value at index 1 in each sub-list in the sorted_list with the value that is calculated for the same img_path, but found in new_vals_list.
[ "This", "method", "replaces", "the", "value", "at", "index", "1", "in", "each", "sub", "-", "list", "in", "the", "sorted_list", "with", "the", "value", "that", "is", "calculated", "for", "the", "same", "img_path", "but", "found", "in", "new_vals_list", "."...
def splice_lists(sorted_list, new_vals_list): """ This method replaces the value at index 1 in each sub-list in the sorted_list with the value that is calculated for the same img_path, but found in new_vals_list. Format of lists: [[img_path, value], [img_path2, value2], ...] :param sorted_list: list that has been sorted by one of the sort methods. :param new_vals_list: list that has been loaded by a different method than the sorted_list. :return: list that is sorted in the same way as the input sorted list but the values corresponding to each image are from new_vals_list. """ new_list = [] # Make new list of just image paths to serve as an index val_index_list = [i[0] for i in new_vals_list] for i in tqdm(range(len(sorted_list)), desc="Splicing", file=sys.stdout): current_img = sorted_list[i] if isinstance(sorted_list[i], str) else sorted_list[i][0] new_val_index = val_index_list.index(current_img) new_list.append([current_img, new_vals_list[new_val_index][1]]) return new_list
[ "def", "splice_lists", "(", "sorted_list", ",", "new_vals_list", ")", ":", "new_list", "=", "[", "]", "# Make new list of just image paths to serve as an index", "val_index_list", "=", "[", "i", "[", "0", "]", "for", "i", "in", "new_vals_list", "]", "for", "i", ...
https://github.com/qiucheng025/zao-/blob/3a5edf3607b3a523f95746bc69b688090c76d89a/tools/sort.py#L616-L641
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/models/roformer/modeling_flax_roformer.py
python
FlaxRoFormerOnlyMLMHead.__call__
(self, hidden_states, shared_embedding=None)
return hidden_states
[]
def __call__(self, hidden_states, shared_embedding=None): hidden_states = self.predictions(hidden_states, shared_embedding=shared_embedding) return hidden_states
[ "def", "__call__", "(", "self", ",", "hidden_states", ",", "shared_embedding", "=", "None", ")", ":", "hidden_states", "=", "self", ".", "predictions", "(", "hidden_states", ",", "shared_embedding", "=", "shared_embedding", ")", "return", "hidden_states" ]
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/roformer/modeling_flax_roformer.py#L576-L578
rspivak/lsbasi
07e1a14516156a21ebe2d82e0bae4bba5ad73dd6
part4/calc4.py
python
Token.__str__
(self)
return 'Token({type}, {value})'.format( type=self.type, value=repr(self.value) )
String representation of the class instance. Examples: Token(INTEGER, 3) Token(MUL, '*')
String representation of the class instance.
[ "String", "representation", "of", "the", "class", "instance", "." ]
def __str__(self): """String representation of the class instance. Examples: Token(INTEGER, 3) Token(MUL, '*') """ return 'Token({type}, {value})'.format( type=self.type, value=repr(self.value) )
[ "def", "__str__", "(", "self", ")", ":", "return", "'Token({type}, {value})'", ".", "format", "(", "type", "=", "self", ".", "type", ",", "value", "=", "repr", "(", "self", ".", "value", ")", ")" ]
https://github.com/rspivak/lsbasi/blob/07e1a14516156a21ebe2d82e0bae4bba5ad73dd6/part4/calc4.py#L15-L25
Lotayou/everybody_dance_now_pytorch
41144e9b5a47d70d0fe9101ca6c748ecded27fd1
util/util.py
python
uint82bin
(n, count=8)
return ''.join([str((n >> y) & 1) for y in range(count-1, -1, -1)])
returns the binary of integer n, count refers to amount of bits
returns the binary of integer n, count refers to amount of bits
[ "returns", "the", "binary", "of", "integer", "n", "count", "refers", "to", "amount", "of", "bits" ]
def uint82bin(n, count=8): """returns the binary of integer n, count refers to amount of bits""" return ''.join([str((n >> y) & 1) for y in range(count-1, -1, -1)])
[ "def", "uint82bin", "(", "n", ",", "count", "=", "8", ")", ":", "return", "''", ".", "join", "(", "[", "str", "(", "(", "n", ">>", "y", ")", "&", "1", ")", "for", "y", "in", "range", "(", "count", "-", "1", ",", "-", "1", ",", "-", "1", ...
https://github.com/Lotayou/everybody_dance_now_pytorch/blob/41144e9b5a47d70d0fe9101ca6c748ecded27fd1/util/util.py#L57-L59
RasaHQ/rasa
54823b68c1297849ba7ae841a4246193cd1223a1
rasa/core/processor.py
python
MessageProcessor.get_tracker
(self, conversation_id: Text)
return tracker
Get the tracker for a conversation. In contrast to `fetch_tracker_and_update_session` this does not add any `action_session_start` or `session_start` events at the beginning of a conversation. Args: conversation_id: The ID of the conversation for which the history should be retrieved. Returns: Tracker for the conversation. Creates an empty tracker in case it's a new conversation.
Get the tracker for a conversation.
[ "Get", "the", "tracker", "for", "a", "conversation", "." ]
def get_tracker(self, conversation_id: Text) -> DialogueStateTracker: """Get the tracker for a conversation. In contrast to `fetch_tracker_and_update_session` this does not add any `action_session_start` or `session_start` events at the beginning of a conversation. Args: conversation_id: The ID of the conversation for which the history should be retrieved. Returns: Tracker for the conversation. Creates an empty tracker in case it's a new conversation. """ conversation_id = conversation_id or DEFAULT_SENDER_ID tracker = self.tracker_store.get_or_create_tracker( conversation_id, append_action_listen=False ) tracker.model_id = self.model_metadata.model_id return tracker
[ "def", "get_tracker", "(", "self", ",", "conversation_id", ":", "Text", ")", "->", "DialogueStateTracker", ":", "conversation_id", "=", "conversation_id", "or", "DEFAULT_SENDER_ID", "tracker", "=", "self", ".", "tracker_store", ".", "get_or_create_tracker", "(", "co...
https://github.com/RasaHQ/rasa/blob/54823b68c1297849ba7ae841a4246193cd1223a1/rasa/core/processor.py#L326-L347
Esri/ArcREST
ab240fde2b0200f61d4a5f6df033516e53f2f416
src/arcrest/manageorg/_parameters.py
python
PublishCSVParameters.description
(self, value)
gets/sets the description
gets/sets the description
[ "gets", "/", "sets", "the", "description" ]
def description(self, value): """ gets/sets the description """ if self._description != value: self._description = value
[ "def", "description", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_description", "!=", "value", ":", "self", ".", "_description", "=", "value" ]
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L1878-L1881
openelections/openelections-core
3c516d8c4cf1166b1868b738a248d48f3378c525
openelex/us/vt/transform/transforms.py
python
CreateResultsTransform.get_candidate
(self, raw_resultDict, extra={})
Get the Candidate model for a RawResult Keyword arguments: * extra - Dictionary of extra query parameters that will be used to select the candidate.
Get the Candidate model for a RawResult
[ "Get", "the", "Candidate", "model", "for", "a", "RawResult" ]
def get_candidate(self, raw_resultDict, extra={}): """ Get the Candidate model for a RawResult Keyword arguments: * extra - Dictionary of extra query parameters that will be used to select the candidate. """ key = self._candidate_key(raw_resultDict) try: return self._candidate_cache[key] except KeyError: fields = self.get_candidate_fields(raw_resultDict) fields.update(extra) del fields['source'] try: print(fields) candidate = Candidate.objects.get(**fields) except Candidate.DoesNotExist: print(fields) raise self._candidate_cache[key] = candidate return candidate
[ "def", "get_candidate", "(", "self", ",", "raw_resultDict", ",", "extra", "=", "{", "}", ")", ":", "key", "=", "self", ".", "_candidate_key", "(", "raw_resultDict", ")", "try", ":", "return", "self", ".", "_candidate_cache", "[", "key", "]", "except", "K...
https://github.com/openelections/openelections-core/blob/3c516d8c4cf1166b1868b738a248d48f3378c525/openelex/us/vt/transform/transforms.py#L449-L472
pycollada/pycollada
5b2d53333f03047b0fdfc25e394f8b77b57b62fc
collada/material.py
python
Material.__init__
(self, id, name, effect, xmlnode=None)
Creates a material. :param str id: A unique string identifier for the material :param str name: A name for the material :param collada.material.Effect effect: The effect instantiated in this material :param xmlnode: If loaded from xml, the xml node
Creates a material.
[ "Creates", "a", "material", "." ]
def __init__(self, id, name, effect, xmlnode=None): """Creates a material. :param str id: A unique string identifier for the material :param str name: A name for the material :param collada.material.Effect effect: The effect instantiated in this material :param xmlnode: If loaded from xml, the xml node """ self.id = id """The unique string identifier for the material""" self.name = name """The name for the material""" self.effect = effect """The :class:`collada.material.Effect` instantiated in this material""" if xmlnode != None: self.xmlnode = xmlnode """ElementTree representation of the surface.""" else: self.xmlnode = E.material( E.instance_effect(url="#%s" % self.effect.id) , id=str(self.id), name=str(self.name))
[ "def", "__init__", "(", "self", ",", "id", ",", "name", ",", "effect", ",", "xmlnode", "=", "None", ")", ":", "self", ".", "id", "=", "id", "\"\"\"The unique string identifier for the material\"\"\"", "self", ".", "name", "=", "name", "\"\"\"The name for the mat...
https://github.com/pycollada/pycollada/blob/5b2d53333f03047b0fdfc25e394f8b77b57b62fc/collada/material.py#L831-L858
pydata/xarray
9226c7ac87b3eb246f7a7e49f8f0f23d68951624
xarray/core/dataarray.py
python
DataArray.swap_dims
( self, dims_dict: Mapping[Any, Hashable] = None, **dims_kwargs )
return self._from_temp_dataset(ds)
Returns a new DataArray with swapped dimensions. Parameters ---------- dims_dict : dict-like Dictionary whose keys are current dimension names and whose values are new names. **dims_kwargs : {existing_dim: new_dim, ...}, optional The keyword arguments form of ``dims_dict``. One of dims_dict or dims_kwargs must be provided. Returns ------- swapped : DataArray DataArray with swapped dimensions. Examples -------- >>> arr = xr.DataArray( ... data=[0, 1], ... dims="x", ... coords={"x": ["a", "b"], "y": ("x", [0, 1])}, ... ) >>> arr <xarray.DataArray (x: 2)> array([0, 1]) Coordinates: * x (x) <U1 'a' 'b' y (x) int64 0 1 >>> arr.swap_dims({"x": "y"}) <xarray.DataArray (y: 2)> array([0, 1]) Coordinates: x (y) <U1 'a' 'b' * y (y) int64 0 1 >>> arr.swap_dims({"x": "z"}) <xarray.DataArray (z: 2)> array([0, 1]) Coordinates: x (z) <U1 'a' 'b' y (z) int64 0 1 Dimensions without coordinates: z See Also -------- DataArray.rename Dataset.swap_dims
Returns a new DataArray with swapped dimensions.
[ "Returns", "a", "new", "DataArray", "with", "swapped", "dimensions", "." ]
def swap_dims( self, dims_dict: Mapping[Any, Hashable] = None, **dims_kwargs ) -> "DataArray": """Returns a new DataArray with swapped dimensions. Parameters ---------- dims_dict : dict-like Dictionary whose keys are current dimension names and whose values are new names. **dims_kwargs : {existing_dim: new_dim, ...}, optional The keyword arguments form of ``dims_dict``. One of dims_dict or dims_kwargs must be provided. Returns ------- swapped : DataArray DataArray with swapped dimensions. Examples -------- >>> arr = xr.DataArray( ... data=[0, 1], ... dims="x", ... coords={"x": ["a", "b"], "y": ("x", [0, 1])}, ... ) >>> arr <xarray.DataArray (x: 2)> array([0, 1]) Coordinates: * x (x) <U1 'a' 'b' y (x) int64 0 1 >>> arr.swap_dims({"x": "y"}) <xarray.DataArray (y: 2)> array([0, 1]) Coordinates: x (y) <U1 'a' 'b' * y (y) int64 0 1 >>> arr.swap_dims({"x": "z"}) <xarray.DataArray (z: 2)> array([0, 1]) Coordinates: x (z) <U1 'a' 'b' y (z) int64 0 1 Dimensions without coordinates: z See Also -------- DataArray.rename Dataset.swap_dims """ dims_dict = either_dict_or_kwargs(dims_dict, dims_kwargs, "swap_dims") ds = self._to_temp_dataset().swap_dims(dims_dict) return self._from_temp_dataset(ds)
[ "def", "swap_dims", "(", "self", ",", "dims_dict", ":", "Mapping", "[", "Any", ",", "Hashable", "]", "=", "None", ",", "*", "*", "dims_kwargs", ")", "->", "\"DataArray\"", ":", "dims_dict", "=", "either_dict_or_kwargs", "(", "dims_dict", ",", "dims_kwargs", ...
https://github.com/pydata/xarray/blob/9226c7ac87b3eb246f7a7e49f8f0f23d68951624/xarray/core/dataarray.py#L1853-L1908
scikit-learn-contrib/lightning
3afcb4a9967a0d9e3961acd967705e42a593e448
lightning/impl/datasets/samples_generator.py
python
make_classification
(n_samples=100, n_features=20, n_informative=2, n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None)
return X, y
Generate a random n-class classification problem. Parameters ---------- n_samples : int, optional (default=100) The number of samples. n_features : int, optional (default=20) The total number of features. These comprise `n_informative` informative features, `n_redundant` redundant features, `n_repeated` duplicated features and `n_features-n_informative-n_redundant- n_repeated` useless features drawn at random. n_informative : int, optional (default=2) The number of informative features. Each class is composed of a number of gaussian clusters each located around the vertices of a hypercube in a subspace of dimension `n_informative`. For each cluster, informative features are drawn independently from N(0, 1) and then randomly linearly combined in order to add covariance. The clusters are then placed on the vertices of the hypercube. n_redundant : int, optional (default=2) The number of redundant features. These features are generated as random linear combinations of the informative features. n_repeated : int, optional (default=2) The number of duplicated features, drawn randomly from the informative and the redundant features. n_classes : int, optional (default=2) The number of classes (or labels) of the classification problem. n_clusters_per_class : int, optional (default=2) The number of clusters per class. weights : list of floats or None (default=None) The proportions of samples assigned to each class. If None, then classes are balanced. Note that if `len(weights) == n_classes - 1`, then the last class weight is automatically inferred. flip_y : float, optional (default=0.01) The fraction of samples whose class are randomly exchanged. class_sep : float, optional (default=1.0) The factor multiplying the hypercube dimension. hypercube : boolean, optional (default=True) If True, the clusters are put on the vertices of a hypercube. If False, the clusters are put on the vertices of a random polytope. shift : float or None, optional (default=0.0) Shift all features by the specified value. If None, then features are shifted by a random value drawn in [-class_sep, class_sep]. scale : float or None, optional (default=1.0) Multiply all features by the specified value. If None, then features are scaled by a random value drawn in [1, 100]. Note that scaling happens after shifting. shuffle : boolean, optional (default=True) Shuffle the samples and the features. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`. Returns ------- X : array of shape [n_samples, n_features] The generated samples. y : array of shape [n_samples] The integer labels for class membership of each sample. Notes ----- The algorithm is adapted from Guyon [1] and was designed to generate the "Madelon" dataset. References ---------- .. [1] I. Guyon, "Design of experiments for the NIPS 2003 variable selection benchmark", 2003.
Generate a random n-class classification problem.
[ "Generate", "a", "random", "n", "-", "class", "classification", "problem", "." ]
def make_classification(n_samples=100, n_features=20, n_informative=2, n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None): """Generate a random n-class classification problem. Parameters ---------- n_samples : int, optional (default=100) The number of samples. n_features : int, optional (default=20) The total number of features. These comprise `n_informative` informative features, `n_redundant` redundant features, `n_repeated` duplicated features and `n_features-n_informative-n_redundant- n_repeated` useless features drawn at random. n_informative : int, optional (default=2) The number of informative features. Each class is composed of a number of gaussian clusters each located around the vertices of a hypercube in a subspace of dimension `n_informative`. For each cluster, informative features are drawn independently from N(0, 1) and then randomly linearly combined in order to add covariance. The clusters are then placed on the vertices of the hypercube. n_redundant : int, optional (default=2) The number of redundant features. These features are generated as random linear combinations of the informative features. n_repeated : int, optional (default=2) The number of duplicated features, drawn randomly from the informative and the redundant features. n_classes : int, optional (default=2) The number of classes (or labels) of the classification problem. n_clusters_per_class : int, optional (default=2) The number of clusters per class. weights : list of floats or None (default=None) The proportions of samples assigned to each class. If None, then classes are balanced. Note that if `len(weights) == n_classes - 1`, then the last class weight is automatically inferred. flip_y : float, optional (default=0.01) The fraction of samples whose class are randomly exchanged. class_sep : float, optional (default=1.0) The factor multiplying the hypercube dimension. hypercube : boolean, optional (default=True) If True, the clusters are put on the vertices of a hypercube. If False, the clusters are put on the vertices of a random polytope. shift : float or None, optional (default=0.0) Shift all features by the specified value. If None, then features are shifted by a random value drawn in [-class_sep, class_sep]. scale : float or None, optional (default=1.0) Multiply all features by the specified value. If None, then features are scaled by a random value drawn in [1, 100]. Note that scaling happens after shifting. shuffle : boolean, optional (default=True) Shuffle the samples and the features. random_state : int, RandomState instance or None, optional (default=None) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`. Returns ------- X : array of shape [n_samples, n_features] The generated samples. y : array of shape [n_samples] The integer labels for class membership of each sample. Notes ----- The algorithm is adapted from Guyon [1] and was designed to generate the "Madelon" dataset. References ---------- .. [1] I. Guyon, "Design of experiments for the NIPS 2003 variable selection benchmark", 2003. """ generator = check_random_state(random_state) # Count features, clusters and samples if n_informative + n_redundant + n_repeated > n_features: raise ValueError("Number of informative, redundant and repeated " "features must sum to less than the number of total" " features") if 2 ** n_informative < n_classes * n_clusters_per_class: raise ValueError("n_classes * n_clusters_per_class must" " be smaller or equal 2 ** n_informative") if weights and len(weights) not in [n_classes, n_classes - 1]: raise ValueError("Weights specified but incompatible with number " "of classes.") n_useless = n_features - n_informative - n_redundant - n_repeated n_clusters = n_classes * n_clusters_per_class if weights and len(weights) == (n_classes - 1): weights.append(1.0 - sum(weights)) if weights is None: weights = [1.0 / n_classes] * n_classes weights[-1] = 1.0 - sum(weights[:-1]) n_samples_per_cluster = [] for k in range(n_clusters): n_samples_per_cluster.append(int(n_samples * weights[k % n_classes] / n_clusters_per_class)) for i in range(n_samples - sum(n_samples_per_cluster)): n_samples_per_cluster[i % n_clusters] += 1 # Intialize X and y X = np.zeros((n_samples, n_features)) y = np.zeros(n_samples, dtype=int) # Build the polytope C = np.array(list(product([-class_sep, class_sep], repeat=n_informative))) generator.shuffle(C) if not hypercube: C[:n_clusters] *= generator.rand(n_clusters, 1) C *= generator.rand(1, n_informative) # Loop over all clusters pos = 0 pos_end = 0 for k in range(n_clusters): # Number of samples in cluster k n_samples_k = n_samples_per_cluster[k] # Define the range of samples pos = pos_end pos_end = pos + n_samples_k # Assign labels y[pos:pos_end] = k % n_classes # Draw features at random X[pos:pos_end, :n_informative] = generator.randn(n_samples_k, n_informative) # Multiply by a random matrix to create co-variance of the features A = 2 * generator.rand(n_informative, n_informative) - 1 X[pos:pos_end, :n_informative] = np.dot(X[pos:pos_end, :n_informative], A) # Shift the cluster to a vertice X[pos:pos_end, :n_informative] += np.tile(C[k, :], (n_samples_k, 1)) # Create redundant features if n_redundant > 0: B = 2 * generator.rand(n_informative, n_redundant) - 1 X[:, n_informative:n_informative + n_redundant] = \ np.dot(X[:, :n_informative], B) # Repeat some features if n_repeated > 0: n = n_informative + n_redundant indices = ((n - 1) * generator.rand(n_repeated) + 0.5).astype(np.intp) X[:, n:n + n_repeated] = X[:, indices] # Fill useless features X[:, n_features - n_useless:] = generator.randn(n_samples, n_useless) # Randomly flip labels if flip_y >= 0.0: for i in range(n_samples): if generator.rand() < flip_y: y[i] = generator.randint(n_classes) # Randomly shift and scale constant_shift = shift is not None constant_scale = scale is not None for f in range(n_features): if not constant_shift: shift = (2 * generator.rand() - 1) * class_sep if not constant_scale: scale = 1 + 100 * generator.rand() X[:, f] += shift X[:, f] *= scale # Randomly permute samples and features if shuffle: X, y = shuffle_func(X, y, random_state=generator) indices = np.arange(n_features) generator.shuffle(indices) X[:, :] = X[:, indices] return X, y
[ "def", "make_classification", "(", "n_samples", "=", "100", ",", "n_features", "=", "20", ",", "n_informative", "=", "2", ",", "n_redundant", "=", "2", ",", "n_repeated", "=", "0", ",", "n_classes", "=", "2", ",", "n_clusters_per_class", "=", "2", ",", "...
https://github.com/scikit-learn-contrib/lightning/blob/3afcb4a9967a0d9e3961acd967705e42a593e448/lightning/impl/datasets/samples_generator.py#L108-L315
LabPy/lantz
3e878e3f765a4295b0089d04e241d4beb7b8a65b
lantz/action.py
python
_dget
(adict, instance=MISSING)
Helper function to get an element by key from a dictionary defaulting to key=MISSING
Helper function to get an element by key from a dictionary defaulting to key=MISSING
[ "Helper", "function", "to", "get", "an", "element", "by", "key", "from", "a", "dictionary", "defaulting", "to", "key", "=", "MISSING" ]
def _dget(adict, instance=MISSING): """Helper function to get an element by key from a dictionary defaulting to key=MISSING """ try: return adict[instance] except KeyError: return adict[MISSING]
[ "def", "_dget", "(", "adict", ",", "instance", "=", "MISSING", ")", ":", "try", ":", "return", "adict", "[", "instance", "]", "except", "KeyError", ":", "return", "adict", "[", "MISSING", "]" ]
https://github.com/LabPy/lantz/blob/3e878e3f765a4295b0089d04e241d4beb7b8a65b/lantz/action.py#L26-L34
linnanwang/AlphaX-NASBench101
87eb0d403def6dee43be7eb73520de074a2f9f03
alphax-1-net/model.py
python
AuxiliaryHeadCIFAR.__init__
(self, C, num_classes)
assuming input size 8x8
assuming input size 8x8
[ "assuming", "input", "size", "8x8" ]
def __init__(self, C, num_classes): """assuming input size 8x8""" super(AuxiliaryHeadCIFAR, self).__init__() self.features = nn.Sequential( nn.ReLU(inplace=True), nn.AvgPool2d(5, stride=3, padding=0, count_include_pad=False), # image size = 2 x 2 nn.Conv2d(C, 128, 1, bias=False), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.Conv2d(128, 768, 2, bias=False), nn.BatchNorm2d(768), nn.ReLU(inplace=True) ) self.classifier = nn.Linear(768, num_classes)
[ "def", "__init__", "(", "self", ",", "C", ",", "num_classes", ")", ":", "super", "(", "AuxiliaryHeadCIFAR", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "features", "=", "nn", ".", "Sequential", "(", "nn", ".", "ReLU", "(", "inplace", "=...
https://github.com/linnanwang/AlphaX-NASBench101/blob/87eb0d403def6dee43be7eb73520de074a2f9f03/alphax-1-net/model.py#L84-L98
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
medusa/providers/generic_provider.py
python
GenericProvider.create_magnet
(self, filename, result)
return False
Create a .magnet file containing the Magnet URI. :param filename: base filename (without extension). :param result: SearchResult object. :returns: True if the magnet file is created and verified.
Create a .magnet file containing the Magnet URI.
[ "Create", "a", ".", "magnet", "file", "containing", "the", "Magnet", "URI", "." ]
def create_magnet(self, filename, result): """ Create a .magnet file containing the Magnet URI. :param filename: base filename (without extension). :param result: SearchResult object. :returns: True if the magnet file is created and verified. """ filename_ext = '{filename}.magnet'.format(filename=filename) log.info('Saving magnet file {result} to {location}', {'result': result.name, 'location': filename_ext}) with open(filename_ext, 'w', encoding='utf-8') as fp: fp.write(result.url) if self._verify_magnet(filename_ext): log.info('Saved .magnet file {result} to {location}', {'result': result.name, 'location': filename_ext}) chmod_as_parent(filename) return True return False
[ "def", "create_magnet", "(", "self", ",", "filename", ",", "result", ")", ":", "filename_ext", "=", "'{filename}.magnet'", ".", "format", "(", "filename", "=", "filename", ")", "log", ".", "info", "(", "'Saving magnet file {result} to {location}'", ",", "{", "'r...
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/medusa/providers/generic_provider.py#L119-L139
PyHDI/veriloggen
2382d200deabf59cfcfd741f5eba371010aaf2bb
veriloggen/thread/fifo.py
python
FIFO.empty
(self)
return self.rif.empty
[]
def empty(self): return self.rif.empty
[ "def", "empty", "(", "self", ")", ":", "return", "self", ".", "rif", ".", "empty" ]
https://github.com/PyHDI/veriloggen/blob/2382d200deabf59cfcfd741f5eba371010aaf2bb/veriloggen/thread/fifo.py#L123-L124
MaybeShewill-CV/lanenet-lane-detection
94be8d9a66c7bbda5ad99b10492bc406c8aee45f
semantic_segmentation_zoo/vgg16_based_fcn.py
python
VGG16FCN._vgg16_fcn_encode
(self, input_tensor, name)
return
:param input_tensor: :param name: :return:
[]
def _vgg16_fcn_encode(self, input_tensor, name): """ :param input_tensor: :param name: :return: """ with tf.variable_scope(name_or_scope=name): # encode stage 1 conv_1_1 = self._vgg16_conv_stage( input_tensor=input_tensor, k_size=3, out_dims=64, name='conv1_1', need_layer_norm=True ) conv_1_2 = self._vgg16_conv_stage( input_tensor=conv_1_1, k_size=3, out_dims=64, name='conv1_2', need_layer_norm=True ) self._net_intermediate_results['encode_stage_1_share'] = { 'data': conv_1_2, 'shape': conv_1_2.get_shape().as_list() } # encode stage 2 pool1 = self.maxpooling( inputdata=conv_1_2, kernel_size=2, stride=2, name='pool1' ) conv_2_1 = self._vgg16_conv_stage( input_tensor=pool1, k_size=3, out_dims=128, name='conv2_1', need_layer_norm=True ) conv_2_2 = self._vgg16_conv_stage( input_tensor=conv_2_1, k_size=3, out_dims=128, name='conv2_2', need_layer_norm=True ) self._net_intermediate_results['encode_stage_2_share'] = { 'data': conv_2_2, 'shape': conv_2_2.get_shape().as_list() } # encode stage 3 pool2 = self.maxpooling( inputdata=conv_2_2, kernel_size=2, stride=2, name='pool2' ) conv_3_1 = self._vgg16_conv_stage( input_tensor=pool2, k_size=3, out_dims=256, name='conv3_1', need_layer_norm=True ) conv_3_2 = self._vgg16_conv_stage( input_tensor=conv_3_1, k_size=3, out_dims=256, name='conv3_2', need_layer_norm=True ) conv_3_3 = self._vgg16_conv_stage( input_tensor=conv_3_2, k_size=3, out_dims=256, name='conv3_3', need_layer_norm=True ) self._net_intermediate_results['encode_stage_3_share'] = { 'data': conv_3_3, 'shape': conv_3_3.get_shape().as_list() } # encode stage 4 pool3 = self.maxpooling( inputdata=conv_3_3, kernel_size=2, stride=2, name='pool3' ) conv_4_1 = self._vgg16_conv_stage( input_tensor=pool3, k_size=3, out_dims=512, name='conv4_1', need_layer_norm=True ) conv_4_2 = self._vgg16_conv_stage( input_tensor=conv_4_1, k_size=3, out_dims=512, name='conv4_2', need_layer_norm=True ) conv_4_3 = self._vgg16_conv_stage( input_tensor=conv_4_2, k_size=3, out_dims=512, name='conv4_3', need_layer_norm=True ) self._net_intermediate_results['encode_stage_4_share'] = { 'data': conv_4_3, 'shape': conv_4_3.get_shape().as_list() } # encode stage 5 for binary segmentation pool4 = self.maxpooling( inputdata=conv_4_3, kernel_size=2, stride=2, name='pool4' ) conv_5_1_binary = self._vgg16_conv_stage( input_tensor=pool4, k_size=3, out_dims=512, name='conv5_1_binary', need_layer_norm=True ) conv_5_2_binary = self._vgg16_conv_stage( input_tensor=conv_5_1_binary, k_size=3, out_dims=512, name='conv5_2_binary', need_layer_norm=True ) conv_5_3_binary = self._vgg16_conv_stage( input_tensor=conv_5_2_binary, k_size=3, out_dims=512, name='conv5_3_binary', need_layer_norm=True ) self._net_intermediate_results['encode_stage_5_binary'] = { 'data': conv_5_3_binary, 'shape': conv_5_3_binary.get_shape().as_list() } # encode stage 5 for instance segmentation conv_5_1_instance = self._vgg16_conv_stage( input_tensor=pool4, k_size=3, out_dims=512, name='conv5_1_instance', need_layer_norm=True ) conv_5_2_instance = self._vgg16_conv_stage( input_tensor=conv_5_1_instance, k_size=3, out_dims=512, name='conv5_2_instance', need_layer_norm=True ) conv_5_3_instance = self._vgg16_conv_stage( input_tensor=conv_5_2_instance, k_size=3, out_dims=512, name='conv5_3_instance', need_layer_norm=True ) self._net_intermediate_results['encode_stage_5_instance'] = { 'data': conv_5_3_instance, 'shape': conv_5_3_instance.get_shape().as_list() } return
[ "def", "_vgg16_fcn_encode", "(", "self", ",", "input_tensor", ",", "name", ")", ":", "with", "tf", ".", "variable_scope", "(", "name_or_scope", "=", "name", ")", ":", "# encode stage 1", "conv_1_1", "=", "self", ".", "_vgg16_conv_stage", "(", "input_tensor", "...
https://github.com/MaybeShewill-CV/lanenet-lane-detection/blob/94be8d9a66c7bbda5ad99b10492bc406c8aee45f/semantic_segmentation_zoo/vgg16_based_fcn.py#L125-L265
inspurer/WorkAttendanceSystem
1221e2d67bdf5bb15fe99517cc3ded58ccb066df
V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py
python
version
(pretty=False, best=False)
return _distro.version(pretty, best)
Return the version of the current Linux distribution, as a human-readable string. If *pretty* is false, the version is returned without codename (e.g. "7.0"). If *pretty* is true, the codename in parenthesis is appended, if the codename is non-empty (e.g. "7.0 (Maipo)"). Some distributions provide version numbers with different precisions in the different sources of distribution information. Examining the different sources in a fixed priority order does not always yield the most precise version (e.g. for Debian 8.2, or CentOS 7.1). The *best* parameter can be used to control the approach for the returned version: If *best* is false, the first non-empty version number in priority order of the examined sources is returned. If *best* is true, the most precise version number out of all examined sources is returned. **Lookup hierarchy:** In all cases, the version number is obtained from the following sources. If *best* is false, this order represents the priority order: * the value of the "VERSION_ID" attribute of the os-release file, * the value of the "Release" attribute returned by the lsb_release command, * the version number parsed from the "<version_id>" field of the first line of the distro release file, * the version number parsed from the "PRETTY_NAME" attribute of the os-release file, if it follows the format of the distro release files. * the version number parsed from the "Description" attribute returned by the lsb_release command, if it follows the format of the distro release files.
Return the version of the current Linux distribution, as a human-readable string.
[ "Return", "the", "version", "of", "the", "current", "Linux", "distribution", "as", "a", "human", "-", "readable", "string", "." ]
def version(pretty=False, best=False): """ Return the version of the current Linux distribution, as a human-readable string. If *pretty* is false, the version is returned without codename (e.g. "7.0"). If *pretty* is true, the codename in parenthesis is appended, if the codename is non-empty (e.g. "7.0 (Maipo)"). Some distributions provide version numbers with different precisions in the different sources of distribution information. Examining the different sources in a fixed priority order does not always yield the most precise version (e.g. for Debian 8.2, or CentOS 7.1). The *best* parameter can be used to control the approach for the returned version: If *best* is false, the first non-empty version number in priority order of the examined sources is returned. If *best* is true, the most precise version number out of all examined sources is returned. **Lookup hierarchy:** In all cases, the version number is obtained from the following sources. If *best* is false, this order represents the priority order: * the value of the "VERSION_ID" attribute of the os-release file, * the value of the "Release" attribute returned by the lsb_release command, * the version number parsed from the "<version_id>" field of the first line of the distro release file, * the version number parsed from the "PRETTY_NAME" attribute of the os-release file, if it follows the format of the distro release files. * the version number parsed from the "Description" attribute returned by the lsb_release command, if it follows the format of the distro release files. """ return _distro.version(pretty, best)
[ "def", "version", "(", "pretty", "=", "False", ",", "best", "=", "False", ")", ":", "return", "_distro", ".", "version", "(", "pretty", ",", "best", ")" ]
https://github.com/inspurer/WorkAttendanceSystem/blob/1221e2d67bdf5bb15fe99517cc3ded58ccb066df/V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py#L238-L279
Chaffelson/nipyapi
d3b186fd701ce308c2812746d98af9120955e810
nipyapi/nifi/models/access_policy_summary_dto.py
python
AccessPolicySummaryDTO.versioned_component_id
(self, versioned_component_id)
Sets the versioned_component_id of this AccessPolicySummaryDTO. The ID of the corresponding component that is under version control :param versioned_component_id: The versioned_component_id of this AccessPolicySummaryDTO. :type: str
Sets the versioned_component_id of this AccessPolicySummaryDTO. The ID of the corresponding component that is under version control
[ "Sets", "the", "versioned_component_id", "of", "this", "AccessPolicySummaryDTO", ".", "The", "ID", "of", "the", "corresponding", "component", "that", "is", "under", "version", "control" ]
def versioned_component_id(self, versioned_component_id): """ Sets the versioned_component_id of this AccessPolicySummaryDTO. The ID of the corresponding component that is under version control :param versioned_component_id: The versioned_component_id of this AccessPolicySummaryDTO. :type: str """ self._versioned_component_id = versioned_component_id
[ "def", "versioned_component_id", "(", "self", ",", "versioned_component_id", ")", ":", "self", ".", "_versioned_component_id", "=", "versioned_component_id" ]
https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/models/access_policy_summary_dto.py#L121-L130
reddit-archive/reddit
753b17407e9a9dca09558526805922de24133d53
r2/r2/models/query_cache.py
python
CachedQueryMutator.send
(self)
Commit the mutations batched up so far and potentially do pruning. This is automatically called by __exit__ when used as a context manager.
Commit the mutations batched up so far and potentially do pruning.
[ "Commit", "the", "mutations", "batched", "up", "so", "far", "and", "potentially", "do", "pruning", "." ]
def send(self): """Commit the mutations batched up so far and potentially do pruning. This is automatically called by __exit__ when used as a context manager. """ self.mutator.send() if self.to_prune: LOG.debug("Pruning queries %r", self.to_prune) CachedQuery._prune_multi(self.to_prune)
[ "def", "send", "(", "self", ")", ":", "self", ".", "mutator", ".", "send", "(", ")", "if", "self", ".", "to_prune", ":", "LOG", ".", "debug", "(", "\"Pruning queries %r\"", ",", "self", ".", "to_prune", ")", "CachedQuery", ".", "_prune_multi", "(", "se...
https://github.com/reddit-archive/reddit/blob/753b17407e9a9dca09558526805922de24133d53/r2/r2/models/query_cache.py#L378-L389
lightkurve/lightkurve
70d1c4cd1ab30f24c83e54bdcea4dd16624bfd9c
src/lightkurve/targetpixelfile.py
python
TargetPixelFileFactory._make_aperture_extension
(self)
return hdu
Create the aperture mask extension (i.e. extension #2).
Create the aperture mask extension (i.e. extension #2).
[ "Create", "the", "aperture", "mask", "extension", "(", "i", ".", "e", ".", "extension", "#2", ")", "." ]
def _make_aperture_extension(self): """Create the aperture mask extension (i.e. extension #2).""" mask = 3 * np.ones((self.n_rows, self.n_cols), dtype="int32") hdu = fits.ImageHDU(mask) # Set the header from the template TPF again template = self._header_template(2) for kw in template: if kw not in ["XTENSION", "NAXIS1", "NAXIS2", "CHECKSUM", "BITPIX"]: try: hdu.header[kw] = (self.keywords[kw], self.keywords.comments[kw]) except KeyError: hdu.header[kw] = (template[kw], template.comments[kw]) # Override the defaults where necessary for keyword in [ "CTYPE1", "CTYPE2", "CRPIX1", "CRPIX2", "CRVAL1", "CRVAL2", "CUNIT1", "CUNIT2", "CDELT1", "CDELT2", "PC1_1", "PC1_2", "PC2_1", "PC2_2", ]: hdu.header[keyword] = "" # override wcs keywords hdu.header["EXTNAME"] = "APERTURE" return hdu
[ "def", "_make_aperture_extension", "(", "self", ")", ":", "mask", "=", "3", "*", "np", ".", "ones", "(", "(", "self", ".", "n_rows", ",", "self", ".", "n_cols", ")", ",", "dtype", "=", "\"int32\"", ")", "hdu", "=", "fits", ".", "ImageHDU", "(", "ma...
https://github.com/lightkurve/lightkurve/blob/70d1c4cd1ab30f24c83e54bdcea4dd16624bfd9c/src/lightkurve/targetpixelfile.py#L2658-L2691
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/writing.py
python
SegmentWriter._merge_segments
(self, mergetype, optimize, merge)
return mergetype(self, self.segments)
[]
def _merge_segments(self, mergetype, optimize, merge): # The writer supports two ways of setting mergetype/optimize/merge: # as attributes or as keyword arguments to commit(). Originally there # were just the keyword arguments, but then I added the ability to use # the writer as a context manager using "with", so the user no longer # explicitly called commit(), hence the attributes mergetype = mergetype if mergetype is not None else self.mergetype optimize = optimize if optimize is not None else self.optimize merge = merge if merge is not None else self.merge if mergetype: pass elif optimize: mergetype = OPTIMIZE elif not merge: mergetype = NO_MERGE else: mergetype = MERGE_SMALL # Call the merge policy function. The policy may choose to merge # other segments into this writer's pool return mergetype(self, self.segments)
[ "def", "_merge_segments", "(", "self", ",", "mergetype", ",", "optimize", ",", "merge", ")", ":", "# The writer supports two ways of setting mergetype/optimize/merge:", "# as attributes or as keyword arguments to commit(). Originally there", "# were just the keyword arguments, but then I...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/writing.py#L809-L830
vertexproject/synapse
8173f43cb5fba5ca2648d12a659afb432139b0a7
synapse/lib/agenda.py
python
Agenda._addappt
(self, iden, appt)
Updates the data structures to add an appointment
Updates the data structures to add an appointment
[ "Updates", "the", "data", "structures", "to", "add", "an", "appointment" ]
def _addappt(self, iden, appt): ''' Updates the data structures to add an appointment ''' if appt.nexttime: heapq.heappush(self.apptheap, appt) self.appts[iden] = appt if self.apptheap and self.apptheap[0] is appt: self._wake_event.set()
[ "def", "_addappt", "(", "self", ",", "iden", ",", "appt", ")", ":", "if", "appt", ".", "nexttime", ":", "heapq", ".", "heappush", "(", "self", ".", "apptheap", ",", "appt", ")", "self", ".", "appts", "[", "iden", "]", "=", "appt", "if", "self", "...
https://github.com/vertexproject/synapse/blob/8173f43cb5fba5ca2648d12a659afb432139b0a7/synapse/lib/agenda.py#L553-L561
lovelylain/pyctp
fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d
example/ctp/futures/ApiStruct.py
python
ExchangeExecOrder.__init__
(self, Volume=0, RequestID=0, BusinessUnit='', OffsetFlag=OF_Open, HedgeFlag=HF_Speculation, ActionType=ACTP_Exec, PosiDirection=PD_Net, ReservePositionFlag=EOPF_Reserve, CloseFlag=EOCF_AutoClose, ExecOrderLocalID='', ExchangeID='', ParticipantID='', ClientID='', ExchangeInstID='', TraderID='', InstallID=0, OrderSubmitStatus=OSS_InsertSubmitted, NotifySequence=0, TradingDay='', SettlementID=0, ExecOrderSysID='', InsertDate='', InsertTime='', CancelTime='', ExecResult=OER_NoExec, ClearingPartID='', SequenceNo=0)
[]
def __init__(self, Volume=0, RequestID=0, BusinessUnit='', OffsetFlag=OF_Open, HedgeFlag=HF_Speculation, ActionType=ACTP_Exec, PosiDirection=PD_Net, ReservePositionFlag=EOPF_Reserve, CloseFlag=EOCF_AutoClose, ExecOrderLocalID='', ExchangeID='', ParticipantID='', ClientID='', ExchangeInstID='', TraderID='', InstallID=0, OrderSubmitStatus=OSS_InsertSubmitted, NotifySequence=0, TradingDay='', SettlementID=0, ExecOrderSysID='', InsertDate='', InsertTime='', CancelTime='', ExecResult=OER_NoExec, ClearingPartID='', SequenceNo=0): self.Volume = '' #数量, int self.RequestID = '' #请求编号, int self.BusinessUnit = '' #业务单元, char[21] self.OffsetFlag = '' #开平标志, char self.HedgeFlag = '' #投机套保标志, char self.ActionType = '' #执行类型, char self.PosiDirection = '' #保留头寸申请的持仓方向, char self.ReservePositionFlag = 'ExecOrderPositionFlag' #期权行权后是否保留期货头寸的标记, char self.CloseFlag = 'ExecOrderCloseFlag' #期权行权后生成的头寸是否自动平仓, char self.ExecOrderLocalID = 'OrderLocalID' #本地执行宣告编号, char[13] self.ExchangeID = '' #交易所代码, char[9] self.ParticipantID = '' #会员代码, char[11] self.ClientID = '' #客户代码, char[11] self.ExchangeInstID = '' #合约在交易所的代码, char[31] self.TraderID = '' #交易所交易员代码, char[21] self.InstallID = '' #安装编号, int self.OrderSubmitStatus = '' #执行宣告提交状态, char self.NotifySequence = 'SequenceNo' #报单提示序号, int self.TradingDay = 'Date' #交易日, char[9] self.SettlementID = '' #结算编号, int self.ExecOrderSysID = '' #执行宣告编号, char[21] self.InsertDate = 'Date' #报单日期, char[9] self.InsertTime = 'Time' #插入时间, char[9] self.CancelTime = 'Time' #撤销时间, char[9] self.ExecResult = '' #执行结果, char self.ClearingPartID = 'ParticipantID' #结算会员编号, char[11] self.SequenceNo = ''
[ "def", "__init__", "(", "self", ",", "Volume", "=", "0", ",", "RequestID", "=", "0", ",", "BusinessUnit", "=", "''", ",", "OffsetFlag", "=", "OF_Open", ",", "HedgeFlag", "=", "HF_Speculation", ",", "ActionType", "=", "ACTP_Exec", ",", "PosiDirection", "=",...
https://github.com/lovelylain/pyctp/blob/fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d/example/ctp/futures/ApiStruct.py#L3400-L3427
bendmorris/static-python
2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473
Lib/http/cookies.py
python
BaseCookie.value_decode
(self, val)
return val, val
real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies.
real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies.
[ "real_value", "coded_value", "=", "value_decode", "(", "STRING", ")", "Called", "prior", "to", "setting", "a", "cookie", "s", "value", "from", "the", "network", "representation", ".", "The", "VALUE", "is", "the", "value", "read", "from", "HTTP", "header", "....
def value_decode(self, val): """real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies. """ return val, val
[ "def", "value_decode", "(", "self", ",", "val", ")", ":", "return", "val", ",", "val" ]
https://github.com/bendmorris/static-python/blob/2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473/Lib/http/cookies.py#L461-L468
AmesCornish/buttersink
5cc37e30d9f8071fcf3497dca8b8a91b910321ea
buttersink/send.py
python
TLV_PUT_BYTES
(attrs, attrNum, value)
Put a tag-length-value encoded attribute as bytes.
Put a tag-length-value encoded attribute as bytes.
[ "Put", "a", "tag", "-", "length", "-", "value", "encoded", "attribute", "as", "bytes", "." ]
def TLV_PUT_BYTES(attrs, attrNum, value): """ Put a tag-length-value encoded attribute as bytes. """ TLV_PUT(attrs, attrNum, 's', value)
[ "def", "TLV_PUT_BYTES", "(", "attrs", ",", "attrNum", ",", "value", ")", ":", "TLV_PUT", "(", "attrs", ",", "attrNum", ",", "'s'", ",", "value", ")" ]
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/send.py#L153-L155
Anaconda-Platform/anaconda-project
df5ec33c12591e6512436d38d36c6132fa2e9618
anaconda_project/requirements_registry/registry.py
python
RequirementsRegistry.find_requirement_by_env_var
(self, env_var, options)
return EnvVarRequirement(registry=self, env_var=env_var, options=options)
Create a requirement instance given an environment variable name. Args: env_var (str): environment variable name options (dict): options from the project file for this requirement Returns: instance of Requirement
Create a requirement instance given an environment variable name.
[ "Create", "a", "requirement", "instance", "given", "an", "environment", "variable", "name", "." ]
def find_requirement_by_env_var(self, env_var, options): """Create a requirement instance given an environment variable name. Args: env_var (str): environment variable name options (dict): options from the project file for this requirement Returns: instance of Requirement """ from .requirement import EnvVarRequirement return EnvVarRequirement(registry=self, env_var=env_var, options=options)
[ "def", "find_requirement_by_env_var", "(", "self", ",", "env_var", ",", "options", ")", ":", "from", ".", "requirement", "import", "EnvVarRequirement", "return", "EnvVarRequirement", "(", "registry", "=", "self", ",", "env_var", "=", "env_var", ",", "options", "...
https://github.com/Anaconda-Platform/anaconda-project/blob/df5ec33c12591e6512436d38d36c6132fa2e9618/anaconda_project/requirements_registry/registry.py#L18-L29
JaniceWuo/MovieRecommend
4c86db64ca45598917d304f535413df3bc9fea65
movierecommend/venv1/Lib/site-packages/django/forms/fields.py
python
DecimalField.validate
(self, value)
[]
def validate(self, value): super(DecimalField, self).validate(value) if value in self.empty_values: return # Check for NaN, Inf and -Inf values. We can't compare directly for NaN, # since it is never equal to itself. However, NaN is the only value that # isn't equal to itself, so we can use this to identify NaN if value != value or value == Decimal("Inf") or value == Decimal("-Inf"): raise ValidationError(self.error_messages['invalid'], code='invalid')
[ "def", "validate", "(", "self", ",", "value", ")", ":", "super", "(", "DecimalField", ",", "self", ")", ".", "validate", "(", "value", ")", "if", "value", "in", "self", ".", "empty_values", ":", "return", "# Check for NaN, Inf and -Inf values. We can't compare d...
https://github.com/JaniceWuo/MovieRecommend/blob/4c86db64ca45598917d304f535413df3bc9fea65/movierecommend/venv1/Lib/site-packages/django/forms/fields.py#L366-L374
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
cpython/Lib/lib-tk/ttk.py
python
Treeview.delete
(self, *items)
Delete all specified items and all their descendants. The root item may not be deleted.
Delete all specified items and all their descendants. The root item may not be deleted.
[ "Delete", "all", "specified", "items", "and", "all", "their", "descendants", ".", "The", "root", "item", "may", "not", "be", "deleted", "." ]
def delete(self, *items): """Delete all specified items and all their descendants. The root item may not be deleted.""" self.tk.call(self._w, "delete", items)
[ "def", "delete", "(", "self", ",", "*", "items", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "\"delete\"", ",", "items", ")" ]
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/lib-tk/ttk.py#L1240-L1243
mitre-attack/attack-scripts
b94e05c0a29a6fdfc9701c721fcf03cdf9f7945b
scripts/techniques_data_sources_vis.py
python
write_DPT
(output_directory)
writes a CSV that links techniques, defenses, permissions, and tactics. specifically, the output will link: a specific technique, to a defense the technique bypassess, to the permissions needed to run the technique, repeated for each defense and tactic that is linked to the technique arguments: output_directory: string. The folder the output data will be written to. The folder will be created if it doesn't already exist.
writes a CSV that links techniques, defenses, permissions, and tactics. specifically, the output will link: a specific technique, to a defense the technique bypassess, to the permissions needed to run the technique, repeated for each defense and tactic that is linked to the technique
[ "writes", "a", "CSV", "that", "links", "techniques", "defenses", "permissions", "and", "tactics", ".", "specifically", "the", "output", "will", "link", ":", "a", "specific", "technique", "to", "a", "defense", "the", "technique", "bypassess", "to", "the", "perm...
def write_DPT(output_directory): """writes a CSV that links techniques, defenses, permissions, and tactics. specifically, the output will link: a specific technique, to a defense the technique bypassess, to the permissions needed to run the technique, repeated for each defense and tactic that is linked to the technique arguments: output_directory: string. The folder the output data will be written to. The folder will be created if it doesn't already exist. """ output_file = os.path.join(output_directory, "dpt.csv") # Make sure the directory exists if not os.path.exists(output_directory): os.makedirs(output_directory) with open (output_file, "w") as output_file: # Write the header of the CSV output_file.write("tech,defense,permission\n") # Iterate through each technique, defense, and permission for tech in tech_to_def: for defn in tech_to_def[tech]: for perm in tech_to_perm[tech]: output_file.write(tech.lower() + "," + defn.lower() + "," + perm.lower() + "\n")
[ "def", "write_DPT", "(", "output_directory", ")", ":", "output_file", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "\"dpt.csv\"", ")", "# Make sure the directory exists", "if", "not", "os", ".", "path", ".", "exists", "(", "output_directory...
https://github.com/mitre-attack/attack-scripts/blob/b94e05c0a29a6fdfc9701c721fcf03cdf9f7945b/scripts/techniques_data_sources_vis.py#L242-L267
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/limits/storage.py
python
RedisSentinelStorage.get
(self, key)
return super(RedisStorage, self).get(key, self.storage_slave)
:param str key: the key to get the counter value for
:param str key: the key to get the counter value for
[ ":", "param", "str", "key", ":", "the", "key", "to", "get", "the", "counter", "value", "for" ]
def get(self, key): """ :param str key: the key to get the counter value for """ return super(RedisStorage, self).get(key, self.storage_slave)
[ "def", "get", "(", "self", ",", "key", ")", ":", "return", "super", "(", "RedisStorage", ",", "self", ")", ".", "get", "(", "key", ",", "self", ".", "storage_slave", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/limits/storage.py#L517-L521
jodal/pyspotify
770aee08de274951b63e60bdd8835188b58e7862
spotify/track.py
python
Track.album
(self)
return spotify.Album(self._session, sp_album=sp_album, add_ref=True)
The album of the track. Will always return :class:`None` if the track isn't loaded.
The album of the track.
[ "The", "album", "of", "the", "track", "." ]
def album(self): """The album of the track. Will always return :class:`None` if the track isn't loaded. """ spotify.Error.maybe_raise(self.error, ignores=[spotify.ErrorType.IS_LOADING]) if not self.is_loaded: return None sp_album = lib.sp_track_album(self._sp_track) return spotify.Album(self._session, sp_album=sp_album, add_ref=True)
[ "def", "album", "(", "self", ")", ":", "spotify", ".", "Error", ".", "maybe_raise", "(", "self", ".", "error", ",", "ignores", "=", "[", "spotify", ".", "ErrorType", ".", "IS_LOADING", "]", ")", "if", "not", "self", ".", "is_loaded", ":", "return", "...
https://github.com/jodal/pyspotify/blob/770aee08de274951b63e60bdd8835188b58e7862/spotify/track.py#L227-L236
jerryli27/TwinGAN
4e5593445778dfb77af9f815b3f4fcafc35758dc
nets/nasnet/nasnet.py
python
nasnet_cifar_arg_scope
(weight_decay=5e-4, batch_norm_decay=0.9, batch_norm_epsilon=1e-5)
Defines the default arg scope for the NASNet-A Cifar model. Args: weight_decay: The weight decay to use for regularizing the model. batch_norm_decay: Decay for batch norm moving average. batch_norm_epsilon: Small float added to variance to avoid dividing by zero in batch norm. Returns: An `arg_scope` to use for the NASNet Cifar Model.
Defines the default arg scope for the NASNet-A Cifar model.
[ "Defines", "the", "default", "arg", "scope", "for", "the", "NASNet", "-", "A", "Cifar", "model", "." ]
def nasnet_cifar_arg_scope(weight_decay=5e-4, batch_norm_decay=0.9, batch_norm_epsilon=1e-5): """Defines the default arg scope for the NASNet-A Cifar model. Args: weight_decay: The weight decay to use for regularizing the model. batch_norm_decay: Decay for batch norm moving average. batch_norm_epsilon: Small float added to variance to avoid dividing by zero in batch norm. Returns: An `arg_scope` to use for the NASNet Cifar Model. """ batch_norm_params = { # Decay for the moving averages. 'decay': batch_norm_decay, # epsilon to prevent 0s in variance. 'epsilon': batch_norm_epsilon, 'scale': True, 'fused': True, } weights_regularizer = tf.contrib.layers.l2_regularizer(weight_decay) weights_initializer = tf.contrib.layers.variance_scaling_initializer( mode='FAN_OUT') with arg_scope([slim.fully_connected, slim.conv2d, slim.separable_conv2d], weights_regularizer=weights_regularizer, weights_initializer=weights_initializer): with arg_scope([slim.fully_connected], activation_fn=None, scope='FC'): with arg_scope([slim.conv2d, slim.separable_conv2d], activation_fn=None, biases_initializer=None): with arg_scope([slim.batch_norm], **batch_norm_params) as sc: return sc
[ "def", "nasnet_cifar_arg_scope", "(", "weight_decay", "=", "5e-4", ",", "batch_norm_decay", "=", "0.9", ",", "batch_norm_epsilon", "=", "1e-5", ")", ":", "batch_norm_params", "=", "{", "# Decay for the moving averages.", "'decay'", ":", "batch_norm_decay", ",", "# eps...
https://github.com/jerryli27/TwinGAN/blob/4e5593445778dfb77af9f815b3f4fcafc35758dc/nets/nasnet/nasnet.py#L111-L144
thatmattlove/hyperglass
c52a6f609843177671d38bcad59b8bd658f46b64
hyperglass/models/config/devices.py
python
Device.__hash__
(self)
return hash((self.name,))
Make device object hashable so the object can be deduplicated with set().
Make device object hashable so the object can be deduplicated with set().
[ "Make", "device", "object", "hashable", "so", "the", "object", "can", "be", "deduplicated", "with", "set", "()", "." ]
def __hash__(self) -> int: """Make device object hashable so the object can be deduplicated with set().""" return hash((self.name,))
[ "def", "__hash__", "(", "self", ")", "->", "int", ":", "return", "hash", "(", "(", "self", ".", "name", ",", ")", ")" ]
https://github.com/thatmattlove/hyperglass/blob/c52a6f609843177671d38bcad59b8bd658f46b64/hyperglass/models/config/devices.py#L105-L107
HymanLiuTS/flaskTs
286648286976e85d9b9a5873632331efcafe0b21
flasky/lib/python2.7/site-packages/werkzeug/datastructures.py
python
ETags.to_header
(self)
return ', '.join( ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak] )
Convert the etags set into a HTTP header string.
Convert the etags set into a HTTP header string.
[ "Convert", "the", "etags", "set", "into", "a", "HTTP", "header", "string", "." ]
def to_header(self): """Convert the etags set into a HTTP header string.""" if self.star_tag: return '*' return ', '.join( ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak] )
[ "def", "to_header", "(", "self", ")", ":", "if", "self", ".", "star_tag", ":", "return", "'*'", "return", "', '", ".", "join", "(", "[", "'\"%s\"'", "%", "x", "for", "x", "in", "self", ".", "_strong", "]", "+", "[", "'W/\"%s\"'", "%", "x", "for", ...
https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/werkzeug/datastructures.py#L2161-L2168
BMW-InnovationLab/BMW-TensorFlow-Training-GUI
4f10d1f00f9ac312ca833e5b28fd0f8952cfee17
training_api/research/object_detection/inputs.py
python
create_eval_input_fn
(eval_config, eval_input_config, model_config)
return _eval_input_fn
Creates an eval `input` function for `Estimator`. # TODO(ronnyvotel,rathodv): Allow batch sizes of more than 1 for eval. Args: eval_config: An eval_pb2.EvalConfig. eval_input_config: An input_reader_pb2.InputReader. model_config: A model_pb2.DetectionModel. Returns: `input_fn` for `Estimator` in EVAL mode.
Creates an eval `input` function for `Estimator`.
[ "Creates", "an", "eval", "input", "function", "for", "Estimator", "." ]
def create_eval_input_fn(eval_config, eval_input_config, model_config): """Creates an eval `input` function for `Estimator`. # TODO(ronnyvotel,rathodv): Allow batch sizes of more than 1 for eval. Args: eval_config: An eval_pb2.EvalConfig. eval_input_config: An input_reader_pb2.InputReader. model_config: A model_pb2.DetectionModel. Returns: `input_fn` for `Estimator` in EVAL mode. """ def _eval_input_fn(params=None): """Returns `features` and `labels` tensor dictionaries for evaluation. Args: params: Parameter dictionary passed from the estimator. Returns: A tf.data.Dataset that holds (features, labels) tuple. features: Dictionary of feature tensors. features[fields.InputDataFields.image] is a [1, H, W, C] float32 tensor with preprocessed images. features[HASH_KEY] is a [1] int32 tensor representing unique identifiers for the images. features[fields.InputDataFields.true_image_shape] is a [1, 3] int32 tensor representing the true image shapes, as preprocessed images could be padded. features[fields.InputDataFields.original_image] is a [1, H', W', C] float32 tensor with the original image. labels: Dictionary of groundtruth tensors. labels[fields.InputDataFields.groundtruth_boxes] is a [1, num_boxes, 4] float32 tensor containing the corners of the groundtruth boxes. labels[fields.InputDataFields.groundtruth_classes] is a [num_boxes, num_classes] float32 one-hot tensor of classes. labels[fields.InputDataFields.groundtruth_area] is a [1, num_boxes] float32 tensor containing object areas. labels[fields.InputDataFields.groundtruth_is_crowd] is a [1, num_boxes] bool tensor indicating if the boxes enclose a crowd. labels[fields.InputDataFields.groundtruth_difficult] is a [1, num_boxes] int32 tensor indicating if the boxes represent difficult instances. -- Optional -- labels[fields.InputDataFields.groundtruth_instance_masks] is a [1, num_boxes, H, W] float32 tensor containing only binary values, which represent instance masks for objects. Raises: TypeError: if the `eval_config`, `eval_input_config` or `model_config` are not of the correct type. """ params = params or {} if not isinstance(eval_config, eval_pb2.EvalConfig): raise TypeError('For eval mode, the `eval_config` must be a ' 'train_pb2.EvalConfig.') if not isinstance(eval_input_config, input_reader_pb2.InputReader): raise TypeError('The `eval_input_config` must be a ' 'input_reader_pb2.InputReader.') if not isinstance(model_config, model_pb2.DetectionModel): raise TypeError('The `model_config` must be a ' 'model_pb2.DetectionModel.') def transform_and_pad_input_data_fn(tensor_dict): """Combines transform and pad operation.""" num_classes = config_util.get_number_of_classes(model_config) model = model_builder.build(model_config, is_training=False) image_resizer_config = config_util.get_image_resizer_config(model_config) image_resizer_fn = image_resizer_builder.build(image_resizer_config) transform_data_fn = functools.partial( transform_input_data, model_preprocess_fn=model.preprocess, image_resizer_fn=image_resizer_fn, num_classes=num_classes, data_augmentation_fn=None, retain_original_image=eval_config.retain_original_images) tensor_dict = pad_input_data_to_static_shapes( tensor_dict=transform_data_fn(tensor_dict), max_num_boxes=eval_input_config.max_number_of_boxes, num_classes=config_util.get_number_of_classes(model_config), spatial_image_shape=config_util.get_spatial_image_size( image_resizer_config)) return (_get_features_dict(tensor_dict), _get_labels_dict(tensor_dict)) dataset = INPUT_BUILDER_UTIL_MAP['dataset_build']( eval_input_config, batch_size=1, # Currently only support batch size of 1 for eval. transform_input_data_fn=transform_and_pad_input_data_fn) return dataset return _eval_input_fn
[ "def", "create_eval_input_fn", "(", "eval_config", ",", "eval_input_config", ",", "model_config", ")", ":", "def", "_eval_input_fn", "(", "params", "=", "None", ")", ":", "\"\"\"Returns `features` and `labels` tensor dictionaries for evaluation.\n\n Args:\n params: Parame...
https://github.com/BMW-InnovationLab/BMW-TensorFlow-Training-GUI/blob/4f10d1f00f9ac312ca833e5b28fd0f8952cfee17/training_api/research/object_detection/inputs.py#L414-L504
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/stringprep.py
python
in_table_c21_c22
(code)
return unicodedata.category(code) == "Cc" or \ ord(code) in c22_specials
[]
def in_table_c21_c22(code): return unicodedata.category(code) == "Cc" or \ ord(code) in c22_specials
[ "def", "in_table_c21_c22", "(", "code", ")", ":", "return", "unicodedata", ".", "category", "(", "code", ")", "==", "\"Cc\"", "or", "ord", "(", "code", ")", "in", "c22_specials" ]
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/stringprep.py#L227-L229
fablabnbg/inkscape-silhouette
e0ad65115b4b2b0a5b60dfecd9a3ca03ec1d6bec
silhouette/pyusb-1.0.2/usb/_objfinalizer.py
python
_AutoFinalizedObjectBase.finalize
(self)
Finalizes the object if not already done. Returns: None
Finalizes the object if not already done.
[ "Finalizes", "the", "object", "if", "not", "already", "done", "." ]
def finalize(self): """Finalizes the object if not already done. Returns: None """ # this is the "public" finalize method raise NotImplementedError( "finalize() must be implemented by AutoFinalizedObject." )
[ "def", "finalize", "(", "self", ")", ":", "# this is the \"public\" finalize method", "raise", "NotImplementedError", "(", "\"finalize() must be implemented by AutoFinalizedObject.\"", ")" ]
https://github.com/fablabnbg/inkscape-silhouette/blob/e0ad65115b4b2b0a5b60dfecd9a3ca03ec1d6bec/silhouette/pyusb-1.0.2/usb/_objfinalizer.py#L73-L81
misterch0c/shadowbroker
e3a069bea47a2c1009697941ac214adc6f90aa8d
windows/Resources/Python/Core/Lib/logging/__init__.py
python
BufferingFormatter.__init__
(self, linefmt=None)
Optionally specify a formatter which will be used to format each individual record.
Optionally specify a formatter which will be used to format each individual record.
[ "Optionally", "specify", "a", "formatter", "which", "will", "be", "used", "to", "format", "each", "individual", "record", "." ]
def __init__(self, linefmt=None): """ Optionally specify a formatter which will be used to format each individual record. """ if linefmt: self.linefmt = linefmt else: self.linefmt = _defaultFormatter
[ "def", "__init__", "(", "self", ",", "linefmt", "=", "None", ")", ":", "if", "linefmt", ":", "self", ".", "linefmt", "=", "linefmt", "else", ":", "self", ".", "linefmt", "=", "_defaultFormatter" ]
https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/logging/__init__.py#L405-L413
ProjectQ-Framework/ProjectQ
0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005
projectq/ops/_gates.py
python
BarrierGate.__str__
(self)
return "Barrier"
Return a string representation of the object.
Return a string representation of the object.
[ "Return", "a", "string", "representation", "of", "the", "object", "." ]
def __str__(self): """Return a string representation of the object.""" return "Barrier"
[ "def", "__str__", "(", "self", ")", ":", "return", "\"Barrier\"" ]
https://github.com/ProjectQ-Framework/ProjectQ/blob/0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005/projectq/ops/_gates.py#L475-L477
bashtage/linearmodels
9256269f01ff8c5f85e65342d66149a5636661b6
linearmodels/panel/results.py
python
PanelResults._out_of_sample
( self, exog: OptionalArrayLike, data: Optional[DataFrame], missing: bool )
return pred
Interface between model predict and predict for OOS fits
Interface between model predict and predict for OOS fits
[ "Interface", "between", "model", "predict", "and", "predict", "for", "OOS", "fits" ]
def _out_of_sample( self, exog: OptionalArrayLike, data: Optional[DataFrame], missing: bool ) -> DataFrame: """Interface between model predict and predict for OOS fits""" if exog is not None and data is not None: raise ValueError( "Predictions can only be constructed using one " "of exog or data, but not both." ) pred = self.model.predict(self.params, exog=exog, data=data) if not missing: pred = pred.loc[pred.notnull().all(1)] return pred
[ "def", "_out_of_sample", "(", "self", ",", "exog", ":", "OptionalArrayLike", ",", "data", ":", "Optional", "[", "DataFrame", "]", ",", "missing", ":", "bool", ")", "->", "DataFrame", ":", "if", "exog", "is", "not", "None", "and", "data", "is", "not", "...
https://github.com/bashtage/linearmodels/blob/9256269f01ff8c5f85e65342d66149a5636661b6/linearmodels/panel/results.py#L473-L485
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
dist/lib/python2.7/fractions.py
python
Fraction.__le__
(a, b)
return a._richcmp(b, operator.le)
a <= b
a <= b
[ "a", "<", "=", "b" ]
def __le__(a, b): """a <= b""" return a._richcmp(b, operator.le)
[ "def", "__le__", "(", "a", ",", "b", ")", ":", "return", "a", ".", "_richcmp", "(", "b", ",", "operator", ".", "le", ")" ]
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/dist/lib/python2.7/fractions.py#L580-L582
aliyun/aliyun-oss-python-sdk
5f2afa0928a58c7c1cc6317ac147f3637481f6fd
oss2/models.py
python
TaggingRule.len
(self)
return len(self.tagging_rule)
[]
def len(self): return len(self.tagging_rule)
[ "def", "len", "(", "self", ")", ":", "return", "len", "(", "self", ".", "tagging_rule", ")" ]
https://github.com/aliyun/aliyun-oss-python-sdk/blob/5f2afa0928a58c7c1cc6317ac147f3637481f6fd/oss2/models.py#L1462-L1463
cal-pratt/SheetVision
f1ce1c9c97d5c922aa95b9120152f9c62fab829d
MIDIUtil-0.89/MIDIUtil-0.89/src/midiutil/MidiFile.py
python
MIDIFile.shiftTracks
(self, offset=0)
Shift tracks to be zero-origined, or origined at offset. Note that the shifting of the time in the tracks uses the MIDIEventList -- in other words it is assumed to be called in the stage where the MIDIEventList has been created. This function, however, it meant to operate on the eventList itself.
Shift tracks to be zero-origined, or origined at offset. Note that the shifting of the time in the tracks uses the MIDIEventList -- in other words it is assumed to be called in the stage where the MIDIEventList has been created. This function, however, it meant to operate on the eventList itself.
[ "Shift", "tracks", "to", "be", "zero", "-", "origined", "or", "origined", "at", "offset", ".", "Note", "that", "the", "shifting", "of", "the", "time", "in", "the", "tracks", "uses", "the", "MIDIEventList", "--", "in", "other", "words", "it", "is", "assum...
def shiftTracks(self, offset=0): """Shift tracks to be zero-origined, or origined at offset. Note that the shifting of the time in the tracks uses the MIDIEventList -- in other words it is assumed to be called in the stage where the MIDIEventList has been created. This function, however, it meant to operate on the eventList itself. """ origin = 1000000 # A little silly, but we'll assume big enough for track in self.tracks: if len(track.eventList) > 0: for event in track.eventList: if event.time < origin: origin = event.time for track in self.tracks: tempEventList = [] #runningTime = 0 for event in track.eventList: adjustedTime = event.time - origin #event.time = adjustedTime - runningTime + offset event.time = adjustedTime + offset #runningTime = adjustedTime tempEventList.append(event) track.eventList = tempEventList
[ "def", "shiftTracks", "(", "self", ",", "offset", "=", "0", ")", ":", "origin", "=", "1000000", "# A little silly, but we'll assume big enough", "for", "track", "in", "self", ".", "tracks", ":", "if", "len", "(", "track", ".", "eventList", ")", ">", "0", "...
https://github.com/cal-pratt/SheetVision/blob/f1ce1c9c97d5c922aa95b9120152f9c62fab829d/MIDIUtil-0.89/MIDIUtil-0.89/src/midiutil/MidiFile.py#L892-L918
demisto/content
5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07
Packs/SailPointIdentityNow/Integrations/SailPointIdentityNow/SailPointIdentityNow.py
python
Client.send_request
(self, url_suffix: str, method: str, params=None, json_data=None)
return self._http_request(url_suffix=url_suffix, method=method, json_data=json_data, params=params, timeout=self.request_timeout, resp_type='response')
Perform a HTTP request to IdentityNow API. :type url_suffix: ``str`` :param url_suffix: IdentityNow API endpoint ext suffix. :type method: ``str`` :param method: HTTP method, e.g. 'GET', 'POST', 'PUT', 'DELETE'. :type params: ``JSON`` :param params: URL parameters to specify the query. :type json_data: ``JSON`` :param json_data: Data to be sent as part of 'POST' or 'PUT' request. :return: Response after fulfilling the request successfully, else None.
Perform a HTTP request to IdentityNow API.
[ "Perform", "a", "HTTP", "request", "to", "IdentityNow", "API", "." ]
def send_request(self, url_suffix: str, method: str, params=None, json_data=None): """ Perform a HTTP request to IdentityNow API. :type url_suffix: ``str`` :param url_suffix: IdentityNow API endpoint ext suffix. :type method: ``str`` :param method: HTTP method, e.g. 'GET', 'POST', 'PUT', 'DELETE'. :type params: ``JSON`` :param params: URL parameters to specify the query. :type json_data: ``JSON`` :param json_data: Data to be sent as part of 'POST' or 'PUT' request. :return: Response after fulfilling the request successfully, else None. """ if url_suffix is None or method is None: return None return self._http_request(url_suffix=url_suffix, method=method, json_data=json_data, params=params, timeout=self.request_timeout, resp_type='response')
[ "def", "send_request", "(", "self", ",", "url_suffix", ":", "str", ",", "method", ":", "str", ",", "params", "=", "None", ",", "json_data", "=", "None", ")", ":", "if", "url_suffix", "is", "None", "or", "method", "is", "None", ":", "return", "None", ...
https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/SailPointIdentityNow/Integrations/SailPointIdentityNow/SailPointIdentityNow.py#L51-L73
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/compiler/ast.py
python
Break.getChildren
(self)
return ()
[]
def getChildren(self): return ()
[ "def", "getChildren", "(", "self", ")", ":", "return", "(", ")" ]
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/compiler/ast.py#L272-L273
intuition-io/intuition
cd517e6b3b315a743eb4d0d0dc294e264ab913ce
intuition/data/remote.py
python
lookup_symbol
(company)
return json.loads(request.text[39:-1])["ResultSet"]["Result"] \ if request.ok else {'error': request.reason}
Fetch company info >>> lookup_symbol("Apple Inc.") {u'exch': u'NMS', u'market': u'NASDAQ', u'name': u'Apple Inc.', u'symbol': u'AAPL', u'type': u'Equity'}
Fetch company info >>> lookup_symbol("Apple Inc.") {u'exch': u'NMS', u'market': u'NASDAQ', u'name': u'Apple Inc.', u'symbol': u'AAPL', u'type': u'Equity'}
[ "Fetch", "company", "info", ">>>", "lookup_symbol", "(", "Apple", "Inc", ".", ")", "{", "u", "exch", ":", "u", "NMS", "u", "market", ":", "u", "NASDAQ", "u", "name", ":", "u", "Apple", "Inc", ".", "u", "symbol", ":", "u", "AAPL", "u", "type", ":"...
def lookup_symbol(company): ''' Fetch company info >>> lookup_symbol("Apple Inc.") {u'exch': u'NMS', u'market': u'NASDAQ', u'name': u'Apple Inc.', u'symbol': u'AAPL', u'type': u'Equity'} ''' request = requests.get(FINANCE_URLS['info_lookup'].format(company)) return json.loads(request.text[39:-1])["ResultSet"]["Result"] \ if request.ok else {'error': request.reason}
[ "def", "lookup_symbol", "(", "company", ")", ":", "request", "=", "requests", ".", "get", "(", "FINANCE_URLS", "[", "'info_lookup'", "]", ".", "format", "(", "company", ")", ")", "return", "json", ".", "loads", "(", "request", ".", "text", "[", "39", "...
https://github.com/intuition-io/intuition/blob/cd517e6b3b315a743eb4d0d0dc294e264ab913ce/intuition/data/remote.py#L97-L108
karlch/vimiv
acbb83e003805e5304131be1f73d7f66528606d6
vimiv/transform.py
python
Transform.rotate_auto
(self)
Autorotate all pictures in the current pathlist.
Autorotate all pictures in the current pathlist.
[ "Autorotate", "all", "pictures", "in", "the", "current", "pathlist", "." ]
def rotate_auto(self): """Autorotate all pictures in the current pathlist.""" autorotate = imageactions.Autorotate(self._app.get_paths()) self.threads_running = True autorotate.connect("completed", self._on_autorotate_completed) autorotate.run()
[ "def", "rotate_auto", "(", "self", ")", ":", "autorotate", "=", "imageactions", ".", "Autorotate", "(", "self", ".", "_app", ".", "get_paths", "(", ")", ")", "self", ".", "threads_running", "=", "True", "autorotate", ".", "connect", "(", "\"completed\"", "...
https://github.com/karlch/vimiv/blob/acbb83e003805e5304131be1f73d7f66528606d6/vimiv/transform.py#L223-L228
yuantailing/ctw-baseline
081c8361b0ed0675bf619ab6316ebf8415e93f46
classification/slim/nets/inception_resnet_v2.py
python
inception_resnet_v2_base
(inputs, final_endpoint='Conv2d_7b_1x1', output_stride=16, align_feature_maps=False, scope=None)
Inception model from http://arxiv.org/abs/1602.07261. Constructs an Inception Resnet v2 network from inputs to the given final endpoint. This method can construct the network up to the final inception block Conv2d_7b_1x1. Args: inputs: a tensor of size [batch_size, height, width, channels]. final_endpoint: specifies the endpoint to construct the network up to. It can be one of ['Conv2d_1a_3x3', 'Conv2d_2a_3x3', 'Conv2d_2b_3x3', 'MaxPool_3a_3x3', 'Conv2d_3b_1x1', 'Conv2d_4a_3x3', 'MaxPool_5a_3x3', 'Mixed_5b', 'Mixed_6a', 'PreAuxLogits', 'Mixed_7a', 'Conv2d_7b_1x1'] output_stride: A scalar that specifies the requested ratio of input to output spatial resolution. Only supports 8 and 16. align_feature_maps: When true, changes all the VALID paddings in the network to SAME padding so that the feature maps are aligned. scope: Optional variable_scope. Returns: tensor_out: output tensor corresponding to the final_endpoint. end_points: a set of activations for external use, for example summaries or losses. Raises: ValueError: if final_endpoint is not set to one of the predefined values, or if the output_stride is not 8 or 16, or if the output_stride is 8 and we request an end point after 'PreAuxLogits'.
Inception model from http://arxiv.org/abs/1602.07261.
[ "Inception", "model", "from", "http", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1602", ".", "07261", "." ]
def inception_resnet_v2_base(inputs, final_endpoint='Conv2d_7b_1x1', output_stride=16, align_feature_maps=False, scope=None): """Inception model from http://arxiv.org/abs/1602.07261. Constructs an Inception Resnet v2 network from inputs to the given final endpoint. This method can construct the network up to the final inception block Conv2d_7b_1x1. Args: inputs: a tensor of size [batch_size, height, width, channels]. final_endpoint: specifies the endpoint to construct the network up to. It can be one of ['Conv2d_1a_3x3', 'Conv2d_2a_3x3', 'Conv2d_2b_3x3', 'MaxPool_3a_3x3', 'Conv2d_3b_1x1', 'Conv2d_4a_3x3', 'MaxPool_5a_3x3', 'Mixed_5b', 'Mixed_6a', 'PreAuxLogits', 'Mixed_7a', 'Conv2d_7b_1x1'] output_stride: A scalar that specifies the requested ratio of input to output spatial resolution. Only supports 8 and 16. align_feature_maps: When true, changes all the VALID paddings in the network to SAME padding so that the feature maps are aligned. scope: Optional variable_scope. Returns: tensor_out: output tensor corresponding to the final_endpoint. end_points: a set of activations for external use, for example summaries or losses. Raises: ValueError: if final_endpoint is not set to one of the predefined values, or if the output_stride is not 8 or 16, or if the output_stride is 8 and we request an end point after 'PreAuxLogits'. """ if output_stride != 8 and output_stride != 16: raise ValueError('output_stride must be 8 or 16.') padding = 'SAME' if align_feature_maps else 'VALID' end_points = {} def add_and_check_final(name, net): end_points[name] = net return name == final_endpoint with tf.variable_scope(scope, 'InceptionResnetV2', [inputs]): with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d], stride=1, padding='SAME'): # 149 x 149 x 32 net = slim.conv2d(inputs, 32, 3, stride=2, padding=padding, scope='Conv2d_1a_3x3') if add_and_check_final('Conv2d_1a_3x3', net): return net, end_points # 147 x 147 x 32 net = slim.conv2d(net, 32, 3, padding=padding, scope='Conv2d_2a_3x3') if add_and_check_final('Conv2d_2a_3x3', net): return net, end_points # 147 x 147 x 64 net = slim.conv2d(net, 64, 3, scope='Conv2d_2b_3x3') if add_and_check_final('Conv2d_2b_3x3', net): return net, end_points # 73 x 73 x 64 net = slim.max_pool2d(net, 3, stride=2, padding=padding, scope='MaxPool_3a_3x3') if add_and_check_final('MaxPool_3a_3x3', net): return net, end_points # 73 x 73 x 80 net = slim.conv2d(net, 80, 1, padding=padding, scope='Conv2d_3b_1x1') if add_and_check_final('Conv2d_3b_1x1', net): return net, end_points # 71 x 71 x 192 net = slim.conv2d(net, 192, 3, padding=padding, scope='Conv2d_4a_3x3') if add_and_check_final('Conv2d_4a_3x3', net): return net, end_points # 35 x 35 x 192 net = slim.max_pool2d(net, 3, stride=2, padding=padding, scope='MaxPool_5a_3x3') if add_and_check_final('MaxPool_5a_3x3', net): return net, end_points # 35 x 35 x 320 with tf.variable_scope('Mixed_5b'): with tf.variable_scope('Branch_0'): tower_conv = slim.conv2d(net, 96, 1, scope='Conv2d_1x1') with tf.variable_scope('Branch_1'): tower_conv1_0 = slim.conv2d(net, 48, 1, scope='Conv2d_0a_1x1') tower_conv1_1 = slim.conv2d(tower_conv1_0, 64, 5, scope='Conv2d_0b_5x5') with tf.variable_scope('Branch_2'): tower_conv2_0 = slim.conv2d(net, 64, 1, scope='Conv2d_0a_1x1') tower_conv2_1 = slim.conv2d(tower_conv2_0, 96, 3, scope='Conv2d_0b_3x3') tower_conv2_2 = slim.conv2d(tower_conv2_1, 96, 3, scope='Conv2d_0c_3x3') with tf.variable_scope('Branch_3'): tower_pool = slim.avg_pool2d(net, 3, stride=1, padding='SAME', scope='AvgPool_0a_3x3') tower_pool_1 = slim.conv2d(tower_pool, 64, 1, scope='Conv2d_0b_1x1') net = tf.concat( [tower_conv, tower_conv1_1, tower_conv2_2, tower_pool_1], 3) if add_and_check_final('Mixed_5b', net): return net, end_points # TODO(alemi): Register intermediate endpoints net = slim.repeat(net, 10, block35, scale=0.17) # 17 x 17 x 1088 if output_stride == 8, # 33 x 33 x 1088 if output_stride == 16 use_atrous = output_stride == 8 with tf.variable_scope('Mixed_6a'): with tf.variable_scope('Branch_0'): tower_conv = slim.conv2d(net, 384, 3, stride=1 if use_atrous else 2, padding=padding, scope='Conv2d_1a_3x3') with tf.variable_scope('Branch_1'): tower_conv1_0 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1') tower_conv1_1 = slim.conv2d(tower_conv1_0, 256, 3, scope='Conv2d_0b_3x3') tower_conv1_2 = slim.conv2d(tower_conv1_1, 384, 3, stride=1 if use_atrous else 2, padding=padding, scope='Conv2d_1a_3x3') with tf.variable_scope('Branch_2'): tower_pool = slim.max_pool2d(net, 3, stride=1 if use_atrous else 2, padding=padding, scope='MaxPool_1a_3x3') net = tf.concat([tower_conv, tower_conv1_2, tower_pool], 3) if add_and_check_final('Mixed_6a', net): return net, end_points # TODO(alemi): register intermediate endpoints with slim.arg_scope([slim.conv2d], rate=2 if use_atrous else 1): net = slim.repeat(net, 20, block17, scale=0.10) if add_and_check_final('PreAuxLogits', net): return net, end_points if output_stride == 8: # TODO(gpapan): Properly support output_stride for the rest of the net. raise ValueError('output_stride==8 is only supported up to the ' 'PreAuxlogits end_point for now.') # 8 x 8 x 2080 with tf.variable_scope('Mixed_7a'): with tf.variable_scope('Branch_0'): tower_conv = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1') tower_conv_1 = slim.conv2d(tower_conv, 384, 3, stride=2, padding=padding, scope='Conv2d_1a_3x3') with tf.variable_scope('Branch_1'): tower_conv1 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1') tower_conv1_1 = slim.conv2d(tower_conv1, 288, 3, stride=2, padding=padding, scope='Conv2d_1a_3x3') with tf.variable_scope('Branch_2'): tower_conv2 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1') tower_conv2_1 = slim.conv2d(tower_conv2, 288, 3, scope='Conv2d_0b_3x3') tower_conv2_2 = slim.conv2d(tower_conv2_1, 320, 3, stride=2, padding=padding, scope='Conv2d_1a_3x3') with tf.variable_scope('Branch_3'): tower_pool = slim.max_pool2d(net, 3, stride=2, padding=padding, scope='MaxPool_1a_3x3') net = tf.concat( [tower_conv_1, tower_conv1_1, tower_conv2_2, tower_pool], 3) if add_and_check_final('Mixed_7a', net): return net, end_points # TODO(alemi): register intermediate endpoints net = slim.repeat(net, 9, block8, scale=0.20) net = block8(net, activation_fn=None) # 8 x 8 x 1536 net = slim.conv2d(net, 1536, 1, scope='Conv2d_7b_1x1') if add_and_check_final('Conv2d_7b_1x1', net): return net, end_points raise ValueError('final_endpoint (%s) not recognized', final_endpoint)
[ "def", "inception_resnet_v2_base", "(", "inputs", ",", "final_endpoint", "=", "'Conv2d_7b_1x1'", ",", "output_stride", "=", "16", ",", "align_feature_maps", "=", "False", ",", "scope", "=", "None", ")", ":", "if", "output_stride", "!=", "8", "and", "output_strid...
https://github.com/yuantailing/ctw-baseline/blob/081c8361b0ed0675bf619ab6316ebf8415e93f46/classification/slim/nets/inception_resnet_v2.py#L94-L267
OpenCobolIDE/OpenCobolIDE
c78d0d335378e5fe0a5e74f53c19b68b55e85388
open_cobol_ide/extlibs/pygments/lexers/templates.py
python
CssDjangoLexer.__init__
(self, **options)
[]
def __init__(self, **options): super(CssDjangoLexer, self).__init__(CssLexer, DjangoLexer, **options)
[ "def", "__init__", "(", "self", ",", "*", "*", "options", ")", ":", "super", "(", "CssDjangoLexer", ",", "self", ")", ".", "__init__", "(", "CssLexer", ",", "DjangoLexer", ",", "*", "*", "options", ")" ]
https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/pygments/lexers/templates.py#L1323-L1324
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py
python
DistInfoDistribution._parsed_pkg_info
(self)
Parse and cache metadata
Parse and cache metadata
[ "Parse", "and", "cache", "metadata" ]
def _parsed_pkg_info(self): """Parse and cache metadata""" try: return self._pkg_info except AttributeError: metadata = self.get_metadata(self.PKG_INFO) self._pkg_info = email.parser.Parser().parsestr(metadata) return self._pkg_info
[ "def", "_parsed_pkg_info", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_pkg_info", "except", "AttributeError", ":", "metadata", "=", "self", ".", "get_metadata", "(", "self", ".", "PKG_INFO", ")", "self", ".", "_pkg_info", "=", "email", ".",...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L2857-L2864
Tencent/bk-bcs-saas
2b437bf2f5fd5ce2078f7787c3a12df609f7679d
bcs-app/backend/container_service/clusters/flow_views/node.py
python
CreateNode.create
(self)
return Response({})
添加节点 1. 检查节点是否可用 2. 触发OPS api
添加节点 1. 检查节点是否可用 2. 触发OPS api
[ "添加节点", "1", ".", "检查节点是否可用", "2", ".", "触发OPS", "api" ]
def create(self): """添加节点 1. 检查节点是否可用 2. 触发OPS api """ # 校验集群edit权限 self.check_perm() # 校验数据 self.check_data() self.ip_list = [ip.split(',')[0] for ip in self.data['ip']] # 检测IP是否被占用 can_use_hosts(self.project_info["cc_app_id"], self.username, self.ip_list) self.project_nodes = paas_cc.get_all_cluster_hosts(self.access_token) self.check_node_ip() # 获取已经存在的IP,直接更新使用 removed_ips, remained_ips = self.get_removed_remained_ips() # 更新IP self.update_nodes(removed_ips) # 添加IP self.add_nodes(remained_ips) # 获取节点是否需要NAT cluster_info = self.get_cluster_info() self.need_nat = cluster_info.get('need_nat', True) # 现阶段平台侧不主动创建CMDB set&module,赋值为空列表 self.module_id_list = [] # 请求ops api with client.ContextActivityLogClient( project_id=self.project_id, user=self.username, resource_type=ACTIVITY_RESOURCE_TYPE, resource=','.join(self.ip_list)[:32], ).log_add(): # 更新所有节点为初始化中 node_info_list = self.update_cluster_nodes(self.ip_list) log = self.create_node_by_bcs(node_info_list) if not log.is_finished and log.is_polling: log.polling_task() return Response({})
[ "def", "create", "(", "self", ")", ":", "# 校验集群edit权限", "self", ".", "check_perm", "(", ")", "# 校验数据", "self", ".", "check_data", "(", ")", "self", ".", "ip_list", "=", "[", "ip", ".", "split", "(", "','", ")", "[", "0", "]", "for", "ip", "in", "...
https://github.com/Tencent/bk-bcs-saas/blob/2b437bf2f5fd5ce2078f7787c3a12df609f7679d/bcs-app/backend/container_service/clusters/flow_views/node.py#L242-L279
Scalsol/mega.pytorch
a6aa6e0537b82d70da94228100a51e6a53d98f82
mega_core/modeling/balanced_positive_negative_sampler.py
python
BalancedPositiveNegativeSampler.__init__
(self, batch_size_per_image, positive_fraction)
Arguments: batch_size_per_image (int): number of elements to be selected per image positive_fraction (float): percentage of positive elements per batch
Arguments: batch_size_per_image (int): number of elements to be selected per image positive_fraction (float): percentage of positive elements per batch
[ "Arguments", ":", "batch_size_per_image", "(", "int", ")", ":", "number", "of", "elements", "to", "be", "selected", "per", "image", "positive_fraction", "(", "float", ")", ":", "percentage", "of", "positive", "elements", "per", "batch" ]
def __init__(self, batch_size_per_image, positive_fraction): """ Arguments: batch_size_per_image (int): number of elements to be selected per image positive_fraction (float): percentage of positive elements per batch """ self.batch_size_per_image = batch_size_per_image self.positive_fraction = positive_fraction
[ "def", "__init__", "(", "self", ",", "batch_size_per_image", ",", "positive_fraction", ")", ":", "self", ".", "batch_size_per_image", "=", "batch_size_per_image", "self", ".", "positive_fraction", "=", "positive_fraction" ]
https://github.com/Scalsol/mega.pytorch/blob/a6aa6e0537b82d70da94228100a51e6a53d98f82/mega_core/modeling/balanced_positive_negative_sampler.py#L10-L17
facebookresearch/hydra
9b2f4d54b328d1551aa70a241a1d638cbe046367
build_helpers/build_helpers.py
python
ANTLRCommand.run
(self)
Run command.
Run command.
[ "Run", "command", "." ]
def run(self) -> None: """Run command.""" root_dir = abspath(dirname(__file__)) project_root = abspath(dirname(basename(__file__))) for grammar in [ "hydra/grammar/OverrideLexer.g4", "hydra/grammar/OverrideParser.g4", ]: command = [ "java", "-jar", join(root_dir, "bin/antlr-4.8-complete.jar"), "-Dlanguage=Python3", "-o", join(project_root, "hydra/grammar/gen/"), "-Xexact-output-dir", "-visitor", join(project_root, grammar), ] self.announce( f"Generating parser for Python3: {command}", level=distutils.log.INFO ) subprocess.check_call(command)
[ "def", "run", "(", "self", ")", "->", "None", ":", "root_dir", "=", "abspath", "(", "dirname", "(", "__file__", ")", ")", "project_root", "=", "abspath", "(", "dirname", "(", "basename", "(", "__file__", ")", ")", ")", "for", "grammar", "in", "[", "\...
https://github.com/facebookresearch/hydra/blob/9b2f4d54b328d1551aa70a241a1d638cbe046367/build_helpers/build_helpers.py#L175-L199
mahmoud/boltons
270e974975984f662f998c8f6eb0ebebd964de82
boltons/ioutils.py
python
SpooledBytesIO.seek
(self, pos, mode=0)
return self.buffer.seek(pos, mode)
[]
def seek(self, pos, mode=0): return self.buffer.seek(pos, mode)
[ "def", "seek", "(", "self", ",", "pos", ",", "mode", "=", "0", ")", ":", "return", "self", ".", "buffer", ".", "seek", "(", "pos", ",", "mode", ")" ]
https://github.com/mahmoud/boltons/blob/270e974975984f662f998c8f6eb0ebebd964de82/boltons/ioutils.py#L269-L270
BillBillBillBill/Tickeys-linux
2df31b8665004c58a5d4ab05277f245267d96364
tickeys/kivy_32/kivy/core/window/__init__.py
python
WindowBase.toggle_fullscreen
(self)
Toggle between fullscreen and windowed mode. .. deprecated:: 1.9.0 Use :attr:`fullscreen` instead.
Toggle between fullscreen and windowed mode.
[ "Toggle", "between", "fullscreen", "and", "windowed", "mode", "." ]
def toggle_fullscreen(self): '''Toggle between fullscreen and windowed mode. .. deprecated:: 1.9.0 Use :attr:`fullscreen` instead. ''' pass
[ "def", "toggle_fullscreen", "(", "self", ")", ":", "pass" ]
https://github.com/BillBillBillBill/Tickeys-linux/blob/2df31b8665004c58a5d4ab05277f245267d96364/tickeys/kivy_32/kivy/core/window/__init__.py#L645-L651
softlayer/softlayer-python
cdef7d63c66413197a9a97b0414de9f95887a82a
SoftLayer/CLI/block/set_note.py
python
cli
(env, volume_id, note)
Set note for an existing block storage volume.
Set note for an existing block storage volume.
[ "Set", "note", "for", "an", "existing", "block", "storage", "volume", "." ]
def cli(env, volume_id, note): """Set note for an existing block storage volume.""" block_manager = SoftLayer.BlockStorageManager(env.client) block_volume_id = helpers.resolve_id(block_manager.resolve_ids, volume_id, 'Block Volume') result = block_manager.volume_set_note(block_volume_id, note) if result: click.echo("Set note successfully!") else: click.echo("Note could not be set! Please verify your options and try again.")
[ "def", "cli", "(", "env", ",", "volume_id", ",", "note", ")", ":", "block_manager", "=", "SoftLayer", ".", "BlockStorageManager", "(", "env", ".", "client", ")", "block_volume_id", "=", "helpers", ".", "resolve_id", "(", "block_manager", ".", "resolve_ids", ...
https://github.com/softlayer/softlayer-python/blob/cdef7d63c66413197a9a97b0414de9f95887a82a/SoftLayer/CLI/block/set_note.py#L17-L28
akkana/scripts
bb59210acd3cef9a7eaccf5e082feff9d2b1b97d
gitbranchsync.py
python
check_push_status
(repo, silent=False)
return modfiles, alllocaldiffs, allremotediffs
Does this repo have changes that haven't been pushed upstream? Print any info, but also return the number of changes that differ. If silent is set, don't print anything, just calculate and return.
Does this repo have changes that haven't been pushed upstream? Print any info, but also return the number of changes that differ. If silent is set, don't print anything, just calculate and return.
[ "Does", "this", "repo", "have", "changes", "that", "haven", "t", "been", "pushed", "upstream?", "Print", "any", "info", "but", "also", "return", "the", "number", "of", "changes", "that", "differ", ".", "If", "silent", "is", "set", "don", "t", "print", "a...
def check_push_status(repo, silent=False): """Does this repo have changes that haven't been pushed upstream? Print any info, but also return the number of changes that differ. If silent is set, don't print anything, just calculate and return. """ modfiles = 0 # git status --porcelain -uno porcelain = repo.git.status(porcelain=True).splitlines() for l in porcelain: if not l.startswith("?? "): if not silent: if not modfiles: print("Need to commit locally modified files:") print(l) modfiles += 1 if not silent: print("") differences = 0 alllocaldiffs = 0 allremotediffs = 0 # Another workaround for the git 2.11.0 bug: try: heads = repo.heads except TypeError as e: print("Skipping repo %s due to git bug:\n %s" % (repo.git_dir, str(e))) return None, None, None for ref in heads: localdiffs, remotediffs = comprefs(ref) alllocaldiffs += localdiffs allremotediffs += remotediffs upstream = ref.tracking_branch() if not upstream: # Can't push if there's no upstream! continue if localdiffs or remotediffs: if not differences: if not silent: print("Need to push:") needspush = True elif not silent: print("Up to date with %s" % upstream.name) if localdiffs > 0 and not silent: print(" %s is ahead of %s by %d commits" % (ref.name, upstream.name, localdiffs)) if remotediffs > 0 and not silent: print(" %s is ahead of %s by %d commits" % (upstream.name, ref.name, remotediffs)) # Perhaps temporarily, compare with the output of what I used before, # git for-each-ref --format="%(refname:short) %(push:track)" refs/heads | fgrep '[ahead' foreachref = repo.git.execute(['git', 'for-each-ref', '--format="%(refname:short) %(push:track)"', 'refs/heads']).splitlines() # git.execute weirdly adds " at the beginning and end of each line. foundref = False for line in foreachref: if '[ahead' in line: if line.startswith('"') and line.endswith('"'): line = line[1:-1] if not foundref: if not silent: print("for-each-ref says:") foundref = True if not silent: print(" " + line) return modfiles, alllocaldiffs, allremotediffs
[ "def", "check_push_status", "(", "repo", ",", "silent", "=", "False", ")", ":", "modfiles", "=", "0", "# git status --porcelain -uno", "porcelain", "=", "repo", ".", "git", ".", "status", "(", "porcelain", "=", "True", ")", ".", "splitlines", "(", ")", "fo...
https://github.com/akkana/scripts/blob/bb59210acd3cef9a7eaccf5e082feff9d2b1b97d/gitbranchsync.py#L62-L131
bookwyrm-social/bookwyrm
0c2537e27a2cdbc0136880dfbbf170d5fec72986
bookwyrm/models/import_job.py
python
ImportItem.rating
(self)
return None
x/5 star rating for a book
x/5 star rating for a book
[ "x", "/", "5", "star", "rating", "for", "a", "book" ]
def rating(self): """x/5 star rating for a book""" if self.normalized_data.get("rating"): return float(self.normalized_data.get("rating")) return None
[ "def", "rating", "(", "self", ")", ":", "if", "self", ".", "normalized_data", ".", "get", "(", "\"rating\"", ")", ":", "return", "float", "(", "self", ".", "normalized_data", ".", "get", "(", "\"rating\"", ")", ")", "return", "None" ]
https://github.com/bookwyrm-social/bookwyrm/blob/0c2537e27a2cdbc0136880dfbbf170d5fec72986/bookwyrm/models/import_job.py#L168-L172
vslavik/bakefile
0757295c3e4ac23cd1e0767c77c14c2256ed16e1
3rdparty/antlr3/python-runtime/antlr3/recognizers.py
python
BaseRecognizer.endResync
(self)
A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter.
A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter.
[ "A", "hook", "to", "listen", "in", "on", "the", "token", "consumption", "during", "error", "recovery", ".", "The", "DebugParser", "subclasses", "this", "to", "fire", "events", "to", "the", "listenter", "." ]
def endResync(self): """ A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter. """ pass
[ "def", "endResync", "(", "self", ")", ":", "pass" ]
https://github.com/vslavik/bakefile/blob/0757295c3e4ac23cd1e0767c77c14c2256ed16e1/3rdparty/antlr3/python-runtime/antlr3/recognizers.py#L485-L491
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/groups/models.py
python
Group.user_in_group
(cls, user_id, group_id)
[]
def user_in_group(cls, user_id, group_id): if not user_id or not group_id: return False c = cls.get_db().view( 'groups/by_user', key=user_id, startkey_docid=group_id, endkey_docid=group_id ).count() if c == 0: return False elif c == 1: return True else: raise Exception( "This should just logically not be possible unless the group " "has the user in there twice" )
[ "def", "user_in_group", "(", "cls", ",", "user_id", ",", "group_id", ")", ":", "if", "not", "user_id", "or", "not", "group_id", ":", "return", "False", "c", "=", "cls", ".", "get_db", "(", ")", ".", "view", "(", "'groups/by_user'", ",", "key", "=", "...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/groups/models.py#L255-L272
ztosec/hunter
4ee5cca8dc5fc5d7e631e935517bd0f493c30a37
HunterCelery/common/http_util.py
python
get_parent_route
(url)
return result
获得父级路由 :param url: :return:
获得父级路由 :param url: :return:
[ "获得父级路由", ":", "param", "url", ":", ":", "return", ":" ]
def get_parent_route(url): """ 获得父级路由 :param url: :return: """ parameter = re.split(r'/[^/]*$', url, re.S) try: result = parameter[0] + "/" except IndexError: result = url + "/" if result == "https://" or result == "http://": result = url + "/" return result
[ "def", "get_parent_route", "(", "url", ")", ":", "parameter", "=", "re", ".", "split", "(", "r'/[^/]*$'", ",", "url", ",", "re", ".", "S", ")", "try", ":", "result", "=", "parameter", "[", "0", "]", "+", "\"/\"", "except", "IndexError", ":", "result"...
https://github.com/ztosec/hunter/blob/4ee5cca8dc5fc5d7e631e935517bd0f493c30a37/HunterCelery/common/http_util.py#L135-L148
zzzeek/sqlalchemy
fc5c54fcd4d868c2a4c7ac19668d72f506fe821e
lib/sqlalchemy/sql/compiler.py
python
IdentifierPreparer._requires_quotes_illegal_chars
(self, value)
return not self.legal_characters.match(util.text_type(value))
Return True if the given identifier requires quoting, but not taking case convention into account.
Return True if the given identifier requires quoting, but not taking case convention into account.
[ "Return", "True", "if", "the", "given", "identifier", "requires", "quoting", "but", "not", "taking", "case", "convention", "into", "account", "." ]
def _requires_quotes_illegal_chars(self, value): """Return True if the given identifier requires quoting, but not taking case convention into account.""" return not self.legal_characters.match(util.text_type(value))
[ "def", "_requires_quotes_illegal_chars", "(", "self", ",", "value", ")", ":", "return", "not", "self", ".", "legal_characters", ".", "match", "(", "util", ".", "text_type", "(", "value", ")", ")" ]
https://github.com/zzzeek/sqlalchemy/blob/fc5c54fcd4d868c2a4c7ac19668d72f506fe821e/lib/sqlalchemy/sql/compiler.py#L5124-L5127
veusz/veusz
5a1e2af5f24df0eb2a2842be51f2997c4999c7fb
veusz/windows/mainwindow.py
python
MainWindow.dropEvent
(self, event)
Respond to a drop event on the current window
Respond to a drop event on the current window
[ "Respond", "to", "a", "drop", "event", "on", "the", "current", "window" ]
def dropEvent(self, event): """Respond to a drop event on the current window""" if event.mimeData().hasUrls(): files = self._getVeuszDropFiles(event) if files: if self.document.isBlank(): self.openFileInWindow(files[0]) else: self.CreateWindow(files[0]) for filename in files[1:]: self.CreateWindow(filename)
[ "def", "dropEvent", "(", "self", ",", "event", ")", ":", "if", "event", ".", "mimeData", "(", ")", ".", "hasUrls", "(", ")", ":", "files", "=", "self", ".", "_getVeuszDropFiles", "(", "event", ")", "if", "files", ":", "if", "self", ".", "document", ...
https://github.com/veusz/veusz/blob/5a1e2af5f24df0eb2a2842be51f2997c4999c7fb/veusz/windows/mainwindow.py#L254-L264
googlearchive/appengine-flask-skeleton
8c25461d003a0bd99a9ff3b339c2791ee6919242
lib/jinja2/parser.py
python
Parser.parse_assign_target
(self, with_tuple=True, name_only=False, extra_end_rules=None)
return target
Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are wanted `name_only` can be set to `True`. The `extra_end_rules` parameter is forwarded to the tuple parsing function.
Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are wanted `name_only` can be set to `True`. The `extra_end_rules` parameter is forwarded to the tuple parsing function.
[ "Parse", "an", "assignment", "target", ".", "As", "Jinja2", "allows", "assignments", "to", "tuples", "this", "function", "can", "parse", "all", "allowed", "assignment", "targets", ".", "Per", "default", "assignments", "to", "tuples", "are", "parsed", "that", "...
def parse_assign_target(self, with_tuple=True, name_only=False, extra_end_rules=None): """Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are wanted `name_only` can be set to `True`. The `extra_end_rules` parameter is forwarded to the tuple parsing function. """ if name_only: token = self.stream.expect('name') target = nodes.Name(token.value, 'store', lineno=token.lineno) else: if with_tuple: target = self.parse_tuple(simplified=True, extra_end_rules=extra_end_rules) else: target = self.parse_primary() target.set_ctx('store') if not target.can_assign(): self.fail('can\'t assign to %r' % target.__class__. __name__.lower(), target.lineno) return target
[ "def", "parse_assign_target", "(", "self", ",", "with_tuple", "=", "True", ",", "name_only", "=", "False", ",", "extra_end_rules", "=", "None", ")", ":", "if", "name_only", ":", "token", "=", "self", ".", "stream", ".", "expect", "(", "'name'", ")", "tar...
https://github.com/googlearchive/appengine-flask-skeleton/blob/8c25461d003a0bd99a9ff3b339c2791ee6919242/lib/jinja2/parser.py#L360-L382