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 |
|---|---|---|---|---|---|---|
Gets the status of this SimulationStatusSchema. | def status(self) -> str:
return self._status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Status(self):\n return self._get_attribute('status')",
"def getStatus(self):\n return self._status",
"def get_status(self):\n return self._status",
"def Status(self):\r\n\t\treturn self._get_attribute('status')",
"def get_status(self):\n # TODO retrieve from db if not set\n ... | [
"0.72538686",
"0.71937454",
"0.7164574",
"0.7136598",
"0.7128647",
"0.71262664",
"0.7121426",
"0.7109712",
"0.7098036",
"0.7092405",
"0.7071419",
"0.7068866",
"0.7049687",
"0.70484966",
"0.70484966",
"0.70484966",
"0.7043865",
"0.70090437",
"0.69839835",
"0.69839835",
"0.6971... | 0.0 | -1 |
Sets the status of this SimulationStatusSchema. | def status(self, status: str):
allowed_values = ["waiting", "running", "complete", "failed"] # noqa: E501
if status not in allowed_values:
raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}"
.format(status, allowed_values)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetStatus(self, status):\r\n self.status = status",
"def setStatus(self, status):\n self.__status = status",
"def set_status(self, status):\n self.status = status",
"def set_status(self, status):\n self.status = status",
"def set_status(self, status):\n self.status = stat... | [
"0.7053628",
"0.70406675",
"0.70260066",
"0.70260066",
"0.70260066",
"0.69412273",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258",
"0.6920258"... | 0.61614007 | 61 |
Gets the grids of this SimulationStatusSchema. | def grids(self) -> List[GridStatusSchema]:
return self._grids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGrid(self):\n\n\t\t\treturn self._logic.getGrid()",
"def grid(self):\n return self._grid",
"def grid(self):\n return self.__grid",
"def get_grid( self ):\n\n return self.__grid",
"def grid(self) -> aa.Grid2D:\r\n return self.analysis.dataset.grid",
"def getGrid(self):\n... | [
"0.6632377",
"0.6457044",
"0.64389086",
"0.62900865",
"0.62889326",
"0.62842256",
"0.62528116",
"0.62511873",
"0.620839",
"0.619619",
"0.60457194",
"0.60437995",
"0.60426676",
"0.59556454",
"0.5941378",
"0.5854123",
"0.58155185",
"0.58094025",
"0.57084584",
"0.5696244",
"0.56... | 0.8601198 | 0 |
View wird mit der Request Methode get aufgerufen. Dem User wird eine leere LoginForm angezeigt. | def get(self, request):
# Falls der User bereits angemeldet ist, wird er zur Startseite weitergeleitet
if request.user.is_authenticated:
students = Student.objects.filter(user=request.user)
if len(students) == 1:
if students[0].new_policy_available():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request):\n form = LoginForm()\n context = {'form': form}\n return render(request, 'login.html', context)",
"def login_view(self):\n\n # Authenticate username/email and login authenticated users.\n\n safe_next_url = self._get_safe_next_url('next', self.USER_AFTER... | [
"0.751386",
"0.7338937",
"0.7189524",
"0.70486665",
"0.70320606",
"0.6920515",
"0.6876764",
"0.67819494",
"0.67723787",
"0.67261034",
"0.67250466",
"0.6653391",
"0.6639504",
"0.6636242",
"0.66361064",
"0.66329813",
"0.6632854",
"0.6626664",
"0.6617563",
"0.65858305",
"0.65842... | 0.0 | -1 |
Turns a protobuf Timestamp object into a timezoneaware datetime | def to_aware_datetime(ts: Timestamp):
return utc.localize(ts.ToDatetime()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pb_timestamp_to_datetime(timestamp_pb):\n return (\n _EPOCH +\n datetime.timedelta(\n seconds=timestamp_pb.seconds,\n microseconds=(timestamp_pb.nanos / 1000.0),\n )\n )",
"def _pd_datetime_to_timestamp_proto(dtype, value) -> Timestamp:\n\n... | [
"0.7052632",
"0.69571203",
"0.6796542",
"0.67405397",
"0.66379625",
"0.6525217",
"0.64685977",
"0.64642674",
"0.64287645",
"0.6410549",
"0.64055693",
"0.6378048",
"0.6364938",
"0.63618505",
"0.6361569",
"0.63488466",
"0.634882",
"0.63250285",
"0.63190305",
"0.63130355",
"0.62... | 0.67344064 | 4 |
Fetch a specific AWS cloud account | def get(cls, aws_cloud_account_id: str = '') -> Union[Dict, List[Dict]]:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_aws_account_id() -> str:\n client: STSClient = fetch_boto3_client(\"sts\")\n return client.get_caller_identity()[\"Account\"]",
"def account_get(request):\n fields = [\"email\", \"token\"]\n\n # serializes the quert string to a dict (neeto)\n args = request.args\n\n query_validation = ... | [
"0.64106673",
"0.6380675",
"0.63469607",
"0.6319402",
"0.62756705",
"0.6217197",
"0.61793035",
"0.6121992",
"0.610902",
"0.6102334",
"0.60936433",
"0.60933423",
"0.6073008",
"0.6027457",
"0.60004133",
"0.5983718",
"0.5969275",
"0.596649",
"0.59590983",
"0.5915972",
"0.5882827... | 0.57125175 | 33 |
Gets the current network mode | def networkMode(self):
response = self.at.sendCommand("AT+CEREG?")
# If we failed to query the network mode, that's a paddlin'
if not response:
raise modem.AtError(response, "Failed to query network mode")
lines = response.lines
if len(lines) < 1:
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network_mode(self) -> Optional[pulumi.Input[Union[str, 'NetworkMode']]]:\n return pulumi.get(self, \"network_mode\")",
"def get_mode(self):\r\n return self._api.get_mode()",
"def get_mode(self) -> str:\n\n return self.send(self.cmd.GET_MODE)",
"def getmode(self):\n return self... | [
"0.8368596",
"0.80002975",
"0.7942454",
"0.7718126",
"0.7677622",
"0.76748943",
"0.75841177",
"0.75329584",
"0.7402769",
"0.7340597",
"0.7320058",
"0.72745526",
"0.72745526",
"0.72745526",
"0.72654223",
"0.72638345",
"0.72638345",
"0.72638345",
"0.7228586",
"0.7228586",
"0.72... | 0.8362507 | 1 |
Continually swap max & last elements, pop, and remake heap | def sort(self):
out = []
while len(self.x) > 0:
self.x[0], self.x[-1] = self.x[-1], self.x[0]
out.append(self.x.pop())
BinaryMaxHeap.max_heapify(self.x, 0)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_min_max(heap):\n\ttemp = heap[0]\n\theap[0] = heap[heap.len-1]\n\theap[heap.len-1] = temp\n\theap.len -= 1\n\treturn",
"def heap_pop_max(heap):\n last = heap.pop()\n if heap:\n return_item = heap[0]\n heap[0] = last\n heapq._siftup_max(heap, 0)\n else:\n return_item ... | [
"0.7456372",
"0.72578955",
"0.7142116",
"0.69673026",
"0.69500744",
"0.6912271",
"0.6894865",
"0.6882103",
"0.6821287",
"0.6802176",
"0.67936605",
"0.6793382",
"0.67724514",
"0.6733606",
"0.67127806",
"0.6643783",
"0.6624183",
"0.6582234",
"0.6582234",
"0.65759873",
"0.657143... | 0.6174243 | 48 |
update figures and statistics windows with a new selection of specimen | def update_selection(self):
# clear all boxes
self.clear_boxes()
self.draw_figure(self.s)
# update temperature list
if self.Data[self.s]['T_or_MW'] == "T":
self.temperatures = np.array(self.Data[self.s]['t_Arai']) - 273.
else:
self.temperatures =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_spec_plot(self):\n if self.img is None:\n return\n\n p = self.params\n pos = np.array(self.roi.pos(), dtype=int)\n size = np.array(self.roi.size(), dtype=int)\n imin = np.clip(pos, 0, self.cube.shape[1])\n imax = np.clip(pos + size, 0, self.cube.shape... | [
"0.6341428",
"0.6211007",
"0.6087727",
"0.6024882",
"0.60203063",
"0.5984992",
"0.5984952",
"0.5932322",
"0.5757499",
"0.5752734",
"0.56910735",
"0.56750053",
"0.5666977",
"0.5648921",
"0.563894",
"0.5633827",
"0.56070507",
"0.5591819",
"0.5590214",
"0.5590214",
"0.5580956",
... | 0.59839946 | 7 |
List of Transformer layers in the encoder. | def transformer_layers(self):
return self._transformer_layers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def layers(self):\n return self['layers']",
"def layers(self):\r\n return self._flc.layers",
"def getLayers(self):\n return self.__layers",
"def layers(self):\n\n if not self.last_node:\n return []\n return nuke.layers(self.last_node)",
"def layers(self) ->Opti... | [
"0.76546353",
"0.7412039",
"0.735497",
"0.729343",
"0.7262977",
"0.7151334",
"0.69913906",
"0.6891594",
"0.6882588",
"0.6786619",
"0.6657021",
"0.6616057",
"0.6580447",
"0.6573983",
"0.65378547",
"0.6516191",
"0.65020543",
"0.64889055",
"0.6487083",
"0.64841074",
"0.64723986"... | 0.7659795 | 0 |
The pooler dense layer after the transformer layers. | def pooler_layer(self):
return self._pooler_layer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pool(self, img, layer):\n\n print(\"reshape pool\", layer)\n # Reshape the image\n img = self.img_reshape(img)\n # Apply the sigmoid activation function\n sig = tf.sigmoid(img)\n # Maxpooling\n max_pool = tf.nn.max_pool(sig, ksize=[1, 3, 3, 1], strides=self.stri... | [
"0.6443281",
"0.6432703",
"0.64221865",
"0.6096378",
"0.60579604",
"0.6009186",
"0.5980341",
"0.5957717",
"0.59535766",
"0.5913127",
"0.585362",
"0.58536136",
"0.5769495",
"0.5765381",
"0.57463044",
"0.57177854",
"0.5669864",
"0.5669823",
"0.56467485",
"0.5620941",
"0.5619522... | 0.7558266 | 0 |
Start the background thread that handles our core communication. | def _start_comms_thread(self):
self.commthread = threading.Thread(target=self.__comms_thread_body, daemon=True)
self.__comm_term = False
self.__comm_exc = None
self.commthread.start()
self.__comm_term = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n self._setup_thread()\n self.thread.start()",
"def background(self):\n self.thread = threading.Thread(target=self.run)\n self.thread.setDaemon(True)\n self.thread.start()",
"def start_background_thread(self):\n self.runner = Runner(queue=queue, app_id... | [
"0.73026776",
"0.72982407",
"0.7277038",
"0.7154931",
"0.7149857",
"0.7138421",
"0.71147335",
"0.70373863",
"0.70208234",
"0.6922902",
"0.6922902",
"0.69005215",
"0.68900114",
"0.6885676",
"0.6878991",
"0.6865937",
"0.68244505",
"0.67919165",
"0.67360646",
"0.6726586",
"0.669... | 0.6404249 | 39 |
Do not return anything, modify rooms inplace instead. | def wallsAndGates(self, rooms: List[List[int]]) -> None:
queue = deque()
for i in range(len(rooms)):
for j in range(len(rooms[0])):
if rooms[i][j] == 0:
queue.append((i, j, 0))
while queue:
i, j, val = queue.popleft()
if i ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rooms(self, rooms):\n\n self._rooms = rooms",
"def _add_rooms(self):\r\n rooms = self.model.get_all_rooms()\r\n\r\n for room in rooms:\r\n self._add_room(room)",
"def rooms(*args):\n send.system_message('\\n'.join(rooms()))",
"def all_rooms(self):\n pass",
... | [
"0.67922723",
"0.6150443",
"0.5985418",
"0.59520423",
"0.5938853",
"0.5910455",
"0.5802791",
"0.5788961",
"0.57677865",
"0.56960684",
"0.56584203",
"0.56518275",
"0.5649922",
"0.56375164",
"0.5580176",
"0.5570199",
"0.5540112",
"0.5534412",
"0.5534412",
"0.5529608",
"0.549605... | 0.5069172 | 63 |
Return an object with the given search option or None if None is found. | def get(**kwargs):
try:
object = ObjectDB.objects.get(**kwargs)
except ObjectDB.DoesNotExist:
object = None
return object | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_match(cls, options):\n for o in options:\n if isinstance(o, cls):\n return o\n return None",
"def find_exact(self, **kwargs):\n results = list(self.find(**kwargs))\n if len(results) == 1:\n return results[0]\n return None",
"def ... | [
"0.7059493",
"0.68324584",
"0.652524",
"0.6491123",
"0.64703393",
"0.63447845",
"0.63063335",
"0.6299679",
"0.61900854",
"0.603484",
"0.5950853",
"0.5905136",
"0.59022784",
"0.58563274",
"0.57933307",
"0.57610226",
"0.5760238",
"0.5708661",
"0.5708047",
"0.5700513",
"0.569370... | 0.5699472 | 20 |
Return the mean absolute deviation of data in x. | def mad(x):
median = np.median(x, axis=0)
diff = np.median(np.abs(median - x), axis=0)
mad = 1.4826 * np.max(diff) * np.sqrt(
x.shape[1]) * ((4./3.) / x.shape[0]) ** (.2)
return mad | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def std_deviation_of_mean_value(x):\n\n import numpy as np\n x = np.array(x)\n M = np.size(x)\n\n if M == 1: return 0\n\n return empirical_std_deviation(x)/np.sqrt(M)",
"def dev_mean(x):\r\n x_bar = mean(x)\r\n return [x_i - x_bar for x_i in x]",
"def stdev_from_mean(x)... | [
"0.8128166",
"0.7970981",
"0.7685947",
"0.7385404",
"0.7325873",
"0.73145753",
"0.7268439",
"0.7260357",
"0.7128688",
"0.7125395",
"0.7125098",
"0.7086564",
"0.7086564",
"0.7086564",
"0.6971384",
"0.6947374",
"0.69318235",
"0.69288206",
"0.6907765",
"0.6887351",
"0.68745536",... | 0.0 | -1 |
Create a single plane (monochrome) test pattern. Returns a flat row flat pixel array. | def generate_image(size, bitdepth, pattern):
width, height = size
maxval = 2**bitdepth-1
if maxval > 255:
a = array('H')
else:
a = array('B')
fw = float(width)
fh = float(height)
pfun = PATTERN[pattern]
for y in range(height):
fy = float(y)/fh
for x in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_uniform_planes(self):\n return np.random.randn(self.m, self.dim)",
"def get_test_pattern(img_size=(2048, 2048)):\n ny, nx = img_size\n # mask = np.zeros((ny, nx))\n\n # patterns with variable spacing\n periods = range(2, 20, 2)\n # vcounter = 0\n for ii, p in enumerate(peri... | [
"0.595569",
"0.5724671",
"0.55068254",
"0.5463038",
"0.5365112",
"0.53572774",
"0.53308684",
"0.52926993",
"0.518838",
"0.5178387",
"0.5139193",
"0.51269114",
"0.51256806",
"0.5120433",
"0.51184255",
"0.5101339",
"0.5058187",
"0.5042946",
"0.50272596",
"0.5008258",
"0.4995194... | 0.46931237 | 78 |
compute left(i) for every element in arr left[0] == left[len] == 0 | def lefts(self):
lstack = [len(self.arr)]
i = len(self.arr) - 1
while i >= 0:
if self.arr[i] > self.arr[lstack[-1] - 1]:
while lstack and self.arr[i] > self.arr[lstack[-1] - 1]:
x = lstack.pop()
self.left[x - 1] = i + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left(self):\n n = len(self)-1\n fl = np.zeros(n+1)\n for ii in range(n+1):\n for jj in range(n+1-ii):\n for kk in range(n+1-ii-jj):\n fl[ii+jj] += self[ii,jj,kk]\n return fl",
"def left(self, A, i):\n if 2*i +1 < len(A):\n ... | [
"0.6552956",
"0.62683547",
"0.62683547",
"0.5807864",
"0.56118333",
"0.56116384",
"0.56116384",
"0.55651414",
"0.55595565",
"0.55138683",
"0.5465798",
"0.5450672",
"0.54477847",
"0.5346157",
"0.5344417",
"0.5311102",
"0.5302391",
"0.52977496",
"0.5287689",
"0.52502346",
"0.52... | 0.7065468 | 0 |
Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.64530563 | 32 |
return the time at start_arg | def _get_starttime_from_startarg_1d(time, start_arg):
assert type(time) == type(np.array([])), "time must be numpy array"
if len(time.shape) > 1:
raise ValueError('time must be 1dimensional. currently has shape {}'.format(time.shape))
return time[start_arg].flatten()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_time(self) -> float:\r\n ...",
"def start_time(self):\n pass",
"def getStartTime(self):\n assert not self.isWaitingToStart(), \"Too early to tell: %s\" % self\n return \"%s\" % self.__rawInfo.startTime",
"def start_time(self):\n return self.__start",
"def start_time(sel... | [
"0.77314585",
"0.7544561",
"0.7120931",
"0.70674896",
"0.701666",
"0.7000139",
"0.69905615",
"0.69905615",
"0.6918673",
"0.6906737",
"0.6906737",
"0.6906737",
"0.6906737",
"0.6906737",
"0.6906737",
"0.6890226",
"0.6854983",
"0.68503034",
"0.6811429",
"0.67654103",
"0.6741046"... | 0.6381211 | 58 |
Test delete last element when list is empty | def test_pop_empty_list(self):
test_list = DoubleLinkedList()
with self.assertRaises(Exception) as context:
test_list.pop()
self.assertTrue('Empty list' in str(context.exception)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_empty(list):\n for x in range(len(list)):\n if len(list[x - 1]) == 0:\n del list[x - 1]\n return list",
"def test_last_element(self):\n self.assertEqual(functions.last_element([1, 2, 3]), 3)\n self.assertEqual(functions.last_element([]), None)",
"def remove_last_it... | [
"0.7048151",
"0.6966669",
"0.6949517",
"0.6821525",
"0.6816009",
"0.67931384",
"0.67117846",
"0.6701146",
"0.6665244",
"0.66141135",
"0.65977174",
"0.6556374",
"0.6540659",
"0.65347004",
"0.6493857",
"0.64855945",
"0.64575875",
"0.6438228",
"0.62803936",
"0.6183844",
"0.61459... | 0.61451286 | 21 |
the derivative of the crossentropy loss w.r.t. to sigmoid activation function (we will get to this later) | def derivative_loss(self, y, y_pred):
return y_pred - y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(x):\n return x * (1-x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def der_sigmoid... | [
"0.77281326",
"0.7685325",
"0.7685325",
"0.765435",
"0.75773454",
"0.7545893",
"0.7537575",
"0.7488571",
"0.7431611",
"0.74011064",
"0.72209287",
"0.7203489",
"0.7129801",
"0.7126261",
"0.7065314",
"0.7044009",
"0.70123464",
"0.70105284",
"0.69976246",
"0.6974087",
"0.6972144... | 0.71228933 | 14 |
A single gradient descent step. | def gradient_descent_step(self, x, y, learning_rate):
# compute derivative of loss wrt Z
dZ = self.derivative_loss(y, self.predict(x))
dW = np.dot(dZ, x)
# subtract average derivative from weights
self.w -= learning_rate * 1.0/dW.shape[0] * dW
if self.fit_b:
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient_step(self):\n n = 10 #Granularity of line search\n grad = self.gradient()\n W = project(self.W[-1] + grad)\n A = np.linspace(0., self.alpha, n+2)[1:-1]\n Objective = map(self, [(1. - a)*self.W[-1] + a*W for a in A])\n a = A[np.argmax(Objective)]\n W = (... | [
"0.7066479",
"0.702465",
"0.6924028",
"0.6881017",
"0.6817962",
"0.6775349",
"0.676984",
"0.67147845",
"0.6708169",
"0.66616976",
"0.66299105",
"0.66248447",
"0.66240823",
"0.6621865",
"0.6615596",
"0.6598249",
"0.6574133",
"0.6547513",
"0.6537788",
"0.6528013",
"0.65221363",... | 0.6627937 | 11 |
Apply gradient descent algorithm. At each iteration, the algorithm will draw a random sample from x and perform a weight update with the partial derivatives that are computed by the use of this sample. | def train(self, X, y, batch_size=8, learning_rate=1, n_steps=100):
self.training_w = np.zeros((n_steps, self.n_in+1))
self.training_loss = np.zeros(n_steps)
for s in tqdm(range(n_steps)):
# draw a random batch
batch_idx = np.random.choice(X.shape[0], batch_size, replace=F... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient_descent_step(self, x, y, learning_rate):\n # compute derivative of loss wrt Z\n dZ = self.derivative_loss(y, self.predict(x))\n dW = np.dot(dZ, x)\n # subtract average derivative from weights\n self.w -= learning_rate * 1.0/dW.shape[0] * dW\n if self.fit_b:\n ... | [
"0.6750847",
"0.6649427",
"0.6524021",
"0.649237",
"0.6420118",
"0.6321613",
"0.6314738",
"0.6313472",
"0.62838554",
"0.6283534",
"0.62646556",
"0.6259997",
"0.62482303",
"0.62469167",
"0.62220544",
"0.6214603",
"0.6193992",
"0.6158888",
"0.6155982",
"0.6132328",
"0.61203456"... | 0.0 | -1 |
Apply dimensionality reduction to X using the model. Compute the expected mean of the latent variables. See Barber, 21.2.33 (or Bishop, 12.66). | def transform(self, X):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_layer_moments(x):\n return torch.mean(x, dim=(1, 2, 3), keepdim=True), torch.var(x, dim=(1, 2, 3), keepdim=True)",
"def _compute_batch_moments(x):\n return torch.mean(x, dim=(0, 2, 3), keepdim=True), torch.var(x, dim=(0, 2, 3), keepdim=True)",
"def fit(self, x):\n self.mean_ =... | [
"0.63754356",
"0.6072645",
"0.5927967",
"0.5910336",
"0.5827002",
"0.58140147",
"0.58083177",
"0.5798858",
"0.57799584",
"0.5774818",
"0.57621014",
"0.5747546",
"0.57192034",
"0.5655611",
"0.56432045",
"0.56411344",
"0.56240904",
"0.5611995",
"0.5611995",
"0.5593492",
"0.5584... | 0.0 | -1 |
Compute data precision matrix with the FactorAnalysis model. Returns | def get_precision(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GmatBase_GetDataPrecision():\n return _gmat_py.GmatBase_GetDataPrecision()",
"def precision(cMatrix):\n return cMatrix[0,0] / np.sum(cMatrix[0,:])",
"def GetDataPrecision():\n return _gmat_py.GmatBase_GetDataPrecision()",
"def precision(self) -> float:\n return self._matrix.precision"... | [
"0.6253341",
"0.624235",
"0.6187702",
"0.6121867",
"0.59828174",
"0.5950762",
"0.5911515",
"0.585981",
"0.58425736",
"0.5711708",
"0.57038945",
"0.5675002",
"0.5616936",
"0.56155574",
"0.55887294",
"0.5568295",
"0.55645037",
"0.55570275",
"0.552171",
"0.5486147",
"0.5486147",... | 0.5691275 | 11 |
Send message to slack channel | def post_msg(text):
client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
client.chat_postMessage(
channel=os.environ["SLACK_CHANNEL"],
text="News",
blocks=[
{"type": "section", "text": {"type": "mrkdwn", "text": (text)}}],
)
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_slack(self, message):\n self.slack_client.api_call('chat.postMessage', channel=self.slack_channel, text=message, username=self.username, icon_emoji=self.slack_icon_emoji)\n print(\"Slack Notification sent\")",
"def send_message(channel, message):\n slack_client = get_client()\n slack... | [
"0.85000354",
"0.80650544",
"0.77331454",
"0.7688865",
"0.74492264",
"0.74169564",
"0.7396353",
"0.73536277",
"0.73371035",
"0.73287034",
"0.7214504",
"0.72094834",
"0.7201152",
"0.7192862",
"0.71824795",
"0.7173662",
"0.71194774",
"0.71050453",
"0.7046588",
"0.7025849",
"0.7... | 0.6336774 | 58 |
Return a set of configured connections instances. | def configured_connections(hass):
return set(
entry.data.get(CONF_NAME) for entry in hass.config_entries.async_entries(DOMAIN)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_connections(self):\n return self.connections",
"def get_connections(self):\n return self.connections",
"def get_connections(self):\n return self._connections",
"def getConnectionList(self):\n return []",
"def get_all(self) -> typing.List[Connection]:\n return [Con... | [
"0.7763236",
"0.7763236",
"0.76180583",
"0.7429083",
"0.6979539",
"0.6956967",
"0.6865074",
"0.6803033",
"0.6776813",
"0.6776798",
"0.67109436",
"0.66908604",
"0.6681677",
"0.65563625",
"0.65533215",
"0.65301704",
"0.6486992",
"0.6468843",
"0.6427187",
"0.6365585",
"0.6361720... | 0.7573443 | 3 |
Return a set of the configured hosts. | def configured_service(hass):
return set(
"ais_wifi_service" for entry in hass.config_entries.async_entries(DOMAIN)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hosts(self):\n\n return self._get_list_field(\"hosts\", lambda x: HostSettingContext(x))",
"def hosts(self):\n\n return self._get_list_field(\"hosts\", lambda x: HostSettingContext(x))",
"def hosts(self):\n hosts = set()\n for p, c in self.configs_:\n hosts.update(c.h... | [
"0.8253178",
"0.8253178",
"0.82302076",
"0.7990578",
"0.7985524",
"0.7985524",
"0.7846063",
"0.77907145",
"0.7740108",
"0.76784396",
"0.7655503",
"0.7576256",
"0.7351472",
"0.734576",
"0.7334889",
"0.72611463",
"0.72245675",
"0.69687057",
"0.69666266",
"0.6880548",
"0.685191"... | 0.0 | -1 |
This method adds values to the csv based on the type of the ecperiment run by the user. | def experiment_data(experiments_filepath, method_type):
df = pd.read_csv(os.path.join(experiments_filepath, "experiments.csv"))
df.at[0, method_type] = 'True'
if method_type == 'rotationtranslationValue' or \
method_type == 'fourierfilteringValue' or \
method_type == 'colortograysca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_experiments(experiments_filepath, method_type):\n\n if os.path.isfile(os.path.join(experiments_filepath, \"experiments.csv\")):\n experiment_data(experiments_filepath, method_type)\n else:\n with open(os.path.join(experiments_filepath, \"experiments.csv\"), 'w', newline='') as expe... | [
"0.5955177",
"0.5799339",
"0.57776695",
"0.569629",
"0.5654318",
"0.5586445",
"0.55445904",
"0.5538577",
"0.5533873",
"0.55140644",
"0.54786485",
"0.5465738",
"0.544635",
"0.54442596",
"0.54190844",
"0.5415556",
"0.54071724",
"0.5389133",
"0.5344478",
"0.53434473",
"0.5312481... | 0.5856166 | 1 |
Given the image and the face's bounding box, crop out the face. | def crop_face(image,face_rect):
(x1,y1,x2,y2) = face_rect
w = abs(x2-x1)
h = abs(y2-y1)
return image[y1:y1 + h, x1:x1 + w] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_face(self, image):\n gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n # gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)\n\n faces = self.faceCascade.detectMultiScale(\n gray,\n scaleFactor=1.1,\n minNeighbors=5,\n minSize=(30, 30)\n )\... | [
"0.82890314",
"0.81894946",
"0.7620541",
"0.7316049",
"0.7219431",
"0.692287",
"0.6681022",
"0.6676392",
"0.65292567",
"0.64825433",
"0.64536095",
"0.6407258",
"0.63640535",
"0.636087",
"0.63439816",
"0.6331505",
"0.63146335",
"0.6292622",
"0.6258957",
"0.62572706",
"0.625094... | 0.81785125 | 2 |
Return matplotlib code for comparing band structures. | def get_mpl_code_for_bands(
dft_bands,
wan_bands,
*,
fermi_energy=None,
shift_fermi=False,
title=None,
save=False,
filename=None,
):
if fermi_energy is None and shift_fermi:
raise ValueError("shift_fermi requested but no fermi_energy provided?")
# dft_bands.show_mpl()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_spectrum(spectrum0, spectrum1):\n title0 = spectrum0.get_title() \n title1 = spectrum1.get_title() \n if(title0 < title1): \n return -1\n elif(title0 > title1): \n return 1\n else:\n return 0",
"def ... | [
"0.5913329",
"0.5867776",
"0.56764007",
"0.56370556",
"0.5586694",
"0.5444995",
"0.53492147",
"0.5229869",
"0.5208389",
"0.51960075",
"0.5179667",
"0.5148397",
"0.51455396",
"0.51097965",
"0.5076049",
"0.507592",
"0.506804",
"0.5064281",
"0.5057183",
"0.5023761",
"0.5023723",... | 0.4963736 | 26 |
Get Fermi energy of Wannier90BandsWorkChain. | def get_workchain_fermi_energy(
workchain: ty.Union[Wannier90BaseWorkChain, Wannier90BandsWorkChain]
) -> float:
from aiida_wannier90_workflows.utils.workflows import get_last_calcjob
from aiida_wannier90_workflows.utils.workflows.pw import (
get_fermi_energy,
get_fermi_energy_from_nscf,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getEnergy(self):\n if not hasattr(self,\"energy\"):\n self.energy = self.calcEnergy()\n return self.energy",
"def get_energy(self):\n return self.momentum*self.momentum/(2*self.mass)",
"def get_energy(self):\r\n return self._energy",
"def energy(self):\n return self.mc.energy(... | [
"0.6449617",
"0.6423447",
"0.64144474",
"0.62146735",
"0.61893106",
"0.6186262",
"0.617732",
"0.6166734",
"0.6116008",
"0.61081624",
"0.61081624",
"0.60513556",
"0.60119957",
"0.5996877",
"0.59921515",
"0.59921515",
"0.5974598",
"0.59724855",
"0.59418535",
"0.59140563",
"0.58... | 0.7865059 | 0 |
Get a dictonary of BandsData. | def get_band_dict(band: ty.Union[dict, orm.BandsData], /) -> dict:
if isinstance(band, dict):
return band
if isinstance(band, orm.BandsData):
# band_json, _ = band._exportcontent(fileformat='json')
# # band_json = band_json.decode()
# band_dict = json.loads(band_json)
ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getData(self):\n return dict(self._dump_data)",
"def dict(self):\n return self.data",
"def dict(self):\n return self.__data_dict",
"def get_dict(self):\n return self._data",
"def get_data(self):\n return {\"bcode\": self.barcode, \"prodid\": self.product_id}",
"def to_d... | [
"0.66219884",
"0.66050303",
"0.6586543",
"0.6531856",
"0.6498209",
"0.6415965",
"0.63278186",
"0.62485445",
"0.6246312",
"0.6246312",
"0.6178007",
"0.6150199",
"0.6148695",
"0.6126884",
"0.6092901",
"0.6088556",
"0.60748523",
"0.60692406",
"0.60606265",
"0.60555166",
"0.60508... | 0.5545951 | 82 |
Get BandsData of workchain outputs. | def get_workflow_output_band(
node: ty.Union[
PwBandsWorkChain,
Wannier90BandsWorkChain,
Wannier90OptimizeWorkChain,
ProjwfcBandsWorkChain,
orm.BandsData,
],
/,
) -> orm.BandsData:
if isinstance(node, orm.BandsData):
return node
# procss_class = node.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_output_bands(workchain):\n if isinstance(workchain, orm.BandsData):\n return workchain\n if workchain.process_class in [PwCalculation, PwBaseWorkChain]:\n return workchain.outputs.output_band\n if workchain.process_class in (\n PwBandsWorkChain,\n ProjwfcBandsWorkChain,... | [
"0.6902057",
"0.6427684",
"0.63589406",
"0.63324606",
"0.63287985",
"0.6286089",
"0.62487304",
"0.62487304",
"0.6220067",
"0.6209136",
"0.61668146",
"0.61579674",
"0.6090362",
"0.6046081",
"0.6022408",
"0.5978674",
"0.589648",
"0.58671826",
"0.58671826",
"0.58671826",
"0.5867... | 0.56800324 | 28 |
This method merges the row tiles as if the user attempted to slide them from right to left. | def merge_tiles_in_row(row_vals):
def _find_next_tile(row_vals, start_index):
j = start_index
while j < len(row_vals) and row_vals[j] == 0:
j += 1
valid_pos, idx = j < len(row_vals), j
return (valid_pos, idx)
i = 0
current_val = None
shifted_row_vals = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_right(row):\r\n row1 = reverse(row)\r\n row2 = add_tiles(row1)\r\n row3 = reverse(row2)\r\n row = row3\r\n\r\n return row",
"def merge_with_completed_rows(self):\n if self.current_direction == \"down\":\n # each row starting at the bottom\n for i in reversed(... | [
"0.7243484",
"0.6939514",
"0.62418675",
"0.6210706",
"0.59788835",
"0.593066",
"0.5878278",
"0.5837892",
"0.58121264",
"0.58070934",
"0.57809955",
"0.57471186",
"0.5666867",
"0.56349266",
"0.56217784",
"0.55230176",
"0.5508657",
"0.54996246",
"0.54773957",
"0.5472604",
"0.545... | 0.56560314 | 13 |
Get the determinant of a tridiagonal matrix with constant offdiagonal terms, and constant diagonals except for the first and last elements, which are equal to each other but not the other diagonal elements in constant time. | def ar_trid_det(A):
if T < 5:
return(np.linalg.det(A))
else:
gamma = A[0,0]
alpha = A[1,1]
beta = A[1,2]
# Get determinant of "middle matrices"
d1 = np.exp(td_const_ldet(alpha, beta, T-2))
print(np.abs(np.linalg.det(A[1:-1,1:-1]) - d1))
d2 = np.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tridiag_det(A):\n if (type(A) is not np.ndarray):\n raise ValueError(\"A must be a np.ndarray\")\n if (A.shape[0] is not A.shape[1]):\n raise ValueError(\"A must be square.\")\n N = A.shape[0]\n f = np.empty(N+2)\n f[0] = 0\n f[1] = 1\n f[2] = A[1,1]\n for n in range(3,N+2... | [
"0.7214086",
"0.69962674",
"0.6847935",
"0.6821472",
"0.6787654",
"0.6638409",
"0.6563",
"0.6553965",
"0.64951706",
"0.6443772",
"0.642179",
"0.6417475",
"0.6414809",
"0.6410782",
"0.63987577",
"0.6395312",
"0.6368337",
"0.6365445",
"0.6290527",
"0.627308",
"0.62463933",
"0... | 0.60333425 | 34 |
Calculate the log determinant of a tridiagonal matrix with banded terms, such that every diagonal element is a, and the super and sub diagonal elements are b, and the matrix is TxT. A should be an np array | def td_const_ldet(a, b, T):
d = np.sqrt(np.square(a) - 4.0 * np.square(b))
# Make this split because we are raising something to a potentially large power and
# need to be ensure that only happens for something < 1.
return(-np.log(d) + (T+1) * (np.log(0.5) + np.log(a+d)) + np.log(1 - pow((a-d)/(a+d), T+... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tridiag_det(A):\n if (type(A) is not np.ndarray):\n raise ValueError(\"A must be a np.ndarray\")\n if (A.shape[0] is not A.shape[1]):\n raise ValueError(\"A must be square.\")\n N = A.shape[0]\n f = np.empty(N+2)\n f[0] = 0\n f[1] = 1\n f[2] = A[1,1]\n for n in range(3,N+2... | [
"0.6662672",
"0.62672263",
"0.6228904",
"0.6065143",
"0.6016102",
"0.59977657",
"0.5979253",
"0.5978536",
"0.59554935",
"0.58753043",
"0.58718175",
"0.56531256",
"0.562726",
"0.5550798",
"0.55432767",
"0.55048525",
"0.5471022",
"0.54459494",
"0.5409553",
"0.5389128",
"0.53837... | 0.6086269 | 3 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8081514",
"0.7890486",
"0.7534929",
"0.72789717",
"0.72789717",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
x_turn = 0
o_turn = 0
for i in range(3):
for j in range(3):
if board[i][j] == X:
x_turn += 1
elif board[i][j] == O:
o_turn += 1
if x_turn == 0 and o_turn == 0:
return X
elif x_turn > o_turn:
return O
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.62238955 | 59 |
Returns the optimal action for the current player on the board. | def minimax(board):
if terminal(board):
return None
if player(board)==X:
value, move = max_value(board)
return move
if player(board)==O:
value, move = min_value(board)
return move | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.77687955",
"0.76336724",
"0.75853777",
"0.75287056",
"0.75184536",
"0.74660885",
"0.74603",
"0.7425707",
"0.7417552",
"0.7395776",
"0.7374339",
"0.73361117",
"0.73148525",
"0.7307234",
"0.72848594",
"0.72660655",
"0.72660655",
"0.7251144",
"0.7233601",
"0.7203659",
"0.7174... | 0.0 | -1 |
Get the value of the probability density function evaluated at a point. | def pdf(self, x):
x = self.lib.atleast_2d(x)
es = x[:, None, :] - self.means[None, :, :]
# The code below does: exp[i] = es[i].T @ self.inverse_covariances_device[i] @ es[i]
exp = es[:, :, None, :] @ self._inverse_covariances[None, :, :, :] @ es[:, :, :, None]
r = self.lib.exp(-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_one(self, x):\n # p = 1. / (np.sqrt(2. * np.pi) * self.sigma) * \\\n # np.exp(-0.5 * (self.mean - x) * self.invvar * (self.mean - x))\n p = self.dist.probability(x)\n return p",
"def pdf(self, point: np.ndarray) -> float:\n return self._probs.dot([rv.pdf(point) for... | [
"0.6892031",
"0.6638326",
"0.6626398",
"0.6589628",
"0.6543286",
"0.65105957",
"0.65105957",
"0.650531",
"0.64748895",
"0.6460713",
"0.6460713",
"0.6414723",
"0.6412853",
"0.64114016",
"0.6408717",
"0.63578147",
"0.63448906",
"0.6338755",
"0.63322383",
"0.63322383",
"0.633162... | 0.57863635 | 72 |
Compute cross entropy for logits and labels w/ label smoothing | def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.float32):
num_classes = logits.shape[-1]
labels = jax.nn.one_hot(labels, num_classes, dtype=dtype)
if label_smoothing > 0:
labels = labels * (1 - label_smoothing) + label_smoothing / num_classes
logp = jax.nn.log_softmax(logits... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax_cross_entropy(y, label):\r\n losses = np.sum((- np.log(y + g_epsilon) * label), axis=1)\r\n return losses\r\n pass",
"def cross_entropy_loss(self, logits, labels):\n return F.cross_entropy(logits, labels)",
"def cross_entropy(y_observed, p):\n\n pass",
"def calculate_cross_entr... | [
"0.76539767",
"0.7548414",
"0.74440634",
"0.73242384",
"0.7245892",
"0.7199458",
"0.71937406",
"0.7191855",
"0.71378994",
"0.7121806",
"0.71203005",
"0.7082006",
"0.7081329",
"0.7065346",
"0.70595443",
"0.70155513",
"0.69821614",
"0.68986845",
"0.68648225",
"0.6851328",
"0.68... | 0.7794154 | 0 |
Compute weighted cross entropy for logits and labels w/ label smoothing. | def weighted_cross_entropy_loss(logits, labels, weights=None, label_smoothing=0.0, dtype=jnp.float32):
if logits.ndim != labels.ndim + 1:
raise ValueError(f'Incorrect shapes. Got shape {logits.shape} logits and {labels.shape} targets')
num_classes = logits.shape[-1]
off_value = label_smoothing / num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.float32):\n num_classes = logits.shape[-1]\n labels = jax.nn.one_hot(labels, num_classes, dtype=dtype)\n if label_smoothing > 0:\n labels = labels * (1 - label_smoothing) + label_smoothing / num_classes\n logp = jax.nn.log_soft... | [
"0.773191",
"0.75471383",
"0.7306294",
"0.7201186",
"0.7194352",
"0.7166019",
"0.7162556",
"0.71450794",
"0.7136435",
"0.71108496",
"0.7095747",
"0.70949763",
"0.7059473",
"0.69993633",
"0.6926923",
"0.69088995",
"0.6886519",
"0.6869772",
"0.68469906",
"0.683391",
"0.6831419"... | 0.7556574 | 1 |
Parse the max_min log to get requantization values | def _parse_requantization_ranges(self):
res = {}
print_suffix = "__print__"
lines = self._get_valid_log()
temp_min = {}
temp_max = {}
pattern_def = r"{};{}:\[\-?\d+\.?\d*e?-?\+?\d*\]".format(print_suffix, self.postfix)
for i in lines:
if not re.search... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_max_min_log(self):\n print_suffix = \"__print__\"\n lines = self._get_valid_log()\n\n res = {}\n temp = {}\n pattern_def = r\"{};{}\\[\\-?\\d+\\.?\\d*e?\\+?\\d*\\]\".format(print_suffix, self.postfix)\n for i in lines:\n\n if not re.search(pattern_def... | [
"0.7834772",
"0.6390236",
"0.62873626",
"0.61562467",
"0.5992704",
"0.57486534",
"0.5746076",
"0.5741339",
"0.56064725",
"0.5549811",
"0.5495061",
"0.5465561",
"0.53881145",
"0.53604424",
"0.53534925",
"0.5336807",
"0.53062767",
"0.530563",
"0.52952737",
"0.52911496",
"0.5268... | 0.61027235 | 4 |
Initializing the class Defense, it's the constructor, assigned the name and two attributes used for calculates the capacity of defend of the object limit both values in 10. | def __init__(self,name,maneuverability,protection):
super().__init__(name)
self.maneuverability = super().limitsValues(maneuverability)
self.protection = super().limitsValues(protection) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, defense):\n self.name = name\n self.defense = defense",
"def __init__(self, name, budget, bid_increase_perc):\n self._name = name\n self._budget = budget\n self._bid_probability = random.random()\n self._bid_increase_perc = bid_increase_perc\n ... | [
"0.76814866",
"0.7217347",
"0.7140976",
"0.70071125",
"0.6946289",
"0.683334",
"0.674038",
"0.6689817",
"0.6651852",
"0.6560615",
"0.65172315",
"0.6460544",
"0.64399624",
"0.64337367",
"0.6414216",
"0.6404823",
"0.6362897",
"0.6357784",
"0.6357331",
"0.6346203",
"0.63187736",... | 0.64216924 | 14 |
Create and configure a Flask application | def create_app(config: dict) -> Flask:
for key, value in config.items():
app.config[key] = value
db.init_app(app)
ma.init_app(app)
app.app_context().push()
return app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_app():\n\n # 1 Create Flask application\n app = Flask(\n import_name=__name__,\n template_folder=\"templates\",\n static_folder=\"static\"\n )\n\n # 2 Update the apps configuration\n app = config_selector(app)\n register_error_handlers(app)\n\n cache.init_app(app... | [
"0.8566035",
"0.8454156",
"0.8453664",
"0.83504754",
"0.8265668",
"0.8249991",
"0.82173014",
"0.817393",
"0.81679577",
"0.8163339",
"0.8130075",
"0.8127249",
"0.80747545",
"0.80626917",
"0.8058702",
"0.8052",
"0.8050514",
"0.80393964",
"0.80209464",
"0.7996232",
"0.79940885",... | 0.8213039 | 7 |
Read content of a Yaml file | def read_content(self, context):
yaml_content = yaml.load(self._file)
for key, value in yaml_content.items():
context[key] = value
#memoize mbean hierarchy
logger.debug('Update Context[%s]=[%s]', key, value)
if key == CTX_KEY_COMMON_COLLECTD_JMX_MBEANS_SE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_yaml(yaml_path):\n with open(yaml_path) as f:\n yaml_data = yaml.load(f, Loader=yaml.FullLoader)\n\n return yaml_data",
"def load_yaml(file_path):\n with open(file_path) as fin:\n content = yaml.load(fin, Loader=yaml.FullLoader)\n return content",
"def _read(self, text):\n ... | [
"0.7296807",
"0.7292776",
"0.72444624",
"0.7229443",
"0.7134055",
"0.7105821",
"0.7084536",
"0.7016807",
"0.6995422",
"0.68559635",
"0.6815792",
"0.6799774",
"0.6761992",
"0.67590237",
"0.67416453",
"0.67351764",
"0.673463",
"0.6733863",
"0.67283577",
"0.6707348",
"0.66756546... | 0.0 | -1 |
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using `self.queryset`. This method should always be used rather than accessing `self.queryset` directly, as `self.queryset` gets evaluated only once, and those results are cached for all subsequent requests. You may want t... | def get_queryset(self):
assert self.queryset is not None, (
"'%s' should either include a `queryset` attribute, "
"or override the `get_queryset()` method."
% self.__class__.__name__
)
queryset = self.queryset
if isinstance(queryset, Query... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n \n # throw error if no args pass in\n assert self.model or self.queryset, 'No queryset found'\n if self.queryset:\n return self.queryset\n else:\n return self.model.objects.all()",
"def get_queryset(self):\n if getattr(self... | [
"0.7866257",
"0.7822994",
"0.7813789",
"0.7698963",
"0.762543",
"0.75064933",
"0.74762326",
"0.7424702",
"0.7396861",
"0.73214054",
"0.7320818",
"0.7284916",
"0.72733974",
"0.70976275",
"0.7067468",
"0.7059603",
"0.7059603",
"0.7059603",
"0.70504385",
"0.702557",
"0.6963806",... | 0.80717546 | 0 |
Returns the object the view is displaying. You may want to override this if you need to provide nonstandard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf. | def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
# Perform the lookup filtering.
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
assert lookup_url_kwarg in self.kwargs, (
'Expected view %s to be called with a URL keyword argument ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_object(self):\n lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field\n\n assert lookup_url_kwarg in self.kwargs, (\n 'Expected view %s to be called with a URL keyword argument '\n 'named \"%s\". Fix your URL conf, or set the `.lookup_field` '\n 'attri... | [
"0.76926893",
"0.7584772",
"0.7417821",
"0.73825294",
"0.71355003",
"0.7099071",
"0.7099071",
"0.7051358",
"0.70489544",
"0.7027412",
"0.7012775",
"0.69342476",
"0.68267244",
"0.6785083",
"0.6676381",
"0.66092163",
"0.65993863",
"0.6593986",
"0.659337",
"0.65915096",
"0.65099... | 0.7830459 | 0 |
Given a queryset, filter it with whichever filter backend is in use. You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom `get_object` method if you want to apply the configured filtering backend to the default queryset. | def filter_queryset(self, queryset):
for backend in list(self.filter_backends):
queryset = backend().filter_queryset(self.request, queryset, self)
return queryset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_queryset(self,queryset):\n filters = {}\n for backend in list(self.filter_backends):\n backendobj = backend()\n queryset = backendobj.filter_queryset(self.request, queryset, self)\n if hasattr(backendobj,'get_applied_filters'):\n filters.upda... | [
"0.67710906",
"0.6747371",
"0.6730551",
"0.6730125",
"0.65300155",
"0.633958",
"0.63272583",
"0.62976974",
"0.6259834",
"0.6232671",
"0.61528313",
"0.61520433",
"0.6139248",
"0.6114376",
"0.61111873",
"0.60996866",
"0.60647786",
"0.6046193",
"0.6029349",
"0.60183007",
"0.5966... | 0.8035435 | 0 |
Sets the version_name of this CRFFormVersionDefinition. | def version_name(self, version_name):
self._version_name = version_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crf_version_name(self, crf_version_name):\n\n self._crf_version_name = crf_version_name",
"def revision_name(self, revision_name):\n\n self._revision_name = revision_name",
"def version(self, version: str):\n\n self._version = version",
"def version(self, version: str):\n\n se... | [
"0.80101985",
"0.668952",
"0.6490059",
"0.6490059",
"0.6376749",
"0.6335843",
"0.6335843",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"0.6297765",
"... | 0.827736 | 0 |
Sets the disp_sequence of this CRFFormVersionDefinition. | def disp_sequence(self, disp_sequence):
self._disp_sequence = disp_sequence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_sequence(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name=\"sequence\", parent=self, path_helper=self._path_helper, ... | [
"0.5214761",
"0.5214761",
"0.5214761",
"0.51467854",
"0.50441116",
"0.50441116",
"0.50441116",
"0.5000879",
"0.495787",
"0.4926427",
"0.4926427",
"0.4926427",
"0.4926427",
"0.4926427",
"0.4926427",
"0.4784346",
"0.47534102",
"0.4726816",
"0.4726816",
"0.4726816",
"0.4726816",... | 0.7444667 | 0 |
Sets the screening_expression of this CRFFormVersionDefinition. | def screening_expression(self, screening_expression):
self._screening_expression = screening_expression | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def screening_flag(self, screening_flag):\n\n self._screening_flag = screening_flag",
"def expression(self, expr):\n self.set(expression=expr)",
"def expression(self, expression):\n\n self._expression = expression",
"def set_expression(self, expression):\n\n self.raw_expression = ... | [
"0.5455012",
"0.5321843",
"0.5309028",
"0.51008856",
"0.49353245",
"0.4776634",
"0.47473302",
"0.46768484",
"0.46511483",
"0.45884532",
"0.45667246",
"0.45388067",
"0.44648632",
"0.44520253",
"0.44459647",
"0.44099808",
"0.4401412",
"0.43851623",
"0.43727505",
"0.43710274",
"... | 0.7633556 | 0 |
Sets the custom_enroll_flag of this CRFFormVersionDefinition. | def custom_enroll_flag(self, custom_enroll_flag):
self._custom_enroll_flag = custom_enroll_flag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ios_enterprise_enrollment_enabled(self, ios_enterprise_enrollment_enabled):\n\n self._ios_enterprise_enrollment_enabled = ios_enterprise_enrollment_enabled",
"def custom_compliance_standard(self, custom_compliance_standard):\n\n self._custom_compliance_standard = custom_compliance_standard",
... | [
"0.5343343",
"0.53401786",
"0.520874",
"0.5170403",
"0.5170403",
"0.5118634",
"0.5118634",
"0.5118634",
"0.5118634",
"0.5118634",
"0.50184315",
"0.49782383",
"0.49638996",
"0.49478647",
"0.4934881",
"0.49342877",
"0.49076614",
"0.48184973",
"0.47224274",
"0.47207263",
"0.4714... | 0.86655015 | 0 |
Sets the used_at_enroll of this CRFFormVersionDefinition. | def used_at_enroll(self, used_at_enroll):
self._used_at_enroll = used_at_enroll | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_enrollment(self, expected_enrollment):\n\n self._expected_enrollment = expected_enrollment",
"def update_enrollment(self, mode=None, is_active=None):\r\n activation_changed = False\r\n # if is_active is None, then the call to update_enrollment didn't specify\r\n # any val... | [
"0.49485815",
"0.4782301",
"0.46048224",
"0.45967966",
"0.45514694",
"0.4534382",
"0.45191392",
"0.45114264",
"0.45028192",
"0.44747978",
"0.44360462",
"0.44292605",
"0.44168425",
"0.44163665",
"0.43935293",
"0.43694058",
"0.43656084",
"0.4363961",
"0.4353675",
"0.43458185",
... | 0.7688575 | 0 |
Sets the irb_approval_date of this CRFFormVersionDefinition. | def irb_approval_date(self, irb_approval_date):
self._irb_approval_date = irb_approval_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_approval(self, approval: DeployApproval):\n if not crypto.verify_deploy_approval_signature(self.hash,\n approval.signature,\n approval.signer):\n raise ValueError(\"Invalid signatur... | [
"0.62019193",
"0.5929497",
"0.58108777",
"0.57622576",
"0.55737054",
"0.5534174",
"0.5443436",
"0.5440523",
"0.5439778",
"0.54241776",
"0.5401063",
"0.5391277",
"0.5382265",
"0.53735363",
"0.5362173",
"0.53459036",
"0.5344097",
"0.5340371",
"0.5321267",
"0.5308051",
"0.529712... | 0.8850005 | 0 |
Sets the valid_from of this CRFFormVersionDefinition. | def valid_from(self, valid_from):
self._valid_from = valid_from | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_from(self, valid_from: datetime):\n if valid_from is None:\n raise ValueError(\"Invalid value for `valid_from`, must not be `None`\") # noqa: E501\n\n self._valid_from = valid_from",
"def valid_from(self) -> datetime:\n return self._valid_from",
"def is_valid_from_ver... | [
"0.77548486",
"0.6571087",
"0.6203682",
"0.6088737",
"0.6069641",
"0.6069641",
"0.6049577",
"0.60166544",
"0.60132647",
"0.59244114",
"0.58272403",
"0.5745993",
"0.5745993",
"0.5745993",
"0.5745993",
"0.5702036",
"0.5679496",
"0.5583681",
"0.5538676",
"0.5436451",
"0.5436451"... | 0.7936625 | 0 |
Sets the crfform_definition of this CRFFormVersionDefinition. | def crfform_definition(self, crfform_definition):
self._crfform_definition = crfform_definition | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crfform_section(self, crfform_section):\n\n self._crfform_section = crfform_section",
"def set_definition(self, definition):\n return self.client._perform_json(\n \"PUT\", \"/projects/%s/managedfolders/%s\" % (self.project_key, self.odb_id),\n body=definition)",
... | [
"0.60325944",
"0.5396078",
"0.52793026",
"0.50807613",
"0.50470316",
"0.48321936",
"0.4794672",
"0.4693511",
"0.46618342",
"0.46428707",
"0.4598526",
"0.4571693",
"0.4571693",
"0.45471004",
"0.45332554",
"0.44805634",
"0.4471432",
"0.44370523",
"0.4433725",
"0.44217575",
"0.4... | 0.8260703 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CRFFormVersionDefinition):
return False
return self.to_dict() == other.to_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):
if not isinstance(other, CRFFormVersionDefinition):
return True
return self.to_dict() != other.to_dict() | {
"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.8457179",
"0.8393067",
"0.81457263",
"0.8140635",
"0.8133462",
"0.8094992",
"0.8093376",
"0.8093376",
"0.8093376",
"0.80863357",
"0.80863357",
"0.8077303",
"0.8077303",
"0.8066831",
"0.8043635",
"0.8043635",
"0.8043635",
"0.8043635",
"0.8043635",
"0.8043635",
"0.8043635",
... | 0.0 | -1 |
r"""Set name value. set_name(a_name) | def set_name(self, a_name):
self.set_parameter('name', a_name)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n\t\tself.name_ = name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n self.name ... | [
"0.8569143",
"0.8515916",
"0.8515916",
"0.8308349",
"0.8308349",
"0.8308349",
"0.8308349",
"0.8308349",
"0.83010453",
"0.8298855",
"0.82767594",
"0.82369137",
"0.82177955",
"0.8188051",
"0.8167288",
"0.81554353",
"0.81455845",
"0.81455845",
"0.81455845",
"0.81455845",
"0.8143... | 0.8482487 | 3 |
r"""Get corporate type code. get_kind() | def get_kind(self, ):
return self.get_parameter('kind') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTypeCode(self):\n return _libsbml.KineticLaw_getTypeCode(self)",
"def type_code(self):\n return self._TYPE_CODE",
"def kind(self):\n return self.get_data(\"kind\")",
"def GetKind(self):\n\n pass",
"def kind(self):\n return self._kind()",
"def GetKind(self):\r\n\r... | [
"0.65230423",
"0.63927835",
"0.6322483",
"0.63206196",
"0.6252573",
"0.62462974",
"0.62321913",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769",
"0.6215769"... | 0.6059327 | 49 |
r"""Get from date string. get_from() | def get_from(self, ):
return self.get_parameter.get('from') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_date(self):\n return self._from_date",
"def date_from(self):\n return self._date_from",
"def get_logs_from(self, obj):\n year = int(self.context.get('from'))\n return date(year,1,1).strftime('%b %m %Y')",
"def get_date_from_display(self) -> str:\n return _date(\n ... | [
"0.68431437",
"0.65138274",
"0.6487889",
"0.64794564",
"0.63785005",
"0.62202996",
"0.6155776",
"0.60072637",
"0.59808135",
"0.5955479",
"0.58593017",
"0.58461714",
"0.5832065",
"0.58311594",
"0.5802843",
"0.5755538",
"0.5737787",
"0.5686168",
"0.56634486",
"0.5662349",
"0.56... | 0.6053872 | 7 |
r"""Set from date. set_from(a_from) | def set_from(self, a_from):
if isinstance(a_from, (str, )):
self.set_parameter('from', a_from)
if isinstance(a_from, (datetime, )):
self.set_parameter('from', a_from.strftime('%Y-%m-%d'))
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_from(self, date_from):\n\n self._date_from = date_from",
"def from_date(self, value: date):\n self._from_date = value\n self._dao.from_date = value",
"def set_from_date(self, date):\n self.set_value_into_input_field(self.set_from_date_locator, date)",
"def from_date_time(... | [
"0.8139321",
"0.76170224",
"0.7319614",
"0.7301215",
"0.7183753",
"0.66698205",
"0.66698205",
"0.66698205",
"0.66698205",
"0.6603456",
"0.6557615",
"0.64628947",
"0.6409472",
"0.63581455",
"0.6293737",
"0.62464875",
"0.6076584",
"0.6039555",
"0.59446895",
"0.590393",
"0.58994... | 0.78319436 | 1 |
It replaces invalid path characters with '_'. | def test_forming_safe_filename_for_downloading(
only_audio_links: List[Tuple[str, str]],
) -> None:
excepted_link = (
"[2016-08-07] # 370. In Conversation with Rob Ager from Liverpool (PART 1_ Life in Liverpool _ Interest in Film Analysis).mp3", # noqa: E501,B950
"http://traffic.libsyn.com/teac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize(s):\n s = s.replace(\"_\", \"\\\\_\")\n return s",
"def clean_directory_path(path):\n allowed = string.digits + string.ascii_letters + string.whitespace\n stripped = \"\".join(c for c in path if c in allowed)\n return stripped.replace(\" \", \"_\")",
"def __clean_path(se... | [
"0.733232",
"0.69560635",
"0.69145614",
"0.6844249",
"0.6757389",
"0.6741014",
"0.6673579",
"0.66638964",
"0.662194",
"0.6592176",
"0.65645576",
"0.65640765",
"0.6560831",
"0.6556912",
"0.65542835",
"0.6546275",
"0.6508134",
"0.6490611",
"0.6447432",
"0.6443403",
"0.6413699",... | 0.0 | -1 |
Returns a dict representation of this transaction. | def to_dict(self) -> dict:
d: dict = {
"id" : self.id,
"time" : self.time,
"action" : str(self.action),
"acting_username" : self.acting_username,
"source_account_id" : self.source_account_id,
"destination_account_id" : self.destination_acco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dictionary(self) -> dict:\n return {\n 'transaction_number': self.transaction_number,\n 'date': self.date,\n 'description': self.description,\n 'memo': self.memo,\n 'amount_debit': self.amount_debit,\n 'amount_credit': self.amount_cred... | [
"0.78736866",
"0.78051966",
"0.7689227",
"0.7678179",
"0.75498843",
"0.73736745",
"0.73389757",
"0.73146564",
"0.7312889",
"0.7293001",
"0.728903",
"0.72783834",
"0.7252931",
"0.72368324",
"0.72252965",
"0.72122157",
"0.72030383",
"0.71802247",
"0.71760744",
"0.7174589",
"0.7... | 0.70893884 | 41 |
Initialize naming convention metadata dictionary. | def init_dict_isdcf(rules):
res = {}
for (name, regex) in six.iteritems(rules):
pattern = re.compile(regex)
res[name] = {}
res[name]['Value'] = ''
res[name].update({k: DEFAULT for k in pattern.groupindex.keys()})
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initMetadata(self):\n\n if not 'flags' in self.metadata:\n\n self.metadata['flags'] = {}\n\n if not 'uidvalidity' in self.metadata:\n\n\n self.metadata['uidvalidity'] = random.randint(1000000, 9999999)\n\n if not 'uids' in self.metadata:\n\n self.metadata['... | [
"0.64130086",
"0.62208563",
"0.62096643",
"0.6179654",
"0.6163247",
"0.61547375",
"0.6133167",
"0.6081627",
"0.6081627",
"0.6081093",
"0.6078748",
"0.5997076",
"0.59890246",
"0.58959347",
"0.58934253",
"0.5888377",
"0.58858824",
"0.5862287",
"0.57594454",
"0.569785",
"0.56568... | 0.0 | -1 |
Blends and returns the mix of colors a and b to a given ratio. | def blend_color(a, b, ratio) -> tuple:
return (
int(a[0] + (b[0] - a[0]) * ratio[0]),
int(a[1] + (b[1] - a[1]) * ratio[1]),
int(a[2] + (b[2] - a[2]) * ratio[2])
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blendRGB(r: float, g: float, b: float, a: float):\n return blend(r, a), blend(g, a), blend(b, a)",
"def blend(c: float, a: float) -> float:\n return 255 + (c - 255) * a",
"def mergedColors(colorA, colorB, factor = 50):\r\n return QColor(\r\n (colorA.red() * factor) / 100 + (colorB.r... | [
"0.7120672",
"0.6759689",
"0.6491625",
"0.64203906",
"0.6054866",
"0.59757274",
"0.5975633",
"0.59506387",
"0.59246725",
"0.58536816",
"0.58330804",
"0.5804179",
"0.5780853",
"0.56329596",
"0.5611895",
"0.5552205",
"0.5547316",
"0.55166215",
"0.5501568",
"0.5455187",
"0.54457... | 0.80817026 | 0 |
Gets or sets the size of this ui element. | def size(self):
return self._size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n size = self.widget.size()\n return Size(size.width(), size.height())",
"def widget_size(self) -> int:\n return self._widget_size",
"def size(self, size):\n self.width = size\n self.height = size",
"def size(self, size):\n self.width = size\n ... | [
"0.7640616",
"0.7466384",
"0.70769364",
"0.70769364",
"0.68845713",
"0.68807566",
"0.67884153",
"0.67464113",
"0.6715928",
"0.6708685",
"0.6700338",
"0.6700338",
"0.6700338",
"0.6700338",
"0.6700338",
"0.6700338",
"0.6700338",
"0.6649823",
"0.66477734",
"0.6613003",
"0.659336... | 0.59948164 | 90 |
Returns whether the given point is inside this object's bounds. | def contains_point(self, point) -> bool:
return (self.pos.x <= point[0] <= self.pos.x + self.size.x and
self.pos.y <= point[1] <= self.pos.y + self.size.y and
self.visible) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_point_in(self, point):\n return (self.upperleft[0] <= point[0] <= self.upperright[0] and self.upperleft[1] <= point[1] <= self.bottomleft[1])",
"def is_point_in(self, point):\n return (self.upperleft[0] <= point[0] <= self.upperright[0] and self.upperleft[1] <= point[1] <= self.bottomleft[1]... | [
"0.8350796",
"0.8350796",
"0.80161273",
"0.7976139",
"0.7892219",
"0.7880858",
"0.77485305",
"0.7708187",
"0.76460385",
"0.7617787",
"0.7617787",
"0.7617087",
"0.75996995",
"0.7569709",
"0.75574064",
"0.74278456",
"0.73788685",
"0.73784995",
"0.73753387",
"0.73647976",
"0.736... | 0.79955786 | 3 |
Returns a point relative to this object's position. | def inner_point(self, point) -> Vec:
return self.pos - point | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPoint(self):\n return Point(*self.position)",
"def position(self) -> Point:\n return self._position",
"def position(self):\n return pm.datatypes.Point(self.transform.getTranslation(ws=True))",
"def pos_as_point(self) -> Point:\n return Point(self.x, self.y, 0)",
"def poin... | [
"0.82574695",
"0.79902536",
"0.79830074",
"0.79675126",
"0.7757363",
"0.76782936",
"0.766551",
"0.7665075",
"0.76628727",
"0.76628727",
"0.76373196",
"0.75596786",
"0.74059564",
"0.73745483",
"0.73284036",
"0.73284036",
"0.73284036",
"0.72219807",
"0.7208341",
"0.7208341",
"0... | 0.0 | -1 |
Gets a foreign customer profile | def get_foreign(request):
if 'auth_id' in request.session:
if have_permission(request.session['auth_id'],'get_foreign_customer'):
if validate_parameter(request.GET,'customer_id'):
try:
customer=U_Customers.objects.get(id=request.GET['customer_id'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_profile(self):\n self.cim.get_profile(customer_profile_id=u\"123\")",
"def get_user_profile(self):\n return self.user.profile",
"def get_profile(self):\n endpoint = '/profile'\n return self.get_request(endpoint)",
"def test_get_payment_profile(self):\n self.cim... | [
"0.7050542",
"0.68770677",
"0.6715479",
"0.6616957",
"0.6581938",
"0.64869475",
"0.64433634",
"0.64433634",
"0.64131904",
"0.63596505",
"0.6346218",
"0.63085806",
"0.6270444",
"0.6240135",
"0.62346184",
"0.6211831",
"0.617272",
"0.61600995",
"0.61243933",
"0.61243206",
"0.610... | 0.65116686 | 5 |
Returns the config object | def config(self):
return self.__config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self):\n return self.config",
"def config():\n return _config",
"def _get_config(self):\n return self.__config",
"def _get_config(self):\n return self.__config",
"def _get_config(self):\n return self.__config",
"def _get_config(self):\n return self.__config",
"def _... | [
"0.87593985",
"0.875581",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"0.8713858",
"... | 0.84968376 | 74 |
Creates learning rate schedule. | def create_learning_rate_scheduler(
base_learning_rate=0.5,
factors='constant * linear_warmup * rsqrt_normalized_decay',
warmup_steps=16000,
decay_factor=0.5,
steps_per_decay=50000,
steps_per_cycle=100000):
factors = [n.strip() for n in factors.split('*')]
def step_fn(step):
"""Step to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_learning_rate_scheduler(learning_rate_config, optimizer, last_step=-1):\n lr_scheduler = None\n learning_rate_type = learning_rate_config.name \n if learning_rate_type == 'constant_learning_rate': \n\n lr_scheduler = learning_schedules.Constant(\n optimizer, last_step=last_s... | [
"0.75394535",
"0.72169983",
"0.7196019",
"0.71728224",
"0.6942991",
"0.69275546",
"0.68732065",
"0.67905575",
"0.6778541",
"0.67552286",
"0.66922337",
"0.6675229",
"0.65987456",
"0.65660095",
"0.65652746",
"0.652655",
"0.6495955",
"0.64869964",
"0.6473915",
"0.6465034",
"0.64... | 0.69888896 | 4 |
Instantiate a Instrument APIRequest instance. | def __init__(self, instrument):
endpoint = self.ENDPOINT.format(instrument=instrument)
super(Instruments, self).__init__(endpoint, method=self.METHOD) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, request: object) -> None:\n super().__init__({}, request, URL, Api)",
"def __init__(self, apiToken=None):\r\n self.requestHelper = RequestHelper(apiToken)",
"def make_request(self, environ, **kwargs):\n factory = self.get(abcs.ARequest)\n request = factory(environ... | [
"0.62519884",
"0.618548",
"0.61129016",
"0.6030523",
"0.60113645",
"0.5954836",
"0.592995",
"0.5853038",
"0.5831772",
"0.5667733",
"0.5665988",
"0.565157",
"0.56363577",
"0.5631862",
"0.5514852",
"0.5507112",
"0.5504826",
"0.55039144",
"0.55016845",
"0.5498841",
"0.54892963",... | 0.6558593 | 0 |
Returns if the word is in the trie. | def search(self, word: str, current_node=None) -> bool:
if current_node == None:
current_node = self.root
for ch in word:
found_in_child = False
for node in current_node.children:
if node.char == ch:
found_in_child = True
current_node = node
if found_in_child == False: # some char not foun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_trie(self, trie, word):\n current_dict = trie\n for letter in word:\n if letter in current_dict:\n current_dict = current_dict[letter]\n else:\n return False\n else:\n if '_end_' in current_dict:\n return curr... | [
"0.838632",
"0.8150416",
"0.8123471",
"0.7856802",
"0.7830664",
"0.77935004",
"0.7792806",
"0.77642965",
"0.7753436",
"0.7747724",
"0.7711298",
"0.76816714",
"0.7677101",
"0.7664614",
"0.76506114",
"0.76338875",
"0.7628353",
"0.76114196",
"0.7577657",
"0.75695884",
"0.756079"... | 0.6896929 | 68 |
Generic ensemble definition. Holds the definition of how the various ensemble members have been configured. If ensemble axes are not present, then this is either a single member ensemble, or part of an uber ensemble. | def ensemble():
return {
"type": "class",
"base": "activity.activity",
"is_abstract": False,
"properties": [
(
"common_conformances",
"linked_to(activity.conformance)",
"0.N",
"Conformance documents for requi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uber_ensemble():\n return {\n \"type\": \"class\",\n \"base\": \"activity.ensemble\",\n \"is_abstract\": False,\n \"properties\": [\n (\n \"child_ensembles\",\n \"linked_to(activity.ensemble)\",\n \"1.N\",\n \... | [
"0.68887866",
"0.68200344",
"0.6382834",
"0.61258876",
"0.61033964",
"0.54149425",
"0.52888864",
"0.5224009",
"0.52050525",
"0.5165498",
"0.51042753",
"0.50901055",
"0.5047963",
"0.50006497",
"0.4967463",
"0.49074265",
"0.48928076",
"0.48904878",
"0.48744014",
"0.4857698",
"0... | 0.6174844 | 3 |
Closes the database session after each request. | def teardown_db(exception):
storage.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_db_session(self, session):\r\n session.close()",
"def after_request():\n db.close()",
"def close(self):\n if self.authenticated:\n self.db.logout()\n if self.connection is not None:\n self.connection.close()",
"def teardown_request(exception):\n if d... | [
"0.8110407",
"0.7753594",
"0.77217776",
"0.75928366",
"0.7384172",
"0.7376199",
"0.7353973",
"0.73509383",
"0.73196524",
"0.7307376",
"0.7307376",
"0.7307376",
"0.7307376",
"0.7307376",
"0.7307376",
"0.7287967",
"0.72746843",
"0.7270765",
"0.72533697",
"0.72533697",
"0.725336... | 0.0 | -1 |
Flask route at /hbnb. Fills the hbnb homepage. | def hbnb():
states = storage.all(State).values()
amenities = storage.all(Amenity).values()
places = storage.all(Place).values()
values = {"states": states, "amenities": amenities, "places": places}
return render_template('100-hbnb.html', **values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n return \"Hello HBNB!\"",
"def index():\n response.view_title = myconf.get('app.name') + ' Home Page'\n return dict(message='')",
"def hello_hbnb():\n return render_template('contact_us.html')",
"def home():\n payload = manager.get_payload()\n return render_template('index.htm... | [
"0.7443706",
"0.65811014",
"0.653675",
"0.6414784",
"0.64034665",
"0.63931346",
"0.6357144",
"0.6350925",
"0.6347675",
"0.63474023",
"0.63466084",
"0.6293009",
"0.6293009",
"0.6293009",
"0.6293009",
"0.62878007",
"0.6281002",
"0.62774676",
"0.6277451",
"0.6273539",
"0.6264542... | 0.62095356 | 30 |
Close the connection to the client | def exit(s_socket):
s_socket.send("") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closeConnecetion(self):\n client.close()",
"def close(self):\n if self.client:\n self.client.connection.close()\n self.client = None",
"def close_connection(self):\n\n self._connection.close()\n print(\"Closed connection....\")",
"def close(self):\n self._... | [
"0.8556496",
"0.8017401",
"0.79838955",
"0.7878359",
"0.78700894",
"0.78143275",
"0.780632",
"0.7721317",
"0.7716643",
"0.7702889",
"0.7689852",
"0.76838577",
"0.7680433",
"0.767855",
"0.767855",
"0.7653283",
"0.76456803",
"0.7641712",
"0.763834",
"0.7631331",
"0.762738",
"... | 0.0 | -1 |
Prepare testcases to file to GitHub. | def setUp(self):
data_types.Job(
name='job1', environment_string=JOB1_ENVIRONMENT,
platform='linux').put()
data_types.Job(
name='job2', environment_string=JOB2_ENVIRONMENT,
platform='linux').put()
data_types.Job(
name='job3', environment_string=JOB3_ENVIRONMENT,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n\n commits = read_file('data/test_commits_data.json')\n self.file_gitignore = commits[0]['data']['files'][0]['file']\n self.file_tests = commits[1]['data']['files'][0]['file']\n self.file_bin = commits[2]['data']['files'][0]['file']\n self.file_perceval = commit... | [
"0.61864394",
"0.61726856",
"0.608342",
"0.60582453",
"0.6044834",
"0.5958922",
"0.5950008",
"0.5881939",
"0.5879537",
"0.582777",
"0.5822135",
"0.5820904",
"0.57985574",
"0.57620823",
"0.57447135",
"0.5738524",
"0.5722813",
"0.56806725",
"0.5562002",
"0.5559432",
"0.555083",... | 0.0 | -1 |
Finds the last index of target in range [start...end] of array. Returns 1 if the target does not exist. The array is expected to be sorted in ascending order and array[start] must be the target for the search to continue. | def lastIndexOf(self, array, target, start, end):
assert start <= end
if array[start] != target:
return -1
elif start == end:
return start
i = start
step = 1
# Use modified binary search to find last occurence of target by
# doubling ste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Find_the_last_index(A, target):\n if len(A) == 0:\n return -1\n begin = 0\n end = len(A) - 1\n while end - begin > 1:\n mid = begin + (end - begin >> 1)\n if target < A[mid]:\n end = mid\n else:\n begin = mid\n if A[end] == target:\n retur... | [
"0.80567485",
"0.71689624",
"0.6913417",
"0.6623299",
"0.6570341",
"0.64649713",
"0.6422092",
"0.63417625",
"0.63254774",
"0.62947655",
"0.6283792",
"0.62499857",
"0.61796397",
"0.61163145",
"0.6071977",
"0.60114175",
"0.5996615",
"0.5989589",
"0.59874",
"0.598022",
"0.597953... | 0.8805539 | 0 |
Writes the registry data list as JSON to the registry file. If no file exists, it will create it and write the data. If a file does exist it will _overwrite_ everything in it. | def __write(self, registry_data: list) -> None:
with open(self.__registry_filepath, 'w+') as registry_file:
registry_file.seek(0)
registry_file.write(json.dumps(registry_data))
registry_file.truncate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write(self, filename, data):\n fullpath = os.path.join(self._tempdir, filename)\n with open(fullpath, 'w') as ofile:\n json.dump(data, ofile)\n return fullpath",
"def write(self):\r\n\r\n with open(self.filename + \".json\", mode='w') as json_file:\r\n json.... | [
"0.72926843",
"0.72908664",
"0.72129583",
"0.7112491",
"0.7098719",
"0.7098381",
"0.70974225",
"0.7074355",
"0.7041869",
"0.7007847",
"0.70033914",
"0.6974814",
"0.69621146",
"0.69562525",
"0.6945239",
"0.6924812",
"0.691038",
"0.69083595",
"0.6883529",
"0.6883108",
"0.685926... | 0.8752029 | 0 |
naive convolutin block x > Conv >BN > Act(optional) | def conv_bn_relu(x, n_filter, kernel_size, name,
activation='relu',
strides=(1, 1),
padding='valid',
use_bias=False):
x = layers.Conv2D(n_filter, kernel_size,
strides=strides, padding=padding,
use_bias=False, name=nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __conv_block(self, x, stage, branch, nb_filter, dropout_rate=None, weight_decay=1e-4):\n\t\teps = 1.1e-5\n\t\tconv_name_base = \"conv\" + str(stage) + \"_\" + str(branch)\n\t\trelu_name_base = \"relu\" + str(stage) + \"_\" + str(branch)\n\n\t\t# 1x1 Convolution (Bottleneck layer)\n\t\tinter_channel = nb_filter... | [
"0.67993236",
"0.64874715",
"0.6468905",
"0.64254665",
"0.6418756",
"0.6415391",
"0.64072233",
"0.63949114",
"0.6394221",
"0.63481796",
"0.6299756",
"0.62905574",
"0.6257234",
"0.6252879",
"0.62494946",
"0.6225351",
"0.6212016",
"0.6210956",
"0.62095684",
"0.62095684",
"0.619... | 0.0 | -1 |
>>> has_sum(1, 3, 5) False >>> has_sum(5, 3, 5) 0 3 + 1 5 = 5 True >>> has_sum(11, 3, 5) 2 3 + 1 5 = 11 True | def has_sum(total, n, m):
if total == 0 or total == m or total == n:
return True
elif total < min(m, n):
return False
return has_sum(total - n, n, m) or has_sum(total - m, n, m) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_sum(total, n, m):\n if total == 0:\n return True\n elif total < 0:\n return False\n\n # keep decrementing.\n # if decrement goes evenly to 0 then we printed the exact total\n # otherwise, if it decremented into a negative, then we couldn't\n # print exactly the total\n ... | [
"0.73996997",
"0.72505707",
"0.72060585",
"0.7054769",
"0.6835003",
"0.667639",
"0.66517866",
"0.6649329",
"0.6528426",
"0.64655095",
"0.64299965",
"0.63933283",
"0.62944436",
"0.62805355",
"0.6252163",
"0.62056357",
"0.6195934",
"0.61775064",
"0.6144016",
"0.61057925",
"0.60... | 0.79310393 | 0 |
Returns a random labelling of dataset X. Labels are onehot encoded, with `n_classes` dimensions. Accepts an optional vector of probabilities with which to generate each class. | def gen_random_labels(
X: Union[np.ndarray, int], n_classes: int, pvec=None
) -> np.ndarray:
if isinstance(X, int):
num = X
else:
num = X.shape[0]
pvec = np.ones((n_classes,)) / n_classes
return npr.multinomial(1, pvec, size=num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_labels(size, num_classes):\n return torch.randint(high=num_classes, size=(size,)).int().tolist()",
"def assign_random_labels(dataset: pd.DataFrame, n_classes: int) -> pd.DataFrame:\n labels = np.zeros(shape=(len(dataset), n_classes))\n labels = pd.DataFrame(labels, columns=[\"l{}\".format(i) ... | [
"0.7470616",
"0.73707783",
"0.6751283",
"0.6430415",
"0.64262587",
"0.6365577",
"0.6353296",
"0.62740046",
"0.62676835",
"0.62381643",
"0.6162187",
"0.6147701",
"0.6130475",
"0.61002535",
"0.6090491",
"0.6067109",
"0.60456425",
"0.60274017",
"0.60211873",
"0.60198796",
"0.601... | 0.8355455 | 0 |
Creates training and validation generators from a list of data dictionaries. First, a sequence of index arrays is created by the splitter object passed to this function. Then, each collection of inputs is partitioned according to these indices. Finally, partition is then passed to `generate_batches`. | def get_train_test_gens(
*data_dicts: DataDict, splitter=ShuffleSplit, splitter_opts, **genbatchopts
):
if isinstance(splitter, type):
splitter = splitter(**splitter_opts)
else:
if splitter_opts:
warn(
"Passed splitter_opts, but splitter is an existing object."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_batches(data_dir='/home/yunhan/batchified'):\n # todo: read in data that is preoprocessed\n # Use batch 1 - 52 as train (60%), 53 - 71 as validation (20%), 72 - 89 as test (20%)\n n = 53\n idx = np.random.permutation(n)\n idx = idx + 1\n for i in range(n):\n X = np.load(\"%s/... | [
"0.6494636",
"0.64906085",
"0.63408995",
"0.6321649",
"0.6302864",
"0.62394917",
"0.61890024",
"0.6168876",
"0.6103972",
"0.6089523",
"0.60696757",
"0.603098",
"0.60144496",
"0.60026485",
"0.598839",
"0.5975193",
"0.5967939",
"0.5953764",
"0.592868",
"0.5901473",
"0.5893335",... | 0.74102646 | 0 |
GET a list of Pages. | def get(self, request):
cards = self.get_queryset().all()
user = None
auth = request.user.is_authenticated
if auth:
user = request.user
return render(request, 'index/index.html', {
'cards': cards,
'user': user
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_pages(request):\n context = RequestContext(request)\n pages = request.website.get_pages()\n return render_to_response(\"pages/list_pages.html\", {\"pages\": pages}, context)",
"def list(self, request ):\n\t\tinUrl = request.query_params.get('url', None )\n\t\t#if inUrl is None:\n\t\t#\tinUrl = ... | [
"0.77786064",
"0.7577209",
"0.75349367",
"0.75349367",
"0.7013189",
"0.6987679",
"0.69482005",
"0.6886229",
"0.6827389",
"0.67998",
"0.67509806",
"0.6702824",
"0.6658481",
"0.66021645",
"0.65862703",
"0.65639615",
"0.6552138",
"0.65515673",
"0.64796925",
"0.64738864",
"0.6440... | 0.0 | -1 |
Closes the connection to the MySQL server | def close(self):
self._port.close()
return not self._port.is_connected() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self): \n self.connection.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n with self.connlock:\n self.conn.do_close()",
"def close(self):\n s... | [
"0.74431974",
"0.73402244",
"0.73402244",
"0.73402244",
"0.7288594",
"0.72864735",
"0.72703564",
"0.7264367",
"0.7245314",
"0.72239107",
"0.7187023",
"0.71585834",
"0.7153128",
"0.7141593",
"0.71359646",
"0.71348315",
"0.7125556",
"0.71217865",
"0.71217865",
"0.71090794",
"0.... | 0.0 | -1 |
ID of the household the pet belongs to. | def serial(self) -> str | None:
return str(serial) if (serial := self._data.get("serial_number")) else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def party_id(self):\n pass",
"def id(self):\n\t\treturn self.__id",
"def id(self) -> int:\n return pulumi.get(self, \"id\")",
"def id(self):\n return self.__id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n re... | [
"0.61588115",
"0.5994927",
"0.5943666",
"0.58633274",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
... | 0.0 | -1 |
ID of the household the pet belongs to. | def serial(self) -> str | None:
return str(serial) if (serial := self._data.get("serial_number")) else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def party_id(self):\n pass",
"def id(self):\n\t\treturn self.__id",
"def id(self) -> int:\n return pulumi.get(self, \"id\")",
"def id(self):\n return self.__id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n re... | [
"0.61588115",
"0.5994927",
"0.5943666",
"0.58633274",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
"0.5850688",
... | 0.0 | -1 |
Returns the Chesbyshev distance of two positions. | def chesbyshev_distance(pos1, pos2):
# Compute x distance
df = abs(pos1.file - pos2.file)
# Compute y distance
dr = abs(pos1.rank - pos2.rank)
# Return the max of the two distances
return max(df, dr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chebyshev_distance(self, other_point):\n return max(abs(self.x - other_point.x), abs(self.y - other_point.y))",
"def distance(pos1, pos2):\n return math.sqrt((pos1[0] - pos2[0])**2. + (pos1[1] - pos2[1])**2.)",
"def _get_distance(a, b):\n return np.sqrt(np.sum((a - b) ** 2))",
"def getDi... | [
"0.7101574",
"0.664793",
"0.6596685",
"0.65652704",
"0.6561872",
"0.6532768",
"0.6521855",
"0.65190625",
"0.65098405",
"0.6508454",
"0.6491273",
"0.64797467",
"0.647319",
"0.6458782",
"0.645429",
"0.64466983",
"0.6437884",
"0.6437603",
"0.6431035",
"0.6414441",
"0.6408617",
... | 0.80131435 | 0 |
Returns True if the frame needs to be removed. | def should_remove_frame(row, dim):
assert len(row) % dim == 0
num_sources = len(row) // dim
max_idx = np.argmax(row)
max_val = row[max_idx]
if max_val < 0.5:
# All the values < 0.5. So we are not confident of any sources.
# Remove frame.
return True
best_source = max_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasPrevFrame(self):\n self.deleteDouble()\n return (len(self.activeFrames) > 1)",
"def hasCurrentFrame(self):\n if self.currentFrame == []:\n return False\n return True",
"def frame_available(self):\n return type(self._frame) != type(None)",
"def remove(self, *args, **kwar... | [
"0.7636534",
"0.6745482",
"0.6654321",
"0.6209038",
"0.61234015",
"0.611291",
"0.61010736",
"0.60607296",
"0.60210156",
"0.5980647",
"0.59539366",
"0.59006196",
"0.58905536",
"0.5847655",
"0.5846482",
"0.5769067",
"0.57658845",
"0.57463336",
"0.5727776",
"0.56946224",
"0.5688... | 0.51881397 | 94 |
This function returns the maximum gas water ratio value. The calculation procedure is based taken from Batzle and Wang. Geophys., 57, 1396 1408. 1992. | def fMaxGasWaterRatio(Salinity, Temperature, Pressure):
Temp = Temperature # Deg C
Press = Pressure / 145.038 # MPa
Sal = Salinity
A = log(0.712 * Press * ((abs(Temp - 76.71)) ** 1.5) + 3676 * (Press ** 0.64)) / log(10)
B = -4 - 7.786 * Sal * (Temp + 17.78) ** -0.306
C = A + B
return 10**C | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fMaxGasOilRatio(APIGravity, GasGravity, Temperature, Pressure):\n\tT = Temperature\n\tP = Pressure / 145.0378 # Converts Pressure from Psia to MPa\n\tRho_0 = (141.5 / (APIGravity + 131.5))\n\tA = P * (exp((4.072 / Rho_0) - (0.00377 * T)))\n\treturn (0.02123 * GasGravity) * (A**1.205)*(158.9873/28.3168) # conve... | [
"0.72345364",
"0.69936377",
"0.6840945",
"0.67915386",
"0.6755207",
"0.65231794",
"0.65025747",
"0.6476447",
"0.64319766",
"0.63280815",
"0.6311207",
"0.63073677",
"0.6305463",
"0.6294888",
"0.62921715",
"0.6269704",
"0.6268538",
"0.6229448",
"0.6226062",
"0.62142235",
"0.619... | 0.8012301 | 0 |
Equivalent to min(max(Val, MinVal), MaxVal) | def ImposeLimits(Val, MinVal, MaxVal):
if MinVal < Val < MaxVal:
return Val
elif Val <= MinVal:
return MinVal
elif Val >= MaxVal:
return MaxVal | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_max(xs):\n return min(xs), max(xs)",
"def minmax(xs):\n min_val = None\n max_val = None\n for x in xs:\n if min_val is None or x < min_val:\n min_val = x\n if max_val is None or x > max_val:\n max_val = x\n return (min_val, max_val)",
"def min_max(item... | [
"0.78577626",
"0.75640285",
"0.75189954",
"0.7516748",
"0.747474",
"0.73972976",
"0.72080576",
"0.72049356",
"0.7203241",
"0.71636367",
"0.7142133",
"0.712638",
"0.7074734",
"0.7067484",
"0.7048933",
"0.7002988",
"0.69800454",
"0.69700646",
"0.69457245",
"0.69268167",
"0.6896... | 0.71841383 | 9 |
Check C{rect} for validity. Raises L{ValueError} if C{rect}'s computed width or height is zero or negative, or if rect contains nonsense. | def checkRect(rect):
try:
left, top, right, bottom = rect
except ValueError:
raise ValueError("%r is not a valid rect; must contain 4 ints" % (rect,))
if not all(isinstance(x, int) for x in rect):
raise ValueError("%r is not a valid rect; must contain 4 ints" % (rect,))
width = right - left
height = bottom -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isRectValid(self, rect):\n for x in range(rect.width):\n for y in range(rect.height):\n if not self.isPositionValid(x + rect.x, y + rect.y):\n return False\n return True",
"def check_box_vaild(self, width, height):\n return (self.box.box_valid... | [
"0.76824355",
"0.6987906",
"0.6865288",
"0.66369855",
"0.63904655",
"0.6256182",
"0.62366515",
"0.62285805",
"0.6166643",
"0.6078785",
"0.60683686",
"0.60642904",
"0.6011083",
"0.5968906",
"0.59577346",
"0.59573555",
"0.59501296",
"0.5934377",
"0.59258974",
"0.5925033",
"0.59... | 0.8148642 | 0 |
Returns a tuple containing ( the xcoordinate of the upperleft corner of the virtual screen, the ycoordinate of the upperleft corner of the virtual screen, the xcoordinate of the lowerright corner of the virtual screen, the ycoordinate of the lowerright corner of the virtual screen ) Note that both x and y coordinates m... | def getVirtualScreenRect():
# Note that one iteration of the loop takes about 2us on a Q6600.
tries = 150
lastRect = None
for _ in range(tries):
# Get dimensions of the entire virtual screen. Note that left/top may be negative.
# Any of these may return nonsense numbers during display configuration
# changes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewed_rect(self):\n\t\tif self._has_local_coords:\n\t\t\twidth, height = self.size\n\t\t\treturn (0, 0, width, height)\n\t\telse:\n\t\t\treturn self.bounds",
"def absolute_position(corner: str):\n screen = ui.main_screen().rect\n if corner == Corner.TOP_LEFT:\n return (0, 0)\n ... | [
"0.7114365",
"0.65904075",
"0.6516171",
"0.64951354",
"0.6402965",
"0.6399879",
"0.6363822",
"0.63584113",
"0.63426554",
"0.63265115",
"0.6311401",
"0.62511843",
"0.6242595",
"0.6238831",
"0.62333494",
"0.62211215",
"0.62155867",
"0.62127966",
"0.6172472",
"0.61374897",
"0.61... | 0.75729513 | 0 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
cities = ('chicago', 'new york', 'washington')
while True:
city = input("Which city would you like to look at?... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.6670663",
"0.65355295",
"0.6460245",
"0.6373799",
"0.6348607",
"0.6310135",
"0.62867314",
"0.625986",
"0.6231188",
"0.62122154",
"0.62052953",
"0.6181617",
"0.61711454",
"0.6169287",
"0.6158972",
"0.6158044",
"0.6153508",
"0.614449",
"0.61302817",
"0.610529",
"0.6102876",
... | 0.5759578 | 77 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
#create the DataFrame
#I'll be honest, I was struggling with this bit of code so I searched the internet and found what I needed to get started.
df = pd.read_csv(CITY_DATA[city])
# convert the Start Time column to datetime
df['Start Time'] = pd.to_datetime(df['Start... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.7889219",
"0.7882541... | 0.79463065 | 14 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# display the most common month
most_common_month = df.groupby('Start Time')['month'].mean()
print('Here is the most common month of travel: ', most_common_month)
# display the most comm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.7496658 | 29 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.