code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def _init_volume(self, scvolume): <NEW_LINE> <INDENT> pf = self._get_payload_filter() <NEW_LINE> pf.append('scSerialNumber', scvolume.get('scSerialNumber'), 'Equals') <NEW_LINE> r = self.client.post('StorageCenter/ScServer/GetList', pf.payload) <NEW_LINE> if r.status_code == 200: <NEW_LINE> <INDENT> scservers = self._g... | Maps the volume to a random server and immediately unmaps
it. This initializes the volume.
Don't wig out if this fails. | 625941ee29b78933be1e5bff |
def crosswalk(self): <NEW_LINE> <INDENT> self.setStatus('REGENERATING CONTENT') <NEW_LINE> self.setUpCrosswalk() <NEW_LINE> self.runCrossWalk() <NEW_LINE> self.postHarvestData() <NEW_LINE> self.finishHarvest() | The crosswalk method is used to re-transform the content of already harvested content
this feature will be implemented after R34 | 625941ee91f36d47f21aca52 |
def nanl2_relative_error(y_true, y_pred): <NEW_LINE> <INDENT> err = y_true - y_pred <NEW_LINE> err = np.nan_to_num(err) <NEW_LINE> y_true = np.nan_to_num(y_true) <NEW_LINE> return np.linalg.norm(err) / np.linalg.norm(y_true) | Return the L2 relative error treating Not a Numbers (NaNs) as zero. | 625941ee91f36d47f21aca53 |
def test_command_line_interface(): <NEW_LINE> <INDENT> runner = CliRunner() <NEW_LINE> result = runner.invoke(cli.main) <NEW_LINE> assert result.exit_code == 0 <NEW_LINE> assert 'jenkins_triage.cli.main' in result.output <NEW_LINE> help_result = runner.invoke(cli.main, ['--help']) <NEW_LINE> assert help_result.exit_cod... | Test the CLI. | 625941ee462c4b4f79d1dc29 |
def DeployCommand(self, project, authname, server=None): <NEW_LINE> <INDENT> python_path = self._preferences[launcher.Preferences.PREF_PYTHON] <NEW_LINE> sdk_root_path = self._preferences[launcher.Preferences.PREF_APPENGINE] <NEW_LINE> if not python_path or not sdk_root_path: <NEW_LINE> <INDENT> return None <NEW_LINE> ... | Build a command for deploying (to Google) the project.
Args:
project: the launcher.Project we want to run.
authname: the authorization name (e.g. fred@gmail.com)
server: the server to deploy to. If None, do not specify one
explicitly on the command line.
Returns:
A tuple of executable and args suitable f... | 625941ee10dbd63aa1bd30fc |
def _get_source_package_name(self, file_name): <NEW_LINE> <INDENT> if not os.path.isfile(file_name): <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> package_pattern = r'^\s*package\s+([\w.]+)' <NEW_LINE> content = open(file_name).read() <NEW_LINE> m = re.search(package_pattern, content, re.MULTILINE) <NEW_LINE> if m:... | Get the java package name from source file if it is specified. | 625941eecc0a2c11143dd3eb |
def tinyfy_url(self,longurl): <NEW_LINE> <INDENT> params = urllib.urlencode({"longurl":longurl}) <NEW_LINE> url = 'http://is.gd/api.php?' + params <NEW_LINE> f = self._get_urlopener().open(url) <NEW_LINE> rsp = "".join(f.readlines()) <NEW_LINE> return rsp | Creates a tiny url using http://is.gd/api_info.php service
| 625941ee090684286d50f249 |
def translate(params: Dict , **data: Dict) -> Dict: <NEW_LINE> <INDENT> shiftX = params.get('x', 0) <NEW_LINE> shiftY = params.get('y', 0) <NEW_LINE> if shiftX == 0 and shiftY == 0: <NEW_LINE> <INDENT> return data <NEW_LINE> <DEDENT> image = data.get('image') <NEW_LINE> M = np.float32([[1, 0, shiftX], [0, 1, shiftY]]) ... | Translates (Shifts) an image by a NumPy matrix in the form:
[[1, 0, shiftX], [0, 1, shiftY]] .
Parameters:
- params:
y: int=0; number of pixels to shift
x: int=0; number of pixels to shift
- data:
image: ndarray; the image
Returns:
- data:
image: ndarray; the result image | 625941ee76e4537e8c351bd1 |
def httpHandle(requestString): <NEW_LINE> <INDENT> header = requestString.split('\n') <NEW_LINE> header = [n.split(' ') for n in header] <NEW_LINE> return (header[0][0], header[0][1][1:], header[1][1]) | Given a http request return its arguments
method, fileName and content | 625941ee96565a6dacc8fc23 |
def allocGetQuestionAllocation(self, dbLec, student, settings, **kwargs): <NEW_LINE> <INDENT> from ..allocation.base import Allocation <NEW_LINE> from ..sync.questions import getQuestionAllocation <NEW_LINE> alloc = Allocation.allocFor( student=student, dbLec=dbLec, urlBase=self.layer['portal'].absolute_url(), ) <NEW_L... | Helper that generates alloc for us | 625941ee5fcc89381b1e1c1d |
def initialize_space(space, a, b): <NEW_LINE> <INDENT> for i in range(dimension): <NEW_LINE> <INDENT> space[i][0] = a <NEW_LINE> space[i][1] = b <NEW_LINE> <DEDENT> return space | set the bounds values for search space. | 625941ee4f88993c3716c5bb |
def rank_columns_mean_plot(df, attatchment_path, show=False): <NEW_LINE> <INDENT> fig, line = plt.subplots(figsize=(8.8,6), sharex=True, sharey=True) <NEW_LINE> line.bar(remove_string_columns(df).columns, df[0:get_iMax(df)].mean(), label = "Mean", color="green") <NEW_LINE> line.grid(axis = "y", linestyle="-", color="da... | In:
df: All of the data (Pandas DataFrame)
attatchment_path: Path where plots will be saved (str)
show: Decides if plot is shown or not (Boolean)
Does: Creates a plot with all means of all columns.
Returns:
None | 625941ee67a9b606de4a8410 |
def predictedGrid(self, x, y, model, full=False): <NEW_LINE> <INDENT> if full: <NEW_LINE> <INDENT> grid = self.grid <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> print("Downsampling...") <NEW_LINE> if self.grid.shape[0]>30: <NEW_LINE> <INDENT> grid = randin(self.grid, 30) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> p... | Prediction for an entire grid of points
Parameters
----------
x, y : 1D array
coordinates of the points on the predicted grid
model : Model
model to use
full : boolean
If False, the original grid will be downsampled for performances
issue. Use True for a prediction based on the entire orig... | 625941ee796e427e537b0b25 |
def test_load_only_required_from_dict(self): <NEW_LINE> <INDENT> d = { "id": 88042, "creationTimeSeconds": 1387381320, "hacker": { "contestId": 374, "members": [{"handle": "ocozalp"}], "participantType": "CONTESTANT", "ghost": False, "room": 24, "startTimeSeconds": 1387380600 }, "defender": { "contestId": 374, "members... | Required fields are:
id,
creationTimeSeconds,
hacker,
defender,
problem | 625941ee6fb2d068a760f600 |
def __ge__(self, other: 'Signature') -> bool: <NEW_LINE> <INDENT> n1, n2, _ = self._to_common_denominator(other) <NEW_LINE> return n1 >= n2 | Compares two signatures.
Signatures are transformed to the common denominator and then their nominators are compared.
:param other: other signature
:return: True if this signature is greater or equal than other signature | 625941eecc0a2c11143dd3ec |
def decide(self): <NEW_LINE> <INDENT> if self._search_context.get_current_serp_position() < self.__depth: <NEW_LINE> <INDENT> return Actions.SNIPPET <NEW_LINE> <DEDENT> return Actions.QUERY | If the user's current position in the current SERP is < the maximum depth, look at the next snippet in the SERP.
Otherwise, a new query should be issued. | 625941eebde94217f3683346 |
def get_equations_for(self, variables, recurse=True, strip_units=True): <NEW_LINE> <INDENT> if strip_units: <NEW_LINE> <INDENT> graph = self.graph_with_sympy_numbers <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> graph = self.graph <NEW_LINE> <DEDENT> sorted_variables = nx.lexicographical_topological_sort(graph, key=str... | Get all equations for a given collection of variables.
Results are sorted first by dependencies, then by variable name.
:param variables: The variables to get the equations for (as :class:`Variable` objects).
:param recurse: Indicates whether to recurse the equation graph, or to return only the top level equations.
:... | 625941ee07f4c71912b119df |
def send(self, port, m): <NEW_LINE> <INDENT> self.log("-> {}: {}", port, m) <NEW_LINE> self._network_ref.send(self._label, port, m) | Sends a message through the given port. Non-blocking. | 625941ee1f5feb6acb0c50a4 |
def mandelbrot_set(xmin, xmax, ymin, ymax, width, height, maxiter): <NEW_LINE> <INDENT> start = time.time() <NEW_LINE> cols = np.linspace(xmin, xmax, width) <NEW_LINE> rows = np.linspace(ymin, ymax, height) <NEW_LINE> arr_img = np.empty((width, height)) <NEW_LINE> for i in range(width): <NEW_LINE> <INDENT> print("%.2f%... | Function that chooses some rectangle in the complex plane
according to the given parameters and plots the coloring
of mandelbrot as an image while also timing the process.
Args:
xmin: lowest x-axis value
xmax: highest x-axis value
ymin: lowest y-axis value
ymax: highest y-axis value
width: length o... | 625941ee85dfad0860c3b3b7 |
def merge_list(left, right): <NEW_LINE> <INDENT> result = [] <NEW_LINE> i = 0 <NEW_LINE> j = 0 <NEW_LINE> while(i < len(left) or j < len(right)): <NEW_LINE> <INDENT> if(i < len(left) and j < len(right)): <NEW_LINE> <INDENT> if(left[i] <= right[j]): <NEW_LINE> <INDENT> result.append(left[i]) <NEW_LINE> i += 1 <NEW_LINE>... | Merge sorted left and right list. Compare elements of 2 list and sort them | 625941eefb3f5b602dac3bf3 |
def __init__(self, items=None): <NEW_LINE> <INDENT> self._items = None <NEW_LINE> self.discriminator = None <NEW_LINE> if items is not None: <NEW_LINE> <INDENT> self.items = items | TournamentBase - a model defined in Swagger | 625941ee5fcc89381b1e1c1e |
def __init__(self, filepattern, vocab, test=False, shuffle_on_load=False): <NEW_LINE> <INDENT> self._data_forward = LMDataset(filepattern, vocab, test=test, reverse=False, shuffle_on_load=shuffle_on_load) <NEW_LINE> self._data_backward = LMDataset(filepattern, vocab, test=test, reverse=True, shuffle_on_load=shuffle_on_... | bidirectional version of LMDataset | 625941ee0383005118ecfb3b |
def build_solution(self): <NEW_LINE> <INDENT> raise NotImplementedError() | Given a solution this should yield (point, shape_id) tuples in the
order that they were placed down
Args:
None
Return:
Generator of point, shape_id tuples | 625941ee3d592f4c4ed1d5b9 |
def filter(self, task, operation, regexps): <NEW_LINE> <INDENT> rest = [] <NEW_LINE> method = Entry.accept if 'accept' in operation else Entry.reject <NEW_LINE> match_mode = 'excluding' not in operation <NEW_LINE> for entry in task.entries: <NEW_LINE> <INDENT> log.trace('testing %i regexps to %s' % (len(regexps), entry... | :param task: Task instance
:param operation: one of 'accept' 'reject' 'accept_excluding' and 'reject_excluding'
accept and reject will be called on the entry if any of the regxps match
*_excluding operations will be called if any of the regexps don't match
:param regexps: list of {co... | 625941ee67a9b606de4a8411 |
def solve_superlink_depths_alt(self): <NEW_LINE> <INDENT> _I_1k = self._I_1k <NEW_LINE> _I_Nk = self._I_Nk <NEW_LINE> _U_Ik = self._U_Ik <NEW_LINE> _V_Ik = self._V_Ik <NEW_LINE> _W_Ik = self._W_Ik <NEW_LINE> _X_Ik = self._X_Ik <NEW_LINE> _Y_Ik = self._Y_Ik <NEW_LINE> _Z_Ik = self._Z_Ik <NEW_LINE> _Q_uk = self._Q_uk <NE... | Solve for depths at superlink ends given discharges and
superjunction heads at time t + dt. | 625941eef548e778e58cdada |
@register.inclusion_tag('comments/inclusions/_form.html', takes_context=True) <NEW_LINE> def show_comment_form(context, post, form=None): <NEW_LINE> <INDENT> if form is None: <NEW_LINE> <INDENT> form = CommentForm <NEW_LINE> <DEDENT> return { 'form': form, 'post': post, } | 显示评论表单 | 625941ee60cbc95b062c6a9e |
def create_minibatch_data(self): <NEW_LINE> <INDENT> self.minibatch_data.reset(numpy.zeros( (self.max_minibatch_size,) + self.shape, dtype=self.dtype)) | Allocate arrays for minibatch_data etc. here.
| 625941ee76d4e153a657f08d |
def test_post_conflict(self): <NEW_LINE> <INDENT> manager = factory.consumer_manager() <NEW_LINE> manager.register(self.CONSUMER_IDS[0]) <NEW_LINE> body = {'id' : self.CONSUMER_IDS[0]} <NEW_LINE> status, body = self.post('/v2/consumers/', params=body) <NEW_LINE> self.assertEqual(409, status) | Tests creating a consumer with an existing ID. | 625941ee66673b3332b925eb |
def show(self, where=stderr): <NEW_LINE> <INDENT> where.write('expression_level=%d\n' % self.expression_level) <NEW_LINE> super().show(where) <NEW_LINE> if self.current_column: <NEW_LINE> <INDENT> where.write('-' * (self.current_column-1)) <NEW_LINE> <DEDENT> where.write('^\n') | Emit also current expression_level and a "pointer" showing current_column. | 625941ee1f037a2d8b946757 |
def show_option (channel, itemlist, text_color='yellow', thumbnail=None, fanart=None): <NEW_LINE> <INDENT> logger.info() <NEW_LINE> if thumbnail == None: <NEW_LINE> <INDENT> thumbnail = 'https://s7.postimg.org/65ooga04b/Auto_Play.png' <NEW_LINE> <DEDENT> if fanart == None: <NEW_LINE> <INDENT> fanart = 'https://s7.posti... | Agrega la opcion Configurar AutoPlay en la lista recibida
:param channel: str
:param itemlist: list (lista donde se desea integrar la opcion de configurar AutoPlay)
:param text_color: str (color para el texto de la opcion Configurar Autoplay)
:param thumbnail: str (direccion donde se encuentra el thumbnail para la opc... | 625941ee66656f66f7cbc708 |
def on_exit(self, event): <NEW_LINE> <INDENT> self.Close(True) | Salir del programa | 625941ee45492302aab5e824 |
def saveDocument(self, doc): <NEW_LINE> <INDENT> if doc.url().isEmpty(): <NEW_LINE> <INDENT> return self.saveDocumentAs(doc) <NEW_LINE> <DEDENT> filename = dest = doc.url().toLocalFile() <NEW_LINE> if not filename: <NEW_LINE> <INDENT> dest = doc.url().toString() <NEW_LINE> <DEDENT> if not util.iswritable(filename): <NE... | Saves the document, asking for a name if necessary.
Returns True if saving succeeded. | 625941ee3617ad0b5ed68451 |
def make_dict_from_cols(col_names): <NEW_LINE> <INDENT> dictionary = {col_name: [] for col_name in col_names} <NEW_LINE> return dictionary | Create dictionary from a list of column names | 625941eed486a94d0b98e6a1 |
def is_room_admin(room_id, username): <NEW_LINE> <INDENT> return room_members_collection.count_documents( {'_id': {'room_id': ObjectId(room_id), 'username': username}, 'is_room_admin': True}) | checks the database if the specified user in an admin for a specified room
:param room_id:
:param username:
:return: checks if the user is a room admin | 625941ee566aa707497f4abc |
def set_user_password(self, user, password, hash_method=None): <NEW_LINE> <INDENT> if hash_method: <NEW_LINE> <INDENT> method = self.db_session.query(HashMethod) .filter(HashMethod.name == hash_method) .filter(HashMethod.allowed.is_(True)) .first() <NEW_LINE> <DEDENT> else: ... | Set user's password using hash_method. | 625941eed10714528d600244 |
def test_size(binary_tree): <NEW_LINE> <INDENT> binary_tree.size == 1 <NEW_LINE> binary_tree.insert(3) <NEW_LINE> binary_tree.size == 2 | Test that we get the correct size. | 625941ee7b25080760e399b0 |
def update_actors(self): <NEW_LINE> <INDENT> progress = self.get_train_progress() <NEW_LINE> self.actors.update_state(progress=progress) | Updates the actors with current training state | 625941ee07d97122c4178df3 |
def __init__(self): <NEW_LINE> <INDENT> self.random_set = set() | Initialize your data structure here. | 625941ee3c8af77a43ae3d02 |
def get_valid_varnames(self, varnames=None): <NEW_LINE> <INDENT> if varnames is None: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> if isinstance(varnames, string_types): <NEW_LINE> <INDENT> varnames = [varnames] <NEW_LINE> <DEDENT> for vn in list(varnames): <NEW_LINE> <INDENT> if vn is True: <NEW_LINE> <INDENT> ... | Filter out var names that are not valid or not equal to 'locations'
If names are explicit numeric arrays, they are unchanged | 625941ee26068e7796caf242 |
def relativeYear(self,count): <NEW_LINE> <INDENT> y,m,d=self.now.timetuple()[:3] <NEW_LINE> y1=y+count <NEW_LINE> try: <NEW_LINE> <INDENT> new_date=dt.date(y1,m,d) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> if m==2 and d==29: <NEW_LINE> <INDENT> m,d=3,1 <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> rais... | Given the number of years (positive or negative) to offset from
self.now, return the datetime.date value of the result.
This method is intended to be called from the convert() method of a
subclass of DateParser. It requires that self.now already be
initialized to an appropriate value. | 625941eeb7558d58953c5463 |
def __init__(self, whitelist_spec=None): <NEW_LINE> <INDENT> super(PciHostDevicesWhiteList, self).__init__() <NEW_LINE> if whitelist_spec: <NEW_LINE> <INDENT> self.spec = self._parse_white_list_from_config(whitelist_spec) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.spec = None | White list constructor
For example, followed json string specifies that devices whose
vendor_id is '8086' and product_id is '1520' can be assigned
to guest.
'[{"product_id":"1520", "vendor_id":"8086"}]'
:param whitelist_spec: A json string for a list of dictionaries,
each dictionary specifies t... | 625941eeb545ff76a8914370 |
def read(self): <NEW_LINE> <INDENT> return self.serialPort.readAll().data() | 读取串口收到的数据
:return: bytes | 625941ee925a0f43d254a3d7 |
def _load_experiment_module(self, experiment_module): <NEW_LINE> <INDENT> self.path, experiment_module = os.path.split(experiment_module) <NEW_LINE> self.name, dot_py = os.path.splitext(experiment_module) <NEW_LINE> assert(dot_py == '.py') <NEW_LINE> self.module_reload = 'import sys; sys.path.append("%s"); '%self.path... | Argument experiment_module is command line argument 0, specifying the
file path to the experiment module. | 625941ee0c0af96317bb8742 |
def series_sum(): <NEW_LINE> <INDENT> n=int(input('Please enter a non-negative integer: ')) <NEW_LINE> if n<0: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> i=1 <NEW_LINE> sum=1000 <NEW_LINE> while i<n+1: <NEW_LINE> <INDENT> sum=sum+(1/(i**2)) <NEW_LINE> i=i+1 <NEW_LINE> <DEDENT> return ... | (none)->number
Prompts user for input n and returns 1000+sigma[1,n][1/n^2]. | 625941eee5267d203edce1f1 |
def update(self): <NEW_LINE> <INDENT> self.rect.x += self.change_x <NEW_LINE> self.rect.y += self.change_y <NEW_LINE> if self.rect.right >= screen_width: <NEW_LINE> <INDENT> self.rect.x -= 5 <NEW_LINE> bump_sound.play() <NEW_LINE> <DEDENT> if self.rect.left <= 0: <NEW_LINE> <INDENT> self.rect.x += 5 <NEW_LINE> bump_sou... | Find a new position for the player | 625941ee24f1403a926010bc |
def setPanZoomAll(self, setPanZoomAllFlag = 'true'): <NEW_LINE> <INDENT> result = self.con.cmdTagList("setPanZoomAll", imageView=self.getId(), setPanZoomAllFlag=setPanZoomAllFlag) <NEW_LINE> return result | Set whether or not a pan/zoom operation should affect all layers in the stack
or just the top layer.
Returns
-------
list
Error message if an error occurred; nothing otherwise. | 625941ee16aa5153ce3629d4 |
def __getattr__(self, name): <NEW_LINE> <INDENT> return getattr(self.state, name) | For all other methods, just delegate.
| 625941eeec188e330fd5acef |
def test_it_fetch_one(self): <NEW_LINE> <INDENT> schema = self._schema_restore() <NEW_LINE> self.session.query(schema).first() | testing fetching from resurected model | 625941ee23e79379d52eeab8 |
def longestValidParentheses(self, s): <NEW_LINE> <INDENT> start = 0 <NEW_LINE> maxlen = 0 <NEW_LINE> stack = [] <NEW_LINE> for i in range(len(s)): <NEW_LINE> <INDENT> if s[i] == '(': <NEW_LINE> <INDENT> stack.append(i) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if len(stack) == 0: <NEW_LINE> <INDENT> start = i + 1 <... | :type s: str
:rtype: int | 625941ee293b9510aa2c37eb |
def bowling(balls): <NEW_LINE> <INDENT> score = [0] <NEW_LINE> strike = [0, 0] <NEW_LINE> spare = [0] <NEW_LINE> i = 0 <NEW_LINE> frame = 1 <NEW_LINE> def advance(): <NEW_LINE> <INDENT> curr = balls[i] <NEW_LINE> score[0] += curr <NEW_LINE> score[0] += curr * strike[0] <NEW_LINE> strike[0], strike[1] = strike[1], 0 <NE... | Compute the total score for a player's game of bowling. | 625941eebe8e80087fb21195 |
def informationschemacomment(payload, **kwargs): <NEW_LINE> <INDENT> retVal = payload <NEW_LINE> if payload: <NEW_LINE> <INDENT> retVal = re.sub(r"(?i)(information_schema)\.", "\g<1>/**/.", payload) <NEW_LINE> <DEDENT> return retVal | Add a comment to the end of all occurrences of (blacklisted) "information_schema" identifier
>>> tamper('SELECT table_name FROM INFORMATION_SCHEMA.TABLES')
'SELECT table_name FROM INFORMATION_SCHEMA/**/.TABLES' | 625941eefbf16365ca6f672a |
def LSBDescription(self): <NEW_LINE> <INDENT> if not self._lsb_description and self.OSType() == "Linux": <NEW_LINE> <INDENT> if hasCommand("lsb_release"): <NEW_LINE> <INDENT> lsbstr = os.popen("lsb_release -d").read()[:-1] <NEW_LINE> if lsbstr: <NEW_LINE> <INDENT> self._lsb_description = lsbstr.split(":")[-1].strip() <... | wrapper around lsb_release -d | 625941ee3eb6a72ae02eca47 |
def import_variables(self, container): <NEW_LINE> <INDENT> for keyword in self.tkvariables: <NEW_LINE> <INDENT> setattr(container, keyword, self.tkvariables[keyword]) | Helper method to avoid call get_variable for every variable. | 625941ee167d2b6e312190f0 |
def test_comment_get_comment_hash(self): <NEW_LINE> <INDENT> comment_txt = 'foo' <NEW_LINE> form_data = {'comment': comment_txt} <NEW_LINE> form = CommentForm(user=self.user, data=form_data, topic=self.topic) <NEW_LINE> self.assertTrue(form.is_valid()) <NEW_LINE> comment_txt_to_hash = '{}thread-{}'.format(comment_txt, ... | Should return the comment hash | 625941ee15fb5d323cde1073 |
def rend(self): <NEW_LINE> <INDENT> return _fife.InstanceSet_rend(self) | rend(InstanceSet self) -> std::set< FIFE::Instance * >::reverse_iterator | 625941eefbf16365ca6f672b |
def _build_base_structure(self): <NEW_LINE> <INDENT> driver_time = ntplib.system_to_ntp_time(time.time()) <NEW_LINE> result = {} <NEW_LINE> result[DataParticleKey.DRIVER_TIMESTAMP] = driver_time <NEW_LINE> result = copy.deepcopy(self.contents) <NEW_LINE> if not self.contents[DataParticleKey.PORT_TIMESTAMP]: <NEW_LINE> ... | Build the base/header information for an output structure.
Follow on methods can then modify it by adding or editing values.
@return A fresh copy of a core structure to be exported | 625941eed18da76e23532a38 |
def create_game(): <NEW_LINE> <INDENT> global game <NEW_LINE> game = game_m.Game(names, deck_size, hand_size, trump_suit, feature_type, buffer_features, only_ais) | Create a new game with the global parameters. | 625941ee3317a56b8693a1a6 |
def test_mariadb_raid(provider, keyid, secret, token, imageid, subscription, tenant, projectid, instancetype, user, localpath, region, zone, sriov, kernel): <NEW_LINE> <INDENT> disk_size = 0 <NEW_LINE> raid = 10 <NEW_LINE> if provider == constants.AWS: <NEW_LINE> <INDENT> disk_size = 100 <NEW_LINE> <DEDENT> elif provid... | Run MariaDB test on 2 instances using 12 x SSD devices in RAID 0.
:param provider Service provider to be used e.g. azure, aws, gce.
:param keyid: user key for executing remote connection
:param secret: user secret for executing remote connection
:param token: GCE refresh token obtained with gcloud sdk
:param subscripti... | 625941ee63b5f9789fde7641 |
def get_dnskey(self, keytag: str) -> Optional[DnsKey]: <NEW_LINE> <INDENT> return self.dnskeys.get(keytag) | Get dnskey from keytag | 625941eecdde0d52a9e53593 |
def __contains__(self, item): <NEW_LINE> <INDENT> for elem in self._items[:self._index+1]: <NEW_LINE> <INDENT> if elem == item: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Returns True if item is in the stack,
and False otherwise. | 625941eeb5575c28eb68e560 |
def add_world_name(self, world_name): <NEW_LINE> <INDENT> self.world_name = world_name | Сохраняет название мира для hud | 625941ee3eb6a72ae02eca48 |
def connect(): <NEW_LINE> <INDENT> DB = psycopg2.connect("dbname=tournament") <NEW_LINE> c = DB.cursor() <NEW_LINE> return (DB, c) | Connect to the PostgreSQL db. Returns a db connection and cursor. | 625941ee7d847024c06be81c |
def int_to_si(n): <NEW_LINE> <INDENT> m = abs(n) <NEW_LINE> sign = -1 if n < 0 else 1 <NEW_LINE> if m < 1e3: <NEW_LINE> <INDENT> return str(n) <NEW_LINE> <DEDENT> if m < 1e6: <NEW_LINE> <INDENT> return '{0}K'.format(sign*int(m / 1e3)) <NEW_LINE> <DEDENT> if m < 1e9: <NEW_LINE> <INDENT> return '{0}M'.format(sign*int(m /... | Convert integer to string with SI magnitude.
`n` will be truncated.
Examples: 5432 ==> 5k, 12345678 ==> 12M
Args:
n: Integer to represent as a string.
Returns:
String representation of `n` containing SI magnitude. | 625941eeb830903b967e9e60 |
def _update_block_device_mapping(self, elevated_context, instance_type, instance_id, block_device_mapping): <NEW_LINE> <INDENT> LOG.debug(_("block_device_mapping %s"), block_device_mapping) <NEW_LINE> for bdm in block_device_mapping: <NEW_LINE> <INDENT> assert 'device_name' in bdm <NEW_LINE> values = {'instance_id': in... | tell vm driver to attach volume at boot time by updating
BlockDeviceMapping | 625941ee21bff66bcd684ea9 |
def backprop_layer(self, G_layer_output): <NEW_LINE> <INDENT> if self.param is None: return G_layer_output <NEW_LINE> layer_input, layer_output, layer_input_org_shape = self.aux <NEW_LINE> G_affine = cm.activate_derv(G_layer_output, layer_output, self.actfunc) <NEW_LINE> layer_input_trans = layer_input.transpose() <NEW... | :param G_output: 각 층의 dL/dY
:return: | 625941ee2c8b7c6e89b35d17 |
def init_user(self): <NEW_LINE> <INDENT> tmp_session = self.session() <NEW_LINE> init = relationship( user_name=default_user, level=0, type='', referer='self') <NEW_LINE> tmp_session.add(init) <NEW_LINE> tmp_session.commit() <NEW_LINE> tmp_session.close() | "初始化用户 | 625941ee5fc7496912cc3ed9 |
def read_text_file(filename): <NEW_LINE> <INDENT> with open(filename, 'r') as text_file: <NEW_LINE> <INDENT> dirty_text = text_file.read() <NEW_LINE> <DEDENT> return dirty_text | read a text file and return its contents as a string | 625941eed8ef3951e3243a99 |
def execute_workflow(self, app_id: str) -> JobInfo: <NEW_LINE> <INDENT> job_info = self._post(f"/v1/workflows/{app_id}/jobs/") <NEW_LINE> return JobInfo(**job_info) | Queue an app execution job.
Returns
-------
JobInfo
Information about the job | 625941ee31939e2706e4d3bd |
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False): <NEW_LINE> <INDENT> if extra_args is None: extra_args = [ None for _ in range(num_nodes) ] <NEW_LINE> if binary is None: binary = [ None for _ in range(num_nodes) ] <NEW_LINE> rpcs = [] <NEW_LINE> try:... | Start multiple super8ds, return RPC connections to them | 625941ee627d3e7fe0d693ad |
@app.route("/") <NEW_LINE> def home(): <NEW_LINE> <INDENT> return ( f"Available Routes:<br/>" f"/api/v1.0/precipitation" f"/api/v1.0/stations" f"/api/v1.0/tobs" f"/api/v1.0/<start>" f"/api/v1.0/<start>/<end>" ) | List all available api routes. | 625941eea05bb46b383ecd78 |
def testLogicalDhcpServerListResult(self): <NEW_LINE> <INDENT> pass | Test LogicalDhcpServerListResult | 625941ee6aa9bd52df037303 |
def Caeser_decrypt(message:str,key:int)->str: <NEW_LINE> <INDENT> ALPHABET = 'abcdefghijklmnopqrstuvwxyz' <NEW_LINE> decyph_key = str.maketrans(ALPHABET[key%26:]+ ALPHABET[0:key%26],ALPHABET) <NEW_LINE> return message.lower().translate(decyph_key) | decrypt a message according to a key with a shift of a given number | 625941ee99fddb7c1c9de8e9 |
def __init__(self, media_item, parent, manager): <NEW_LINE> <INDENT> super(EditCustomForm, self).__init__(parent) <NEW_LINE> self.manager = manager <NEW_LINE> self.media_item = media_item <NEW_LINE> self.setupUi(self) <NEW_LINE> self.edit_slide_form = EditCustomSlideForm(self) <NEW_LINE> self.preview_button.clicked.con... | Constructor | 625941eed7e4931a7ee9e47b |
def test_creation(self): <NEW_LINE> <INDENT> person = self.Person(name="Test User", age=30) <NEW_LINE> self.assertEqual(person.name, "Test User") <NEW_LINE> self.assertEqual(person.age, 30) | Ensure that document may be created using keyword arguments. | 625941ee046cf37aa974d29d |
def __init__(self, cow='default', eyes='oo', tongue=' ', thoughts='\\', width=40): <NEW_LINE> <INDENT> self.cows = None <NEW_LINE> self.cow = get_cow(cow) <NEW_LINE> if not isinstance(width, int) or width < 1: <NEW_LINE> <INDENT> message = 'Width must be int > 0' <NEW_LINE> raise ValueError(message) <NEW_LINE> <DEDENT... | Initialize the internal variables.
Args:
cow (str): The cow to use. Use the module functions list_cows to
see which avatars can be used
eyes (str): The eyes string, must be length 2
tongue (str): The tongue string, must be length 2
thoughts (str): The thoughts string, must be length 1
width... | 625941eed58c6744b42581b9 |
def register(self, address, proxy): <NEW_LINE> <INDENT> if address in self.addr: <NEW_LINE> <INDENT> self.addr[address].append(proxy) <NEW_LINE> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | register a proxy in a one address device | 625941ee377c676e91272702 |
def __init__(self, rng, input, filter_shape, image_shape, poolsize=(2, 2)): <NEW_LINE> <INDENT> assert image_shape[1] == filter_shape[1] <NEW_LINE> self.input = input <NEW_LINE> fan_in = numpy.prod(filter_shape[1:]) <NEW_LINE> fan_out = (filter_shape[0] * numpy.prod(filter_shape[2:]) // numpy.prod(poolsize)) <NEW_LINE>... | Allocate a LeNetConvPoolLayer with shared variable internal parameters.
:type rng: numpy.random.RandomState
:param rng: a random number generator used to initialize weights
:type input: theano.tensor.dtensor4
:param input: symbolic image tensor, of shape image_shape
:type filter_shape: tuple or list of length 4
:par... | 625941eea79ad161976cc6a1 |
def __validate_config(self): <NEW_LINE> <INDENT> cls = self.__class__ <NEW_LINE> if self.__config is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for o in cls.__required_opts: <NEW_LINE> <INDENT> if not self.__config.has_option('config', o): <NEW_LINE> <INDENT> self.result = TestResult() <NEW_LINE> self.result[... | Validate config.
Check that that all required options are present. If
validation fails, set ``self.result`` to failure.
Currently, this function does not validate the options'
values.
:return: None | 625941ee7cff6e4e81117ee1 |
def display_board(): <NEW_LINE> <INDENT> print("\n\t", board[0], "|", board[1], "|", board[2]) <NEW_LINE> print("\t", "-----------") <NEW_LINE> print("\n\t", board[3], "|", board[4], "|", board[5]) <NEW_LINE> print("\t", "-----------") <NEW_LINE> print("\n\t", board[6], "|", board[7], "|", board[8]) | Wyświetla plansze gry na ekranie | 625941eeb57a9660fec33de8 |
def iterLabels(self): <NEW_LINE> <INDENT> lo = int(math.floor(self.min / self.step + 1 - 1e-9)) <NEW_LINE> hi = int(math.floor(self.max / self.step + 1e-9)) <NEW_LINE> for i in xrange(lo, hi + 1): <NEW_LINE> <INDENT> value = i * self.step <NEW_LINE> if self.min == 0 and i == 0: <NEW_LINE> <INDENT> continue <NEW_LINE> <... | Helper to iterate through all the tick marks along the axis. | 625941ee004d5f362079a88b |
def lookup_index(self, index): <NEW_LINE> <INDENT> if index not in self.idx_to_token: <NEW_LINE> <INDENT> raise Keyerror("the index (%d) is not in the Vocabulary" % index) <NEW_LINE> <DEDENT> return self.idx_to_token[index] | Retrieve the token associated with the token or the UNK index if token isn't present.
Args:
token (str): the index to look up.
Returns:
index (int): the token corresponding to the index.
Raises:
Keyerror: if the index is not in the Vocabulary. | 625941ee99cbb53fe6793140 |
def to_list(self): <NEW_LINE> <INDENT> return [ self.table1, self.fid1, self.table2, self.fid2, self.int_geom, self.msg ] | Load attribute values from a list.
Args:
arr: List with fid1, table1, fid2, table2, int_geom, msg values. | 625941eebe7bc26dc91cdb51 |
@delayed <NEW_LINE> def clean_cuota_tarjeta_de_credito_column(dataframe): <NEW_LINE> <INDENT> df = dataframe.copy() <NEW_LINE> df['cuota_tarjeta_de_credito'] = df['cuota_tarjeta_de_credito'].apply(lambda x: float(x)) <NEW_LINE> print(f'Variable 6 terminó') <NEW_LINE> return df | [summary]
Args:
dataframe ([type]): [description]
Returns:
[type]: [description] | 625941ee236d856c2ad44d3e |
def set_option(self, name, value): <NEW_LINE> <INDENT> if name not in ('debug', 'verify_fingerprint', 'driver'): <NEW_LINE> <INDENT> raise TypeError('No such option: ' + repr(name)) <NEW_LINE> <DEDENT> if self.options is None: <NEW_LINE> <INDENT> self.options = {} <NEW_LINE> <DEDENT> self.options[name] = value | Defines a (possibly protocol-specific) option for the host.
Possible options include:
verify_fingerprint: bool
@type name: str
@param name: The option name.
@type value: object
@param value: The option value. | 625941ee9f2886367277ade4 |
def test_unhabred(self): <NEW_LINE> <INDENT> self.resource._request.register_uri( 'GET', '/hub/python/unhabred?page=2', 'fixture_hub.json') <NEW_LINE> response = self.resource.unhabred('python', 2) <NEW_LINE> self.assertTrue('data' in response) <NEW_LINE> self.assertTrue('server_time' in response) | Test HubResource.unhabred(alias, page) method | 625941ee507cdc57c6307244 |
@pytest.mark.control <NEW_LINE> def test_auth_add_cmd_line(volttron_instance_encrypt): <NEW_LINE> <INDENT> platform = volttron_instance_encrypt <NEW_LINE> auth_add_cmd_line(platform, _auth_entry1) <NEW_LINE> entries = auth_list_json(platform) <NEW_LINE> assert len(entries) > 0 <NEW_LINE> assert_auth_entries_same(entrie... | Add a single entry, specifying parameters on the command line | 625941eed18da76e23532a39 |
def refresh_zone_status(self): <NEW_LINE> <INDENT> response = requests.get( "http://" + self._host + ":" + str(self._port) + "/getZone") <NEW_LINE> dom = minidom.parseString(response.text) <NEW_LINE> if _get_dom_elements(dom, "member"): <NEW_LINE> <INDENT> self._zone_status = ZoneStatus(dom) <NEW_LINE> <DEDENT> else: <... | Refresh Zone Status. | 625941eebd1bec0571d90b8b |
def ffmpeg_error_catcher(loop, channel, err): <NEW_LINE> <INDENT> if not err: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> LOGGER.error( f'FFmpeg failed while streaming: {type(err).__name__}, {err.args!r}' ) <NEW_LINE> reporter_coro = channel.send('Had an issue while streaming; try again.') <NEW_LINE> fut = asyncio.r... | Passed into `VoiceContoller.play` to handle and report FFmpeg errors.
Inspired by:
https://discordpy.readthedocs.io/en/latest/faq.html#id13 | 625941ee2ae34c7f2600d68c |
def set_joint_angle(self, link_num, new_angle): <NEW_LINE> <INDENT> raise PendingDeprecationWarning("Will likely be unused") <NEW_LINE> if (link_num < 0) or (link_num >= self.num_joints): <NEW_LINE> <INDENT> error_str = "link number given ({0}) is not between range of 0 (inclusive) and {1} (exclusive)" <NEW_LINE> raise... | Set the angle (radians) for a specific joint in the robot.
:param link_num: Index of the joint in the robot arm (Base = 0, Gripper = end)
:type link_num: `int`
:param new_angle: The required angle to set the arm rotated towards
:type new_angle: `float`
:raise IndexError: Link index must be between 0 (inclusive) and nu... | 625941ee9b70327d1c4e1334 |
def test_price_empty(self): <NEW_LINE> <INDENT> login = super(Test_Order_Case, self).Auth(self.signup_data) <NEW_LINE> data = json.loads(login.data.decode()) <NEW_LINE> token = data['access_token'] <NEW_LINE> res = self.app.post(ADD_ORDER_URL, headers=dict(Authorization="Bearer " + token), data=json.dumps(self.price_it... | Test price is not an integer | 625941ee01c39578d7e75397 |
def setup_pipeline(self): <NEW_LINE> <INDENT> self.glyph = glyph.Glyph(scale_mode='scale_by_scalar', color_mode='color_by_scalar', show_scale_mode=True) <NEW_LINE> actor = self.actor = Actor() <NEW_LINE> actor.mapper.scalar_visibility = 1 <NEW_LINE> actor.property.set(line_width=2, backface_culling=False, frontface_cul... | Override this method so that it *creates* the tvtk
pipeline.
This method is invoked when the object is initialized via
`__init__`. Note that at the time this method is called, the
tvtk data pipeline will *not* yet be setup. So upstream data
will not be available. The idea is that you simply create the
basic objects... | 625941ee7b180e01f3dc4d4d |
def addInPort(self, *args): <NEW_LINE> <INDENT> return _pilot.OutputPort_addInPort(self, *args) | addInPort(OutputPort self, InPort inPort) -> bool | 625941ee090684286d50f24a |
def get_table_names(): <NEW_LINE> <INDENT> return ['metadata', 'films', 'ratings', 'users', 'favouriteFilms', 'names', 'crew'] | Stores all table names. | 625941ee1d351010ab856076 |
def test_exception_in_response_building( base_endpoint, core_manager, managed_application_client, server_rule_prototype, server_response_prototype, ): <NEW_LINE> <INDENT> rule = server_rule_prototype.create_new(match_implementation=True) <NEW_LINE> exceptional_rule_id = core_manager.add_rule(rule=rule) <NEW_LINE> succe... | Check that rule is skipped if exception is raised while building a response.
1. Create 2 rules, matching every request.
2. Set response for the first rule, raising an exception.
3. Set response for the second rule.
4. Make a request.
5. Check that response, build for the second rule, is returned. | 625941eeb830903b967e9e61 |
def dilated_resnet152(**kwargs): <NEW_LINE> <INDENT> return get_dilated_resnet(2, 152, **kwargs) | Dilated_ResNet-152 V2 model from `"Identity Mappings in Deep Residual Networks"
<https://arxiv.org/abs/1603.05027>`_ paper.
Parameters
----------
pretrained : bool, default False
Whether to load the pretrained weights for model.
ctx : Context, default CPU
The context in which to load the pretrained weights.
ro... | 625941eebaa26c4b54cb1675 |
def clean_member_no(self): <NEW_LINE> <INDENT> member_no = self.cleaned_data['member_no'] <NEW_LINE> if not member_no: <NEW_LINE> <INDENT> if Member.objects.filter(member_no=member_no): <NEW_LINE> <INDENT> raise forms.ValidationError(_("Member No. is already taken")) <NEW_LINE> <DEDENT> max_no = Member.objects.all().ag... | Validate member's No. uniqueness or gets a new one | 625941ee4a966d76dd551571 |
def clever_cat(source): <NEW_LINE> <INDENT> for path in source: <NEW_LINE> <INDENT> if path.endswith('.gz'): <NEW_LINE> <INDENT> cat_generator = gzcat <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> cat_generator = cat <NEW_LINE> <DEDENT> for line in cat_generator((path,)): <NEW_LINE> <INDENT> yield line | Determine wrapper format by filename and delegate to correct cat generator. | 625941ee090684286d50f24b |
def get_timeout(self): <NEW_LINE> <INDENT> return self.options['timeout'] | The time period for which the persistence is in effect for a specific client. The value ranges from 2 to 1440 minutes.
Default value: 2
Minimum value = 0
Maximum value = 1440 | 625941ee31939e2706e4d3be |
def uvp_masks(rmask): <NEW_LINE> <INDENT> rmask = np.asarray(rmask) <NEW_LINE> if rmask.ndim != 2: <NEW_LINE> <INDENT> raise ValueError('rmask must be a 2D array') <NEW_LINE> <DEDENT> if not np.all((rmask == 0) | (rmask ==1 )): <NEW_LINE> <INDENT> raise ValueError('rmask array must contain only ones and zeros.') <NEW_L... | return u-, v-, and psi-masks based on input rho-mask
Parameters
----------
rmask : ndarray
mask at CGrid rho-points
Returns
-------
(umask, vmask, pmask) : ndarrays
masks at u-, v-, and psi-points | 625941ee76e4537e8c351bd3 |
def print_summaries(summaries, vocab): <NEW_LINE> <INDENT> i2w = {key: value for value, key in vocab.items()} <NEW_LINE> for idx in range(len(summaries)): <NEW_LINE> <INDENT> fout = open(os.path.join(args.output_dir, "%d.txt" % idx), "w") <NEW_LINE> line = [i2w[tok] for tok in summaries[idx] if tok != vocab["</s>"]] <N... | param summaries: in shape (seq_len, batch) | 625941eecc40096d61595eaa |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.