query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Outputs wiener filtered data in ell space, done with the messenger method, given the input data. | def wiener_filter_data(self, data):
# set up fields
t = np.copy(data)
t[self.mask.bad_pix] = hp.UNSEEN
t[self.mask.good_pix] *= self.weights_map[self.mask.good_pix]
tlm = hp.map2alm(t, self.params.lmax, iter=0)
# get cooling schedule
lamb_list = self.cs.lamb_list
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_stdout(self, data):\n filt, handler = self.filter[-1]\n data, filtered = filt.filter(data)\n self._write(pty.STDOUT_FILENO, data)\n if filtered:\n self.log(\"Filter matched %d bytes\" % len(filtered))\n self.filter.pop()\n assert callable(handl... | [
"0.5489444",
"0.5464298",
"0.5392203",
"0.5341291",
"0.5334053",
"0.53160447",
"0.5298067",
"0.5285309",
"0.52490765",
"0.5215759",
"0.5203446",
"0.5172595",
"0.51572376",
"0.5100819",
"0.50922024",
"0.5080058",
"0.5060283",
"0.50591666",
"0.50544244",
"0.5047716",
"0.5037467... | 0.61047363 | 0 |
NumKeyLite(array, args, kwargs) create key from numpy.ndarray instance other. The input array argument is converted to NumKeyLite instance. To do this, numpy.asarray(array) is called first. This may or may not copy the input argument. See its docs for more. Extra positional and keyword arguments are passed to numpy.asa... | def __init__(self, array, hashfcn=hash, *nparray_args, **nparray_kwargs):
self.hashfcn = hashfcn
self.__value = numpy.asarray(array, *nparray_args, **nparray_kwargs)
# As long as we're holding the reference to key, we make it read-only,
# so that the key cannot be modified.
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _snap.TIntKd_swiginit(self, _snap.new_TIntKd(*args))",
"def new_double(*args, **kwargs):\n return array.array(DOUBLE_TYPECODE, *args, **kwargs)",
"def __init__(self, *args):\n _snap.TIntKdV_swiginit(self, _snap.new_TIntKdV(*args))",
"def default_numpy_number_seri... | [
"0.5179693",
"0.49563912",
"0.48975325",
"0.48423356",
"0.48300934",
"0.48237067",
"0.48029009",
"0.4802763",
"0.47933465",
"0.4787353",
"0.47826627",
"0.4744171",
"0.47392824",
"0.47243193",
"0.47206625",
"0.47008213",
"0.47007015",
"0.46852645",
"0.4672209",
"0.4621101",
"0... | 0.53864396 | 0 |
Decoratorfactory that returns a decorator suitable for methods of a class that inherits ArrayMethodCacheMixin. | def memoized(cachetype=cachetools.LRUCache, cachesize=32,
keyfcn=NumKeyLite, *cargs, **ckwargs):
if cachetype is None:
# Do nothing, return identity decorator.
return lambda x: x
def decorator(arraymethod):
"""Method decorator to be returned by the enclosing factory functio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decorator(arraymethod):\n # Create the wrapper around the underlying method call. This wrapper\n # does the memoization using the cache just\n # retrieve-if-absent-create'd.\n mname = arraymethod.__name__\n\n @functools.wraps(arraymethod)\n def wrapper(self, arrayarg,... | [
"0.6681341",
"0.58848363",
"0.587852",
"0.5840141",
"0.57785785",
"0.57720476",
"0.57294285",
"0.5682057",
"0.56638294",
"0.5652158",
"0.5600774",
"0.5600774",
"0.5600774",
"0.5531577",
"0.54945475",
"0.5483946",
"0.5483419",
"0.54486316",
"0.54333705",
"0.54049057",
"0.54037... | 0.6301227 | 1 |
Callback for the IMU message When init is running, sums the messages to average the offsets When init is done, removes the offsets and publish a new imu message | def imu_callback(self, msg):
if self.init_running:
self.offset_a_x += msg.linear_acceleration.x
self.offset_a_y += msg.linear_acceleration.y
self.offset_a_z += msg.linear_acceleration.z
self.offset_w_x += msg.angular_velocity.x
self.offset_w_y += msg.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imu_callback(self, msg):\r\n self.imu_msg_buffer.append(msg)",
"def imu_callback(self, msg):\n self.mutex.acquire()\n\n self.ni[3] = msg.angular_rate.x\n self.ni[4] = msg.angular_rate.y\n self.ni[5] = msg.angular_rate.z\n\n self.eta2[0] = msg.orientation.roll\n ... | [
"0.6460932",
"0.6222663",
"0.57142854",
"0.5705133",
"0.53839874",
"0.5363519",
"0.5338955",
"0.5267891",
"0.52223825",
"0.51575685",
"0.51538664",
"0.51306134",
"0.511591",
"0.51148176",
"0.5107969",
"0.508895",
"0.50867367",
"0.5077075",
"0.50763875",
"0.50465786",
"0.50352... | 0.7152991 | 0 |
Sets the response_host of this TokenizeResponseSchema. | def response_host(self, response_host):
self._response_host = response_host | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host(self, host):\n\n self._host = host",
"def host(self, host):\n\n self._host = host",
"def host(self, host):\n\n self._host = host",
"def host(self, host):\n\n self._host = host",
"def set_service_host(self, host):\n self._api_host = f\"https://{host}\"",
"def pr... | [
"0.610538",
"0.610538",
"0.610538",
"0.610538",
"0.5974707",
"0.59690285",
"0.59583265",
"0.5887142",
"0.58620155",
"0.5853089",
"0.5722001",
"0.57052654",
"0.56126904",
"0.5610465",
"0.5561022",
"0.55445236",
"0.5503424",
"0.5479013",
"0.5446339",
"0.54091394",
"0.5376489",
... | 0.8352323 | 1 |
Sets the response_id of this TokenizeResponseSchema. | def response_id(self, response_id):
self._response_id = response_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def survey_response_id(self, survey_response_id):\n\n self._survey_response_id = survey_response_id",
"def response_status_id(self, response_status_id):\n\n self._response_status_id = response_status_id",
"def rc_response_sets_id(self, rc_response_sets_id):\n\n self._rc_response_sets_id = ... | [
"0.7190857",
"0.7133049",
"0.64617866",
"0.5752024",
"0.5752024",
"0.56953293",
"0.5678653",
"0.5678653",
"0.56637406",
"0.56487066",
"0.5554293",
"0.5545388",
"0.55333394",
"0.54893297",
"0.5440423",
"0.5322974",
"0.5306163",
"0.52734816",
"0.5243084",
"0.52299786",
"0.52274... | 0.80410653 | 0 |
Sets the decision of this TokenizeResponseSchema. | def decision(self, decision):
self._decision = decision | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_decision(self, decision, responder):\n self.responder = responder\n self.status = decision\n self.decision_datetime = timezone.now()\n self.save()",
"def set_response_variable(self, response_variable):\n\n transform, raw_variable = find_raw_variable(response_variable... | [
"0.5380883",
"0.51508623",
"0.49541798",
"0.49244145",
"0.48189366",
"0.48189",
"0.4771373",
"0.4761762",
"0.4729601",
"0.47003517",
"0.46950614",
"0.46551433",
"0.4600451",
"0.45887265",
"0.45847246",
"0.4554046",
"0.45415014",
"0.4537058",
"0.45308405",
"0.4477484",
"0.4472... | 0.61944234 | 0 |
Sets the authentication_methods of this TokenizeResponseSchema. | def authentication_methods(self, authentication_methods):
self._authentication_methods = authentication_methods | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_method(self, authentication_method):\n\n self._authentication_method = authentication_method",
"def methods(self, methods):\n\n self._methods = methods",
"def for_authenticate_only(self):\n self.token['type'] = 'auth'\n\n return self",
"def set_requests_auth(sel... | [
"0.609965",
"0.5883241",
"0.5729277",
"0.55534893",
"0.53841305",
"0.5383745",
"0.5225265",
"0.52036256",
"0.5090709",
"0.50764024",
"0.50543785",
"0.50277215",
"0.50273085",
"0.50180805",
"0.49973318",
"0.49967802",
"0.49876738",
"0.49357298",
"0.49169585",
"0.48832485",
"0.... | 0.8070846 | 0 |
Sets the token_unique_reference of this TokenizeResponseSchema. | def token_unique_reference(self, token_unique_reference):
self._token_unique_reference = token_unique_reference | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_reference(self, unique_reference):\n\n self._unique_reference = unique_reference",
"def pan_unique_reference(self, pan_unique_reference):\n\n self._pan_unique_reference = pan_unique_reference",
"def token_uri(self, token_uri):\n\n self._token_uri = token_uri",
"def token(self,... | [
"0.66069114",
"0.54265714",
"0.52031356",
"0.51464486",
"0.51464486",
"0.5061283",
"0.50280356",
"0.49233103",
"0.48930898",
"0.48925546",
"0.48611587",
"0.48317307",
"0.47713757",
"0.47481495",
"0.4733137",
"0.47289088",
"0.47012594",
"0.46930283",
"0.46761343",
"0.46750033",
... | 0.82809067 | 0 |
Sets the pan_unique_reference of this TokenizeResponseSchema. | def pan_unique_reference(self, pan_unique_reference):
self._pan_unique_reference = pan_unique_reference | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_unique_reference(self, token_unique_reference):\n\n self._token_unique_reference = token_unique_reference",
"def unique_reference(self, unique_reference):\n\n self._unique_reference = unique_reference",
"def pan_sequence_number(self, pan_sequence_number):\n\n self._pan_sequence_n... | [
"0.6234564",
"0.611241",
"0.55672145",
"0.5140222",
"0.4986098",
"0.49174616",
"0.48529235",
"0.4787108",
"0.4750052",
"0.4643384",
"0.46425733",
"0.46316928",
"0.46316928",
"0.45758823",
"0.4542411",
"0.4542411",
"0.45124412",
"0.45003307",
"0.4466403",
"0.44440213",
"0.4410... | 0.81144524 | 0 |
Sets the product_config of this TokenizeResponseSchema. | def product_config(self, product_config):
self._product_config = product_config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(self, product):\n\n self._product = product",
"def product(self, product):\n\n self._product = product",
"def product_version(self, product_version):\n\n self._product_version = product_version",
"def product_id(self, product_id):\n\n self._product_id = product_id",
... | [
"0.6096053",
"0.6096053",
"0.60652715",
"0.59610796",
"0.59610796",
"0.59389794",
"0.5865274",
"0.581178",
"0.5763602",
"0.5661054",
"0.5498623",
"0.54238635",
"0.5404442",
"0.53621626",
"0.53515965",
"0.5347389",
"0.5290099",
"0.5210525",
"0.5210525",
"0.5210416",
"0.5190162... | 0.80587953 | 0 |
Sets the token_info of this TokenizeResponseSchema. | def token_info(self, token_info):
self._token_info = token_info | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_token(self, token):\n # type: (Token) -> None\n self.token = token\n self._token_header = \"Bearer \" + token[\"access_token\"]",
"def set_maptoken(self, token):\n self._data['maptoken'] = token",
"def token(self, token):\n\n self._token = token",
"def token(self, t... | [
"0.6609939",
"0.62733406",
"0.61689615",
"0.61689615",
"0.6141988",
"0.6096179",
"0.5885897",
"0.57662356",
"0.5666246",
"0.5639956",
"0.5639956",
"0.5585643",
"0.555811",
"0.5554539",
"0.54502577",
"0.5446071",
"0.54024565",
"0.5384385",
"0.53712815",
"0.53652114",
"0.533296... | 0.802484 | 0 |
Sets the token_detail of this TokenizeResponseSchema. | def token_detail(self, token_detail):
self._token_detail = token_detail | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_info(self, token_info):\n\n self._token_info = token_info",
"def set_token(self, token):\n # type: (Token) -> None\n self.token = token\n self._token_header = \"Bearer \" + token[\"access_token\"]",
"def error_detail(self, error_detail):\n\n self._error_detail = err... | [
"0.63697726",
"0.5925274",
"0.5838624",
"0.5797187",
"0.5791003",
"0.5791003",
"0.5643845",
"0.56285834",
"0.55679846",
"0.55679846",
"0.55679846",
"0.55239844",
"0.52082306",
"0.51737744",
"0.5173633",
"0.5173558",
"0.5164342",
"0.5164342",
"0.5126371",
"0.5104957",
"0.50998... | 0.8307674 | 0 |
Synchronously waits until the cluster reaches the provided status. Upon timeout a LaunchError is thrown. | def wait_for_status(es, expected_cluster_status):
logger.info("Wait for cluster status [%s]" % expected_cluster_status)
start = time.perf_counter()
reached_cluster_status, relocating_shards = _do_wait(es, expected_cluster_status)
stop = time.perf_counter()
logger.info("Cluster reached status [%s] wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_vsan_cluster_status(self, cluster_id, status):\n waiters.wait_for_vsan_cluster_status(self, cluster_id, status)",
"def _wait_until_job_starts_on_cluster(self) -> Optional[float]:\n status = None\n job_checking_retry_cnt = 0\n while job_checking_retry_cnt < MAX_JOB_CHECKIN... | [
"0.7208825",
"0.68414533",
"0.6651432",
"0.6453654",
"0.61644745",
"0.61434287",
"0.61178726",
"0.60923296",
"0.608488",
"0.6030005",
"0.6023809",
"0.5960995",
"0.5952244",
"0.5947532",
"0.59441376",
"0.59317267",
"0.58664024",
"0.5864378",
"0.5854844",
"0.5745892",
"0.573860... | 0.6863995 | 1 |
Calculates global throughput based on samples gathered from multiple load generators. | def calculate_global_throughput(samples, bucket_interval_secs=1):
samples_per_task = {}
# first we group all warmup / measurement samples by operation.
for sample in samples:
k = sample.task
if k not in samples_per_task:
samples_per_task[k] = []
samples_per_task[k].append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_sampling(numSamples, localDevices=None, numChainsPerDevice=1):\n\n global globNumSamples\n\n # Determine number of samples per process\n samplesPerProcess = numSamples // commSize\n\n if rank < numSamples % commSize:\n samplesPerProcess += 1\n\n if localDevices is None:\n\n ... | [
"0.58395964",
"0.58128244",
"0.57595015",
"0.55879265",
"0.5453143",
"0.5441605",
"0.5434401",
"0.5383769",
"0.5374519",
"0.5318638",
"0.5299533",
"0.52898085",
"0.52715355",
"0.52604645",
"0.5259625",
"0.524881",
"0.5220609",
"0.5177333",
"0.5171854",
"0.51618403",
"0.515931... | 0.6661292 | 0 |
Calculates an allocation matrix consisting of two dimensions. The first dimension is the client. The second dimension are the task | def allocations(self):
max_clients = self.clients
allocations = [None] * max_clients
for client_index in range(max_clients):
allocations[client_index] = []
join_point_id = 0
# start with an artificial join point to allow master to coordinate that all clients start at ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_cost_matrix(self): \n cost_matrix = np.zeros((self.N+self.M, self.N+self.M))\n\n for i in range(self.N):\n for j in range(self.M):\n cost_matrix[i, j] = self.substitute_cost(i, j)\n \n for i in range(self.M):\n for j in range(self.M):... | [
"0.6448241",
"0.6228586",
"0.5966818",
"0.5957692",
"0.5885746",
"0.58736086",
"0.58492595",
"0.58042854",
"0.5770307",
"0.57545084",
"0.5658075",
"0.5649128",
"0.5618056",
"0.55819154",
"0.5560718",
"0.55199283",
"0.54979736",
"0.5496861",
"0.54868776",
"0.546959",
"0.546724... | 0.6429781 | 1 |
Calculates a flat list of all unique operations that are run in between join points. | def operations_per_joinpoint(self):
ops = []
current_ops = set()
allocs = self.allocations
# assumption: the shape of allocs is rectangular (i.e. each client contains the same number of elements)
for idx in range(0, len(allocs[0])):
for client in range(0, self.client... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOperations(tasks):\n uniqueOps = []\n for t in tasks:\n if t.operation not in uniqueOps:\n uniqueOps.append(t.operation)\n return uniqueOps",
"def fanouts(op):\n ops = set()\n for t in op.outputs:\n for op in t.consumers():\n ops |= {op}\n return ops",... | [
"0.5933223",
"0.5763123",
"0.55463856",
"0.5331518",
"0.53306586",
"0.53206986",
"0.53206986",
"0.5270969",
"0.52656543",
"0.52622086",
"0.5222275",
"0.51407045",
"0.51267153",
"0.5083262",
"0.50792116",
"0.5062097",
"0.5057217",
"0.50348175",
"0.50258017",
"0.50079",
"0.4988... | 0.71224505 | 0 |
Calculates a client's schedule for a given task. | def schedule_for(current_track, task, client_index):
op = task.operation
num_clients = task.clients
sched = scheduler.scheduler_for(task.schedule, task.params)
logger.info("Choosing [%s] for [%s]." % (sched, task))
runner_for_op = runner.runner_for(op.type)
params_for_op = track.operation_parame... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_task(self, task, date):\n return self.connection.schedule_task(task, date)",
"def _schedule(self,task_dict):\n times = [time(), None, None, None] # (schedule timestamp, execution timestamp, stop timestamp, get timestamp)\n result_id = self._extract_features.remote(self, times) #... | [
"0.59409654",
"0.59177864",
"0.5825994",
"0.5577229",
"0.550346",
"0.5396048",
"0.5332319",
"0.53288907",
"0.5304861",
"0.5264537",
"0.52540666",
"0.5232967",
"0.5224693",
"0.50529546",
"0.5033008",
"0.5014159",
"0.500251",
"0.4994591",
"0.49813053",
"0.49754286",
"0.4955319"... | 0.6271675 | 0 |
Calculates the necessary schedule based on a given number of iterations. | def iteration_count_based(sched, warmup_iterations, iterations, runner, params):
next_scheduled = 0
total_iterations = warmup_iterations + iterations
if total_iterations == 0:
raise exceptions.RallyAssertionError("Operation must run at least for one iteration.")
for it in range(0, total_iteratio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_schedules(list_uses, archetype_schedules, occupancy, archetype_values):\n\n # set up schedules to be defined and empty dictionary\n schedule_labels = ['people', 've', 'Qs', 'X', 'Ea', 'El', 'Epro', 'Ere', 'Ed', 'Vww', 'Vw', 'Qhpro']\n schedules = {}\n\n # define the archetypal schedule type to... | [
"0.64414954",
"0.6243073",
"0.60540605",
"0.59359616",
"0.5856404",
"0.5851014",
"0.580083",
"0.56817377",
"0.567007",
"0.56667936",
"0.56661534",
"0.5665359",
"0.5643789",
"0.56227446",
"0.56170315",
"0.5609368",
"0.55854475",
"0.55842614",
"0.55608046",
"0.5535597",
"0.5534... | 0.6302282 | 1 |
Returns a bool indicating whether the passed version matches the minimum required version for the given feature. | def _matches_feature(feature: ContractFeature, version: Optional[str]) -> bool:
if version is None:
# contracts_version == None means the stock version in development.
return True
return CONTRACT_FEATURE_VERSIONS[feature].match(Version(version)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supported_version(version, minimum, maximum):\n if minimum and StrictVersion(version) < StrictVersion(minimum):\n return False\n\n if maximum and StrictVersion(version) > StrictVersion(maximum):\n return False\n\n return True",
"def is_version_sufficient(self, min_version):\n \n... | [
"0.7003667",
"0.6983828",
"0.6628169",
"0.64035785",
"0.63591325",
"0.63319844",
"0.6319353",
"0.63074565",
"0.6189644",
"0.61790854",
"0.61719733",
"0.61530966",
"0.61475015",
"0.6113066",
"0.6089206",
"0.6076634",
"0.6063754",
"0.6043555",
"0.6041803",
"0.6030734",
"0.60298... | 0.78464067 | 0 |
Test no heartbeat received. | async def test_no_hb(self):
await self.async_setup()
pyinsteon.managers.heartbeat_manager.HB_CHECK_BUFFER = 1
self._hb_mgr = pyinsteon.managers.heartbeat_manager.HeartbeatManager(
self._address, self._group, 0
)
await asyncio.sleep(1.1)
assert self._heartbeat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_heartbeatDisabled(self):\n self.assertIdentical(self.client._heartbeat, None)\n self.client.heartbeatInterval = None\n self.client.irc_RPL_WELCOME(\"foo\", [])\n self.assertIdentical(self.client._heartbeat, None)",
"def test_heartbeat(self):\n pass",
"def check_heart... | [
"0.8121816",
"0.7763661",
"0.7393462",
"0.7228855",
"0.71622515",
"0.6988598",
"0.69775856",
"0.6857906",
"0.68550146",
"0.6835265",
"0.67907804",
"0.6714012",
"0.6697501",
"0.66401714",
"0.659621",
"0.65663195",
"0.65090305",
"0.64288",
"0.6420232",
"0.6372148",
"0.6368841",... | 0.77683955 | 1 |
Sets the speed of the left and right motors to the given speed. The speed should be in the range of [0, 255]. Sleeps for 0.1 seconds in between setting the left and right motor speeds. | def set_speed(speed):
if speed >255:
speed =255
elif speed <0:
speed =0
set_left_speed(speed)
#time.sleep(.1)
set_right_speed(speed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self, speed=1):\n self.set_motor(self.left_motor, 'left', speed)\n self.set_motor(self.right_motor, 'right', speed)\n time.sleep(0.5)",
"def set_left_speed(speed):\n if speed >255:\n speed =255\n elif speed <0:\n speed =0\n return write_i2c_block(ADDRESS,set_l... | [
"0.78023344",
"0.7445923",
"0.7445923",
"0.73864216",
"0.72845906",
"0.726722",
"0.7251113",
"0.7161834",
"0.71615404",
"0.7146234",
"0.7146234",
"0.7104322",
"0.7103598",
"0.70458686",
"0.69860035",
"0.6962281",
"0.69477236",
"0.69449216",
"0.69364804",
"0.6886092",
"0.68427... | 0.8324373 | 0 |
Sets the speed of the left motor. The speed should be in the range of [0, 255]. Returns 1 if the motor speed change fails. | def set_left_speed(speed):
if speed >255:
speed =255
elif speed <0:
speed =0
return write_i2c_block(ADDRESS,set_left_speed_cmd+[speed,0,0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left(self, speed):\n self.pwm_right.ChangeDutyCycle(0)\n self.pwm_left.ChangeDutyCycle(speed)",
"def set_speed(speed):\n if speed >255:\n speed =255\n elif speed <0:\n speed =0\n set_left_speed(speed)\n #time.sleep(.1)\n set_right_speed(speed)",
"def forward_left(... | [
"0.7700109",
"0.76205206",
"0.7412373",
"0.72926587",
"0.7235961",
"0.7044568",
"0.7021893",
"0.69868207",
"0.69657636",
"0.69270515",
"0.6876808",
"0.6876808",
"0.68469834",
"0.68361795",
"0.67879915",
"0.677919",
"0.67780375",
"0.67594516",
"0.6752442",
"0.66976255",
"0.669... | 0.8075815 | 1 |
Sets the speed of the right motor. The speed should be in the range of [0, 255]. Returns 1 if the motor speed change fails. | def set_right_speed(speed):
if speed >255:
speed =255
elif speed <0:
speed =0
return write_i2c_block(ADDRESS,set_right_speed_cmd+[speed,0,0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_speed(speed):\n if speed >255:\n speed =255\n elif speed <0:\n speed =0\n set_left_speed(speed)\n #time.sleep(.1)\n set_right_speed(speed)",
"def change_motor_speed(self, speed=0.0):\r\n if not self.enabled:\r\n self.set_neutral(braked=False)\r\n ... | [
"0.7731893",
"0.7696117",
"0.76720047",
"0.76159036",
"0.75545514",
"0.7524931",
"0.7504935",
"0.7452765",
"0.7441803",
"0.7439142",
"0.7396335",
"0.7354837",
"0.726273",
"0.72002035",
"0.7173224",
"0.7173224",
"0.71548945",
"0.71335036",
"0.70881885",
"0.7053561",
"0.7052570... | 0.795676 | 1 |
Sets the speed of the left motor. The speed should be in the range of [0, 255]. Returns 1 if the motor speed change fails. | def set_left_speed(speed):
if speed >255:
speed =255
elif speed <0:
speed =0
return write_i2c_block(ADDRESS,set_left_speed_cmd+[speed,0,0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left(self, speed):\n self.pwm_right.ChangeDutyCycle(0)\n self.pwm_left.ChangeDutyCycle(speed)",
"def set_speed(speed):\n if speed >255:\n speed =255\n elif speed <0:\n speed =0\n set_left_speed(speed)\n #time.sleep(.1)\n set_right_speed(speed)",
"def forward_left(... | [
"0.76990485",
"0.76227975",
"0.74126786",
"0.72940695",
"0.723603",
"0.7043412",
"0.7025084",
"0.6987145",
"0.6968445",
"0.6930331",
"0.6878611",
"0.6878611",
"0.68473905",
"0.6835755",
"0.67874986",
"0.67820156",
"0.6777819",
"0.6763273",
"0.67553306",
"0.6699774",
"0.669506... | 0.8076513 | 0 |
Sets the speed of the right motor. The speed should be in the range of [0, 255]. Returns 1 if the motor speed change fails. | def set_right_speed(speed):
if speed >255:
speed =255
elif speed <0:
speed =0
return write_i2c_block(ADDRESS,set_right_speed_cmd+[speed,0,0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_speed(speed):\n if speed >255:\n speed =255\n elif speed <0:\n speed =0\n set_left_speed(speed)\n #time.sleep(.1)\n set_right_speed(speed)",
"def change_motor_speed(self, speed=0.0):\r\n if not self.enabled:\r\n self.set_neutral(braked=False)\r\n ... | [
"0.7731893",
"0.7696117",
"0.76720047",
"0.76159036",
"0.75545514",
"0.7524931",
"0.7504935",
"0.7452765",
"0.7441803",
"0.7439142",
"0.7396335",
"0.7354837",
"0.726273",
"0.72002035",
"0.7173224",
"0.7173224",
"0.71548945",
"0.71335036",
"0.70881885",
"0.7053561",
"0.7052570... | 0.795676 | 0 |
Checks that we're consistently running at 60 ticks/s. | def test_tick_rate(self):
history = self.history
fps = 60 # I know it's not frames but I find it easier to read than tps.
def get_time(history_item):
return history_item.game_tick_proto.GameInfo().SecondsElapsed()
def is_admissible(history_item):
return history... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_clocks(self) -> int:\n pass",
"def must_run(self):\r\n self.current_time = datetime.now()\r\n return all([self._minute(), self._hour(), self._day_of_month(), self._month(), self._day_of_week()])",
"def trigger(self):\n if self.timer is None or time.time() - self.last_try >... | [
"0.6439625",
"0.6252726",
"0.6111706",
"0.6087357",
"0.6052535",
"0.60162747",
"0.60071677",
"0.6004329",
"0.5976713",
"0.59697694",
"0.59691685",
"0.5926805",
"0.59260744",
"0.592052",
"0.5848709",
"0.5847624",
"0.58312494",
"0.58304274",
"0.5811613",
"0.5803207",
"0.5800268... | 0.6675983 | 0 |
Adds data to url. Data should be a list or tuple consisting of 2item | def addGETdata(url, data):
return url + '?' + urllib.urlencode(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_data(self, data):\n self.data = self.data + data",
"def add_data(self, data: List[dict]):\n raise NotImplementedError()",
"def add_data(self, data):\n self._data += data",
"def add_data(self, data):\n self.data = data",
"def append(self, data):\n self.data_lis... | [
"0.684323",
"0.6788979",
"0.67569935",
"0.6707727",
"0.6425773",
"0.6395899",
"0.6246503",
"0.61942405",
"0.6123122",
"0.6112333",
"0.61010677",
"0.59934676",
"0.596161",
"0.59553415",
"0.5948385",
"0.59133947",
"0.58285093",
"0.5776429",
"0.5745425",
"0.5723657",
"0.57041126... | 0.7192949 | 0 |
Takes a name like exam_20150128.pdf and returns 20150128.pdf which is the format that Xmr uses. | def normalizeFilenameToCommonDateFormat(filename):
rgx_date = re.search(r'(\d+)-(\d+)-(\d+)', filename)
if (rgx_date == None):
raise ValueError("Not interested in this file!")
year = rgx_date.group(1)
month = rgx_date.group(2)
day = rgx_date.group(3)
return "%s%s%s.pdf" % (year, m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_name_to_file_name(page_name):\n if page_name.endswith('.md') or page_name.endswith('.markdown'):\n return page_name\n return page_name + '.md'",
"def get_output_pdfname(pdf_name):\n\n # Since we use the pdf name as output filename (e.g. \"foo.pdf\") there\n # could be conflicts if two... | [
"0.67287767",
"0.65832454",
"0.63394296",
"0.6218128",
"0.61437064",
"0.61239153",
"0.6027333",
"0.59802127",
"0.5976775",
"0.5900234",
"0.5880146",
"0.5865507",
"0.58614683",
"0.5843099",
"0.58242625",
"0.57777953",
"0.57597464",
"0.5748331",
"0.5736142",
"0.5729173",
"0.570... | 0.6714254 | 1 |
Loads events data yaml file | def load_events(fich):
with fich.open() as fd_conf:
yaml_text = fd_conf.read()
conf = yaml.safe_load(yaml_text)
return yaml_text, conf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_events(self):\n command = '{0}'.format(\n os.path.join(self.datadir, 'monol_testA.evt'))\n hen.read_events.main(command.split())\n new_filename = self.first_event_file\n ev = hen.io.load_events(new_filename)\n assert hasattr(ev, 'header')\n assert ... | [
"0.6732955",
"0.6544107",
"0.6451484",
"0.64316",
"0.64136624",
"0.6410783",
"0.6367961",
"0.63107944",
"0.63100755",
"0.6308662",
"0.62172604",
"0.61343026",
"0.61211604",
"0.6112824",
"0.6101682",
"0.60651755",
"0.606097",
"0.6039743",
"0.6021246",
"0.6012363",
"0.5954735",... | 0.7538355 | 0 |
Create a file in `path` with content `text` | def save_file(path, text):
with path.open(mode='w') as f_stream:
f_stream.write(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_text_file(text, path):\n os.makedirs(os.path.dirname(path), exist_ok=True)\n with open(path, \"w\") as f:\n f.write(text)",
"def txtWrite(text, path, mode=\"w\"):\n dirMake(os.path.dirname(path))\n textFile = open(path, mode)\n textFile.close()",
"def create_file(path: Path, cont... | [
"0.8540395",
"0.8102859",
"0.8018981",
"0.7762343",
"0.7733981",
"0.7637607",
"0.7446907",
"0.7391051",
"0.73870933",
"0.7368893",
"0.73258084",
"0.7322873",
"0.7298298",
"0.7283397",
"0.72687566",
"0.72406983",
"0.723338",
"0.7189882",
"0.7131052",
"0.7115634",
"0.71132755",... | 0.82927257 | 1 |
Returns the actual version of youtubedl | def youtube_dl_version():
import pkg_resources
return pkg_resources.get_distribution("youtube-dl").version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_version(self):",
"def version(self):",
"def get_version():\n return magpy.get_version()",
"def get_version():\n\n with open('yubico/yubico_version.py', 'r') as f:\n match = VERSION_PATTERN.search(f.read())\n return match.group(1)",
"def get_version(self):\n return arbwav... | [
"0.62348336",
"0.6141164",
"0.61034447",
"0.5941352",
"0.59348905",
"0.58997494",
"0.5871692",
"0.58463037",
"0.5832502",
"0.5819035",
"0.5815244",
"0.57877034",
"0.57457024",
"0.57263017",
"0.569385",
"0.5688496",
"0.5665162",
"0.5659438",
"0.5659438",
"0.5648556",
"0.562384... | 0.64586157 | 0 |
Create new directories and conference file in pyvideo repository to add a new event | def create_dirs(self):
for new_directory in [self.event_dir, self.event_dir / 'videos']:
new_directory.mkdir(exist_ok=self.overwrite)
logger.debug('Dir {} created', new_directory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_create_event():\n data = request.get_json(force=True)\n if not data:\n return jsonify(**{'succeed': False, 'data': []})\n new_event = Event()\n new_event.data = data\n new_event.data['registrants'] = {email: False for email in new_event.data['registrants']}\n all_event[data['event... | [
"0.69179034",
"0.6370179",
"0.5998139",
"0.59141",
"0.590322",
"0.58751065",
"0.57564807",
"0.5747336",
"0.5655401",
"0.5610383",
"0.5609907",
"0.55262184",
"0.54948896",
"0.54372036",
"0.53920734",
"0.53760904",
"0.5373575",
"0.53668636",
"0.5328634",
"0.528751",
"0.52811027... | 0.6549668 | 1 |
Create category.json for the conference | def create_category(self): # , conf_dir, title):
category_file_path = self.event_dir / 'category.json'
category_data = {
'title': self.title,
}
category_data_text = json.dumps(category_data, **
JSON_FORMAT_KWARGS) + '\n'
save_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def easyCategory():\n return prepJSON(cs411_dash.easyCategory())",
"def add_categories_handler():\n rq = request.get_json()\n name = rq['name']\n picture = rq['picture']\n description = rq['description']\n category = addCategory(name, picture, description, g.user.id)\n return jsonify(categor... | [
"0.6681808",
"0.64873785",
"0.6258061",
"0.6256895",
"0.59745955",
"0.5965075",
"0.59421617",
"0.5941212",
"0.5859045",
"0.5848215",
"0.5845714",
"0.57973224",
"0.5767958",
"0.57416517",
"0.5718623",
"0.5716601",
"0.56976086",
"0.5630907",
"0.5620964",
"0.56165236",
"0.558047... | 0.7401774 | 0 |
Download youtube metadata corresponding to this event youtube lists | def download_video_data(self):
def scrape_url(url):
"""Scrape the video list, youtube_dl does all the heavy lifting"""
ydl_opts = {
"ignoreerrors": True, # Skip private and unavaliable videos
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_info(self, event):\n\n title, url = event.description.split(\"\\n\", 1)\n\n ytdl = YoutubeDL(self.YOUTUBE_DL_OPTIONS)\n try:\n info = await self.loop.run_in_executor(None, lambda: ytdl.extract_info(url, **self.YOUTUBE_DL_EXTRACT_OPTIONS))\n except DownloadError... | [
"0.6910188",
"0.6578394",
"0.62467515",
"0.6113745",
"0.6105808",
"0.60103685",
"0.60016453",
"0.600144",
"0.59874576",
"0.59844863",
"0.5904831",
"0.5891526",
"0.5872654",
"0.5864564",
"0.5851306",
"0.5834338",
"0.5815214",
"0.5776731",
"0.5763101",
"0.5761539",
"0.5760842",... | 0.70303667 | 0 |
Load video data form existing event video files | def load_video_data(self):
self.file_videos = [
Video.from_file(path, self)
for path in self.video_dir.glob('*.json')
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_video_data(self):\n if self.overwrite:\n # Erase old event videos\n for path in self.video_dir.glob('*.json'):\n path.unlink()\n for video in self.videos:\n video.save()",
"def onclick_load_video(self):\n video_source = select_file(\n ... | [
"0.6645899",
"0.6543385",
"0.6515621",
"0.64798486",
"0.62572676",
"0.61565137",
"0.61433256",
"0.6138817",
"0.60811174",
"0.6022243",
"0.59866077",
"0.5967924",
"0.59576726",
"0.5947624",
"0.59459805",
"0.58843154",
"0.58469665",
"0.58348954",
"0.57942754",
"0.5781785",
"0.5... | 0.7250237 | 0 |
Merge old video data when configured so | def merge_video_data(self):
if self.overwrite:
if self.wipe:
self.videos = self.youtube_videos
elif self.add_new_files or self.overwrite_fields:
old_videos = {
video.filename: video
for video in self.file_videos
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_video_data(self):\n if self.overwrite:\n # Erase old event videos\n for path in self.video_dir.glob('*.json'):\n path.unlink()\n for video in self.videos:\n video.save()",
"def merge(self, new_video, fields):\n merged_video = Video(sel... | [
"0.7066059",
"0.7032111",
"0.6201307",
"0.6085444",
"0.60070926",
"0.599688",
"0.58548707",
"0.5782042",
"0.5735686",
"0.57083267",
"0.5605703",
"0.55211353",
"0.5460723",
"0.5411573",
"0.5384754",
"0.53750867",
"0.5374354",
"0.5340819",
"0.5333001",
"0.5325647",
"0.53208685"... | 0.80573696 | 0 |
Save all event videos in PyVideo format | def save_video_data(self):
if self.overwrite:
# Erase old event videos
for path in self.video_dir.glob('*.json'):
path.unlink()
for video in self.videos:
video.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_video(self):\n # Release the video capture and \n # video write objects \n self.video.release()\n if self.record_video:\n self.video_result.release()\n print(\"The video was successfully saved\")",
"def save_video(self, video=None, fps=None):\r\n\r\n ... | [
"0.69763184",
"0.6546324",
"0.6485328",
"0.63934904",
"0.63397515",
"0.6280899",
"0.62786955",
"0.62674654",
"0.62673616",
"0.62341094",
"0.62274504",
"0.6136293",
"0.6113412",
"0.6102779",
"0.60443217",
"0.60026574",
"0.6002561",
"0.59859747",
"0.59802985",
"0.5979195",
"0.5... | 0.7811017 | 0 |
Create a new commit in pyvideo repository with the new event data | def create_commit(self, event_data_yaml):
os.chdir(str(self.repository_path))
sh.git.checkout(self.branch)
sh.git.add(self.event_dir)
message_body = (
'\n\nEvent config:\n~~~yaml\n{}\n~~~\n'.format(event_data_yaml)
+ '\nScraped with [pyvideo_scrape]'
+... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_commit(repo, cfg, model, developer_gen, date):\n model, kwargs = model_note_change(model, developer_gen, date)\n msg = message_of(\n cfg, model.ticket if model.ticket is not None else \"\", \"general_commit_words\"\n )\n repo.index.commit(msg, **kwargs)\n return repo, model",
"def t... | [
"0.6233234",
"0.61580694",
"0.58837044",
"0.5794478",
"0.5789865",
"0.56889015",
"0.5668763",
"0.5666856",
"0.56622714",
"0.5660473",
"0.5637205",
"0.56186",
"0.5607628",
"0.55924743",
"0.5572018",
"0.5568413",
"0.55608547",
"0.55321395",
"0.55321395",
"0.55321395",
"0.553213... | 0.7511692 | 0 |
Calculate title from youtube fields | def __calculate_title(video_data):
title = 'Unknown'
if 'fulltitle' in video_data.keys():
title = video_data['fulltitle']
elif 'title' in video_data.keys():
title = video_data['title']
elif '_filename' in video_data.keys():
title = video_data['_filenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_title():",
"def get_video_title(self, response):\n return response.css(\".watch-title::text\").extract_first(default='')",
"def video_title(self):\n # type: () -> string_types\n return self._video_title",
"def get_video_title(self, video_ID): #WORKS\n try:\n sel... | [
"0.6415981",
"0.6390042",
"0.6202874",
"0.61616015",
"0.6136649",
"0.61353344",
"0.601618",
"0.60098416",
"0.59906054",
"0.5918744",
"0.58389795",
"0.58245",
"0.57838464",
"0.5782499",
"0.57673097",
"0.5766891",
"0.5766891",
"0.5755305",
"0.575",
"0.57433414",
"0.5736346",
... | 0.6963522 | 0 |
Calculate slug from title | def __calculate_slug(self):
return slugify.slugify(self.metadata['title']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_slug(self):\n slug = slugify(self.title)\n new_slug = slug\n n = 1\n while Article.objects.filter(slug=new_slug).exists():\n new_slug = '{}-{}'.format(slug, n)\n n += 1\n\n return new_slug",
"def generate_slug(self):\n slug = slugify(self... | [
"0.7447691",
"0.74240756",
"0.7259259",
"0.72176224",
"0.7143147",
"0.71370405",
"0.709131",
"0.7071297",
"0.6937583",
"0.69070274",
"0.68914616",
"0.6890017",
"0.6739159",
"0.6722646",
"0.67199016",
"0.67184854",
"0.66902643",
"0.66720086",
"0.6663638",
"0.66542524",
"0.6624... | 0.8464547 | 0 |
Calculate record date from youtube field and event dates | def __calculate_date_recorded(self, upload_date_str):
upload_date = datetime.date(
int(upload_date_str[0:4]),
int(upload_date_str[4:6]), int(upload_date_str[6:8]))
if self.event.know_date:
if not (self.event.date_begin <= upload_date <=
self.event... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_date(self):\r\n return self.end_date",
"def apply_date(self, wd):\r\n t_range_count = len(self.time_range)\r\n count = 1\r\n c_mod_date = str(self.m_time)[:10].replace(\"-\", \".\")\r\n\r\n # No dates were found. Return source mod date\r\n if len(self.time_rang... | [
"0.5481478",
"0.537586",
"0.5361697",
"0.5343954",
"0.53253764",
"0.52640146",
"0.5221841",
"0.520659",
"0.51802117",
"0.51758",
"0.51263577",
"0.5114345",
"0.5101076",
"0.5099636",
"0.5094675",
"0.509236",
"0.5072248",
"0.5027174",
"0.49891365",
"0.49810794",
"0.49647325",
... | 0.5605623 | 0 |
Contructor. Retrieves video metadata with youtubedl | def from_youtube(cls, video_data, event):
self = cls(event)
metadata = self.metadata
metadata['title'] = self.__calculate_title(video_data)
self.filename = self.__calculate_slug()
metadata['speakers'] = ['TODO'] # Needs human intervention later
# youtube_id = video_dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, url, params=None):\n super(YoutubeVideo, self).__init__(url, params)\n self.video_id = self.get_video_id()",
"def __init__(self, *args, **kwargs):\r\n super(VideoDescriptor, self).__init__(*args, **kwargs)\r\n # For backwards compatibility -- if we've got XML data, ... | [
"0.6797171",
"0.6761065",
"0.66624993",
"0.65523833",
"0.65339583",
"0.6381884",
"0.63576883",
"0.6357445",
"0.6329871",
"0.63215464",
"0.629405",
"0.6290303",
"0.6277051",
"0.62768745",
"0.62544906",
"0.6250548",
"0.62496716",
"0.6233115",
"0.6223115",
"0.62194794",
"0.62183... | 0.6873472 | 0 |
Create video copy overwriting fields | def merge(self, new_video, fields):
merged_video = Video(self.event)
merged_video.filename = self.filename
for field in self.metadata:
if field in set(fields):
merged_video.metadata[field] = new_video.metadata.get(field)
else:
merged_video.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_frame(video_path, video_name, second, label, dest_path):\n print \"video_path\", video_path\n print 'video_name',video_name\n print 'second',second\n print 'label',label\n print 'dest_path',dest_path\n\n vidcap = cv2.VideoCapture(os.path.join(video_path, video_name))\n vidcap.set(... | [
"0.61236143",
"0.58862036",
"0.5873412",
"0.5863304",
"0.5847396",
"0.5786833",
"0.57654285",
"0.5754191",
"0.5709897",
"0.5694832",
"0.56716293",
"0.5660207",
"0.5623384",
"0.55988485",
"0.5564128",
"0.5554488",
"0.55535036",
"0.5535681",
"0.5510409",
"0.5510409",
"0.5498354... | 0.6564113 | 0 |
Generates schedules for a rabi experiment using a Gaussian pulse | def rabi_schedules(amp_list, qubits, pulse_width, pulse_sigma=None,
width_sigma_ratio=4, drives=None, cmd_def=None,
inst_map=None, meas_map=None):
xdata = amp_list
# copy the instruction to schedule mapping
inst_map = copy.deepcopy(inst_map)
if not inst_map:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def workflow(now, realtime):\n szx = 7000\n szy = 3500\n # Create the image data\n imgdata = np.zeros((szy, szx), 'u1')\n sts = now - datetime.timedelta(minutes=2)\n metadata = {'start_valid': sts.strftime(\"%Y-%m-%dT%H:%M:%SZ\"),\n 'end_valid': now.strftime(\"%Y-%m-%dT%H:%M:%SZ\")... | [
"0.6014506",
"0.5990029",
"0.58660716",
"0.58092046",
"0.5775319",
"0.5713036",
"0.5693866",
"0.56776065",
"0.56660676",
"0.5642816",
"0.5597764",
"0.559718",
"0.5589229",
"0.557686",
"0.5573268",
"0.55314124",
"0.55264544",
"0.55153507",
"0.5505333",
"0.5489393",
"0.54875124... | 0.64958745 | 0 |
Generates schedules for a drag experiment doing a pulse then the pulse | def drag_schedules(beta_list, qubits, pulse_amp, pulse_width,
pulse_sigma=None,
width_sigma_ratio=4, drives=None, cmd_def=None,
inst_map=None, meas_map=None):
xdata = beta_list
# copy the instruction to schedule mapping
inst_map = copy.deepcopy(inst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_schedules(self):\n\n ''''''",
"def dumbSnake_burst(self, xStart, xEnd, yDelta, nRoundTrips, sweepTime,windowList,startgrid):#for burst mode\n self.sam_x.umv(xStart)\n self.sam_y.umv(windowList[startgrid])\n daq.connect()\n daq.begin()\n sleep(2)\n prin... | [
"0.6023474",
"0.6017365",
"0.60029423",
"0.59028995",
"0.58932453",
"0.5862639",
"0.5854462",
"0.5823552",
"0.5788966",
"0.5773561",
"0.57271296",
"0.57246697",
"0.5724626",
"0.5719636",
"0.5710551",
"0.5685761",
"0.5665338",
"0.5660499",
"0.56228495",
"0.5602872",
"0.557558"... | 0.7292922 | 0 |
Calculate beam radius using numerical method. | def beam_radius(self, x, Amp, beam_type='vortex', Amp_Flag=True):
# dx = x[[0],[1]]-x[[0],[0]]
#
# Intensity = (Amp*Amp.conjugate()).real
# N,N = Amp.shape
#
# if beam_type == 'vortex':
#
#
# m,n = matrix_Lib.getPositon(In... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beamradius(params,z):\n \n w0=params[0] # beam width at waist [e.g. meters]\n zw=params[1] # waist position [e.g. meters]\n lam = params[2] # wavelength [meters]\n \n zR=np.pi*w0**2/lam # Raleigh length [e.g. m... | [
"0.73551536",
"0.6815536",
"0.6782462",
"0.6683011",
"0.65259564",
"0.65156573",
"0.64876854",
"0.64751196",
"0.6428476",
"0.6376738",
"0.63206553",
"0.63206553",
"0.62759846",
"0.6266276",
"0.6249527",
"0.6246731",
"0.62323844",
"0.6219044",
"0.620518",
"0.6180577",
"0.61699... | 0.7203599 | 1 |
Calculate the PIB using numerical methods. PIB, power in the bucket, defined as the ratio of the far field laser power in given size 'bucket' and the total power(percentage), it can be used to describe the laser power concentration, and reflect the focusing ability in far field of practical laser. | def Power_in_the_Bucket(self,PIB_Func,a,b):
Temp1 = integrate.dblquad(PIB_Func,0,2*np.pi,lambda x:0,lambda x:b)[0]
Temp2 = integrate.dblquad(PIB_Func,0,2*np.pi,lambda x:0,lambda x:a)[0]
PIB = Temp1/Temp2
return PIB | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_bn(self, lvl):\n bn = [0] # number of samples crossing the left/right boundary\n for n in range(lvl):\n # 1. down-sampling of N samples by the factor scl gives (N-1)//scl + 1 samples\n # 2. bn[-1]+M-1 is the number of samples acrossing the left/right boundary, with... | [
"0.59821904",
"0.5593582",
"0.55114025",
"0.540089",
"0.5381502",
"0.53687227",
"0.534425",
"0.52939373",
"0.52920914",
"0.5278142",
"0.5269385",
"0.52405536",
"0.5231438",
"0.52229476",
"0.5210197",
"0.5208923",
"0.5194065",
"0.5194065",
"0.51929146",
"0.51692796",
"0.516459... | 0.6668526 | 0 |
Tests that the api can be hit and that authorization works and that it can return one particular person who is likely to be with the company for some time | def test_api():
# person id for one long time employee
content = get_person(10050)
assert content['preferredName'].endswith('immel') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generic_test(self):\n api_params[params_to_api[\"org_id\"]] = str(self.org_id)\n valid_response = [\n entry for entry in self.valid_response\n if all(\n str(entry[k]).lower().find(str(api_params[k]).lower()) != -1\n for k in api_params\n ... | [
"0.65235025",
"0.6501353",
"0.6472427",
"0.64364195",
"0.6426616",
"0.64263946",
"0.6409696",
"0.6380067",
"0.6376479",
"0.633538",
"0.63281476",
"0.62975615",
"0.6294384",
"0.6268598",
"0.6262227",
"0.62525415",
"0.6242194",
"0.6224487",
"0.6209244",
"0.61947787",
"0.6183047... | 0.6604673 | 0 |
Decorator for handling legend of mpl.Patch | def _patch_legend(obj, draw_options, legend_type):
legend = ""
if _is_in_legend(obj):
# Unfortunately, patch legend entries need \addlegendimage in Pgfplots.
do = ", ".join([legend_type] + draw_options) if draw_options else ""
legend += "\\addlegendimage{{{}}}\n\\addlegendentry{{{}}}\n\n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legend (self, **kwargs):\n axes = self.twin_axes or self.axes\n self.mpl_legend = axes.legend (self.mpl_lines, self.labels, **kwargs)",
"def set_legend(self, **lgdkwargs):\n\n if 'loc' not in lgdkwargs.keys(): \n lgdkwargs['loc'] = 'upper right'\n \n if 'scatterp... | [
"0.7171054",
"0.7168987",
"0.6854049",
"0.68341994",
"0.6755757",
"0.6587965",
"0.6531944",
"0.64263946",
"0.642071",
"0.6398324",
"0.6380565",
"0.6310541",
"0.6282369",
"0.6258558",
"0.62474394",
"0.6220899",
"0.62024856",
"0.6189992",
"0.6181365",
"0.617804",
"0.6155175",
... | 0.7210462 | 0 |
``` Get current weight decay rate ``` | def get_weight_decay(self):
if type(self.model.optimizer).__name__ == "AdamWeightDecay":
return self.model.optimizer.weight_decay_rate
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_decay(self):\n if self._weight_decay is not None:\n return self._weight_decay\n return 5e-5 if 'VG' in self.dataset else 5e-4",
"def decay(self):\n return self._decay",
"def _decay(self):\n wd_losses = tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)\n log.... | [
"0.7772663",
"0.7588543",
"0.7197065",
"0.70361257",
"0.6825383",
"0.6824575",
"0.67655575",
"0.67583513",
"0.67453355",
"0.6740679",
"0.6740679",
"0.6651961",
"0.6601236",
"0.65886915",
"0.6570518",
"0.6546319",
"0.65148735",
"0.6501756",
"0.64437497",
"0.6422064",
"0.639320... | 0.7858903 | 0 |
``` alias for self.validate(). Returns confusion matrix and optionally prints a classification report. This is currently only supported for binary and multiclass classification, not multilabel classification. By default, this uses val_data, as supplied to ktrain.get_learner(). Other validation or test data can be optio... | def evaluate(
self,
test_data=None,
print_report=True,
save_path="ktrain_classification_report.csv",
class_names=[],
):
return self.validate(
val_data=test_data,
print_report=print_report,
save_path=save_path,
class_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(\n self,\n val_data=None,\n print_report=True,\n save_path=\"ktrain_classification_report.csv\",\n class_names=[],\n ):\n if val_data is not None:\n val = val_data\n else:\n val = self.val_data\n\n classification, multila... | [
"0.7061594",
"0.6620979",
"0.6557049",
"0.64944804",
"0.6290662",
"0.6205117",
"0.61709756",
"0.60951626",
"0.6075812",
"0.6047021",
"0.6033616",
"0.60332537",
"0.5952465",
"0.59386826",
"0.5937747",
"0.5890762",
"0.5887027",
"0.58835757",
"0.586785",
"0.5853565",
"0.5828185"... | 0.7392718 | 0 |
``` Computes losses on validation set sorted by examples with top losses | def top_losses(self, n=4, val_data=None, preproc=None):
# check validation data and arguments
if val_data is not None:
val = val_data
else:
val = self.val_data
if val is None:
raise Exception("val_data must be supplied to get_learner or top_losses")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_top_losses(self, n=4, preproc=None, val_data=None):\n val = self._check_val(val_data)\n\n # get top losses and associated data\n tups = self.top_losses(n=n, val_data=val, preproc=preproc)\n\n # get multilabel status and class names\n classes = preproc.get_classes() if pr... | [
"0.6342087",
"0.6342087",
"0.6285686",
"0.6184228",
"0.6143505",
"0.5943816",
"0.58742076",
"0.5871172",
"0.5871172",
"0.5862677",
"0.5841007",
"0.5797185",
"0.579355",
"0.57559305",
"0.5755333",
"0.5748603",
"0.57427806",
"0.5716219",
"0.56941265",
"0.56534934",
"0.5652545",... | 0.67297906 | 0 |
``` View observations with top losses in validation set. Musta be overridden by Learner subclasses. ``` | def view_top_losses(self, n=4, preproc=None, val_data=None):
raise NotImplementedError(
"view_top_losses must be overriden by Learner subclass"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_top_losses(self, n=4, preproc=None, val_data=None):\n val = self._check_val(val_data)\n\n # get top losses and associated data\n tups = self.top_losses(n=n, val_data=val, preproc=preproc)\n\n # get multilabel status and class names\n classes = preproc.get_classes() if pr... | [
"0.690854",
"0.690854",
"0.68353695",
"0.67022794",
"0.6513898",
"0.59249014",
"0.5795531",
"0.57954496",
"0.5687133",
"0.5644001",
"0.56356734",
"0.56347084",
"0.563436",
"0.5591639",
"0.5556396",
"0.55204254",
"0.551339",
"0.5507075",
"0.5500442",
"0.5487079",
"0.5479208",
... | 0.71523297 | 0 |
``` checks whether optimizer attached to model is an "Adamlike" optimizer with beta_1 parameter. ``` | def _is_adamlike(self):
return self.model is not None and hasattr(self.model.optimizer, "beta_1") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_optimizer(self, optimizer):\r\n if optimizer in optimizer_implemented:\r\n return optimizer\r\n else:\r\n raise InvalidNeuralNetwork()",
"def get_optimizer(model):\n optimizer = optim.Adam(model.parameters(), lr=0.001, betas=(0.5, 0.999))\n return optimizer",
... | [
"0.68022156",
"0.62298334",
"0.6071112",
"0.60635936",
"0.6038728",
"0.6008286",
"0.59879905",
"0.5945063",
"0.59336495",
"0.5895568",
"0.58892685",
"0.5881455",
"0.5832392",
"0.58163524",
"0.5802902",
"0.5794838",
"0.57547295",
"0.57023084",
"0.56976044",
"0.5696452",
"0.568... | 0.78264856 | 0 |
``` If freeze_range is None, makes all layers trainable=False except last Dense layer. If freeze_range is given, freezes the first layers and unfrezes all remaining layers. | def freeze(self, freeze_range=None):
if freeze_range is None:
# freeze everything except last Dense layer
# first find last dense layer
dense_id = None
for i, layer in reversed(list(enumerate(self.model.layers))):
if isinstance(layer, keras.layers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfreeze(self, exclude_range=None):\n # make all layers trainable\n for i, layer in enumerate(self.model.layers):\n layer.trainable = True\n if exclude_range:\n for i, layer in enumerate(self.model.layers[:exclude_range]):\n layer.trainable = False\n ... | [
"0.74953765",
"0.74448335",
"0.73082614",
"0.7082195",
"0.69717956",
"0.6841668",
"0.68320596",
"0.67648673",
"0.6746724",
"0.66701394",
"0.66571945",
"0.66404206",
"0.65767574",
"0.6555493",
"0.6438692",
"0.63134444",
"0.6292875",
"0.6292875",
"0.6269727",
"0.615773",
"0.615... | 0.8398271 | 0 |
``` Make every layer trainable except those in exclude_range. unfreeze is simply a proxy method to freeze. | def unfreeze(self, exclude_range=None):
# make all layers trainable
for i, layer in enumerate(self.model.layers):
layer.trainable = True
if exclude_range:
for i, layer in enumerate(self.model.layers[:exclude_range]):
layer.trainable = False
self._r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_freeze_layers(self):\n for layer in self.encoder.layers[:self.freeze_layers]:\n layer.trainable = False",
"def unfreeze(net):\n for p in net.parameters():\n p.requires_grad_(True)\n return net",
"def freeze(self, freeze_range=None):\n\n if freeze_range is None:\n ... | [
"0.72568554",
"0.6638978",
"0.6617777",
"0.65604836",
"0.6548017",
"0.6448261",
"0.62517256",
"0.6230969",
"0.6091655",
"0.60071284",
"0.593866",
"0.59288687",
"0.58614165",
"0.58492386",
"0.579668",
"0.5725522",
"0.57151955",
"0.57089233",
"0.57042134",
"0.5698407",
"0.56568... | 0.871734 | 0 |
``` Train model using a version of Leslie Smith's 1cycle policy. This method can be used with any optimizer. Thus, cyclical momentum is not currently implemented. | def fit_onecycle(
self,
lr,
epochs,
checkpoint_folder=None,
cycle_momentum=True,
max_momentum=0.95,
min_momentum=0.85,
class_weight=None,
callbacks=[],
steps_per_epoch=None,
verbose=1,
):
if not self._is_adamlike() and c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,\n weight_decay,\n learning_rate,\n momentum,\n use_locking=False,\n name=\"MomentumW\",\n use_nesterov=False):\n super(MomentumWOptimizer, self).__init__(\n weight_decay,\n learning_rate=learning... | [
"0.6256662",
"0.6253452",
"0.62092066",
"0.60618925",
"0.5937184",
"0.59116924",
"0.5880686",
"0.5851725",
"0.5850066",
"0.58497584",
"0.58325064",
"0.5821707",
"0.58127165",
"0.5775546",
"0.57647693",
"0.5756522",
"0.5727081",
"0.5723098",
"0.57171744",
"0.57134026",
"0.5706... | 0.6422775 | 0 |
``` Trains the model. By default, fit is simply a wrapper for model.fit. When cycle_len parameter is supplied, an SGDR learning rate schedule is used. Trains the model. | def fit(
self,
lr,
n_cycles,
cycle_len=None,
cycle_mult=1,
lr_decay=1,
checkpoint_folder=None,
early_stopping=None,
verbose=1,
class_weight=None,
callbacks=[],
steps_per_epoch=None,
):
# check early_stopping
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, training_steps=10):",
"def train(self, x, t):\n self.model.fit(x, t)",
"def train(self, x, t):\n self.model.fit(x, t)",
"def train(self, x, t):\n self.model.fit(x, t)",
"def train(self, x, t):\n self.model.fit(x, t)",
"def train(self, x, t):\n self.model... | [
"0.619779",
"0.61389446",
"0.61389446",
"0.61389446",
"0.61389446",
"0.61389446",
"0.6129235",
"0.6086946",
"0.60522664",
"0.59538764",
"0.5937075",
"0.586253",
"0.58526266",
"0.5774153",
"0.5759417",
"0.5688797",
"0.5649711",
"0.5631626",
"0.56164694",
"0.56153095",
"0.56034... | 0.6616282 | 0 |
``` Trains the model. By default, fit is simply a wrapper for model.fit (for generators/sequences). When cycle_len parameter is supplied, an SGDR learning rate schedule is used. | def fit(
self,
lr,
n_cycles,
cycle_len=None,
cycle_mult=1,
lr_decay=1.0,
checkpoint_folder=None,
early_stopping=None,
class_weight=None,
callbacks=[],
steps_per_epoch=None,
verbose=1,
):
# check early_stopping
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(\n self,\n lr,\n n_cycles,\n cycle_len=None,\n cycle_mult=1,\n lr_decay=1,\n checkpoint_folder=None,\n early_stopping=None,\n verbose=1,\n class_weight=None,\n callbacks=[],\n steps_per_epoch=None,\n ):\n\n # chec... | [
"0.674917",
"0.62537503",
"0.6130474",
"0.6058735",
"0.6058735",
"0.6058735",
"0.6058735",
"0.6058735",
"0.59835505",
"0.5917398",
"0.5874811",
"0.58250046",
"0.57983094",
"0.57891625",
"0.5749539",
"0.56710434",
"0.5635797",
"0.5614563",
"0.5594933",
"0.5557598",
"0.5554473"... | 0.6283766 | 1 |
An image with GPS EXIF data should have it stripped out with a new object. Testing the image when added to a brand new publication. | def test_exif_data_removed_from_added_thumbnail(self):
# The image that has GPS data:
path = "tests/core/fixtures/images/tester_exif_gps.jpg"
# Double-check the original image does have some GPS data:
exif_dict = piexif.load(path)
self.assertEqual(len(exif_dict["GPS"].keys()), ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exif_data_removed_from_updated_thumbnail(self):\n\n # The image that has GPS data:\n path = \"tests/core/fixtures/images/tester_exif_gps.jpg\"\n\n # Double-check it does have some GPS data:\n exif_dict = piexif.load(path)\n self.assertEqual(len(exif_dict[\"GPS\"].keys())... | [
"0.7582161",
"0.7270803",
"0.6658896",
"0.64127284",
"0.6338549",
"0.6294199",
"0.62452686",
"0.62452686",
"0.62189156",
"0.6157361",
"0.61135304",
"0.6093739",
"0.6040987",
"0.6040361",
"0.6029232",
"0.60003126",
"0.5993806",
"0.5990794",
"0.5978",
"0.5978",
"0.5900418",
"... | 0.7872446 | 0 |
A replacement thumbnail should have its GPS data removed. i.e. an image that's added to an existing publication, not a brand new one. | def test_exif_data_removed_from_updated_thumbnail(self):
# The image that has GPS data:
path = "tests/core/fixtures/images/tester_exif_gps.jpg"
# Double-check it does have some GPS data:
exif_dict = piexif.load(path)
self.assertEqual(len(exif_dict["GPS"].keys()), 15)
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exif_data_removed_from_added_thumbnail(self):\n\n # The image that has GPS data:\n path = \"tests/core/fixtures/images/tester_exif_gps.jpg\"\n\n # Double-check the original image does have some GPS data:\n exif_dict = piexif.load(path)\n self.assertEqual(len(exif_dict[\"... | [
"0.7741051",
"0.66341645",
"0.659211",
"0.65176636",
"0.6435591",
"0.6162346",
"0.5920657",
"0.57691544",
"0.57613194",
"0.5753854",
"0.5736138",
"0.56746906",
"0.56679213",
"0.5613139",
"0.5581824",
"0.556515",
"0.55536145",
"0.5548147",
"0.5531315",
"0.5524793",
"0.55067116... | 0.77298826 | 1 |
Takes the fully qualified path of a file as the input. Checks the current working directory. If that directory is within the fully qualified path, returns the local path from working directory to file. If no, returns fully qualified path. | def get_file_path(qualified_path):
# Hacky little workaround for different environments running unit test from different, unpredicatble, directories
# (PyCharm behavior is particularly odd.)
pwd = os.getcwd()
pwdl = pwd.split('/')
qpl = qualified_path.split('/')
stat = False
out = []
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_path(root_dir, dirpath, f):\n full = os.path.join(dirpath, f)\n if not root_dir:\n return full\n if not full.startswith(root_dir):\n print(\"ERROR - bad path for root\", full)\n return None\n full = full[len(root_dir):]\n if full.startswith(\"/\"):\n return f... | [
"0.7182216",
"0.70704246",
"0.7027782",
"0.6905919",
"0.6883684",
"0.68740064",
"0.68594676",
"0.68565387",
"0.6855552",
"0.6855529",
"0.68550545",
"0.68128973",
"0.6796536",
"0.6780357",
"0.6754754",
"0.67167574",
"0.6691441",
"0.66856325",
"0.66749936",
"0.6643463",
"0.6586... | 0.7429044 | 0 |
Let center be (0.5 train_width, 0.5 train_height) Given the polygon vertices of some canvas, compute how much it needs to be enlarged from the center so we can crop out a centered rectangle of (train_width, train_height) | def compute_canvas_scaling(
self,
canvas_corners: np.array
) -> float:
canvas_box = Polygon(zip(canvas_corners[:, 0], -canvas_corners[:, 1]))
train_corners = np.array([
(0, 0), (self.train_width, 0), (self.train_width, self.train_height), (0, self.train_height)])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center_size(boxes):\n concat = P.Concat(1)\n return concat(((boxes[:, 2:] + boxes[:, :2])/2, # cx, cy\n boxes[:, 2:] - boxes[:, :2])) # w, h",
"def center_size(boxes):\n return torch.cat([(boxes[:, :2] + boxes[:, 2:])/2, # cx, cy\n boxes[:, :2] - boxes[:,... | [
"0.6060341",
"0.5892901",
"0.57100004",
"0.57056683",
"0.57005465",
"0.5678968",
"0.55696034",
"0.5528815",
"0.55135554",
"0.5512205",
"0.54925054",
"0.54905105",
"0.5479942",
"0.546968",
"0.5451635",
"0.54464954",
"0.5433388",
"0.54276353",
"0.5405532",
"0.5401927",
"0.54013... | 0.64222825 | 0 |
Creates a sequence example from a single image and ordering pair and conserves disk space by not duplicating features | def create_sequence_example(inner_image_path,
inner_sample):
# serialize a pointer to the disk location of the image features
# copying data for every training example would consume too much storage
image_path_feature = tf.train.Feature(
bytes_list=tf.train.BytesList(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_example(image_path, annotations, label_map_dict):\n print(\"encoding %s\" % image_path)\n with tf.gfile.GFile(image_path, 'rb') as fid:\n encoded_png = fid.read()\n encoded_png_io = io.BytesIO(encoded_png)\n image = pil.open(encoded_png_io)\n\n if image.format != 'PNG':\n r... | [
"0.63316333",
"0.61458004",
"0.58649594",
"0.58257097",
"0.5818865",
"0.57881355",
"0.5760908",
"0.57592547",
"0.5743457",
"0.56925213",
"0.5641719",
"0.5602537",
"0.5586567",
"0.5572796",
"0.55707115",
"0.5545738",
"0.5537902",
"0.5524718",
"0.55045223",
"0.5496017",
"0.5463... | 0.6995742 | 0 |
Get the details for the plugin. | def get_details(self):
return PluginDetails(
plugin_name="bad-string-detail-is-int",
plugin_id="MDE007",
plugin_enabled_by_default=True,
plugin_description=123,
plugin_version="0.0.0",
plugin_interface_version=1,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_details(self):\n response = self._server._api_request(\"GET\", \"/plugins/plugin/%d\" % self.id, \"\")\n if response is not None:\n self.id = response[\"id\"]\n self.name = response[\"name\"]\n self.family_name = response[\"family_name\"]\n self.at... | [
"0.74133354",
"0.70366853",
"0.69682646",
"0.69427323",
"0.69427323",
"0.69427323",
"0.69322133",
"0.6870447",
"0.6840347",
"0.6793439",
"0.6766492",
"0.676512",
"0.676512",
"0.6704927",
"0.67042005",
"0.6699309",
"0.669437",
"0.65802103",
"0.65387255",
"0.6526944",
"0.651363... | 0.7069294 | 1 |
Creates a Plotly bar plot. Bar plots work with categorical data. Function computes appropriate counts and percentages to create bar plots. | def barplot(self, x = "Predictor", color = None, opacity = 1, template = "ggplot2",
has_title = True, barmode="stack", is_horizontal = False, title = None, is_percent = False,
show_num = False):
if color: #Produce either a stacked or grouped bar plot
df_stack = self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_bar_chart(df):\n label_names = df.drop(['message', 'original', 'genre', 'id'], axis=1).columns\n label_counts = []\n for column in label_names:\n label_counts.append(df[column].sum())\n return {\n 'data': [\n Bar(\n x=label_names,\n ... | [
"0.72194046",
"0.71174055",
"0.6937447",
"0.6775842",
"0.6733003",
"0.6684813",
"0.6653163",
"0.6649413",
"0.66449785",
"0.6579396",
"0.6567126",
"0.65648836",
"0.65589094",
"0.64846426",
"0.6439378",
"0.64338756",
"0.641193",
"0.63892895",
"0.6372072",
"0.63706815",
"0.63664... | 0.722512 | 0 |
Convert input to int or None. | def to_int_or_none(value: Union[None, int, str]) -> Optional[int]:
return None if value is None else int(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_int(n):\n if n is not None:\n return int(n)\n return n",
"def safe_int(n):\n if n is not None:\n return int(n)\n return n",
"def safe_int(n):\n if n is not None:\n return int(n)\n return n",
"def make_intger(value):\n if value:\n return int(value)\n ... | [
"0.7781337",
"0.7781337",
"0.7781337",
"0.7518989",
"0.73636466",
"0.7351112",
"0.71629924",
"0.7137978",
"0.7055296",
"0.7053462",
"0.70123845",
"0.6952432",
"0.6920805",
"0.69069695",
"0.6905367",
"0.6884723",
"0.686551",
"0.6853952",
"0.6842137",
"0.68142843",
"0.67846656"... | 0.7897519 | 0 |
Make converter that returns value or ``None``. ``converter`` is called to further convert non``None`` values. | def value_or_none(converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:
return lambda value: None if value is None else converter(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truthy_or_none(converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:\n return lambda value: converter(value) if value else None",
"def convert(self, converter=None):\n if converter is not None:\n self.converter = converter\n self.code(self.prepare)",
"def converterValu... | [
"0.73842376",
"0.6788747",
"0.6735242",
"0.6262596",
"0.6160665",
"0.58736897",
"0.58207244",
"0.5810433",
"0.5806184",
"0.5796253",
"0.56792873",
"0.56451964",
"0.5600903",
"0.5582337",
"0.5560803",
"0.5466902",
"0.54607475",
"0.5430933",
"0.5421707",
"0.54138815",
"0.540173... | 0.7628677 | 0 |
Make converter that returns a truthy value or ``None``. ``converter`` is called to further convert non``None`` values. | def truthy_or_none(converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:
return lambda value: converter(value) if value else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_or_none(converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:\n return lambda value: None if value is None else converter(value)",
"def convert(self, converter=None):\n if converter is not None:\n self.converter = converter\n self.code(self.prepare)",
"def conver... | [
"0.74117136",
"0.6217806",
"0.60996294",
"0.6047573",
"0.58413285",
"0.5426432",
"0.54246247",
"0.54015446",
"0.5386038",
"0.5373192",
"0.53192526",
"0.5307836",
"0.52500135",
"0.5246546",
"0.52267283",
"0.5171171",
"0.5150713",
"0.5147207",
"0.5136645",
"0.5133075",
"0.50921... | 0.8393245 | 0 |
Make converter that returns a string stripped of newlines or ``None``. ``converter`` is called to further convert non``None`` values. | def stripped_newlines(converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:
return lambda value: converter(value.replace('\r', '').replace('\n', '')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_safe_str_or_none(value: Optional[str]) -> Optional[str]:\n if value is None:\n return None\n v = str(value.strip()).replace('\\r', '').replace('\\n', '')\n return v or None",
"def _coerce_str_unless_none(value):\n return str(value) if value is not None else None",
"def _nullify(self, ... | [
"0.57796806",
"0.5565792",
"0.5423951",
"0.51866627",
"0.5173151",
"0.5128336",
"0.51152",
"0.50806856",
"0.5063399",
"0.496225",
"0.4939525",
"0.49193722",
"0.4881577",
"0.48720887",
"0.4861825",
"0.48315695",
"0.48274344",
"0.48204777",
"0.4794638",
"0.4782126",
"0.47787866... | 0.79939085 | 0 |
Make converter that pads a string to the given ``length`` or ``None``. ``converter`` is called to further convert non``None`` values. | def fixed_len_str(length: int, converter: Callable[[Any], T]) -> Callable[[Any], Optional[T]]:
return lambda value: converter('{value:{length}}'.format(value=value, length=length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r_pad(arg, length):\n if length <= len(arg):\n return arg\n else:\n return arg + \" \" * (length - len(arg))",
"def pad_to_len(string, length, leftpad=False, pad_char=None):\n pad_len = length - len(string)\n if not pad_char:\n pad_char = chr(pad_len)\n pad = pad_char * pa... | [
"0.63583606",
"0.6331325",
"0.6219211",
"0.6056578",
"0.5974136",
"0.5924698",
"0.5879173",
"0.5876417",
"0.57539606",
"0.5703852",
"0.5703074",
"0.5691029",
"0.565843",
"0.5619489",
"0.5596193",
"0.5578779",
"0.557342",
"0.5527868",
"0.5486929",
"0.54777336",
"0.5429382",
... | 0.76321566 | 0 |
Convert input to cleaned string or None. | def to_safe_str_or_none(value: Optional[str]) -> Optional[str]:
if value is None:
return None
v = str(value.strip()).replace('\r', '').replace('\n', '')
return v or None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nullify(self, value):\n if not str(value).strip():\n return None\n else:\n return value",
"def s2s(s):\n if (s is None): return \"\"\n else: return s",
"def _coerce_str_unless_none(value):\n return str(value) if value is not None else None",
"def pr_str(inp_s... | [
"0.6912935",
"0.679337",
"0.66672534",
"0.648431",
"0.63433313",
"0.63390726",
"0.63277876",
"0.63038266",
"0.6289571",
"0.6266268",
"0.62587976",
"0.6125083",
"0.607986",
"0.6077214",
"0.6066858",
"0.60576636",
"0.60568833",
"0.6034547",
"0.601238",
"0.60031074",
"0.6000978"... | 0.68710715 | 1 |
Convert input to ServiceCode. | def to_service_code(value: Union[ServiceCode, int, str]) -> ServiceCode:
return ServiceCode(int(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_code(self):\n return self._service_code",
"def carrier_service_code(self) -> CarrierServiceCode:\n return self._carrier_service_code",
"def to_service(self):\n pass",
"def service_code(self, service_code):\n \n self._service_code = service_code",
"def CODE(str... | [
"0.59258175",
"0.5562645",
"0.5473153",
"0.5180083",
"0.5047485",
"0.5024791",
"0.49567187",
"0.4890521",
"0.48772183",
"0.487579",
"0.48667815",
"0.48661387",
"0.4863664",
"0.48508915",
"0.483762",
"0.4823044",
"0.48018318",
"0.4795829",
"0.47856128",
"0.47587553",
"0.475723... | 0.7668961 | 0 |
Convert input to AssignmentType. | def to_assignment_type(value: Union[AssignmentType, int, str]) -> AssignmentType:
return AssignmentType(int(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(self, name, to):\n valid_types = ['int', 'float', 'single', 'delimited set', 'string']\n if not to in valid_types:\n raise TypeError(\"Cannot convert to type {}!\".format(to))\n if to == 'int':\n self._as_int(name)\n elif to == 'float':\n sel... | [
"0.579724",
"0.5793444",
"0.56160337",
"0.55743766",
"0.5487973",
"0.5482975",
"0.5360676",
"0.53187215",
"0.52928305",
"0.5241999",
"0.51792806",
"0.51730794",
"0.51294607",
"0.5070607",
"0.50627756",
"0.50597924",
"0.50533307",
"0.50039476",
"0.5000716",
"0.4984232",
"0.498... | 0.76733494 | 0 |
Convert input to TransactionType. | def to_transaction_type(value: Union[TransactionType, int, str]) -> TransactionType:
return TransactionType(int(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_type(self) -> str:\n return self.chunks[2].decode(\"ascii\")",
"def convert_type(param: str, target: str):\n converted = param\n if target == \"boolean\":\n converted = bool(strtobool(param))\n if target == \"integer\":\n converted = int(param)\n return converted"... | [
"0.58068913",
"0.56707996",
"0.55360234",
"0.54179615",
"0.54034764",
"0.53638124",
"0.522108",
"0.5167776",
"0.51571816",
"0.51562405",
"0.5148098",
"0.51314104",
"0.5106495",
"0.50999385",
"0.50826794",
"0.50459546",
"0.5043674",
"0.50401795",
"0.50316054",
"0.49789613",
"0... | 0.7538369 | 0 |
Convert input to RecordType. | def to_record_type(value: Union[RecordType, int, str]) -> RecordType:
return RecordType(int(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __convert( source ):\n # Just in case things get this far but we don't know about the record\n if source['recordType'] not in definitions.RECORDS:\n return {\n 'rec_type': source['recordType']\n }\n\n # Create a flat wrapper\n record = estreamer.common.Flatdict( source )\n\... | [
"0.66987187",
"0.6536924",
"0.62192184",
"0.62178814",
"0.6115495",
"0.5975086",
"0.5944287",
"0.5787325",
"0.567308",
"0.55839926",
"0.55722314",
"0.55714315",
"0.5509635",
"0.54881006",
"0.54644316",
"0.54034185",
"0.53840655",
"0.5376388",
"0.5374155",
"0.5368817",
"0.5351... | 0.73229134 | 0 |
Convert input to AvtaleGiroRegistrationType. | def to_avtalegiro_registration_type(
value: Union[AvtaleGiroRegistrationType, int, str]
) -> AvtaleGiroRegistrationType:
return AvtaleGiroRegistrationType(int(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_type(self, value, schema_type, **kwargs):",
"def as_type(self, type_):\n\n try:\n return type_(self.value)\n except (ValueError, TypeError):\n\n message = \"Attribute <{}> = '{}' could not be converted to {}\".format(\n self.namespace, self.value, ty... | [
"0.53376335",
"0.52972144",
"0.51747817",
"0.5173467",
"0.5140503",
"0.50965077",
"0.50736964",
"0.50084394",
"0.4998834",
"0.4962407",
"0.49113736",
"0.48977277",
"0.48228055",
"0.47975847",
"0.4774673",
"0.47527826",
"0.47318712",
"0.47290275",
"0.47289726",
"0.47167358",
"... | 0.820782 | 0 |
Convert input to date or None. | def to_date_or_none(value: Optional[Union[datetime.date, str]]) -> Optional[datetime.date]:
if isinstance(value, datetime.date):
return value
if value is None or value == '000000':
return None
return datetime.datetime.strptime(value, '%d%m%y').date() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date_or_none(date_str, date_format='%Y-%m-%d'):\n try:\n return datetime.strptime(date_str, date_format).date()\n except (ValueError, TypeError):\n return None",
"def get_date_or_none(obj, key):\n try:\n return datetime.strptime(obj[key], '%Y-%m-%d')\n except (KeyError, V... | [
"0.7074362",
"0.6840503",
"0.68382853",
"0.68216044",
"0.665924",
"0.6622794",
"0.6614629",
"0.6591658",
"0.65521365",
"0.6540483",
"0.64765716",
"0.646378",
"0.6439453",
"0.6374112",
"0.6242532",
"0.6207828",
"0.6172377",
"0.61720425",
"0.615784",
"0.6155691",
"0.6126636",
... | 0.774011 | 0 |
generate an item group index array suppose total = 10, unitlen = 2, then we will return array [0 0 1 1 2 2 3 3 4 4] | def gen_item_group_index(total, group_len):
group_count = total / group_len
group_index = np.arange(total)
for i in range(group_count):
group_index[i * group_len: (i + 1) * group_len] = i
group_index[(i + 1) * group_len : total] = i + 1
return group_index.tolist() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_uniform(totalsize, groups):\n ret = []\n for i in range(groups):\n myn = totalsize // groups\n off = 0\n leftover = totalsize % groups\n if ( i < leftover ):\n myn = myn + 1\n off = i * myn\n else:\n off = ((myn + 1) * leftove... | [
"0.6378276",
"0.6240153",
"0.6072229",
"0.58978605",
"0.5774649",
"0.57084954",
"0.570569",
"0.5617115",
"0.5617115",
"0.5589388",
"0.5583923",
"0.55738425",
"0.5546293",
"0.5525756",
"0.5525756",
"0.55106634",
"0.5503081",
"0.5472381",
"0.5417983",
"0.5379947",
"0.53645253",... | 0.8579454 | 0 |
Return the appropriate configuration object based on the environment. | def current_config():
if os.environ["ENVIRONMENT"] == "production":
return Production()
elif os.environ["ENVIRONMENT"] == "staging":
return Staging()
elif os.environ["ENVIRONMENT"] == "testing":
return Testing()
elif os.environ["ENVIRONMENT"] == "development":
return Deve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_env():\n app_env = os.getenv(\"APP_ENV\", \"TEST\")\n return ConfigurationFactory.get_config(app_env)",
"def get_config() -> Config:\n app_config = os.environ.get('APP_CONFIG', 'ProductionConfig')\n config_module = importlib.import_module(\n '.'.join(\n f\"magma.flu... | [
"0.77241725",
"0.7273741",
"0.7243146",
"0.6993538",
"0.6954362",
"0.6895705",
"0.6863902",
"0.68583167",
"0.68498826",
"0.6803447",
"0.6802271",
"0.67192346",
"0.67163754",
"0.6706015",
"0.6699992",
"0.6689478",
"0.6682749",
"0.66788447",
"0.66552925",
"0.6649258",
"0.664641... | 0.7457492 | 1 |
Reteive a unique identifier for a node, or create one. | def create_or_retrieve_node_id(self, wg, node_name):
try:
return self.retrieve_node_id(wg, node_name)
except UnknownNodeError:
return self._create_node(wg, node_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_or_create_unique_id(self):\n if not self.unique_id:\n self.unique_id = uuid.uuid4().hex\n return self.unique_id",
"def establish_id(self):\n if self.config.node_id is None:\n self.config.node_id = str(uuid4()).replace('-', '')\n return self.config.node_id... | [
"0.7112194",
"0.7047334",
"0.6942829",
"0.68635917",
"0.66633224",
"0.6659892",
"0.6632713",
"0.65084535",
"0.647988",
"0.6463734",
"0.64200485",
"0.64160454",
"0.6304957",
"0.6304957",
"0.63036376",
"0.6247643",
"0.62012863",
"0.6187429",
"0.6185521",
"0.615422",
"0.6137128"... | 0.7517324 | 0 |
Ingest results from a node FITS file. | def ingest_node_results(self, filename, extension=-1):
# Which node is this?
wg, node_name = utils.parse_node_filename(filename)
#node_id = self.retrieve_node_id(wg, node_name)
uves_node_id = self.retrieve_node_id(wg, "UVES-{}".format(node_name))
giraffe_node_id = self.retrieve_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_readfile_fits(self):\n fitsname = os.path.join(self.datadir, 'monol_testA.evt')\n command = \"{0}\".format(fitsname)\n\n hen.io.main(command.split())",
"def run(self):\r\n #print 'WriteFITS_IDI.run'\r\n\r\n # construct the name of the file\r\n readfits = self.pr... | [
"0.5461746",
"0.5436107",
"0.50063705",
"0.49693927",
"0.4956127",
"0.49234617",
"0.48929214",
"0.48917216",
"0.487374",
"0.4871812",
"0.4836861",
"0.48343527",
"0.4830213",
"0.48178682",
"0.48047635",
"0.48032883",
"0.47866166",
"0.47846198",
"0.47678658",
"0.47470143",
"0.4... | 0.7039076 | 0 |
Ingest a master list of spectra from a FITS template file. | def ingest_spectra_masterlist(self, filename, extension=-1):
image = fits.open(filename)
data = image[extension].data
# Create mapper between FITS and database columns.
columns = ("cname", "ges_fld", "object", "filename", "ges_type", "setup",
"wg", "ra", "dec", "snr", "vel"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spectra_stacker(file_name):\n file_data = read_file(file_name)\n image_data = file_data[1]\n\n data_shape = np.shape(image_data)\n ra_axis = data_shape[2]\n dec_axis = data_shape[1]\n wl_axis = data_shape[0]\n\n pxl_total = ra_axis * dec_axis\n \n data_unwrap = [] \n... | [
"0.5904526",
"0.571757",
"0.5714277",
"0.5623908",
"0.5520187",
"0.5479177",
"0.5477202",
"0.5443257",
"0.54315567",
"0.5424685",
"0.5417307",
"0.53666973",
"0.53290844",
"0.53203815",
"0.5317045",
"0.52666986",
"0.5265641",
"0.52395934",
"0.52278274",
"0.5212533",
"0.5201286... | 0.6971969 | 0 |
Return the density of the mask's model. | def mask_density(mask):
return get_number_of_unpruned_weights(mask).float() / get_number_of_weights(mask).float() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return self.nnz/self.dim",
"def density(self):\n return self.get_density()",
"def density( self ) :\n return self.__density",
"def density( self ) :\n return self.__density",
"def density( self ) :\n return self.__density",
"def density(self):\n ... | [
"0.7146775",
"0.7057674",
"0.6915033",
"0.6915033",
"0.6915033",
"0.68925333",
"0.6860638",
"0.68238187",
"0.6782899",
"0.6741262",
"0.67350525",
"0.6734582",
"0.66461",
"0.6584711",
"0.655791",
"0.654934",
"0.6408289",
"0.618068",
"0.6179919",
"0.61492056",
"0.6135738",
"0... | 0.8207859 | 0 |
Return number of unpruned weights. | def get_number_of_unpruned_weights(mask: Mask):
return torch.sum(torch.Tensor([torch.sum(torch.Tensor(values.cpu())) for values in mask.values()])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numWeights(self):\r\n\t\treturn None",
"def nobs(self):\n return self.sum_weights",
"def _count_total_weights(model):\n wlist = get_weights(model)\n numels = []\n for w in wlist:\n numels.append(w.numel())\n return torch.FloatTensor(numels)",
"def getSizeOfWeightVector(layerNeur... | [
"0.7496215",
"0.70635945",
"0.68432814",
"0.6698552",
"0.659073",
"0.6571404",
"0.651708",
"0.64780134",
"0.64242935",
"0.6369788",
"0.63572407",
"0.63535714",
"0.63387597",
"0.63248026",
"0.62749726",
"0.62387",
"0.62387",
"0.62387",
"0.62387",
"0.62387",
"0.6227472",
"0.6... | 0.74434453 | 1 |
Consume (advancing self.pos) some characters based on a regex. The regex is applied to a slice of self.text starting from self.pos and ending at the end of the string. Note that matches are only ever expected at the start of the string slice. | def _consume(self, pattern):
if self.is_finished:
raise StopIteration()
found = re.match(pattern, self.text[self.pos:])
if found is None:
return None
self.pos += found.end()
return found.group() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, content):\n parts = []\n offset = 0\n for match in self.regexp.finditer(content):\n parts.append(content[offset:match.start(0)])\n parts.append(self.replace(match))\n offset = match.end(0)\n parts.append(content[offset:])\n return ''... | [
"0.56725097",
"0.5503764",
"0.5453472",
"0.5173999",
"0.51322013",
"0.50761455",
"0.5026643",
"0.5016195",
"0.49955225",
"0.4988532",
"0.4959381",
"0.49036267",
"0.48756927",
"0.48751032",
"0.48712543",
"0.48695114",
"0.4857852",
"0.484281",
"0.48091012",
"0.48067796",
"0.480... | 0.57993543 | 0 |
The forward model must make a prediction of the experimental data we would expect to measure given a specific state of the system, which is specified by the model parameters theta. | def forward_model(self, x, theta):
# unpack the model parameters
A1, w1, A2, w2, bg = theta
# evaluate the peaks
peak_1 = A1 / ((1 + ((x - self.c1)/w1)**2)*(pi*w1))
peak_2 = A2 / ((1 + ((x - self.c2)/w2)**2)*(pi*w2))
# return the prediction of the data
return peak... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x):\n t1 = self.stn1(x)\n t1 = t1.view(-1, 3, 4)\n p1 = affine_transform(x, t1)\n\n s1 = self.sampler1(p1)\n t2 = self.stn2(s1)\n t2 = t2.view(-1, 3, 4)\n p2 = affine_transform(s1, t2)\n\n s2 = self.sampler2(p2)\n t3 = self.stn3(s2)\n... | [
"0.6502413",
"0.64158374",
"0.6395363",
"0.63500696",
"0.63318604",
"0.6290281",
"0.6255284",
"0.623862",
"0.6229918",
"0.61962885",
"0.61936635",
"0.6185957",
"0.6112231",
"0.61070263",
"0.610672",
"0.60978025",
"0.6096405",
"0.6083371",
"0.6075705",
"0.6052505",
"0.6052505"... | 0.7423029 | 0 |
y is a length n_verts vector of labels returns a length n_verts vector in the same order as the input indicates which block each node is | def _get_block_indices(y):
block_labels, block_inv, block_sizes = np.unique(
y, return_inverse=True, return_counts=True
)
n_blocks = len(block_labels)
block_inds = range(n_blocks)
block_vert_inds = []
for i in block_inds:
# get the inds from the original graph
inds = np... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_block_indices(y: np.ndarray) -> Tuple[List[np.ndarray], range, np.ndarray]:\n block_labels: np.ndarray\n block_inv: np.ndarray\n block_sizes: np.ndarray\n block_labels, block_inv, block_sizes = np.unique(\n y, return_inverse=True, return_counts=True\n )\n\n n_blocks = len(block_la... | [
"0.62348026",
"0.5600089",
"0.54737574",
"0.5428312",
"0.5358455",
"0.53135777",
"0.5248974",
"0.524133",
"0.5223199",
"0.5222416",
"0.5205251",
"0.51775557",
"0.5147562",
"0.5147483",
"0.5099824",
"0.5064149",
"0.50625664",
"0.50625664",
"0.505992",
"0.5052874",
"0.5046085",... | 0.6433956 | 0 |
Function to calculate check digit and return full bowler ID | def UpdateID(bowler):
# initialize weights
weights = [1, 3, 6, 7]
# initialize sum of products
sum_of_products = 0
# loop to compute sum of products
for i in range(len(bowler)):
sum_of_products += int(bowler[i]) * weights[i]
# calculate modulo arithmetic
check_digit = sum_of_prod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bsn(self) -> str:\n\n def _is_valid_bsn(number: str) -> bool:\n total = 0\n multiplier = 9\n\n for char in number:\n multiplier = -multiplier if multiplier == 1 else multiplier\n total += int(char) * multiplier\n multiplier -=... | [
"0.62775725",
"0.6231749",
"0.622409",
"0.6126202",
"0.6122478",
"0.60617286",
"0.60579795",
"0.60528296",
"0.60487413",
"0.60260737",
"0.60089326",
"0.60073733",
"0.59951824",
"0.59918064",
"0.59261274",
"0.59191304",
"0.59167296",
"0.5875953",
"0.5875297",
"0.5875297",
"0.5... | 0.664109 | 0 |
Initialize a new iDevice, setting a unique id | def __init__(self, title, author, purpose, tip, icon, parentNode=None):
log.debug("Creating iDevice")
self.edit = True
self.lastIdevice = True
self.emphasis = Idevice.NoEmphasis
self.version = 0
self.id = unicode(Idevice.nextId)
Idevice.next... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(cls, imei, device_id):\n try:\n imei_device = cls(imei, device_id)\n imei_device.save()\n except Exception:\n raise Exception",
"def init_device(platform=\"Android\", uuid=None, **kwargs):\n cls = import_device_cls(platform)\n dev = cls(uuid, **kwar... | [
"0.6817653",
"0.6420761",
"0.6356844",
"0.6305547",
"0.622365",
"0.6196802",
"0.61091626",
"0.60808223",
"0.60808223",
"0.605584",
"0.6049573",
"0.6039419",
"0.60135734",
"0.599427",
"0.59898573",
"0.598348",
"0.59663177",
"0.5936982",
"0.5934662",
"0.59233546",
"0.58766687",... | 0.6927187 | 0 |
Clone an iDevice just like this one | def clone(self):
log.debug("Cloning iDevice")
newIdevice = copy.deepcopy(self)
return newIdevice | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_device(device, new_name):\n command = 'clone \"%s\" \"%s\"' % (device.udid, new_name)\n device_id = _run_command(command)\n\n # The device ID has a new line at the end. Strip it when returning.\n return device_id[:-1]",
"def clone(self):",
"def clone(self):\n raise NotImplementedEr... | [
"0.7238111",
"0.67687154",
"0.6523191",
"0.651832",
"0.63139325",
"0.6092573",
"0.60587895",
"0.60579824",
"0.60538805",
"0.6049935",
"0.6031564",
"0.60267353",
"0.5998032",
"0.5994472",
"0.5973418",
"0.59654176",
"0.5962842",
"0.59419715",
"0.593527",
"0.5928403",
"0.5903759... | 0.8101924 | 0 |
delete an iDevice from it's parentNode | def delete(self):
while self.userResources:
self.userResources[0].delete()
if self.parentNode:
self.parentNode.idevices.remove(self)
self.parentNode = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeDevice(self, node, fullDeviceName):",
"def delete(self):\n self.parent.delete_node(self)",
"def delete_device(self):\n # PROTECTED REGION ID(CspSubElementSubarray.delete_device) ENABLED START #\n # PROTECTED REGION END # // CspSubElementSubarray.delete_device",
"def delete_... | [
"0.6851124",
"0.64951426",
"0.64106977",
"0.63060063",
"0.62603277",
"0.6254395",
"0.6159923",
"0.61001027",
"0.60352707",
"0.6032872",
"0.5971561",
"0.5924153",
"0.5853628",
"0.5850418",
"0.5822739",
"0.58080447",
"0.57989216",
"0.57989216",
"0.5774701",
"0.5757732",
"0.5755... | 0.7279056 | 0 |
Return true if this is the first iDevice in this node | def isFirst(self):
index = self.parentNode.idevices.index(self)
return index == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_first_cell(self):\n\n return self._executor.is_first_cell()",
"def is_on(self) -> bool:\n raise NotImplementedError(\"Device subclass needs to implement this.\")",
"def recognize_device(self, device):\n return False",
"def is_on(self):\n return bool(self._insteon_device_gro... | [
"0.6101419",
"0.60058457",
"0.5857476",
"0.5807316",
"0.5768552",
"0.5658133",
"0.5645262",
"0.564466",
"0.5624907",
"0.56009805",
"0.5587161",
"0.5583362",
"0.5583204",
"0.5581106",
"0.55721927",
"0.55706275",
"0.55612385",
"0.55323666",
"0.5521172",
"0.5521172",
"0.5521172"... | 0.85065955 | 0 |
Return true if this is the last iDevice in this node | def isLast(self):
index = self.parentNode.idevices.index(self)
return index == len(self.parentNode.idevices) - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_last(self) -> Optional[bool]:\n return pulumi.get(self, \"is_last\")",
"def is_last(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"is_last\")",
"def isFirst(self):\n index = self.parentNode.idevices.index(self)\n return index == 0",
"def is_last_position... | [
"0.72330636",
"0.70814407",
"0.63565904",
"0.6286492",
"0.62641656",
"0.6215419",
"0.61710554",
"0.6045571",
"0.6025509",
"0.59382546",
"0.5908243",
"0.5905103",
"0.58671975",
"0.5860887",
"0.58545214",
"0.58509946",
"0.5844678",
"0.57779473",
"0.5775696",
"0.5762029",
"0.573... | 0.87166387 | 0 |
Upgrades the Idevice class members from version 0 to version 1. Should be called in derived classes. | def _upgradeIdeviceToVersion1(self):
log.debug("upgrading to version 1")
self._title = self.__dict__.get('title', self.title)
self._author = self.__dict__.get('author', self.title)
self._purpose = self.__dict__.get('purpose', self.title)
self._tip = self.__dict__.get('tip'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _upgradeIdeviceToVersion2(self):\n log.debug(\"upgrading to version 2, for 0.12\")\n self.userResources = []\n if self.icon:\n self.systemResources = [\"icon_\"+self.icon+\".gif\"]\n else:\n self.systemResources = []",
"def upgradeToVersion3(self):\n s... | [
"0.66419125",
"0.6461012",
"0.6416738",
"0.6304885",
"0.6278399",
"0.61745286",
"0.6133812",
"0.61181194",
"0.61181194",
"0.6070843",
"0.60104465",
"0.5952816",
"0.5868903",
"0.58070505",
"0.57820904",
"0.57820904",
"0.5702772",
"0.5588109",
"0.55046326",
"0.54860246",
"0.547... | 0.72554654 | 0 |
Upgrades the Idevice class members from version 1 to version 2. Should be called in derived classes. | def _upgradeIdeviceToVersion2(self):
log.debug("upgrading to version 2, for 0.12")
self.userResources = []
if self.icon:
self.systemResources = ["icon_"+self.icon+".gif"]
else:
self.systemResources = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _upgradeIdeviceToVersion1(self):\n log.debug(\"upgrading to version 1\")\n self._title = self.__dict__.get('title', self.title)\n self._author = self.__dict__.get('author', self.title)\n self._purpose = self.__dict__.get('purpose', self.title)\n self._tip = self.__dict... | [
"0.69945484",
"0.6869157",
"0.66040444",
"0.62244797",
"0.62182",
"0.62122685",
"0.61407745",
"0.59281236",
"0.5909978",
"0.5900281",
"0.5865497",
"0.58555174",
"0.58083576",
"0.58083576",
"0.5776942",
"0.5776942",
"0.57502586",
"0.5526123",
"0.550954",
"0.550954",
"0.5411637... | 0.7323693 | 0 |
Scales the predicted boxes in order to be drawable on the image | def scale_boxes(boxes, image_shape):
height = image_shape[0]
width = image_shape[1]
image_dims = K.stack([height, width, height, width])
image_dims = K.reshape(image_dims, [1, 4])
boxes = boxes * image_dims
return boxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rescale_box(box, img_size_orig, img_size_new):\n orig_w, orig_h = img_size_orig\n new_w, new_h = img_size_new\n scale_x = new_w / orig_w\n scale_y = new_h / orig_h\n sx, sy, ex, ey = box\n return [sx * scale_x, sy * scale_y, ex * scale_x, ey * scale_y]",
"def rescaleBox(box_pred, box_true, ... | [
"0.6557506",
"0.65303427",
"0.64935285",
"0.646102",
"0.64112127",
"0.6408017",
"0.63719594",
"0.63689524",
"0.63674325",
"0.63624996",
"0.63514966",
"0.62879807",
"0.61864674",
"0.6119357",
"0.61088264",
"0.60942566",
"0.6082471",
"0.6038492",
"0.6038461",
"0.5983688",
"0.59... | 0.6855609 | 0 |
Computes the forward pass for an affine function. The input x has shape (N, d_1, ..., d_k) and contains a minibatch of N examples, where each example x[i] has shape (d_1, ..., d_k). We will reshape each input into a vector of dimension D = d_1 ... d_k, and then transform it to an output vector of dimension M. | def affine_forward(x, w, b):
############################################################################
# TODO: Implement the affine forward pass. Store the result in 'out'. You #
# will need to reshape the input into rows. #
######################################################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affine_forward(x, w, b):\n out = None\n \n # reshape the input into (N, d_1 *...* d_k)\n input_shape = x.shape\n prod = 1\n for i in range(1,len(input_shape)):\n prod *= input_shape[i]\n\n a = x.reshape(x.shape[0],prod)\n out = np.dot(a,w) + b\n \n cache = (x, w, b)\n re... | [
"0.7094998",
"0.67181295",
"0.67068255",
"0.65999496",
"0.6484268",
"0.6482346",
"0.64567316",
"0.6452318",
"0.6417239",
"0.6345573",
"0.63311523",
"0.6328981",
"0.6287458",
"0.6224862",
"0.6101912",
"0.60300726",
"0.60289514",
"0.59841985",
"0.59634197",
"0.5935654",
"0.5910... | 0.67979425 | 1 |
Factory function returning appropriate XML writer object for chart_type, loaded with series_seq. | def ChartXmlWriter(chart_type, series_seq):
try:
BuilderCls = {
XL_CHART_TYPE.BAR_CLUSTERED: _BarChartXmlWriter,
XL_CHART_TYPE.BAR_STACKED_100: _BarChartXmlWriter,
XL_CHART_TYPE.COLUMN_CLUSTERED: _BarChartXmlWriter,
XL_CHART_TYPE.COLUMN_STACKED: _BarChar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeDataSeriesType(tagname, keyword, G):\n result=[]\n dic = {}\n xpara = G(\"%sParameter\" % keyword)\n if xpara:\n dic[\"parameter\"] = xpara\n xunits = G(\"%sUnits\" % keyword)\n if xunits:\n dic[\"units\"] = xunits\n xid = G(\"%sID\" % keyword)\n if xid:\n dic[\... | [
"0.5418205",
"0.515569",
"0.51371247",
"0.5132969",
"0.50264215",
"0.5010495",
"0.49942213",
"0.48977464",
"0.4818085",
"0.4813571",
"0.48001945",
"0.47948703",
"0.47724935",
"0.47693497",
"0.47579697",
"0.47444847",
"0.4737446",
"0.47120693",
"0.47107217",
"0.4710302",
"0.47... | 0.8219975 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.