query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Calculate m^2 area of a wgs84 square pixel. | def area_of_pixel(pixel_size, center_lat):
a = 6378137 # meters
b = 6356752.3142 # meters
e = numpy.sqrt(1-(b/a)**2)
area_list = []
for f in [center_lat+pixel_size/2, center_lat-pixel_size/2]:
zm = 1 - e*numpy.sin(numpy.radians(f))
zp = 1 + e*numpy.sin(numpy.radians(f))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n area = 0\n last = self._coordinates[-1]\n for c in self._coordinates:\n area += (last[0] * c[1] - last[1] * c[0])\n last = c\n return float(\"{:.2f}\".format(abs(area) * 0.5))",
"def area(x, y):\n return x*y/2",
"def area(self):\n\n ... | [
"0.65402156",
"0.6536346",
"0.6490702",
"0.6384468",
"0.63473636",
"0.63410383",
"0.6317995",
"0.626634",
"0.62533635",
"0.6233821",
"0.6206045",
"0.6205743",
"0.6197351",
"0.6186741",
"0.61692876",
"0.6156493",
"0.6140983",
"0.6107988",
"0.6099527",
"0.6079559",
"0.6050664",... | 0.0 | -1 |
Return an entire dict of a specific class_reference, with value that not in partial_dict value in template. | def make_entity_dict(class_reference, template, partial_dict):
_data = class_reference.properties()
for _key in _data:
_data[_key] = partial_dict.get(_key, template.get(_key, ''))
return _data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_by_class(dict_,class_):\n v = None\n for c in classlist(class_)[::-1]:\n if c in dict_:\n v = dict_[c]\n break\n return v",
"def invert_classes(orig_dict):\r\n inv_dict = {}\r\n for email_filename, truth in orig_dict.items():\r\n inv_dict[email_filena... | [
"0.50671744",
"0.49810186",
"0.48294201",
"0.47631404",
"0.4757528",
"0.4741675",
"0.4732998",
"0.47204667",
"0.46938542",
"0.4665725",
"0.46034804",
"0.45980883",
"0.4587361",
"0.4571944",
"0.45580745",
"0.45361668",
"0.45161417",
"0.45152247",
"0.45052987",
"0.44999406",
"0... | 0.6825306 | 0 |
Gets the current value of the bits. | def getValue(self):
return DPxGetDinValue() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n if hasattr(self, '_m_value'):\n return self._m_value if hasattr(self, '_m_value') else None\n\n self._m_value = (self.b & 127)\n return self._m_value if hasattr(self, '_m_value') else None",
"def get_current_value(self):\n assert(self.is_s... | [
"0.75253373",
"0.70285946",
"0.6814496",
"0.67528015",
"0.66390926",
"0.6631336",
"0.66143584",
"0.65567166",
"0.65440804",
"0.6476098",
"0.6441274",
"0.6407309",
"0.6400492",
"0.6391237",
"0.63809025",
"0.6347824",
"0.63405514",
"0.63405514",
"0.6340113",
"0.63310176",
"0.62... | 0.0 | -1 |
Sets the port direction mask. Sets the port direction for each bit. The mask is one value representing all bits from the port. The given ``bit_mask`` will set the direction of all digital input bits. For each bit which should drive its port, the corresponding ``bit_mask`` value should be set to 1. An hexadecimal ``bit_... | def setBitDirection(self, bit_mask):
DPxSetDinDataDir(bit_mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMask(self, mask):\n self.mask = mask",
"def set_mask(self, mask):\n self.mask = mask",
"def set_port_direction(self, port, direction):\n\n if port == 1:\n self.__bus.write_byte_data(\n self.__ioaddress, self.IODIRB, direction)\n self.__port_b_dir... | [
"0.5917578",
"0.58691025",
"0.5745566",
"0.5460471",
"0.53694445",
"0.53694445",
"0.5368885",
"0.5268375",
"0.5166452",
"0.50176686",
"0.49800947",
"0.4959418",
"0.49519765",
"0.49120265",
"0.49073195",
"0.47790155",
"0.47614002",
"0.4739055",
"0.4738864",
"0.46848133",
"0.46... | 0.7326797 | 0 |
Gets the Ram buffer size. This method allows the user to get the RAM buffer size used in schedules. | def getBufferSize(self):
return DPxGetDinBuffSize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ram_size(self):\n\t\treturn call_sdk_function('PrlVmCfg_GetRamSize', self.handle)",
"def get_usage_ram_size(self):\n\t\treturn call_sdk_function('PrlStat_GetUsageRamSize', self.handle)",
"def get_total_ram_size(self):\n\t\treturn call_sdk_function('PrlStat_GetTotalRamSize', self.handle)",
"def get_fr... | [
"0.8083486",
"0.791237",
"0.77963513",
"0.77706224",
"0.7756433",
"0.7748938",
"0.7529886",
"0.7499676",
"0.7441068",
"0.7184475",
"0.70885414",
"0.69414234",
"0.69116664",
"0.69116664",
"0.6875057",
"0.68390083",
"0.6790145",
"0.6668991",
"0.66353095",
"0.6604294",
"0.653586... | 0.5958043 | 47 |
Sets the schedule onset value. This method allows the user to set the nanosecond delay between schedule start and first sample. If no delay is required, this method does not need to be used. Default value is 0. | def setScheduleOnset(self, onset):
DPxSetDinSchedOnset(onset) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setStartTime(self, t0):\n self._simulator_.update(t0=t0)\n return",
"def setDelay(self, *args):\n return _libsbml.Event_setDelay(self, *args)",
"def schedule(self, schedule):\n \n self._schedule = schedule",
"def schedule(self, schedule):\n\n self._schedule = sch... | [
"0.6216358",
"0.6119197",
"0.5969866",
"0.58590484",
"0.58590484",
"0.5728359",
"0.57192093",
"0.56866515",
"0.5665514",
"0.56502134",
"0.5632581",
"0.56279105",
"0.561515",
"0.56134814",
"0.56101656",
"0.560535",
"0.5596059",
"0.5577898",
"0.5549093",
"0.55241936",
"0.547113... | 0.6835493 | 0 |
Gets the schedule count value. This method allows the user to get the current count for a schedule. | def getScheduleCount(self):
return DPxGetDinSchedCount() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self) -> int:\n return pulumi.get(self, \"count\")",
"def get_count(self):\n return self.count",
"def get_count(self):\n return self.count",
"def get_count(self):\r\n return self.count",
"def count(self):\n with self._block:\n counter = re.search(r'co... | [
"0.68729573",
"0.6747663",
"0.6747663",
"0.6683865",
"0.6672399",
"0.6664099",
"0.66408926",
"0.6599058",
"0.65461475",
"0.65461475",
"0.6529244",
"0.6523279",
"0.6420016",
"0.6383871",
"0.63235503",
"0.63027096",
"0.63027096",
"0.63027096",
"0.63027096",
"0.63027096",
"0.630... | 0.76366657 | 0 |
stop the active schedule for a given subsystem. Depending on how the Schedules are configured, it may not be necessary to call this method. When a schedule is using a count down, it is not required to stop the schedule. | def stopSchedule(self):
DPxStopDinSched() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n schedule = self._schedules[self._index]\n schedule.stop()\n self._stopped.set()\n self._started.clear()",
"def stop():\n # Wyczyszczenie schedulera spowoduje czyste zakonczenie watku\n with lock:\n global running, s\n\n for event in s.queue:\n ... | [
"0.69434714",
"0.66351914",
"0.64332634",
"0.64238137",
"0.63299674",
"0.6325",
"0.6272689",
"0.6229594",
"0.62203455",
"0.6216021",
"0.6180752",
"0.61679214",
"0.6031662",
"0.59153944",
"0.5877905",
"0.5872941",
"0.58612496",
"0.5852913",
"0.5841851",
"0.58382374",
"0.583038... | 0.6908405 | 1 |
Create required parameters dict for the request. | def build_params(self, season_id):
return {
'College': '',
'Conference': '',
'Country': '',
'DateFrom': '',
'DateTo': '',
'Division': '',
'DraftPick': '',
'DraftYear': '',
'GameScope': '',
'Ga... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_required_params():\n return {}",
"def request_params(self):\n return {'key': self.key, 'hash': self.hash}",
"def _required_parameters(self) -> RequiredParameters:\n return RequiredParameters([])",
"def _required_parameters(self) -> RequiredParameters:\n return RequiredPara... | [
"0.8375964",
"0.7456644",
"0.73895395",
"0.73895395",
"0.73788327",
"0.7118652",
"0.69378275",
"0.6885733",
"0.6865472",
"0.68040067",
"0.6757807",
"0.6757768",
"0.6751884",
"0.67383516",
"0.67104787",
"0.67062324",
"0.66926634",
"0.668606",
"0.6682524",
"0.66766566",
"0.6648... | 0.0 | -1 |
Return the name of the device if any. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_name(self) -> Optional[str]:\n return pulumi.get(self, \"device_name\")",
"def device_name(self) -> Optional[str]:\n return pulumi.get(self, \"device_name\")",
"def name(self):\n return self._device.name",
"def name(self):\n return self._device.name",
"def name(self):... | [
"0.89734465",
"0.89734465",
"0.8584627",
"0.8584627",
"0.8584627",
"0.8502048",
"0.84944665",
"0.84194607",
"0.83955586",
"0.83955586",
"0.8379756",
"0.83165",
"0.8306566",
"0.8161454",
"0.81564134",
"0.8090303",
"0.8087526",
"0.8073198",
"0.8006941",
"0.7999654",
"0.79544145... | 0.0 | -1 |
Return the state attributes of the device. | def device_state_attributes(self):
return self._device.status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_a... | [
"0.92738223",
"0.92053986",
"0.91516256",
"0.91516256",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148889",
"0.9148746",
"0.9148746",
"0.9137698",
"0.9110632",... | 0.8948436 | 25 |
Constructor for ModelCheckpoint class. | def __init__(self, mode: str = "min", monitor: str = "val_loss"):
super(ModelCheckpoint, self).__init__(order=CallbackOrder.INTERNAL)
self.mode = mode
self.eps = 1e-7
if "val_" not in monitor:
self.monitor = "val_" + monitor
else:
self.monitor = monitor
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n # Number of examples per epoch of training data.\n self.num_examples_per_epoch = None \n\n # Optimizer for training the model.\n self.optimizer = \"SGD\" #default \"SGD\"\n\n # Learning rate for the initial phase of training.\n self.initial_learning_r... | [
"0.7281369",
"0.71553236",
"0.6797001",
"0.6615878",
"0.6603439",
"0.6576648",
"0.64174026",
"0.64138556",
"0.64057535",
"0.6377543",
"0.6356363",
"0.63517433",
"0.6340139",
"0.6309982",
"0.6290898",
"0.6272829",
"0.6242992",
"0.6237599",
"0.62232536",
"0.6216645",
"0.6207713... | 0.585373 | 74 |
Returns a JSON response, transforming 'context' to make the payload. | def render_to_json_response(self, context, **response_kwargs):
return JsonResponse(
self.get_data(context),
**response_kwargs
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_to_response(self, context):\n return self.get_json_response(self.convert_context_to_json(context))",
"def render_to_response(self, context):\n\t\treturn self.get_json_response(self.convert_context_to_json(context))",
"def render_to_json_response(self, context, **response_kwargs):\n ret... | [
"0.7898263",
"0.7824009",
"0.76766837",
"0.76766837",
"0.7560496",
"0.75058556",
"0.73821956",
"0.73662317",
"0.7348336",
"0.7347456",
"0.7309291",
"0.7130906",
"0.6941217",
"0.6892298",
"0.6722085",
"0.663044",
"0.663044",
"0.663044",
"0.663044",
"0.6624278",
"0.66101027",
... | 0.74115 | 6 |
Evaluate the fault displacement magnitude at each location | def evaluate_fault_displacements(self,points,scale=True):
if scale:
points = self.scale(points,inplace=False)
vals = np.zeros(points.shape[0])
for f in self.features:
if f.type == 'fault':
disp = f.displacementfeature.evaluate_value(points)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude(self): # @todo @caution check: something wrong?\n\n return (math.sqrt(reduce(lambda x, y: x+y,\n [x**2 for x in self.vector])))",
"def computeMagnitudeErr(instFluxErr, instFlux, calibrationErr, calibration, flux):\n return 2.5/np.log(10)*computeMaggiesErr(instFluxErr, instF... | [
"0.6223352",
"0.6206339",
"0.60708314",
"0.59685576",
"0.58984625",
"0.58571744",
"0.583324",
"0.583021",
"0.58124584",
"0.58124584",
"0.57992333",
"0.5795835",
"0.5777622",
"0.5743629",
"0.57335776",
"0.57301664",
"0.5714974",
"0.5699999",
"0.5662668",
"0.56319606",
"0.56078... | 0.6674907 | 0 |
compute the haversine distance between a list coordinates (coord1) and a given coordinate (coord2) | def haversine(coord1, coord2):
return 2 * RADIUS_EARTH * ny.arcsin(ny.sqrt(ny.sin((coord1[:,0] - coord2[0])/2 ) ** 2 + ny.cos(coord2[0])*ny.cos(coord1[:,0]) * ny.sin((coord2[1] -coord1[:,1])/2) **2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_distance_haversine(coord1, coord2):\n lat1, lon1 = coord1\n lat2, lon2 = coord2\n # approximate radius of earth in km\n R = 6373.0\n\n lat1 = radians(lat1)\n lon1 = radians(lon1)\n lat2 = radians(lat2)\n lon2 = radians(lon2)\n\n dlon = lon2 - lon1\n dlat = lat2 - lat1\n\n ... | [
"0.8296543",
"0.7935986",
"0.7933038",
"0.7917138",
"0.7911019",
"0.78857344",
"0.78799397",
"0.7875213",
"0.7873103",
"0.78551435",
"0.7850477",
"0.7834798",
"0.7823377",
"0.7823297",
"0.7819288",
"0.7812433",
"0.78033155",
"0.7796257",
"0.7777385",
"0.7775714",
"0.77681005"... | 0.8420375 | 0 |
Assert that two requests are 'equal'. This is the most complicated due to how we serialize parent and children requests to avoid reference loops. Parent fields will not serialize their children. That's why compare_parent asserts that the children field is None. The requests in the children field will not serialize thei... | def assert_request_equal(obj1, obj2, do_raise=False):
def assert_all_none(*args):
for arg in args:
_assert(arg is None, "")
# Parent requests will not serialize their children since that's a loop
def compare_parent(req1, req2):
_assert_wrapper(
req1,
req... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_different(self):\n\n x = self.start_request_tests(service.get_request('POST', {u'tree1_nwk': '((a,b)c);',\n u'tree2_nwk': '(a,(b,c));'}))\n # Insert: whether result is what it should be according to docs\n self.assert_su... | [
"0.64876235",
"0.6483889",
"0.6478216",
"0.63430804",
"0.62925184",
"0.62247574",
"0.62030923",
"0.6143838",
"0.60958076",
"0.60471195",
"0.60339016",
"0.60040253",
"0.59565103",
"0.59553313",
"0.5901126",
"0.5869842",
"0.58462864",
"0.58453465",
"0.5840993",
"0.5840375",
"0.... | 0.79267335 | 0 |
Return whether there are OIDs to fetch. | def has_oids(self):
# type: () -> bool
return bool(self.scalar_oids or self.next_oids or self.bulk_oids) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_orcid(self):\n try:\n if self.orcid:\n return True\n except Orcid.DoesNotExist:\n pass\n return False",
"def available(self):\n #return not self.anonymous and len(self._data())\n return True",
"def any_author_exists(self):\n ... | [
"0.6610158",
"0.6299308",
"0.627192",
"0.6152724",
"0.6100274",
"0.6010182",
"0.6003457",
"0.59998894",
"0.5993669",
"0.59936076",
"0.59219676",
"0.58593106",
"0.5822894",
"0.58148885",
"0.5794466",
"0.5760256",
"0.5752229",
"0.57419944",
"0.57393235",
"0.5730104",
"0.5728904... | 0.6889557 | 0 |
x.__nonzero__() x != 0 | def __nonzero__(self): # real signature unknown; restored from __doc__
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __nonzero__(self):\n for e in self:\n if e != 0:\n return True\n return False",
"def __nonzero__(self):\n return self.value.__nonzero__()",
"def __nonzero__(self):\n return self.__nonzero",
"def __nonzero__(self):\n return self.__nonzero",
"def _... | [
"0.77507436",
"0.76362675",
"0.74977964",
"0.74977964",
"0.749715",
"0.7277969",
"0.71057385",
"0.70980686",
"0.7076215",
"0.7038673",
"0.7013006",
"0.69773006",
"0.6971467",
"0.69356734",
"0.6927782",
"0.6920768",
"0.690163",
"0.6892301",
"0.6864851",
"0.6852248",
"0.6836008... | 0.61815006 | 78 |
x.__nonzero__() x != 0 | def __nonzero__(self): # real signature unknown; restored from __doc__
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __nonzero__(self):\n for e in self:\n if e != 0:\n return True\n return False",
"def __nonzero__(self):\n return self.value.__nonzero__()",
"def __nonzero__(self):\n return self.__nonzero",
"def __nonzero__(self):\n return self.__nonzero",
"def _... | [
"0.77507436",
"0.76362675",
"0.74977964",
"0.74977964",
"0.749715",
"0.7277969",
"0.71057385",
"0.70980686",
"0.7076215",
"0.7038673",
"0.7013006",
"0.69773006",
"0.6971467",
"0.69356734",
"0.6927782",
"0.6920768",
"0.690163",
"0.6892301",
"0.6864851",
"0.6852248",
"0.6836008... | 0.61815006 | 79 |
Set up test data for the whole TestCase (only run once for the TestCase) | def setUpTestData(cls):
data_gen.run() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n\n self.test_data_path = 'testing/test_data/'",
"def setUp(self):\n self.dataset = get_test_dataset()",
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUp(self):\n self.dataset = self.dataset_cls()",
"def setUp... | [
"0.8151314",
"0.81394684",
"0.805013",
"0.7755899",
"0.77489984",
"0.77354276",
"0.7571873",
"0.75621843",
"0.7557796",
"0.75538814",
"0.75478435",
"0.75068873",
"0.7504429",
"0.7477761",
"0.74667764",
"0.7459755",
"0.744017",
"0.74311286",
"0.743051",
"0.7430405",
"0.7407945... | 0.804802 | 4 |
Returns the average Lipschitz constant of individual losses. This is particularly useful for stepsize tuning of some solvers. Returns | def get_lip_mean(self) -> float:
if self._fitted:
return self._model.get_lip_mean()
else:
raise ValueError("call ``fit`` before using ``get_lip_max``") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kl_loss(self):\n return sum([p.kl_loss() for p in self.parameters])",
"def lapse(self):\n pass",
"def get_duct_linear_heat_loss_coefficient() -> float:\n return 0.49",
"def profit_loss(self) -> float:\n return self.net_worth / self.initial_net_worth",
"def get_loss(self):\n ... | [
"0.6473362",
"0.6340902",
"0.6306362",
"0.62927824",
"0.6193142",
"0.61590755",
"0.6148258",
"0.6075791",
"0.6062522",
"0.6056253",
"0.6053945",
"0.60419226",
"0.5998071",
"0.59977627",
"0.59831244",
"0.5978852",
"0.5951738",
"0.5946855",
"0.59379184",
"0.58999115",
"0.589791... | 0.53774506 | 100 |
Update the binary classification weights. | def update_weights(self, weight_priors, latent_mat, output_mat):
new_weights = {'mu': np.zeros(weight_priors['alpha'].shape),
'sigma': np.zeros((self.task_count,
self.R + 1, self.R + 1))}
h_sum = np.sum(latent_mat['mu'], axis=1)
h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def updateWeights(self,weightUpdate):\n\t\n\t... | [
"0.81484026",
"0.7942983",
"0.7688436",
"0.7426983",
"0.7407733",
"0.72915196",
"0.7123603",
"0.71039957",
"0.69634324",
"0.6960061",
"0.6852013",
"0.6832201",
"0.6823326",
"0.6806129",
"0.6785535",
"0.67735934",
"0.6764993",
"0.67589414",
"0.6729023",
"0.6715791",
"0.6697946... | 0.0 | -1 |
Returns the number of seconds from the epoch to date. Should match the number returned by the equivalent function in postgres. | def epoch_seconds(date):
td = date - epoch
return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def epoch_seconds(date):\r\n td = date - epoch\r\n return td.days * 86400 + td.seconds + (float(td.microseconds) / 1000000)",
"def seconds_since_epoch(date_time, epoch=None):\n return microseconds_since_epoch(date_time) / 10.0**6",
"def _current_epoch_secs():\n now = datetime.datetime.utcnow()\n epo... | [
"0.8104526",
"0.7947113",
"0.750754",
"0.7160082",
"0.70695573",
"0.68526405",
"0.67466754",
"0.6745077",
"0.6721347",
"0.66505826",
"0.6621885",
"0.6621885",
"0.6607314",
"0.6590369",
"0.65068203",
"0.64717203",
"0.6453204",
"0.64264446",
"0.6402945",
"0.6367948",
"0.6337083... | 0.8093896 | 1 |
Build a dictionary through a list of words | def buildDict(self, dict):
self.all_words = set(dict)
self.wc_dict = collections.defaultdict(int)
for w in dict:
for wc in self.get_wildcards(w):
self.wc_dict[wc] += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_dict(word_list):\r\n\r\n # initialize a dictonary\r\n d = dict()\r\n\r\n # iterate through the word_list, mapping sorted letters to word\r\n for i in word_list:\r\n\r\n # key - sorted letters in the word\r\n # how to sort ? --> convert to list, then sort. Finally join the sorted... | [
"0.7771935",
"0.7714796",
"0.76650697",
"0.75896126",
"0.75077",
"0.7402118",
"0.7371921",
"0.7257023",
"0.724838",
"0.72190464",
"0.71511894",
"0.7121465",
"0.70906883",
"0.70329714",
"0.69910663",
"0.6939837",
"0.6926235",
"0.69013107",
"0.68620795",
"0.68157786",
"0.680981... | 0.6463316 | 40 |
Returns if there is any word in the trie that equals to the given word after modifying exactly one character | def search(self, word):
for wc in self.get_wildcards(word):
# Don't forget word not in self.all_words
if wc in self.wc_dict and (self.wc_dict[wc] > 1 or word not in self.all_words) :
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_word(trie, string: str) -> bool:\n return any(w == string for w in trie)",
"def search(self, word):\n curr = self.trie\n for i, ch in enumerate(word):\n curr = curr.get(ch, {})\n if curr:\n continue\n else:\n break\n \n... | [
"0.78987586",
"0.7713067",
"0.76827085",
"0.7650699",
"0.74977815",
"0.74953616",
"0.7492678",
"0.74721324",
"0.7441035",
"0.7440776",
"0.7415909",
"0.7413349",
"0.73969525",
"0.7383449",
"0.7365638",
"0.7334273",
"0.73318183",
"0.72946453",
"0.72943574",
"0.72771394",
"0.727... | 0.6678582 | 81 |
Uses the POST api endpoint to post a single sensor reading. | def post(meas_type, unit, value, timestamp=True):
payload = {"key": meas_type, "unit": unit, "value": value, "lat": MY_LAT, "lon": MY_LON}
if timestamp:
payload["timestamp"] = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
resp = requests.post(POST_URL, data=payload)
return resp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request, pk):\n json_data = open(settings.BASE_DIR+'/sensorapp/sensor_data.json').read()\n jsonData = json.loads(json_data)\n sdata = jsonData[\"sensor_data\"]\n respose_data = []\n for data in sdata:\n data[\"reading_timestamp\"] = time.mktime(datetime.... | [
"0.68284583",
"0.64752597",
"0.61823404",
"0.6127135",
"0.6031738",
"0.6024244",
"0.5988254",
"0.57938683",
"0.57245433",
"0.5701917",
"0.56954366",
"0.56829286",
"0.56318027",
"0.55595946",
"0.55236",
"0.5492572",
"0.5489064",
"0.5471483",
"0.5461013",
"0.5447577",
"0.542669... | 0.53772163 | 22 |
Given a review ID, return the description associated with that review. | def get_description(self, id, year=None):
year = self.get_year(id, switch='reviews') if year is None else year
review = self.get_review(id, year)
return review['description'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_review(self, id_):\n cursor = self._connection.cursor()\n select_command = make_select_command(\"reviews\")\n select_command += \" WHERE id_ = ?\"\n cursor.execute(select_command, (id_,))\n for row in cursor:\n return expandable_from_tuple(row, FIELD_DESCRIPTIONS) \n return None",... | [
"0.787991",
"0.7046271",
"0.67535424",
"0.6628309",
"0.65394425",
"0.64600104",
"0.64537233",
"0.64390373",
"0.6385218",
"0.59808385",
"0.59547967",
"0.58935773",
"0.5813767",
"0.5792099",
"0.5784452",
"0.5667967",
"0.56483",
"0.5647745",
"0.5644596",
"0.5643746",
"0.5622614"... | 0.8336716 | 0 |
Get the total free energy of a harmonic oscillator with this frequency and these atoms. Temperatures are clipped at 1 microKelvin. | def get_classical_harmonic_free_energy(self, temperatures=None):
if temperatures is None:
temperatures = self.input.temperature
temperatures = np.clip(temperatures, 1e-6, np.inf)
beta = 1.0 / (KB * temperatures)
return (
-3
* len(self.input.structure)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quantum_harmonic_free_energy(self, temperatures=None):\n if temperatures is None:\n temperatures = self.input.temperature\n temperatures = np.clip(temperatures, 1e-6, np.inf)\n beta = 1.0 / (KB * temperatures)\n f = 0\n for m in self.input.structure.get_masses(... | [
"0.7245388",
"0.70027137",
"0.69853157",
"0.6729733",
"0.6721604",
"0.66150934",
"0.6579566",
"0.6450256",
"0.64264965",
"0.6419435",
"0.6412604",
"0.6394664",
"0.63616216",
"0.6354492",
"0.63448423",
"0.6294995",
"0.6291252",
"0.62784314",
"0.62776107",
"0.6254628",
"0.62499... | 0.67386603 | 3 |
Get the total free energy of a harmonic oscillator with this frequency and these atoms. Temperatures are clipped at 1 microKelvin. | def get_quantum_harmonic_free_energy(self, temperatures=None):
if temperatures is None:
temperatures = self.input.temperature
temperatures = np.clip(temperatures, 1e-6, np.inf)
beta = 1.0 / (KB * temperatures)
f = 0
for m in self.input.structure.get_masses():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free_energy(self, T=0, P=0, mus={}):\n # global environment\n return self.energy",
"def get_energy(self):\n return self.momentum*self.momentum/(2*self.mass)",
"def get_classical_harmonic_free_energy(self, temperatures=None):\n if temperatures is None:\n temperatures =... | [
"0.7003301",
"0.6984585",
"0.6740122",
"0.67287576",
"0.67200327",
"0.6613455",
"0.65786207",
"0.6449017",
"0.6427686",
"0.64179045",
"0.64122105",
"0.6393598",
"0.6360696",
"0.63530034",
"0.63423496",
"0.629455",
"0.62888",
"0.62775683",
"0.6276775",
"0.6253897",
"0.62496376... | 0.72456896 | 0 |
Posting a post with an invalid body | def testInvalidData(self):
data = {
"title": 32,
"rent": 700
}
response = self.client.post("/api/posts",
data=json.dumps(data),
content_type="application/json",
headers=[("Accept", "application/json")]
)
self.assertEqu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_missing_body(self):\n self._login_as_staff()\n response = self.client.post(self.path())\n assert response.status_code == 400",
"def test_post_no_content(self):\n response = self.post(title='foo')\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST... | [
"0.72845495",
"0.70353395",
"0.6914541",
"0.6890934",
"0.6829769",
"0.68229645",
"0.67496055",
"0.66929364",
"0.6626599",
"0.6624536",
"0.6614122",
"0.66037023",
"0.6530199",
"0.64720976",
"0.64591336",
"0.63967395",
"0.6393242",
"0.63932115",
"0.63788515",
"0.6335431",
"0.63... | 0.6453764 | 15 |
Timezone aware UTC now. | def utcnow() -> datetime.datetime:
return datetime.datetime.utcnow().replace(tzinfo=pytz.UTC) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nowUTC():\n return datetime.datetime.now(pytz.utc)",
"def utc_now():\n return datetime.now(tz=timezone.utc)",
"def now_utc() -> datetime:\n return datetime.now(timezone.utc)",
"def datetime_utc_now() -> datetime:\n return datetime.now(timezone.utc)",
"def utc_now():\n realtime = datetime... | [
"0.8509725",
"0.83848816",
"0.822516",
"0.8159737",
"0.81217617",
"0.8110946",
"0.8104256",
"0.8081836",
"0.8045279",
"0.7912622",
"0.7880216",
"0.784423",
"0.7733743",
"0.7718092",
"0.76843685",
"0.76723087",
"0.74987286",
"0.74987286",
"0.74686915",
"0.744483",
"0.73215675"... | 0.7934128 | 9 |
Return duration in seconds. | def elapsed(self):
if self.start and self.end:
return (self.end - self.start).total_seconds()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duration_in_seconds(self):\n return self.get_data(\"duration_in_seconds\")",
"def duration_seconds(self):\n duration = 0.0\n if self.is_video() or self.is_audio():\n if self.__dict__['duration']:\n try:\n duration = float(self.__dict__['durati... | [
"0.852767",
"0.8103076",
"0.8089623",
"0.8077145",
"0.8036213",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7942442",
"0.7940655",
"0.7915932",
"0.78827506",
"0.78798556",
"0.7866422",
"0.78646374",
"0.786395",
"0.78328675",
... | 0.0 | -1 |
Record the end timestamp for the given key. Can be called multiple times with the same key, which will keep overwriting the previous `end` timestamp. | def end(self, key):
if key not in self:
raise KeyError(
"`start` missing for {}, cannot record end.".format(key)
)
self[key] = Interval(self[key].start, utcnow()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_end(self, ts):\n base_key = self.floor_time(ts)\n if self.last_timestamp is None or base_key > self.last_timestamp:\n self.last_timestamp = base_key",
"def end_time_stamp(self, end_time_stamp):\n\n self._end_time_stamp = end_time_stamp",
"def end(self, end):\n if ... | [
"0.69299734",
"0.67263526",
"0.64030427",
"0.6373018",
"0.6339404",
"0.6339404",
"0.63353074",
"0.63353074",
"0.63353074",
"0.62768495",
"0.62768495",
"0.62768495",
"0.6258943",
"0.6013547",
"0.5966932",
"0.59355545",
"0.5928336",
"0.5925922",
"0.5910351",
"0.59091824",
"0.59... | 0.72512233 | 0 |
Format seconds in hours / minutes / seconds in readable format. >>> format_duration(3730) 1 hours 2 minutes 10 seconds | def format_duration(duration: int) -> str:
assert duration > 0, "`duration` must be nonzero number."
hours = duration / 3600
minutes = duration // 60 % 60
seconds = duration % 60
result = []
if hours >= 1:
result.append("{} hours".format(hours))
if minutes >= 1:
result.appe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_seconds(duration):\n\treturn stats_utils.format_seconds(duration)",
"def format_duration(seconds: float) -> str:\n if seconds < 60:\n return f'{seconds:.0f}s'\n elif seconds < 3600:\n minutes = math.floor(seconds / 60)\n seconds -= minutes * 60\n return f'{minutes}m{seconds:.0f}s'\n els... | [
"0.8108612",
"0.7742682",
"0.74755687",
"0.7340124",
"0.7328268",
"0.7299271",
"0.71376383",
"0.70367026",
"0.6974592",
"0.6938442",
"0.6870475",
"0.68475163",
"0.68394333",
"0.67895496",
"0.6773892",
"0.67423147",
"0.6723701",
"0.66851234",
"0.66821474",
"0.6650317",
"0.6629... | 0.77792287 | 1 |
Returns right boundary mps __| __| __| | def get_right_mps(D, L):
mps = np.zeros([L], np.object)
#ten0 = np.zeros([D, D],np.object) # <-- bottom-most
#teni = np.zeros([D, D, D],np.object) # <-- general
ten0 = np.zeros([D, D]) # <-- bottom-most
teni = np.zeros([D, D, D]) # <-- general
ten0[z, z] = 1
ten0[a, a] = 1
teni[z,a,z]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mw_boundaries(self):\n phi = np.arange(0., 2.0*np.pi, 0.1)\n theta_l = np.ones_like(phi)* 110 * np.pi / 180.\n theta_h = np.ones_like(phi)* 70 * np.pi / 180.\n ra_l, dec_l = self.gc2radec(phi, theta_l)\n ra_h, dec_h = self.gc2radec(phi, theta_h)\n return (ra_h, dec_h),... | [
"0.6416118",
"0.6079651",
"0.59029",
"0.5893384",
"0.5807296",
"0.5682659",
"0.56805384",
"0.5666723",
"0.56307274",
"0.5573946",
"0.55631995",
"0.55461586",
"0.5504188",
"0.54996026",
"0.5487034",
"0.5478181",
"0.54719824",
"0.5462099",
"0.54616183",
"0.5426012",
"0.5426012"... | 0.5476311 | 16 |
Test whether the highlevel GFF3 interface can properly read the features from a GFF3 file and write these properties to a file without data changing. The 'phase' is tested additionally, since it is not part of a `Feature` object. | def test_conversion_highlevel(path):
gff_file = gff.GFFFile.read(join(data_dir("sequence"), path))
ref_annot = gff.get_annotation(gff_file)
ref_phases = []
for _, _, type, _, _, _, _, phase, _ in gff_file:
if type == "CDS":
ref_phases.append(phase)
gff_file = gff.GFFFile()
g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_gff3(self,gff3_file):\r\n with open(gff3_file) as infile:\r\n set = None\r\n for line in infile:\r\n if line[0] == '#':\r\n if line[:3] == '###' and set:\r\n self.sets.append(set)\r\n set = None\r\... | [
"0.5861071",
"0.55998117",
"0.55320144",
"0.552993",
"0.55164295",
"0.5408356",
"0.53901905",
"0.5344513",
"0.53081614",
"0.52478",
"0.52320164",
"0.5230046",
"0.5220379",
"0.52139574",
"0.51998216",
"0.518737",
"0.5185574",
"0.518532",
"0.5182513",
"0.5175064",
"0.51746464",... | 0.5445151 | 5 |
Setup the sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
ham_data = hass.data.get(DATA_HAM)
if not ham_data:
return
sensors = []
data_provider = {
ATTR_WEEKDAY: {
ATTR_STATE: ham_data.get_weekday,
ATTR_ATTRIBUTES: None
},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_platform(hass, config, add_devices, discovery_info=None):\n thread1 = QQ(config[QQ_NUMBER])\n thread1.start()\n object_qq = Qqsensor(hass, QQ_NUMBER, thread1)\n add_devices([object_qq])",
"def setup_sensors(self, configs):\n self.__sensors = self.setup_components(configs, 'scale_clie... | [
"0.7249521",
"0.7210104",
"0.7194671",
"0.7163429",
"0.7035067",
"0.6979973",
"0.6975266",
"0.69677466",
"0.696644",
"0.6903852",
"0.690341",
"0.6835207",
"0.6825917",
"0.680988",
"0.679155",
"0.67871094",
"0.6784935",
"0.6776815",
"0.6770015",
"0.67620605",
"0.67544883",
"... | 0.6571912 | 35 |
Return the state of this sensor. | def state(self):
return self._state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n return self.device.device_data[self.device_id][self._sensor_type]",
"def state(self):\n if self.coordinator.data:\n return self.coordinator.data[self._sensor]",
"def state(self):\n return self.device.value()",
"def state(self):\n return self._device.v... | [
"0.8998373",
"0.8456933",
"0.8426156",
"0.8404828",
"0.8316373",
"0.82554173",
"0.82472205",
"0.817695",
"0.8155576",
"0.80494386",
"0.8019522",
"0.8004513",
"0.7848942",
"0.7848942",
"0.7800974",
"0.7787611",
"0.7747029",
"0.7741532",
"0.77304995",
"0.7725836",
"0.7724544",
... | 0.0 | -1 |
Return the state attributes. | def device_state_attributes(self):
return self._attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.8273077",
"0.82236886",
"0.8223562",
"0.8205066",
"0.8184393",
"0.81659013",
"0.8102565",
"0.8064994",
"0.8064994",... | 0.82871646 | 14 |
Return the full path to the data directory, ensuring that it exists. If the 'data_dir' configuration parameter is set, checks that it exists and returns it (doesn't automatically create it). Otherwise, uses `(astropy cache dir)/sncosmo` (automatically created if it doesn't exist). | def get_data_dir():
if conf.data_dir is not None:
if os.path.isdir(conf.data_dir):
return conf.data_dir
else:
raise RuntimeError(
"data directory {0!r} not an existing directory"
.format(conf.data_dir))
else:
data_dir = join(get_cac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_dir() -> str:\n os.makedirs(DEFAULT_OUTPUT_DIR, exist_ok=True)\n return DEFAULT_OUTPUT_DIR",
"def data_dir():\n return _config.datadir",
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def get_data_dir():\n if not _datadir:\n local_dir = os.path.abspath(os.path.j... | [
"0.72709966",
"0.7191842",
"0.7052607",
"0.70512253",
"0.7007311",
"0.69776547",
"0.6940576",
"0.6867808",
"0.6831866",
"0.67782056",
"0.67562294",
"0.6742938",
"0.6739254",
"0.6736782",
"0.6700761",
"0.6687532",
"0.6672271",
"0.6668328",
"0.66304797",
"0.6626105",
"0.6616323... | 0.86421114 | 0 |
Removes a queue from the shard catalog. Call this method after successfully deleting it from a backend shard. | def deregister(self, queue, project=None):
self._invalidate_cached_id(queue, project)
self._catalogue_ctrl.delete(project, queue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_queue(self):\n self.work_queue_client.delete_queue()",
"def remove_queue(self, queue) -> None:\r\n self.receive_queues.remove(queue)",
"def remove_queue(self, queue):\n with self.mutex:\n self.queues.remove(queue)",
"def _queue_delete(self, queue):\n\n queue.... | [
"0.7496421",
"0.73610497",
"0.73293966",
"0.7305945",
"0.72437954",
"0.72253674",
"0.7151214",
"0.7142337",
"0.71367115",
"0.7116734",
"0.7023352",
"0.6969044",
"0.68962514",
"0.6785475",
"0.6775993",
"0.6749584",
"0.67103916",
"0.6655882",
"0.65476745",
"0.65264994",
"0.6509... | 0.65470827 | 19 |
Returns the updated interpolated data if the instance has is_raw_data = False. Else the raw data is returned. | def get(self):
if not self.is_raw_data and self._interp_xs is not None:
return self.get_interpolation()
return self._ys, self._xs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_raw_data(self):\n if self._img and self.is_4d():\n temp = self._img.get_data(caching='unchanged')\n temp = np.rot90(temp)\n for tp in self._loaded_time_list:\n temp[..., tp] = self._data[..., tp]\n else:\n temp = self._data.copy()\n\n... | [
"0.63492435",
"0.6335329",
"0.6186918",
"0.61409134",
"0.60807425",
"0.6053128",
"0.6053128",
"0.6002188",
"0.6002188",
"0.5993923",
"0.5940913",
"0.5885374",
"0.5848196",
"0.5813982",
"0.57514167",
"0.572691",
"0.57145023",
"0.5706114",
"0.5624072",
"0.5597885",
"0.5597111",... | 0.56316906 | 18 |
Get range of map between start and end px. This method allows to store abstract frequency maps without information that is specific to the track. | def get_map(self):
return self.get_raw_ys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_range():\n\n def_range = {'lt': [0.0, 24.0],\n 'lon': [0.0, 360.0],\n 'angle': [0.0, 2.0 * np.pi]}\n\n return def_range",
"def map_range( self, rng ):\n rmap = {\n '2 nA': pac.Ammeter.CurrentRange.N2,\n '20 nA': pac.Ammeter.CurrentR... | [
"0.663399",
"0.64556164",
"0.62715036",
"0.62069154",
"0.6182567",
"0.61762357",
"0.61409974",
"0.61368495",
"0.61176187",
"0.6080028",
"0.60486376",
"0.6042315",
"0.6037796",
"0.6031462",
"0.60078406",
"0.59257025",
"0.59251624",
"0.5918538",
"0.59124076",
"0.59042615",
"0.5... | 0.5880148 | 21 |
Calculate the precision of measurement (percent RSD) for a column of data. Allow for inf, inf values in input. | def calcPrecision(measuredConc):
std = numpy.std(measuredConc)
rsd = (std / numpy.mean(measuredConc)) * 100
if numpy.isnan(rsd):
rsd = numpy.inf
return rsd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precisions(self):\n raise NotImplementedError",
"def precision(self):\n tpos, fpos = len(self.__true_positives), len(self.__false_positives)\n return float(tpos) / (tpos + fpos)",
"def show_precision(self):\r\n return round(f1_score(self.actual, self.predicted),2)",
"def _get_... | [
"0.6148764",
"0.6081337",
"0.6030484",
"0.6028098",
"0.6025829",
"0.6017732",
"0.60029876",
"0.59590054",
"0.59561014",
"0.59508973",
"0.59438634",
"0.5887117",
"0.58840007",
"0.58820784",
"0.58729804",
"0.5861612",
"0.58602184",
"0.5833024",
"0.58086485",
"0.58077693",
"0.57... | 0.6870618 | 0 |
Compute the IoU between two arrays If the arrays are probabilities (floats) instead of predictions (integers or booleans) they are automatically rounded to the nearest integer and converted to bool before the IoU is computed. | def iou_bitmap(y_true, y_pred, verbose=False):
EPS = np.finfo(float).eps
# Make sure each pixel was predicted e.g. turn probability into prediction
if y_true.dtype in [np.float32, np.float64]:
y_true = y_true.round().astype(bool)
if y_pred.dtype in [np.float32, np.float64]:
y_pred = y_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iou(prediction, target):\r\n intersection = np.logical_and(prediction, target)\r\n union = np.logical_or(prediction, target)\r\n return np.sum(intersection) / np.sum(union)",
"def _iou_binary(preds, labels, EMPTY=1., per_image=False):\n preds = ((preds.float().view(-1, 1, 1, 1)).... | [
"0.7120553",
"0.6559061",
"0.65034837",
"0.6463628",
"0.6455993",
"0.6454782",
"0.64154756",
"0.6389634",
"0.6259211",
"0.6241029",
"0.62167686",
"0.6188566",
"0.61399513",
"0.61398494",
"0.61191815",
"0.61154073",
"0.6104779",
"0.60889775",
"0.6078737",
"0.6071421",
"0.60485... | 0.55505836 | 59 |
if input a vector, return a diagonal matrix | def diagonalise(self, input, batch):
if len(input.size()) == 1:
return torch.diag(input)
if len(input.size()) == 2:
if not batch:
return torch.diag(vec(input))
else:
bdiag = torch.Tensor().to(self.device)
for i in range(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_vector_to_diagonal_matrix(vector):\n num_columns = gs.shape(vector)[-1]\n identity = gs.eye(num_columns)\n identity = gs.cast(identity, vector.dtype)\n diagonals = gs.einsum('...i,ij->...ij', vector, identity)\n return diagonals",
"def matDiag(vec):\n ret=matZeros((len(vec),len(vec)))\... | [
"0.8390741",
"0.81109643",
"0.7800452",
"0.7622944",
"0.7312805",
"0.724312",
"0.7212917",
"0.7113068",
"0.69213337",
"0.6800939",
"0.6703636",
"0.6647841",
"0.66257715",
"0.6548756",
"0.6518099",
"0.6459483",
"0.64542425",
"0.6412448",
"0.638988",
"0.6384865",
"0.6357297",
... | 0.6375012 | 20 |
Fast check to determine of the edge is a border. | def is_border(self, threshold):
def dist_to_line(p1, p2, p3):
return np.linalg.norm(np.cross(p2 - p1, p1 - p3)) / np.linalg.norm(p2 - p1)
total_dist = 0
for p in self.shape:
total_dist += dist_to_line(self.shape[0], self.shape[-1], p)
return total_dist < thresho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_edge(self):\n if self._row == 0 or self._row == 9 or self._column == 0 or self._column == 9:\n # check that the edge is not actually a corner square\n if not self.is_corner():\n # If not a corner and in a border row return True\n return True\n\n ... | [
"0.7551858",
"0.75158983",
"0.7363427",
"0.70759135",
"0.7023558",
"0.6860162",
"0.6730458",
"0.6684477",
"0.665951",
"0.6631665",
"0.6615347",
"0.6584409",
"0.65555423",
"0.65503985",
"0.65308964",
"0.6503788",
"0.64706427",
"0.64044964",
"0.6314697",
"0.63030803",
"0.629132... | 0.68804514 | 5 |
Computes the acceleration of one particle based on the distance to the other particles of the space | def acceleration(self, Y):
acc = np.array([0.0, 0.0])
for part in self.particles:
d3 = ((part.x-Y[0])**2 + (part.y-Y[1])**2)**1.5
if d3 < 1e5: # When particles are too close, divergences occur
continue
acc += (part.mass/d3)*G*np.array([part.x-Y[0], par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force(particle1, particle2):\n position1 = particle1.position\n position2 = particle2.position\n\n distance_12 = np.sqrt((position1.x - position2.x)**2 +\n (position1.y - position2.y)**2 +\n (position1.z - position2.z)**2)\n\n ... | [
"0.6733729",
"0.6674904",
"0.666162",
"0.6610552",
"0.6446342",
"0.63871706",
"0.6303397",
"0.6270542",
"0.6147492",
"0.6106558",
"0.61039454",
"0.60831136",
"0.6082944",
"0.6076739",
"0.6057781",
"0.60250044",
"0.5993674",
"0.59509516",
"0.5943108",
"0.59070504",
"0.5898085"... | 0.688044 | 0 |
Takes an variable len batch of visual features and preprocess them through a transformer. Output a tensor with the same shape as visual_feats passed in input. | def forward(self, visual_feats, visual_feats_len=None, boxes=None):
# max_len = max(visual_feats_len)
# bs = visual_feats.shape[1]
# attention_mask = torch.zeros(bs, max_len).bool()
# for e, l in zip(attention_mask, visual_feats_len):
# e[l:] = True
# attention_mask =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipeline(input_, preprocess):\n input_ = input_.convert(\"L\")\n input_ = preprocess(input_)\n input_ = input_.reshape(-1, td.get_resize(Config.is_small_resize)[0], td.get_resize(Config.is_small_resize)[1], 1)\n input_ = input_.permute(3, 0, 1, 2)\n\n if cuda.is_available():\n return inpu... | [
"0.6077393",
"0.5973481",
"0.5960856",
"0.5828423",
"0.5781957",
"0.578063",
"0.57423276",
"0.5725372",
"0.5722356",
"0.56060934",
"0.5564434",
"0.55016184",
"0.5497879",
"0.54914296",
"0.54840076",
"0.546409",
"0.5461935",
"0.54394686",
"0.54394686",
"0.5435605",
"0.5434803"... | 0.62456757 | 0 |
Returns the duration for an incident; if the incident is not resolved the duration is from start until now. | def get_incident_duration(incident):
started = dateparse(incident.created_at)
if incident.status == 'resolved':
last_update = dateparse(incident.last_status_change_at)
else:
last_update = datetime.now()
# Convert duration to a nice string representation
return str(last_update - start... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_duration(self):\n return (self.stop_day - self.start_day) * (24 * 60) \\\n + (self.stop_hour - self.start_hour) * 60",
"def get_duration(self):\n i = self.icalendar_component\n return self._get_duration(i)",
"def get_duration(self, obj):\n started = obj.started... | [
"0.6775093",
"0.67330843",
"0.6608493",
"0.6591439",
"0.6541086",
"0.65239006",
"0.6468536",
"0.6462862",
"0.6387129",
"0.619435",
"0.61542225",
"0.61335915",
"0.6112901",
"0.61113423",
"0.6044302",
"0.6036117",
"0.6009817",
"0.6004777",
"0.60003275",
"0.6000319",
"0.5981661"... | 0.8086599 | 0 |
Creates a printable representation of the map service. returns a string for printing. | def __repr__(self):
dbline = ' - {0}'
fcline = ' + {0}'
output = ['{0} ({1})'.format(self.name, self.url)]
output.append('-' * len(output[0]))
output.append(' {0}'.format(self.mxd))
for db in self._dbnames:
output.append(dbline.format(db))
for fc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_map(self):\n print(self.__str__())",
"def __str__(self):\n tmp = {str(c)+\" (id=\"+str(id(c))+\")\":v for c,v in self.items()}\n return \"ComponentMap(\"+str(tmp)+\")\"",
"def dump_map(self) -> str:\n return utils.to_json(self.mapping)",
"def view_map():\n print(\"\"\"... | [
"0.6763217",
"0.67295104",
"0.66014475",
"0.6532086",
"0.63509667",
"0.62860024",
"0.61440605",
"0.61326325",
"0.6113768",
"0.60871357",
"0.60472983",
"0.5982687",
"0.59760237",
"0.59346396",
"0.5906684",
"0.58646953",
"0.5844098",
"0.58360076",
"0.5818757",
"0.5814094",
"0.5... | 0.0 | -1 |
Read a manifest.json file, and pull out the relavant information. manfile is the filename and path of a manifest.json file | def parse_manifest(manfile):
mxd = ''
service = ''
url = ''
databases = {}
with open(manfile, 'r') as f:
manifest = json.load(f)
mxd = manifest['resources'][0]['onPremisePath']
pathbits = manifest['resources'][0]['serverPath'].split('\\')
servicename = [x for x in pathbits if 'Ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_manifest(manifest_path):\n with open(manifest_path, 'r') as f:\n data = f.read()\n if data:\n return json.loads(data)\n else:\n return {}",
"def manifest_from_file(file_name):\n in_file = open(file_name, 'rb')\n try:\n return read_file_manifest... | [
"0.6642836",
"0.65847313",
"0.6456769",
"0.6447418",
"0.6274114",
"0.6073729",
"0.5958652",
"0.5909834",
"0.58877736",
"0.5880943",
"0.58254766",
"0.57938623",
"0.5783545",
"0.5699878",
"0.56876427",
"0.56415826",
"0.56273514",
"0.56135243",
"0.56051874",
"0.56031597",
"0.560... | 0.68515867 | 0 |
Test that filtering page still loads when no failed pod name is given | def test_no_failed_pod(self):
nodelog_url = self.BUILD_DIR + 'nodelog?junit=junit_01.xml'
init_build(self.BUILD_DIR)
write(self.BUILD_DIR + 'artifacts/tmp-node-image/junit_01.xml', JUNIT_SUITE)
write(self.BUILD_DIR + 'artifacts/tmp-node-image/kubelet.log',
'abc\nEvent(api.Obj... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_health_facilities_endpoint_with_keyword_only(self):\n response = self.client.get(\"search?q=hf\")\n self.assertIn(b'\"status\": \"FAILED\"', response.data)",
"def test_health_facilities_endpoint_without_query(self):\n response = self.client.get(\"search/health-facilities?q=\")\n ... | [
"0.6269784",
"0.62046266",
"0.6191928",
"0.61281914",
"0.595943",
"0.58230835",
"0.5788055",
"0.5779153",
"0.5778206",
"0.56951785",
"0.5685474",
"0.5659939",
"0.5635128",
"0.56228405",
"0.5620017",
"0.5603897",
"0.55877423",
"0.5583932",
"0.556894",
"0.55631375",
"0.5556702"... | 0.52053356 | 77 |
Create a search tree Node, derived from a parent by an action. | def __init__(self, state, parent, action, path_cost):
self.state = state
self.parent = parent
self.action = action
self.path_cost = path_cost
self.depth = 0
if parent:
self.depth = parent.depth + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, state, parent=None, action=None):\n\t\tself.state = state\n\t\tself.parent = parent\n\t\tself.action = action\n\t\tself.depth = 0\n\t\t# If depth is specified then depth of node will be 1 more than the depth of parent\n\t\tif parent:\n\t\t\tself.depth = parent.depth + 1",
"def __call__(self, p... | [
"0.65833175",
"0.6459039",
"0.60139126",
"0.6007905",
"0.6000603",
"0.59630543",
"0.5954473",
"0.588921",
"0.5867272",
"0.58405125",
"0.58161235",
"0.5798438",
"0.57502145",
"0.57459635",
"0.565649",
"0.56405544",
"0.5638548",
"0.5589593",
"0.55554473",
"0.5552606",
"0.555208... | 0.59128064 | 7 |
List the nodes reachable in one step from this node. | def expand(self, problem):
return [self.child_node(problem, action)
for action in problem.actions(self.state)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes(self):\n return list(self.__graph.keys())",
"def nodes(self):\n return self.graph.nodes",
"def nodes (self):\n return self.__nodes",
"def get_visited_nodes(self):\n return self.visited_nodes",
"def nodes(self):\n return self.__nodes",
"def get_nodes(self):... | [
"0.693908",
"0.69369644",
"0.6879865",
"0.68754965",
"0.68689376",
"0.6827248",
"0.68100685",
"0.68097466",
"0.68097466",
"0.68097466",
"0.6764401",
"0.67621917",
"0.6743569",
"0.67257047",
"0.67242104",
"0.6685335",
"0.6649937",
"0.66321135",
"0.66193134",
"0.66079694",
"0.6... | 0.0 | -1 |
Return a list of nodes forming the path from the root to this node. | def path(self):
node, path_back = self, []
while node:
path_back.append(node)
node = node.parent
return list(reversed(path_back)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n node, return_path = self, []\n while node:\n # Add the nodes in reverse order to a list until you reach the\n # root parent node which will terminate the loop\n return_path.append(node)\n node = node.parent\n # Reverse the list to g... | [
"0.7984329",
"0.77074516",
"0.7606885",
"0.7442534",
"0.7393407",
"0.73567694",
"0.73452824",
"0.7337256",
"0.7315247",
"0.7297849",
"0.7290767",
"0.7246857",
"0.72439355",
"0.7197385",
"0.7157757",
"0.715197",
"0.71127594",
"0.710878",
"0.7068614",
"0.7051616",
"0.70308995",... | 0.7581861 | 3 |
Return a list of nodes forming the path from the root to this node. | def cost(self):
node, path_back = self, []
cost = 0
while node:
path_back.append(node)
if node.action is not None:
cost = cost + node.action.cost
node = node.parent
# remove one due to root empty node
#cost = cost-1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n node, return_path = self, []\n while node:\n # Add the nodes in reverse order to a list until you reach the\n # root parent node which will terminate the loop\n return_path.append(node)\n node = node.parent\n # Reverse the list to g... | [
"0.7984695",
"0.7707993",
"0.76075685",
"0.7582547",
"0.7582547",
"0.74433106",
"0.73939186",
"0.7357707",
"0.7344919",
"0.7336959",
"0.731532",
"0.72982883",
"0.72902405",
"0.7246324",
"0.72434825",
"0.71981883",
"0.7157075",
"0.71537286",
"0.7113386",
"0.71092755",
"0.70693... | 0.0 | -1 |
Return an empty list, suitable as a LastInFirstOut Queue. | def Stack():
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_nowait(queue: Queue) -> list:\n\n results = []\n\n while True:\n try:\n result = queue.get_nowait()\n results.append(result)\n except Empty:\n break\n\n return results",
"def syncdequeue(self):\n #FIXME: Handle exceptions caused when some... | [
"0.6821298",
"0.6768826",
"0.672515",
"0.672515",
"0.65561545",
"0.65105253",
"0.64947486",
"0.63419896",
"0.63324875",
"0.632704",
"0.6161069",
"0.6150938",
"0.615033",
"0.60879225",
"0.60813576",
"0.6068872",
"0.6061594",
"0.60239273",
"0.59947866",
"0.59844345",
"0.5976385... | 0.5354029 | 81 |
This test should ensure that the correct exception gets returned on creating a user with a short password. | def test_create_user_password_too_short(self):
data = {
"firstname": "John",
"lastname": "Doe",
"password": "short",
"password_repeat": "short",
}
res = self.post(url="/users", data=data)
self.assertException(res, exc.PasswordTooShort)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_too_short(self):\n payload = {\n 'email': 'rest@eamil.com',\n 'password': 'pw',\n 'name': 'test Name'\n }\n\n res = self.client.post(CREATE_USER_URL, payload)\n\n self.assertEquals(res.status_code, status.HTTP_400_BAD_REQUEST)",
"def ... | [
"0.83701366",
"0.8299526",
"0.82450336",
"0.82040614",
"0.81924886",
"0.8191082",
"0.8187987",
"0.8187643",
"0.8187331",
"0.8173519",
"0.8141736",
"0.8121234",
"0.8115956",
"0.80198705",
"0.7919002",
"0.78852385",
"0.78054214",
"0.77995336",
"0.7794868",
"0.7775997",
"0.77651... | 0.7929082 | 14 |
This test should ensure that the correct exception gets returned on creating a user when the passwords do not match. | def test_create_user_passwords_do_not_match(self):
data = {
"firstname": "John",
"lastname": "Doe",
"password": "supersecret",
"password_repeat": "supersecret_ooops",
}
res = self.post(url="/users", data=data)
self.assertException(res, exc.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_user_invalid_password(self):\r\n print(\"Create user invalid password (empty)\")\r\n u_id = 3\r\n username = \"newtestuser\"\r\n password = \"\"\r\n u_type = 1\r\n\r\n prev_noUsers = len(User.query.all())\r\n self.assertEqual(self.system.create_user(... | [
"0.83762646",
"0.8207531",
"0.80691093",
"0.8069102",
"0.8061012",
"0.7957495",
"0.7907003",
"0.7904376",
"0.7876258",
"0.78687865",
"0.78686625",
"0.78662515",
"0.7863485",
"0.78485876",
"0.78359693",
"0.78196526",
"0.7811175",
"0.78035074",
"0.7797841",
"0.7797841",
"0.7797... | 0.7847159 | 14 |
Generate a random string of fixed length of 8 | def random_string() -> str:
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(8)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",
"def random_string(length):\n # this conservatively gets 8*length bits and then returns 6*length of\n # them. Grabbing (6/8)*length bits could lo... | [
"0.8328549",
"0.8311473",
"0.82442516",
"0.79748046",
"0.7971683",
"0.7937174",
"0.78839236",
"0.78783065",
"0.78696907",
"0.7846706",
"0.7825582",
"0.77538955",
"0.76995504",
"0.7684068",
"0.76775575",
"0.76590836",
"0.7633136",
"0.76221114",
"0.761787",
"0.761305",
"0.76027... | 0.801054 | 3 |
Create a rotation matrix corresponding to the rotation around a general axis by a specified angle. | def vrrotvec2mat(ax_ang):
#file_dir = os.path.dirname(os.path.realpath(__file__))
#path_dir2 = file_dir + '/../geometry/'
#sys.path.append(path_dir2)
if ax_ang.ndim == 1:
if np.size(ax_ang) == 5:
ax_ang = np.reshape(ax_ang, (5, 1))
msz = 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotation(self, angle, axis):\r\n\r\n sqr_a = axis.x*axis.x\r\n sqr_b = axis.y*axis.y\r\n sqr_c = axis.z*axis.z\r\n len2 = sqr_a+sqr_b+sqr_c\r\n\r\n k2 = math.cos(angle)\r\n k1 = (1.0-k2)/len2\r\n k3 = math.sin(angle)/math.sqrt(len2)\r\n k1ab = ... | [
"0.7499418",
"0.74165714",
"0.7336505",
"0.72626525",
"0.7190893",
"0.70425063",
"0.69224447",
"0.6921608",
"0.6853846",
"0.6844978",
"0.68238324",
"0.6821718",
"0.6789848",
"0.67720777",
"0.67404425",
"0.6723477",
"0.66915923",
"0.66581553",
"0.6643707",
"0.6625455",
"0.6621... | 0.0 | -1 |
Call in a loop to create terminal progress bar. | def print_progress_bar(self, iter_num, start_time):
iteration = iter_num + 1
prefix = "Progress: "
length = 50
fill = '█'
percent = ("{0:." + str(1) + "f}").format(100 *
(iteration / float(self.num_games)))
exact_progress ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_progress_bar():\n\n if simple_tregex_mode:\n total_files = len(list(to_iterate_over.keys()))\n else:\n total_files = sum(len(x) for x in list(to_iterate_over.values()))\n\n par_args = {'printstatus': kwargs.get('printstatus', True),\n 'root': r... | [
"0.7299647",
"0.72136474",
"0.71250576",
"0.70456845",
"0.68892944",
"0.6889146",
"0.6872352",
"0.68412644",
"0.68061566",
"0.6793585",
"0.677608",
"0.677608",
"0.677608",
"0.67743635",
"0.6771614",
"0.6771258",
"0.6771258",
"0.6771145",
"0.67609525",
"0.6756896",
"0.6752498"... | 0.6898423 | 4 |
Get the ChromeOS build version from /etc/lsbrelease. chromeos release version. | def get_chromeos_version():
try:
get_board_property('CHROMEOS_RELEASE_VERSION')
except:
logging.info("CHROMEOS_RELEASE_VERSION not found")
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_centos_release(self) -> str:\n return run('cat /etc/redhat-release').split()[-2][0]",
"def get_os_release():\n if platform.linux_distribution()[0]:\n return \" \".join(platform.linux_distribution())\n elif platform.mac_ver()[0]:\n return \"%s %s\" % (platform... | [
"0.69959277",
"0.690742",
"0.68039197",
"0.66506964",
"0.6629549",
"0.6610124",
"0.652456",
"0.6505086",
"0.6494291",
"0.64611316",
"0.6460999",
"0.6446504",
"0.63952297",
"0.63737077",
"0.6368136",
"0.6320774",
"0.63077646",
"0.6302513",
"0.6301613",
"0.62888604",
"0.6281491... | 0.7736488 | 0 |
Get the ChromeOS platform name. For unibuild this should be equal to model name. For nonunibuild it will either be board name or empty string. In the case of empty string return board name to match equivalent logic in server/hosts/cros_host.py platform name | def get_chromeos_platform_name():
try:
platform = cros_config.call_cros_config_get_output('/ name', utils.run)
if platform == '':
platform = get_board()
return platform
except:
logging.info("Not found")
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def platform():\n return \"micaz\"",
"def PlatformName():\n if override_platform_name:\n return override_platform_name\n if IsWindows():\n return 'win32'\n if IsLinux():\n return 'linux'\n if IsMac():\n return 'mac'\n raise NotImplementedError('Unknown platform \"%s\".' % sys.platform)",
"d... | [
"0.71827334",
"0.71827245",
"0.70403415",
"0.69764656",
"0.68741584",
"0.68345904",
"0.68326366",
"0.6712714",
"0.6663454",
"0.6645088",
"0.65717965",
"0.6544426",
"0.6544426",
"0.6526504",
"0.65111035",
"0.6504747",
"0.6488302",
"0.6470735",
"0.64631975",
"0.6394207",
"0.636... | 0.7519619 | 0 |
Get the firmware version as strings. a string representing this host's firmware version. | def get_firmware_version():
return utils.run('crossystem fwid').stdout.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def firmware_version(self):\n buf = (ctypes.c_char * self.MAX_BUF_SIZE)()\n self._dll.JLINKARM_GetFirmwareString(buf, self.MAX_BUF_SIZE)\n return ctypes.string_at(buf).decode()",
"def firmware_version(self) -> str:\n return self._firmware_version",
"def firmware_version(self):\n ... | [
"0.79400396",
"0.7779086",
"0.7521428",
"0.7473645",
"0.74618",
"0.72982407",
"0.72559255",
"0.70889515",
"0.70473623",
"0.689738",
"0.68797696",
"0.6878019",
"0.6875305",
"0.6871219",
"0.6749576",
"0.6746246",
"0.6715031",
"0.6689781",
"0.6677149",
"0.66495883",
"0.66249996"... | 0.71868354 | 7 |
Get the kernel version as strings. a string representing this host's kernel version. | def get_kernel_version():
try:
return utils.run('uname -r').stdout.strip()
except:
logging.info("Not Found")
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def systemversionstr():\n return platform.uname().system",
"def version():\n cmd = \"{} -v\".format(_detect_os())\n out = __salt__[\"cmd.run\"](cmd).splitlines()\n ret = out[0].split(\": \")\n return ret[1]",
"def rhel_kernel(packages, kernel_version, current_version):\n return _rhel_kernel_i... | [
"0.67689794",
"0.6689234",
"0.65093845",
"0.6421613",
"0.638744",
"0.63701737",
"0.6309763",
"0.6305329",
"0.6297143",
"0.628527",
"0.62825394",
"0.62666667",
"0.6249764",
"0.62033993",
"0.620263",
"0.6182576",
"0.616743",
"0.61661345",
"0.61620593",
"0.61375564",
"0.6099651"... | 0.6512545 | 2 |
Return root device. Will return correct disk device even system boot from /dev/dm0 | def get_root_device():
return utils.system_output('rootdev -s -d') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_boot_device(self):\n root_vol = None\n boot_vol = None\n for volume in self.volumes:\n if not volume.partitions:\n continue\n for partition in volume.partitions:\n if partition.mount_point == \"/\":\n ... | [
"0.743768",
"0.7065002",
"0.6749646",
"0.67476046",
"0.6702804",
"0.6655139",
"0.6615999",
"0.6479103",
"0.64013696",
"0.6383586",
"0.63643336",
"0.63574684",
"0.6346968",
"0.6338461",
"0.62723887",
"0.62526584",
"0.62246984",
"0.62164897",
"0.6178602",
"0.61552894",
"0.61273... | 0.83389235 | 0 |
Set up a test environment. | def generate_environment(dataset, tmpdir):
print(">>> Test environment:")
print("dataset:", dataset)
print("tmpdir:", tmpdir)
generate_test_environment(tmpdir, dataset)
return { 'dataset': dataset, 'tmpdir': tmpdir } | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n test_env_setup()",
"def SetupEnvironment(self):\n pass",
"def setUpModule():\n # pull in test environment as dict\n global TestEnv\n get_test_env(TestEnv)",
"def setUpModule():\n # pull in test environment as dict\n global TestEnv\n get_test_env(TestEnv)",
"de... | [
"0.807226",
"0.7482669",
"0.7395789",
"0.7395789",
"0.7323509",
"0.7323509",
"0.72632086",
"0.7179126",
"0.7114935",
"0.7060469",
"0.7008032",
"0.6990954",
"0.6977949",
"0.69689155",
"0.6968162",
"0.69093984",
"0.68979186",
"0.68898356",
"0.68822104",
"0.68772477",
"0.6875155... | 0.0 | -1 |
Set up a test environment using test dataset 'min1'. | def environment_min1(tmpdir):
return generate_environment('min1', tmpdir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n test_env_setup()",
"def setUp(self):\n self.dataset = get_test_dataset()",
"def test_setup(self, test_data: list=None):\n print(\"[dataset]: using test setup ...\")\n self.vocabulary = [\"empty\"]\n self.eval_dataset = ABSADataset(data_path=self.dev_path, m... | [
"0.6628866",
"0.6622548",
"0.65294117",
"0.640557",
"0.6338267",
"0.63281184",
"0.6320459",
"0.6320425",
"0.631288",
"0.6231715",
"0.6222626",
"0.62161267",
"0.618193",
"0.6144903",
"0.61337966",
"0.61266404",
"0.6115915",
"0.61072934",
"0.6102301",
"0.6102085",
"0.60989827",... | 0.6162583 | 13 |
Set up a test environment using test dataset 'min3'. | def environment_min3(tmpdir):
return generate_environment('min3', tmpdir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n test_env_setup()",
"def setUp(self):\n self.dataset = get_test_dataset()",
"def test_setup(self, test_data: list=None):\n print(\"[dataset]: using test setup ...\")\n self.vocabulary = [\"empty\"]\n self.eval_dataset = ABSADataset(data_path=self.dev_path, m... | [
"0.65883803",
"0.65667874",
"0.64844406",
"0.645259",
"0.6328357",
"0.6326369",
"0.63216734",
"0.62923676",
"0.6269549",
"0.62622607",
"0.6247097",
"0.6186915",
"0.61831725",
"0.61763924",
"0.6164265",
"0.6159328",
"0.615682",
"0.615682",
"0.61561793",
"0.6148458",
"0.6144971... | 0.6414367 | 4 |
Displays the root UI. | def ui_root1():
return send_build() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display(self) -> None:\n self.root.display()",
"def display_main(self):\n self.clear_terminal()\n self.main_menu()\n self.handle_selection_main()",
"def main():\r\n return render_template(\"UI.html\")",
"def root():\n return render_template('root.html')",
"def root(sel... | [
"0.77400357",
"0.73010254",
"0.71644497",
"0.7095685",
"0.7030151",
"0.69971895",
"0.69582045",
"0.68906975",
"0.68906975",
"0.68906975",
"0.6825896",
"0.6811073",
"0.67543066",
"0.6727734",
"0.67221874",
"0.6683957",
"0.6672294",
"0.66719496",
"0.66472286",
"0.6632292",
"0.6... | 0.6442545 | 29 |
Gets the views of this PrefetchResponse. Contains all the views matching the request. | def views(self):
return self._views | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getViews(self):\n return list(self.__views)",
"def getViews(self):\n return list(self.__views.keys())",
"def get_views(self):\n query = mssqlqueries.get_views()\n logger.info(u'Views query: %s', query)\n for tabular_result in self.execute_query(query):\n for ro... | [
"0.71542346",
"0.66912264",
"0.6390769",
"0.62425417",
"0.6107243",
"0.6035034",
"0.59929824",
"0.58978415",
"0.57811755",
"0.57342356",
"0.56681156",
"0.566706",
"0.5564722",
"0.5559799",
"0.5556475",
"0.5547521",
"0.5512223",
"0.54970616",
"0.54686934",
"0.5458042",
"0.5457... | 0.68580717 | 1 |
Sets the views of this PrefetchResponse. Contains all the views matching the request. | def views(self, views):
self._views = views | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_list(self, view_list):\n\n self._view_list = view_list",
"def set_preds_as_viewed(preds):\n predictions.set_preds_as_viewed(preds)",
"def fit(self, views: Iterable[np.ndarray], y=None, **kwargs):\n return self",
"def fit_transform(self, views: Iterable[np.ndarray], **kwargs):\n ... | [
"0.5453209",
"0.52553564",
"0.51034665",
"0.50927436",
"0.5021565",
"0.5018381",
"0.4993566",
"0.49459183",
"0.48753285",
"0.48663464",
"0.4837061",
"0.4791182",
"0.474467",
"0.4713523",
"0.46919867",
"0.4668019",
"0.4611431",
"0.45873412",
"0.45708817",
"0.45478213",
"0.4523... | 0.7067103 | 0 |
Gets the mboxes of this PrefetchResponse. Prefetched mboxes, including content and notification tokens to be sent back when the mboxes are displayed. | def mboxes(self):
return self._mboxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mboxes(mboxes):\n if not mboxes:\n return None\n\n result_mboxes = []\n for mbox in mboxes:\n options = create_options(mbox)\n result_mboxes.append(MboxResponse(index=mbox.get(\"index\"),\n name=mbox.get(\"name\"),\n ... | [
"0.6314072",
"0.6191602",
"0.59009296",
"0.5886659",
"0.5678111",
"0.56578785",
"0.5609376",
"0.5444694",
"0.53151405",
"0.52151567",
"0.52070636",
"0.5130126",
"0.50709504",
"0.5016885",
"0.5015728",
"0.49420232",
"0.48590705",
"0.4830721",
"0.4806369",
"0.4786646",
"0.47778... | 0.71640295 | 0 |
Sets the mboxes of this PrefetchResponse. Prefetched mboxes, including content and notification tokens to be sent back when the mboxes are displayed. | def mboxes(self, mboxes):
self._mboxes = mboxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mboxes(mboxes):\n if not mboxes:\n return None\n\n result_mboxes = []\n for mbox in mboxes:\n options = create_options(mbox)\n result_mboxes.append(MboxResponse(index=mbox.get(\"index\"),\n name=mbox.get(\"name\"),\n ... | [
"0.63638073",
"0.61803854",
"0.59135115",
"0.482469",
"0.47008628",
"0.46655414",
"0.4608289",
"0.4608289",
"0.46044838",
"0.45921344",
"0.457805",
"0.44858494",
"0.44810584",
"0.44389394",
"0.44326752",
"0.44082797",
"0.4396439",
"0.43941227",
"0.43911472",
"0.43674633",
"0.... | 0.7771728 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, PrefetchResponse):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.80915105",
"0.80915105",
"0.80915105",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006"
] | 0.0 | -1 |
Finds the reward gained on the last iteration. | def find_reward(self, opponent: Player) -> Dict[Action, Dict[Action, Score]]:
if len(opponent.history) == 0:
opp_prev_action = self._random.random_choice()
else:
opp_prev_action = opponent.history[-1]
reward = self.payoff_matrix[self.prev_action][opp_prev_action]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_reward(\r\n self, opponent: Player\r\n ) -> Dict[Action, Dict[Action, Score]]:\r\n return self.payoff_matrix[self.decision][opponent.history[-1]]",
"def _compute_reward(self): \n reward = -1\n return reward",
"def get_reward(self):\n\t\t# returns the r... | [
"0.75797004",
"0.734375",
"0.72672707",
"0.726439",
"0.7164849",
"0.7149232",
"0.7122559",
"0.70738345",
"0.70325845",
"0.6970495",
"0.696674",
"0.69628793",
"0.69453853",
"0.694346",
"0.68970233",
"0.6871107",
"0.6856799",
"0.67591786",
"0.6752317",
"0.67387927",
"0.6735471"... | 0.7442721 | 1 |
Appends the last reward to the rewards list and makes sure it only holds the last n items. | def rewards_list_manager(self, reward):
self.rewards_list.append(reward)
if len(self.rewards_list) > self.list_size:
self.rewards_list.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finalReward(self, reward: float) -> SarsList:\n (board, move) = self.prevBoardMove\n self.sarsList.append((board, move, reward, None))\n return self.sarsList",
"def add_reward(self, choice, count=1):\n self.redis.hincrby(EXPERIMENT_REDIS_KEY_TEMPLATE % self.name, \"%s:rewards\" % ... | [
"0.6940695",
"0.6293838",
"0.6049912",
"0.6036716",
"0.5980498",
"0.5978603",
"0.5953674",
"0.5928577",
"0.5901281",
"0.5889297",
"0.58783174",
"0.58511144",
"0.5816891",
"0.57781863",
"0.5770032",
"0.57581145",
"0.57199514",
"0.57122374",
"0.56712264",
"0.5667138",
"0.566302... | 0.72789717 | 0 |
Checks in its history if it has played this Player before. | def has_met_before(self, opponent: Player):
if opponent.name in self.previous_matches_dict:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_guess_if_previous(self): # is a helper function to add_previous_guess()\n if self.guess in self.past_guesses:\n return False\n else:\n return True",
"def has_previous(self) -> bool:\n return self.published_before().count() != 0",
"def havePlayedPreviously(p... | [
"0.6726694",
"0.6357391",
"0.62660646",
"0.61942995",
"0.60906136",
"0.60780567",
"0.6056948",
"0.6056064",
"0.6030249",
"0.59795034",
"0.5927675",
"0.5924521",
"0.5924521",
"0.58539885",
"0.57905394",
"0.5765914",
"0.57540375",
"0.5738936",
"0.5726516",
"0.57102835",
"0.5708... | 0.70664173 | 0 |
Returns the value of a key of a dictionary that is in a list. | def get_value(self, listOfDicts, key):
for val in listOfDicts:
if key in val:
return val[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_if_in_list(dict_list, value, key):\n if dict_list is None:\n return None\n return next((item for item in dict_list if item[key] == value), None)",
"def get_item_in_dict(d_or_l, key_list, prev=None):\n if prev is None:\n res = []\n else:\n res = prev.cop... | [
"0.7252144",
"0.7230733",
"0.7200766",
"0.70316327",
"0.69805676",
"0.69760656",
"0.6875394",
"0.67682153",
"0.6677581",
"0.66481495",
"0.6639688",
"0.66168624",
"0.6585044",
"0.65550876",
"0.65442616",
"0.65321434",
"0.6455877",
"0.63427633",
"0.6333561",
"0.6266734",
"0.623... | 0.7182878 | 3 |
Evaluate policies and switches current_policy if mean average reward for the last n steps > than current policy. | def evaluate_policies(self):
combined_rewards = {}
previous_current_policy = self.current_policy
for policy in self.policy_list:
mean_reward_f = lambda x: (sum(x)/len(x))
value = mean_reward_f(policy.rewards_list)
#print(f" Memory length: {policy.memory_length... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _on_step(self):\n # self.logger.record(\"current_reward\")\n # self.n_calls is automatically updated because\n # we derive from BaseCallback\n if self.n_calls % self.eval_freq == 0:\n # === YOUR CODE HERE ===#\n # Evaluate the agent:\n # you need to do self.n_eval_episodes loop using... | [
"0.67783296",
"0.6595428",
"0.6524142",
"0.64929575",
"0.64715815",
"0.6469852",
"0.64628375",
"0.64430654",
"0.6443044",
"0.64113194",
"0.64113194",
"0.6395731",
"0.6375213",
"0.6306766",
"0.6303111",
"0.6301132",
"0.629855",
"0.62930226",
"0.6281682",
"0.62657493",
"0.62623... | 0.72443324 | 0 |
Checks if it is time to evaluate policy. | def vf_eval_point(self):
if self.turns in range(0,(self.game_length + 1),self.Vs_eval_point):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_time():\n times = get_times()\n time_difference = abs((times['local'] - times['target']).total_seconds())\n return time_difference < post_time_tol_seconds",
"def isTimeRemaining(self):\n if self.run_type.startswith('timed'):\n time_since_start = (time.time() - self.start_times['run'])\... | [
"0.6689097",
"0.65070665",
"0.64731044",
"0.64486563",
"0.64077616",
"0.6395067",
"0.63318723",
"0.62511456",
"0.624812",
"0.6182041",
"0.6167794",
"0.61447847",
"0.6119615",
"0.60869086",
"0.6085523",
"0.6051685",
"0.6037464",
"0.6010893",
"0.6007734",
"0.60010743",
"0.59722... | 0.0 | -1 |
Gets a list of all neighbours from a position towards all directions. | def get_neighbours_and_directions(self, from_position):
# Transform index into board matrix into index into index into neighbour matrix
from_row_index = self.board_to_connection_index(from_position)
row = self.connection_matrix[from_row_index]
neighbours = []
for col_num in range(0, len(ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_neighbours(self, position):\n grid = self._grid\n x, y = position\n neighbours = []\n offsets = [(0,1),(1,0),(0,-1),(-1,0)]\n shuffle(offsets)\n for offset in offsets:\n i, j = offset\n position = (x + i, y + j)\n if grid.valid_pos... | [
"0.76507026",
"0.7549347",
"0.73710203",
"0.73402965",
"0.72468984",
"0.7022887",
"0.70182645",
"0.7008794",
"0.70060974",
"0.69371927",
"0.6935482",
"0.69351274",
"0.6918002",
"0.6916862",
"0.68926436",
"0.68735766",
"0.6868936",
"0.68377554",
"0.68138546",
"0.68085164",
"0.... | 0.736226 | 3 |
Gets all legal moves for the current board state. (self.board). Returns a matrix of True/False where True means, and a list of positions that it is legal to place there | def get_all_moves(self):
# 2d matrix of true/false, true if something can be placed
legal_move_board = []
possible_move_list = []
for row in range(self.size):
move_row = []
for col in range(self.size):
empty = self.board[row][col].state == PegState.EMPTY
move_row.append(empty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_legal_moves(self):\n moves = []\n if self.player_locations[self.whose_turn] is None:\n return self.get_blank_locations()\n matrix = [(1,0), (-1,0), (0,1), (0,-1), (1,1), (1,-1), (-1, 1), (-1,-1)]\n\n for dx, dy in matrix:\n x,y = self.player_locations[self.... | [
"0.8308492",
"0.8300396",
"0.802414",
"0.78296113",
"0.77352315",
"0.77256405",
"0.7718534",
"0.77081513",
"0.7668014",
"0.765604",
"0.7645819",
"0.7626022",
"0.7584768",
"0.7581337",
"0.75597256",
"0.754108",
"0.75220305",
"0.75061715",
"0.7477422",
"0.7466972",
"0.74535805"... | 0.86073625 | 0 |
Yield successive nsized chunks from lst. | def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"de... | [
"0.83073896",
"0.81937337",
"0.8191178",
"0.8191178",
"0.81903666",
"0.81268156",
"0.812207",
"0.812207",
"0.80774724",
"0.80527616",
"0.80527616",
"0.80527616",
"0.80527616",
"0.80527616",
"0.80042547",
"0.7870935",
"0.78464705",
"0.7828888",
"0.78281975",
"0.78149104",
"0.7... | 0.80534166 | 16 |
Test that the command updates the specified records (ignoring ones with errors). | def test_run(s3_stubber, caplog):
caplog.set_level('ERROR')
companies = CompanyFactory.create_batch(4)
data = []
for company in companies:
record = _get_data_for_company(company.id)
raw_record = json.dumps(record)
base64_record = b64encode(raw_record.encode('utf-8')).decode('ut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_record(self):\n pass",
"def test_edit_record_edits_the_correct_record(self):\n # create some db records\n dataset = self.create_mixed_test_data()\n test_log_entries = dataset['test_log_entries']\n # set the menu instance's `records` property\n self.menu.r... | [
"0.78881055",
"0.7061696",
"0.69923824",
"0.68376505",
"0.6822583",
"0.6767727",
"0.6729194",
"0.6729194",
"0.6729194",
"0.66630197",
"0.6654071",
"0.6638935",
"0.6625693",
"0.65843153",
"0.6565443",
"0.6560695",
"0.6543985",
"0.65364295",
"0.6535769",
"0.65290207",
"0.651321... | 0.0 | -1 |
Set the pool of servers used by this client. | def set_servers(self, servers):
kwargs = dict(io_loop = self.io_loop)
#if self.connect_timeout:
# kwargs['connect_timeout'] = self.connect_timeout
if self.dead_retry:
kwargs['dead_retry'] = self.dead_retry
self.servers = [_Host(s, self.debuglog, **kwargs) for s i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_pool(self, server_pool):\n\n self._server_pool = server_pool",
"def set_servers(self, servers):\n\n\t\tself.servers = []\n\t\tself.buckets = []\n\n\t\tfor server_desc in servers:\n\t\t\tif type(server_desc) == tuple:\n\t\t\t\tserver_addr, weight = server_desc\n\t\t\telse:\n\t\t\t\tserver_addr, ... | [
"0.7321937",
"0.70889455",
"0.68078506",
"0.6469448",
"0.6269636",
"0.6156293",
"0.6094887",
"0.6013716",
"0.59658796",
"0.5912318",
"0.5881732",
"0.58734155",
"0.58019567",
"0.5772837",
"0.5721683",
"0.56458396",
"0.5584574",
"0.5561476",
"0.5553551",
"0.55455774",
"0.553602... | 0.6783839 | 3 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.8331214",
"0.8284662",
"0.82381004",
"0.8229767",
"0.82202226",
"0.81864446",
"0.81847763",
"0.8175173",
"0.8171541",
"0.81699467",
"0.81664646",
"0.81645083",
"0.81637454",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"... | 0.7852251 | 79 |
Replaces PII from string input, which could be an email address or a string representation of a Python object. The string representation may also be truncated to a certain length, thus the value pattern above also captures values when hitting endofstring. | def _sanitize_string(msg: str) -> str:
for email in EMAIL_PATTERN.findall(msg):
msg = msg.replace(email, re.sub(EMAIL_REPLACEMENT, EMAIL_SUBSTITUTION, email))
for field_pattern in SENSITIVE_FIELD_PATTERNS:
msg = field_pattern.sub(FIELD_SUBSTITUTION_PATTERN, msg)
return msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_ip_address(self, string):\n count = string.count('.')\n newstring = string\n if count < 3:\n # Not enough components to matter\n return newstring\n\n dot_split = string.split('.')\n\n # Count the number of components that convert to an integer\n ... | [
"0.529651",
"0.5286037",
"0.5113821",
"0.5107283",
"0.5072503",
"0.5039288",
"0.5021523",
"0.5010002",
"0.50037354",
"0.50005305",
"0.49705333",
"0.49659023",
"0.49548504",
"0.49321055",
"0.4885496",
"0.4882123",
"0.48803803",
"0.4876779",
"0.4867307",
"0.4856089",
"0.4831583... | 0.58040845 | 0 |
Returns the transport used by the client instance. | def transport(self) -> TensorboardServiceTransport:
return self._transport | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transport(self):\n return self._transport",
"def transport(self) -> TraceServiceTransport:\n return self._client.transport",
"def transport(self) -> ServiceControllerTransport:\n return self._client.transport",
"def transport(self) -> MetadataServiceTransport:\n return self._c... | [
"0.82946277",
"0.7887542",
"0.773594",
"0.773068",
"0.76806635",
"0.7674273",
"0.76357967",
"0.7558095",
"0.7551682",
"0.75303864",
"0.74958986",
"0.7488142",
"0.7436853",
"0.7423566",
"0.7368433",
"0.73340607",
"0.7109823",
"0.7102308",
"0.68808985",
"0.68144",
"0.6671675",
... | 0.721926 | 16 |
Returns a fullyqualified tensorboard_experiment string. | def tensorboard_experiment_path(
project: str,
location: str,
tensorboard: str,
experiment: str,
) -> str:
return "projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}".format(
project=project,
location=location,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def experiment_name(self):\n # type: () -> string_types\n return self._experiment_name",
"def tensorboard_run_path(\n project: str,\n location: str,\n tensorboard: str,\n experiment: str,\n run: str,\n ) -> str:\n return \"projects/{project}/locations/{l... | [
"0.6733724",
"0.63253695",
"0.62591577",
"0.6120263",
"0.60489845",
"0.59458035",
"0.58992136",
"0.5865498",
"0.58287936",
"0.57862365",
"0.57394284",
"0.57240576",
"0.5649301",
"0.5647834",
"0.54428434",
"0.53889257",
"0.5316732",
"0.5296445",
"0.5286561",
"0.52846986",
"0.5... | 0.7786094 | 0 |
Parses a tensorboard_time_series path into its component segments. | def parse_tensorboard_time_series_path(path: str) -> Dict[str, str]:
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/tensorboards/(?P<tensorboard>.+?)/experiments/(?P<experiment>.+?)/runs/(?P<run>.+?)/timeSeries/(?P<time_series>.+?)$",
path,
)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_time_series(self, path: str) -> np.ndarray:\n items = []\n previous = None\n for item in sorted(pathlib.Path(path).glob(\"*.nc\")):\n with xr.open_dataset(item) as ds:\n current = ds.ocean_time.values[0].astype(\"datetime64[M]\")\n if (previou... | [
"0.5642332",
"0.53205794",
"0.5216421",
"0.50843465",
"0.5084148",
"0.4992526",
"0.49634525",
"0.49479604",
"0.49462703",
"0.48868632",
"0.48567763",
"0.48517153",
"0.48504207",
"0.48441702",
"0.48363525",
"0.4835228",
"0.48223904",
"0.48207572",
"0.48102683",
"0.4792345",
"0... | 0.69275206 | 0 |
Returns a fullyqualified billing_account string. | def common_billing_account_path(
billing_account: str,
) -> str:
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def billing_account(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"billing_account\")",
"def billing_account(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"billing_account\")",
"def billing_account(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"billing_account... | [
"0.79002553",
"0.79002553",
"0.79002553",
"0.7712969",
"0.7712969",
"0.750967",
"0.74875593",
"0.74875593",
"0.68009645",
"0.6783066",
"0.66662496",
"0.66662496",
"0.66435224",
"0.66435224",
"0.65389526",
"0.6513056",
"0.6302785",
"0.6262761",
"0.6173323",
"0.6169606",
"0.616... | 0.73243135 | 8 |
r"""Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. | def get_iam_policy(
self,
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network_access_policy(self) -> Optional[str]:\n return pulumi.get(self, \"network_access_policy\")",
"def client_access_policy(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"client_access_policy\")",
"def get_policy(usage_id):\r\n return policy.get(policy_key... | [
"0.6178885",
"0.61590993",
"0.61123925",
"0.6104738",
"0.6104738",
"0.600796",
"0.59676766",
"0.59676766",
"0.59460056",
"0.59460056",
"0.59353316",
"0.59042543",
"0.5884025",
"0.58732426",
"0.58699167",
"0.58668566",
"0.5858578",
"0.5836053",
"0.5836053",
"0.5836053",
"0.577... | 0.0 | -1 |
Set hidden layer parameters. Initialize to 0 | def set_hiddenx(self, batch_size):
if self.config['cuda']:
self.hx = torch.zeros(batch_size, self.config['state_dim'], device='cuda')
self.cx = torch.zeros(batch_size, self.config['state_dim'], device='cuda')
else:
self.hx = torch.zeros(batch_size, self.config['state_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_hidden(self):\n # TODO ========================\n # initialize the hidden states to zero\n\n initial_hidden = torch.zeros(self.num_layers, self.batch_size, self.hidden_size)\n return initial_hidden # a parameter tensor of shape (self.num_layers, self.batch_size, self.hidden_si... | [
"0.7579515",
"0.7219264",
"0.7147271",
"0.7117862",
"0.7116846",
"0.7094303",
"0.70175666",
"0.7016845",
"0.70109487",
"0.6990654",
"0.6898711",
"0.68371445",
"0.6832899",
"0.6749875",
"0.6701819",
"0.6675785",
"0.6666213",
"0.6666213",
"0.6666213",
"0.6630961",
"0.6610587",
... | 0.61685276 | 63 |
Return a list of bigram from a set of tokens | def get_bigrams(self, tokens):
return [a + " " + b for a, b in zip(tokens, tokens[1:])] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bigrams(sentence):\n return [word+'_'+sentence[i+1] \n if word+'_'+sentence[i+1] in word_ids else None \n for i, word in enumerate(sentence[:-1])] if config.USE_BIGRAMS else []",
"def make_bigrams(bigram_mod, texts):\n return [bigram_mod[doc] for doc in texts]",
"def get_big... | [
"0.72109574",
"0.6979419",
"0.6973909",
"0.6913209",
"0.6872742",
"0.66915166",
"0.66187626",
"0.63897",
"0.6356495",
"0.62698644",
"0.62079304",
"0.6190746",
"0.61907154",
"0.61585534",
"0.6137321",
"0.61241156",
"0.6113256",
"0.610226",
"0.6063019",
"0.6057659",
"0.60537195... | 0.7848915 | 0 |
Returns features based on the SentiWordNet features | def senti_wordnet(self, tokens):
positive_score, negative_score = 0.0, 0.0
positive_unigram_words, negative_unigram_words = 0, 0
# loop through the bigrams
for token in tokens:
if token in self.senti_wordnet_map:
if self.senti_wordnet_map[token] >= 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doc2features(self,sent):\n return [self.word2features(sent['tokens'], i) for i in range(len(sent['tokens']))]",
"def sent_features(tweet):\n twitter_objs = count_twitter_objs(tweet)\n tweet=clean_tweet(tweet) \n sentiment = sentiment_analyzer.polarity_scores(tweet)\n #Get text only\n ... | [
"0.73183894",
"0.71263",
"0.70751894",
"0.69676757",
"0.6945837",
"0.69217503",
"0.69050235",
"0.6876446",
"0.6857538",
"0.6857172",
"0.68460387",
"0.6833683",
"0.68296003",
"0.6827002",
"0.6808507",
"0.6793462",
"0.6743678",
"0.67287916",
"0.671578",
"0.6701386",
"0.66613275... | 0.0 | -1 |
insert node at end traverse the list, then add when node.next is none | def append(self, new_node):
if self.head is None:
self.head = new_node
return None
curr_node = self.head
while curr_node.next is not None:
curr_node = curr_node.next
curr_node.next = new_node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_end(self, data):\n\n if self.head is None:\n self.head = ListNode(data)\n else:\n temp = self.head\n while temp.next is not None:\n temp = temp.next\n temp.next = ListNode(data)",
"def add_last(self, node_to_add):\n if sel... | [
"0.7634774",
"0.7556984",
"0.72107995",
"0.7086823",
"0.7028926",
"0.70181656",
"0.7015274",
"0.6972772",
"0.69708765",
"0.6946059",
"0.6935984",
"0.6920278",
"0.69060373",
"0.68891156",
"0.6885321",
"0.6863869",
"0.6806091",
"0.6787113",
"0.6786611",
"0.6782133",
"0.67751724... | 0.66094273 | 36 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.