code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def get_column_name(self, column): <NEW_LINE> <INDENT> return get_property_name(column.names[self.nested_path[0]]) | RETURN THE COLUMN NAME, FROM THE PERSPECTIVE OF THIS SCHEMA
:param column:
:return: NAME OF column | 625941d60fa83653e46571f2 |
def _inference_pass(x): <NEW_LINE> <INDENT> x = tf.layers.flatten(x) <NEW_LINE> x = tf.layers.dense(x, 100, activation=tf.nn.relu) <NEW_LINE> logits = tf.layers.dense(x, 10) <NEW_LINE> return logits | Sample the base classifier's prediction under noisy corruptions of the input x. | 625941d6097d151d1a223090 |
def teardown_method(self,method): <NEW_LINE> <INDENT> FileList = ['tetgen.ele', 'tetgen.face', 'tetgen.node', 'hexmesh_3x3.mesh', 'poisson_3d_c0p1pe1.xmf', 'poisson_3d_c0p1pe1.h5', 'poisson_3d_c0p2pe1.xmf', 'poisson_3d_c0p2pe1.h5', 'poisson_3d_c0q1_hexMesh_pe1.xmf', 'poisson_3d_c0q1_hexMesh_pe1.h5', 'poisson_3d_c0q1_pr... | Tear down function | 625941d68c3a8732951585f3 |
def __init__(self, emission=None, diffuse=None, refraction_index=1.0, reflectivity=-1.0, reflection_cone_angle=0.0): <NEW_LINE> <INDENT> self.emission = emission if emission is not None else Vec3() <NEW_LINE> self.diffuse = diffuse if diffuse is not None else Vec3() <NEW_LINE> self.refraction_index = refraction_index <... | Creates material with default or given settings. | 625941d663b5f9789fde731d |
def get_post_info(self, code): <NEW_LINE> <INDENT> url = "https://www.instagram.com/p/{}/".format(code) <NEW_LINE> with self.session.get(url) as res: <NEW_LINE> <INDENT> data = get_shared_data(res.text) <NEW_LINE> return data['entry_data']['PostPage'][0]['graphql']['shortcode_media'] | Get media information from a given post code.
Arguments:
code (str): the code of the post (can be obtained either
from the ``shortcode`` attribute of media dictionaries, or
from a post URL: ``https://www.instagram.com/p/<code>/``)
Returns:
dict: a media dictionaries, in the format used by Inst... | 625941d6ad47b63b2c50a1b7 |
def set_dim_sim_meth(self, _size_tang=1, _size_sag=1, _ap_shape='r', _sim_meth=2, _npt=500, _nps=500, _treat_in_out=1, _ext_in=0, _ext_out=0): <NEW_LINE> <INDENT> if((_sim_meth < 1) or (_sim_meth > 2)): <NEW_LINE> <INDENT> raise Exception("Simulation method is not specified correctly (should be 1 for \"thin\", 2 for \"... | Sets Mirror Dimensions, Aperture Shape and its simulation method
:param _size_tang: size in tangential direction [m]
:param _size_sag: size in sagital direction [m]
:param _ap_shape: shape of aperture in local frame ('r' for rectangular, 'e' for elliptical)
:param _sim_meth: simulation method (1 for "thin" approximatio... | 625941d697e22403b379d1d2 |
def save_new_constituency(self, data): <NEW_LINE> <INDENT> constituency = Constituency.query.filter_by(name=data['name']).first() <NEW_LINE> if not constituency: <NEW_LINE> <INDENT> new_constituency = Constituency( name = data['name'], county_id = data['county_id'] ) <NEW_LINE> self.models.save_changes(new_constituency... | Add a new county to the database | 625941d682261d6c526ab6d9 |
def _dl_from_cache_(self, url): <NEW_LINE> <INDENT> return self.cachedir(self._cache_[url]['id']) | Get a file from cachedir(), based on url and cache info | 625941d615baa723493c41af |
def __div__(self, other): <NEW_LINE> <INDENT> assert isinstance(other, Quaternion) <NEW_LINE> return other * self.inverse() | Division operator for quaternions
Arguments:
other: the quaternion we're going to divide by this one
Returns:
other/this | 625941d6379a373c97cfad7d |
def build_graph(device, n, m, k, transpose_a, transpose_b, dtype): <NEW_LINE> <INDENT> with ops.device('%s' % device): <NEW_LINE> <INDENT> if not transpose_a: <NEW_LINE> <INDENT> x = variables.VariableV1(random_ops.random_uniform([n, m], dtype=dtype), use_resource=False) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> x ... | Build a graph containing a sequence of matmul operations.
Args:
device: String, the device to run on.
n: tensor A's first dimension size.
m: tensor A's second dimension size.
k: tensor B's second dimension size.
transpose_a: boolean value to show if tensor A is transposed.
transpose_b: boolean value to sho... | 625941d6dd821e528d63b3e0 |
def _more_populate_from_attributes(self, attributes): <NEW_LINE> <INDENT> self.type = str(attributes['type']) | Fills in an object with the additional attributes.
Overridden by inheriting classes to provide the specific attributes
when getting objects from the APIC. | 625941d61f037a2d8b946435 |
def getFillPeakInstLumi(self, fillNo = None): <NEW_LINE> <INDENT> if fillNo is None: <NEW_LINE> <INDENT> instLumi = {} <NEW_LINE> for fill in self.fillData.keys(): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> instLumi[key] = float(self.fillData[key][4].strip()) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> instLumi[k... | Return fill instant lumi | 625941d6c432627299f04e7f |
def read_cinema(fn): <NEW_LINE> <INDENT> t = json.load(open(fn + '/info.json')) <NEW_LINE> name_pairs = [] <NEW_LINE> for k, v in t['arguments'].items(): <NEW_LINE> <INDENT> if v['type'] == 'range': <NEW_LINE> <INDENT> name_pairs.append((k, v['label'])) <NEW_LINE> <DEDENT> <DEDENT> name_pairs = sorted(name_pairs, key=l... | Parse a Cinema Spec A database schema.
Parameters
----------
fn : string
Path to the database that contains the info.json
Side-effects
------------
None.
Returns
-------
(valstr, cols, pattern)
valstr : string
A SQL substring for describing the Cinema DB as values schema
cols : a list... | 625941d63c8af77a43ae39d9 |
def test_post_json(self, client): <NEW_LINE> <INDENT> api = '/rest/v1.0/std/eaccount/topupquery' <NEW_LINE> params = { 'parentMerchantNo': '10000470992', 'merchantNo': '10000470992', 'orderId': '12345' } <NEW_LINE> res = client.post_json(api, params) <NEW_LINE> if 'qa' == client.env and '40020' != res.get('code'): <NEW... | Test POST JSON response.
Args:
self: write your description
client: write your description | 625941d630c21e258bdfa6d6 |
def discover(self, fuzzableRequest ): <NEW_LINE> <INDENT> if not self._run: <NEW_LINE> <INDENT> raise w3afRunOnce() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._run = False <NEW_LINE> bing_wrapper = bing( self._uri_opener ) <NEW_LINE> domain = fuzzableRequest.getURL().getDomain() <NEW_LINE> if is_private_site( d... | @parameter fuzzableRequest: A fuzzableRequest instance that contains (among other things) the URL to test. | 625941d6236d856c2ad44a14 |
def amplitude(self, amp): <NEW_LINE> <INDENT> turnbackon = 0 <NEW_LINE> if self.running == 1: <NEW_LINE> <INDENT> self.onoff() <NEW_LINE> turnbackon = 1 <NEW_LINE> <DEDENT> self.amplitude_spin.setValue(amp) <NEW_LINE> if turnbackon == 1: <NEW_LINE> <INDENT> self.onoff() | Adjusts the maximum allowed amplitude for the flipper current | 625941d67047854f462a163f |
def appendQzParams(self): <NEW_LINE> <INDENT> new_dir = self.fileDialog() <NEW_LINE> if new_dir: <NEW_LINE> <INDENT> if appendProject(new_dir) == 'done': <NEW_LINE> <INDENT> self.statusDisplay() <NEW_LINE> self.qzRefresh() <NEW_LINE> self.qzRefreshAll() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.statusDisplay(F... | add project middleman | 625941d6cc40096d61595b88 |
def draw_to_window(self, window): <NEW_LINE> <INDENT> if self.row < 1 or self.row > curses.LINES - 1: <NEW_LINE> <INDENT> raise OutOfBoundsError("Went Out of Bounds!") <NEW_LINE> <DEDENT> if self.column < 1 or self.column > curses.COLS - 1: <NEW_LINE> <INDENT> raise OutOfBoundsError("Went Out of Bounds!") <NEW_LINE> <D... | Draws this Point to the curses window | 625941d6f7d966606f6aa23e |
def FBMergeTransactionFileRefEditBegin(): <NEW_LINE> <INDENT> pass | Call to begin the transaction for merging multiple files and applying File Reference edit at the same time.
Useful to consecutively merge multiple files into scene with FileRef edit operation in between. | 625941d697e22403b379d1d3 |
def leastInterval(self, tasks, n): <NEW_LINE> <INDENT> array=[0 for _ in range(26)] <NEW_LINE> for task in tasks: <NEW_LINE> <INDENT> array[ord(task)-ord('A')]+=1 <NEW_LINE> <DEDENT> array.sort() <NEW_LINE> mxn=array[-1] <NEW_LINE> maxLength=(mxn-1)*(n+1) +array.count(mxn) <NEW_LINE> return max(maxLength,len(tasks)) | :type tasks: List[str]
:type n: int
:rtype: int | 625941d61f037a2d8b946436 |
def __init__(self, data_container: list): <NEW_LINE> <INDENT> self.data_ = data_container <NEW_LINE> self.first_var = 0 <NEW_LINE> self.last_var = len(self.data_) <NEW_LINE> self.grade_regression_result = None <NEW_LINE> self.results = list() <NEW_LINE> self.error_results = list() | This class handles all the main process
:param data_container: Its a list of data | 625941d67b25080760e39690 |
def _make_filename(self, filename, metadata, settings): <NEW_LINE> <INDENT> if settings["move_files"]: <NEW_LINE> <INDENT> new_dirname = settings["move_files_to"] <NEW_LINE> if not os.path.isabs(new_dirname): <NEW_LINE> <INDENT> new_dirname = os.path.normpath(os.path.join(os.path.dirname(filename), new_dirname)) <NEW_L... | Constructs file name based on metadata and file naming formats. | 625941d6dc8b845886cb576e |
def list_orgs(self, login=None): <NEW_LINE> <INDENT> if login: <NEW_LINE> <INDENT> url = self._build_url('users', login, 'orgs') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> url = self._build_url('user', 'orgs') <NEW_LINE> <DEDENT> json = self._json(self._get(url), 200) <NEW_LINE> return [Organization(org, self) for o... | List public organizations for login if provided; otherwise
list public and private organizations for the authenticated
user.
:param login: (optional), user whose orgs you wish to list
:type login: str
:returns: list of :class:`Organization <github3.orgs.Organization>`\ s | 625941d6ac7a0e7691ed4301 |
def insert(self, data: T) -> None: <NEW_LINE> <INDENT> if not self.head: <NEW_LINE> <INDENT> new_node = DoublyLinkedListNode(data, prev=None) <NEW_LINE> self.head = new_node <NEW_LINE> self.tail = new_node <NEW_LINE> self.size += 1 <NEW_LINE> return <NEW_LINE> <DEDENT> new_node = DoublyLinkedListNode(data, prev=self.ta... | Adds an element to the end of the list. | 625941d69c8ee82313fbb9ad |
def _get_slide_name(filename, name): <NEW_LINE> <INDENT> if FLAGS.one_FT_per_Tile == True: <NEW_LINE> <INDENT> return os.path.basename(filename) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if FLAGS.PatientID > 0: <NEW_LINE> <INDENT> return os.path.basename(filename)[:FLAGS.PatientID+len(name)+1] <NEW_LINE> <DEDENT>... | Extract root name of the file, remove "test_" and "indexes | 625941d694891a1f4081bce2 |
def get_archive(self, safe_id, uuid): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> res = self.api.storage.c14.safe(safe_id).archive(uuid).get() <NEW_LINE> <DEDENT> except slumber.exceptions.HttpClientError as e: <NEW_LINE> <INDENT> res = self.handle_error(e) <NEW_LINE> <DEDENT> except slumber.exceptions.HttpServerError... | Get information on an Archive.
:param safe_id: Id of the safe.
:param uuid: Id of the archive. | 625941d6ec188e330fd5a9d4 |
def msbuild(name_or_gen_or_ver): <NEW_LINE> <INDENT> ver = to_ver(name_or_gen_or_ver) <NEW_LINE> if ver < 12: <NEW_LINE> <INDENT> import winreg as wr <NEW_LINE> msbuild = None <NEW_LINE> msbvers = ('4.0', '3.5', '2.0') <NEW_LINE> for v in msbvers: <NEW_LINE> <INDENT> key = "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\... | get the MSBuild.exe path | 625941d6a79ad161976cc37e |
def list_routes_table( self, resource_group_name: str, circuit_name: str, **kwargs: Any ) -> AsyncIterable["_models.ExpressRouteCircuitsRoutesTableListResult"]: <NEW_LINE> <INDENT> cls = kwargs.pop('cls', None) <NEW_LINE> error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError... | The ListRoutesTable from ExpressRouteCircuit operation retrieves the currently advertised
routes table associated with the ExpressRouteCircuits in a resource group.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param circuit_name: The name of the circuit.
:type circuit_nam... | 625941d626238365f5f0f0a9 |
def subarraySum(self, nums: List[int], k: int) -> int: <NEW_LINE> <INDENT> hash_map = defaultdict(int) <NEW_LINE> hash_map[0] = 1 <NEW_LINE> total = 0 <NEW_LINE> count = 0 <NEW_LINE> for num in nums: <NEW_LINE> <INDENT> total += num <NEW_LINE> if hash_map.get(total - k): <NEW_LINE> <INDENT> count += hash_map[total - k]... | Heuristic (c.f. two sum)
---------
- Example: nums = [1, 1, 1]; k = 2
- Start from 0
1. index 0: cumulative sum = 1; distance(k, sum(nums[0:1])): 1 - 2 = -1
2. index 1: cumulative sum = 2; distance(k, sum(nums[0:2])): 2 - 2 = 0
3. index 2: cumulative sum = 3; distance(k, sum(nums[0:3])): 3 - 2 = 1
- Start f... | 625941d6f9cc0f698b140832 |
def __init__(self, ftp_path, outdir): <NEW_LINE> <INDENT> self.ftp_dir = ftp_path <NEW_LINE> self.outdir = outdir <NEW_LINE> self.gbff = None <NEW_LINE> self.checksum_file = self.outdir + '/md5checksums.txt' | :param ftp_path: The path to the directory with the assembly's files
:param outdir: directory to store all downloaded files
:return: | 625941d6d10714528d5fff1d |
def get_host_ip_address(params=None, ip_ver="ipv4", linklocal=False): <NEW_LINE> <INDENT> net_dev = "" <NEW_LINE> if params: <NEW_LINE> <INDENT> host_ip = params.get('host_ip_addr', None) <NEW_LINE> if host_ip: <NEW_LINE> <INDENT> logging.debug("Use IP address at config %s=%s", 'host_ip_addr', host_ip) <NEW_LINE> retur... | Returns ip address of host specified in host_ip_addr parameter if provided.
Otherwise ip address on interface specified in netdst parameter is returned.
In case of "nettype == user" "netdst" parameter is left empty, then the
default interface of the system is used.
:param params
:param ip_ver: Host IP version, ipv4 or... | 625941d65510c4643540f618 |
def storeSpecificSettings(self): <NEW_LINE> <INDENT> self.storedsettings = self.save(self.preprocessormodel) <NEW_LINE> super().storeSpecificSettings() | Reimplemented. | 625941d6bd1bec0571d90868 |
def screenBlankingControlSupported(self): <NEW_LINE> <INDENT> return True | Screen blanking support is handled through Qt Mobility | 625941d64e696a04525c9684 |
def make_config_from_memdump(dumpname): <NEW_LINE> <INDENT> index = open( os.path.sep.join( [dumpname, Config.DUMPNAME_INDEX_FILENAME] ), 'r' ) <NEW_LINE> m1 = index.readline().split(' ') <NEW_LINE> if len(m1[0]) > 10: <NEW_LINE> <INDENT> log.info('[+] WORDSIZE = 8 #x64 arch dump detected') <NEW_LINE> Config.set_word_s... | Load a memory dump meta data | 625941d64d74a7450ccd43fc |
def test_view_diary_logs_of_child(self): <NEW_LINE> <INDENT> response = self.client.get(reverse('diary_logs', kwargs={'child_id':self.child.id})) <NEW_LINE> self.assertEqual(response.status_code, 200) <NEW_LINE> self.assertTemplateUsed(response, 'diary_logs.html') <NEW_LINE> self.assertIn(self.diary_log_1, response.con... | test that all diary logs of a child is shown using the correct template | 625941d64f88993c3716c29e |
def to_ds9_reg(self, ds9reg, rawimage=False, numpix=100, fibid_at=0): <NEW_LINE> <INDENT> return to_ds9_reg_function(self, ds9reg, rawimage=rawimage, numpix=numpix, fibid_at=fibid_at ) | Transform fiber traces to ds9-region format.
Parameters
----------
ds9reg : BinaryIO
Handle to output file name in ds9-region format.
rawimage : bool
If True the traces must be generated to be overplotted on
raw FITS images.
numpix : int
Number of abscissae per fiber trace.
fibid_at : int
Abscissae... | 625941d6a8370b7717052ad7 |
def _AddMockData(self): <NEW_LINE> <INDENT> testing_common.AddTests(*_MOCK_DATA) <NEW_LINE> test_path = 'ChromiumPerf/mac/SunSpider/Total/t' <NEW_LINE> test_key = utils.TestKey(test_path) <NEW_LINE> test_container_key = utils.GetTestContainerKey(test_key) <NEW_LINE> for rev in range(15000, 15100, 2): <NEW_LINE> <INDENT... | Adds sample TestMetadata, Row, and Anomaly entities. | 625941d61f5feb6acb0c4d85 |
def get_request_details(_irid): <NEW_LINE> <INDENT> if bool(re.match(r"^\d+-\d+$", _irid)) == False: <NEW_LINE> <INDENT> sys.exit("Interpretation request ID doesn't match the format 11111-1, please check entry") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> request_id, request_version = _irid.split('-') <NEW_LINE> <DED... | Check the format of the entered Interpretation request ID and version number | 625941d657b8e32f524836d4 |
def compute(windata, wl0, wl_width): <NEW_LINE> <INDENT> slot = windata.hdr.slit_id[0].decode() in ('40"', '266"') <NEW_LINE> if slot: <NEW_LINE> <INDENT> windata.missing = -100 <NEW_LINE> windata.exposure_time = np.array([float(et) for et in windata.exposure_time]) <NEW_LINE> exposure_time = windata.exposure_time <NEW... | Compute synthetic emission for a given AIA band using EIS data.
Parameters
==========
windata : idl.IDLStructure
Windata structure containing the wavelength windows necessary to compute
the AIA emission.
wl0 : float
The central wavelength of the integration domain, in Ångström.
wl_width : float
The wid... | 625941d61f5feb6acb0c4d86 |
def class_filter(self, class_n, npoints): <NEW_LINE> <INDENT> self.assertModule('v.in.lidar', input=self.las_file, output=self.imported_points, flags='bt', class_filter=class_n) <NEW_LINE> self.assertVectorExists(self.imported_points) <NEW_LINE> self.assertVectorFitsTopoInfo( vector=self.imported_points, reference=dict... | Actual code for testing class filter | 625941d65e10d32532c5f15f |
def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, SimpleGroupResource): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.__dict__ == other.__dict__ | Returns true if both objects are equal | 625941d64f6381625f114c74 |
def set_inuse_bit_at_offset(self, p, s): <NEW_LINE> <INDENT> chunk = malloc_chunk((p.address + s), inuse=False, debugger=self.dbg) <NEW_LINE> chunk.size |= self.PREV_INUSE <NEW_LINE> chunk.write() | set inuse bits in known places | 625941d621a7993f00bc7f2b |
def rotate(self, matrix): <NEW_LINE> <INDENT> self.rotateHelper(matrix,0,len(matrix[0])-1) | :type matrix: List[List[int]]
:rtype: None Do not return anything, modify matrix in-place instead. | 625941d68e05c05ec3eea5af |
def read_file(from_file_path, coding='utf-8', return_type='list', errors_type='strict'): <NEW_LINE> <INDENT> coding = coding.lower() <NEW_LINE> with open(from_file_path, 'rb') as f: <NEW_LINE> <INDENT> encoded_text = f.read() <NEW_LINE> <DEDENT> codingInfo = re.match(r'^(utf-(?:8|(?:(?:16|32)[lb][e])))(?: (bom))?$', co... | This func is used to read input file
Three new features:
1. can set the coding
2. decide whether return str or list
3. As for list, there is no '
' or '
' in the end
:param from_file_path:
:param coding:
:return:
| 625941d685dfad0860c3b094 |
def start(self, args=None): <NEW_LINE> <INDENT> if self.is_daemon: <NEW_LINE> <INDENT> if not self.isAlive: <NEW_LINE> <INDENT> self.thread = Thread(target=self.run) <NEW_LINE> self.isAlive = True <NEW_LINE> self.isRunning = True <NEW_LINE> self.thread.start() <NEW_LINE> self.isFinished = False <NEW_LINE> <DEDENT> <DED... | Starts to repeatedly (if it's daemon) call the worker
function. If it's not daemon, execute only once.
Argumets should be passed only for non daemon
worker function.
This method assigns a new Thread Object to the thread
(allowing to be called more than once).
It actives the flags isAlive and isRunning,
calls the sta... | 625941d6627d3e7fe0d6908a |
def jackknife_indexes(data): <NEW_LINE> <INDENT> base=np.arange(0,len(data)) <NEW_LINE> return (np.delete(base,i) for i in base) | From the scikits.bootstrap package.
Given data points data, where axis 0 is considered to delineate points, return
a list of arrays where each array is a set of jackknife indexes.
For a given set of data Y, the jackknife sample J[i] is defined as the data set
Y with the ith data point deleted.
| 625941d6c432627299f04e80 |
def get_bindings_for_keys(self, keys): <NEW_LINE> <INDENT> return self._keys_to_bindings[keys] | Return a list of key bindings that can handle this key.
(This return also inactive bindings, so the `filter` still has to be
called, for checking it.)
:param keys: tuple of keys. | 625941d65fcc89381b1e18f9 |
def test_changelog_entry_only(self): <NEW_LINE> <INDENT> changelog_entry = ( "{pkg} ({ver}) suite; urgency=high\n\n" " * New stable release:\n" " - Feature 1\n" " - Feature 2\n\n" " -- Maintainer <email@domain.com> Mon, 1 July 2013 09:00:00 +0000" ).format(pkg=self.source_package.name, ver=self.source_package.v... | Tests that the :meth:`get_changelog_entry
<distro_tracker.core.models.SourcePackage.get_changelog_entry>` returns
the changelog part correctly when it is the only entry in the changelog
file. | 625941d68e71fb1e9831d9e1 |
def index(request): <NEW_LINE> <INDENT> return render(request, 'project/index.html') | Домашняя страница приложения Project. | 625941d66fece00bbac2d979 |
def get_eth_network(dbsession: Session, asset_network_name="ethereum") -> AssetNetwork: <NEW_LINE> <INDENT> network = dbsession.query(AssetNetwork).filter_by(name=asset_network_name).one_or_none() <NEW_LINE> if not network: <NEW_LINE> <INDENT> network = AssetNetwork(name=asset_network_name) <NEW_LINE> dbsession.add(net... | Create Ethereum network instance.
:param asset_network_name: What network we use. *ethereum* for main network, *testnet* for testnet. | 625941d667a9b606de4a80f1 |
@config_cli.command() <NEW_LINE> @click.argument("key") <NEW_LINE> @pass_global_config <NEW_LINE> def get(cfg, key): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> print(cfg[key]) <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> print("No such item.") | Print a global config value. | 625941d6ad47b63b2c50a1b8 |
def delete_notifications(filter_, sync=False): <NEW_LINE> <INDENT> query = {"bool": {"filter": [filter_]}} <NEW_LINE> query_delete(notifications_index(), query, sync=sync) | Delete notifications from a specific channel. | 625941d638b623060ff0b026 |
def chequear_input(self): <NEW_LINE> <INDENT> events = pygame.event.get() <NEW_LINE> for event in events: <NEW_LINE> <INDENT> if event.type == QUIT: <NEW_LINE> <INDENT> exit() <NEW_LINE> <DEDENT> elif event.type == KEYDOWN: <NEW_LINE> <INDENT> if event.key == K_RETURN: <NEW_LINE> <INDENT> self._modelos.agregar_planeta_... | Chequea el input del usuario
:return: | 625941d615fb5d323cde0d4b |
def test_not_overlapping_barriers(self): <NEW_LINE> <INDENT> qr = QuantumRegister(2, 'q') <NEW_LINE> circuit = QuantumCircuit(qr) <NEW_LINE> circuit.barrier(qr[0]) <NEW_LINE> circuit.barrier(qr[1]) <NEW_LINE> expected = QuantumCircuit(qr) <NEW_LINE> expected.barrier(qr[0]) <NEW_LINE> expected.barrier(qr[1]) <NEW_LINE> ... | Test two barriers with no overlap are not merged
(NB in these pictures they look like 1 barrier but they are
actually 2 distinct barriers, this is just how the text
drawer draws them)
░ ░
q_0: |0>─░─ q_0: |0>─░─
░ -> ░
q_1: |0>─░─ q_1: |... | 625941d63cc13d1c6d3c75b2 |
def save_file(self): <NEW_LINE> <INDENT> if not self.__is_untitled and foundations.common.path_exists(self.__file): <NEW_LINE> <INDENT> return self.write_file(self.__file) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return self.save_fileAs() | Saves the editor file content.
:return: Method success.
:rtype: bool | 625941d6d8ef3951e3243776 |
def BWPrefMatrix(self, v): <NEW_LINE> <INDENT> g = HigherOrderNetwork(self) <NEW_LINE> indeg = len(g.predecessors[v]) <NEW_LINE> outdeg = len(g.successors[v]) <NEW_LINE> index_succ = {} <NEW_LINE> index_pred = {} <NEW_LINE> B_v = _np.zeros(shape=(indeg, outdeg)) <NEW_LINE> i = 0 <NEW_LINE> for u in g.predecessors[v]: <... | Computes a betweenness preference matrix for a node v
@param v: Node for which the betweenness preference matrix shall
be calculated | 625941d65510c4643540f619 |
def test_00_private_attrs(self): <NEW_LINE> <INDENT> fs = FileStorage() <NEW_LINE> self.assertTrue(hasattr(FileStorage, "_FileStorage__file_path")) <NEW_LINE> self.assertTrue(hasattr(FileStorage, "_FileStorage__objects")) | Validate attributes are private. | 625941d650812a4eaa59c559 |
def containsNearbyDuplicate(self, nums, k): <NEW_LINE> <INDENT> tmp_dict = {} <NEW_LINE> for x in xrange(0, len(nums)): <NEW_LINE> <INDENT> num = nums[x] <NEW_LINE> index = tmp_dict.get(num) <NEW_LINE> if index is not None and x - index <= k: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> tmp_dict[num] = x <NEW_LI... | :type nums: List[int]
:type k: int
:rtype: bool | 625941d6fbf16365ca6f63ff |
def wca_camouflage_login(self): <NEW_LINE> <INDENT> if WkvCwApi._login_once_flag: <NEW_LINE> <INDENT> return dl.PUB_E_OK <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> WkvCwApi._login_once_flag = True <NEW_LINE> <DEDENT> if self._gatherpostkey() != dl.PUB_E_OK: <NEW_LINE> <INDENT> exit(dl.PUB_E_RESPONSE_FAIL) <NEW_LINE>... | Camouflage browser to login
If login failed, program will exit here
@@API that allows external calls
:return: status code | 625941d656ac1b37e6264406 |
def __relocate_cluster(self, cluster): <NEW_LINE> <INDENT> self.__queue.remove(cluster); <NEW_LINE> self.__insert_cluster(cluster); | !
@brief Relocate cluster in list in line with distance order.
@param[in] cluster (cure_cluster): Cluster that should be relocated in line with order. | 625941d6097d151d1a223091 |
def main(apply_config=True): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> signal.signal(signal.SIGPIPE, signal.SIG_DFL) <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> args = parse_args(sys.argv[1:], apply_config=apply_config) <NEW_LINE> if args.list_fixe... | Tool main. | 625941d6d18da76e23532711 |
def json(self, data=None): <NEW_LINE> <INDENT> self.refresh() <NEW_LINE> return {'id': self.id, 'handle': self.handle, 'progress': self.progress, 'remaining': self.remaining, 'status': self.status, 'message': self.message, 'data': data} | Return a simple JSON structure representing the Job status | 625941d67cff6e4e81117bbe |
def long2ip(l): <NEW_LINE> <INDENT> return socket.inet_ntoa(struct.pack("!L", l)) | Convert big-endian long representation of IP address to string
| 625941d6293b9510aa2c34cd |
def rmsdAlign(molecule0, molecule1, mapping=None, property_map0={}, property_map1={}): <NEW_LINE> <INDENT> if type(property_map0) is not dict: <NEW_LINE> <INDENT> raise TypeError("'property_map0' must be of type 'dict'") <NEW_LINE> <DEDENT> if type(property_map1) is not dict: <NEW_LINE> <INDENT> raise TypeError("'prope... | Align atoms in molecule0 to those in molecule1 using the mapping
between matched atom indices. The molecule is aligned using rigid-body
translation and rotations, with a root mean squared displacement (RMSD)
fit to find the optimal translation vector (as opposed to merely taking
the difference of centroids).
Parameters... | 625941d6d486a94d0b98e380 |
def kerning(face, a, b): <NEW_LINE> <INDENT> unitsPerEm = getattr(face, "unitsPerEm", 0) <NEW_LINE> if not unitsPerEm: <NEW_LINE> <INDENT> return 0. <NEW_LINE> <DEDENT> scale = lambda x, unitsPerEm=unitsPerEm: x * 1000. / unitsPerEm <NEW_LINE> kerning_table = getattr(face, "kerning_table", None) <NEW_LINE> if kerning_t... | Returns the kerning for the characters a and b and the font face.
The return value is given in em/1000(?). | 625941d6009cb60464c635ea |
def obtain_sandbox(user, branch_id): <NEW_LINE> <INDENT> branch = Branch.objects.get(pk=int(branch_id)) <NEW_LINE> sandbox = Sandbox.objects.filter(bound_to_branch_ref=branch, created_by__id=user.id, status=0, is_deleted=False).first() <NEW_LINE> if sandbox is None: <NEW_LINE> <INDENT> branch_revision = BranchRevision.... | Finds sandbox for given @user and @branch_id. | 625941d6442bda511e8be64f |
def test_parse_binning(): <NEW_LINE> <INDENT> bin1, bin2 = parse.parse_binning('2,2') <NEW_LINE> assert bin1 == 2 <NEW_LINE> assert bin2 == 2 <NEW_LINE> bin1, bin2 = parse.parse_binning((2,2)) <NEW_LINE> assert bin1 == 2 <NEW_LINE> assert bin2 == 2 | Test parse binning algorithm
| 625941d6566aa707497f479f |
def convert_location(loc, my_map): <NEW_LINE> <INDENT> cell_size = my_map.info.resolution <NEW_LINE> x = loc[0] <NEW_LINE> y = loc[1] <NEW_LINE> x = x - ((x + (cell_size / 2)) % cell_size) + (cell_size / 2) <NEW_LINE> y = y - ((y + (cell_size / 2)) % cell_size) + (cell_size / 2) <NEW_LINE> newloc = (x, y) <NEW_LINE> re... | converts points to the grid | 625941d6091ae35668667195 |
@make_result('staticPiston') <NEW_LINE> def make_static_pist(ent, res): <NEW_LINE> <INDENT> bottom_pos = ent.fixup['bottom_level', '-1'] <NEW_LINE> if (ent.fixup['connectioncount', '0'] != "0" or ent.fixup['disable_autodrop', '0'] != "0"): <NEW_LINE> <INDENT> if int(bottom_pos) > 0: <NEW_LINE> <INDENT> val = res.value[... | Convert a regular piston into a static version.
This is done to save entities and improve lighting. | 625941d6d8ef3951e3243777 |
@cache.cache_on_arguments() <NEW_LINE> def cached_topic_word_counts(user_mc_key, topics_id, **kwargs): <NEW_LINE> <INDENT> if user_mc_key == TOOL_API_KEY: <NEW_LINE> <INDENT> local_mc = mc <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> local_mc = user_mediacloud_client() <NEW_LINE> <DEDENT> return local_mc.topicWordCoun... | Internal helper - don't call this; call topic_word_counts instead. This needs user_mc_key in the
function signature to make sure the caching is keyed correctly. | 625941d644b2445a339322ce |
def test_encode(self): <NEW_LINE> <INDENT> name = dns.Name(b"foo.example.com") <NEW_LINE> stream = BytesIO() <NEW_LINE> name.encode(stream) <NEW_LINE> self.assertEqual(stream.getvalue(), b"\x03foo\x07example\x03com\x00") | L{Name.encode} encodes its name information and writes it to the
file-like object passed to it. | 625941d6f9cc0f698b140833 |
def set_parameters_free(self, parameter_name_list=None): <NEW_LINE> <INDENT> parameter_list = [] <NEW_LINE> if not parameter_name_list: <NEW_LINE> <INDENT> parameter_list = self.parameters <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> for _parameter in self.parameters: <NEW_LINE> <INDENT> if _parameter.name in paramete... | Sets parameters in a component to free.
Parameters
----------
parameter_name_list : None or list of strings, optional
If None, will set all the parameters to free.
If list of strings, will set all the parameters with the same name
as the strings in parameter_name_list to free.
Examples
--------
>>> v1 = h... | 625941d66fece00bbac2d97a |
def build_package(): <NEW_LINE> <INDENT> local('docker-compose run --rm dev python setup.py sdist') | Build the pip packages. | 625941d60a366e3fb873ea55 |
def amsaves_audit(audits): <NEW_LINE> <INDENT> combinedUsageDct = {} <NEW_LINE> for key, value in audits.iteritems(): <NEW_LINE> <INDENT> elecUsage = [] <NEW_LINE> gasUsage = [] <NEW_LINE> jsonAudits = value <NEW_LINE> for jsonAudit in jsonAudits: <NEW_LINE> <INDENT> values = jsonAudit['TotalUnitsUsed'] <NEW_LINE> peri... | Pass the results of get_model_audits function; produce audit of
results for the 'America Saves!' program as a DataFrame | 625941d6a8370b7717052ad8 |
def read_file(file_to_read): <NEW_LINE> <INDENT> with open(file_to_read, 'r') as file: <NEW_LINE> <INDENT> funilrys = file.read() <NEW_LINE> <DEDENT> return funilrys | Read the content of a given file
:param file_to_read: A string, a path to the file we have to read | 625941d6283ffb24f3c55b39 |
def learn(): <NEW_LINE> <INDENT> description = '''Generate coaching data for gitcoach.''' <NEW_LINE> parser = argparse.ArgumentParser(description=description) <NEW_LINE> parser.add_argument( '--max-commit-files', '-n', type=int, default=7, help='Commits touching more than N files are thrown away' ) <NEW_LINE> args = pa... | Entry point for gitlearn command. | 625941d6566aa707497f47a0 |
def forEachIDL(self, func, idls=[], idl_dirs=[], except_files=[]): <NEW_LINE> <INDENT> default_idl_dirs = [os.path.join(wasanbon.get_rtm_root(), 'rtm', 'idl'), os.path.join(wasanbon.home_path, 'idl')] <NEW_LINE> default_except_files = ['RTM.idl', 'RTC.idl', 'OpenRTM.idl', 'DataPort.idl', 'Manager.idl', 'SDOPackage.idl'... | Apply func function to each IDLs.
| 625941d6097d151d1a223092 |
def Error(self, backtrace, client_id=None, status=None): <NEW_LINE> <INDENT> client_id = client_id or self.args.client_id <NEW_LINE> if self.IsRunning(): <NEW_LINE> <INDENT> reply = rdfvalue.GrrStatus() <NEW_LINE> if status is None: <NEW_LINE> <INDENT> reply.status = rdfvalue.GrrStatus.ReturnedStatus.GENERIC_ERROR <NEW... | Kills this flow with an error. | 625941d68c3a8732951585f5 |
def add_fit(self, x, y): <NEW_LINE> <INDENT> if self.training_inputs is None: <NEW_LINE> <INDENT> self.fit([x], [y]) <NEW_LINE> return <NEW_LINE> <DEDENT> self.training_inputs = np.append(self.training_inputs, [x], axis=0) <NEW_LINE> self.training_outputs = np.append(self.training_outputs, y.reshape(-1, 1), axis=1) <NE... | Adds new training points to the training set
Args:
X: input of shape (n-features)
y: output of shape (n-targets) | 625941d6ad47b63b2c50a1b9 |
def _middle(self, image): <NEW_LINE> <INDENT> x = self.pool1_stage2(F.relu(self.conv1_stage2(image))) <NEW_LINE> x = self.pool2_stage2(F.relu(self.conv2_stage2(x))) <NEW_LINE> x = self.pool3_stage2(F.relu(self.conv3_stage2(x))) <NEW_LINE> return x | Compute shared pool3_stage_map for the following stage
:param image: source image with (368, 368)
:return: pool3_stage2_map | 625941d6851cf427c661a747 |
def group_create(self, operator, project, group, description): <NEW_LINE> <INDENT> ou = self._get_project(project) <NEW_LINE> groupname = '%s-%s' % (project, group) <NEW_LINE> gr = Utils.Factory.get('PosixGroup')(self.db) <NEW_LINE> name_error = gr.illegal_name(groupname) <NEW_LINE> if name_error: <NEW_LINE> <INDENT> r... | Method for creating a new group | 625941d64f6381625f114c75 |
def get_samplerate_datetime(datetimedata, timeformat='%H:%M:%S.%f'): <NEW_LINE> <INDENT> datetimedata = np.asarray(datetimedata, dtype='str') <NEW_LINE> elapsed = ((datetime.strptime(datetimedata[-1], timeformat) - datetime.strptime(datetimedata[0], timeformat)).total_seconds()) <NEW_LINE> sample_rate = (len(datetimeda... | Determines sample rate of data from datetime-based timer.
Keyword arguments:
timerdata -- array containing values of a timer, datetime strings
timeformat -- the format of the datetime-strings in datetimedata
default('%H:%M:%S.f', 24-hour based time including ms: 21:43:12.569) | 625941d615baa723493c41b1 |
def g(x,y): <NEW_LINE> <INDENT> r = np.sqrt(x**2 + y**2) <NEW_LINE> return np.where((r > 2.) & (r < 3.) & (x>1.) & (y>-2.), np.exp(-1.0*(y+2)),0.) | The function over which we want to integrate.
This function must take a single argument, which can
be a list or a tuple or a numpy array. The argument
defines a point. | 625941d6287bf620b61d3c9c |
def set_right(self,other): <NEW_LINE> <INDENT> self.right = other <NEW_LINE> other.parent = self | Make node `other` the right child of this one | 625941d621a7993f00bc7f2c |
def test_no_image_bfv(self): <NEW_LINE> <INDENT> self.server.pop('imageRef') <NEW_LINE> self.server['block_device_mapping'] = [{'volume_id': '235'}] <NEW_LINE> validate(self.server, group_schemas.server) | Not providing ``imageRef`` is valid, if ``block_device_mapping`` is
provided. | 625941d61b99ca400220acec |
def serialize_numpy(self, buff, numpy): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> length = len(self.ints) <NEW_LINE> buff.write(_struct_I.pack(length)) <NEW_LINE> pattern = '<%si'%length <NEW_LINE> buff.write(self.ints.tostring()) <NEW_LINE> length = len(self.floats) <NEW_LINE> buff.write(_struct_I.pack(length)) <NE... | serialize message with numpy array types into buffer
:param buff: buffer, ``StringIO``
:param numpy: numpy python module | 625941d6287bf620b61d3c9d |
def insert(self, url, content, isHeader=False, ext=None): <NEW_LINE> <INDENT> key, dirpath, filepath = self.genPathFromUrl(url, isHeader, ext) <NEW_LINE> if not os.path.exists(dirpath): <NEW_LINE> <INDENT> os.makedirs(dirpath) <NEW_LINE> <DEDENT> elif os.path.exists(filepath) and not self.overwrite: <NEW_LINE> <INDENT>... | Insert entry to cache, return true if new entry is written into cache, false otherwise | 625941d630c21e258bdfa6d8 |
def output_operator(self, output): <NEW_LINE> <INDENT> operator = self.next_starts(*OPERATORS) <NEW_LINE> if operator not in ('++', '--', '::', '->') and self.text[self.position - 1] != ' ': <NEW_LINE> <INDENT> self.warn('no space before ' + operator) <NEW_LINE> if self.cleanup: <NEW_LINE> <INDENT> output.append... | read an operator, add it to the output list, and check for spacing,
etc. | 625941d6a17c0f6771cbe28a |
@hook.api_key('domainr') <NEW_LINE> @hook.command <NEW_LINE> def domainr(inp, say='', api_key=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> data = http.get_json('https://api.domainr.com/v1/search', q=inp, client_id=api_key) <NEW_LINE> <DEDENT> except (http.URLError, http.HTTPError) as e: <NEW_LINE> <INDENT> retur... | .domainr <domain> - Use domai.nr's API to search for a domain, and similar domains. | 625941d6b5575c28eb68e23b |
def __str__(self): <NEW_LINE> <INDENT> return str(self.value) | Get the Rust expression form of this constant. | 625941d663d6d428bbe44729 |
def change_datas(self, prof): <NEW_LINE> <INDENT> surch = prof.get_type('exec') <NEW_LINE> surch.update(prof.get_type('cmde')) <NEW_LINE> surch.update(prof.get_type('ele')) <NEW_LINE> surch = surch.get_data() <NEW_LINE> prof.relocate(serv=None, newdir=None, user='', fromlist=surch) <NEW_LINE> prof.relocate(serv=None, n... | Relocate the datas of types 'exec/cmde/ele' supposed to be built
in a previous multiple execution. | 625941d6f7d966606f6aa240 |
def scottknott(data, max_rank_size=3, epsilon=0.01): <NEW_LINE> <INDENT> flat_data = [x for log in data for x in log.contents()] <NEW_LINE> data_mean = basic_stats.mean(flat_data) <NEW_LINE> def recurse_and_rank(parts, rank=0): <NEW_LINE> <INDENT> cut = min_mu(parts, data_mean, len(flat_data), max_rank_size, epsilon) <... | Recursively split data, maximizing delta of the expected value of the
mean before and after the splits. Reject splits with under max_rank_size
items. | 625941d63317a56b86939e8e |
def __clean_paragraph(self, text): <NEW_LINE> <INDENT> reNL = re.compile('\r|\n') <NEW_LINE> reWS = re.compile(r'\s{2,}') <NEW_LINE> text = reNL.sub(' ', text) <NEW_LINE> text = reWS.sub(' ', text) <NEW_LINE> text = text.strip() <NEW_LINE> return text | Cleans some text. Remove multiple whitespace, newlines, etc. | 625941d67047854f462a1641 |
def __init__(self, dependency_graph): <NEW_LINE> <INDENT> super().__init__(dependency_graph) <NEW_LINE> self._count_type = CountTypes.PRIV_EDGE.name | Store graph and set type. | 625941d621bff66bcd684b8b |
def make_response_from_book_dict(adict, file_type, status=200, file_name=None, **keywords): <NEW_LINE> <INDENT> io = pe.save_book_as(bookdict=adict, dest_file_type=file_type, **keywords) <NEW_LINE> return _make_response(io, file_type, status, file_name) | Make a http response from a dictionary of two dimensional
arrays
:param book_dict: a dictionary of two dimensional arrays
:param file_type: same as :meth:`~pyexcel_webio.make_response`
:param status: same as :meth:`~pyexcel_webio.make_response`
:returns: http response | 625941d6e76e3b2f99f3aa42 |
def test_registrar_link_count_this_year(self): <NEW_LINE> <INDENT> r = Registrar() <NEW_LINE> r.save() <NEW_LINE> o1 = Organization(registrar=r) <NEW_LINE> o1.save() <NEW_LINE> o2 = Organization(registrar=r) <NEW_LINE> o2.save() <NEW_LINE> now = tz_datetime(timezone.now().year, 1, 1) <NEW_LINE> two_years_ago = tz_datet... | Should include links created this year and exclude links
older than that. Should work across all its orgs. | 625941d6004d5f362079a56c |
def shutdown(self): <NEW_LINE> <INDENT> for process in self.processes: <NEW_LINE> <INDENT> process.terminate() <NEW_LINE> process.join() | Terminates all the workers | 625941d699cbb53fe6792e20 |
def extract_metadata(self): <NEW_LINE> <INDENT> self.log('Extracting metadata from raster.') <NEW_LINE> try: <NEW_LINE> <INDENT> max_zoom = self.compute_max_zoom() <NEW_LINE> <DEDENT> except GDALException: <NEW_LINE> <INDENT> raise RasterException('Failed to compute max zoom. Check the SRID of the raster.') <NEW_LINE> ... | Extract and store metadata for the raster and its bands. | 625941d63617ad0b5ed68130 |
def put_sub_page(self, mcb, buffer, DEBUG): <NEW_LINE> <INDENT> io_hdr = sg_io_hdr() <NEW_LINE> io_hdr.dxfer_direction = sg_io_hdr.SG_DXFER_TO_DEV <NEW_LINE> io_hdr.status = 99 <NEW_LINE> io_hdr.cmd_len = len(mcb) <NEW_LINE> io_hdr.cmdp = mcb <NEW_LINE> sense_buffer = create_string_buffer(32) <NEW_LINE> io_hdr.mx_sb_le... | ioctl to write using a sub-page to the Drobo.
required arguments:
modepageblock -
buffer
DEBUG
return the number of bytes written. | 625941d6ec188e330fd5a9d6 |
def tkn_check(self, inp: str) -> bool: <NEW_LINE> <INDENT> if (inp.isdigit() or inp == "") and len(inp) <= 8: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Restricts all but numbers and that too upto 5 digits only. | 625941d6460517430c3943bb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.