code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
def predict(self,Y): <NEW_LINE> <INDENT> self.test_i=np.ones([Y.shape[0],self.nod]) <NEW_LINE> if len(Y.shape) is 1: <NEW_LINE> <INDENT> Y=Y.reshape([Y.shape[0],1]) <NEW_LINE> <DEDENT> self.test_i[:,1:]=Y <NEW_LINE> self.test_o=self.test_i.dot(self.parameters) <NEW_LINE> return self.test_o | This function gives the predicted value of the data set given for testing.
Parameters
----------
Y: numpy.ndarray
This is the input of the linear regression model whose number of columns represent
the number of dimensions of the input. The rows represent the number of data sets given
for prediction.
... | 625941d660cbc95b062c676e |
def disable_package_apache_site(): <NEW_LINE> <INDENT> if os.path.exists(PACKAGE_CEILOMETER_API_CONF): <NEW_LINE> <INDENT> subprocess.check_call(['a2dissite', 'ceilometer-api']) | Ensure that the package-provided apache configuration is disabled to
prevent it from conflicting with the charm-provided version. | 625941d630dc7b7665901b8f |
def inode_number(self, path): <NEW_LINE> <INDENT> return os.stat(self.check_path(path)).st_ino | Get the inode number of the file system object.
:param path: The path to operate on.
:return: The inode number. | 625941d6bf627c535bc133f9 |
def gen_lines(problem): <NEW_LINE> <INDENT> n_point = 1000 <NEW_LINE> p0, p1 = nm.array([0.0, 0.0, 0.0]), nm.array([0.1, 0.0, 0.0]) <NEW_LINE> line = LineProbe(p0, p1, n_point) <NEW_LINE> line.set_options(close_limit=0.5) <NEW_LINE> centre = 0.5 * (p0 + p1) <NEW_LINE> normal = [0.0, 1.0, 0.0] <NEW_LINE> r = 0.02 <NEW_L... | Define a line probe and a circle probe. | 625941d63617ad0b5ed68121 |
def moving_average(iterable, n): <NEW_LINE> <INDENT> it = iter(iterable) <NEW_LINE> d = collections.deque(itertools.islice(it, n - 1)) <NEW_LINE> d.appendleft(0) <NEW_LINE> s = sum(d) <NEW_LINE> for elem in it: <NEW_LINE> <INDENT> s += elem - d.popleft() <NEW_LINE> d.append(elem) <NEW_LINE> yield s / float(n) | From Python collections module documentation
moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0 | 625941d65166f23b2e1a5383 |
def get_ancestry(self, version_ids, topo_sorted=True): <NEW_LINE> <INDENT> if isinstance(version_ids, bytes): <NEW_LINE> <INDENT> version_ids = [version_ids] <NEW_LINE> <DEDENT> i = self._inclusions([self._lookup(v) for v in version_ids]) <NEW_LINE> return [self._idx_to_name(v) for v in i] | See VersionedFile.get_ancestry. | 625941d66e29344779a6283b |
def is_numerical(self, value): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> float(value) <NEW_LINE> return True <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return False | Returns whether the provided argument can be converted to a number.
Returns
-------
bool
True if the argument can be converted to a number, and False otherwise | 625941d66e29344779a6283c |
def test_view_outsight_enemy_unit(self): <NEW_LINE> <INDENT> enemy1 = self.add(Fighter, 0, (13, 3)) <NEW_LINE> enemy2 = self.add(Destroyer, 0, (5, 8)) <NEW_LINE> enemy3 = self.add(Submarine, 0, (7, 14)) <NEW_LINE> units_in_sight = self.gamebody.view_elements(1) <NEW_LINE> for element in [enemy1, enemy2, enemy3]: <NEW_L... | Test behavior of viewing enemy units out of sight (see nothing) | 625941d6d4950a0f3b08c578 |
def session_archive_id(session): <NEW_LINE> <INDENT> if session.archive_id: <NEW_LINE> <INDENT> archive_id = session.archive_id <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> archive_id = "om-" + str(session.site_id) + "-" + str(session.id) <NEW_LINE> <DEDENT> return archive_id | Generates a unique identifier for archive item: om-om_site_id-om_id | 625941d621a7993f00bc7f1d |
def _send_service_msg(self, namespace, message_val): <NEW_LINE> <INDENT> resp = None <NEW_LINE> try: <NEW_LINE> <INDENT> srv_proxy_map = self.service_proxies_map[namespace] <NEW_LINE> srv_proxy = srv_proxy_map['service_proxy'] <NEW_LINE> srv_req_type = roslib.message.get_service_class(str(srv_proxy_map['service_request... | :param namespace:
:param message_val:
:return: result of invoking the service | 625941d64c3428357757c552 |
def add_subscriber_listener(self, l): <NEW_LINE> <INDENT> self.subscriber_listeners.append(l) | Add a L{SubscribeListener} for subscribe events.
@param l: listener instance
@type l: L{SubscribeListener} | 625941d6ad47b63b2c50a1aa |
def filter_glyph_names( alist, filter ): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> extras = [] <NEW_LINE> for name in alist: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> filtered_index = filter.index( name ) <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> extras.append( name ) <NEW_LINE> <DEDENT> <DEDENT> return extras | filter `alist' by taking _out_ all glyph names that are in `filter' | 625941d650485f2cf553cfc5 |
def getAccelData(self, handle, addr, g=False): <NEW_LINE> <INDENT> x = self.i2c.readWord(handle, addr, 0x3b) <NEW_LINE> y = self.i2c.readWord(handle, addr, 0x3d) <NEW_LINE> z = self.i2c.readWord(handle, addr, 0x3f) <NEW_LINE> accelScaleModifier = None <NEW_LINE> accelRange = self.readAccelRange(handle, addr, True) <NEW... | Gets and returns the X, Y and Z values from the accelerometer.
If g is True, it will return the data in g. If g is False, it will return
the data in m/s^2. Returns a dictionary with the measurement results. | 625941d6796e427e537b07f2 |
def moduli_vector_bundles(rank, degree, genus): <NEW_LINE> <INDENT> r = rank <NEW_LINE> d = degree <NEW_LINE> g = genus <NEW_LINE> assert r >= 2, "rank needs to be at least 2" <NEW_LINE> assert g >= 2, "genus needs to be at least 2" <NEW_LINE> assert gcd(r, d) == 1, "rank and degree need to be coprime" <NEW_LINE> R = H... | Hodge diamond for the moduli space of vector bundles of given rank and
fixed determinant of given degree on a curve of a given genus.
For the proof, see Corollary 5.1 of [MR1817504].
* [MR1817504] del Baño, On the Chow motive of some moduli spaces. J. Reine Angew. Math. 532 (2001), 105–132.
If the Hodge diamond for ... | 625941d6851cf427c661a738 |
def remove(self): <NEW_LINE> <INDENT> devices = self.parsed_registry['core.device_registry']['data']['devices'] <NEW_LINE> entities = self.parsed_registry['core.entity_registry']['data']['entities'] <NEW_LINE> devids = self.find_ids(devices, self.opts.deviceid, 'id', True) <NEW_LINE> entids = self.find_ids(entities, se... | remove entities or devices from registries | 625941d6167d2b6e31218dc0 |
def loadAttributes(self, obj, pointcount, vertexcount, primitivecount): <NEW_LINE> <INDENT> obj = listToDict(obj) <NEW_LINE> self.VertexAttributes = self.loadAttributeDict( obj.get('vertexattributes', None), vertexcount) <NEW_LINE> self.PointAttributes = self.loadAttributeDict( obj.get('pointattributes', None), pointco... | Interpret the schema to load all attributes | 625941d6d164cc6175782f79 |
def open_restaurant(self): <NEW_LINE> <INDENT> print(f"{self.restaurant_name} is open for business.") | Prints a message saying the restaurant is open. | 625941d6ab23a570cc2503ae |
def __init__(self, *args, **kwargs): <NEW_LINE> <INDENT> super(HelpersTests, self).__init__(*args, **kwargs) | Initialize test. | 625941d6627d3e7fe0d6907c |
def get_extensions(f, v): <NEW_LINE> <INDENT> valid, extensionIDs = get_attr(f, "openPMDextension") <NEW_LINE> result = {ext: False for ext in ext_list.keys()} <NEW_LINE> if valid: <NEW_LINE> <INDENT> enabledExtMask = 0 <NEW_LINE> for extension, bitmask in ext_list.items(): <NEW_LINE> <INDENT> if (bitmask & extensionID... | Get a dictionary which maps each extension name to a bool whether it is
enabled in the file
Parameters
----------
f : an h5py.File or h5py.Group object
The object in which to find claimed extensions
v : bool
Verbose option
Returns
-------
A dictionary {string:bool} where the keys are the extension names and t... | 625941d6d18da76e23532702 |
def retrieve_geoip_by_local_ip_breakdown(self, start_period: datetime.datetime, end_period: datetime.datetime, db_conn): <NEW_LINE> <INDENT> local_ip_results = self.config.database.run_procedure_fetchall( "traffic_report.report_traffic_breakdown_in_site_by_machine", [self.site.pg_id, start_period, end_period], existing... | Breaks down traffic by machine and destination | 625941d63cc13d1c6d3c75a4 |
def vnl_c_vector_vcl_complexLD_deallocate(*args): <NEW_LINE> <INDENT> return _vnl_c_vectorPython.vnl_c_vector_vcl_complexLD_deallocate(*args) | deallocate(vcl_complexLD arg0, int n_when_allocated)
vnl_c_vector_vcl_complexLD_deallocate(vcl_complexLD arg0, int n_when_allocated) | 625941d6b57a9660fec33ab1 |
def basic_ack(self, delivery_tag): <NEW_LINE> <INDENT> _debug_fun('basic_ack', (delivery_tag,)) <NEW_LINE> delivery_info = self.qos.get(delivery_tag).delivery_info <NEW_LINE> try: <NEW_LINE> <INDENT> queue = delivery_info['taskqueue_queue'] <NEW_LINE> <DEDENT> except KeyError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDEN... | Acknowledge the message.
For task queues this generally means that
task has been completed. | 625941d650812a4eaa59c54b |
def _handle_pooltogether(normalized_balance: FVal, token_name: str) -> Optional[DefiBalance]: <NEW_LINE> <INDENT> if 'DAI' in token_name: <NEW_LINE> <INDENT> dai_price = Inquirer.find_usd_price(EthereumToken('DAI')) <NEW_LINE> return DefiBalance( token_address=to_checksum_address('0x49d716DFe60b37379010A75329ae09428f17... | Special handling for pooltogether
https://github.com/rotki/rotki/issues/1429 | 625941d6711fe17d82542593 |
def test_hush_duration_converter_for_valid(self): <NEW_LINE> <INDENT> test_values = ( ("0", 0), ("15", 15), ("10", 10), ("5m", 5), ("5M", 5), ("forever", None), ) <NEW_LINE> converter = HushDurationConverter() <NEW_LINE> for minutes_string, expected_minutes in test_values: <NEW_LINE> <INDENT> with self.subTest(minutes_... | HushDurationConverter returns correct value for minutes duration or `"forever"` strings. | 625941d67b180e01f3dc4a25 |
def __init__(self, cura_api) -> None: <NEW_LINE> <INDENT> self._cura_api = cura_api | Create a new instance of the Drive API service and set the cura_api object. | 625941d615fb5d323cde0d3d |
def __init__(self): <NEW_LINE> <INDENT> with open(Dictionary.DICT_RANDOM, 'r', encoding='utf-8-sig') as f: <NEW_LINE> <INDENT> self._random = [x for x in f.read().splitlines() if x] <NEW_LINE> <DEDENT> with open(Dictionary.DICT_PATTERN, 'r', encoding='utf-8-sig') as g: <NEW_LINE> <INDENT> self._pattern = [Dictionary.ma... | ファイルから辞書の読み込みを行う | 625941d6e8904600ed9f215a |
def _perform_end_game_updates(self, new_state): <NEW_LINE> <INDENT> self.game_state = new_state <NEW_LINE> if new_state == 'W': <NEW_LINE> <INDENT> self.user_history.games_won += 1 <NEW_LINE> <DEDENT> self.user_history.games_played += 1 <NEW_LINE> self.user_history.active_game_id = None <NEW_LINE> self.user_history.sav... | Return the updated Game instance.
Updates the game_state with the new_state parameter,
increments games_played and resets active_game for the client. | 625941d66fb2d068a760f2ca |
def _robot_match(self, match): <NEW_LINE> <INDENT> logging.debug('robot match %r' % match) <NEW_LINE> if self._sugar: <NEW_LINE> <INDENT> self._robot_card.spr.hide() <NEW_LINE> <DEDENT> if self.grid.grid[match[0]] is not None: <NEW_LINE> <INDENT> self.clicked[0].spr = self.grid.grid[match[0]].spr <NEW_LINE> self.grid.g... | Robot finds a match | 625941d607f4c71912b116af |
def create_cipher(self, algname : str = 'AES'): <NEW_LINE> <INDENT> self.key = load_object(CFG.key_outpath) <NEW_LINE> self.value = load_object(CFG.value_outpath) <NEW_LINE> attr_cipher: Any = self.get_cipher(algname = algname) <NEW_LINE> _cipher = attr_cipher.new(self.key, AES.MODE_CFB, self.value) <NEW_LINE> return _... | Create new cipher
with predefined algorithm name.
Params
----------
algo: str
Algorithm name (#TODO list it)
Returns
----------
_cipher: Any | 625941d6498bea3a759b9cda |
def __init__(self, main, config, doitargs): <NEW_LINE> <INDENT> self._cmdnames = [] <NEW_LINE> self._main = main <NEW_LINE> self._config = config <NEW_LINE> self._doitargs = doitargs <NEW_LINE> try: <NEW_LINE> <INDENT> cmdict = self._doitargs['cmds'].to_dict() <NEW_LINE> <DEDENT> except AttributeError: <NEW_LINE> <INDE... | Take a main instance, work as wrapper for commands. | 625941d66fb2d068a760f2cb |
def PltRelWater(datax,datay,waterx,watery,normWL,aqfrac, celllength=1,newfig=True,**kwargs): <NEW_LINE> <INDENT> datay_fixed = -np.log(10**-datay)/celllength <NEW_LINE> normidx_data = np.searchsorted(datax,normWL) <NEW_LINE> WaterAbs = watery[np.searchsorted(waterx, normWL)] <NEW_LINE> datay_corr = np.add(datay_fixed, ... | Plot WbLS with aqueous fraction aqfrac, normalizing using water data.
The input data are NOT corrected for the UV-VIS's base-10 wierdness. | 625941d65fc7496912cc3ba9 |
def GetPointer(self): <NEW_LINE> <INDENT> return _ITKCommonBasePython.itkVersion_GetPointer(self) | GetPointer(self) -> itkVersion | 625941d6ec188e330fd5a9c7 |
def test_customer_city_is_required(self): <NEW_LINE> <INDENT> customer = Customer.objects.get(pk=1) <NEW_LINE> customer.city = '' <NEW_LINE> self.assertRaises(ValidationError, customer.save) <NEW_LINE> db_customer = Customer.objects.get(pk=1) <NEW_LINE> self.assertEqual(db_customer.city, 'Space') | Requires city length to be greater than zero | 625941d6cdde0d52a9e5325f |
def make_sine_model(prefix=None): <NEW_LINE> <INDENT> sine_model, params = make_sinewithoutoffset_model(prefix=prefix) <NEW_LINE> constant_model, params = lfm.make_constant_model(prefix=prefix) <NEW_LINE> sine_offset_model = sine_model + constant_model <NEW_LINE> params = sine_offset_model.make_params() <NEW_LINE> retu... | Create a sine model with amplitude and offset.
@param str prefix: optional, if multiple models should be used in a
composite way and the parameters of each model should be
distinguished from each other to prevent name collisions.
@return tuple: (object model, object params), for ... | 625941d62ae34c7f2600d35c |
def __init__(self, mailhost, fromaddr, toaddrs, subject, job_config, credentials=None, secure=None, timeout=5.0): <NEW_LINE> <INDENT> logging.Handler.__init__(self) <NEW_LINE> if isinstance(mailhost, (list, tuple)): <NEW_LINE> <INDENT> self.mailhost, self.mailport = mailhost <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT... | Initialize the handler (this is the default constructor with added handling of a MorfJobConfig input). | 625941d6293b9510aa2c34bf |
def eval_uncertainty(self, params=None, sigma=1, **kwargs): <NEW_LINE> <INDENT> self.userkws.update(kwargs) <NEW_LINE> if params is None: <NEW_LINE> <INDENT> params = self.params <NEW_LINE> <DEDENT> nvarys = self.nvarys <NEW_LINE> ndata = self.ndata <NEW_LINE> covar = self.covar / self.redchi <NEW_LINE> fjac = np.zeros... | Evaluate the uncertainty of the *model function* from the
uncertainties for the best-fit parameters. This can be used to give
confidence bands for the model.
Parameters
----------
params : Parameters, optional
Parameters, defaults to ModelResult.params.
sigma : float, optional
Confidence level, i.e. how man... | 625941d6925a0f43d254a0a3 |
def fourSumCount(self, A, B, C, D): <NEW_LINE> <INDENT> count = 0 <NEW_LINE> partialSum = defaultdict(int) <NEW_LINE> for i in A: <NEW_LINE> <INDENT> for j in B: <NEW_LINE> <INDENT> partialSum[i+j] += 1 <NEW_LINE> <DEDENT> <DEDENT> for k in C: <NEW_LINE> <INDENT> for l in D: <NEW_LINE> <INDENT> tmp = (k+l) *(-1) <NEW_L... | :type A: List[int]
:type B: List[int]
:type C: List[int]
:type D: List[int]
:rtype: int | 625941d6e64d504609d74a6b |
def get_kv_from_dict(dict_data, sep='\r\n'): <NEW_LINE> <INDENT> kv = '' <NEW_LINE> for key, value in dict_data.items(): <NEW_LINE> <INDENT> kv += str(key) + ': ' + str(value) + sep <NEW_LINE> <DEDENT> return kv | 将字典格式数据转换成键值对字符串
:param dict_data:
:return: | 625941d64e4d5625662d4601 |
def set_verbosity(verbose): <NEW_LINE> <INDENT> logging.getLogger(SQLALCHEMY_LOGGER).setLevel(logging.ERROR) <NEW_LINE> logging.getLogger(SQLALCHEMY_ENGINE).setLevel(logging.ERROR) <NEW_LINE> logging.getLogger(NEWSREAP_LOGGER).setLevel(logging.ERROR) <NEW_LINE> logging.getLogger(NEWSREAP_CLI).setLevel(logging.ERROR) <N... | A simple function one can use to set the verbosity of
the app. | 625941d67cff6e4e81117bb0 |
def test_present(reg_vars): <NEW_LINE> <INDENT> expected = { "comment": "Added {} to {}".format(reg_vars.vname, reg_vars.name), "changes": { "reg": { "Added": { "Inheritance": True, "Perms": {"Deny": None, "Grant": None}, "Value": reg_vars.vdata, "Key": reg_vars.name, "Owner": None, "Entry": reg_vars.vname, } } }, "nam... | Test reg.present | 625941d63cc13d1c6d3c75a5 |
def test_get_queues_from_config(self): <NEW_LINE> <INDENT> queue_config = tempfile.NamedTemporaryFile(delete=True) <NEW_LINE> queue_config.write(self.test_string) <NEW_LINE> queue_config.seek(0) <NEW_LINE> queues = queue_info.QueueInfo._get_queues_from_config( queue_config.name, queue_info.TaskQueue) <NEW_LINE> queue_c... | Success case for get_queues_from_config.
Don't have failure case. If fails, fails loudly. | 625941d67cff6e4e81117bb1 |
def write_to_file(path, header, data): <NEW_LINE> <INDENT> new_line = '\n' <NEW_LINE> with open(path,'w') as out_file: <NEW_LINE> <INDENT> writer = csv.writer(out_file, delimiter='\t') <NEW_LINE> writer.writerows([header]) <NEW_LINE> writer.writerows(zip(*data)) <NEW_LINE> <DEDENT> print("[INFO] finished writing to: {}... | This function write the provided data (column wise) to
the specified file path
:param path: The output path of the file
:param header: The file header
:param data: The data (nested list in which each item is a column) | 625941d6566aa707497f4791 |
def check_for_regex(item, rxTest, errorHandler=None, checkWordform=False): <NEW_LINE> <INDENT> if rxTest.field == 'stem' or rxTest.field == 'prev': <NEW_LINE> <INDENT> if not rxTest.perform(item.stem): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> elif rxTest.field == 'paradigm': <NEW_LINE> <INDENT> if ... | Perform the given RegexTest against the given item (SubLexeme or Wordform). | 625941d630dc7b7665901b90 |
def set_resources_quota_usage_dirty(context, resources, tenant_id, dirty=True): <NEW_LINE> <INDENT> query = common_db_api.model_query(context, quota_models.QuotaUsage) <NEW_LINE> query = query.filter_by(tenant_id=tenant_id) <NEW_LINE> if resources: <NEW_LINE> <INDENT> query = query.filter(quota_models.QuotaUsage.resour... | Set quota usage dirty bit for a given tenant and multiple resources.
:param resources: list of resource for which the dirty bit is going
to be set
:param tenant_id: tenant identifier
:param dirty: the desired value for the dirty bit (defaults to True)
:returns: the number of records for which the bit... | 625941d673bcbd0ca4b2c2a1 |
def getChannelHistory(chanid, token, latest=0): <NEW_LINE> <INDENT> ch_payload = {"token": token, "channel": chanid, "latest": latest} <NEW_LINE> chan_history = [] <NEW_LINE> get_more = True <NEW_LINE> while get_more: <NEW_LINE> <INDENT> hist_dict = getRequest(ch_hist_url, ch_payload) <NEW_LINE> chan_history.extend(his... | For a given channel ID, returns a string JSON object of channel history and time period | 625941d6e1aae11d1e749ee4 |
def shouldAdvance(self, queue, processes_running, processors): <NEW_LINE> <INDENT> for i in range(len(processes_running)): <NEW_LINE> <INDENT> queue.insert(0, processes_running[i]) <NEW_LINE> queue[0].execution_time = 0 <NEW_LINE> processes_running[i] = queue.pop() <NEW_LINE> processes_running[i].timesRun += 1 | Checks if a processor should kick out a process and
advance the queue. Default implementation only advances when the process
running finishes. | 625941d621bff66bcd684b7c |
def output(self, mode, msg): <NEW_LINE> <INDENT> kwargs = self.output_dict.get('kwargs-%s' % mode, self.output_dict['kwargs-error']) <NEW_LINE> func = self.output_dict.get(mode, self.output_dict['error']) <NEW_LINE> func(msg, **kwargs) | Generic output module which calls the mapped functions
from the class's init.
@param mode: string, one of ['info', 'error']
@param msg: string | 625941d666656f66f7cbc3d7 |
def pickup_object(self, collision_map_processing_msg, which_arm, index = 0, desired_approach_distance = 0.2, min_approach_distance = 0.05, lift_desired_distance = 0.1, lift_min_distance = 0.05, wait = rospy.Duration()): <NEW_LINE> <INDENT> pickup_goal = PickupGoal() <NEW_LINE> pickup_goal.target = collision_map_process... | Picks up a previously detected object
@param collision_map_processing_msg: The message resulting from calling
a TabletopCollisionMapProcessing service.
@param index: The index of the object to grasp, if more than one
@param which_arm: left_arm or right_arm
@param desired_approach_distance: how far the pre-grasp shoul... | 625941d60fa83653e46571e6 |
def compile(self, optim = None): <NEW_LINE> <INDENT> optimizer = optim if optim != None else SGD() <NEW_LINE> units = self.model[0].units <NEW_LINE> for layer in self.model[1:]: <NEW_LINE> <INDENT> if type(layer) is Dense: <NEW_LINE> <INDENT> layer.init_weights(units) <NEW_LINE> layer.optim = deepcopy(optimizer) <NEW_L... | Initialize weights and set optimizer | 625941d6b7558d58953c513d |
def TrafficTransDataRailway(self, indicID='', indicName='', beginDate='', endDate='', field=''): <NEW_LINE> <INDENT> code, result = self.client.getData(vs.TRAFFICTRANSDATARAILWAY%(indicID, indicName, beginDate, endDate, field)) <NEW_LINE> return _ret_data(code, result) | 包含交通运输行业中铁路运输数据,如铁路旅客、货物周转量等,具体指标可参见API文档;历史数据从1983年12月开始,数据按月更新。 | 625941d6e76e3b2f99f3aa34 |
def __init__(self, corners, order=0, chaos=0): <NEW_LINE> <INDENT> self.order = order <NEW_LINE> self.chaos = chaos <NEW_LINE> self.heights = list(map(float, corners)) <NEW_LINE> self.sub_squares = [] <NEW_LINE> self.random = gauss(0, 5) <NEW_LINE> self.random_scalar = self.chaos / (1 + self.order ** 2) <NEW_LINE> if s... | Data structure for squares in the Diamond Square Algorithm
:param a: Top left corner height
:param b: Top right corner height
:param c: Bottom left corner height
:param d: Bottom right corner height
:param order: Order of recursion depth
:param chaos: Amount of chaos to induce | 625941d6460517430c3943ad |
def __init__(self): <NEW_LINE> <INDENT> self.tfBuffer = tf2_ros.Buffer() <NEW_LINE> listen = tf2_ros.TransformListener(self.tfBuffer) | Will maintain a buffer of transforms | 625941d68e7ae83300e4b1f8 |
def error(self, *args, **kwargs): <NEW_LINE> <INDENT> self.logger.error(*args, **kwargs) | Wrapper for logging.error | 625941d6ad47b63b2c50a1ab |
def test_remove_all_versions_recursive_on_subdir(self): <NEW_LINE> <INDENT> bucket_uri = self.CreateVersionedBucket() <NEW_LINE> k1_uri = bucket_uri.clone_replace_name('dir/foo') <NEW_LINE> k2_uri = bucket_uri.clone_replace_name('dir/foo2') <NEW_LINE> k1_uri.set_contents_from_string('bar') <NEW_LINE> k2_uri.set_content... | Test that 'rm -r' works on subdir. | 625941d6a219f33f34628b93 |
def NaNs( N ): <NEW_LINE> <INDENT> return np.full( N, np.nan ) | Create a 1d array of NaNs of size N | 625941d6379a373c97cfad72 |
def get_id_and_signature(url): <NEW_LINE> <INDENT> components = None if not url else CHECKIN_URL.search(url) <NEW_LINE> if not components: <NEW_LINE> <INDENT> return (None, None) <NEW_LINE> <DEDENT> return components.groups() | Potentially extract checkin id and signature from `url`. | 625941d645492302aab5e4f1 |
def model_accuracy(X_train, X_test, g, d): <NEW_LINE> <INDENT> noise_train = np.random.uniform(-1, 1, size = (X_train.shape[0], 3)) <NEW_LINE> noise_test = np.random.uniform(-1, 1, size = (X_test.shape[0], 3)) <NEW_LINE> data_generated_train = g.predict(noise_train, verbose = 0) <NEW_LINE> data_generated_test = g.predi... | Function computing a single metrics of the GAN approach, to determine
if we save the model or not | 625941d6cc40096d61595b7c |
def test_get_user_from_confirmation_token_bad_or_wrong_token(self): <NEW_LINE> <INDENT> s = Serializer(current_app.config['SECRET_KEY']) <NEW_LINE> wrongtoken = s.dumps({'whee': 'beep!'}) <NEW_LINE> with pytest.raises(KeyError): <NEW_LINE> <INDENT> get_user_from_confirmation_token(wrongtoken) <NEW_LINE> <DEDENT> with p... | get_user_from... should raise exception with bad/wrong token. | 625941d6c432627299f04e73 |
def __init__(self, force_run=None, policy=None, report_id=None, update=None): <NEW_LINE> <INDENT> self._force_run = None <NEW_LINE> self._policy = None <NEW_LINE> self._report_id = None <NEW_LINE> self._update = None <NEW_LINE> self.discriminator = None <NEW_LINE> if force_run is not None: <NEW_LINE> <INDENT> self.forc... | JobJobAvscanParams - a model defined in Swagger | 625941d61f037a2d8b946429 |
def findRightInterval(self, intervals): <NEW_LINE> <INDENT> l = sorted([(e.start, i) for (i, e) in enumerate(intervals)]) <NEW_LINE> rec = [] <NEW_LINE> for interval in intervals: <NEW_LINE> <INDENT> r = self.find_right(l, interval) <NEW_LINE> rec.append(l[r][1] if r < len(l) else -1) <NEW_LINE> <DEDENT> return rec | :type intervals: List[Interval]
:rtype: List[int] | 625941d6507cdc57c6306f0a |
def test_return_available_window_with_next_block(self): <NEW_LINE> <INDENT> start = datetime(2018, 7, 20, 12, 0, 0) <NEW_LINE> end = datetime(2018, 7, 20, 13, 0, 0) <NEW_LINE> previous_block = Block(datetime(2018, 7, 20, 12, 0), datetime(2018, 7, 20, 12, 30), 'X') <NEW_LINE> next_block = Block(datetime(2018, 7, 20, 13,... | start end
12pm 1230 1pm
|------------|
block |------| |------|
result |-----| | 625941d6b5575c28eb68e22d |
def get_region_based_count(self, ontology_file, registered_brain_tif): <NEW_LINE> <INDENT> ontology_json = json.load(open(ontology_file, 'r')) <NEW_LINE> id2name = self._get_child_nodes_from_ontology(ontology_json, {}) <NEW_LINE> id2name[32767] = 'background' <NEW_LINE> background_region_number = 0 <NEW_LINE> registere... | Given a region ontology file and a registered annotated brain, this method returns the number of predicted cells in each region | 625941d632920d7e50b283fe |
def __init__(self, s, buffer_size=4096): <NEW_LINE> <INDENT> self.sock = s <NEW_LINE> self.buffer_size = buffer_size | Buffer a pre-created socket.
| 625941d663b5f9789fde7311 |
def mayaviFig(sceneName="Figure", plotExtents=[-10,10,-10,10,-10,10], crossAxes=True,oriAxes=True, colCrossAxes=True, fsize = (400, 350), bgcol=(0.97, 0.97, 0.97), fgcol=(0.07,0.07,0.07)): <NEW_LINE> <INDENT> mfig = mlab.figure(sceneName,bgcolor=bgcol,fgcolor=fgcol,size=fsize) <NEW_LINE> drawOriginAxes(plotExtents,colA... | Custom Mayavi figure. It returns the handle to the figure (scene in
Mayavi pipeline language)
Defaults:
plotExtents = [-10,10,-10,10,-10,10]
fsize = (400, 350)
bgcol=(0.97, 0.97, 0.97) #Color of the background
fgcol=(0.07,0.07,0.07) #color of all text annotation labels(axes, ori axes, scalar bar labels)
Please... | 625941d6004d5f362079a55e |
def syllabify_on_nucleus(transcription_arr): <NEW_LINE> <INDENT> syllables = [] <NEW_LINE> current_syllable = syllable.Syllable() <NEW_LINE> for phone in transcription_arr: <NEW_LINE> <INDENT> if current_syllable.has_nucleus and phone in VOWELS: <NEW_LINE> <INDENT> syllables.append(current_syllable) <NEW_LINE> current_... | First round of syllabification. Divide the word such that each syllable
starts with a vowel (except the first one, if the word starts with a consonant/consonants). | 625941d67b25080760e39684 |
def __str__(self): <NEW_LINE> <INDENT> return "EIE_E: " + str(self.identifier) + " " + self.op + " " + str(self.value) | to string | 625941d6e8904600ed9f215b |
def drstree_path(self): <NEW_LINE> <INDENT> if self.version!='NA': <NEW_LINE> <INDENT> version=self.version <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> version='v20110427' <NEW_LINE> <DEDENT> return self.variable.drstree_path().replace('latest',version) | Returns the drstree path for this particular version | 625941d63c8af77a43ae39cd |
def to_str(unicode_or_str): <NEW_LINE> <INDENT> if isinstance(unicode_or_str, unicode): <NEW_LINE> <INDENT> value = unicode_or_str.encode('utf-8') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> value = unicode_or_str <NEW_LINE> <DEDENT> return value | Takes str or unicode and always returns a str
:param unicode_or_str: str or unicode
:return: str | 625941d67b25080760e39685 |
def contentmenu_factories_available(self): <NEW_LINE> <INDENT> if hasattr(self._addContext(), 'portal_type') and self._addContext().portal_type in [ 'ARImport', 'Batch', 'Client', 'AnalysisRequest', 'Worksheet', 'Sample', 'AnalysisCategory', 'AnalysisProfile', 'ARTemplate', 'AnalysisService', 'AnalysisSpec', 'Attach... | These types will have their Add New... factories dropdown menu removed.
| 625941d67d43ff24873a2ecd |
def send_document( self, document: Union[FileInput, 'Document'], filename: str = None, caption: str = None, disable_notification: bool = False, reply_to_message_id: Union[int, str] = None, reply_markup: 'ReplyMarkup' = None, timeout: float = 20, parse_mode: str = None, thumb: FileInput = None, api_kwargs: JSONDict = No... | Shortcut for::
bot.send_message(update.effective_user.id, *args, **kwargs)
For the documentation of the arguments, please see :meth:`telegram.Bot.send_document`.
Returns:
:class:`telegram.Message`: On success, instance representing the message posted. | 625941d6e1aae11d1e749ee5 |
def check_game_over(self): <NEW_LINE> <INDENT> if (self._lives<=0 or self.check_alien_wave() or self.alien_defense_line()): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False | Returns True if game is over, returns False otherwise.
| 625941d630bbd722463cbff4 |
def Register(self): <NEW_LINE> <INDENT> pass | Register(self: Events) | 625941d656ac1b37e62643f9 |
def set_max_range(self, max_range=None): <NEW_LINE> <INDENT> if max_range is not None: <NEW_LINE> <INDENT> self._max_range = max_range | :param max_range:
:return: | 625941d69f2886367277aab8 |
def test_note_api_create(self): <NEW_LINE> <INDENT> data = TEST_NOTE.copy() <NEW_LINE> related_topics = [ create_topic(preferred_name='Testing', project=self.project, user=self.user), create_topic(preferred_name='Django', project=self.project, user=self.user) ] <NEW_LINE> data['related_topics'] = [ topic.get_absolute_u... | Creating a note within your own project is ok | 625941d6099cdd3c635f0e86 |
def preInitialization(self): <NEW_LINE> <INDENT> logging.info("preInitialization - instantiating pollers ...") <NEW_LINE> self._createPollers() <NEW_LINE> logging.info("preInitialization - starting pollers ...") <NEW_LINE> [poller.start() for poller in self._pollers] <NEW_LINE> logging.info("preInitialization - finishe... | Create poller instances running in threads. | 625941d6a8370b7717052acb |
def add(self, task: nidaqmx.Task) -> None: <NEW_LINE> <INDENT> if self._delay < 0: <NEW_LINE> <INDENT> pre = round(task.timing.samp_clk_rate * abs(self._delay)) <NEW_LINE> t = task.triggers.reference_trigger <NEW_LINE> if self._level is None: <NEW_LINE> <INDENT> t.cfg_dig_edge_ref_trig(pretrigger_samples=pre, **self._k... | Add this trigger to a task.
Parameters
----------
task : :class:`~nidaqmx.Task`
The task to add the trigger event to. | 625941d65f7d997b87174cc5 |
def has_media_reference(self, handle): <NEW_LINE> <INDENT> return False | Indicate if the object has a media references.
In the base class, no such references exist. Derived classes should
override this if they provide media references. | 625941d6956e5f7376d71098 |
def create_app(config_name=None) -> Flask: <NEW_LINE> <INDENT> app = Flask("__name__") <NEW_LINE> app.config.from_object(config[config_name]) <NEW_LINE> config[config_name].init_app(app) <NEW_LINE> from scorer.controller import prediction_app <NEW_LINE> app.register_blueprint(prediction_app) <NEW_LINE> _logger.debug("A... | Create a flask app instance. | 625941d69f2886367277aab9 |
def test_parse_file_url(self): <NEW_LINE> <INDENT> deserializer = WAPMD(self.device) <NEW_LINE> deserializer.logger.setLevel(logging.CRITICAL) <NEW_LINE> file_url = "http://hello.there.hi/resource.png" <NEW_LINE> expected = file_url <NEW_LINE> incoming_topic = ( WAPMD.FILE_URL_DOWNLOAD_INITIATE + WAPMD.DEVICE_PATH_DELI... | Test parse file url command. | 625941d657b8e32f524836c8 |
def mysum(num : int) -> int: <NEW_LINE> <INDENT> return reduce(lambda x, y: x+y, [int(x) for x in str(num)], 0) | сумма цифр числа | 625941d6be7bc26dc91cd82a |
def hashes_load(hashfilename): <NEW_LINE> <INDENT> hashes = [] <NEW_LINE> fmtsize = struct.calcsize(HASH_FMT) <NEW_LINE> with open(hashfilename, 'rb') as f: <NEW_LINE> <INDENT> magic = f.read(len(HASH_MAGIC)) <NEW_LINE> if magic != HASH_MAGIC: <NEW_LINE> <INDENT> raise IOError('%s is not a hash file (magic %s)' % (hash... | Read back a set of hashes written by hashes_save | 625941d6e76e3b2f99f3aa35 |
def debug(self, text): <NEW_LINE> <INDENT> if text: <NEW_LINE> <INDENT> self._logger.debug(text) | Logs debug message | 625941d64f6381625f114c68 |
def setUp(self): <NEW_LINE> <INDENT> self.card = Card.objects.create(suit=Card.CLUB, rank="jack") <NEW_LINE> self.card_high = Card.objects.create(suit=Card.CLUB, rank='queen') | Test that we get the proper ranking for a card | 625941d696565a6dacc8f8f7 |
def create_researcher(nes_id, owner): <NEW_LINE> <INDENT> return Researcher.objects.create(nes_id=nes_id, owner=owner) | Creates researcher model object that are used
in test classes that depends on it. | 625941d699fddb7c1c9de5bd |
def combine_current_new_differnce_dataframes_player_transaction(current_team_9cat_averages, new_team_9cat_averages, difference_team_9cat_averages): <NEW_LINE> <INDENT> current_team_9cat_averages[""] = CURRENT_COLUMN <NEW_LINE> new_team_9cat_averages[""] = NEW_COLUMN <NEW_LINE> difference_team_9cat_averages[""] = DIFFER... | @param current_team_9cat_averages:
@param new_team_9cat_averages:
@param difference_team_9cat_averages:
@return: | 625941d6aad79263cf390c70 |
def conductive_heat_flux(state, grad_t): <NEW_LINE> <INDENT> return _compute_conductive_heat_flux(grad_t, state.thermal_conductivity) | Compute the conductive heat flux, ($\mathbf{q}_{c}$).
The conductive heat flux is defined by:
.. math::
\mathbf{q}_{c} = -\kappa\nabla{T},
with thermal conductivity $\kappa$, and gas temperature $T$.
Parameters
----------
state: :class:`~mirgecom.gas_model.FluidState`
Full fluid conserved and thermal stat... | 625941d6b545ff76a8914042 |
def __init__(self, key, owner, **kwargs): <NEW_LINE> <INDENT> super(LengthWidthStage, self).__init__( key, owner, label='Length & Width Comparison', **kwargs) <NEW_LINE> self._paths = [] | Creates a new instance of LengthWidthStage. | 625941d6d10714528d5fff12 |
def inlist(code_version, col, inlist, **parm): <NEW_LINE> <INDENT> initialize_v_result = assignment('v_result', '\'NOT FOUND\'') + '\n' <NEW_LINE> return initialize_v_result + make_for_loop_exp(code_version, col, **parm) | Function to generate code for notation 'INLIST' | 625941d6cb5e8a47e48b7cd4 |
def get_heart_rate_data_for_day(self, day='today'): <NEW_LINE> <INDENT> return self.get_heart_rate_data_for_x_days(1, end_date=day) | Retrieves and saves a patient's heart-rate data (daily average and time-series data) for a given day.
:param day: date of interest in yyyy-MM-dd format as a string
:returns True or False whether or not the fetch was successful | 625941d6d164cc6175782f7b |
def ignore_done(obj): <NEW_LINE> <INDENT> obj = ignore_done_dict(obj) <NEW_LINE> obj = ignore_done_list(obj) <NEW_LINE> return obj | Uses ignore_done_list and ignore_done_dict to walk through a complex
dictionary object and sweep out any done values. | 625941d66e29344779a6283d |
def __init__(self, parent, *args, **kwargs): <NEW_LINE> <INDENT> super().__init__(parent, *args, **kwargs) <NEW_LINE> self.parent = parent <NEW_LINE> self.SetBackgroundColour(theme.background2_dark) <NEW_LINE> top_sizer = wx.BoxSizer(wx.HORIZONTAL) <NEW_LINE> image_panel = ImagePanel(self) <NEW_LINE> top_sizer.Add(imag... | Panel containing the anime/manga cover image, details, and synopsis | 625941d656ac1b37e62643fa |
def on_deselect(self): <NEW_LINE> <INDENT> for tile in self.divisions: <NEW_LINE> <INDENT> tile.group_selected = False <NEW_LINE> tile.selected = False | How to handle this tile being deselected | 625941d685dfad0860c3b088 |
def get_real_name(self): <NEW_LINE> <INDENT> dot = self.token_next_match(0, T.Punctuation, '.') <NEW_LINE> if dot is None: <NEW_LINE> <INDENT> return self.token_next_by_type(0, T.Name).value <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> next_ = self.token_next_by_type(self.token_index(dot), (T.Name, T.Wildcard)) <NEW_L... | Returns the real name (object name) of this identifier. | 625941d6851cf427c661a73a |
def JsonError(msg): <NEW_LINE> <INDENT> return JsonResponse({'error': msg}) | Shortcut wrapper for returning error message | 625941d6460517430c3943ae |
def map_agents(mod_agents_file, pm, source, save_csv=True): <NEW_LINE> <INDENT> with open(mod_agents_file, 'rb') as f: <NEW_LINE> <INDENT> mod_agents = pickle.load(f) <NEW_LINE> <DEDENT> print("Mapping %s" % mod_agents_file) <NEW_LINE> sites = [] <NEW_LINE> for ag_ix, ag in enumerate(mod_agents): <NEW_LINE> <INDENT> if... | Tabulate valid, invalid, and mapped sites from a set of Agents. | 625941d663f4b57ef0001342 |
def __get_trade_info(self): <NEW_LINE> <INDENT> trade_info_response = self.s.get(self.config['trade_info_page']) <NEW_LINE> search_result = re.search(r'var data = "([/=\w\+]+)"', trade_info_response.text) <NEW_LINE> if not search_result: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> need_data_index = 0 <NEW_LINE... | 请求页面获取交易所需的 uid 和 password | 625941d6be383301e01b56b0 |
def send(self, type, data, prio: Priority = Priority.NORMAL): <NEW_LINE> <INDENT> frame = Frame() <NEW_LINE> frame.type = type <NEW_LINE> frame.request = False <NEW_LINE> frame.priority = prio <NEW_LINE> self._safely_push_frame(frame) | Put a frame on the bus.
:param type:
:param data:
:param prio:
:return: | 625941d657b8e32f524836c9 |
def run_migrations_online(): <NEW_LINE> <INDENT> engine = db_engine <NEW_LINE> connection = engine.connect() <NEW_LINE> context.configure( connection=connection, target_metadata=target_metadata ) <NEW_LINE> try: <NEW_LINE> <INDENT> with context.begin_transaction(): <NEW_LINE> <INDENT> context.run_migrations() <NEW_LINE... | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context. | 625941d6711fe17d82542595 |
def __init__(self, commands_file='', logger=None): <NEW_LINE> <INDENT> super(self.__class__, self).__init__(logger) <NEW_LINE> self.commands_file = commands_file <NEW_LINE> self.commands = REODelimitedFile(self.commands_file, ',') <NEW_LINE> self.str_vars_exist = True <NEW_LINE> config[BATCH_FILE] = commands_file <NEW_... | Class Constructor
:param commands_file: Commands file to process. | 625941d607f4c71912b116b1 |
def _pull_commits(self, commits): <NEW_LINE> <INDENT> opts = GLib.Variant('a{sv}', { 'refs': GLib.Variant('as', commits), 'depth': GLib.Variant('i', 0), 'inherit-transaction': GLib.Variant('b', True), 'disable-static-deltas': GLib.Variant('b', True), }) <NEW_LINE> progress = OSTree.AsyncProgress.new() <NEW_LINE> progre... | Pull commits from repo
The caller is responsible for managing the repository transaction. | 625941d671ff763f4b5498bb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.