code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def sum(array, axis=None, keepdims=False, name=None): <NEW_LINE> <INDENT> if not isinstance(array, Node): <NEW_LINE> <INDENT> array = ConstantNode.create_using(array) <NEW_LINE> <DEDENT> opvalue = np.sum(array, axis=axis, keepdims=keepdims) <NEW_LINE> return OperationalNode.create_using(opvalue, 'sum', array, name=name... | defines a node in the computational graph representing a sum operation
Parameters:
----------
array: Node | ndarray | number
the array to be summed
axis: int
the axis to perform the sum on
keepdims: Boolean
a flag to determine if the dimensions are kept
name: String
node's name in the graph | 625941c5379a373c97cfab51 |
def factor( self, pol ): <NEW_LINE> <INDENT> LSTools.p( 'factoring ', pol, ' in ', self ) <NEW_LINE> if pol in self.get_num_field(): <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> fct_lst = sage_factor( pol ) <NEW_LINE> LSTools.p( '\t', fct_lst ) <NEW_LINE> return fct_lst | INPUT:
- "pol" -- A univariate polynomial in "self.pol_ring".
OUTPUT
- A list of factors of "pol" in "PolyRing.pol_ring":
[ ( <polynomial-factor>, <multiplicity> ), ... ]
If "pol" is a constant then the empty list is returned. | 625941c57c178a314d6ef46a |
def test_simpacks(): <NEW_LINE> <INDENT> from . import simpacks as problematic_simpacks_package <NEW_LINE> simpacks = list( import_tools.import_all(problematic_simpacks_package).values() ) <NEW_LINE> simpacks_dir = os.path.dirname(problematic_simpacks_package.__file__) <NEW_LINE> assert len( path_tools.list_sub_... | Test problematic simpacks. | 625941c5a79ad161976cc152 |
def is_valid_pdf(fname): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> pdfrw.PdfReader(fname) <NEW_LINE> <DEDENT> except pdfrw.PdfParseError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> except Exception: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return True | Check the pdf file is valid.
A pdf file is only valid if it can be open with pdfrw with on error | 625941c501c39578d7e74e48 |
def padright(self, padding): <NEW_LINE> <INDENT> if self.ndim != 1: <NEW_LINE> <INDENT> raise NotImplementedError("unimplemented for ndim=%s" % self.ndim) <NEW_LINE> <DEDENT> padded = NomialArray(np.hstack((self, padding))) <NEW_LINE> _ = padded.units <NEW_LINE> return padded | Returns (self[0], self[1] ... self[N], {padding}) | 625941c515fb5d323cde0b1b |
def delete(self, request, treeId, nodeId): <NEW_LINE> <INDENT> node = Node.objects.get(id=nodeId) <NEW_LINE> node.delete() <NEW_LINE> return Response(None, status=status.HTTP_204_NO_CONTENT) | Delete a node | 625941c55510c4643540f3f4 |
def test_13(self): <NEW_LINE> <INDENT> con_string = 'Huehue=troll;' <NEW_LINE> obj = ConnectionString.from_string(con_string) <NEW_LINE> self.assertEqual(str(obj), con_string) <NEW_LINE> try: <NEW_LINE> <INDENT> self.assertEqual(unicode(obj), con_string) <NEW_LINE> <DEDENT> except NameError: <NEW_LINE> <INDENT> pass | Casting the ConnectionString object to unicode/string returns the connection string | 625941c55fdd1c0f98dc0240 |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(UserCreationForm, self).__init__(*args, **kwargs) <NEW_LINE> self.fields.pop('username') | Changes the order of fields, and removes the username field. | 625941c5656771135c3eb87a |
def d_ks_test(x, y, **kwargs): <NEW_LINE> <INDENT> kwargs.setdefault('simulate_p_value', True) <NEW_LINE> kwargs.setdefault('alternative', 'less') <NEW_LINE> x = np.array(x).astype(int) <NEW_LINE> y = np.array(y).astype(int) <NEW_LINE> x = robj.IntVector(x) <NEW_LINE> y = robj.IntVector(y) <NEW_LINE> results = dgof.ks_... | Discrete ks test from R package dgof
:param x:
:param y:
:param kwargs:
:return: | 625941c5cc0a2c11143dce9d |
def ResponseStats(self): <NEW_LINE> <INDENT> return pywrapsat.SatHelper.SolverResponseStats(self.__solution) | Returns some statistics on the solution found as a string. | 625941c599fddb7c1c9de39f |
def main(): <NEW_LINE> <INDENT> print('iPOPO initialization') <NEW_LINE> init_ipopo(wait_for_message, fire_content_to) <NEW_LINE> print('starting main loop') <NEW_LINE> while True: <NEW_LINE> <INDENT> msg = extract_herald_message() <NEW_LINE> if msg: <NEW_LINE> <INDENT> manage_message(msg) <NEW_LINE> <DEDENT> component... | main loop of microNode | 625941c54c3428357757c336 |
def delete_entity_rows(self, entity_name, query): <NEW_LINE> <INDENT> entity_data = self.get(entity_name, query) <NEW_LINE> if len(entity_data['items']) == 0: <NEW_LINE> <INDENT> self.logger.error('Query returned 0 results, no row to delete.') <NEW_LINE> raise Exception('Query returned 0 results, no row to delete.') <N... | delete entity rows
Args:
entity_name (string): Name of the entity to update
query (list): List of dictionaries which contain query to select the row to update (see documentation of get()) | 625941c5460517430c394196 |
def _roi_2d(self): <NEW_LINE> <INDENT> self._x_d = -self._x_d if (self._x_d >= -self._L / 2.) and (self._x_d < 0) else self._x_d <NEW_LINE> self._y_d = -self._y_d if (self._y_d >= -self._L / 2.) and (self._y_d < 0) else self._y_d <NEW_LINE> return np.array([self._x_d, self._y_d]) if self._x_d > self._y_d else np.array(... | Moves coordinates (x,y) to triangle area (x',y') in [0,L/2]X[0,x']
without loss of generality | 625941c5c432627299f04c52 |
def totalNQueens(self, n): <NEW_LINE> <INDENT> def try_solve(guess, i): <NEW_LINE> <INDENT> if 0 <= i < n: <NEW_LINE> <INDENT> dia = [] <NEW_LINE> for x in range(i): <NEW_LINE> <INDENT> dia += [x + guess[x] - i, -x + guess[x] + i] <NEW_LINE> <DEDENT> possible = n_list - set(guess) - set(dia) <NEW_LINE> if possible: <NE... | :type n: int
:rtype: int | 625941c50383005118ecf5f1 |
def test_assignment_success_get_by_id(self): <NEW_LINE> <INDENT> actual_assignment = Assignment.get_by_id(101) <NEW_LINE> expected_assignment = Assignment.objects.get(id=101) <NEW_LINE> self.assertEqual(actual_assignment, expected_assignment) | Method that tests succeeded `get_by_id` method of Assignment class object. | 625941c5f7d966606f6aa010 |
def apply_ds(self, voc_ds, repeat_size=1, batch_size=32, num_parallel_workers=None, is_training=True): <NEW_LINE> <INDENT> if not isinstance(voc_ds, VOCDataset): <NEW_LINE> <INDENT> raise TypeError("Input type should be VOCDataset, got {}.".format(type(voc_ds))) <NEW_LINE> <DEDENT> compose_map_func = (lambda image, box... | Apply preprocess operation on VOCDataset instance.
Args:
voc_ds (data.VOCDataset): VOCDataset instance.
repeat_size (int): The repeat size of dataset. Default: 1.
batch_size (int): Batch size. Default: 32.
num_parallel_workers (int): The number of concurrent workers. Default: None.
is_training (boo... | 625941c5d53ae8145f87a27f |
def test_fenced_property_set(self): <NEW_LINE> <INDENT> self.passmanager.append(PassH_Bad_TP()) <NEW_LINE> self.assertSchedulerRaises(self.circuit, self.passmanager, ['run transformation pass PassH_Bad_TP'], TranspilerError) | Transformation passes are not allowed to modify the property set. | 625941c57047854f462a1418 |
def p_jref_4(p): <NEW_LINE> <INDENT> p[0] = p[1] + [None,''] | jref : jitem | 625941c597e22403b379cfa7 |
def error_noisy_col(U, V, Ahat, M, indices): <NEW_LINE> <INDENT> M[:,indices] = 0 <NEW_LINE> return error(U, V, Ahat, M) | rms error on unobserved entries
but ignore the cols in indices | 625941c54d74a7450ccd41d1 |
def __new__(Polygon, points, metadata=None, copy=True, dtype=np.float64): <NEW_LINE> <INDENT> arr = np.array(points, dtype, copy=copy) <NEW_LINE> arr.shape = (-1, 2) <NEW_LINE> arr = arr.view(Polygon) <NEW_LINE> if metadata is not None: <NEW_LINE> <INDENT> arr.metadata = metadata <NEW_LINE> <DEDENT> else: <NEW_LINE> <I... | Takes Points as an array. Data is any python sequence that can be
turned into a Nx2 numpy array of floats. The data will be copied unless
the copy argument is set to False.
metadata is a dict of meta-data. This can hold anything. | 625941c52ae34c7f2600d13f |
def _get_dependent_services_cost( self, date, pricing_service, forecast, service_environments, exclude=None, excluded_services=None, ): <NEW_LINE> <INDENT> result = {} <NEW_LINE> exclude = exclude[:] if exclude else [] <NEW_LINE> exclude.append(pricing_service) <NEW_LINE> dependent_services = pricing_service.get_depend... | Calculates cost of dependent services used by pricing_service. | 625941c57b180e01f3dc480e |
def __init__(self, items, size, enabledPlugins = None): <NEW_LINE> <INDENT> pass | void KIO.PreviewJob.__init__(KFileItemList items, QSize size, QStringList enabledPlugins = None) | 625941c523e79379d52ee572 |
def predict(self, u=0): <NEW_LINE> <INDENT> self._x = dot(self._F, self._x) + dot(self._B, u) <NEW_LINE> self._P = dot3(self._F, self._P, self._F.T) + self._Q | Predict next position.
Parameters
----------
u : np.array
Optional control vector. If non-zero, it is multiplied by B
to create the control input into the system. | 625941c5a8370b77170528ae |
def _tee(self, length): <NEW_LINE> <INDENT> buf2 = self.buf <NEW_LINE> buf2.seek(0, 2) <NEW_LINE> while True: <NEW_LINE> <INDENT> chunk, buf2 = self.parser.filter_body(buf2) <NEW_LINE> if chunk: <NEW_LINE> <INDENT> self.tmp.write(chunk) <NEW_LINE> self.tmp.flush() <NEW_LINE> self.tmp.seek(0, 2) <NEW_LINE> self.buf = St... | fetch partial body | 625941c53d592f4c4ed1d07e |
def test_invalid_config(self): <NEW_LINE> <INDENT> self.render_config_template( path=os.path.abspath(self.working_dir + "/log/") + "*", multiline=True, multiline_type="pattern", match="after", ) <NEW_LINE> proc = self.start_beat() <NEW_LINE> self.wait_until(lambda: self.log_contains("multiline.pattern cannot be empty")... | Test that filebeat errors if pattern is missing config | 625941c53eb6a72ae02ec4e7 |
def validate(self): <NEW_LINE> <INDENT> self.edit_simple_tempory_value() <NEW_LINE> if self._tempory_value != self._old_value or self._auto: <NEW_LINE> <INDENT> self._parent.change_value(self._key, self._tempory_value) | validate change of the value
| 625941c5ec188e330fd5a7af |
def mk_func( self, ctx: Union[RelayParser.FuncContext, RelayParser.DefnContext]) -> function.Function: <NEW_LINE> <INDENT> self.enter_var_scope() <NEW_LINE> self.enter_type_param_scope() <NEW_LINE> type_params = ctx.typeParamList() <NEW_LINE> if type_params is not None: <NEW_LINE> <INDENT> type_params = type... | Construct a function from either a Func or Defn. | 625941c56e29344779a62621 |
def step_fractal_triangle(img, iterations, color, triangle_coordinates): <NEW_LINE> <INDENT> new = [] <NEW_LINE> old = triangle_coordinates <NEW_LINE> for i in ([0, 1], [1, 2], [2, 0]): <NEW_LINE> <INDENT> new.append([(old[i[0]][0] + old[i[1]][0])/2, (old[i[0]][1] + old[i[1]][1])/2]) <NEW_LINE> <DEDENT> for i in ([0, 1... | Makes one iteration of splitting the triangle into four equal triangles.
Than it recursively continues by splitting three triangles in the corners. | 625941c5cc40096d6159595e |
def retrieve_messages(self): <NEW_LINE> <INDENT> query = "label:inbox" <NEW_LINE> for id in self.message_ids(query): <NEW_LINE> <INDENT> yield self.get_message(id) | Retrieve data for all active messages in inbox | 625941c5bd1bec0571d9063c |
def find_length(self, head): <NEW_LINE> <INDENT> length = 0 <NEW_LINE> current = head <NEW_LINE> while current is not None: <NEW_LINE> <INDENT> length += 1 <NEW_LINE> current = current.next <NEW_LINE> <DEDENT> return length | A helper function for the last_element to determine the length of the
linked list | 625941c58c0ade5d55d3e9c7 |
def create_modules(module_defs): <NEW_LINE> <INDENT> hyperparams = module_defs.pop(0) <NEW_LINE> output_filters = [int(hyperparams["channels"])] <NEW_LINE> module_list = nn.ModuleList() <NEW_LINE> for module_i, module_def in enumerate(module_defs): <NEW_LINE> <INDENT> modules = nn.Sequential() <NEW_LINE> if module_def[... | construct layer from list(network) | 625941c576d4e153a657eb3e |
def protection_routing(nd_in, start_in, end_in, route_in, pro_in): <NEW_LINE> <INDENT> layer_name = "ClosestFacility" <NEW_LINE> impedance = "Length" <NEW_LINE> result_object = arcpy.na.MakeClosestFacilityLayer(nd_in, layer_name, impedance, 'TRAVEL_TO', default_cutoff=None, default_number_facilities_to_find=1, output_p... | This function finds a disjoint path between given start-end node pars to the given existing working path.
The general procedure is the same as for the fiber routing but with additional constraint (line barrier) and thus
restricted on one node pair (facility-demand).
:param nd_in: network dataset on which the shortes... | 625941c5462c4b4f79d1d6de |
def __init__( self, evt_type: str, time: int, evt: Optional[VCDTriggerDescriptor] = None, ): <NEW_LINE> <INDENT> if not isinstance(time, int): <NEW_LINE> <INDENT> raise TypeError("time must be an integer") <NEW_LINE> <DEDENT> self._time = time <NEW_LINE> if evt_type not in self.EVENT_TYPES: <NEW_LINE> <INDENT> raise Va... | Initialize. | 625941c57b25080760e39467 |
def romanToInt(self, s): <NEW_LINE> <INDENT> roman = {'M': 1000,'D': 500 ,'C': 100,'L': 50,'X': 10,'V': 5,'I': 1} <NEW_LINE> sum = 0 <NEW_LINE> for i in range(len(s) - 1): <NEW_LINE> <INDENT> if roman[s[i]] < roman[s[i+1]]: <NEW_LINE> <INDENT> sum -= roman[s[i]] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> sum += roma... | :type s: str
:rtype: int | 625941c55fcc89381b1e16cb |
def back_propagate(self, Y): <NEW_LINE> <INDENT> self.deltas[-1] = np.mean(self.output-Y, axis=1, keepdims=True) * self.gPrime(self.acts[-1], self.Zs[-1]) <NEW_LINE> for l in range(self.L-2, 0, -1): <NEW_LINE> <INDENT> self.deltas[l] = self.Ws[l+1].T @ self.deltas[l+1] * self.g... | gets gradients for each layers given forward propagation
has already occurred | 625941c501c39578d7e74e49 |
def revert(self): <NEW_LINE> <INDENT> rcode, stdout, _ = yield "type -t deactivate" <NEW_LINE> if rcode == 0 and stdout.strip() == 'function': <NEW_LINE> <INDENT> yield 'deactivate' | Deactivate virtualenv | 625941c5dd821e528d63b1b8 |
def get_node_statuses(self): <NEW_LINE> <INDENT> return self._tree.get_node_statuses() | Public method access private node status information in ._tree
Returns
-------
pandas.Series
A series with index of nodes, and values of statuses | 625941c576e4537e8c35167f |
def delete(self, data): <NEW_LINE> <INDENT> if self.root is None: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> elif self.root.data == data: <NEW_LINE> <INDENT> if self.root.left is None: <NEW_LINE> <INDENT> self.root = self.root.right <NEW_LINE> <DEDENT> elif self.root.right is None: <NEW_LINE> <INDENT> self.ro... | delete a node from the tree. | 625941c58e05c05ec3eea381 |
def GetColour(self, id): <NEW_LINE> <INDENT> if id == BP_BACKGROUND_COLOUR: <NEW_LINE> <INDENT> return self._background_brush.GetColour() <NEW_LINE> <DEDENT> elif id == BP_GRADIENT_COLOUR_FROM: <NEW_LINE> <INDENT> return self._gradient_colour_from <NEW_LINE> <DEDENT> elif id == BP_GRADIENT_COLOUR_TO: <NEW_LINE> <INDENT... | Returns the option value for the specified colour `id`.
:param integer `id`: the identification bit for the colour value. This can be one of the
following bits:
================================== ======= =====================================
Colour Id Value Description
=================... | 625941c5eab8aa0e5d26db65 |
def get_const_tuple(in_tuple): <NEW_LINE> <INDENT> ret = [] <NEW_LINE> for elem in in_tuple: <NEW_LINE> <INDENT> if isinstance(elem, tvm.tir.Var): <NEW_LINE> <INDENT> ret.append(elem) <NEW_LINE> <DEDENT> elif not isinstance(elem, (tvm.tir.IntImm, int)): <NEW_LINE> <INDENT> elem = tvm.tir.ir_pass.Simplify(elem) <NEW_LIN... | Verifies input tuple is IntImm or Var, returns tuple of int or Var.
Parameters
----------
in_tuple : tuple of Expr
The input.
Returns
-------
out_tuple : tuple of int
The output. | 625941c57c178a314d6ef46b |
@instances.command('stop') <NEW_LINE> @click.option("--project", default=None, help="Only instances for project (tag Project:<name>)") <NEW_LINE> def stop_instances(project): <NEW_LINE> <INDENT> instances = filter_instances(project) <NEW_LINE> for i in instances: <NEW_LINE> <INDENT> print("Stopping {0}...".format(i.id)... | Stop EC2 Instances | 625941c585dfad0860c3ae68 |
def expand_cells(parent, tblock, colcount): <NEW_LINE> <INDENT> ret = [] <NEW_LINE> for row in tblock: <NEW_LINE> <INDENT> ret.append(colcount * [0]) <NEW_LINE> <DEDENT> for rpos, row in enumerate(tblock): <NEW_LINE> <INDENT> cpos = 0 <NEW_LINE> for startpos, rspan, cspan in row: <NEW_LINE> <INDENT> while cpos < len(re... | Generate table layout for validation/rendering | 625941c5eab8aa0e5d26db66 |
def select_move(self, board): <NEW_LINE> <INDENT> explore_message = 'Exploration turn' <NEW_LINE> missing_experience_message = 'No experience for this state: explore' <NEW_LINE> experience_present_message = 'Using previous experience' <NEW_LINE> state_key = Agent.serialize_board(board) <NEW_LINE> log('-' * 100) <NEW_LI... | Choose from exploration and exploitation.
Epsilon greedy implementation for policy.
http://home.deib.polimi.it/restelli/MyWebSite/pdf/rl5.pdf
http://tokic.com/www/tokicm/publikationen/papers/AdaptiveEpsilonGreedyExploration.pdf | 625941c5baa26c4b54cb112e |
def check_edges(self): <NEW_LINE> <INDENT> screen_rect = self.screen.get_rect() <NEW_LINE> if self.rect.right >= screen_rect.right or self.rect.left <= 0: <NEW_LINE> <INDENT> return True | function to check when alien hits the right edge , it moves to the left | 625941c5d58c6744b4257c6e |
def add_op_list(self, op_list): <NEW_LINE> <INDENT> if not isinstance(op_list, op_def_pb2.OpList): <NEW_LINE> <INDENT> raise TypeError("%s is %s, not an op_def_pb2.OpList" % (op_list, type(op_list))) <NEW_LINE> <DEDENT> for op_def in op_list.op: <NEW_LINE> <INDENT> self.add_op(op_def) | Register the OpDefs from an OpList. | 625941c58a43f66fc4b54075 |
def set_permissions(self, role): <NEW_LINE> <INDENT> if role == User.ROLE_ADMIN: <NEW_LINE> <INDENT> for perm in permissions.admin_permissions(): <NEW_LINE> <INDENT> self.user_permissions.add(perm) <NEW_LINE> <DEDENT> <DEDENT> elif role == User.ROLE_MANAGER: <NEW_LINE> <INDENT> for perm in permissions.manager_permissio... | Set user_permissions according to user's role.
Argument:
role - user's role | 625941c5283ffb24f3c55911 |
def get_results(self, competition=None, **extra_filter): <NEW_LINE> <INDENT> return Result.wizard(team=self, competition=competition, **extra_filter) | Return results of a team | 625941c54c3428357757c337 |
def check_model_constraints(self): <NEW_LINE> <INDENT> pass | Since some rules cannot be evaluated at instantiation time this
function should be called on model elements by the interpreter when
building the concrete model.
Don't confuse this with "Constraint" from UML specification
All "check_model_constraints" methods through the whole inheritance
hierarchy should be called. ... | 625941c57cff6e4e81117994 |
def add(self, config): <NEW_LINE> <INDENT> entity = self.session.query(Config).filter(Config.key == config.key).first() <NEW_LINE> if not entity: <NEW_LINE> <INDENT> self.session.add(config) <NEW_LINE> self.session.commit() <NEW_LINE> return config | 新增 | 625941c530c21e258bdfa4aa |
def preview_environment(self, app, settings, config): <NEW_LINE> <INDENT> content = "" <NEW_LINE> if "appenv" in config: <NEW_LINE> <INDENT> content = "\n".join(config["appenv"]) <NEW_LINE> bot.info("+ " + "appenv ".ljust(5) + app) <NEW_LINE> print(settings["appenv"]) <NEW_LINE> print(content) <NEW_LINE> <DEDENT> retur... | preview the environment section
Parameters
==========
app should be the name of the app, for lookup in config['apps']
settings: the output of _init_app(), a dictionary of environment vars | 625941c55fc7496912cc398c |
def test_alternative_data_serializer(wf): <NEW_LINE> <INDENT> data = {'key1': 'value1'} <NEW_LINE> assert wf.data_serializer == 'cpickle' <NEW_LINE> wf.store_data('test', data) <NEW_LINE> for path in _stored_data_paths(wf, 'test', 'cpickle'): <NEW_LINE> <INDENT> assert os.path.exists(path) <NEW_LINE> <DEDENT> assert wf... | Alternative data serializer | 625941c592d797404e304198 |
def extra_url(self): <NEW_LINE> <INDENT> return [] | ##钩子函数
:return: | 625941c571ff763f4b549697 |
def __eq__(self, other): <NEW_LINE> <INDENT> EPS = 1.0e-4 <NEW_LINE> slen = self.nsites <NEW_LINE> olen = other.nsites <NEW_LINE> if slen != olen: <NEW_LINE> <INDENT> if self._verbose or other._verbose: <NEW_LINE> <INDENT> print("potentials are not of the same size.") <NEW_LINE> <DEDENT> return False <NEW_LINE> <DEDENT... | checks of two potentials are equal (in the sense that
the atom coordinates and properties are equal)
NB! No check on the exclusion list is currently done | 625941c591f36d47f21ac4ff |
def test_prod(): <NEW_LINE> <INDENT> pf.set_backend("pytorch") <NEW_LINE> ones = torch.ones([5, 4, 3]) <NEW_LINE> val = ops.prod(ones) <NEW_LINE> assert isinstance(val, torch.Tensor) <NEW_LINE> assert val.ndim == 2 <NEW_LINE> assert val.shape[0] == 5 <NEW_LINE> assert val.shape[1] == 4 <NEW_LINE> assert np.all(val.nump... | Tests prod | 625941c54f88993c3716c076 |
def ins_voce_contab(lrow=0, arg=1): <NEW_LINE> <INDENT> callAlert() <NEW_LINE> PL.ins_voce_contab(lrow, arg) | Inserisce una nuova voce in CONTABILITA. | 625941c58a349b6b435e8181 |
def get_show(self, name): <NEW_LINE> <INDENT> show = None <NEW_LINE> for _show in self.root.findall('Show'): <NEW_LINE> <INDENT> if _show.find('Name').text.startswith(name): <NEW_LINE> <INDENT> show = _show <NEW_LINE> break <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> raise KeyError("No show found for name '{... | returns one show found by its name | 625941c5aad79263cf390a4d |
def __eq__(self, *args): <NEW_LINE> <INDENT> return _DataModel.StationMagnitudeContribution___eq__(self, *args) | __eq__(StationMagnitudeContribution self, StationMagnitudeContribution other) -> bool | 625941c5925a0f43d2549e84 |
def get_actions(self, context, instance_id): <NEW_LINE> <INDENT> return self.db.instance_get_actions(context, instance_id) | Retrieve actions for the given instance. | 625941c523849d37ff7b309e |
def SetDefault(self, parser, default): <NEW_LINE> <INDENT> flag = self.__GetFlag(parser) <NEW_LINE> if flag: <NEW_LINE> <INDENT> kwargs = {flag.dest: default} <NEW_LINE> parser.set_defaults(**kwargs) | Sets the default value for this flag in the given parser.
Args:
parser: The argparse parser.
default: The default flag value. | 625941c56aa9bd52df036db1 |
def reformat(self, **kwargs): <NEW_LINE> <INDENT> self.width = kwargs.pop("width", self.width) <NEW_LINE> self.height = kwargs.pop("height", self.height) <NEW_LINE> for key, value in kwargs.items(): <NEW_LINE> <INDENT> setattr(self, key, value) <NEW_LINE> <DEDENT> hchar = kwargs.pop("header_line_char", self.header_line... | Force a re-shape of the entire table.
Keyword Args:
Table options as per `EvTable.__init__`. | 625941c50fa83653e4656fca |
def __makePage(self, index): <NEW_LINE> <INDENT> bytes_ = self.array_constructor(self.pagesize, self.undefined_value) <NEW_LINE> self.pages[index] = bytes_ <NEW_LINE> return bytes_ | Fills a page bytes | 625941c58c0ade5d55d3e9c8 |
def remove_line(line_number, csv_list): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if not line_number > 0: <NEW_LINE> <INDENT> log.error("The provided line_number: {} is incorrect.".format(line_number)) <NEW_LINE> return None <NEW_LINE> <DEDENT> <DEDENT> except TypeError: <NEW_LINE> <INDENT> log.error("line_number mu... | return the contents of csv_list without the specified line_number. | 625941c530bbd722463cbdd3 |
def write_json(jsonstr="{}", filepath="profile.json"): <NEW_LINE> <INDENT> print("Writing output to " + filepath) <NEW_LINE> f = open(filepath, "w") <NEW_LINE> f.write(jsonstr) <NEW_LINE> f.close() | Save JSON profile on local filesystem. | 625941c5d486a94d0b98e154 |
def read(self, prop): <NEW_LINE> <INDENT> return self.get(prop) | . | 625941c58a349b6b435e8182 |
def draw_game_over(self): <NEW_LINE> <INDENT> output = "Game Over" <NEW_LINE> arcade.draw_text(output, 110, 300, arcade.color.WHITE, 54) <NEW_LINE> output = "Click to restart" <NEW_LINE> arcade.draw_text(output, 180, 250, arcade.color.WHITE, 24) | Draw "Game over" across the screen. | 625941c573bcbd0ca4b2c085 |
def equal(self, value): <NEW_LINE> <INDENT> from .mask import Mask <NEW_LINE> return Mask(self.data == value, wcs=self.wcs, pixelscale=self.pixelscale) | This function ...
:param value:
:return: | 625941c5b7558d58953c4f25 |
def _initFlow(self): <NEW_LINE> <INDENT> for i in range( len(self._imageBuffer)): <NEW_LINE> <INDENT> self._flow.update( self._imageBuffer[i]) | Should be called after buffer is full to compute the optical flow
information on the buffered frames. Only needs to be called once,
prior to first call of _computeBGDiff(), because from then on,
the flow will be updated as new frames are added to the buffer. | 625941c544b2445a339320a5 |
def play(self, time_limit=TIME_LIMIT_MILLIS, show=False): <NEW_LINE> <INDENT> move_history = [] <NEW_LINE> curr_time_millis = lambda: 1000 * timeit.default_timer() <NEW_LINE> while True: <NEW_LINE> <INDENT> legal_player_moves = self.get_legal_moves() <NEW_LINE> game_copy = self.copy() <NEW_LINE> if show is True: <NEW_L... | Execute a match between the players by alternately soliciting them
to select a move and applying it in the game.
Parameters
----------
time_limit : numeric (optional)
The maximum number of milliseconds to allow before timeout
during each turn.
Returns
----------
(player, list<[(int, int),]>, str)
Return m... | 625941c596565a6dacc8f6da |
def test_profile_image_requested_field(self): <NEW_LINE> <INDENT> source_comments = [self.create_source_comment()] <NEW_LINE> self.register_get_thread_response({ "id": self.thread_id, "course_id": unicode(self.course.id), "thread_type": "discussion", "children": source_comments, "resp_total": 100, }) <NEW_LINE> self.re... | Tests all comments retrieved have user profile image details if called in requested_fields | 625941c5097d151d1a222e69 |
def __init__(self, *column, **options): <NEW_LINE> <INDENT> if len(column) == 2: <NEW_LINE> <INDENT> self.__model, self.__column = column <NEW_LINE> <DEDENT> elif len(column) == 1: <NEW_LINE> <INDENT> column = column[0] <NEW_LINE> try: <NEW_LINE> <INDENT> if issubclass(column, orb.Model): <NEW_LINE> <INDENT> self.__mod... | Initializes the Query instance. The only required variable
is the column name, the rest can be manipulated after
creation. This class takes a variable set of information
to initialize. You can initialize a blank query object
by supplying no arguments, which is useful when generating
queries in a loop, or you can sup... | 625941c53346ee7daa2b2d7a |
def autodiscover(): <NEW_LINE> <INDENT> for app in settings.INSTALLED_APPS: <NEW_LINE> <INDENT> mod = import_module(app) <NEW_LINE> try: <NEW_LINE> <INDENT> before_import_registry = copy.copy(permissions._registry) <NEW_LINE> import_module('%s.permissions' % app) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> permissi... | Auto-discover INSTALLED_APPS permissions.py modules and fail silenty when
not present. This forces an import on them to register any permission
checks they may want. | 625941c55fdd1c0f98dc0241 |
def fill_prefetch_cache(self, field, queryset): <NEW_LINE> <INDENT> if hasattr(self, "_prefetched_objects_cache"): <NEW_LINE> <INDENT> assert field not in self._prefetched_objects_cache, "field already cached" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._prefetched_objects_cache = {} <NEW_LINE> <D... | Manually fills the prefetch cache with a queryset.
Use this sparingly and only if you know what you're doing or
things may go wrong. | 625941c5ad47b63b2c509f8e |
def gather(*coros_or_futures, return_exceptions=False): <NEW_LINE> <INDENT> if not coros_or_futures: <NEW_LINE> <INDENT> loop = events.get_event_loop() <NEW_LINE> outer = loop.create_future() <NEW_LINE> outer.set_result([]) <NEW_LINE> return outer <NEW_LINE> <DEDENT> def _done_callback(fut): <NEW_LINE> <INDENT> nonloca... | Return a future aggregating results from the given coroutines/futures.
Coroutines will be wrapped in a future and scheduled in the event
loop. They will not necessarily be scheduled in the same order as
passed in.
All futures must share the same event loop. If all the tasks are
done successfully, the returned future... | 625941c5a8ecb033257d30dc |
def remove_empties(inlist,protect=[str,str]): <NEW_LINE> <INDENT> if tuple in protect: unprotected_type=list <NEW_LINE> elif list in protect: unprotected_type=tuple <NEW_LINE> elif type(inlist)==tuple: unprotected_type=tuple <NEW_LINE> else: unprotected_type=list <NEW_LINE> inlist=list(inlist) <NEW_LINE> if type(inlist... | Remove "empty" entries from an iterable (or nested
iterables). Returns a list or tuple of the same
shape as the input containing no iterables of
length 0 (like () or []) and no *None* values.
*protect* is a list of types to protect from
iteration. See the function *iterable* for
further description. | 625941c5ab23a570cc250190 |
def GetReportData(self, get_report_args, token): <NEW_LINE> <INDENT> ret = rdf_report_plugins.ApiReportData( representation_type=RepresentationType.AUDIT_CHART, audit_chart=rdf_report_plugins.ApiAuditChartReportData( used_fields=self.USED_FIELDS)) <NEW_LINE> ret.audit_chart.rows = _LoadAuditEvents( self.HANDLERS, get_r... | Filter the hunt approvals in the given timerange. | 625941c51d351010ab855b2b |
def get_answers_from_usage_log(questions, qa_pairs_from_logs): <NEW_LINE> <INDENT> answers = pandas.merge(questions, qa_pairs_from_logs, on=QUESTION, how="left") <NEW_LINE> missing_answers = answers[answers[ANSWER].isnull()] <NEW_LINE> if len(missing_answers): <NEW_LINE> <INDENT> logger.warning("%d questions without an... | Get answers returned by WEA to questions by looking them up in the usage log.
Each question in the Q&A pairs must have a unique answer.
:param questions: questions to look up in the usage logs
:type questions: pandas.DataFrame
:param qa_pairs_from_logs: question/answer pairs extracted from user logs
:type qa_pairs_fr... | 625941c54d74a7450ccd41d2 |
def punkt_eingabe(): <NEW_LINE> <INDENT> x = int(input("x Koordinate: ")) <NEW_LINE> y = int(input("y Koordinate: ")) <NEW_LINE> return x, y | Aufgabe:
- welche Fehler können entstehen?
- Fangen Sie die Fehler mit try/except ab
- Wertebereich: Lassen Sie nur Werte >= -1. | 625941c585dfad0860c3ae69 |
def do_home(self): <NEW_LINE> <INDENT> self.load() <NEW_LINE> structure_name = settings.nest.structure <NEW_LINE> structure = self._get_structure_by_name(structure_name) <NEW_LINE> if not structure: <NEW_LINE> <INDENT> raise ValueError(f"Could not find structure in API: {structure_name}") <NEW_LINE> <DEDENT> if is_wint... | Sets up the thermostat in *home* mode. | 625941c5e76e3b2f99f3a81d |
def nms(boxes, probs, threshold): <NEW_LINE> <INDENT> order = probs.argsort()[::-1] <NEW_LINE> keep = [True] * len(order) <NEW_LINE> for i in range(len(order) - 1): <NEW_LINE> <INDENT> ovps = compute_iou(boxes[order[i + 1:]], boxes[order[i]]) <NEW_LINE> for j, ov in enumerate(ovps): <NEW_LINE> <INDENT> if ov > threshol... | Non-Maximum supression.
Args:
boxes: array of [cx, cy, w, h] (center format)
probs: array of probabilities
threshold: two boxes are considered overlapping if their IOU is largher than
this threshold
form: 'center' or 'diagonal'
Returns:
keep: array of True or False. | 625941c5462c4b4f79d1d6df |
def deserialize(self, bdb, blob): <NEW_LINE> <INDENT> raise NotImplementedError | Reconstitute a serialized predictor instance.
The `blob` will have been created by calling :meth:`serialize`
on an instance of :class:`IBayesDBForeignPredictorFactory`
registered with the same :meth:`name` as this one at some
point in the past. In typical use, this will be the same
instance as the present one, but th... | 625941c5d18da76e235324e3 |
def check_topology(self, *args, **kwargs): <NEW_LINE> <INDENT> return _trellis.trellis_pccc_encoder_si_sptr_check_topology(self, *args, **kwargs) | check_topology(self, int ninputs, int noutputs) -> bool | 625941c563b5f9789fde70f4 |
def sit(self): <NEW_LINE> <INDENT> print(self.name.title() + " is now sitting.") | emulate sit | 625941c563f4b57ef000112b |
def choose_difficulty(): <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> difficulty = input("What mode to you want to play?\nEasy[e], Normal[n], or Hard[h]: ").lower().strip() <NEW_LINE> if difficulty not in 'enh' or difficulty == "": <NEW_LINE> <INDENT> print("\nType 'e' for Easy, 'n' for Normal, 'h' for Hard.\n")... | Prompts user to select easy, normal, or hard mode. | 625941c516aa5153ce362487 |
def forward(self, x): <NEW_LINE> <INDENT> x = x <NEW_LINE> x = self.convBlock(x) <NEW_LINE> x = x.view(x.size(0), -1) <NEW_LINE> x = self.fc_block(x) <NEW_LINE> return x | Perform forward. | 625941c5796e427e537b05d3 |
@click.command('env-clean', short_help='clean env test data') <NEW_LINE> @pass_context <NEW_LINE> def cli(ctx): <NEW_LINE> <INDENT> client = config.get_global_client() <NEW_LINE> for env in client.list_project(limit=config.RESULT_LIMIT): <NEW_LINE> <INDENT> if env.name.startswith(config.ENV_FREFIX): <NEW_LINE> <INDENT>... | Clean test data | 625941c5fff4ab517eb2f44a |
def addFace(self, du, dv, d, ru=0.5, rv=0.5): <NEW_LINE> <INDENT> self.faces.append([du,dv]) <NEW_LINE> nP = 10 <NEW_LINE> ni = self.ms[abs(du)-1].shape[0] <NEW_LINE> nj = self.ms[abs(dv)-1].shape[0] <NEW_LINE> verts = numpy.zeros((2,2,3),order='F') <NEW_LINE> verts[:,:,:] = d <NEW_LINE> verts[0,:,abs(du)-1] = -ru*nump... | Creates a set of rectangular surfaces, their IDs, and face dims.
nu,nv: number of surfaces in the u and v directions
du,dv: {1,2,3} maps to {x,y,z}; negative sign means reverse order
d: position of the surfaces in the remaining coordinate axis
ru,rv: surfaces span -ru to +ru in u dir. and -rv to +rv in v dir.
Adds to ... | 625941c571ff763f4b549698 |
def set(self, key, value): <NEW_LINE> <INDENT> return self.execute_query(key, ("set", key, value)) | Set or update the value of key from the cache. Also updates the LRU cache for already existing key or (key, value)
:return: bool value indicating if the operation was successful or not. | 625941c566673b3332b920a0 |
def step_batch( self, actions: numpy.ndarray, states: numpy.ndarray = None, dt: [numpy.ndarray, int] = None, ): <NEW_LINE> <INDENT> return self._batch_env.step_batch(actions=actions, states=states, dt=dt) | Vectorized version of the `step` method. It allows to step a vector of states and actions.
The signature and behaviour is the same as `step`, but taking a list of states, actions and dts as input.
Args:
actions: Iterable containing the different actions to be applied.
states: Iterable containi... | 625941c5379a373c97cfab53 |
def target(): <NEW_LINE> <INDENT> def prep(r): <NEW_LINE> <INDENT> if r.interactive: <NEW_LINE> <INDENT> if r.component_name == "response": <NEW_LINE> <INDENT> record = r.record <NEW_LINE> table = s3db.dc_response <NEW_LINE> table.location_id.default = record.location_id <NEW_LINE> f = table.template_id <NEW_LINE> f.de... | RESTful CRUD controller | 625941c591f36d47f21ac500 |
def _update_proxy_model(self, text: str): <NEW_LINE> <INDENT> model = api.completion.get_model(text, api.modes.COMMAND.last) <NEW_LINE> if model != self.model: <NEW_LINE> <INDENT> model.on_enter(text) <NEW_LINE> self.proxy_model.setSourceModel(model) <NEW_LINE> self._completion.update_column_widths() <NEW_LINE> <DEDENT... | Update completion proxy model depending on text.
Args:
text: Text in the commandline which defines the model. | 625941c58c3a8732951583c8 |
def load(filename:str)->panscore.Score: <NEW_LINE> <INDENT> with open(filename,"r",encoding="utf8") as file: <NEW_LINE> <INDENT> line=file.readline().split(" ") <NEW_LINE> tempo=float(line[0]) <NEW_LINE> beats=(int(line[1]),int(line[2])) <NEW_LINE> file.readline() <NEW_LINE> note=[] <NEW_LINE> for i in file.readlines()... | 打开nn文件,返回panscore.Score对象 | 625941c59c8ee82313fbb783 |
def get_num_sources(self): <NEW_LINE> <INDENT> return self.__num_sources | Get the number of sources included in the mapping.
Returns:
Integer number of sources included in this mapping. | 625941c5627d3e7fe0d68e5e |
def standardize(x): <NEW_LINE> <INDENT> mean_x = np.mean(x) <NEW_LINE> x = x - mean_x <NEW_LINE> std_x = np.std(x) <NEW_LINE> x = x / std_x <NEW_LINE> return x, mean_x, std_x | Standardize the original data set.
Args:
x (numpy.array): Array with data for x
Returns:
(tuple): tuple containing:
x (numpy.array): Standardized array
mean_x (numpy.array): Arithmetic Mean
std_x (numpy.array): Standard deviation | 625941c599cbb53fe6792bf6 |
def deploy(): <NEW_LINE> <INDENT> _assert_target_set() <NEW_LINE> if env.target == 'production': <NEW_LINE> <INDENT> if not console.confirm("Uploading to live site: sure?", default=False): <NEW_LINE> <INDENT> utils.abort("User aborted") <NEW_LINE> <DEDENT> <DEDENT> deploy_code() <NEW_LINE> install_requirements() <NEW_L... | Upload code, install any new requirements | 625941c55510c4643540f3f7 |
def enable(): <NEW_LINE> <INDENT> pass | Not implemented. | 625941c5711fe17d8254237d |
def random_policy(self, state): <NEW_LINE> <INDENT> return np.random.randint(0, self.action_space) | Outputs a random action
:param state: current state
:return: action | 625941c529b78933be1e56bd |
def setContactContextMenu(self, cb): <NEW_LINE> <INDENT> raise NotImplementedError | Set the callback when a context menu for a group should be
displayed (choice is given to the front-end developer, usually on right
click)
If cb is None, the callback should be removed
Expected signature: function(gid)
gid is the group id of the group actionned
That function must return a MenuView | 625941c57b180e01f3dc480f |
def __init__(self, page_size: M.Vector, style, pure_net=True): <NEW_LINE> <INDENT> self.page_size = page_size <NEW_LINE> self.pure_net = pure_net <NEW_LINE> self.style = style <NEW_LINE> self.margin = 0 <NEW_LINE> self.text_size = 12 | Initialize document settings.
page_size: document dimensions in meters
pure_net: if True, do not use image | 625941c5656771135c3eb87c |
def build_inputs(batch_size, num_steps): <NEW_LINE> <INDENT> shape = (batch_size, num_steps) <NEW_LINE> inputs = tf.placeholder(tf.int32, shape=shape) <NEW_LINE> targets = tf.placeholder(tf.int32, shape=shape) <NEW_LINE> keep_prob = tf.placeholder(tf.float32) <NEW_LINE> return inputs, targets, keep_prob | Define placeholders for inputs, targets, and dropout
Arguments
---------
batch_size: Batch size, number of sequences per batch
num_steps: Number of sequence steps in a batch | 625941c599fddb7c1c9de3a1 |
def test_imputation(self, train_defined, use_value = True): <NEW_LINE> <INDENT> if use_value: <NEW_LINE> <INDENT> for variable, info in train_defined.items(): <NEW_LINE> <INDENT> if info[0] in ['zero', 'max', 'min', 'median', 'mode', 'indicator']: <NEW_LINE> <INDENT> self.df_test[variable] = self.df_test[variable].fill... | Pass a dictionary with train actions to impute on test dataset
Parameters
----------
defined_methods : Dict
Dictionary type of form {"variable":"method"}
indicator : str or int or float
For method indicator of missing (default is "other")
knn : int
For KNN imputation (default is 5) | 625941c59b70327d1c4e0de3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.