code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def __init__(self): <NEW_LINE> <INDENT> super(EventsListWidget, self).__init__() <NEW_LINE> self.mainLayout = QtGui.QVBoxLayout() <NEW_LINE> self.listLayout = QtGui.QHBoxLayout() <NEW_LINE> self.btnsLayout = QtGui.QVBoxLayout() <NEW_LINE> self.titleLabel = QtGui.QLabel(u"Eventos", self) <NEW_LINE> self.titleLabel.setFo... | Setup widgets and select client data from the
database. | 625941dc5f7d997b87174d95 |
def add_gate_monitor(self, node_uid, gate, sheaf=None, name=None, color=None): <NEW_LINE> <INDENT> mon = monitor.NodeMonitor(self, node_uid, 'gate', gate, sheaf=sheaf, name=name, color=color) <NEW_LINE> self._monitors[mon.uid] = mon <NEW_LINE> return mon.uid | Adds a continuous monitor to the activation of a gate. The monitor will collect the activation
value in every calculation step.
Returns the uid of the new monitor. | 625941dcc4546d3d9de72d30 |
def transform_homogeneous(matrices, vertices): <NEW_LINE> <INDENT> if len(matrices.shape) != 3: <NEW_LINE> <INDENT> raise ValueError( 'matrices must have 3 dimensions (missing batch dimension?)') <NEW_LINE> <DEDENT> if len(vertices.shape) != 3: <NEW_LINE> <INDENT> raise ValueError( 'vertices must have 3 dimensions (mis... | Applies batched 4x4 homogenous matrix transformations to 3-D vertices.
The vertices are input and output as as row-major, but are interpreted as
column vectors multiplied on the right-hand side of the matrices. More
explicitly, this function computes (MV^T)^T.
Vertices are assumed to be xyz, and are extended to xyzw w... | 625941dc29b78933be1e59a2 |
def test_commandline(self): <NEW_LINE> <INDENT> output = execute(["--url", "https://example.net/", "list-projects"]) <NEW_LINE> self.assertIn("Hello", output) | Configuration using command-line. | 625941dc30dc7b7665901c5e |
def get_size(self): <NEW_LINE> <INDENT> pass | Returns the 'size' of the ad. Every ad should extend this function to return the size of the ad.
This function is used by Placements | 625941dc3eb6a72ae02ec7de |
def __init__(self, root, key, timestamp, desc=None, host=None, user=None): <NEW_LINE> <INDENT> super(PlistEvent, self).__init__( timestamp, eventdata.EventTimestamp.WRITTEN_TIME) <NEW_LINE> self.root = root <NEW_LINE> self.key = key <NEW_LINE> if desc: <NEW_LINE> <INDENT> self.desc = desc <NEW_LINE> <DEDENT> if host: <... | Template for creating a Plist EventObject for returning data to Plaso.
All events extracted from files get passed around Plaso internally as an
EventObject. PlistEvent is an EventObject with attributes specifically
relevant to data extracted from a Plist file. The attribute DATA_TYPE
'plist:key' allows the formatter u... | 625941dc435de62698dfdf47 |
def TimeCheck(): <NEW_LINE> <INDENT> return time.localtime() | Returns current time in a time.localtime() struct | 625941dcd164cc6175783049 |
def remove(self): <NEW_LINE> <INDENT> if self.status not in (PKFeature._STATUS_TO_BE_REMOVED, PKFeature._STATUS_REMOVED): <NEW_LINE> <INDENT> self.status = PKFeature._STATUS_TO_BE_REMOVED | Elimina la feature. Puede lanzar excepciones. | 625941dc50812a4eaa59c619 |
def CashbackTracker_alert(now_info_list, last_info_list): <NEW_LINE> <INDENT> alert_by_print(now_info_list, last_info_list) | alert cashback for given new & old StoreInfo objects
| 625941dc4f6381625f114d36 |
def run_tests(): <NEW_LINE> <INDENT> test_gmaps() <NEW_LINE> test_tsp() <NEW_LINE> test_tsp_with_data() | Runs all tests | 625941dc8c0ade5d55d3ecb7 |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ApiGetExtraChannelResponse): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941dc498bea3a759b9da9 |
def cartesian_to_spherical(vector): <NEW_LINE> <INDENT> r = np.linalg.norm(vector) <NEW_LINE> x, y, z = np.ravel(vector) <NEW_LINE> theta = np.arctan2(z, np.linalg.norm((x, y))) <NEW_LINE> phi = np.arctan2(y, x) <NEW_LINE> return np.array((r, theta, phi)) | Transforms given Cartesian coordinates vector to Spherical coordinates.
Parameters
----------
vector : array_like
Cartesian coordinates vector (x, y, z) to transform.
Returns
-------
ndarray
Spherical coordinates vector (r, theta, phi).
See Also
--------
spherical_to_cartesian, cartesian_to_cylindrical, cyli... | 625941dc56b00c62f0f14955 |
def set_Region(self, value): <NEW_LINE> <INDENT> super(GetRegionOperationInputSet, self)._set_input('Region', value) | Set the value of the Region input for this Choreo. ((required, string) The name of the region associated with the request.) | 625941dcdc8b845886cb5831 |
def strip_full_file_path(file_path, project_name): <NEW_LINE> <INDENT> split = file_path.split(os.sep) <NEW_LINE> try: <NEW_LINE> <INDENT> index = split.index(project_name) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise ValueError("Project %s not in file_path" % project_name) <NEW_LINE> <DEDENT> retur... | Splits a full file path which is an absolute path, to a relative path where
the project_name is the root of the path
:file_path: The path of the file to split
:project_name: The project name | 625941dc3539df3088e2e645 |
def predict(self,sample_data): <NEW_LINE> <INDENT> return self.ann.forward(sample_data) | 根据样本数据,计算神经网络输出
:param sample_data:
:return: | 625941dcaad79263cf390d40 |
def callback(self, menuitems, menu, terminal): <NEW_LINE> <INDENT> if not self.watches.has_key(terminal): <NEW_LINE> <INDENT> item = gtk.MenuItem(_('Watch for activity')) <NEW_LINE> item.connect("activate", self.watch, terminal) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> item = gtk.MenuItem(_('Stop watching for acti... | Add our menu items to the menu | 625941dc8c3a8732951586b8 |
def compile_prob(self, x=None, **kwargs): <NEW_LINE> <INDENT> if x is None: <NEW_LINE> <INDENT> x = self.x_dev <NEW_LINE> <DEDENT> self.probability = theano.function( inputs=[x], outputs=self.P, on_unused_input='ignore', ) <NEW_LINE> return self.probability | Compile the probability (logistic) function.
[inputs] (x=None, **kwargs)
x: (optional) Theano tensor for the weights.
[returns] probability
probability: compiled function. | 625941dc6aa9bd52df0370a0 |
def _optimize(self, num_iter, lr, verbose=False): <NEW_LINE> <INDENT> costs = [] <NEW_LINE> for i in range(num_iter): <NEW_LINE> <INDENT> grads, cost = self._propagate() <NEW_LINE> costs.append(cost) <NEW_LINE> dw = grads['dw'] <NEW_LINE> db = grads['db'] <NEW_LINE> self.w = self.w - lr * dw <NEW_LINE> self.b = self.b ... | Optimize w and b by gradient descent. | 625941dc442bda511e8be70f |
def get_signatures_and_packets(self): <NEW_LINE> <INDENT> return [[packet.signature.signature, packet.packet.SerializeToString(), packet.packet.from_key.key] for packet in self.packets.packet] | gets signatures and packets | 625941dcd99f1b3c44c67885 |
def remove_watcher(name, watcher): <NEW_LINE> <INDENT> url = "/{}/watcher/{}".format(name, watcher) <NEW_LINE> proxy_request(name, "DELETE", url) <NEW_LINE> msg = "watcher {} successfully removed!\n".format(watcher) <NEW_LINE> sys.stdout.write(msg) | remove-watcher removes the specified watcher from the given monitoring
instance. Usage:
remove-watcher <instance-name> <email>
Example:
tsuru {plugin_name} remove-watcher mysite mysite+monit@mycompany.com | 625941dc23849d37ff7b3388 |
def setup_test_user(self): <NEW_LINE> <INDENT> self.setup_test_tenant() <NEW_LINE> self._create_test_user(tenant_id=self.tenant['id']) | Set up a test user. | 625941dc8c0ade5d55d3ecb8 |
def safe_sql_identifier(string, validation_re=mysql_allowed): <NEW_LINE> <INDENT> return "".join(validation_re.findall(string)) | Return injection-free MySQL identifier | 625941dc1f037a2d8b9464f8 |
def run(self, plugin=None, plugin_args=None, updatehash=False): <NEW_LINE> <INDENT> if plugin is None: <NEW_LINE> <INDENT> plugin = config.get('execution', 'plugin') <NEW_LINE> <DEDENT> if not isinstance(plugin, (str, bytes)): <NEW_LINE> <INDENT> runner = plugin <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = '.'.... | Execute the workflow
Parameters
----------
plugin: plugin name or object
Plugin to use for execution. You can create your own plugins for
execution.
plugin_args : dictionary containing arguments to be sent to plugin
constructor. see individual plugin doc strings for details. | 625941dc16aa5153ce362772 |
def make_post(self, podcast): <NEW_LINE> <INDENT> meta = podcast.metadata <NEW_LINE> mp3 = self.file(podcast, "VBR MP3") <NEW_LINE> if not mp3: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> title = meta.get('title') <NEW_LINE> date = parser.parse( meta.get('date') or meta.get('publicdate') ).strftime("%d %b %Y") ... | Convert an Audio object into a post compatible with
the PodcastPublisher. | 625941dc435de62698dfdf48 |
def _fire_and_reset(self): <NEW_LINE> <INDENT> self._fire() <NEW_LINE> self._reset() | Invokes `_fire()` and `_reset()`. | 625941dce64d504609d74b3a |
def get_element_full(self, type_, id_): <NEW_LINE> <INDENT> if type_ not in ("way", "relation"): <NEW_LINE> <INDENT> raise ValueError("Type must be from {}.".format(", ".join(("way", "relation")))) <NEW_LINE> <DEDENT> path = "{}/{}/full".format(type_, id_) <NEW_LINE> return wrappers["osm"].from_xml(self.get(path)) | Download way/relation by id and all elements that references.
Return OSM wrapper.
Arguments:
type_ --- Element type (way/relation).
id_ --- Element id. | 625941dc24f1403a92600e5e |
def __init__(self, crystal_list): <NEW_LINE> <INDENT> self.crystal_list = crystal_list | Polycrystal constructor
Simply reads in the list of crystals.
Args:
crystal_list: a list of the kalidindi1992.Crystal instances
that comprise the polycrystal | 625941dc5510c4643540f6d8 |
def normal_basis(self, basis, base_point=None): <NEW_LINE> <INDENT> norms = self.squared_norm(basis, base_point) <NEW_LINE> return gs.einsum("i, ikl->ikl", 1.0 / gs.sqrt(norms), basis) | Normalize the basis with respect to the metric.
This corresponds to a renormalization of each basis vector.
Parameters
----------
basis : array-like, shape=[dim, dim]
Matrix of a metric.
base_point
Returns
-------
basis : array-like, shape=[dim, n, n]
Normal basis. | 625941dcd7e4931a7ee9e219 |
def cancel(self, obj): <NEW_LINE> <INDENT> return self._remove(obj, dict(remove='false')) | Cancels a remote Subscription representation with that obj.id
:param Subscription obj: the Subscription object with an id set
:return Subscription: the removed Subscription object | 625941dcfbf16365ca6f64c3 |
def minimum(*args, **kwargs): <NEW_LINE> <INDENT> return _cmf_core.minimum(*args, **kwargs) | minimum(real a, real b) -> real | 625941dce76e3b2f99f3ab02 |
def _make_paths(self): <NEW_LINE> <INDENT> self._folder_base = os.path.abspath(os.path.join( os.sep, 'HFIR', self._beamline, 'IPTS-{:04}'.format(self._ipts_number), 'exp{}'.format(self._exp_number), )) <NEW_LINE> self._folder_shared = os.path.join(self._folder_base, "Shared") <NEW_LINE> self._folder_datafiles = os.path... | Make:
folder_base
folder_shared
folder_datafiles | 625941dc379a373c97cfae41 |
def __init__(self, db, **kwargs): <NEW_LINE> <INDENT> super(Follow_up, self).__init__(db, **kwargs) | * _db : ref. to database. usage: self.db.table(fqtn)
fields list:
* cog_oid_ : c_oid, PK, not null
* cog_fqtn_ : c_fqtn, not null
* cog_signature_ : text, inherited
* cog_test_ : bool, inherited
* cog_creat_date_ : timestamp, inherited
* cog_modif_date_ : timestamp, inherited
* cog_environment_ : c_oid, inherited
* cog... | 625941dccad5886f8bd272d4 |
def main(): <NEW_LINE> <INDENT> test_something() | Calls the desired TEST functions. | 625941dc0fa83653e46572b4 |
def _cursorline(self): <NEW_LINE> <INDENT> if self.cursorline_id is not None: <NEW_LINE> <INDENT> self._match_clear() <NEW_LINE> self.cursorline_id = None <NEW_LINE> <DEDENT> if self.empty() and self.is_middle: <NEW_LINE> <INDENT> self.cursorline_id = vimeval( "matchaddpos('vlf_hl_cursorline_%d', [%s], 100, -1, #{windo... | highlight curcorline | 625941dcd58c6744b4257f59 |
def test_get_atlas_version(): <NEW_LINE> <INDENT> cache = get_cached_atlas_version() <NEW_LINE> libs = [ 'lib' ] <NEW_LINE> dirs = [ 'dir' ] <NEW_LINE> attr = { 'libraries': libs, 'library_dirs': dirs } <NEW_LINE> cache_key = (tuple(libs), tuple(dirs)) <NEW_LINE> cache[cache_key] = True <NEW_LINE> assert get_atlas_vers... | Ensure that a cached entry is returned from get_atlas_version
if _cached_atlas_version contains the key created in get_atlas_version. | 625941dcac7a0e7691ed43c2 |
def get_untried_moves(self, legalMoves): <NEW_LINE> <INDENT> triedMoves = [child.move for child in self.childNodes] <NEW_LINE> return [move for move in legalMoves if move not in triedMoves] | Return the elements of legalMoves for which this node does not have children.
length of legalMoves always be less that or equal to 2 | 625941dc44b2445a3393238f |
def _has_numstats(self, jcol, cgcols, cvals, threshold): <NEW_LINE> <INDENT> values = [jcol, "ntotal", cgcols, cvals] <NEW_LINE> if threshold is None: <NEW_LINE> <INDENT> threshold = "threshold IS NULL" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> values.append(threshold) <NEW_LINE> threshold = "threshold = %s" <NEW_L... | Checks whether statistics have been recorded for a given set of columns.
It just checks whether the "ntotal" stat has been added.
INPUT:
- ``jcol`` -- a list containing the column name whose min/max/avg were computed (wrapped in Json)
- ``cgcols`` -- the sorted constraint columns, followed by the sorted grouping colu... | 625941dc5fdd1c0f98dc052f |
def test_get_months_from_dates(): <NEW_LINE> <INDENT> result = wf.utils.get_months_from_dates('2020-04-23', '2020-05-11') <NEW_LINE> expected_result = { 'April': '2020-04-01', 'May': '2020-05-01', } <NEW_LINE> assert expected_result == result | Tests get_months_from_dates() funciton. | 625941dcd53ae8145f87a566 |
def dragonDanger(xcoord,ycoord): <NEW_LINE> <INDENT> with open("/web/s1676540/webmappwd", 'r') as pwf: <NEW_LINE> <INDENT> pwd = pwf.read().strip() <NEW_LINE> <DEDENT> conn = cx_Oracle.connect(dsn="geosgen", user ="s1676540", password=pwd) <NEW_LINE> c = conn.cursor() <NEW_LINE> query = "SELECT A.REGION_ID, A.NAME, B.N... | get all of the information about a field and make it into a dictionary | 625941dc0a366e3fb873eb17 |
def __init__(self, building_id, sub_type, sys_func_flag, ttl_path, sub_index=None): <NEW_LINE> <INDENT> self.building_id = building_id <NEW_LINE> self.ttl_path = ttl_path <NEW_LINE> self.sys_func_flag = sys_func_flag <NEW_LINE> if isinstance(sub_type, str): <NEW_LINE> <INDENT> self.sub_type_list = [sub_type.upper()] <N... | :parameter sub_type: e.g. 'VAV'
:parameter sys_func_flag:
:parameter sub_index: subsystem's sub_index ,can assign value directly | 625941dc38b623060ff0b0e8 |
def get_train_examples(self, data_dir): <NEW_LINE> <INDENT> lines = self._read_tsv( os.path.join(data_dir, "multinli", "multinli.train.%s.tsv" % self.language)) <NEW_LINE> examples = [] <NEW_LINE> for (i, line) in enumerate(lines): <NEW_LINE> <INDENT> if i == 0: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> guid = "... | See base class. | 625941dc6fb2d068a760f39c |
def is_fitted(self): <NEW_LINE> <INDENT> return self.token_to_idx is not None | Checks if ColumnEncoder (still) needs to be fitted to data
:return: True if the column encoder does not require fitting (anymore or at all) | 625941dc7b180e01f3dc4af3 |
def is_next_run(self, time): <NEW_LINE> <INDENT> return time <= self.stop_time | Check if this is the next run after the provided time. | 625941dc046cf37aa974d040 |
def test_create_name_in_db_right_slash(self): <NEW_LINE> <INDENT> with patch_settings({'path': 'gallery/'}): <NEW_LINE> <INDENT> name = utils.name_in_db('foo.jpg') <NEW_LINE> <DEDENT> self.assertEqual(name, 'gallery/foo.jpg') | Checks whether the name_in_db function returns a correct
name as it is in the database (path + filename) of the
'path' setting contains an ending slash | 625941dc16aa5153ce362773 |
def fit(self, data, labels): <NEW_LINE> <INDENT> self.X = data <NEW_LINE> self.y = labels | Fits the model using train data and labels | 625941dc3317a56b86939f4d |
def get_conditional_order(self, stop_order_id=None, order_link_id=None, symbol=None, order=None, page=None, limit=None, api_url="/open-api/stop-order/list"): <NEW_LINE> <INDENT> params_dict = {"stop_order_id": stop_order_id, "order_link_id": order_link_id, "symbol": symbol, "order": order, "page": page, "limit": limit}... | Gets a conditional order list.
Link: https://bybit-exchange.github.io/docs/inverse/#t-getcond
:param stop_order_id: Order ID of conditional order
:type stop_order_id: string
:param order_link_id: Customized order ID
:type order_link_id: string
:param symbol: Contract type. Default BTCUSD
:type symbol: string
:param ... | 625941dc6fece00bbac2da3d |
def do_exit(self, argv): <NEW_LINE> <INDENT> self.TCSsocket.close() <NEW_LINE> if self.TRS: TRS.close() <NEW_LINE> raise SystemExit | Close the program. | 625941dc9c8ee82313fbba71 |
@api_view(['GET']) <NEW_LINE> @authentication_classes((TokenAuthentication,)) <NEW_LINE> @schema(RawInfoSchema, ) <NEW_LINE> def list_raw_info_view(request): <NEW_LINE> <INDENT> if request.method == "GET": <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> raw_info = Raw.objects.filter(name=request.GET.get('raw_name')).order... | API endpoint that return raw and quantity by raw name | 625941dc23e79379d52ee85c |
def setup_colors(self): <NEW_LINE> <INDENT> postfix = "" if v.opt("bg") == "light" else "_darkbg" <NEW_LINE> colors = { "SurferShade": settings.get("shade_color{}".format(postfix)), "SurferMatches": settings.get("matches_color{}".format(postfix)), "SurferPrompt": settings.get("prompt_color{}".format(postfix)), "SurferE... | To setup Surfer highlight groups. | 625941dc8e7ae83300e4b2c9 |
def _get_special_fields(self, cr, uid, context=None): <NEW_LINE> <INDENT> return [ {'price_unit_tax_excluded': 'shipping_amount_tax_excluded', 'price_unit_tax_included': 'shipping_amount_tax_included', 'tax_rate_field': 'shipping_tax_rate', 'product_ref': ('connector_ecommerce', 'product_product_shipping'), }, {'tax_ra... | Deprecated! Replaced by LineBuilder classes | 625941dc7d847024c06be5ba |
def lstm_forward(x, h0, Wx, Wh, b): <NEW_LINE> <INDENT> h, cache = None, None <NEW_LINE> h = [h0] <NEW_LINE> cell_state = 0.0 <NEW_LINE> cache = [] <NEW_LINE> _,T,_ = x.shape <NEW_LINE> for t in range(T): <NEW_LINE> <INDENT> next_h, cell_state, next_cache = lstm_step_forward(x[:,t,:], h[-1], cell_state, Wx, Wh, b) <NEW... | Forward pass for an LSTM over an entire sequence of data. We assume an input
sequence composed of T vectors, each of dimension D. The LSTM uses a hidden
size of H, and we work over a minibatch containing N sequences. After running
the LSTM forward, we return the hidden states for all timesteps.
Note that the initial h... | 625941dcb5575c28eb68e2fe |
def test_create_ingredients_successfull(self): <NEW_LINE> <INDENT> payload = {'name': 'Cabbage'} <NEW_LINE> self.client.post(INGREDIENT_URL, payload) <NEW_LINE> exists = Ingredient.objects.filter( user=self.user, name=payload['name'], ).exists() <NEW_LINE> self.assertTrue(exists) | Test create a new ingredient | 625941dc0383005118ecf8dd |
def diagnostics(self): <NEW_LINE> <INDENT> super(SpectralClustering, self).diagnostics() <NEW_LINE> self.scree_plot(self.evals) <NEW_LINE> self.plot_evecs(self.evecs, labels=self.fittedvalues.columns) <NEW_LINE> scikit_mixin.plot_clusters(data=self.fittedvalues, cluster_labels=self.labels, cluster_centers=self.centers) | Diagnostics for SpectralClustering.
Generates a scree plot of evals and plot for evecs. | 625941dccc0a2c11143dd18c |
def wait_for(self, css_selector, children=True, timeout=10): <NEW_LINE> <INDENT> if self.wait_for_count >= timeout: <NEW_LINE> <INDENT> raise NoSuchElementException('timeout reached') <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> self.driver.find_element_by_css_selector(css_selector) <NEW_LINE> if children: <NEW_LINE> <... | Wait for page to load
Args:
- css_selector
- children: if True, wait for children to exist | 625941dc7047854f462a1702 |
def run(self, target_db_name, souce_db_name, source_group_name, target_group_name, timestamp, vdb_type, cloudshell_api, reservation_id): <NEW_LINE> <INDENT> client = self.get_delphix_client() <NEW_LINE> source_database = client.get_database(souce_db_name, source_group_name) <NEW_LINE> target_group = client.get_group(ta... | Provision vDB in the target group from the given source DDB
:param target_db_name:
:param souce_db_name:
:param source_group_name:
:param target_group_name:
:param timestamp:
:param vdb_type:
:param cloudshell_api:
:return: | 625941dc5fcc89381b1e19bd |
def dropEvent(self, event): <NEW_LINE> <INDENT> super().dropEvent(event) <NEW_LINE> if event.mimeData().hasUrls(): <NEW_LINE> <INDENT> for url in event.mimeData().urls(): <NEW_LINE> <INDENT> local_file = url.toLocalFile() <NEW_LINE> if os.path.isfile(local_file): <NEW_LINE> <INDENT> self.open_trace(local_file) | QMainWindow method reimplementation for file drop. | 625941dc0a50d4780f667190 |
def generateParenthesis(self, n): <NEW_LINE> <INDENT> def generate(p, left, right): <NEW_LINE> <INDENT> if left: <NEW_LINE> <INDENT> generate(p + '(', left-1, right) <NEW_LINE> <DEDENT> if right > left: <NEW_LINE> <INDENT> generate(p + ')', left, right-1) <NEW_LINE> <DEDENT> if not right: <NEW_LINE> <INDENT> parens.app... | :type n: int
:rtype: List[str] | 625941dcadb09d7d5db6ca89 |
def find_native_contacts(native_file): <NEW_LINE> <INDENT> native_coords, resis=read_PDB(native_file, atom='CA') <NEW_LINE> native_contacts=compute_contacts_matrix(native_coords) <NEW_LINE> return native_coords, resis, native_contacts | finds all native contacts from native PDB file | 625941dc236d856c2ad44ad9 |
def get_all_vpn_gateways(self, vpn_gateway_ids=None, filters=None): <NEW_LINE> <INDENT> params = {} <NEW_LINE> if vpn_gateway_ids: <NEW_LINE> <INDENT> self.build_list_params(params, vpn_gateway_ids, 'VpnGatewayId') <NEW_LINE> <DEDENT> if filters: <NEW_LINE> <INDENT> i = 1 <NEW_LINE> for filter in filters: <NEW_LINE> <I... | Retrieve information about your VpnGateways. You can filter results to
return information only about those VpnGateways that match your search
parameters. Otherwise, all VpnGateways associated with your account
are returned.
:type vpn_gateway_ids: list
:param vpn_gateway_ids: A list of strings with the desired VpnGat... | 625941dc50485f2cf553d097 |
def fit_coordinates(places, sort_coords): <NEW_LINE> <INDENT> possible_fit = defaultdict(lambda: []) <NEW_LINE> print(places) <NEW_LINE> for place in places: <NEW_LINE> <INDENT> for k, v in sort_coords.items(): <NEW_LINE> <INDENT> if len(v) == len(place): <NEW_LINE> <INDENT> possible_fit[place].append(v) <NEW_LINE> <DE... | args: places - the list of places to fit into the puzzle
sort_coords - list of possible fit to that place based on length
return: a dictionary of list of possible coordinates based on place | 625941dc3346ee7daa2b3069 |
def Date(val): <NEW_LINE> <INDENT> LOG.debug("got date = %r", val) <NEW_LINE> if isinstance(val, datetime.date): <NEW_LINE> <INDENT> return val <NEW_LINE> <DEDENT> if val in ['now', 'today']: <NEW_LINE> <INDENT> date = datetime.date.today() <NEW_LINE> <DEDENT> elif isinstance(val, str): <NEW_LINE> <INDENT> date = datet... | transform date on the command line into a datetime.date object
the values 'now' and 'today' both evaluate to the current day
(datetime.date.today()). | 625941dcbe7bc26dc91cd8f6 |
def test_random_permute_inverse_changes_group(self): <NEW_LINE> <INDENT> np.random.seed(232) <NEW_LINE> nchan = 3 <NEW_LINE> nsteps = 20 <NEW_LINE> rho = 1.0/4 <NEW_LINE> target = np.random.randn(nchan, nsteps) <NEW_LINE> controller = LinearController(self.G, target, tau=None) <NEW_LINE> controller.set_random_permute_i... | Test random permutation moves affected neurons to different groups. | 625941dcb57a9660fec33b84 |
def _new_tests(self, verbosity=1, interactive=False, extra_tests=None, failfast=False, **kwargs): <NEW_LINE> <INDENT> settings.configure( DEBUG=True, DATABASES={ 'default': { 'ENGINE': 'django.db.backends.sqlite3', } }, INSTALLED_APPS=self.INSTALLED_APPS + self.apps, ROOT_URLCONF=__name__, ) <NEW_LINE> self._setup_urlp... | Fire up the Django test suite developed for version 1.2 | 625941dcd53ae8145f87a567 |
def get_multiband_image_mask(data, threshold=0): <NEW_LINE> <INDENT> if len(data.shape) != 3: <NEW_LINE> <INDENT> raise ValueError('Invalid data dimension, data should be 3 dimensional.') <NEW_LINE> <DEDENT> min_data = numpy.min(data, axis=0) <NEW_LINE> return get_image_mask(min_data, threshold) | This method takes as input a multiband image, it flattens the image by applying
a minimum over the first axis, obtaining a 2x2 matrix. Then the process of
creating a mask is applied to this new matrix. | 625941dc5fdd1c0f98dc0530 |
def fill_polygon(polygon, canvas, color=1): <NEW_LINE> <INDENT> if not len(polygon): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> min_y = min(y for y,x in polygon) <NEW_LINE> max_y = max(y for y,x in polygon) <NEW_LINE> polygon = [(float(y),float(x)) for y,x in polygon] <NEW_LINE> if max_y < canvas.shape[0]: <NEW_LIN... | fill_polygon([(y0,x0), (y1,x1),...], canvas, color=1)
Draw a filled polygon in canvas
Parameters
----------
polygon : list of pairs
a list of (y,x) points
canvas : ndarray
where to draw, will be modified in place
color : integer, optional
which colour to use (default: 1) | 625941dc8e05c05ec3eea672 |
def Grundkoerper_sets(modell, name): <NEW_LINE> <INDENT> import part <NEW_LINE> partGrundkoerper = modell.parts[name]; <NEW_LINE> partGrundkoerper.Set(cells=partGrundkoerper.cells, name='setAll'); <NEW_LINE> rpname = 'RP_' + name; <NEW_LINE> if (partGrundkoerper.features.has_key(rpname)): <NEW_LINE> <INDENT> rpid = par... | Erstelle die Hauptsets fuer das Bauteil (Part) name im modell.
| 625941dcd7e4931a7ee9e21a |
def __init__(self, cacheconfig): <NEW_LINE> <INDENT> self._caches = [] <NEW_LINE> for cache in cacheconfig: <NEW_LINE> <INDENT> if cache["BACKEND"] == "varnish": <NEW_LINE> <INDENT> self._caches.append(VarnishCache(cache["LOCATION"])) <NEW_LINE> <DEDENT> <DEDENT> if not self._caches: <NEW_LINE> <INDENT> warnings.warn("... | Initialise a cache.
cacheconfig is a list of dictionaries e.g.:
[
{'BACKEND': 'varnish', 'LOCATION': 'http://localhost:6081'},
] | 625941dc507cdc57c6306fdd |
def __init__(self, config_data=None, config_string=None): <NEW_LINE> <INDENT> self.config_data = config_data if config_data else None <NEW_LINE> self.config_string = config_string if config_string else None | a HAHQConfigurator can be initialized either with a dict describing the config, or a string formatted like the
config file.
:param config_data: dict with config data
:param config_string: string in config file format | 625941dc956e5f7376d71168 |
def plotSummaryMat(toplot, BatchName, mainPath = 'C:/DataSets/Results/Fraust'): <NEW_LINE> <INDENT> os.chdir(mainPath + '/' + BatchName) <NEW_LINE> out = [] <NEW_LINE> if toplot.find('e') != -1: <NEW_LINE> <INDENT> eqq_mat = np.fromfile('e_qq_mat.dat') <NEW_LINE> eqq_mat = eqq_mat.reshape(10000,10) <NEW_LINE> figure() ... | Plots the e_qq/f_qq and or g_qq of Batch in Batch Name | 625941dcd4950a0f3b08c647 |
def test_run_cwd(self): <NEW_LINE> <INDENT> pants_run = self.run_pants(['goal', 'run', 'testprojects/src/java/com/pants/testproject/cwdexample', '--interpreter=CPython>=2.6,<3', '--interpreter=CPython>=3.3']) <NEW_LINE> self.assert_failure(pants_run) <NEW_LINE> self.assertIn('Neither ExampleCwd.java nor readme.txt foun... | Tests the --cwd option that allows the working directory to change when running. | 625941dccc0a2c11143dd18d |
def get_levels(self): <NEW_LINE> <INDENT> levels = [] <NEW_LINE> for group in self.groups.values('name'): <NEW_LINE> <INDENT> group_name = group['name'] <NEW_LINE> if re.match(r'^user level: \d+$', group_name): <NEW_LINE> <INDENT> levels.append(int(re.search(r'\d+', group_name).group())) <NEW_LINE> <DEDENT> <DEDENT> re... | A getter for the user's permission levels.
The user groups are named "user level: #".
Returns:
list: An ordered list of the user's levels. | 625941dc293b9510aa2c358e |
def remove_redundant_suggestions(datapath): <NEW_LINE> <INDENT> c = 0 <NEW_LINE> for root, dirs, files in os.walk(datapath): <NEW_LINE> <INDENT> for filename in files: <NEW_LINE> <INDENT> if filename[-3:]!= 'ann': <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> f = open(os.path.join(root,filen... | DESCRIPTION:
Parameters
----------
datapath : str
path to folder where Brat files are.
Returns
-------
c : int
Number of removed suggestions. | 625941dcd268445f265b516a |
def pickle(self, path): <NEW_LINE> <INDENT> with open(path, 'w') as f: <NEW_LINE> <INDENT> pk.dump(self, f) | Saves the current Map as a pickled file
Args: path - the file path and name to save | 625941dc6fb2d068a760f39d |
def get_data_mt_loaders(imsize=128, batch_size=16, num_folds=5, fold=0, unlabeled_ratio=0.5): <NEW_LINE> <INDENT> img_ids = [os.path.basename(x) for x in glob.glob('../data/train/images/*.png')] <NEW_LINE> kf = KFold(n_splits=num_folds, shuffle=True) <NEW_LINE> img_idx = list(range(len(img_ids))) <NEW_LINE> splits = li... | sets up the torch data loaders for training | 625941dc5fc7496912cc3c7a |
def _update_dict(dictionary, Y, code, verbose=False, return_r2=False, random_state=None, positive=False): <NEW_LINE> <INDENT> n_components = len(code) <NEW_LINE> n_features = Y.shape[0] <NEW_LINE> random_state = check_random_state(random_state) <NEW_LINE> gemm, = linalg.get_blas_funcs(('gemm',), (dictionary, code, Y)) ... | Update the dense dictionary factor in place.
Parameters
----------
dictionary : array of shape (n_features, n_components)
Value of the dictionary at the previous iteration.
Y : array of shape (n_features, n_samples)
Data matrix.
code : array of shape (n_components, n_samples)
Sparse coding of the data ag... | 625941dc7d43ff24873a2f9e |
def test_name_label_starts_with_hyphen(self): <NEW_LINE> <INDENT> expected_errors = { "name": [ "Not a valid domain name." ] } <NEW_LINE> with self.assertRaisesMessage(ValidationError, str(expected_errors)): <NEW_LINE> <INDENT> factory.DomainFactory.create(name="-example.com").full_clean() | Ensure name label cannot start with hyphen. | 625941dc656771135c3ebb6e |
def test_check_isolated_nodes_storage(): <NEW_LINE> <INDENT> model = Model() <NEW_LINE> storage = Storage(model, "storage", inputs=1, outputs=0, initial_volume=0.0) <NEW_LINE> with pytest.raises(ModelStructureError): <NEW_LINE> <INDENT> model.check() <NEW_LINE> <DEDENT> demand = Output(model, "demand") <NEW_LINE> stora... | Test model structure checker with Storage
The Storage node itself doesn't have any connections, but it's child
nodes do need to be connected. | 625941dc462c4b4f79d1d9cc |
def rm_one_way_conv(dialogs_path): <NEW_LINE> <INDENT> print('Removing one way conversations...') <NEW_LINE> if not os.path.exists(os.path.join(dialogs_path + '/.one_way_conv_removed')): <NEW_LINE> <INDENT> files=glob.glob(os.path.join(dialogs_path+'/**/*.tsv')) <NEW_LINE> for tsv in files: <NEW_LINE> <INDENT> persons ... | remove all one way conversation in the tsv that are in dialogs_path
do nothing if it's already done (if .one_way_conv_removed exists) | 625941dc32920d7e50b284ce |
def p_compound_statement(p): <NEW_LINE> <INDENT> if len(p) == 3 : p[0] = Node('compound_statement', [p[1], p[2]]) <NEW_LINE> elif len(p) == 4 : p[0] = Node('compound_statement', [p[1], p[2], p[3]]) <NEW_LINE> else : p[0] = Node('compound_statement', [p[1], p[2], p[3], p[4]]) | compound_statement : '{' '}'
| '{' statement_list '}'
| '{' declaration_list '}'
| '{' declaration_list statement_list '}' | 625941dc63b5f9789fde73e2 |
def discover_credentials(qiskitrc_filename=None): <NEW_LINE> <INDENT> credentials = OrderedDict() <NEW_LINE> readers = OrderedDict([ ('qconfig', (read_credentials_from_qconfig, {})), ('environment variables', (read_credentials_from_environ, {})), ('qiskitrc', (read_credentials_from_qiskitrc, {'filename': qiskitrc_filen... | Automatically discover credentials for IBM Q.
This method looks for credentials in the following locations, in order,
and returning as soon as credentials are found::
1. in the `Qconfig.py` file in the current working directory.
2. in the environment variables.
3. in the `qiskitrc` configuration file
Arg... | 625941dcf548e778e58cd87b |
def _smooth(list_of_numbers, crop_for_season=False): <NEW_LINE> <INDENT> length_of_season = len(list_of_numbers) <NEW_LINE> if crop_for_season: <NEW_LINE> <INDENT> number_of_days_to_crop = (dt.date.today() - dt.date(2019, 9, 1)).days <NEW_LINE> list_of_numbers = list_of_numbers[:number_of_days_to_crop] <NEW_LINE> <DEDE... | Smooths a list of numbers with a sliding hanning window. If list_of_numbers represents the current
season, days after today are cropped away.
:param list_of_numbers:
:param crop_for_season:
:return: | 625941dc3317a56b86939f4e |
def Enable(self,switch=True): <NEW_LINE> <INDENT> if not self.native: <NEW_LINE> <INDENT> wx.PyControl.Enable(self, switch) <NEW_LINE> if switch: <NEW_LINE> <INDENT> events=[ (wx.EVT_LEFT_DOWN, self.OnLeftDown), (wx.EVT_LEFT_DCLICK, self.OnLeftDown), (wx.EVT_LEFT_UP, self.OnLeftUp), (wx.EVT_ENTER_WINDOW, self.... | Enables or disables the button
Enables by default
(maybe change to toggle?) | 625941dc32920d7e50b284cf |
def fi(self, subset): <NEW_LINE> <INDENT> if len(subset) < 2: <NEW_LINE> <INDENT> return [] <NEW_LINE> <DEDENT> path = [] <NEW_LINE> fti = [] <NEW_LINE> for element in subset: <NEW_LINE> <INDENT> path.append(self.getPredecessor(element)) <NEW_LINE> <DEDENT> i = 1 <NEW_LINE> fti = path[0] <NEW_LINE> while i < len(path):... | Entrada: subset => Subconjunto do conjunto A.
Saída: Lista contendo a fronteira inferior de subset
Cada elemento do subconjunto subset
é passado para o método getPredecessor
o qual retorna uma lista com todos os
predecessores de cada elemento do subconjunto.
As listas são guardadas dentro da lista Path,
ao final é fei... | 625941dc377c676e912724a4 |
def get_trial(self, model): <NEW_LINE> <INDENT> result = self.compute_model_size(model) <NEW_LINE> self.trial_size = result[0] <NEW_LINE> self.total_p_bits = result[1] <NEW_LINE> self.total_a_bits = result[2] <NEW_LINE> self.trial_size_dict = result[3] <NEW_LINE> return self.trial_size | Computes size of quantization trial. | 625941dcb830903b967e9c05 |
def getAction(self): <NEW_LINE> <INDENT> assert self.lastobs != None <NEW_LINE> assert self.lastaction == None | 2. stores the action in a temporary variable until reward is given. | 625941dc7cff6e4e81117c82 |
def setupOptions(): <NEW_LINE> <INDENT> define("DB_SID" , default="db/afspy", help="Database name or for sqlite path to DB file") <NEW_LINE> define("DB_TYPE" , default="sqlite", help="Type of DB. [mysql|sqlite]") <NEW_LINE> define("DB_HOST", default="", help="Database host") <NEW_LINE> define("DB_PORT", default="", hel... | Only to be called from AfsConfig | 625941dc50812a4eaa59c61b |
def display_timedelta(minutes): <NEW_LINE> <INDENT> def plural(num): <NEW_LINE> <INDENT> if num != 1: <NEW_LINE> <INDENT> return 's' <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return '' <NEW_LINE> <DEDENT> <DEDENT> if minutes < 0: <NEW_LINE> <INDENT> raise ValueError <NEW_LINE> <DEDENT> days = minutes // 1440 <NEW_L... | Converts timedelta in minutes to human friendly format.
Parameters
----------
minutes: int
Returns
-------
string
The timedelta in 'x days y hours z minutes' format.
Raises
------
ValueError
If the timedelta is negative. | 625941dc4f6381625f114d38 |
def test_cached_get_from_db(self): <NEW_LINE> <INDENT> db_cache_mixin.REDIS_CLIENT.get.return_value = None <NEW_LINE> products.ProductsDetails.get.return_value = self.test_data <NEW_LINE> data = products.ProductsDetails.cached_get(product_id='1234') <NEW_LINE> self.assertEquals(self.test_data, data) <NEW_LINE> db_cache... | Test for cached_get function. | 625941dc15fb5d323cde0e10 |
def design_fancy_filter(fs, lc, hc=None, order=4, ftype=None, flag=False): <NEW_LINE> <INDENT> nyq = fs/2 <NEW_LINE> if ftype is None or 'low': <NEW_LINE> <INDENT> sos = signal.butter(order, lc/nyq, 'lowpass', output = 'sos') <NEW_LINE> <DEDENT> if ftype is 'bandpass': <NEW_LINE> <INDENT> wn = [lc/nyq, hc/nyq] <NEW_LIN... | Design a butterworth filter.
At least 2 arguments needed: filter cutoff, sample rate
Ex:
y = design_fancy_filter(16000, 30)
y = design_fancy_filter(fs=10000, lc=30, hc=300, order=4, ftype=bandpass, flag=True)
return: sos coefficients | 625941dc287bf620b61d3d5e |
def dew_point_temperature(p_w_kpa: float) -> float: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> alpha = log(p_w_kpa) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> raise AssertionError("Bad water vapor pressure! ({} kPa)" .format(p_w_kpa)) <NEW_LINE> <DEDENT> c14 = 6.54 <NEW_LINE> c15 = 14.526 <NEW_LINE> c... | Dew point temperature.
Eqs. (39) and (40) Peppers 1988
2009 ASHRAE Handbook—Fundamentals (SI). | 625941dc6aa9bd52df0370a1 |
def get_network(prod, sid, data: List[SHEFElement]): <NEW_LINE> <INDENT> networks = list(LOCS.get(sid, {}).keys()) <NEW_LINE> if len(networks) == 1: <NEW_LINE> <INDENT> return networks[0] <NEW_LINE> <DEDENT> is_coop = False <NEW_LINE> varnames = [se.varname() for se in data] <NEW_LINE> if prod.afos[:3] == "RR3": <NEW_L... | Figure out which network this belongs to | 625941dc596a897236089dba |
def __init__(self, parent=None): <NEW_LINE> <INDENT> OptionsDialog.__init__(self, title='InVEST Settings', modal=True, parent=parent) <NEW_LINE> self.resize(600, 200) <NEW_LINE> self.global_label = QtWidgets.QLabel( 'Note: these settings affect all InVEST models.') <NEW_LINE> self.global_label.setStyleSheet(inputs.QLAB... | Initialize the SettingsDialog.
Parameters:
parent=None (QWidget or None): The parent of the dialog. None if
no parent.
Returns:
``None`` | 625941dc6aa9bd52df0370a2 |
def create_model(x_train, y_train, x_test, y_test): <NEW_LINE> <INDENT> model = Sequential() <NEW_LINE> model.add(Dense(512, input_shape=(784,))) <NEW_LINE> model.add(Activation('relu')) <NEW_LINE> model.add(Dropout({{uniform(0, 1)}})) <NEW_LINE> model.add(Dense({{choice([256, 512, 1024])}})) <NEW_LINE> model.add(Activ... | Model providing function:
Create Keras model with double curly brackets dropped-in as needed.
Return value has to be a valid python dictionary with two customary keys:
- loss: Specify a numeric evaluation metric to be minimized
- status: Just use STATUS_OK and see hyperopt documentation if not feasible
The las... | 625941dc10dbd63aa1bd2e9f |
def perform_create(self, serializer): <NEW_LINE> <INDENT> serializer.save(user=self.request.user) | Create new object. | 625941dc55399d3f055889b2 |
def cast(*args): <NEW_LINE> <INDENT> return _itkNoiseImageFilterPython.itkNoiseImageFilterIF3IF3_cast(*args) | cast(itkLightObject obj) -> itkNoiseImageFilterIF3IF3 | 625941dca17c0f6771cbe34c |
def _buy_list_scroll(self, up_down): <NEW_LINE> <INDENT> for ind, i in enumerate(self._buy_list): <NEW_LINE> <INDENT> if i[0] == self._buy[0]: <NEW_LINE> <INDENT> if up_down == 4: <NEW_LINE> <INDENT> ind += 1 <NEW_LINE> if ind >= len(self._buy_list): <NEW_LINE> <INDENT> self._buy = self._buy_list[0] <NEW_LINE> <DEDENT>... | It will set the _buy variable to the previous or next item in the _buy_list depending on the input.
todo:Remove the for loop and use an index which is added / subtracted. The self._buy will become obsolete
and parts of the code need to be changed
:param up_down: (integer) button clicked value from pygame.event.bu... | 625941dce8904600ed9f222d |
def ellipsoidal_earth_slant_ranges(azimuth_time, latlon, orbit_interp, start_x, end_x, start_y, end_y): <NEW_LINE> <INDENT> geo_to_cart = np.vectorize(wgs84.geodesic_to_cartesian) <NEW_LINE> x,y = np.meshgrid(np.arange(start_x, end_x), np.arange(start_y, end_y)) <NEW_LINE> lat, lon = latlon(y,x) <NEW_LINE> lines = lat.... | Compute slant ranges assuming no topography
@param azimuth_time: Pandas time series data conatining the time of each azimuth line
@param latlon: Function to compute latitude and longitude for each pixel coordinate
@param orbit_interp: Function to compute satellite positions
@param start_x: Starting x pixel
@param end_... | 625941dc23849d37ff7b338a |
def __init__(self, task, wait_time): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.task = task <NEW_LINE> self.wait_time = wait_time <NEW_LINE> self._running = False | Object constructor
:param task: The task (a function) to execute
:param wait_time: Seconds to wait between two consecutive executions | 625941dc1f037a2d8b9464fa |
def remove(agent, tokens, concept): <NEW_LINE> <INDENT> tokens.append(concept.item[tokens[1]].parent) <NEW_LINE> return remove_from(agent, tokens, concept) | to bring out of some location | 625941dcb5575c28eb68e2ff |
def grep(self, request, response): <NEW_LINE> <INDENT> response_url = response.get_url().uri2url() <NEW_LINE> if response_url in self._urls: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> self._urls.append(response_url) <NEW_LINE> csp_vulns = find_vulns(response) <NEW_LINE> if len(csp_vulns) > 0: <NEW_LINE> <INDENT> vu... | Perform search on current HTTP request/response exchange.
Store information about vulns for further global processing.
@param request: HTTP request
@param response: HTTP response | 625941dcff9c53063f47c4ef |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.