code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def run(self, method, *args, **kwargs): <NEW_LINE> <INDENT> event = utils.EventData() <NEW_LINE> AppHelper.callAfter(self.__ui_runner, event, method, args, kwargs) <NEW_LINE> return event.wait() | Runs the given method in the main thread
:param method: The method to call
:param args: Method arguments
:param kwargs: Method keyword arguments
:return: The result of the method | 625941c230dc7b7665901918 |
def execute(self, args): <NEW_LINE> <INDENT> from qt4i.driver.tools.dt import DT <NEW_LINE> import pprint <NEW_LINE> for device in DT().get_devices(): <NEW_LINE> <INDENT> pprint.pprint(device) | 执行过程
| 625941c2293b9510aa2c3248 |
def testStsize(self): <NEW_LINE> <INDENT> self.assertEqual(None, stsizefmt(None), "An invalid size") <NEW_LINE> self.assertEqual(None, stsizefmt("."), "An invalid size") <NEW_LINE> self.assertEqual("N/A", stsizefmt("N/A"), "Not a valid stone size") <NEW_LINE> self.assertEqual("N/A", stsizefmt("n/a"), "Not a valid stone... | test for stone size parser
| 625941c255399d3f05588663 |
@app.route('/disconnect') <NEW_LINE> def disconnect(): <NEW_LINE> <INDENT> if 'username' in login_session: <NEW_LINE> <INDENT> gdisconnect() <NEW_LINE> del login_session['gplus_id'] <NEW_LINE> del login_session['access_token'] <NEW_LINE> del login_session['username'] <NEW_LINE> del login_session['email'] <NEW_LINE> del... | Logout the user from session and delete all information | 625941c2ec188e330fd5a753 |
def setUp(self): <NEW_LINE> <INDENT> self.origdir = os.getcwd() <NEW_LINE> self.dirname = tempfile.mkdtemp("test_dir") <NEW_LINE> os.chdir(self.dirname) | initialize a new temporary directory. | 625941c25510c4643540f399 |
def linear_step(self): <NEW_LINE> <INDENT> x = self.x <NEW_LINE> dt = self.dt <NEW_LINE> real = self.wf.real <NEW_LINE> imag = self.wf.imag <NEW_LINE> prev = self.wf.prev <NEW_LINE> T = self.T <NEW_LINE> V = self.V <NEW_LINE> real += dt * (T.fast(imag) + V(x) * imag) <NEW_LINE> prev[:] = imag <NEW_LINE> imag -= dt * (T... | Make one linear step dt forward in time | 625941c20a366e3fb873e7c9 |
@pulsar <NEW_LINE> @sdc_min_version('4.4.0') <NEW_LINE> def test_pulsar_consumer_topic_header(sdc_builder, sdc_executor, pulsar): <NEW_LINE> <INDENT> topic_name = get_random_string() <NEW_LINE> input_text = 'Hello World!' <NEW_LINE> builder = sdc_builder.get_pipeline_builder() <NEW_LINE> pulsar_consumer = builder.add_s... | Test for Pulsar consumer origin stage.
We verify that the output records contains a header with the topic
Pulsar Consumer pipeline:
pulsar_consumer >> wiretap | 625941c2956e5f7376d70e1e |
def cleanSkyline_(self, skyline): <NEW_LINE> <INDENT> if len(skyline) == 0: <NEW_LINE> <INDENT> return list() <NEW_LINE> <DEDENT> clean = [skyline[0]] <NEW_LINE> for i in range(1, len(skyline)): <NEW_LINE> <INDENT> if skyline[i][0] == clean[-1][0]: <NEW_LINE> <INDENT> y = max(skyline[i][1], clean[-1][1]) <NEW_LINE> cle... | Cleans the skyline by removing redundant points.
:type skyline: List[(int, int)]
:rtype: List[(int, int)] | 625941c221a7993f00bc7c9d |
def test_login_route_can_be_seen(testapp): <NEW_LINE> <INDENT> response = testapp.get("/login", status=200) <NEW_LINE> html = response.html <NEW_LINE> assert len(html.find_all("input")) == 3 | Can send a GET request to the login route and see three input fields. | 625941c273bcbd0ca4b2c027 |
def edit_operator(self, event): <NEW_LINE> <INDENT> item = self.tree.item(self.tree.focus()) <NEW_LINE> item_name = item['values'][0] <NEW_LINE> print('FINISH: Load operator with name {}'.format(item_name)) <NEW_LINE> operator = self.operators.get(item_name) <NEW_LINE> self.view_operator(operator, self._update_operator... | Retrieves the operator and shows it in the editor. | 625941c28c0ade5d55d3e969 |
def save_model(self, request, obj, form, change): <NEW_LINE> <INDENT> if not change: <NEW_LINE> <INDENT> obj.created_by = request.user <NEW_LINE> <DEDENT> obj.save() | Sets the transaction creator and saves the transaction. | 625941c2be8e80087fb20bf6 |
def add_mkdir_exclude(self, index, dirName): <NEW_LINE> <INDENT> self.__in_excludes[index][dirName] = None | Adds a mkdir exclude.
@type index: integer
@param index: Index of the dump file.
@type dirName: string
@param dirName: Name of the directory. | 625941c2d8ef3951e32434ed |
def corr2d_all_spixel_vid_seq(spixel_seqs): <NEW_LINE> <INDENT> corr_patches_superpixels = [] <NEW_LINE> for i in range(spixel_seqs.shape[0]): <NEW_LINE> <INDENT> corr_patches_superpixels.append(corr2d_spixel_vid_seq(spixel_seqs[i])) <NEW_LINE> <DEDENT> corr_patches_superpixels = np.vstack(corr_patches_superpixels) <NE... | computes the 2d image correlation between successive patches along a superpixel track for each superpixel track
Parameters
----------
spixel_seqs : numpy array
n_spixels x n_frames number of image patch sequences. (assumes all image patches are successive temporally per superpixel)
Returns
-------
corr_patches_su... | 625941c2d8ef3951e32434ee |
def test_neg_metagraph_split_and_merge(): <NEW_LINE> <INDENT> from ibeis.algo.graph import demo <NEW_LINE> from ibeis.algo.graph.state import (POSTV, NEGTV, INCMP, UNREV, UNKWN) <NEW_LINE> infr = demo.demodata_infr(num_pccs=4, pcc_size=5, pos_redun=3, ignore_pair=True, infer=True) <NEW_LINE> cc_a, cc_b, cc_c, cc_d = in... | Test that the negative metagraph tracks the number of negative edges
between PCCs through label-changing split and merge operations | 625941c28c0ade5d55d3e96a |
def __init__(self, nature: str, party: str) -> None: <NEW_LINE> <INDENT> self.nature = nature <NEW_LINE> self.party = party | Initialize a Label object.
:param str nature: The identified `nature` of the element.
:param str party: The identified `party` of the element. | 625941c23539df3088e2e2fc |
def controlled_state_transition_graph(self, driver_nodes=[]): <NEW_LINE> <INDENT> self._check_compute_variables(attractors=True) <NEW_LINE> if self.keep_constants: <NEW_LINE> <INDENT> for dv in driver_nodes: <NEW_LINE> <INDENT> if dv in self.get_constants(): <NEW_LINE> <INDENT> warnings.warn("Cannot control a constant ... | Returns the Controlled State-Transition-Graph (CSTG).
In practice, it copies the original STG, flips driver nodes (variables), and updates the CSTG.
Args:
driver_nodes (list) : The list of driver nodes.
Returns:
(networkx.DiGraph) : The Controlled State-Transition-Graph.
See also:
:func:`attractor_driver... | 625941c29c8ee82313fbb725 |
def __del__(self): <NEW_LINE> <INDENT> if self._owner==True: <NEW_LINE> <INDENT> f=self._link.o2scl.o2scl_free_uniform_grid_log_width_ <NEW_LINE> f.argtypes=[ctypes.c_void_p] <NEW_LINE> f(self._ptr) <NEW_LINE> self._owner=False <NEW_LINE> self._ptr=0 <NEW_LINE> <DEDENT> return | Delete function for class uniform_grid_log_width | 625941c2462c4b4f79d1d681 |
def _toggle_show_mip(self): <NEW_LINE> <INDENT> if self._toggle_show_mip_button.text() == 'Show Max Intensity Proj': <NEW_LINE> <INDENT> self._toggle_show_mip_button.setText('Hide Max Intensity Proj') <NEW_LINE> self._images['mip'] = list() <NEW_LINE> self._images['mip_chs'] = list() <NEW_LINE> ct_min, ct_max = np.nanm... | Toggle whether the maximum-intensity projection is shown. | 625941c2e1aae11d1e749c66 |
def _rav_getval_ ( self ) : <NEW_LINE> <INDENT> return self.getVal() | Get the value, associated with the variable
>>> var = ...
>>> print var.value | 625941c20fa83653e4656f6d |
def testBuildRev(self): <NEW_LINE> <INDENT> self.build_config['uprev'] = True <NEW_LINE> commands.UprevPackages(self.build_root, self._boards, [], enter_chroot=True) <NEW_LINE> self.mox.ReplayAll() <NEW_LINE> self.RunStage() <NEW_LINE> self.mox.VerifyAll() | Uprevving the build without uprevving chrome. | 625941c276e4537e8c351621 |
def test_instances_pagination_and_filtration(self): <NEW_LINE> <INDENT> items_per_page = 1 <NEW_LINE> instance_count = 2 <NEW_LINE> instance_list = ["{0}-{1}".format(self.INSTANCE_NAME, item) for item in range(1, instance_count + 1)] <NEW_LINE> first_page_definition = {'Next': True, 'Prev': False, 'Count': items_per_pa... | This test checks instance pagination and filtration
Steps:
1) Login to Horizon Dashboard as admin
2) Go to to user settings page
3) Change 'Items Per Page' value to 1
4) Go to Project > Compute > Instances page
5) Create 2 instances
6) Go to Admin > Compute > Instances page
7) Check filter by Name of the first and the... | 625941c2e64d504609d747f1 |
def _handle_mouse_press(self, event_data): <NEW_LINE> <INDENT> if not self._handler_enabled: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> for mouse_press_handler in self._mouse_press_handlers: <NEW_LINE> <INDENT> if mouse_press_handler(event_data): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> <DEDENT> if event_data... | Handle Matplotlib button_press_event for WindowManager Instance
Parameters:
* event_data - An object representing the key press event data | 625941c26fece00bbac2d6ee |
def setup_lrn_rate(self, global_step): <NEW_LINE> <INDENT> batch_size = FLAGS.batch_size * (1 if not FLAGS.enbl_multi_gpu else mgw.size()) <NEW_LINE> if FLAGS.mobilenet_version == 1: <NEW_LINE> <INDENT> nb_epochs = 100 <NEW_LINE> idxs_epoch = [30, 60, 80, 90] <NEW_LINE> decay_rates = [1.0, 0.1, 0.01, 0.001, 0.0001] <NE... | Setup the learning rate (and number of training iterations). | 625941c2d10714528d5ffc92 |
def get_invoke_query(self, **kwargs): <NEW_LINE> <INDENT> operation = kwargs.get('operation', None) <NEW_LINE> if operation.lower() == "preapproval": <NEW_LINE> <INDENT> return self.get_invoke_preapproval_query(**kwargs) <NEW_LINE> <DEDENT> if operation.lower() == "preapprovaldetails": <NEW_LINE> <INDENT> return self.g... | docstring for api payload | 625941c260cbc95b062c64f3 |
def MP(candidate, references, n): <NEW_LINE> <INDENT> counts = Counter(ngrams(candidate, n)) <NEW_LINE> if not counts: <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> max_counts = {} <NEW_LINE> for reference in references: <NEW_LINE> <INDENT> reference_counts = Counter(ngrams(reference, n)) <NEW_LINE> for ngram in cou... | calculate modified precision | 625941c25fcc89381b1e166e |
def starts_with_ignore_case(string: str, substring: str) -> bool: <NEW_LINE> <INDENT> return re.match(substring, string, re.I) | Checks if 'string' starts with 'substring' ignoring case
Args:
string:
full string
substring:
sub string
Returns:
True if 'string' starts with 'substring' ignoring case | 625941c2097d151d1a222e0c |
def get(self, keylist): <NEW_LINE> <INDENT> return {} | Retreive a list of values as a python dict | 625941c2656771135c3eb81d |
def entropy_of_vector(vector): <NEW_LINE> <INDENT> entropy = 0 <NEW_LINE> for p in vector: <NEW_LINE> <INDENT> if p != 0: <NEW_LINE> <INDENT> entropy += p * math.log2(p) <NEW_LINE> <DEDENT> <DEDENT> return -entropy | Compute the entropy of a probability vector
:param vector: the probability vector (example: [.1, .5, .4])
:return: the entropy of the vector (log base 2) | 625941c250485f2cf553cd4a |
def syntax(retCode): <NEW_LINE> <INDENT> print("arcgiscsv_report outputs VISTA table files in the current directory for an ArcGIS CSV ") <NEW_LINE> print("track.") <NEW_LINE> print() <NEW_LINE> print("Usage:") <NEW_LINE> print(" python arcgiscsv_report.py dbServer network user password arcgiscsvFile arcgiscsvPathMatch... | Print usage information | 625941c24d74a7450ccd4174 |
def R1bars(simulations, data): <NEW_LINE> <INDENT> denom = np.sum([np.sum(np.sqrt(1/dataset.error)*np.sqrt(dataset.y)) for dataset in data if dataset.use]) <NEW_LINE> return [1.0/denom*np.sqrt(1/dataset.error)* (np.sqrt(dataset.y) - np.sqrt(sim)) for (dataset, sim) in zip(data,simulations)] | Weighted crystallographic R-factor (R1)
| 625941c27d43ff24873a2c50 |
def insertImageFile(self, parentWindow, imageContext): <NEW_LINE> <INDENT> file = None <NEW_LINE> wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" <NEW_LINE> dialog = wx.FileDialog(parentWindow, u"Choose an image file.", u"", u"", wildcard, wx.OPEN) <NEW_LINE> if dialog.ShowModal() == wx.ID_OK: <NEW_LINE> <INDENT> fi... | insertImageFile(wxWindow, IZXHTMLEditControlImageContext) -> void
Shows the File open dialog to display an image. | 625941c2fbf16365ca6f6171 |
def calVolatilityRatio(macroEcoData, stockData, N=10): <NEW_LINE> <INDENT> result = [] <NEW_LINE> dates = [] <NEW_LINE> for dtt in macroEcoData.index[:]: <NEW_LINE> <INDENT> if dtt in stockData.index: <NEW_LINE> <INDENT> indexToUse = stockData.index.get_loc(dtt) <NEW_LINE> newStock = stockData[indexToUse - N:indexToUse... | Function to Calculate Volatility Ratio.
Args:
param1: MacroEconomic Data, Stock Data and N-Days
Returns:
A DataFrame of Volatility Ratio for the MacroEconomic Data Selected. | 625941c20383005118ecf595 |
@pytest.mark.parametrize('table_data,expected_w,expected_h', [ ([[]], [], [0]), ([['']], [0], [0]), ([['', '']], [0, 0], [0]), ([[], []], [], [0, 0]), ([[''], ['']], [0], [0, 0]), ([['', ''], ['', '']], [0, 0], [0, 0]), ]) <NEW_LINE> def test_zero_length(table_data, expected_w, expected_h): <NEW_LINE> <INDENT> actual =... | Test zero-length or empty tables.
:param list table_data: Input table data to test.
:param list expected_w: Expected widths.
:param list expected_h: Expected heights. | 625941c2a79ad161976cc0f6 |
def delete(self): <NEW_LINE> <INDENT> l, r = self._input_index('输入删除区间, 如:10 20\n') <NEW_LINE> confirm = input('是否删除记录%d-%d\n确认(y),任意键取消.\n' % (l, r)) <NEW_LINE> if confirm != 'y': <NEW_LINE> <INDENT> print('已放弃删除!') <NEW_LINE> return <NEW_LINE> <DEDENT> for i in range(r-l+1): <NEW_LINE> <INDENT> print('成功删除:', l+i, se... | 删除日志 | 625941c26e29344779a625c5 |
def delete_pet_by_id(self, data_json): <NEW_LINE> <INDENT> response = requests.delete(self.url + '/pet/' + str(json.loads(data_json)['id'])) <NEW_LINE> return response | method for deleting pet by id
:param data_json:
:return: | 625941c2046cf37aa974ccfa |
def generateParenthesis(self, n): <NEW_LINE> <INDENT> res = self.generateParenthesisHelper(n) <NEW_LINE> if n == 0: <NEW_LINE> <INDENT> return [''] <NEW_LINE> <DEDENT> return list(res) | :type n: int
:rtype: List[str] | 625941c250812a4eaa59c2d4 |
def GetTargetCompileTool(name, cross_compile=None): <NEW_LINE> <INDENT> env = dict(os.environ) <NEW_LINE> target_name = None <NEW_LINE> extra_args = [] <NEW_LINE> if name in ('as', 'ld', 'cc', 'cpp', 'ar', 'nm', 'ldr', 'strip', 'objcopy', 'objdump', 'dtc'): <NEW_LINE> <INDENT> target_name, *extra_args = env.get(name.up... | Get the target-specific version for a compile tool
This first checks the environment variables that specify which
version of the tool should be used (e.g. ${CC}). If those aren't
specified, it checks the CROSS_COMPILE variable as a prefix for the
tool with some substitutions (e.g. "${CROSS_COMPILE}gcc" for cc).
The f... | 625941c299cbb53fe6792b98 |
def test_traverse_partial_match(self): <NEW_LINE> <INDENT> status, node, path = self.rootpub.traverse(u'/nodeX') <NEW_LINE> self.assertEqual(status, TRAVERSE_STATUS.PARTIAL) <NEW_LINE> self.assertEqual(node, self.root) <NEW_LINE> self.assertEqual(path, '/nodeX') <NEW_LINE> status, node, path = self.rootpub.traverse(u'/... | Test for partial path matching. | 625941c2596a897236089a74 |
def create_outname(outdir, infile): <NEW_LINE> <INDENT> basename = os.path.basename(infile) <NEW_LINE> outname = basename + '.out' <NEW_LINE> return os.path.join(outdir, outname) | Create the output file's name. | 625941c2d486a94d0b98e0f6 |
def setup_synth(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if self._libfluidsynth_path is not None: <NEW_LINE> <INDENT> log.info("Using libfluidsynth: " + self._libfluidsynth_path) <NEW_LINE> <DEDENT> self._fluidhandle = fluidhandle.FluidHandle(self._libfluidsynth_path) <NEW_LINE> self._fluidsettings = fluidse... | Setup the synth so that it can produce sound.
Raises:
PlayerException: an error occured during the synth setup.
Most common errors: fluidsynth library not found, soundfont not found. | 625941c2ad47b63b2c509f31 |
def leerArchivo(pnombreArchivo): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> print("Se va a abrir el archivo: ", pnombreArchivo) <NEW_LINE> f=open(pnombreArchivo,"rb") <NEW_LINE> print("Se va a leer el archivo: ", pnombreArchivo) <NEW_LINE> pickle.load(f) <NEW_LINE> print("Se va a cerrar el archivo: ", pnombreArchivo)... | Función: Cargar y leer datos del archivo seleccionado
Entradas: Nombre del archivo (binario)
Salidas: NA | 625941c294891a1f4081ba59 |
def __DoShowEditProgress(self): <NEW_LINE> <INDENT> song = viewmgr.Get()._selectedSong <NEW_LINE> if song: <NEW_LINE> <INDENT> viewmgr.signalSongEditProgress(song) | The edit progress panel needs to be visible, and shown. We do this through the
view mgr because on this level we do not have access to that frame | 625941c2d4950a0f3b08c302 |
def test_obtener_cantidad_personas_en_hotel_desde_ciudad_en_rango_anios_mensualmente(self): <NEW_LINE> <INDENT> query_string = [('AnioInicio', 2002), ('AnioFin', 2004)] <NEW_LINE> response = self.client.open('/server/INE/Operaciones/ObtenerCantidadPersonasEnHotelDesdeCiudadEnRangoAniosMensualmente/{CiudadOrigen}'.forma... | Test case for obtener_cantidad_personas_en_hotel_desde_ciudad_en_rango_anios_mensualmente
Dado una ciudad y un rango de años obtiene la cantidad total de personas que van a hoteles desde esa ciudad de forma mensual | 625941c2287bf620b61d3a16 |
def drawXLine(name): <NEW_LINE> <INDENT> print(len(name) * "X") | Draws a line of X | 625941c2bf627c535bc1317f |
def get_batch(self, partition): <NEW_LINE> <INDENT> if partition == 'train': <NEW_LINE> <INDENT> audio_paths = self.train_audio_paths <NEW_LINE> cur_index = self.cur_train_index <NEW_LINE> texts = self.train_texts <NEW_LINE> <DEDENT> elif partition == 'valid': <NEW_LINE> <INDENT> audio_paths = self.valid_audio_paths <N... | Obtain a batch of train, validation, or test data
| 625941c2b545ff76a8913dc7 |
def attempt_recovery(self, task, args=None, kwargs=None, einfo=None, retval=None): <NEW_LINE> <INDENT> pass | Here you can try to recover from errors that Celery couldn't deal with.
Example:
if isinstance(retval, SoftTimeLimitExceeded):
# half the number of processed objects
first_half, second_half = args[0][0:len(args[0])/2], args[0][len(args[2]/2):]
# resubmit
args[0] = first_half
task.apply_async(args=... | 625941c2d58c6744b4257c11 |
def get_channel_info(channel_id: str) -> Dict[str, str]: <NEW_LINE> <INDENT> url = get_channel_video_url(channel_id) <NEW_LINE> soup = get_soup(url) <NEW_LINE> if soup is None: <NEW_LINE> <INDENT> logger.error("Got invalid response for channel: {url}") <NEW_LINE> sys.exit(1) <NEW_LINE> <DEDENT> profile = soup.find(id="... | Get meta information from channel website. | 625941c21f037a2d8b9461af |
def pad(data, pad_width, pad_value=0, pad_mode="constant"): <NEW_LINE> <INDENT> if isinstance(pad_width, Expr) or (isinstance(pad_value, Expr)): <NEW_LINE> <INDENT> if not isinstance(pad_width, Expr): <NEW_LINE> <INDENT> pad_width = const(list(pad_width)) <NEW_LINE> <DEDENT> if not isinstance(pad_value, Expr): <NEW_LIN... | Padding
This operator takes in a tensor and pads each axis by the specified
widths using the specified value.
Parameters
----------
data: tvm.relay.Expr
The input data to the operator
pad_width: tuple of <tuple of <int>>, or tvm.relay.Expr, required
Number of values padded to the edges of each axis, in the fo... | 625941c2283ffb24f3c558b4 |
def get_window(self): <NEW_LINE> <INDENT> return [self.x_lower , self.x_upper , self.y_lower , self.y_upper] | This function get the coordinates of the window as a list | 625941c27b25080760e3940b |
def uncondition(self) -> Query: <NEW_LINE> <INDENT> return Query( outcomes=self.outcomes | self.conditions, treatments=self.treatments, conditions=None, ) | Move the conditions to outcomes. | 625941c2a17c0f6771cbe003 |
def kickstart(ks, uploaded, path=settings.KS_DIR): <NEW_LINE> <INDENT> if not uploaded: <NEW_LINE> <INDENT> ks = "%s%s" % (path, ks) <NEW_LINE> <DEDENT> ksparser = DecoratedKickstartParser(makeVersion()) <NEW_LINE> ksparser.readKickstart(ks) <NEW_LINE> return ksparser | return parsed pykickstart object | 625941c245492302aab5e273 |
@require(gribid=int, fileobj=file) <NEW_LINE> def grib_write(gribid, fileobj): <NEW_LINE> <INDENT> GRIB_CHECK(_internal.grib_c_write(gribid, fileobj)) | @brief Write a message to a file.
Examples:
ef set.py "set.py"
@param gribid id of the grib loaded in memory
@param fileobj python file object
@exception GribInternalError | 625941c2046cf37aa974ccfb |
def check_win(self): <NEW_LINE> <INDENT> arr = self.arr <NEW_LINE> if arr[0][0] == arr[0][1] == arr[0][2] != '.': <NEW_LINE> <INDENT> return arr[0][0] <NEW_LINE> <DEDENT> elif arr[1][0] == arr[1][1] == arr[1][2] != '.': <NEW_LINE> <INDENT> return arr[1][0] <NEW_LINE> <DEDENT> elif arr[2][0] == arr[2][1] == arr[2][2] !=... | Checks if there is a win! | 625941c20a50d4780f666e42 |
def getTables(self): <NEW_LINE> <INDENT> return self.tables | Returns container tables. | 625941c28c3a87329515836a |
def test_nested_forall(): <NEW_LINE> <INDENT> l1 = Variable('l1',Variable.Real) <NEW_LINE> l2 = Variable('l2',Variable.Real) <NEW_LINE> ox = Variable('ox',Variable.Real) <NEW_LINE> oy = Variable('oy',Variable.Real) <NEW_LINE> param_bounds = logical_and(l1 > 0, l1 < 20, l2 > 0, l2 < 20, ox > -20, ox < 20, oy > -20, oy <... | Test whether we can choose parameters for a system, such that there is a
satisfying solution over an entire range of values.
Basically, choose an origin (ox,oy) and the lengths of two arms (l1 & l2)
so that there is an angle (t1 & t2) for each arm, that allows it to reach
any point within a circle centered at (25,25)... | 625941c28e05c05ec3eea324 |
def run(self): <NEW_LINE> <INDENT> print("Programme starts!") <NEW_LINE> self.root.mainloop() | Make everything begin | 625941c2c432627299f04bf6 |
def not_null(self): <NEW_LINE> <INDENT> self._not_null = Clause('NOT NULL') <NEW_LINE> return self | Adds a |NOT NULL| constraint to the column | 625941c2f548e778e58cd52e |
def _sample_cauchy_process_at(self, times): <NEW_LINE> <INDENT> if times[0] != 0: <NEW_LINE> <INDENT> zero = False <NEW_LINE> times = np.insert(times, 0, [0]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> zero = True <NEW_LINE> <DEDENT> deltas = np.diff(times) <NEW_LINE> levys = [levy.rvs(loc=0, scale=d ** 2 / 2, size=... | Generate a realization of a Cauchy process. | 625941c28e05c05ec3eea325 |
def get(self, index): <NEW_LINE> <INDENT> if index < 0: <NEW_LINE> <INDENT> return -1 <NEW_LINE> <DEDENT> i = 0 <NEW_LINE> current = self.root.next <NEW_LINE> while i < index and current != self.root: <NEW_LINE> <INDENT> current = current.next <NEW_LINE> i += 1 <NEW_LINE> <DEDENT> return current.val | Get the value of the index-th node in the linked list. If the index is invalid, return -1.
:type index: int
:rtype: int | 625941c297e22403b379cf4b |
def evaluate(self, *inputs): <NEW_LINE> <INDENT> inputs = np.broadcast_arrays(*inputs) <NEW_LINE> if isinstance(inputs, u.Quantity): <NEW_LINE> <INDENT> inputs = inputs.value <NEW_LINE> <DEDENT> shape = inputs[0].shape <NEW_LINE> inputs = [inp.flatten() for inp in inputs[: self.n_inputs]] <NEW_LINE> inputs = np.array(i... | Return the interpolated values at the input coordinates.
Parameters
----------
inputs : list of scalar or list of ndarray
Input coordinates. The number of inputs must be equal
to the dimensions of the lookup table. | 625941c2a05bb46b383ec7d5 |
def test_cube_oplst(): <NEW_LINE> <INDENT> oplst = [['Y', 'Y'], ['R', 'G'], ['B', 'G']] <NEW_LINE> cube = Cube(oplst) <NEW_LINE> assert cube.oplst() == oplst | Test opposite pairs method | 625941c263f4b57ef00010cf |
def test_user_tags(self): <NEW_LINE> <INDENT> nt = self.client.create_tag("明日之星") <NEW_LINE> print(nt) <NEW_LINE> tags = self.client.get_all_tags() <NEW_LINE> for t in tags: <NEW_LINE> <INDENT> print(t) <NEW_LINE> <DEDENT> self.client.remove_tag(nt.id) | 测试用户标签 | 625941c210dbd63aa1bd2b56 |
def make_read_flag_selector (self,namespace,**kw): <NEW_LINE> <INDENT> sel = MSReadFlagSelector(namespace=namespace,**kw); <NEW_LINE> if self.flagsets: <NEW_LINE> <INDENT> sel.update_flagsets(self.flagsets); <NEW_LINE> <DEDENT> self._flag_selectors.append(sel); <NEW_LINE> return sel; | Makes an MSReadFlagSelector object connected to this MS selector. | 625941c2aad79263cf3909f0 |
def _checkInputData(workload, sitewhitelist=None): <NEW_LINE> <INDENT> sitewhitelist = sitewhitelist or [] <NEW_LINE> self.assertEqual(workload.listPileupDatasets().values(), [{testArguments['Step2']['MCPileup']}]) <NEW_LINE> task = workload.getTaskByName(testArguments['Step1']['StepName']) <NEW_LINE> self.assertEqual(... | Validate input data/block/run/step/PU for the 4-tasks request | 625941c24f88993c3716c01a |
def testConceptNetworkGetLinksLabeledOrTo(self): <NEW_LINE> <INDENT> cn = ConceptNetwork() <NEW_LINE> nodeFrom = Node("From") <NEW_LINE> nodeTo1 = Node("To1") <NEW_LINE> nodeTo2 = Node("To2") <NEW_LINE> nodeLabel= Node("Label") <NEW_LINE> cn.addLink(nodeFrom, nodeTo1) <NEW_LINE> cn.addLink(nodeFrom, nodeLabel) <NEW_L... | Get links with a label or to that label | 625941c2d53ae8145f87a224 |
def parse_json(self, req, name, field): <NEW_LINE> <INDENT> json_data = self._cache.get('json') <NEW_LINE> if json_data is None: <NEW_LINE> <INDENT> if not req.is_json: <NEW_LINE> <INDENT> raise ApiError('Mimetype application/json expected but {} found.'.format(req.mimetype), 400) <NEW_LINE> <DEDENT> <DEDENT> return su... | Pull a json value from the request. | 625941c27cff6e4e81117937 |
def vlan_access_positive(dut, hs1, hs2, step): <NEW_LINE> <INDENT> dut_port1 = dut.ports["3"] <NEW_LINE> dut_port2 = dut.ports["4"] <NEW_LINE> configure_hosts(hs1, hs2, step) <NEW_LINE> step("Configure vlan 2 in switch") <NEW_LINE> with dut.libs.vtysh.ConfigVlan('2') as ctx: <NEW_LINE> <INDENT> ctx.no_shutdown() <NEW_L... | In this testcase reachability is tested when vlan access mode
is configured on the interfaces of a switch. | 625941c2b5575c28eb68dfb0 |
def __len__(self): <NEW_LINE> <INDENT> return self.nrows // self.bs | Denotes the number of batches per epoch | 625941c2711fe17d82542321 |
def get_user(self): <NEW_LINE> <INDENT> return self.user | Get the user who created this changeset. | 625941c2bde94217f3682da4 |
def process_request(self, request): <NEW_LINE> <INDENT> current_url = request.path_info <NEW_LINE> for reg in settings.VALID_URL: <NEW_LINE> <INDENT> if re.match(reg,current_url): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> permission_dict = request.session.get(settings.PERMISSION_SESSION_KEY) <NEW_LIN... | 权限控制
:param request:
:return: | 625941c2d486a94d0b98e0f7 |
def linprogParams(ssd_matrix, ij, ji, graphix, graphmap, s, t): <NEW_LINE> <INDENT> L = ssd_matrix.shape[0] <NEW_LINE> A = np.zeros((L,len(graphmap)), dtype=np.int) <NEW_LINE> for n in range(L): <NEW_LINE> <INDENT> for i in ij[n]: A[n,graphmap['%d_%d' % (n,i)]] += 1 <NEW_LINE> for j in ji[n]: A[n,graphmap['%d_%d' % (j,... | Compute the linear programming parameters for the given problem | 625941c256b00c62f0f1460a |
def tf_rotate_perturb_point_cloud(): <NEW_LINE> <INDENT> raise NotImplementedError | Tensorflow op: perturbation by slightly rotating a point cloud | 625941c2adb09d7d5db6c742 |
def _get_original_port_for_delete(original_ip, original_port): <NEW_LINE> <INDENT> runtime_properties = ctx.target.instance.runtime_properties <NEW_LINE> if PORT_REPLACEMENT not in runtime_properties: <NEW_LINE> <INDENT> return original_port <NEW_LINE> <DEDENT> key = '{}:{}'.format(original_ip, original_port) <NEW_LINE... | check may be we already replaced port by some new free port | 625941c27d43ff24873a2c51 |
def play_sound(sound_file): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> if platform.system() == "Windows": <NEW_LINE> <INDENT> winsound.PlaySound(sound_file, winsound.SND_FILENAME) <NEW_LINE> <DEDENT> elif platform.system() == "Darwin": <NEW_LINE> <INDENT> os.system("afplay " + sound_file + "&") <NEW_LINE> <DEDENT> el... | Plays a given sound on Windows and Mac OSX
:param sound_file: **string** name of the sound to play
:return: | 625941c2b7558d58953c4ec9 |
def test_registration_validates_email_registration_ban(self): <NEW_LINE> <INDENT> Ban.objects.create( check_type=Ban.EMAIL, banned_value='lorem*', user_message="You can't register account like this.", registration_only=True, ) <NEW_LINE> response = self.client.post( self.api_link, data={ 'username': 'totallyNew', 'emai... | api validates email registration-only ban | 625941c25fcc89381b1e166f |
def find(self, _limit=None, _offset=0, _step=5000, order_by='id', **_filter): <NEW_LINE> <INDENT> self._check_dropped() <NEW_LINE> if not isinstance(order_by, (list, tuple)): <NEW_LINE> <INDENT> order_by = [order_by] <NEW_LINE> <DEDENT> order_by = [o for o in order_by if o in self.table.columns] <NEW_LINE> order_by = [... | Performs a simple search on the table. Simply pass keyword arguments as ``filter``.
::
results = table.find(country='France')
results = table.find(country='France', year=1980)
Using ``_limit``::
# just return the first 10 rows
results = table.find(country='France', _limit=10)
You can sort the result... | 625941c2009cb60464c63365 |
def assign(self, n, x): <NEW_LINE> <INDENT> return _math_linear.std_vector_vector_double_assign(self, n, x) | assign(std_vector_vector_double self, std::vector< std::vector< double > >::size_type n, std_vector_double x) | 625941c221bff66bcd684906 |
def test_write_header_fields(self): <NEW_LINE> <INDENT> control_file = os.path.join(REGRESSION_TESTS_DIR, 'MSVBVM60.DLL') <NEW_LINE> pe = pefile.PE(control_file, fast_load=True) <NEW_LINE> pe.parse_data_directories( directories=[ pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_RESOURCE']]) <NEW_LINE> original_data = pe.w... | Verify correct field data modification. | 625941c2e8904600ed9f1edc |
def get_headers(data): <NEW_LINE> <INDENT> return {k for row in data for k, _ in row.iteritems()} if data is not None else None | Loop through the data and collect any headers.
:param data list[dict]:
:rtype: set[str]
:returns: set of headers | 625941c28e71fb1e9831d75c |
def show_config(jail): <NEW_LINE> <INDENT> ret = {} <NEW_LINE> if subprocess.call(["jls", "-nq", "-j", jail]) == 0: <NEW_LINE> <INDENT> jls = subprocess.check_output( ["jls", "-nq", "-j", jail] ) <NEW_LINE> jailopts = salt.utils.args.shlex_split(salt.utils.stringutils.to_unicode(jls)) <NEW_LINE> for jailopt in jailopts... | Display specified jail's configuration
CLI Example:
.. code-block:: bash
salt '*' jail.show_config <jail name> | 625941c230c21e258bdfa44d |
def cylinder(draw, v1_, v2_, r, **options): <NEW_LINE> <INDENT> options = {"fill": "#fff", **options} <NEW_LINE> draw.line([int(x) for x in [v1_[0], v1_[1], v2_[0], v2_[1]]], width=int(r * 2), fill=options["fill"]) | draw a 3D cylinder | 625941c2e5267d203edcdc51 |
def ouvrePortes(mat): <NEW_LINE> <INDENT> for i in range(len(mat)): <NEW_LINE> <INDENT> for j in range(len(mat[0])): <NEW_LINE> <INDENT> pos = mat[i][j] <NEW_LINE> if pos == "E": <NEW_LINE> <INDENT> mat[i][j] = "S" <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return copy.deepcopy(mat) | Cette fonction permet de sortir une fois qu'il n'y a plus de diamant dans le jeu | 625941c291af0d3eaac9b9c9 |
def isEmptyString(inp): <NEW_LINE> <INDENT> return (inp == '' or inp is None) | Returns true if the input is None or is an Empty string. | 625941c226238365f5f0ee1e |
@application.route('/semanticize/<langcode>', methods=['GET', 'POST']) <NEW_LINE> def _semanticize_handler(langcode): <NEW_LINE> <INDENT> text = _get_text_from_request() <NEW_LINE> settings = {"langcode": langcode} <NEW_LINE> for key, value in request.values.iteritems(): <NEW_LINE> <INDENT> assert key not in settings <... | The function handling the /semanticize/<langcode> namespace. It uses
the chain-of-command pattern to run all processors, using the
corresponding preprocess, process, and postprocess steps.
@param langcode: The language to use in the semanticizing
@return: The body of the response, in this case a json formatted list ... | 625941c25fc7496912cc3930 |
def main(args_list=None): <NEW_LINE> <INDENT> if args_list is None: <NEW_LINE> <INDENT> args_list = sys.argv[1:] <NEW_LINE> <DEDENT> args = arg_parser.parse_args(args_list) <NEW_LINE> predictor = mhc_binding_predictor_from_args(args) <NEW_LINE> input_dictionary = { ("sequence%d" % i): seq for (i, seq) in enumerate(args... | Script to make pMHC binding predictions from amino acid sequences.
Usage example:
mhctools
--sequence SFFPIQQQQQAAALLLI --sequence SILQQQAQAQQAQAASSSC --mhc-predictor netmhc --mhc-alleles HLA-A0201 H2-Db --output-csv epitope.csv | 625941c27047854f462a13be |
def bar(self, serie, rescale=False): <NEW_LINE> <INDENT> serie_node = self.svg.serie(serie) <NEW_LINE> bars = self.svg.node(serie_node['plot'], class_="bars") <NEW_LINE> if rescale and self.secondary_series: <NEW_LINE> <INDENT> points = self._rescale(serie.points) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> points = ... | Draw a bar graph for a serie | 625941c2283ffb24f3c558b5 |
@require_POST <NEW_LINE> @login_required <NEW_LINE> def unwatch_locale(request): <NEW_LINE> <INDENT> ReviewableRevisionInLocaleEvent.stop_notifying(request.user, locale=request.LANGUAGE_CODE) <NEW_LINE> return HttpResponse() | Stop watching a locale for revisions ready for review. | 625941c230c21e258bdfa44e |
def test_socket_server_init_success(self): <NEW_LINE> <INDENT> socket_object_keys = ['accept', 'bind', 'close', 'connect', 'recv', 'send', 'shutdown'] <NEW_LINE> server_socket = BaseSocket() <NEW_LINE> [self.assertTrue(x in server_socket.__dir__()) for x in socket_object_keys] <NEW_LINE> server_socket.close_unix_socket... | Checking if socket object has all needed properties | 625941c24f6381625f1149ee |
def test_html_meta_title(self): <NEW_LINE> <INDENT> input_fname = "../../test-plans/HTML/Meta-title/input.txt" <NEW_LINE> input_type = "html" <NEW_LINE> expected_output_fname = "../../test-plans/HTML/Meta-title/output.txt" <NEW_LINE> actual_output_fname = "../../test-plans/HTML/Meta-title/actual.txt" <NEW_LINE> self.ru... | throws AssertionError: If test case fails
System test for meta title HTML test plan | 625941c2462c4b4f79d1d682 |
def save_state(self, fname: str): <NEW_LINE> <INDENT> with open(fname, "wb") as fp: <NEW_LINE> <INDENT> pickle.dump(self.batch_indices, fp) <NEW_LINE> pickle.dump(self.curr_batch_index, fp) <NEW_LINE> np.save(fp, [a.asnumpy() for a in self.inverse_data_permutations]) <NEW_LINE> np.save(fp, [a.asnumpy() for a in self.da... | Saves the current state of iterator to a file, so that iteration can be
continued. Note that the data is not saved, i.e. the iterator must be
initialized with the same parameters as in the first call.
:param fname: File name to save the information to. | 625941c2ec188e330fd5a754 |
def test_negative_take(self): <NEW_LINE> <INDENT> assert_raises(ValueError, take, -3, xrange(10)) | Make sure taking negative items results in a ValueError | 625941c2b7558d58953c4eca |
def test_ecdf_simple(self): <NEW_LINE> <INDENT> test_case = unittest.TestCase() <NEW_LINE> test_data = numpy.array([2,1,4,5]) <NEW_LINE> test_x, test_y = ecdf(test_data) <NEW_LINE> test_case.assertListEqual(test_x.tolist(),[1,2,4,5]) <NEW_LINE> test_case.assertListEqual(test_y.tolist(),[0.25,0.5,0.75,1.0]) | should have property that f(x) = P(X ≤ x).
f(x) = count where t ≤ x / total number in x | 625941c37b25080760e3940c |
def update_data(self, event=None): <NEW_LINE> <INDENT> self.server_append_caris_file.SetSelection( self.server_append_caris_file.FindString(str(self.settings_db.server_append_caris_file))) <NEW_LINE> self.server_append_caris_file.SetOwnBackgroundColour(wx.WHITE) <NEW_LINE> self.auto_export_on_server_send.SetSelection( ... | Update the data from the database | 625941c367a9b606de4a7e6d |
def reduce(self, f, check=True, degree_bound=None, coefficients=None, valuations=None): <NEW_LINE> <INDENT> f = self.domain().coerce(f) <NEW_LINE> if check: <NEW_LINE> <INDENT> v = self(f) <NEW_LINE> if v < 0: <NEW_LINE> <INDENT> raise ValueError("f must have non-negative valuation") <NEW_LINE> <DEDENT> elif v > 0: <NE... | Reduce ``f`` module this valuation.
INPUT:
- ``f`` -- an element in the domain of this valuation
- ``check`` -- whether or not to check whether ``f`` has non-negative
valuation (default: ``True``)
- ``degree_bound`` -- an a-priori known bound on the degree of the
result which can speed up the computation (defau... | 625941c28a349b6b435e8125 |
def get_last(fi_id): <NEW_LINE> <INDENT> db = DB() <NEW_LINE> query_tuple = ("SELECT * FROM Summaries WHERE FI_ID=%s ORDER BY PK DESC LIMIT 1",fi_id) <NEW_LINE> cur = db.execute(query_tuple) <NEW_LINE> summary = TwitterSummary() <NEW_LINE> summary.fi_id = fi_id <NEW_LINE> if cur.rowcount: <NEW_LINE> <INDENT> row = cur.... | Return the latest Summary object of the give fi_id account.
| 625941c36aa9bd52df036d55 |
def query_popen(filename, chrom, start, end): <NEW_LINE> <INDENT> query = '{}:{}-{}'.format(chrom, start, end) <NEW_LINE> process = subprocess.Popen(['tabix', filename, query],stdout=subprocess.PIPE) <NEW_LINE> for line in process.stdout: <NEW_LINE> <INDENT> yield line.strip().split() | Call tabix and generate an array of strings for each line it returns. | 625941c3ec188e330fd5a755 |
def _getUnderlyingVmDevicesInfo(self): <NEW_LINE> <INDENT> self._getUnderlyingNetworkInterfaceInfo() <NEW_LINE> self._getUnderlyingDriveInfo() <NEW_LINE> self._getUnderlyingSoundDeviceInfo() <NEW_LINE> self._getUnderlyingVideoDeviceInfo() <NEW_LINE> self._getUnderlyingGraphicsDeviceInfo() <NEW_LINE> self._getUnderlying... | Obtain underlying vm's devices info from libvirt. | 625941c307f4c71912b11433 |
def getRandom(self): <NEW_LINE> <INDENT> choice=self.list.val <NEW_LINE> head,i=self.list.next,1 <NEW_LINE> while head != None: <NEW_LINE> <INDENT> i+=1 <NEW_LINE> k=random.random() <NEW_LINE> if k <= 1.0/i: <NEW_LINE> <INDENT> choice=head.val <NEW_LINE> <DEDENT> head=head.next <NEW_LINE> <DEDENT> return choice | Returns a random node's value.
:rtype: int | 625941c37b180e01f3dc47b3 |
def reformat_json_data_into_csv(json_file: str, local_path_raw: str, local_path_csv: str) -> any: <NEW_LINE> <INDENT> filename_only = os.path.relpath(json_file, local_path_raw) <NEW_LINE> self.log.debug(f"json_file: {json_file}, local_path_raw: {local_path_raw}, local_path_csv: {local_path_csv}") <NEW_LINE> filename_wo... | Extract OpenAQ data fields from gzipped json file and
write them into csv file | 625941c3796e427e537b0576 |
def on_expr(self, node): <NEW_LINE> <INDENT> return self.interp(node.value) | expression | 625941c373bcbd0ca4b2c029 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.