code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def heatEquationMatrix(n): <NEW_LINE> <INDENT> N = n*n <NEW_LINE> A = np.diag([1]*(N-n), -n) + np.diag([1]*(N-n), n) <NEW_LINE> sub = -4*np.eye(n) + np.diag([1]*(n-1), 1) + np.diag([1]*(n-1), -1) <NEW_LINE> for i in range(0, n): <NEW_LINE> <INDENT> A[i*n:(i+1)*n,i*n:(i+1)*n] = sub[:,:] <NEW_LINE> <DEDENT> return A | Returns a tridiagonal n^2*n^2 matrix A to solve the heat equation
in a discrete way by solving the linear system Ax = b, where b is a n^2
vector such as b[n*x+y] is the heat flux density in the point (x,y)
and h is the distance on both axis between 2 consecutive points | 625941b36aa9bd52df036b5d |
def broken_seqs(ol,break_points): <NEW_LINE> <INDENT> bps = list(break_points) <NEW_LINE> length = ol.__len__() <NEW_LINE> rgs = rangize(bps,length) <NEW_LINE> rslt = [] <NEW_LINE> for i in range(0,rgs.__len__()): <NEW_LINE> <INDENT> si,ei = rgs[i] <NEW_LINE> sec = ol[si:ei] <NEW_LINE> rslt.append(sec) <NEW_LINE> <DEDE... | ol = initRange(0,20,1)
ol
break_points = [1,6,14,9]
secs = broken_seqs(ol,break_points)
forEach(secs,print) | 625941b30383005118ecf3a0 |
def test_molecular_density(self): <NEW_LINE> <INDENT> self.assertAlmostEqual( molecular_density(200), 3.669449208173649e+19, places=24) <NEW_LINE> self.assertAlmostEqual( molecular_density(300), 2.4462994721157665e+19, places=24) <NEW_LINE> self.assertAlmostEqual( molecular_density(400), 1.8347246040868246e+19, places=... | Tests
:func:`colour.phenomenons.rayleigh.molecular_density`
definition. | 625941b323849d37ff7b2e4e |
def r_hash(self, keys): <NEW_LINE> <INDENT> with self.r.pipeline(transaction=False) as pipe: <NEW_LINE> <INDENT> for key in keys: <NEW_LINE> <INDENT> pipe.hgetall(key) <NEW_LINE> <DEDENT> values = pipe.execute() <NEW_LINE> <DEDENT> res = zip(keys, values) <NEW_LINE> return res | get redis hash values
:param keys:
:return: | 625941b3377c676e91271f6c |
def send(combination, do_press=True, do_release=True): <NEW_LINE> <INDENT> for keys in canonicalize(combination): <NEW_LINE> <INDENT> if do_press: <NEW_LINE> <INDENT> for key in keys: <NEW_LINE> <INDENT> _os_keyboard.press(to_scan_code(key)) <NEW_LINE> <DEDENT> <DEDENT> if do_release: <NEW_LINE> <INDENT> for key in rev... | Sends OS events that perform the given hotkey combination.
- `combination` can be either a scan code (e.g. 57 for space), single key
(e.g. 'space') or multi-key, multi-step combination (e.g. 'alt+F4, enter').
- `do_press` if true then press events are sent. Defaults to True.
- `do_release` if true then release events ... | 625941b30a50d4780f666c4a |
def add_structure(self, struct, path=None): <NEW_LINE> <INDENT> if path == None or path == '': <NEW_LINE> <INDENT> self._structures[struct.id] = struct <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> path = path.split('/') <NEW_LINE> if path[0] in self._packages: <NEW_LINE> <INDENT> self._packages[path[0]].add_structure(... | Adds an object to L10nPackage.
Optional parameter path allows to declare place
inside the package where the object should be added.
For example l10npack.add_structure(l10nstruct, 'pkg1/pkg2') is similar to
l10npack.get_package('pkg1').get_package('pkg2').add_structure(l10nstruct)
with the difference that it will crea... | 625941b326068e7796caea94 |
@singledispatch <NEW_LINE> def cycle(iterable): <NEW_LINE> <INDENT> return itertools.cycle(iterable) | Make an iterator returning elements from the iterable and saving a copy of each.
When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely.
This function uses single dispatch.
.. seealso:: :func:`itertools.cycle` | 625941b350485f2cf553cb54 |
def render( self ): <NEW_LINE> <INDENT> raise NotImplementedError( "Not implemented method" ); | Interface for render function
@returns output | 625941b3de87d2750b85fb49 |
def line0_p(x,p): <NEW_LINE> <INDENT> return p*x | Straight line through origin: a*x
Parameters
----------
x : float or array_like of floats
independent variable
p : iterable of floats
`p[0]` is a
Returns
-------
float
function value(s) | 625941b330bbd722463cbb7f |
def plot_control_loop_output(output_generator: Generator, x_lim: List[int] = None, plot_errors: bool = True) -> plt.Figure: <NEW_LINE> <INDENT> system_states = [] <NEW_LINE> velocities = [] <NEW_LINE> error_signals = defaultdict(list) <NEW_LINE> controller_outputs = [] <NEW_LINE> time_step = [] <NEW_LINE> for output in... | Plot the output of a closed control loop run. | 625941b33c8af77a43ae3562 |
def create_replace(self, scheduled_date, warehouse, product, qty, uom): <NEW_LINE> <INDENT> self.ensure_one() <NEW_LINE> self._ensure_can_be_replaced() <NEW_LINE> moves_before = self.delivery_move_ids <NEW_LINE> self._action_launch_stock_rule(scheduled_date, warehouse, product, qty, uom) <NEW_LINE> new_move = self.deli... | Intended to be invoked by the delivery wizard | 625941b360cbc95b062c6305 |
def fcall(self, children: List[Union[str, Optional[PyLautAtom]]]) -> Change: <NEW_LINE> <INDENT> fname = children[0] <NEW_LINE> args = [] <NEW_LINE> for c in children[1:]: <NEW_LINE> <INDENT> args.append(c) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self.funcs[fname](*args) <NEW_LINE> <DEDENT> except KeyError:... | Looks up a function name in the function library,
a dictionary passed to the PyLautLang object at init time.
If the function exists, call it. If not, return an empty
Change.
:param list children: A function name plus the arguments to it.
:returns: A Change object. | 625941b345492302aab5e07b |
def test_feedback_can_set_reference(self) -> None: <NEW_LINE> <INDENT> email = 'test@email.com' <NEW_LINE> feedback = Feedback(email=email, reviewer_id=self.reviewer_in_db.id, review_status_id=self.review_status_in_db.id) <NEW_LINE> db.session.add(feedback) <NEW_LINE> db.session.commit() <NEW_LINE> feedback_in_db = db.... | Test of setting reviewer for a feedback | 625941b32eb69b55b151c665 |
def genPetscTests(self,root,dirs,files,dataDict): <NEW_LINE> <INDENT> debug=False <NEW_LINE> dataDict[root]={} <NEW_LINE> for exfile in files: <NEW_LINE> <INDENT> if exfile.startswith("."): continue <NEW_LINE> if exfile.startswith("#"): continue <NEW_LINE> if exfile.endswith("~"): continue <NEW_LINE> ext=os.path.splite... | Go through and parse the source files in the directory to generate
the examples based on the metadata contained in the source files | 625941b394891a1f4081b864 |
def unstack(self): <NEW_LINE> <INDENT> if self.stack_pointer == 0: <NEW_LINE> <INDENT> raise Underflow() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.stack_pointer -= 1 <NEW_LINE> return self.remove_node(self.stack_pointer) | Return the top item and delete it from the stack | 625941b397e22403b379cd54 |
def transfer_var(self, value, row, field): <NEW_LINE> <INDENT> j = self.current_row + row <NEW_LINE> line = self.data[j] <NEW_LINE> sub = _SubHelper() <NEW_LINE> sub.set(value, field) <NEW_LINE> newline = re.sub(self.reg, sub.replace, line) <NEW_LINE> self.data[j] = newline | Changes a single variable in the template relative to the
current anchor.
Args
----
value : float, integer, bool, string
New value to set at the location.
row : integer
Number of lines offset from anchor line (0 is anchor line).
This can be negative.
field : integer
Which word in line to replace, as ... | 625941b385dfad0860c3ac14 |
def awaitable(fn, *args, **kwargs): <NEW_LINE> <INDENT> future = POOL.submit(fn, *args, **kwargs) <NEW_LINE> return asyncio.wrap_future(future) | Turn sync method to async | 625941b338b623060ff0abb2 |
def get(self, path, as_json=False): <NEW_LINE> <INDENT> bucket, path = self._parse_uri(path) <NEW_LINE> return self._request('%s/o/%s' % (bucket, urllib.parse.quote(path, '')), {'alt': 'media'}, as_json=as_json) | Get an object from GCS. | 625941b363b5f9789fde6ea1 |
def sync_wallet(self, fast=True): <NEW_LINE> <INDENT> if self.synced: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if fast: <NEW_LINE> <INDENT> self.sync_wallet_fast() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.sync_addresses() <NEW_LINE> self.sync_unspent() <NEW_LINE> <DEDENT> self.last_seen_txid = next... | Syncs wallet; note that if slow sync
requires multiple rounds this must be called
until self.synced is True.
Before starting the event loop, we cache
the current most recent transactions as
reported by the blockchain interface, since
we are interested in deltas. | 625941b367a9b606de4a7c79 |
def addMusic(item): <NEW_LINE> <INDENT> artist = item.find(attrs={'class':'s_name'}).a['title'].encode('utf-8') <NEW_LINE> title = item.find(attrs={'class':'m_name'}).a['title'].encode('utf-8') <NEW_LINE> mid = item.find(attrs={'class':'number'}).input['mid'].encode('utf-8') <NEW_LINE> iconimage = '' <NEW_LINE> addLink... | for mingxing and album | 625941b30383005118ecf3a1 |
def select(self): <NEW_LINE> <INDENT> warnings.filterwarnings("ignore", category=DeprecationWarning) <NEW_LINE> result_model = self.base_model(self.n_constant) <NEW_LINE> max_value = float('inf') <NEW_LINE> for n_components in range(self.min_n_components, self.max_n_components+1): <NEW_LINE> <INDENT> try: <NEW_LINE> <I... | select the best model for self.this_word based on
BIC score for n between self.min_n_components and self.max_n_components
:return: GaussianHMM object | 625941b39b70327d1c4e0b90 |
def set_NDV(self, ndv: int) -> bool: <NEW_LINE> <INDENT> self.NDV = ndv <NEW_LINE> return True | set nodata value | 625941b3ec188e330fd5a564 |
def show_diffBragg_state(D, debug_pixel_panelfastslow): <NEW_LINE> <INDENT> D.show_params() <NEW_LINE> MAIN_LOGGER.info("internal spot scale=%f" % D.spot_scale) <NEW_LINE> D.raw_pixels*=0 <NEW_LINE> p, f, s = debug_pixel_panelfastslow <NEW_LINE> D.printout_pixel_fastslow = f, s <NEW_LINE> D.add_diffBragg_spots((p, f, s... | D, diffBragg instance
debug_pixel_panelfastslow, 3-tuple of ints, panelId, fast coord, slow coord | 625941b350812a4eaa59c0e3 |
def main(): <NEW_LINE> <INDENT> logging.basicConfig(level=logging.INFO) <NEW_LINE> args = parse_args() <NEW_LINE> instance = get_instance(args.instance_id) <NEW_LINE> with ec2window.run_ec2_instance(instance): <NEW_LINE> <INDENT> LOG.info('hello world!') | Start and stop an instance. | 625941b3004d5f362079a0f4 |
def dispatch(method, headers, url, payload): <NEW_LINE> <INDENT> method, headers, filename, param_dict = _preprocess(method, headers, url) <NEW_LINE> gcs_stub = cloudstorage_stub.CloudStorageStub( apiproxy_stub_map.apiproxy.GetStub('blobstore').storage) <NEW_LINE> with GCS_STUB_LOCK: <NEW_LINE> <INDENT> if method == 'P... | Dispatches incoming request and returns response.
In dev appserver GCS requests are forwarded to this method via the /_ah/gcs
endpoint. In unittest environment, this method is called instead of urlfetch.
See https://developers.google.com/storage/docs/xml-api-overview for the
exepected format for the request.
Args:
... | 625941b3e5267d203edcda5e |
def _create_voucher_from_record(self, cursor, uid, record, statement, line_ids, context=None): <NEW_LINE> <INDENT> context.update({'move_line_ids': line_ids}) <NEW_LINE> voucher_obj = self.pool.get('account.voucher') <NEW_LINE> move_line_obj = self.pool.get('account.move.line') <NEW_LINE> voucher_line_obj = self.pool.g... | Create a voucher with voucher line | 625941b3aad79263cf3907f7 |
def __init__(self): <NEW_LINE> <INDENT> self.Type = None <NEW_LINE> self.StartTime = None <NEW_LINE> self.EndTime = None | :param Type: 请求类型 1:人群特征洞察统计 2:购车意向预测统计
:type Type: int
:param StartTime: 开始时间戳(毫秒)
:type StartTime: int
:param EndTime: 结束时间戳(毫秒)
:type EndTime: int | 625941b391af0d3eaac9b7cf |
def get_sigmoid_data(self, index_offset=150, max_fnh3=1.): <NEW_LINE> <INDENT> if max_fnh3 > 1. or max_fnh3 < 0.: <NEW_LINE> <INDENT> raise ValueError("max_fnh3 must be between 0 and 1") <NEW_LINE> <DEDENT> if self.Tc_indices is None: <NEW_LINE> <INDENT> self.get_temp_changes() <NEW_LINE> <DEDENT> times = self.log_data... | Return sigmoid data for all changes in temperature
Args:
index_offset: number of points to take averages over
max_fnh3: maximum fraction of NH3 (for experiments where more than
one input gas). | 625941b363b5f9789fde6ea2 |
def label_preprocessing(self): <NEW_LINE> <INDENT> centered_continuous_label_dict = {key: [] for key in self.emotion_dimension} <NEW_LINE> for emotion in self.emotion_dimension: <NEW_LINE> <INDENT> continuous_labels = self.continuous_label[emotion] <NEW_LINE> for continuous_label in continuous_labels: <NEW_LINE> <INDEN... | Carry out the label preprocessing. Here, since multiple raters are available, therefore
concordance_correlation_coefficient_centering has to be performed. | 625941b382261d6c526ab25f |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, FilterKeys): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941b38a349b6b435e7f37 |
def _trace_global(self, frame, event, arg): <NEW_LINE> <INDENT> if self._stop is True: <NEW_LINE> <INDENT> raise KeyboardInterrupt <NEW_LINE> <DEDENT> if self._end is True: <NEW_LINE> <INDENT> sys.settrace(None) <NEW_LINE> return self._trace_off <NEW_LINE> <DEDENT> filename = inspect.getsourcefile(frame) or inspect.get... | The main trace function called on call events | 625941b31b99ca400220a86c |
def _delete_test_log_files(self): <NEW_LINE> <INDENT> util.remove_file(self._PATH_TO_TEST_DIR + "/" + self._LOG_ERRORS_NAME) <NEW_LINE> util.remove_file(self._PATH_TO_TEST_DIR + "/" + self._LOG_INFO_NAME) | deletes the two generated logfiles | 625941b330c21e258bdfa259 |
def _all(self, *args, **kwargs): <NEW_LINE> <INDENT> data = dict() <NEW_LINE> data["software"] = self._software(**kwargs) <NEW_LINE> data["system"] = self._system(**kwargs) <NEW_LINE> data["services"] = self._services(**kwargs) <NEW_LINE> try: <NEW_LINE> <INDENT> data["configuration"] = self._configuration(**kwargs) <N... | Return all the summary of the particular system. | 625941b3d164cc6175782b0a |
def __init__(self, width, height, title): <NEW_LINE> <INDENT> file_path = os.path.dirname(os.path.abspath(__file__)) <NEW_LINE> os.chdir(file_path) <NEW_LINE> super().__init__(width, height, title) <NEW_LINE> self.all_sprites_list = None <NEW_LINE> self.player_sprite = None <NEW_LINE> self.score = 0 <NEW_LINE> arcade.s... | Initializer | 625941b3ec188e330fd5a565 |
def train(self, X, Y, lr=1e-4, lambda_=1e-5, momentum=0.99, steps=10000, batch=None): <NEW_LINE> <INDENT> X = np.asarray(X) <NEW_LINE> Y = np.asarray(Y) <NEW_LINE> m = X.shape[0] <NEW_LINE> if batch is None: <NEW_LINE> <INDENT> batch = X.shape[0] <NEW_LINE> <DEDENT> i = m <NEW_LINE> indices = np.arange(m) <NEW_LINE> fo... | Train the network.
Apply multiple steps of stochastic gradient descent.
Parameters
----------
X : ndarray, shape (m, n)
input features (one row per feature vector).
Y : ndarray, shape (m,)
target output (integer class labels).
lr : float
learning rate.
lambda_ : float
regularization coefficients.
mome... | 625941b3046cf37aa974cb07 |
def sp_sim_xpcs_events(events, decaytime, scatterrate, clockperiod=40e-9): <NEW_LINE> <INDENT> import sys <NEW_LINE> lam = clockperiod/decaytime <NEW_LINE> sigmazsq = scatterrate/2.0 <NEW_LINE> num = (1.0 - np.exp(-2.0*lam) ) <NEW_LINE> den = (1.0 - np.exp(-1.0*lam) )**2 <NEW_LINE> sigmay = np.sqrt( sigmazsq * (num/den... | Simulate a single photon XPCS signal with a decaytime for events events.
The simulated sample has a scatterrate (in Hz) and detector has a
clockperiod (in s).
This algorithm implements the simulator from Rev. Sci. Instrum 74 4273.
arguments:
events - Total number of events to collect.
decaytime - Deca... | 625941b34d74a7450ccd3f80 |
def fetch_simple_stats(_, textbuffer: Gtk.TextBuffer) -> None: <NEW_LINE> <INDENT> tlp_stat_cmd = which("tlp-stat") <NEW_LINE> if tlp_stat_cmd is None: <NEW_LINE> <INDENT> textbuffer.set_text(TLP_STAT_MISSING) <NEW_LINE> return <NEW_LINE> <DEDENT> simple_stat_command = ["tlp-stat", "-r", "-t", "-c", "-s", "-u"] <NEW_LI... | Fetch simple tlp-stat information. | 625941b399cbb53fe67929a4 |
def quit(self): <NEW_LINE> <INDENT> self.timer_heap.quit() | Terminate the timer factory. Pending timers and events will not
be processed. | 625941b332920d7e50b27f8c |
def focus_in(self, *args): <NEW_LINE> <INDENT> pass | Focus change event | 625941b307f4c71912b11242 |
def _square_wave(self, sampling_frequency, square_wave_frequency, measurement_period, duty_cycle): <NEW_LINE> <INDENT> t_sampling = np.linspace(0, measurement_period, int(measurement_period * sampling_frequency)) <NEW_LINE> square_wave = signal.square(2 * np.pi * square_wave_frequency * t_sampling, duty=duty_cycle) <NE... | Creates a square wave. This is used as a box function over a sine wave to turn it off and on.
@param sampling_frequency The frequency at which the wave is sampled. Consecutive samples
are separated by units of time equalling 1/sample_frequency
@param square_wave_frequency The freque... | 625941b3462c4b4f79d1d48c |
def install(self,install_type = "nr"): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> self.code2sys(self.install_hosts.code(install_type)) <NEW_LINE> return 0 <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> return 1 | 传入nr普通安装,传入na安装科学上网+去除广告hosts | 625941b3de87d2750b85fb4a |
def straight_polynom(value, coefficients): <NEW_LINE> <INDENT> polynom = 0 <NEW_LINE> for i,a in enumerate(coefficients): <NEW_LINE> <INDENT> polynom += a * value**(len(coefficients)-1-i) <NEW_LINE> <DEDENT> return polynom | Calculate polynom value with Horner algorythm
Parameters are coefficients of the polynom and a value to calculate for | 625941b321bff66bcd684713 |
def e2wrn28_7(pretrained=False, **kwargs): <NEW_LINE> <INDENT> model = Wide_ResNet(28, 7, 0.3, f=True, initial_stride=1, **kwargs) <NEW_LINE> if pretrained: <NEW_LINE> <INDENT> model.load_state_dict(model_paths['e2wrn28_7']) <NEW_LINE> <DEDENT> return model | Constructs a Wide ResNet 28-7 model
Args:
pretrained (bool): If True, returns a model pre-trained | 625941b301c39578d7e74c01 |
def goto(self, value) : <NEW_LINE> <INDENT> self._value = float(value) <NEW_LINE> pcnt = (self._value - self._value_from) / (self._value_to - self._value_from) <NEW_LINE> pcnt = 0.0 if pcnt < 0.0 else 1.0 if pcnt > 1.0 else pcnt <NEW_LINE> len_done = int(round(pcnt * self._length)) <NEW_LINE> len_wait = self._length - ... | Walk the progress bar to specified value, and flush the display
args:
value: position of progress bar. If out of range, will display 0% or 100% | 625941b3627d3e7fe0d68c0a |
def predict(self, input_matrix): <NEW_LINE> <INDENT> alpha = self.population[0] <NEW_LINE> return alpha.predict(input_matrix) | Predict output matrix of an input matrix
:param input_matrix: matrix of inputs
:return: best guess of output matrix | 625941b3eab8aa0e5d26d91b |
def __init__(self, data, affine, coord_sys, metadata=None): <NEW_LINE> <INDENT> affine = np.asarray(affine) <NEW_LINE> if affine.shape != (4,4): <NEW_LINE> <INDENT> raise ValueError('Affine image takes 4x4 affine as input') <NEW_LINE> <DEDENT> function_domain = CoordinateSystem(['axis%d' % i for i in range(3)], name=co... | Creates a new nipy image with an affine mapping.
Parameters
----------
data : ndarray
ndarray representing the data.
affine : 4x4 ndarray
affine transformation to the reference coordinate system
coord_system : string
name of the reference coordinate system. | 625941b3ab23a570cc24ff44 |
def test_flavor_list_filter_project(self): <NEW_LINE> <INDENT> response = self.myget('flavors/detail', data={'SNF:flavor-access': self.project1}) <NEW_LINE> self.assertSuccess(response) <NEW_LINE> api_flavors = json.loads(response.content)['flavors'] <NEW_LINE> self.assertEqual(len(api_flavors), 3) <NEW_LINE> for api_f... | Test listing only flavors accesed by a specific project | 625941b34e4d5625662d419b |
def user_media_path(what): <NEW_LINE> <INDENT> default = os.path.join(settings.MEDIA_ROOT, what) <NEW_LINE> key = "{0}_PATH".format(what.upper()) <NEW_LINE> return getattr(settings, key, default) | Make it possible to override storage paths in settings.
By default, all storage paths are in the MEDIA_ROOT.
This is backwards compatible. | 625941b3cad5886f8bd26d9f |
def train(self, n_steps=10000, print_steps=100, plot=True): <NEW_LINE> <INDENT> pyro.clear_param_store() <NEW_LINE> learning_rate = 0.2 * 1e-2 <NEW_LINE> momentum = 1e-1 <NEW_LINE> optimizer = torch.optim.SGD(self.GP.parameters(), lr=learning_rate, momentum=momentum) <NEW_LINE> optimizer = torch.optim.Adam(self.GP.para... | Train the embedding and GP.
Args:
n_steps (int): number of training steps.
print_steps (int): print the loss if step is a multiple of
`print_steps`. `None` if no print.
plot (bool): plot the steps-by-loss matrix after training. | 625941b3bf627c535bc12f94 |
def back(self, savePath, parentPath, needBack): <NEW_LINE> <INDENT> tr = ExecUtil.execCommand(" tar czvf " + savePath + " -C " + parentPath + " " + needBack) | savePath:备份文件保存的路径
parentPath:需要备份的父路径
needBack:需要备份的父目录 | 625941b3cdde0d52a9e52df1 |
def __init__(self): <NEW_LINE> <INDENT> self.logger = logging.getLogger('JSONUtil') | Constructor | 625941b35166f23b2e1a4f16 |
@app.route('/list') <NEW_LINE> def list_all(): <NEW_LINE> <INDENT> expressions = index.trees[:100] <NEW_LINE> return render_template('list.html', expressions=expressions) | [DEPRECATED]
Return first 100 symbol tress | 625941b310dbd63aa1bd296e |
def read_from_in_pipe(self, *l): <NEW_LINE> <INDENT> txt = '\n' <NEW_LINE> txt_line = '' <NEW_LINE> os_read = os.read <NEW_LINE> self_stdin_pipe = self.stdin_pipe <NEW_LINE> self_mode = self.mode <NEW_LINE> self_write = self.write <NEW_LINE> Clock_schedule_once = Clock.schedule_once <NEW_LINE> self_update_cache = self.... | Read the output from the command
| 625941b399fddb7c1c9de151 |
@app.route('/killprocess', methods=['POST']) <NEW_LINE> def kill_process(): <NEW_LINE> <INDENT> if request.method == 'POST': <NEW_LINE> <INDENT> pid = request.form['pid'] <NEW_LINE> try : <NEW_LINE> <INDENT> with dbt.execute('kill %s', pid): pass <NEW_LINE> <DEDENT> except : <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT>... | Tris to kill the process corresponding to the pid posted. | 625941b3fb3f5b602dac3454 |
def __init__(self, *args, **options): <NEW_LINE> <INDENT> self.__log.call(*args, **options) <NEW_LINE> super().__init__(*args, **options) <NEW_LINE> fm = self.master <NEW_LINE> self._disc_eject_button = Button( self, name="disc_eject_button", text="Eject", command=fm.eject_disc) <NEW_LINE> self._disc_status_label = Lab... | :arg tuple args: positional arguments to initialize the frame
:arg dict options: ``config`` options to initialize the frame
All widgets for this frame are initialized, but layout is
deferred until methods are called to transition between states. | 625941b38c0ade5d55d3e77c |
def __init__(self, file_name='users.db', table_name='users'): <NEW_LINE> <INDENT> self.__file_name = file_name <NEW_LINE> self.__table_name = table_name | This class is responsible for the users.db data base. This data base has all the information about the users.
This class can create the table, add new users, change info.
:param file_name: The name of the data base file (.db). This data base contains the information about the users.
:param table_name: The name of the t... | 625941b36aa9bd52df036b5f |
def convert_single_example(ex_index, example, label_list, max_seq_length, tokenizer): <NEW_LINE> <INDENT> if isinstance(example, PaddingInputExample): <NEW_LINE> <INDENT> return InputFeatures( input_ids=[0] * max_seq_length, input_mask=[0] * max_seq_length, segment_ids=[0] * max_seq_length, label_id=0, is_real_example=... | Converts a single `InputExample` into a single `InputFeatures`. | 625941b3be383301e01b5253 |
def __call__(self, img): <NEW_LINE> <INDENT> s = self.get_params(img) <NEW_LINE> return FF.resize(img, s) | random resize.
by zxn.
:param img: PIL image
:return: resized pil image | 625941b3e5267d203edcda5f |
def reloadPlugins(self): <NEW_LINE> <INDENT> self.pluginWidget.updatePlugins() | Slot to reload plugins.
| 625941b323849d37ff7b2e50 |
def threeSum2(self, nums): <NEW_LINE> <INDENT> d = collections.Counter(nums) <NEW_LINE> nums_2 = [x[0] for x in d.items() if x[1] > 1] <NEW_LINE> nums_unique = sorted([x[0] for x in d.items()]) <NEW_LINE> rtn = [[0, 0, 0]] if d[0] >= 3 else [] <NEW_LINE> for i, j in enumerate(nums_unique): <NEW_LINE> <INDENT> if j <= 0... | :type nums: List[int]
:rtype: List[List[int]] | 625941b3be7bc26dc91cd3c4 |
@_system_proxy <NEW_LINE> def open_system_proxy(_set_key, internet_set_option, proxy_ip=u"", ignore_ip=u""): <NEW_LINE> <INDENT> _set_key('ProxyEnable', 1) <NEW_LINE> if ignore_ip: <NEW_LINE> <INDENT> _set_key('ProxyOverride', ignore_ip) <NEW_LINE> <DEDENT> if proxy_ip: <NEW_LINE> <INDENT> _set_key('ProxyServer', proxy... | 开启系统代理 | 625941b30a50d4780f666c4c |
def iterables(self): <NEW_LINE> <INDENT> iterables = {} <NEW_LINE> for key, value in self.parameters.items(): <NEW_LINE> <INDENT> if (not isinstance(value, str) and isinstance(value, collections.Iterable)): <NEW_LINE> <INDENT> iterables[key] = value <NEW_LINE> <DEDENT> <DEDENT> keys = list(iterables.keys()) <NEW_LINE> ... | Generator yielding the product of every iterable keyword | 625941b34527f215b584c21b |
def how_many(aDict): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> for vals in aDict.values(): <NEW_LINE> <INDENT> count += len(vals) <NEW_LINE> <DEDENT> return count | Returns how many values are in a dictionary of lists. | 625941b360cbc95b062c6307 |
def cyllat(r, lonc, z): <NEW_LINE> <INDENT> r = ctypes.c_double(r) <NEW_LINE> lonc = ctypes.c_double(lonc) <NEW_LINE> z = ctypes.c_double(z) <NEW_LINE> radius = ctypes.c_double() <NEW_LINE> lon = ctypes.c_double() <NEW_LINE> lat = ctypes.c_double() <NEW_LINE> libspice.cyllat_c(r, lonc, z, ctypes.byref(radius), ctypes.b... | Convert from cylindrical to latitudinal coordinates.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cyllat_c.html
:param r: Distance of point from z axis.
:type r: float
:param lonc: Cylindrical angle of point from XZ plane(radians).
:type lonc: float
:param z: Height of point above XY plane.
:type z: float
... | 625941b326238365f5f0ec27 |
def filenamesort(filename): <NEW_LINE> <INDENT> name, ext = os.path.splitext(filename) <NEW_LINE> return naturalsort(name), ext | Return a key for sorting filenames. | 625941b363f4b57ef0000ee9 |
def elapseTime(self, progress, seconds): <NEW_LINE> <INDENT> progress.set_time(progress.time - datetime.timedelta(seconds=seconds)) <NEW_LINE> try: <NEW_LINE> <INDENT> session = ScriptSession.objects.get(connection=progress.connection, end_time=None) <NEW_LINE> session.start_time = session.start_time - datetime.timedel... | This hack mimics the progression of time, from the perspective of a linear test case,
by actually *subtracting* from the value that's currently stored (usually datetime.datetime.now()) | 625941b3167d2b6e3121895c |
def fit_galaxy_sky_multi(galaxy0, datas, weights, ctrs, psfs, regpenalty, factor): <NEW_LINE> <INDENT> nepochs = len(datas) <NEW_LINE> cvals = [] <NEW_LINE> for data, weight, ctr, psf in zip(datas, weights, ctrs, psfs): <NEW_LINE> <INDENT> cval, _ = chisq_galaxy_sky_single(galaxy0, data, weight, ctr, psf) <NEW_LINE> cv... | Fit the galaxy model to multiple data cubes.
Parameters
----------
galaxy0 : ndarray (3-d)
Initial galaxy model.
datas : list of ndarray
Sky-subtracted data for each epoch to fit. | 625941b30a50d4780f666c4d |
def get_used_gpu_memory(self): <NEW_LINE> <INDENT> result = subprocess.check_output( [ 'nvidia-smi', '--query-gpu=memory.used', '--format=csv,nounits,noheader' ], encoding='utf-8') <NEW_LINE> gpu_memory = [int(x) for x in result.strip().split('\n')] <NEW_LINE> gpu_memory = np.array(gpu_memory) <NEW_LINE> return gpu_mem... | Adapted code from mjstevens777
https://discuss.pytorch.org/t/access-gpu-memory-usage-in-pytorch/3192/3
Get the current GPU usage.
Return:
gpu_memory: numpy array
memory usage as integers in MB. | 625941b323e79379d52ee327 |
def _annotations(self): <NEW_LINE> <INDENT> start = 0 <NEW_LINE> for end in self.annot_index: <NEW_LINE> <INDENT> yield start, end <NEW_LINE> start = end | Yield blocks of annotated SNPs | 625941b397e22403b379cd56 |
def test_filter_no_parameters(self): <NEW_LINE> <INDENT> statement1 = StatementModel(text="Testing...") <NEW_LINE> statement2 = StatementModel(text="Testing one, two, three.") <NEW_LINE> self.adapter.update(statement1) <NEW_LINE> self.adapter.update(statement2) <NEW_LINE> results = self.adapter.filter() <NEW_LINE> self... | If no parameters are passed to the filter,
then all statements should be returned. | 625941b3460517430c393f4e |
def validateValue(self, value): <NEW_LINE> <INDENT> if type(value) not in (int, float): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True | Validates the incoming value is the correct type.
Arguments:
value -- Type, value to check the type of.
Return:
True if successful. | 625941b3d164cc6175782b0b |
def faces_from_solids(self, solid): <NEW_LINE> <INDENT> return self._loop_topo(topology_type=TopAbs_FACE, topological_entity=solid) | Parameters
----------
solid
Returns
------- | 625941b38c3a87329515817c |
def __neg__(self): <NEW_LINE> <INDENT> lc_new = Lightcurve(self.time, -1*self.counts) <NEW_LINE> return lc_new | Implement the behavior of negation of the light curve objects.
The negation operator ``-`` is supposed to invert the sign of the count
values of a light curve object.
Example
-------
>>> time = [1, 2, 3]
>>> count1 = [100, 200, 300]
>>> count2 = [200, 300, 400]
>>> lc1 = Lightcurve(time, count1)
>>> lc2 = Lightcurve(... | 625941b37c178a314d6ef216 |
def test_file_s_detailed(self): <NEW_LINE> <INDENT> expected_filesize = 2131 <NEW_LINE> filename = 'testfile.tsv' <NEW_LINE> if os.path.exists(filename): <NEW_LINE> <INDENT> os.remove(filename) <NEW_LINE> <DEDENT> self.assertFalse(os.path.exists(filename)) <NEW_LINE> argv = ['s', '-de', '-o', filename, os.path.join(sel... | Test detailed S output. | 625941b338b623060ff0abb4 |
def home_axis(x=None, y=None, z=None, optional=None): <NEW_LINE> <INDENT> return Code("G28", x=Bool(x), y=Bool(y), z=Bool(z), o=Bool(optional)) | G28: Home one or more axis. | 625941b3d18da76e2353228e |
def __call__(self, atom): <NEW_LINE> <INDENT> position = atom.position <NEW_LINE> atomicnumber = atom.atomicnumber <NEW_LINE> newposition = self.r * position + self.t <NEW_LINE> return atomsite.AtomSite(atomicnumber, newposition) | Return the symmetry operation on an *atomsite*.
:math:`= RV + T`
:arg atom: atomsite to apply the symmetry operation
:type atom: :class:`atomsite.AtomSite` | 625941b38e7ae83300e4ad8a |
def copy_xyz_tree(base_dir, new_dir): <NEW_LINE> <INDENT> structures = get_structures(base_dir) <NEW_LINE> copy_tree(structures, base_dir, new_dir) | Copy all xyz files recursively to a new directory, maintaining the original
directory structure. Give the new directory as a relative path to the
base directory that you are copying from. | 625941b3d486a94d0b98df0d |
def parse_qpidd_conf(config_file): <NEW_LINE> <INDENT> f = open(config_file) <NEW_LINE> try: <NEW_LINE> <INDENT> clean = filter(None, [line.split("#")[0].strip() for line in f]) <NEW_LINE> def item(line): return [x.strip() for x in line.split("=")] <NEW_LINE> config = dict(item(line) for line in clean if "=" in line) ... | Parse a qpidd.conf configuration file into a dictionary | 625941b350812a4eaa59c0e5 |
def form_valid(self, form): <NEW_LINE> <INDENT> context = self.get_context_data() <NEW_LINE> fl_form_formset = context['formLegendFormFormset'] <NEW_LINE> if fl_form_formset.is_valid(): <NEW_LINE> <INDENT> fl_form_form = form.save(commit=False) <NEW_LINE> fl_form_form.user = self.request.user <NEW_LINE> try: <NEW_LINE>... | This method overrides form_valid and makes sure the
authenticated user is bound to both the FormLegendForm and
FormLegenField instances that are saved here. | 625941b3aad79263cf3907f9 |
def isCorner(size, i, j): <NEW_LINE> <INDENT> return (i == 0 and i == 0) or (i == 0 and j == size) or (i == size and j == 0) or (i == size and j == size) | Returns true if the given position is an corner | 625941b3ec188e330fd5a566 |
def string_to_tiles(self, text): <NEW_LINE> <INDENT> parsed_tiles = [] <NEW_LINE> suit_markers = re.findall("[mpsz]", text) <NEW_LINE> remainder = text <NEW_LINE> for suit in suit_markers: <NEW_LINE> <INDENT> values, remainder = remainder.split(suit) <NEW_LINE> for value in values: <NEW_LINE> <INDENT> parsed_tiles.appe... | "
Enables standard string formats to be read in as a tiles
E.g. 1m222p --> Tile(1, 'm'), Tile(2, 'p'), etc. | 625941b3e5267d203edcda60 |
def to_pandas(self): <NEW_LINE> <INDENT> self._t_env._before_execute() <NEW_LINE> gateway = get_gateway() <NEW_LINE> max_arrow_batch_size = self._j_table.getTableEnvironment().getConfig().getConfiguration() .getInteger(gateway.jvm.org.apache.flink.python.PythonOptions.MAX_ARROW_BATCH_SIZE) <NEW_LINE> batches... | Converts the table to a pandas DataFrame. It will collect the content of the table to
the client side and so please make sure that the content of the table could fit in memory
before calling this method.
Example:
::
>>> pdf = pd.DataFrame(np.random.rand(1000, 2))
>>> table = table_env.from_pandas(pdf, ["a", "... | 625941b330dc7b7665901729 |
def predict(self, items, k=10): <NEW_LINE> <INDENT> result = dict() <NEW_LINE> if isinstance(items, list): <NEW_LINE> <INDENT> for item in items: <NEW_LINE> <INDENT> if item in self.item_similarity: <NEW_LINE> <INDENT> for i, val in self.item_similarity[item].items(): <NEW_LINE> <INDENT> if i not in items: <NEW_LINE> <... | predict result for a given user
:param user: str, user id
:param items: list, user recent behavior item list
:param k: predict top k result
:return: dict | 625941b3d6c5a10208143e04 |
def test_restore_group_node_group_layer(self): <NEW_LINE> <INDENT> p = QgsProject() <NEW_LINE> layer = QgsVectorLayer("Point?field=fldtxt:string", "layer1", "memory") <NEW_LINE> p.addMapLayer(layer, False) <NEW_LINE> layer2 = QgsVectorLayer("Point?field=fldtxt:string", "layer2", "memory") <NEW_LINE> p.addMapLayer(layer... | Test that group node's QgsGroupLayers are restored with projects | 625941b3091ae35668666d25 |
def _df_structure(self): <NEW_LINE> <INDENT> return pd.DataFrame(0.0, index=self.cosecha.get_index(), columns=( 'saldo_inicial0', 'saldo_inicial30', 'saldo_inicial60', 'saldo_inicial90', 'saldo_inicial120', 'saldo_inicial150', 'saldo_inicial180', 'saldo_inicial210', 'gasto0', 'gasto30', 'gasto60', 'gasto90', 'gasto120'... | Crea la estructura del dataframe de salida
:return pandas dataframe | 625941b3d6c5a10208143e05 |
def create_checkpoint(weights_and_biases, global_step, model_dir, batch_norm_vars=None): <NEW_LINE> <INDENT> weights, biases = zip(*weights_and_biases) <NEW_LINE> if batch_norm_vars: <NEW_LINE> <INDENT> assert len(batch_norm_vars) == len(weights_and_biases) - 1 <NEW_LINE> (bn_betas, bn_gammas, bn_means, bn_variances) =... | Create checkpoint file with provided model weights.
Args:
weights_and_biases: Iterable of tuples of weight and bias values.
global_step: Initial global step to save in checkpoint.
model_dir: Directory into which checkpoint is saved. | 625941b3d18da76e2353228f |
def test_maybeDeferredAsyncError(self): <NEW_LINE> <INDENT> d = defer.Deferred() <NEW_LINE> d2 = defer.maybeDeferred(lambda: d) <NEW_LINE> d.errback(failure.Failure(RuntimeError())) <NEW_LINE> self.assertImmediateFailure(d2, RuntimeError) | L{defer.maybeDeferred} should let L{defer.Deferred} instance pass by
so that L{failure.Failure} returned by the original instance is the
same. | 625941b382261d6c526ab261 |
def end(self): <NEW_LINE> <INDENT> self.intransaction.pop() | End the most recent transaction. | 625941b38a349b6b435e7f39 |
def annotate_image(self, scale=None, fit_size=None): <NEW_LINE> <INDENT> return self.image_annotator.annotate_image(self.raw_image, scale=scale, fit_size=fit_size) | Adds any enabled annotations to the image.
Optionally resizes the image prior to annotations being applied. The
aspect ratio of the resulting image always matches that of the raw image.
Args:
scale (float): If set then the base image will be scaled by the
supplied multiplier. Cannot be combined with fit... | 625941b330c21e258bdfa25c |
def XPLMFindPluginsMenu(): <NEW_LINE> <INDENT> pass | This function returns the ID of the plug-ins menu, which is created for you
at startup. | 625941b373bcbd0ca4b2be3b |
def setJobDescription(self, value): <NEW_LINE> <INDENT> self._jsc.setJobDescription(value) | Set a human readable description of the current job.
.. note:: Currently, setting a job description (set to local properties) with multiple
threads does not properly work. Internally threads on PVM and JVM are not synced,
and JVM thread can be reused for multiple threads on PVM, which fails to isolate
loca... | 625941b33617ad0b5ed67cbd |
def get_user_details(self, response): <NEW_LINE> <INDENT> return response | Return user details from MIPT account. | 625941b3ff9c53063f47bfbd |
def opp_ready(c): <NEW_LINE> <INDENT> if not is_timed(c[1]): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return _opponent_waiting(cuid, c[0]) | Returns True if this is a timed challenge and the opponent is ready to play | 625941b3925a0f43d2549c31 |
def saveM(request): <NEW_LINE> <INDENT> username = request.POST.get("username") <NEW_LINE> title = request.POST.get("title") <NEW_LINE> content = request.POST.get("content") <NEW_LINE> publish = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") <NEW_LINE> messageB = Messages(title=title, content=content, username=u... | 用户创建留言后,保存留言
返回保存留言后的用户页面 | 625941b3498bea3a759b9871 |
@function_wrapper(output={'parameters': dict, 'topology': str, 'coordinates': str, 'simulation_state': str}) <NEW_LINE> def read_tpr(filename: str = '', output=None): <NEW_LINE> <INDENT> sim_input = fileio.read_tpr(filename) <NEW_LINE> output._internal = sim_input <NEW_LINE> output.parameters = sim_input.parameters.ext... | Get simulation input sources from a TPR file.
Outputs:
parameters : MDP simulation parameters
coordinates : atom (or CG particle) coordinates (not yet implemented)
simulation_state : simulation internal state (checkpoint data) (not yet implemented)
topology : molecular force field data (not yet impleme... | 625941b3460517430c393f4f |
def duration_outside_nwh(self, starttime=datetime.time(NORMAL_DAY_START_H), endtime=datetime.time(NORMAL_DAY_END_H)): <NEW_LINE> <INDENT> total = datetime.timedelta() <NEW_LINE> for interval in self.intervals: <NEW_LINE> <INDENT> total += interval.duration_outside_nwh(starttime, endtime) <NEW_LINE> <DEDENT> return tota... | Returns the total duration outside normal working hours, i.e.
evenings/nights, weekends (and Bank Holidays). | 625941b3099cdd3c635f0a1b |
def sum_before_first_even(xs): <NEW_LINE> <INDENT> sum = 0 <NEW_LINE> for x in xs: <NEW_LINE> <INDENT> if x % 2 != 0: <NEW_LINE> <INDENT> sum = sum + x <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> <DEDENT> return sum | Returns sum of all elements in a list up to but not including the first even number
| 625941b3d58c6744b4257a1f |
def get_key(self, timestamp=None): <NEW_LINE> <INDENT> return self.api.get('key', timestamp)["permissions"] | Gets the permissions associated with the given API key | 625941b3627d3e7fe0d68c0c |
def create_tensor(self, name=None, persistable=None, dtype=None): <NEW_LINE> <INDENT> if name is not None: <NEW_LINE> <INDENT> var_name = ".".join([self._full_name, name]) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> var_name = unique_name.generate(".".join( [self._full_name, "_generated_var"])) <NEW_LINE> <DEDENT> re... | Create Tensor for this layer.
Parameters:
name(str, optional): name of the tensor. Please refer to :ref:`api_guide_Name` . Default: None
persistable(bool, optional): if set this tensor persistable. Default: False
dtype(str, optional): data type of this parameter.
If set str, it can be "bool", "flo... | 625941b301c39578d7e74c03 |
def _expand_index(self, num): <NEW_LINE> <INDENT> if self.ndim == 3: <NEW_LINE> <INDENT> num_z = self._shape[2] - self._size[2] + 1 <NEW_LINE> num_y = self._shape[1] - self._size[1] + 1 <NEW_LINE> k = self.stride[2] * num % num_z <NEW_LINE> j = self.stride[1] * (self.stride[2] * num // num_z) % num_y <NEW_LINE> i = sel... | Should expand 1D index into 3D index (x, y, z) | 625941b3a4f1c619b28afe05 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.