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 |
|---|---|---|---|---|---|---|
Check if valid add_book response | def validBookObject(bookObject):
return ("name" in bookObject and
"price" in bookObject and
"isbn" in bookObject) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_books(self):\n response = self.client.post(\n '/api/v1/books', data=json.dumps(add_book), content_type='application/json',\n headers=self.get_admin_token())\n result = json.loads(response.data.decode())\n self.assertEqual(result['message'], 'Book awarded succ... | [
"0.7324188",
"0.71444285",
"0.6754424",
"0.6736015",
"0.6707971",
"0.65491146",
"0.64058864",
"0.6374645",
"0.63528895",
"0.62992406",
"0.6231329",
"0.61846805",
"0.6130675",
"0.61279374",
"0.61115086",
"0.6074249",
"0.60553634",
"0.59958106",
"0.59835815",
"0.5963882",
"0.59... | 0.5959604 | 20 |
Retrieves a specific State | def get_users(user_id):
instance = storage.get(User, user_id)
if not instance:
abort(404)
return jsonify(instance.to_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(state_id):\n state = storage.get(\"State\", state_id)\n if state:\n return jsonify(state.to_dict())\n abort(404)",
"def get_state(state_id):\n try:\n state = jsonify(storage.get(State, state_id).to_dict())\n return state\n except:\n abort(404)",
"def get... | [
"0.7712307",
"0.7697305",
"0.75829816",
"0.75710946",
"0.7479273",
"0.7385776",
"0.7367735",
"0.73124015",
"0.7242776",
"0.7230957",
"0.7230957",
"0.7226292",
"0.7187894",
"0.7184518",
"0.71566695",
"0.70179963",
"0.70118475",
"0.70118475",
"0.698592",
"0.69692653",
"0.696791... | 0.0 | -1 |
Get the command args to run this step. If skip_serialized_namedtuple is True, then get_command_env should be used to pass the args to Click using an env var. | def get_command_args(self, skip_serialized_namedtuple: bool = False) -> Sequence[str]:
return (
_get_entry_point(self.job_origin)
+ ["api", "execute_step"]
+ (
["--compressed-input-json", self._get_compressed_args()]
if not skip_serialized_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_command_env(self) -> Sequence[Mapping[str, str]]:\n return [\n {\"name\": \"DAGSTER_COMPRESSED_EXECUTE_STEP_ARGS\", \"value\": self._get_compressed_args()},\n ]",
"def get_unparsed_args():\n # Threads are set to 1 so that running tests doesn't completely drain\n # computing... | [
"0.6210668",
"0.6135422",
"0.61330277",
"0.60214496",
"0.6014586",
"0.59911364",
"0.59727347",
"0.5931152",
"0.5925983",
"0.5814533",
"0.56944984",
"0.5693068",
"0.5686931",
"0.56763566",
"0.5610325",
"0.5578867",
"0.5564705",
"0.5560622",
"0.5509382",
"0.5509382",
"0.5486576... | 0.76721996 | 0 |
Get the env vars for overriding the Click args of this step. Used in conjuction with get_command_args(skip_serialized_namedtuple=True). | def get_command_env(self) -> Sequence[Mapping[str, str]]:
return [
{"name": "DAGSTER_COMPRESSED_EXECUTE_STEP_ARGS", "value": self._get_compressed_args()},
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def env_vars(self):\n return _untag_env_vars(self._tagged_env_vars, build=False)",
"def build_env_vars(self):\n return _untag_env_vars(self._tagged_env_vars, build=True)",
"def _generate_environment(self):\n envvars = {}\n for key in self.envvars:\n try:\n ... | [
"0.689278",
"0.6753468",
"0.67225736",
"0.6722288",
"0.6669228",
"0.66501456",
"0.65956956",
"0.6542301",
"0.65310127",
"0.6529589",
"0.6508932",
"0.6465983",
"0.6465983",
"0.6465983",
"0.6465983",
"0.64303946",
"0.63602084",
"0.6296463",
"0.6256607",
"0.6251316",
"0.6251316"... | 0.66326296 | 6 |
Check if an instance profile exists. | def exists(profile, name):
result = fetch_by_name(profile, name)
return len(result) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance_profile_exists(self) -> None:\n self.assertTrue(self.validate_instance_profile('s3-access-role', is_prod=self.prod_env))",
"def profile_exists(profile):\n if os.path.isfile(AWS_CREDENTIALS_FILE):\n boto.config.load_credential_file(AWS_CREDENTIALS_FILE)\n if boto.config.g... | [
"0.8154871",
"0.7510733",
"0.66523707",
"0.6491631",
"0.6476768",
"0.6417421",
"0.63992935",
"0.6298554",
"0.62861156",
"0.6164219",
"0.6151578",
"0.6124031",
"0.6035546",
"0.60092634",
"0.60092336",
"0.60053897",
"0.5968085",
"0.5876538",
"0.58478",
"0.5842592",
"0.57657355"... | 0.7405177 | 3 |
Create an instance profile. | def create(profile, name):
# Make sure it doesn't exist already.
if exists(profile, name):
msg = "Instance profile '" + str(name) + "' already exists."
raise ResourceAlreadyExists(msg)
# Now we can create it.
params = {}
params["profile"] = profile
params["name"] = name
resp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(profile, name):\n client = boto3client.get(\"iam\", profile)\n params = {}\n params[\"InstanceProfileName\"] = name\n return client.create_instance_profile(**params)",
"def create_profile(sender, **kw):\n user = kw['instance']\n if kw['created']:\n profile = UserProfile(user=u... | [
"0.7980981",
"0.73846895",
"0.73759806",
"0.7278604",
"0.71552795",
"0.71538186",
"0.71216303",
"0.71066165",
"0.706962",
"0.70648557",
"0.6899764",
"0.6899764",
"0.6899764",
"0.6889016",
"0.6884204",
"0.684115",
"0.6837916",
"0.6823874",
"0.6795658",
"0.6794917",
"0.6757974"... | 0.7846144 | 1 |
Check if an IAM role is attached to an instance profile. | def is_attached(profile, instance_profile, role):
# Make sure the instance profile exists.
instance_profile_data = fetch_by_name(profile, instance_profile)
if not instance_profile_data:
msg = "No instance profile '" + str(instance_profile) + "'."
raise ResourceDoesNotExist(msg)
# Make s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_detached(profile, instance_profile, role):\n # Make sure the instance profile exists.\n instance_profile_data = fetch_by_name(profile, instance_profile)\n if not instance_profile_data:\n msg = \"No instance profile '\" + str(instance_profile) + \"'.\"\n raise ResourceDoesNotExist(msg)... | [
"0.7088546",
"0.6954864",
"0.6926873",
"0.67344093",
"0.632607",
"0.6269203",
"0.62026495",
"0.6070061",
"0.60275495",
"0.59771913",
"0.5725403",
"0.57020354",
"0.5701487",
"0.56407905",
"0.5587612",
"0.55163646",
"0.55126065",
"0.5507493",
"0.5485463",
"0.54719484",
"0.54596... | 0.8047882 | 0 |
Visualises the layers into matplotlib images | def predict_visualize_layers(self, X):
if isinstance(X, np.ndarray):
X = np.reshape(X, (X.shape[0], X.shape[1], X.shape[2], 1))
elif isinstance(X, tf.data.Dataset):
X = X.map(self._reshape)
for x, y in X:
x = tf.expand_dims(x, 0)
plt.title("Test... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_model(self, ax):\n rs = self.w[1:,:].reshape(28, 28, 10, order='F')\n rs2 = np.transpose(rs, axes=[1,0,2])\n ax.imshow(rs2.reshape(28, -1, order='F'), cmap='bone')",
"def visualize_conv_layers(self, layer_name='conv1', savefig_path=\"\"):\n\n # The name of the layer we w... | [
"0.71518236",
"0.7068693",
"0.7035294",
"0.6981722",
"0.6935098",
"0.6823357",
"0.6802339",
"0.6800211",
"0.6793122",
"0.6783266",
"0.6780422",
"0.67716116",
"0.6752977",
"0.672909",
"0.6727449",
"0.6726443",
"0.6697387",
"0.6638319",
"0.65907335",
"0.6580887",
"0.6580887",
... | 0.67066616 | 16 |
Returns a diagonal or a diagonal array. | def diag(v, k=0):
if isinstance(v, cupy.ndarray):
if v.ndim == 1:
size = v.size + abs(k)
ret = cupy.zeros((size, size), dtype=v.dtype)
ret.diagonal(k)[:] = v
return ret
else:
return v.diagonal(k)
else:
return cupy.array(numpy.di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonal(nd):\n assert nd.ndim == 2, \"diagonal requires 2 dimensional ndarray\"\n shape_min = hl.min(nd.shape[0], nd.shape[1])\n return hl.nd.array(hl.range(hl.int32(shape_min)).map(lambda i: nd[i, i]))",
"def diagonal(a, offset=0, axis1=0, axis2=1):\n # TODO(okuta): check type\n return a.dia... | [
"0.6815963",
"0.6779226",
"0.6757019",
"0.66014105",
"0.65470177",
"0.65308356",
"0.6455631",
"0.6425529",
"0.6404942",
"0.6394657",
"0.6366269",
"0.6340309",
"0.63219327",
"0.6299192",
"0.6271247",
"0.62636733",
"0.626132",
"0.6198233",
"0.61666346",
"0.6134196",
"0.6132334"... | 0.6123252 | 22 |
Creates a diagonal array from the flattened input. | def diagflat(v, k=0):
if isinstance(v, cupy.ndarray):
return cupy.diag(v.ravel(), k)
else:
return cupy.diag(numpy.ndarray(v).ravel(), k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonal(nd):\n assert nd.ndim == 2, \"diagonal requires 2 dimensional ndarray\"\n shape_min = hl.min(nd.shape[0], nd.shape[1])\n return hl.nd.array(hl.range(hl.int32(shape_min)).map(lambda i: nd[i, i]))",
"def diagonal(self):\n M = self.rep\n m, n = self.shape\n return [M[i, i]... | [
"0.7002077",
"0.6953516",
"0.6932767",
"0.6844725",
"0.68130857",
"0.672427",
"0.6572406",
"0.64834136",
"0.64701927",
"0.6462185",
"0.6459648",
"0.6401316",
"0.6344102",
"0.63140404",
"0.6306936",
"0.6284715",
"0.6267831",
"0.6260347",
"0.61699694",
"0.6159974",
"0.6145433",... | 0.6463307 | 9 |
Constructs a radix(2^N) representation of data from charlist, where charlist is of length 2^N. (like base64) | def base_charlist_encode(data, charlist):
if (len(charlist) & (len(charlist) - 1)) != 0:
raise Exception("charlist length is not a power of 2")
bits_per_digit = int(math.floor(math.log(len(charlist), 2)))
cur_bits = 0
cur_index = 0
indices = []
# Note: For Py3k only, bytearray would not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_byte( clist, bytesize):\n assert (len(clist)>=0)\n B = (1<<bytesize) - 1\n n=0\n while 1:\n d = bin_to_dec(clist,bytesize)\n if (d == B):\n return n\n else:\n n = n*B + d\n pass\n pass\n pass",
"def _base64_to_der_keylist(base64... | [
"0.6283157",
"0.60114247",
"0.5999854",
"0.5967389",
"0.59325397",
"0.58388025",
"0.57500297",
"0.57471853",
"0.5655632",
"0.56444794",
"0.5587657",
"0.55712277",
"0.5569921",
"0.5564001",
"0.5543843",
"0.5539689",
"0.55359596",
"0.55316466",
"0.54873633",
"0.54620403",
"0.54... | 0.76633596 | 0 |
takes a node and returns a display string containing its bbox | def displayBBoxInfoForNode(node):
return "%s: %s" % (node.name(), BBoxDimensionString(node.bbox())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox(self, node):\n node_id = node.get('id')\n #inkex.utils.debug(\"Check if \" + str(node_id) + \" is in \" + str(self.node_info))\n info = self.node_info[node_id] \n \n x = info.x\n y = info.y\n width = info.width\n height = info.height\n\n ... | [
"0.7424719",
"0.65300006",
"0.62933594",
"0.60478354",
"0.6046967",
"0.6031258",
"0.60228676",
"0.5945682",
"0.5918483",
"0.5912601",
"0.5868687",
"0.58246267",
"0.5781722",
"0.57788426",
"0.5736045",
"0.5733403",
"0.57300884",
"0.5722795",
"0.56736726",
"0.56667054",
"0.5640... | 0.8292475 | 0 |
Function called when the user presses the blur_button. It performs gaussian blurring on the image. | def blur_slide(self):
std_input = self.horizontal.get() # Get the user STD input
img = self.master.images[-1] # Select the displayed image for transformation
blurred_image = blur.gaussian_blur(img, std_input) # Perform gaussian blurring on the input image
self.master.display_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blur_released(self, event):\r\n if self.winfo_containing(event.x_root, event.y_root) == self.blur_button: # If clicked area has the blur button\r\n if self.image_present_check(): # Check if there is a displayed image else throw an error box\r\n self.horizontal = Scale(self,... | [
"0.7722035",
"0.76690006",
"0.7510682",
"0.75013095",
"0.74837667",
"0.73598856",
"0.7315707",
"0.7294763",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
"0.72899055",
... | 0.7406741 | 5 |
Invoked when the sharpen_button is pressed. Performs unsharp masking on the displayed image using gaussian blur with STD set by the user. The constant multiplied is also determined by the user. | def sharpen_slide(self):
std_input = self.horizontal.get() # Get the std defined by user
c_input = self.vertical.get() # get the constant defined by the user
img = self.master.images[-1] # Use the most recent displayed image for sharpening
sharpened_image = sharpen.gaussian_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sharpening_released(self, event):\r\n if self.winfo_containing(event.x_root, event.y_root) == self.sharpening_button: # If clicked area contains the \r\n # sharpening button\r\n if self.image_present_check(): # Check if image is being displayed, if not throw error box.\r\n ... | [
"0.7014764",
"0.6965435",
"0.67520636",
"0.67291576",
"0.67200476",
"0.66416484",
"0.64673835",
"0.64494747",
"0.62225056",
"0.6155897",
"0.61447334",
"0.61404",
"0.6123072",
"0.5979111",
"0.5931946",
"0.5888824",
"0.58493227",
"0.5829368",
"0.5828138",
"0.5823372",
"0.581278... | 0.67564183 | 2 |
Return the document request record class. | def document_request_record_cls(self):
return self.record_class_by_pid_type(DOCUMENT_REQUEST_PID_TYPE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_record_cls(self):\n return self.record_class_by_pid_type(DOCUMENT_PID_TYPE)",
"def document_request_search_cls(self):\n return self.search_by_pid_type(DOCUMENT_REQUEST_PID_TYPE)",
"def request_class(self):\n raise NotImplementedError()",
"def _class(self):\n try:\n ... | [
"0.7799157",
"0.70509356",
"0.66858846",
"0.60147554",
"0.59282196",
"0.59181327",
"0.5890304",
"0.57738495",
"0.5768338",
"0.5756767",
"0.5719984",
"0.5689928",
"0.56885153",
"0.56840444",
"0.5669853",
"0.56684095",
"0.56683636",
"0.5654152",
"0.56521016",
"0.5650806",
"0.56... | 0.87766784 | 0 |
Return the eitem record class. | def eitem_record_cls(self):
return self.record_class_by_pid_type(EITEM_PID_TYPE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_record_cls(self):\n return self.record_class_by_pid_type(ITEM_PID_TYPE)",
"def record_cls(self):\n return self._ELE_CLS",
"def document_record_cls(self):\n return self.record_class_by_pid_type(DOCUMENT_PID_TYPE)",
"def _get_class(self, item):\n\t\t# it's already a class, return ... | [
"0.8246512",
"0.67597944",
"0.674543",
"0.6591923",
"0.646923",
"0.64527714",
"0.6421278",
"0.6418583",
"0.64165735",
"0.63099736",
"0.62671673",
"0.6129993",
"0.61276144",
"0.61229557",
"0.61126244",
"0.60887665",
"0.60302216",
"0.60233307",
"0.59484863",
"0.59318405",
"0.59... | 0.8748377 | 0 |
Ask user for a valid IPv4 subnet mask in dotted decimal | def enter_subnet_mask():
masks = [255, 254, 252, 248, 240, 224, 192, 128, 0]
#Checking Subnet Mask validity
while True:
try:
major_subnet_mask = input("Enter the current subnet mask: ")
except KeyboardInterrupt:
print('\nGood bye!\n')
sys.exit()
#Checking octets - split major_subnet_mask string i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dotted_netmask(mask):\n mask = int(mask)\n bits = 0xffffffff ^ (1 << 32 - mask) - 1\n return socket.inet_ntoa(struct.pack('>I', bits))",
"def _ask_user_ipv4():\n\n while True:\n answer = input(\"Please enter the IPv4 Address [n.n.n.n/n]: \")\n try:\n ipinp... | [
"0.70959437",
"0.68923104",
"0.6870825",
"0.66647846",
"0.65872353",
"0.63958573",
"0.6395524",
"0.6290091",
"0.6273001",
"0.6236289",
"0.6216331",
"0.6195159",
"0.6131487",
"0.60903776",
"0.607975",
"0.6037063",
"0.60239947",
"0.60215896",
"0.5991053",
"0.5944972",
"0.592508... | 0.7122879 | 0 |
Private method to handle the paste action. | def __editPaste(self):
if QApplication.focusWidget() == e5App().getObject("Shell"):
e5App().getObject("Shell").paste()
else:
self.activeWindow().paste() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_paste(self, expanded, unexpanded) :\n\t\tif expanded :\n\t\t\treturn self.errormessage(\"Doesn't need any argument\")\n\t\tif not self.HasPerms(self.__context, 'View management screens') :\n\t\t\treturn -1\n\t\tif not hasattr(self, '_clipboard') :\n\t\t\treturn self.errormessage(\"Clipboard is empty\")\n\t... | [
"0.70122194",
"0.6758794",
"0.6625979",
"0.6554356",
"0.6468314",
"0.64067304",
"0.6149966",
"0.60509753",
"0.59971136",
"0.5959481",
"0.5845177",
"0.5840773",
"0.58308846",
"0.57955885",
"0.57947767",
"0.57841873",
"0.57615405",
"0.57409805",
"0.57308275",
"0.5724637",
"0.57... | 0.7310397 | 0 |
Private method to open a new view of the current editor in a new split. | def __newDocumentSplitView(self):
aw = self.activeWindow()
if aw:
self.addSplit()
self.newEditorView(aw.getFileName(), aw, aw.getFileType()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __newDocumentView(self):\n aw = self.activeWindow()\n if aw:\n self.newEditorView(aw.getFileName(), aw, aw.getFileType())",
"def __splitView(self):\n self.addSplit()",
"def open_editor(event):\n event.current_buffer.open_in_editor(event.cli)",
"def open_launcher(sel... | [
"0.7121881",
"0.6540798",
"0.6514014",
"0.63474935",
"0.62472415",
"0.6149323",
"0.6010219",
"0.5963351",
"0.59611124",
"0.59055626",
"0.5874557",
"0.5814578",
"0.5792717",
"0.5766427",
"0.5662704",
"0.56464523",
"0.5627508",
"0.55724305",
"0.5561633",
"0.55538857",
"0.553940... | 0.8286171 | 0 |
Private slot to set the automatic spell checking of all editors. | def __setAutoSpellChecking(self):
enabled = self.autoSpellCheckAct.isChecked()
Preferences.setEditor("AutoSpellCheckingEnabled", enabled)
for editor in self.editors:
editor.setAutoSpellChecking() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enableSpellingActions(self):\n from QScintilla.SpellChecker import SpellChecker\n spellingAvailable = SpellChecker.isAvailable()\n \n self.spellCheckAct.setEnabled(\n len(self.editors) != 0 and spellingAvailable)\n self.autoSpellCheckAct.setEnabled(spellingAvaila... | [
"0.7636197",
"0.71462005",
"0.65836585",
"0.5865829",
"0.5843504",
"0.5776261",
"0.5665405",
"0.5537406",
"0.55343485",
"0.5509878",
"0.54583484",
"0.53753674",
"0.53663105",
"0.5298167",
"0.52587396",
"0.5242033",
"0.5233465",
"0.52325606",
"0.5229334",
"0.5192617",
"0.51908... | 0.8417452 | 0 |
Public method to get a list of all actions. actionSetType string denoting the action set to get. It must be one of "edit", "file", "search", "view", "window", "macro", "bookmark" or "spelling". list of all actions (list of E5Action) | def getActions(self, actionSetType):
try:
return self.__actions[actionSetType][:]
except KeyError:
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actions(self):\n return self._action_list",
"def get_list_of_actions(self):\n return self.actions",
"def get_actions(self):\n return []",
"def getActions(self):\n actions = self.actions[:]\n return actions",
"def actions(self):\n r = self.session.query(models.A... | [
"0.7648261",
"0.754506",
"0.7339192",
"0.72533303",
"0.72417945",
"0.7237163",
"0.72027916",
"0.72027916",
"0.7079289",
"0.7059448",
"0.704063",
"0.69953513",
"0.6951467",
"0.6951467",
"0.6951467",
"0.6950716",
"0.6929098",
"0.69041616",
"0.68887097",
"0.68832284",
"0.6839939... | 0.8236746 | 0 |
Calculate the next rectangular position of the object by moving along the current direction. The rectangle is returned together with the delta x and delta y from the topleft of the old position. | def calc_next_pos(self, time_passed):
vx, vy = self.DIR_VECTORS[self.direction]
dx, dy = vx * self.speed * time_passed, vy * self.speed * time_passed
next_pos = self.rect.move(dx, dy)
return next_pos, dx, dy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self, deltaX, deltaY):\n\t\treturn Location(self.x + deltaX, self.y + deltaY)",
"def move(self, deltaX, deltaY):\n return Location(self.x + deltaX, self.y + deltaY)",
"def move_rectangle(old_rec,dx,dy):\n new_rec = Rectangle()\n new_rec.height = old_rec.height\n new_rec.width = old_rec... | [
"0.6548108",
"0.6512436",
"0.6511377",
"0.65025324",
"0.63872814",
"0.6326634",
"0.6320892",
"0.627287",
"0.6198977",
"0.6069119",
"0.60591114",
"0.6053064",
"0.6042055",
"0.60325384",
"0.6026192",
"0.5996216",
"0.59890306",
"0.597638",
"0.5930403",
"0.5928315",
"0.5920207",
... | 0.65715355 | 0 |
Get notification type defined with class name. | def type(cls):
return cls.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notification_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"notification_type\")",
"def notification_type(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"notification_type\")",
"def notification_type(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self,... | [
"0.6816152",
"0.6767083",
"0.67297274",
"0.6410028",
"0.63802385",
"0.6354915",
"0.62539977",
"0.6193046",
"0.6141165",
"0.6061648",
"0.60268986",
"0.60262996",
"0.59612995",
"0.5947072",
"0.5915754",
"0.59023654",
"0.58839464",
"0.5814799",
"0.5795495",
"0.5776086",
"0.57666... | 0.6068346 | 9 |
Initialise weights and biases | def initialise_parameters(self):
# Weights
init = select_w_init(self.w_init)
if self.w_gain:
gain = nn.init.calculate_gain('relu')
init(self.relations, gain=gain)
else:
init(self.relations)
# Biases
if self.b_init:
init = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def initialize_weights(self, weights_initializer, bias_initializer):\n wshapes = [\n [self.input_size, self.hidden_size[0]],\n [self.hidden_size[0], self.hidden_size[1]],\n [self.hidden_size[1], self.output_size]\n ]\n... | [
"0.82576996",
"0.8227028",
"0.82042074",
"0.817285",
"0.8160349",
"0.8155006",
"0.8127573",
"0.81187093",
"0.8007405",
"0.7982579",
"0.7974712",
"0.79322505",
"0.78819776",
"0.78818023",
"0.7876818",
"0.78659105",
"0.7865434",
"0.7865434",
"0.7865434",
"0.78556186",
"0.782407... | 0.7561252 | 38 |
Initialise biases and weights (glorot_uniform or uniform) | def reset_parameters(self, reset_mode='glorot_uniform'):
if reset_mode == 'glorot_uniform':
if self.weight_decomp == 'block':
nn.init.xavier_uniform_(self.blocks, gain=nn.init.calculate_gain('relu'))
elif self.weight_decomp == 'basis':
nn.init.xavier_unif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_weight_initializer(self):\n self.biases = [np.random.randn(y, 1) for y in self.sizes[1:]]\n self.weights = [np.random.randn(y, x)/np.sqrt(x)\n for x, y in zip(self.sizes[:-1], self.sizes[1:])]",
"def initWeights(self):\n self.weights = []\n self.bias... | [
"0.7695583",
"0.76904297",
"0.768687",
"0.7631656",
"0.75850135",
"0.7546133",
"0.7538794",
"0.74401927",
"0.74401927",
"0.74317634",
"0.739828",
"0.73953336",
"0.737125",
"0.7343187",
"0.7282984",
"0.7263123",
"0.72536844",
"0.72379565",
"0.72379565",
"0.72379565",
"0.723438... | 0.0 | -1 |
Fill the input `Tensor` with values according to the Schlichtkrull method, using a normal distribution. | def schlichtkrull_normal_(tensor, shape, gain=1.):
std = schlichtkrull_std(shape, gain)
with torch.no_grad():
return tensor.normal_(0.0, std) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeDistribution(self):\n if (self.lowerBoundUsed == False and self.upperBoundUsed == False):\n self._distribution = distribution1D.BasicWeibullDistribution(self.k,self.lambdaVar,self.low)\n self.lowerBound = self.low\n self.upperBound = sys.float_info.max\n else:\n if self.lowe... | [
"0.5979632",
"0.5846269",
"0.5841435",
"0.5806471",
"0.5806471",
"0.58041257",
"0.5796013",
"0.57950556",
"0.5716712",
"0.5704743",
"0.5704743",
"0.5704743",
"0.5704743",
"0.5704743",
"0.5689562",
"0.56430966",
"0.56412244",
"0.5617718",
"0.5609436",
"0.5605589",
"0.5591438",... | 0.6289478 | 0 |
Return the current project data dir, creating it if it doesn't exist | def project_data_dir(project: str = "default") -> str:
if not inside_project():
raise NotConfigured("Not inside a project")
cfg = get_config()
if cfg.has_option(DATADIR_CFG_SECTION, project):
d = Path(cfg.get(DATADIR_CFG_SECTION, project))
else:
scrapy_cfg = closest_scrapy_cfg()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_dir():\n\n data_dir = Path(get_project_dir() / 'data')\n data_dir.mkdir(parents=True, exist_ok=True)\n return data_dir",
"def get_data_dir():\n return Path(current_app.config[\"USER_DIR\"]) / \"data\"",
"def data_dir():\n return os.path.join(os.path.dirname(os.path.abspath(__file__)... | [
"0.884594",
"0.8154901",
"0.8143387",
"0.8130206",
"0.7878359",
"0.7874639",
"0.78590393",
"0.7808614",
"0.77807176",
"0.7725354",
"0.7691692",
"0.76879364",
"0.7636406",
"0.75192946",
"0.75016165",
"0.74805737",
"0.7458777",
"0.7458247",
"0.7436417",
"0.74316865",
"0.7429985... | 0.7689561 | 11 |
Return the given path joined with the .scrapy data directory. If given an absolute path, return it unmodified. | def data_path(path: str, createdir: bool = False) -> str:
path_obj = Path(path)
if not path_obj.is_absolute():
if inside_project():
path_obj = Path(project_data_dir(), path)
else:
path_obj = Path(".scrapy", path)
if createdir and not path_obj.exists():
path_ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path(data_path):\n\treturn os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path",
"def get_data_path(path):\n\n data_path = Path(self.kard.meta.get('data_path', 'data'))\n\n if data_path.is_absolute():\n return str(data_path / path)\n\n return s... | [
"0.7194747",
"0.712831",
"0.6813964",
"0.6805899",
"0.67509013",
"0.675075",
"0.6701231",
"0.6690529",
"0.66013783",
"0.65679127",
"0.65266705",
"0.650922",
"0.64778847",
"0.6452505",
"0.64015555",
"0.63948417",
"0.6387983",
"0.63615096",
"0.63472974",
"0.63385934",
"0.630335... | 0.71222496 | 2 |
Online status of the application. True if no local card data is present. | def set_online(self, status: bool):
self.ui.get_object('statusbar_icon').set_from_icon_name(util.online_icons[status], Gtk.IconSize.BUTTON)
self.ui.get_object('statusbar_icon').set_tooltip_text(util.online_tooltips[status])
self.config['local_db'] = not status
self.save_config() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def online(self) -> bool:\n\t\treturn self._raw_result['data']['online']",
"def is_online(self) -> bool:\n return self.data[Attribute.ONLINE]",
"def online(self):\n return False",
"def is_online(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"is_online\")",
"def is_o... | [
"0.7865311",
"0.7805424",
"0.76072806",
"0.7488986",
"0.7395054",
"0.72255445",
"0.71028167",
"0.71028167",
"0.70384157",
"0.6982051",
"0.6942591",
"0.6909111",
"0.67982364",
"0.6796394",
"0.6764952",
"0.675009",
"0.67485243",
"0.67328125",
"0.6655613",
"0.6646827",
"0.662441... | 0.0 | -1 |
Set up the status bar in the Mac menu | def _setup_status_bar(self):
self.status = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength)
self.status.setMenu_(self.status_menu)
self.status.setTitle_("Core")
self.status.setHighlightMode_(objc.YES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_status_bar(self):\n self.statusbar = self.CreateStatusBar()",
"def set_statusbar(self):\n self.statusbar = self.CreateStatusBar()\n self.statusbar.SetFieldsCount(3) # make 3 of them\n self.statusbar.SetStatusWidths([-1,-1,-2]) # last one is 2x size of 1st and 2nd, all stret... | [
"0.72974026",
"0.704181",
"0.6907672",
"0.6680588",
"0.66564",
"0.664472",
"0.6605341",
"0.6601754",
"0.65815306",
"0.64965403",
"0.64820766",
"0.64719707",
"0.64041114",
"0.6365701",
"0.6295507",
"0.6215244",
"0.6096732",
"0.60924906",
"0.6074106",
"0.605839",
"0.60554826",
... | 0.7981992 | 0 |
Search all of the available window handles (i.e. Chromium instances / web pages / Finsemble components) that are visible to Selenium and locate the specific one corresponding to the provided URL. | def get_selenium_handle_of_page_containing_url(self, desired_url: str) -> str:
# Define an inline method that will search for the desired page so that we can pass it in as a callable
# predicate in order to wait for the page to become visible.
# (Components may still be loading when this method... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_selenium_handles_of_all_pages_containing_url(self, desired_url: str) -> List[str]:\n\n all_pages = self.discover_all_available_pages()\n matching_page_handles = [handle for handle, page_data in all_pages.items()\n if desired_url.lower() in page_data['url'].lowe... | [
"0.6499459",
"0.64341563",
"0.60216457",
"0.58066374",
"0.5801197",
"0.5758334",
"0.5699086",
"0.55551445",
"0.5531188",
"0.5505056",
"0.5485803",
"0.5469651",
"0.5457565",
"0.5358329",
"0.53565603",
"0.5326569",
"0.5326569",
"0.52843535",
"0.52678406",
"0.526148",
"0.5256366... | 0.6465577 | 1 |
Returns True or False whether the specified plugin is disabled or not. | def is_plugin_disabled(self, plugin: str) -> bool:
with PluginStore.mutex:
return plugin in self._disabled | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_disabled(self) -> pulumi.Output[bool]:\n return pulumi.get(self, \"is_disabled\")",
"def is_disabled(self) -> pulumi.Output[Optional[bool]]:\n return pulumi.get(self, \"is_disabled\")",
"def is_disabled(self):\n\n return self.__contains__('disabled')",
"def disabled(self) -> bool:... | [
"0.7553718",
"0.7410899",
"0.7372038",
"0.73590446",
"0.73590446",
"0.72663414",
"0.72172564",
"0.7114851",
"0.71010745",
"0.7099821",
"0.7045404",
"0.7045404",
"0.6978214",
"0.6959868",
"0.6959868",
"0.6959868",
"0.6959868",
"0.6959868",
"0.6959868",
"0.6959868",
"0.6959868"... | 0.887675 | 0 |
It will open a .txt file and return the fileName back. | def askInputFile():
while True:
print("Enter a valid .txt file")
# Try until a plain-text file is provided.
try:
fileName = easygui.fileopenbox("Enter a .txt file",
"Open file",
default="C:\\",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_text(file_name):\n\tf = open(file_name, 'r')\n\ttext = f.read()\n\treturn text",
"def read_text_file(str_name_file: str):\n content: str = ''\n with open(str_name_file, mode=\"r\", encoding='utf-8') as file:\n print(\"file being read: \" + str_name_file + \"\\n\")\n content = fil... | [
"0.72944707",
"0.7255649",
"0.7086624",
"0.7031243",
"0.6920041",
"0.688983",
"0.68801343",
"0.6845105",
"0.6827755",
"0.67921734",
"0.67916375",
"0.6778593",
"0.6729788",
"0.67192703",
"0.66965175",
"0.66637677",
"0.6642754",
"0.6637316",
"0.6620653",
"0.66100776",
"0.658348... | 0.6160696 | 62 |
Read the text from the file and return in back. | def readText(fileName):
fileText = ""
with open(fileName,"r") as fileObject:
fileText = fileObject.read()
return fileText | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simple_text_reader(text_file):\n with open(text_file, 'rt') as file:\n data = file.read()\n return data",
"def open_and_read_file(file_path):\n text_data = open(file_path).read()\n # print text_data\n return text_data",
"def read_file(file_path):\n try:\n input_file = op... | [
"0.7722382",
"0.7580321",
"0.75347316",
"0.75064945",
"0.74893135",
"0.74482197",
"0.74246323",
"0.73390263",
"0.733697",
"0.7333794",
"0.7299624",
"0.7280394",
"0.7240668",
"0.7229014",
"0.7227244",
"0.72060597",
"0.7188755",
"0.71726364",
"0.71656406",
"0.7130675",
"0.71202... | 0.7460799 | 5 |
Return a tuple ``(updated_bias, updated_weight)`` representing the gradient for the cost function C_x. ``updated_bias`` and ``updated_weight`` are layerbylayer lists of numpy arrays, similar to ``self.biases`` and ``self.weights``. | def backprop(self, x, y):
#Building an empty networks filled with empty 0
updated_bias = []
for b in self.biases:
updated_bias.append(np.zeros(b.shape))
updated_weight = []
for w in self.weights:
updated_weight.append(np.zeros(w.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_gradients(self):\n wlist = self._neural_net.weights()\n blist = self._neural_net.biases()\n\n nmatrices = len(wlist)\n weight_grad = []\n bias_grad = []\n\n cost_function = self._cost_function\n weight_der = WeightDerivative(neural_net=self._neural_net,\... | [
"0.70037687",
"0.6904672",
"0.68984175",
"0.68149334",
"0.6785196",
"0.6736419",
"0.67154384",
"0.6707164",
"0.6702782",
"0.66837496",
"0.65808415",
"0.65519845",
"0.65458727",
"0.64750123",
"0.6470527",
"0.645518",
"0.6451915",
"0.6412186",
"0.64033324",
"0.6388749",
"0.6388... | 0.0 | -1 |
Return the vector of partial derivatives \partial C_x / \partial a for the output activations. | def cost_derivative(self, output_activations, y):
return (output_activations-y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_partials(self, inputs, partials):\n SOC = inputs['SOC']\n temperature = inputs['temperature']\n P_bat = inputs['P_bat']\n\n # dI_dP\n dV_dvoc = IR * self.exponential\n dV_dT = - IR * self.voc * np.exp(alpha*(temperature[4, :] - T0)/T0) * alpha / T0\n dVo... | [
"0.6179747",
"0.6113179",
"0.6110102",
"0.6063869",
"0.6060675",
"0.5840477",
"0.58356196",
"0.57909757",
"0.5785478",
"0.576321",
"0.56648666",
"0.56212157",
"0.5613195",
"0.5575484",
"0.5562849",
"0.5559713",
"0.5545122",
"0.55250263",
"0.551218",
"0.5509232",
"0.5506259",
... | 0.56029624 | 15 |
Derivative of the sigmoid function. | def sigmoid_prime(z):
return sigmoid(z)*(1-sigmoid(z)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(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 derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_der... | [
"0.84754366",
"0.8450928",
"0.8396931",
"0.83485264",
"0.83485264",
"0.8298343",
"0.80539966",
"0.7753385",
"0.77070266",
"0.7498153",
"0.7464916",
"0.7454039",
"0.7401582",
"0.7385017",
"0.73829913",
"0.7346935",
"0.7321687",
"0.73094004",
"0.7192053",
"0.7113881",
"0.709236... | 0.0 | -1 |
Return the absolute end of the utterance relative to the signal. | def end_abs(self):
if self.end == float('inf'):
return self.track.duration
else:
return self.end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end(self):\n return self._t0 + self.length",
"def _get_end(self):\n return self._end",
"def get_end(self):\n return self.__end",
"def get_end(self):\n return self._end",
"def getEnd(self) -> long:\n ...",
"def get_end(self):\n return self._start + self._durat... | [
"0.67138165",
"0.6436659",
"0.6302284",
"0.6288117",
"0.6269361",
"0.6230538",
"0.61950463",
"0.6194317",
"0.6047313",
"0.59740156",
"0.5973062",
"0.5929029",
"0.5923726",
"0.5916584",
"0.5906003",
"0.5864616",
"0.58030725",
"0.579325",
"0.5792297",
"0.5780779",
"0.5766522",
... | 0.73755103 | 0 |
Return the absolute duration in seconds. | def duration(self):
return self.end_abs - self.start | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duration(self):\n return float('{0:.2f}'.format(self.end_time - self.start_time))",
"def duration(self) -> float:\n return self._stop - self._start if self._stop is not None else None",
"def duration_in_seconds(self):\n return self.get_data(\"duration_in_seconds\")",
"def duration(se... | [
"0.74623835",
"0.73813367",
"0.7258197",
"0.7205601",
"0.7184122",
"0.7179667",
"0.7177773",
"0.717655",
"0.71611416",
"0.71505004",
"0.7140248",
"0.7140148",
"0.7113886",
"0.71128476",
"0.70916873",
"0.7089816",
"0.7074316",
"0.70680296",
"0.70603245",
"0.7009464",
"0.700419... | 0.7618609 | 0 |
``modular_squareroot_in_FQ2(x)`` returns the value ``y`` such that ``y2 % q == x``, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal imaginary component the value with higher real component is favored. | def modular_squareroot_in_FQ2(value: FQ2) -> Optional[FQ2]:
candidate_squareroot = value ** ((FQ2_ORDER + 8) // 16)
check = candidate_squareroot ** 2 / value
if check in EIGTH_ROOTS_OF_UNITY[::2]:
x1 = candidate_squareroot / EIGTH_ROOTS_OF_UNITY[EIGTH_ROOTS_OF_UNITY.index(check) // 2]
x2 = -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fdq2(f, x, h=1e-5):\n return (-3*f(x) + 4*f(x+h) - f(x+2*h))/(2*h)\n raise NotImplementedError(\"Problem 2 Incomplete\")",
"def cdq2(f, x, h=1e-5):\n return (f(x+h)-f(x-h))/(2*h)\n raise NotImplementedError(\"Problem 2 Incomplete\")",
"def rewofzt2(x,y):\n z=x+y*(1j)\n q=(1j)*z/(jnp.sqrt(... | [
"0.60363",
"0.5656827",
"0.5607009",
"0.5589462",
"0.5497674",
"0.52864265",
"0.5166727",
"0.5152072",
"0.51497895",
"0.51399916",
"0.5110753",
"0.5099447",
"0.50873184",
"0.50827193",
"0.5010801",
"0.49463192",
"0.49347386",
"0.48830405",
"0.48534817",
"0.48531464",
"0.48519... | 0.8154235 | 0 |
Return a dataframe where index is sequences and columns is kmers | def sequences_to_kmer_counts(sequences, kmer_size):
pfunc = functools.partial(sequence_to_kmer_freqs, kmer_size=kmer_size, normalize=False)
pool = multiprocessing.Pool(multiprocessing.cpu_count())
kmer_freqs = pool.map(pfunc, sequences, chunksize=250)
pool.close()
pool.join()
mat = np.vstack(kme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_df():\n iterable = [['approach', 'contact', 'retract', 'pause'], ['force', 'height']]\n index = pd.MultiIndex.from_product(iterable, names=['segment', 'channel'])\n return pd.DataFrame(columns=index)",
"def create_panda(read):\n k_values = []\n for i in range(1,len(read)+1):\... | [
"0.63301885",
"0.61599785",
"0.5676173",
"0.566182",
"0.56429535",
"0.5638753",
"0.56306696",
"0.5625229",
"0.5522354",
"0.5496233",
"0.5451835",
"0.5386565",
"0.5336502",
"0.53291607",
"0.53284216",
"0.53099346",
"0.5295041",
"0.5238038",
"0.5201106",
"0.51936346",
"0.518240... | 0.5231338 | 18 |
Given a sequence and query kmers, return a binary matrix where each row represents if that kmer is in that position >>> sequence_kmer_pileup("ACTGCGTACG", ['ACT', 'GCG', 'TACG']) array([[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1]]) >>> sequence_kmer_pileup("ACTGCGTACG"... | def sequence_kmer_pileup(seq, query_kmers):
assert isinstance(query_kmers, list)
lengths = set([len(kmer) for kmer in query_kmers])
retval = np.zeros((len(query_kmers), len(seq))).astype(int)
for length in lengths:
assert length <= len(seq), "Cannoty query a kmer against a seq shorter than that ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assemble_kmer_motifs(seq, kmers, min_len=10, gap_allowed=2):\n try:\n pileup = sequence_kmer_pileup(seq, kmers)\n except AssertionError:\n return []\n pileup_flat = np.clip(np.sum(pileup, axis=0), 0, 1) # Flatten\n pileup_flat = connect_nearby_runs(pileup_flat, gap_allowed) # Connec... | [
"0.61783755",
"0.60753685",
"0.5434832",
"0.5219357",
"0.5162407",
"0.5095824",
"0.50787956",
"0.49830213",
"0.49265006",
"0.49147594",
"0.4905451",
"0.48459452",
"0.48157683",
"0.47851542",
"0.4756707",
"0.47567025",
"0.47282517",
"0.47153527",
"0.4694984",
"0.4694121",
"0.4... | 0.81217086 | 0 |
Return the index and length of all run non zero elements of length greater than l Primarily intended as a helper function for the below function assemble_kmer_motifs | def find_long_runs(num_sequence, l):
chunked = [(k, list(g)) for k, g in itertools.groupby(num_sequence)]
retval = [(i, len(g)) for i, (k, g) in enumerate(chunked) if k and len(g) > l]
return retval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _lengths_groupings(mol):\n return [len(list(group)) for _, group in itertools.groupby(mol)]",
"def lens(steps):\n lens = []\n for i in steps:\n lens.append(len(i))\n return lens",
"def get_seq_length(embeddings: np.ndarray) -> np.ndarray:\n nonzero_mask = np.any(np.logical_not(np.iscl... | [
"0.57668364",
"0.57313144",
"0.5707507",
"0.5580042",
"0.55796087",
"0.5565112",
"0.55609334",
"0.5546772",
"0.5518239",
"0.5488525",
"0.54691786",
"0.54683095",
"0.5459347",
"0.5455764",
"0.54440415",
"0.5441734",
"0.5425191",
"0.53992045",
"0.53959763",
"0.53895664",
"0.537... | 0.6479534 | 0 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
has_archival_copy = dictionary.get('hasArchivalCopy')
has_local_copy = dictionary.get('hasLocalCopy')
has_remote_copy = dictionary... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.0 | -1 |
Create a new instance of our `User` model. | def orm_create_user(session: Session, user: User) -> User:
try:
session.add(user) # Add the user
session.commit() # Commit the change
LOGGER.success(f"Created new user: {user}")
return user
except IntegrityError as e:
LOGGER.error(e.orig)
raise e.orig
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(self, email: str, password: str, **kwargs: str) -> \"User\":\n email = self.normalize_email(email)\n user: \"User\" = self.model(email=email, **kwargs)\n user.set_password(password)\n user.save()\n return user",
"def create_user(self):\n return UserFactor... | [
"0.7993599",
"0.79923683",
"0.79566765",
"0.7897849",
"0.77330023",
"0.77002925",
"0.7699446",
"0.76870686",
"0.7683861",
"0.76535153",
"0.7635452",
"0.7633329",
"0.7607549",
"0.7600044",
"0.758689",
"0.75838315",
"0.758236",
"0.7579588",
"0.75724137",
"0.75642264",
"0.756048... | 0.0 | -1 |
Create a list of partitioned variables according to the given `slicing`. Currently only one dimension of the full variable can be sliced, and the full variable can be reconstructed by the concatenation of the returned list along that dimension. | def create_partitioned_variables(
shape, slicing, initializer, dtype=dtypes.float32,
trainable=True, collections=None, name=None, reuse=None):
if len(shape) != len(slicing):
raise ValueError("The 'shape' and 'slicing' of a partitioned Variable "
"must have the length: shape: %s, slici... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_partitioned_variables(\n shape, slicing, initializer, dtype=dtypes.float32,\n trainable=True, collections=None, name=None, reuse=None):\n if len(shape) != len(slicing):\n raise ValueError(\n \"The 'shape' and 'slicing' of a partitioned Variable \"\n f\"must have the length: shape... | [
"0.7400339",
"0.6649992",
"0.6155834",
"0.6027694",
"0.5980611",
"0.58807266",
"0.5725447",
"0.5596276",
"0.55921227",
"0.5575733",
"0.55720437",
"0.5551016",
"0.55449885",
"0.55369186",
"0.5514247",
"0.548069",
"0.5457379",
"0.5433361",
"0.5427207",
"0.54064906",
"0.53875506... | 0.73679435 | 1 |
Returns the number of fields in this schema. | def __len__(self):
return len(self._by_number) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return self.dbms.get_nb_fields(self.table, self.db)",
"def _fields_num(self):\n return len(self.paths)",
"def no_of_columns(self): \n return len(self.columns) + (1 if self.serialize else 0)",
"def columns_count(self):\n if self.value.count != 0:\n re... | [
"0.81591487",
"0.78460896",
"0.7257139",
"0.7252796",
"0.7120052",
"0.6978501",
"0.68712497",
"0.68519604",
"0.68484867",
"0.6738405",
"0.67203087",
"0.6709255",
"0.66980517",
"0.6691632",
"0.66814804",
"0.6612548",
"0.6610964",
"0.6578507",
"0.65737176",
"0.6571952",
"0.6560... | 0.0 | -1 |
Returns a list of the names of the fields in this schema. | def field_names(self):
return self._names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fieldNames(self):\n return self.__fieldNames",
"def get_field_names(self):\n return self._keys",
"def field_names(self):\n return self.base_field_names() + list(self.data.keys())",
"def _fields_names(cls) -> List:\n return list(field.name for field in dataclasses.fields(cls))"... | [
"0.84484935",
"0.8384219",
"0.8352998",
"0.8320168",
"0.8296431",
"0.82712126",
"0.8186574",
"0.8079723",
"0.79368764",
"0.7814438",
"0.77573127",
"0.77475095",
"0.7678432",
"0.7672202",
"0.76382",
"0.76280415",
"0.76061904",
"0.7572449",
"0.7543729",
"0.7541312",
"0.75341004... | 0.8322108 | 3 |
Given a field number, returns the field's name. | def number_to_name(self, number):
return self._names[number] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def py_field_name(self, field):\n name = field.name\n name = as_identifier(name)\n if self.options(field).convert_case:\n name = from_camel_case(name)\n name = self._mangle_name(name)\n return name",
"def capnp_field_name(self, field):\n name = field.name\n ... | [
"0.7281962",
"0.7170076",
"0.7035154",
"0.7026706",
"0.7006933",
"0.6831218",
"0.6755667",
"0.6750089",
"0.67179394",
"0.6710781",
"0.6677429",
"0.6654905",
"0.65733427",
"0.6517517",
"0.65146506",
"0.64716965",
"0.6448458",
"0.6425866",
"0.63990456",
"0.6378071",
"0.6367998"... | 0.6655586 | 11 |
Returns a list of field numbers corresponding to the fields that are vectored. | def vectored_fields(self):
return [i for i, ftype in enumerate(self._by_number) if ftype.vector] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_vectored_fields(self):\r\n return any(ftype.vector for ftype in self._by_number)",
"def velocity_field(self):\n return scipy.dstack((self._u_int, self._v_int))",
"def get_vector_field(self, key):\n f1 = self.get_field(key + '1')\n f2 = self.get_field(key + '2')\n f3 =... | [
"0.6576135",
"0.62712544",
"0.60526973",
"0.5864147",
"0.57768536",
"0.57186764",
"0.5664389",
"0.56052095",
"0.5580481",
"0.55764526",
"0.5470249",
"0.54560256",
"0.54304016",
"0.5407624",
"0.54074955",
"0.5394592",
"0.53900814",
"0.53792286",
"0.53194577",
"0.52956903",
"0.... | 0.85502195 | 0 |
Returns the content analyzer for the given fieldname, or None if the field has no analyzer | def analyzer(self, fieldname):
field = self[fieldname]
if field.format and field.format.analyzer:
return field.format.analyzer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_analyzer(cls, analyzer_name):\n return cls._class_registry[analyzer_name.lower()]",
"def get_field(self, field_name):\n for f in self.fields:\n if f.name.lower() == field_name.lower():\n return f\n return None",
"def getdocfield(fieldname):\t\t\n\tl = [d f... | [
"0.6079767",
"0.589265",
"0.5835959",
"0.53897285",
"0.5088177",
"0.5068475",
"0.50557554",
"0.5018533",
"0.49397895",
"0.49092835",
"0.48768896",
"0.47611442",
"0.47393295",
"0.4728982",
"0.4700087",
"0.46914902",
"0.4690814",
"0.466198",
"0.4646916",
"0.4645643",
"0.4635231... | 0.7778403 | 0 |
Sets the timesheet_line_id of this TimesheetLine. | def timesheet_line_id(self, timesheet_line_id):
self._timesheet_line_id = timesheet_line_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_item_id(self, line_item_id):\n\n self._line_item_id = line_item_id",
"def set_mask_line(self, _=None):\n self.set_mask_type(\"line\")",
"def line_nbr(self, line_nbr):\n\n self._line_nbr = line_nbr",
"def line_status(self, line_status):\n\n self._line_status = line_status"... | [
"0.6376212",
"0.585144",
"0.57867175",
"0.56583244",
"0.5600785",
"0.5485917",
"0.5475551",
"0.54733694",
"0.5457823",
"0.5449516",
"0.5371612",
"0.5358188",
"0.52637",
"0.5210421",
"0.52039397",
"0.5165261",
"0.51464885",
"0.51464885",
"0.51464885",
"0.5125291",
"0.51213425"... | 0.9208573 | 0 |
Sets the tracking_item_id of this TimesheetLine. | def tracking_item_id(self, tracking_item_id):
self._tracking_item_id = tracking_item_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_item_id(self, line_item_id):\n\n self._line_item_id = line_item_id",
"def tracking_id(self, tracking_id):\n\n self._tracking_id = tracking_id",
"def item_id(self, item_id):\n\n self._item_id = item_id",
"def item_id(self, item_id):\n\n self._item_id = item_id",
"def ite... | [
"0.7257509",
"0.6755095",
"0.64136916",
"0.64136916",
"0.64136916",
"0.5871529",
"0.5680786",
"0.56769633",
"0.56769633",
"0.5609209",
"0.5501813",
"0.5485787",
"0.5467613",
"0.51974404",
"0.51598537",
"0.51566774",
"0.51323116",
"0.5124376",
"0.5121191",
"0.5074866",
"0.5072... | 0.815952 | 0 |
Sets the number_of_units of this TimesheetLine. | def number_of_units(self, number_of_units):
if number_of_units is None:
raise ValueError(
"Invalid value for `number_of_units`, must not be `None`"
) # noqa: E501
self._number_of_units = number_of_units | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_units(self, number_of_units):\n\n self._number_of_units = number_of_units",
"def set_number_of_time_steps(self, number_of_time_steps):\n self.number_of_time_steps = number_of_time_steps",
"def set_units(self, units):\n self.units = units",
"def units_setting(self, units_set... | [
"0.8183294",
"0.70641243",
"0.6417182",
"0.6198261",
"0.5933052",
"0.5933052",
"0.5933052",
"0.5894928",
"0.574319",
"0.5724416",
"0.56904614",
"0.5610853",
"0.55990285",
"0.55183345",
"0.54891974",
"0.5480462",
"0.54644585",
"0.5446119",
"0.5418585",
"0.5403658",
"0.53636944... | 0.71914977 | 1 |
Matches to explicit slashless URLs should go unmolested. | def test_append_slash_slashless_resource(self):
def get_response(req):
return HttpResponse("Here's the text of the web page.")
request = self.rf.get("/noslash")
self.assertIsNone(CommonMiddleware(get_response).process_request(request))
self.assertEqual(
CommonMi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_extra_slash():\n # TODO: Should we actually do this?\n # TODO: See https://webmasters.stackexchange.com/questions/8354/what-does-the-double-slash-mean-in-urls/8381#8381\n assert (normalize_url(\"http://www.example.com/foo//bar.html\") ==\n \"http://www.example.com/foo/bar.html\"... | [
"0.69019014",
"0.6602079",
"0.64100283",
"0.6345101",
"0.6202505",
"0.61982834",
"0.59627116",
"0.5944036",
"0.5937673",
"0.5934989",
"0.5899633",
"0.5865584",
"0.5847636",
"0.58120596",
"0.57773834",
"0.5759613",
"0.5758419",
"0.5756713",
"0.57340276",
"0.57326156",
"0.56948... | 0.52134234 | 99 |
APPEND_SLASH should append slash to path when redirecting a request with a querystring ending with slash. | def test_append_slash_redirect_querystring_have_slash(self):
request = self.rf.get("/slash?test=slash/")
resp = CommonMiddleware(get_response_404)(request)
self.assertIsInstance(resp, HttpResponsePermanentRedirect)
self.assertEqual(resp.url, "/slash/?test=slash/") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_append_slash_redirect_querystring(self):\n request = self.rf.get(\"/slash?test=1\")\n resp = CommonMiddleware(get_response_404)(request)\n self.assertEqual(resp.url, \"/slash/?test=1\")",
"def fix_slash(environ, wantslash):\n from colubrid.exceptions import HttpMoved\n #FIXME\... | [
"0.74099624",
"0.7253963",
"0.7086631",
"0.6728155",
"0.6602731",
"0.6182194",
"0.6003779",
"0.59855634",
"0.5924239",
"0.59172046",
"0.5905983",
"0.5868049",
"0.5868018",
"0.5817994",
"0.562229",
"0.56061345",
"0.55782634",
"0.55239135",
"0.55239135",
"0.55194396",
"0.549757... | 0.74912924 | 0 |
Disabling append slash functionality should leave slashless URLs alone. | def test_append_slash_disabled(self):
request = self.rf.get("/slash")
self.assertEqual(CommonMiddleware(get_response_404)(request).status_code, 404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_extra_slash():\n # TODO: Should we actually do this?\n # TODO: See https://webmasters.stackexchange.com/questions/8354/what-does-the-double-slash-mean-in-urls/8381#8381\n assert (normalize_url(\"http://www.example.com/foo//bar.html\") ==\n \"http://www.example.com/foo/bar.html\"... | [
"0.67874944",
"0.6561039",
"0.65192884",
"0.64829475",
"0.6442448",
"0.64176923",
"0.6327198",
"0.63167566",
"0.61084825",
"0.61076355",
"0.6096986",
"0.6096121",
"0.6088276",
"0.6011603",
"0.60082155",
"0.60057205",
"0.5990615",
"0.59772855",
"0.5931927",
"0.59236723",
"0.59... | 0.69257134 | 0 |
Matches to explicit slashless URLs should go unmolested. | def test_append_slash_slashless_resource_custom_urlconf(self):
def get_response(req):
return HttpResponse("web content")
request = self.rf.get("/customurlconf/noslash")
request.urlconf = "middleware.extra_urls"
self.assertIsNone(CommonMiddleware(get_response).process_reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_extra_slash():\n # TODO: Should we actually do this?\n # TODO: See https://webmasters.stackexchange.com/questions/8354/what-does-the-double-slash-mean-in-urls/8381#8381\n assert (normalize_url(\"http://www.example.com/foo//bar.html\") ==\n \"http://www.example.com/foo/bar.html\"... | [
"0.69019014",
"0.6602079",
"0.64100283",
"0.6345101",
"0.6202505",
"0.61982834",
"0.59627116",
"0.5944036",
"0.5937673",
"0.5934989",
"0.5899633",
"0.5865584",
"0.5847636",
"0.58120596",
"0.57773834",
"0.5759613",
"0.5758419",
"0.5756713",
"0.57340276",
"0.57326156",
"0.56948... | 0.0 | -1 |
Disabling append slash functionality should leave slashless URLs alone. | def test_append_slash_disabled_custom_urlconf(self):
request = self.rf.get("/customurlconf/slash")
request.urlconf = "middleware.extra_urls"
self.assertIsNone(CommonMiddleware(get_response_404).process_request(request))
self.assertEqual(CommonMiddleware(get_response_404)(request).status_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_append_slash_disabled(self):\n request = self.rf.get(\"/slash\")\n self.assertEqual(CommonMiddleware(get_response_404)(request).status_code, 404)",
"def test_remove_extra_slash():\n # TODO: Should we actually do this?\n # TODO: See https://webmasters.stackexchange.com/questions/8354/... | [
"0.69257134",
"0.67874944",
"0.6561039",
"0.65192884",
"0.64829475",
"0.64176923",
"0.6327198",
"0.63167566",
"0.61084825",
"0.61076355",
"0.6096986",
"0.6096121",
"0.6088276",
"0.6011603",
"0.60082155",
"0.60057205",
"0.5990615",
"0.59772855",
"0.5931927",
"0.59236723",
"0.5... | 0.6442448 | 5 |
The 304 Not Modified response should include only the headers required by RFC 9110 Section 15.4.5, LastModified, and the cookies. | def test_not_modified_headers(self):
def get_response(req):
resp = self.client.get(req.path_info)
resp["Date"] = "Sat, 12 Feb 2011 17:35:44 GMT"
resp["Last-Modified"] = "Sat, 12 Feb 2011 17:35:44 GMT"
resp["Expires"] = "Sun, 13 Feb 2011 17:35:44 GMT"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get304(self):\n bad = ('allow', 'content-encoding', 'content-language',\n 'content-length', 'content-md5', 'content-range',\n 'content-type', 'last-modified') # + c-location, expires?\n for h in bad:\n bottle.response.set_header(h, 'foo')\n bottle.sta... | [
"0.77433777",
"0.7389816",
"0.7304999",
"0.72709113",
"0.7158089",
"0.71346813",
"0.67680997",
"0.6660743",
"0.65579474",
"0.6540546",
"0.65395445",
"0.64814484",
"0.64814484",
"0.64471066",
"0.6441493",
"0.64004403",
"0.6374444",
"0.6374444",
"0.6342886",
"0.63065875",
"0.63... | 0.7653532 | 1 |
The X_FRAME_OPTIONS setting can be set to SAMEORIGIN to have the middleware use that value for the HTTP header. | def test_same_origin(self):
with override_settings(X_FRAME_OPTIONS="SAMEORIGIN"):
r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())
self.assertEqual(r.headers["X-Frame-Options"], "SAMEORIGIN")
with override_settings(X_FRAME_OPTIONS="sameorigin"):
r = XFr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_defaults_sameorigin(self):\n with override_settings(X_FRAME_OPTIONS=None):\n del settings.X_FRAME_OPTIONS # restored by override_settings\n r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())\n self.assertEqual(r.headers[\"X-Frame-Options\"], \"DENY\")",... | [
"0.797619",
"0.7835283",
"0.7401202",
"0.7227937",
"0.70077145",
"0.6819348",
"0.67600465",
"0.66922677",
"0.64878297",
"0.63498175",
"0.6249832",
"0.6233134",
"0.6120981",
"0.60746974",
"0.60449773",
"0.5995455",
"0.59321135",
"0.59264505",
"0.5913701",
"0.58064616",
"0.5800... | 0.7810529 | 2 |
The X_FRAME_OPTIONS setting can be set to DENY to have the middleware use that value for the HTTP header. | def test_deny(self):
with override_settings(X_FRAME_OPTIONS="DENY"):
r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())
self.assertEqual(r.headers["X-Frame-Options"], "DENY")
with override_settings(X_FRAME_OPTIONS="deny"):
r = XFrameOptionsMiddleware(get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_defaults_sameorigin(self):\n with override_settings(X_FRAME_OPTIONS=None):\n del settings.X_FRAME_OPTIONS # restored by override_settings\n r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())\n self.assertEqual(r.headers[\"X-Frame-Options\"], \"DENY\")",... | [
"0.77441394",
"0.77235246",
"0.7475997",
"0.7407488",
"0.72964406",
"0.6919084",
"0.6720077",
"0.64512885",
"0.6388979",
"0.633439",
"0.59314615",
"0.58958787",
"0.5841698",
"0.57990575",
"0.5778251",
"0.5755206",
"0.57463",
"0.5726813",
"0.5702936",
"0.56696177",
"0.56688845... | 0.8097318 | 0 |
If the X_FRAME_OPTIONS setting is not set then it defaults to DENY. | def test_defaults_sameorigin(self):
with override_settings(X_FRAME_OPTIONS=None):
del settings.X_FRAME_OPTIONS # restored by override_settings
r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())
self.assertEqual(r.headers["X-Frame-Options"], "DENY") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deny(self):\n with override_settings(X_FRAME_OPTIONS=\"DENY\"):\n r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())\n self.assertEqual(r.headers[\"X-Frame-Options\"], \"DENY\")\n\n with override_settings(X_FRAME_OPTIONS=\"deny\"):\n r = XFrameOpt... | [
"0.81923014",
"0.8078053",
"0.7757181",
"0.7130634",
"0.667028",
"0.64313835",
"0.57909423",
"0.56664836",
"0.5645852",
"0.554543",
"0.55281603",
"0.5457793",
"0.5340389",
"0.5340389",
"0.53040135",
"0.52516526",
"0.51903003",
"0.5158321",
"0.5144021",
"0.51436627",
"0.511732... | 0.7452115 | 3 |
If the XFrameOptions header is already set then the middleware does not attempt to override it. | def test_dont_set_if_set(self):
def same_origin_response(request):
response = HttpResponse()
response.headers["X-Frame-Options"] = "SAMEORIGIN"
return response
def deny_response(request):
response = HttpResponse()
response.headers["X-Frame-Op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_defaults_sameorigin(self):\n with override_settings(X_FRAME_OPTIONS=None):\n del settings.X_FRAME_OPTIONS # restored by override_settings\n r = XFrameOptionsMiddleware(get_response_empty)(HttpRequest())\n self.assertEqual(r.headers[\"X-Frame-Options\"], \"DENY\")",... | [
"0.75769746",
"0.7559421",
"0.69810355",
"0.69232666",
"0.6921727",
"0.6782732",
"0.6491265",
"0.6448554",
"0.6047611",
"0.56697845",
"0.54975253",
"0.5489311",
"0.54482067",
"0.54186684",
"0.53674936",
"0.5365614",
"0.527816",
"0.52711457",
"0.5242988",
"0.52124727",
"0.5202... | 0.75254494 | 2 |
GZipMiddleware makes a strong ETag weak. | def test_strong_etag_modified(self):
def get_response(req):
response = HttpResponse(self.compressible_string)
response.headers["ETag"] = '"eggs"'
return response
request = self.rf.get("/", headers={"accept-encoding": "gzip, deflate"})
gzip_response = GZipMid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weak_etag_not_modified(self):\n\n def get_response(req):\n response = HttpResponse(self.compressible_string)\n response.headers[\"ETag\"] = 'W/\"eggs\"'\n return response\n\n request = self.rf.get(\"/\", headers={\"accept-encoding\": \"gzip, deflate\"})\n ... | [
"0.7565509",
"0.6790778",
"0.6711801",
"0.63088965",
"0.624187",
"0.6101281",
"0.59977597",
"0.5978516",
"0.5971494",
"0.5754018",
"0.56875217",
"0.5585591",
"0.55424803",
"0.5439437",
"0.5348001",
"0.5328124",
"0.53126985",
"0.52768075",
"0.5225052",
"0.51471895",
"0.514468"... | 0.7457159 | 1 |
GZipMiddleware doesn't modify a weak ETag. | def test_weak_etag_not_modified(self):
def get_response(req):
response = HttpResponse(self.compressible_string)
response.headers["ETag"] = 'W/"eggs"'
return response
request = self.rf.get("/", headers={"accept-encoding": "gzip, deflate"})
gzip_response = GZi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_strong_etag_modified(self):\n\n def get_response(req):\n response = HttpResponse(self.compressible_string)\n response.headers[\"ETag\"] = '\"eggs\"'\n return response\n\n request = self.rf.get(\"/\", headers={\"accept-encoding\": \"gzip, deflate\"})\n ... | [
"0.7308437",
"0.6863467",
"0.66180116",
"0.6354348",
"0.62460524",
"0.6134506",
"0.6048172",
"0.59835535",
"0.5968006",
"0.58983374",
"0.575672",
"0.5627629",
"0.5577308",
"0.55178344",
"0.54604185",
"0.5438792",
"0.5319739",
"0.5313638",
"0.526459",
"0.5229137",
"0.51921755"... | 0.74918115 | 0 |
GZipMiddleware allows 304 Not Modified responses. | def test_etag_match(self):
def get_response(req):
return HttpResponse(self.compressible_string)
def get_cond_response(req):
return ConditionalGetMiddleware(get_response)(req)
request = self.rf.get("/", headers={"accept-encoding": "gzip, deflate"})
response = GZ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weak_etag_not_modified(self):\n\n def get_response(req):\n response = HttpResponse(self.compressible_string)\n response.headers[\"ETag\"] = 'W/\"eggs\"'\n return response\n\n request = self.rf.get(\"/\", headers={\"accept-encoding\": \"gzip, deflate\"})\n ... | [
"0.6854429",
"0.6741573",
"0.658272",
"0.6445341",
"0.63581556",
"0.63434166",
"0.6312553",
"0.6298311",
"0.6186649",
"0.5948793",
"0.5864117",
"0.5847581",
"0.56995493",
"0.5563173",
"0.5528743",
"0.5521492",
"0.55056155",
"0.5495077",
"0.5490004",
"0.5417216",
"0.5371164",
... | 0.6394955 | 4 |
Sets datadog API key | async def statset_apikey(self, key):
self._set_api_key(key)
await self.bot.say("API key successfully set.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def SetAPIKey(self, api_key):\n self._analyzer.SetAPIKey(api_key)",
"def set_api_key(api_key):\n Movie.__api_key = api_key",
"def set_api_key(new_api_key):\n global api_k... | [
"0.70950806",
"0.70950806",
"0.6908245",
"0.67399395",
"0.6729884",
"0.66733587",
"0.66491234",
"0.655347",
"0.64002097",
"0.6328368",
"0.6238506",
"0.6142716",
"0.6066376",
"0.6057347",
"0.6047893",
"0.59926176",
"0.5980683",
"0.5965308",
"0.5939813",
"0.58505857",
"0.584780... | 0.67987484 | 3 |
The constructor initializes empty lists | def __init__(self):
self.param_names = []
self.param_values = []
self.param_settings = []
self.result = []
self.best_params = None
self.best_score = None
self.max_reps = 5
self.num_values = False
self.algorithm_done = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n # Initializing an empty list.\n self.mylist = []",
"def __init__(self):\n self.l = []",
"def __init__(self):\n self.list = []",
"def __init__(self):\n List.__init__(self)",
"def __init__(self):\n list.__init__([])\n self.name = ''\n ... | [
"0.7677622",
"0.76043624",
"0.7603818",
"0.7514921",
"0.7482716",
"0.7436217",
"0.74123544",
"0.7351431",
"0.7351431",
"0.73165447",
"0.73157436",
"0.72575426",
"0.7222783",
"0.7204848",
"0.72019887",
"0.7201009",
"0.71974546",
"0.7175932",
"0.706622",
"0.70638686",
"0.703859... | 0.0 | -1 |
Return True if file exist, Return FileExistsError if file doesn't exist | def check_file(filename: str):
if os.path.isfile(filename):
return True
else:
raise FileExistsError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exist() -> bool:\n pass",
"def is_file_exists(self):\n pass",
"def FileExists(file):\n return os.path.exists(file)",
"def check_file_exist(self):\n return False",
"def file_exists(self):\r\n if os.path.exists(self.file_path):\r\n return True\r\n els... | [
"0.8629078",
"0.8614841",
"0.846485",
"0.8403369",
"0.83062434",
"0.81839824",
"0.81131935",
"0.8106633",
"0.810475",
"0.8093502",
"0.8087499",
"0.8060332",
"0.80587894",
"0.8054834",
"0.8054834",
"0.8041066",
"0.8017158",
"0.80128294",
"0.8006283",
"0.7999294",
"0.7994094",
... | 0.84336394 | 3 |
Normalizes probability vectors so they sum to one. | def normalize_vecs(mat):
#convert to array for operation
order = len(mat.shape) - 1
mat = COO(mat)
row_sums = mat.sum(axis=order)
mat = DOK(mat)
for point in mat.data:
divisor = row_sums[point[:-1]]
mat[point] = mat[point] / divisor
mat = COO(mat)
return mat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return normalized",
"def normalize(vectors):\n if len(np.asarray(vectors).shape) == 1:\n return vectors / np.linalg.norm(vectors)\n norm = np.linalg.norm(vectors, axis=1)\n return vectors /... | [
"0.7580847",
"0.75564206",
"0.74186236",
"0.7410925",
"0.7377618",
"0.73085237",
"0.72912604",
"0.72175294",
"0.7196013",
"0.71357614",
"0.70906126",
"0.70791817",
"0.70737934",
"0.70503455",
"0.70298916",
"0.70199317",
"0.69846654",
"0.6981637",
"0.6973443",
"0.69549954",
"0... | 0.0 | -1 |
Returns all predecessor transaction ids for a write of the provided address. | def find_write_predecessors(self, address):
# A write operation must be preceded by:
# - The "enclosing writer", which is the writer at the address or
# the nearest writer higher (closer to the root) in the tree.
# - The "enclosing readers", which are the readers at the address
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_read_predecessors(self, address):\n # A read operation must be preceded by:\n # - The \"enclosing writer\", which is the writer at the address or\n # the nearest writer higher (closer to the root) in the tree.\n # - All \"children writers\", which include all writers wh... | [
"0.6227516",
"0.61230135",
"0.5462253",
"0.5246722",
"0.5119472",
"0.5113666",
"0.5044757",
"0.4976977",
"0.4962724",
"0.49612528",
"0.4944683",
"0.49066156",
"0.48827434",
"0.48396674",
"0.481053",
"0.47906673",
"0.477658",
"0.47230756",
"0.4710375",
"0.47073352",
"0.4684185... | 0.64865726 | 0 |
Returns all predecessor transaction ids for a read of the provided address. | def find_read_predecessors(self, address):
# A read operation must be preceded by:
# - The "enclosing writer", which is the writer at the address or
# the nearest writer higher (closer to the root) in the tree.
# - All "children writers", which include all writers which are
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_history(address):\n # Fetches up to 25 transactions, need to chain multiple calls if more are needed.\n # We won't bother now.\n txs = requests.get(\"https://blockstream.info/testnet/api/address/{}/txs\".format(address)).json()\n tx_ids = [tx[\"txid\"] for tx in txs]\n return tx_ids",
"def... | [
"0.6252107",
"0.5598242",
"0.5539953",
"0.54895395",
"0.5374383",
"0.5285195",
"0.519724",
"0.51863295",
"0.51379186",
"0.5116271",
"0.5083562",
"0.5043375",
"0.50414634",
"0.4970563",
"0.49442694",
"0.4913162",
"0.4908487",
"0.48961192",
"0.48753965",
"0.48634443",
"0.481537... | 0.6184831 | 1 |
Return a random vector within the constraints of this cube. | def random_vec(self, rand):
return array([rand.uniform(*c) for c in self.constraints]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_vector(self):\n\n return asarray([np.random.uniform(l, u) for l, u in self.bounds])",
"def random_vector_in_unit_ball():\n x = np.random.normal(loc=0.0, scale=1.0, size=(numSamples, self.dim))\n z = np.random.exponential(scale=1.0, size=(numSamples,))\n d = (np... | [
"0.7057693",
"0.66879135",
"0.6620441",
"0.65932673",
"0.6571752",
"0.63854337",
"0.63134366",
"0.6206621",
"0.6206621",
"0.6163843",
"0.61616606",
"0.61566645",
"0.6156069",
"0.61395216",
"0.61284345",
"0.61011714",
"0.60848147",
"0.60419506",
"0.60418",
"0.6007049",
"0.6001... | 0.7298451 | 0 |
Return all extended attributes on path as a mapping. path can either be a path (str or bytes) or an open file descriptor (int). follow_symlinks indicates whether symlinks should be followed and only applies when path is not an open file descriptor. The returned mapping maps xattr names (bytes) to values (bytes or None)... | def get_all(path, follow_symlinks=False):
if isinstance(path, str):
path = os.fsencode(path)
result = {}
try:
names = listxattr(path, follow_symlinks=follow_symlinks)
for name in names:
try:
# xattr name is a bytes object, we directly use it.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_all(path, xattrs, follow_symlinks=False):\n if isinstance(path, str):\n path = os.fsencode(path)\n warning = False\n for k, v in xattrs.items():\n try:\n setxattr(path, k, v, follow_symlinks=follow_symlinks)\n except OSError as e:\n # note: platform.xattr... | [
"0.6320701",
"0.55420697",
"0.5457799",
"0.531721",
"0.5238313",
"0.5232355",
"0.5222333",
"0.52132016",
"0.5200607",
"0.5169005",
"0.49911028",
"0.49643806",
"0.49535906",
"0.480479",
"0.48016867",
"0.47861853",
"0.47584578",
"0.4731208",
"0.4717506",
"0.46894896",
"0.464641... | 0.79996324 | 0 |
Set up this platform for a specific ConfigEntry(==Gateway). | async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
async def async_discover(discovery_info: DiscoveryInfo) -> None:
"""Discover and add a MySensors sensor."""
mysensors.setup_mysensors_platform(
ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_setup_entry_gateway(hass, config_entry, async_add_entities):\n api = hass.data[DOMAIN][config_entry.entry_id][\"api\"]\n coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]\n\n entities = []\n switch_classes = [\"plug\", \"switch_group\"]\n\n all_devices = api.get_all... | [
"0.6461348",
"0.62020314",
"0.61107635",
"0.6081859",
"0.6049066",
"0.59690785",
"0.5960705",
"0.59341437",
"0.59322643",
"0.58968097",
"0.58958465",
"0.5891298",
"0.5835677",
"0.57888645",
"0.5782377",
"0.57703453",
"0.57316804",
"0.5725577",
"0.571871",
"0.5710234",
"0.5706... | 0.0 | -1 |
Return True if state updates should be forced. If True, a state change will be triggered anytime the state property is updated, not just when the value changes. | def force_update(self) -> bool:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on(self):\n if self.is_update_locked():\n return self.graceful_state\n if self._state['action'] == 1 and self._state['state'] == 2:\n return True\n return False",
"def update_state(self, force=False):\n if not force and time.time() - self.last_updated_at <... | [
"0.7352021",
"0.68483967",
"0.67604077",
"0.6739706",
"0.6698367",
"0.66888833",
"0.6679782",
"0.6679782",
"0.6679782",
"0.6679782",
"0.6679782",
"0.66680014",
"0.6620739",
"0.6605557",
"0.6564037",
"0.6564037",
"0.65255386",
"0.650659",
"0.64855486",
"0.6420593",
"0.6403902"... | 0.678565 | 2 |
Return the state of this entity. | def state(self) -> str | None:
return self._values.get(self.value_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n return self.get_state()",
"def getState(self):\n return self.state",
"def getState(self):\n return self.state",
"def getState(self):\n return self.state",
"def getState(self) :\n return self.state",
"def getState(self) -> None:\n return self.st... | [
"0.83650255",
"0.82515925",
"0.82515925",
"0.82515925",
"0.8231717",
"0.8165146",
"0.81334424",
"0.81334424",
"0.8123368",
"0.8123368",
"0.8102165",
"0.8098855",
"0.8098855",
"0.8073014",
"0.80673444",
"0.80554146",
"0.80554146",
"0.80554146",
"0.80554146",
"0.80554146",
"0.8... | 0.0 | -1 |
Return the device class of this entity. | def device_class(self) -> str | None:
return self._get_sensor_type()[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class"... | [
"0.88960886",
"0.88960886",
"0.88960886",
"0.88960886",
"0.88960886",
"0.88906753",
"0.8848185",
"0.88091695",
"0.88091695",
"0.88091695",
"0.8716641",
"0.86759204",
"0.8606744",
"0.8605054",
"0.8460027",
"0.8391178",
"0.83831364",
"0.83497155",
"0.8252572",
"0.8227272",
"0.8... | 0.8458741 | 15 |
Return the unit of measurement of this entity. | def unit_of_measurement(self) -> str | None:
set_req = self.gateway.const.SetReq
if (
AwesomeVersion(self.gateway.protocol_version) >= AwesomeVersion("1.5")
and set_req.V_UNIT_PREFIX in self._values
):
custom_unit: str = self._values[set_req.V_UNIT_PREFIX]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_of_measurement(self):\n return self._unit",
"def unit_of_measurement(self):\n return self._unit",
"def unit_of_measurement(self):\n return self._unit",
"def unit_of_measurement(self):\n return self._unit",
"def unit_of_measurement(self):\n return self._unit",
"... | [
"0.8798436",
"0.8798436",
"0.8798436",
"0.8798436",
"0.8798436",
"0.8798436",
"0.8798436",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.874902",
"0.8740797",
... | 0.73999214 | 85 |
Recursively merge 2 dictionaries. This does not use deepcopy (performance is too slow for large data) and thus it will modify the dict in place. | def merge_dicts(a, b):
if not isinstance(b, dict):
return b
result = a
for k, v in b.items():
if k in result and isinstance(result[k], dict):
result[k] = merge_dicts(result[k], v)
else:
result[k] = v
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_dictionaries(d1, d2):\n\n if d2 is None: \n return\n\n for k, v in d2.items():\n if k not in d1:\n d1[k] = dict()\n if isinstance(v, dict):\n merge_dictionaries(d1[k], v)\n else:\n d1[k] = v",
"def _merge_dicts(d1, d2):\n for key, va... | [
"0.81556773",
"0.81311816",
"0.8113898",
"0.80247134",
"0.80247134",
"0.79859436",
"0.79759693",
"0.79412216",
"0.7936173",
"0.7839935",
"0.7834071",
"0.7808992",
"0.7799202",
"0.7765704",
"0.7758297",
"0.7753694",
"0.7719996",
"0.7696061",
"0.7671423",
"0.76403594",
"0.75944... | 0.7722735 | 16 |
Implements the sigmoid activation in numpy | def sigmoid(Z):
A = 1/(1+np.exp(-Z))
cache = Z
return A, cache | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))",
"def sigmoid(X,W,b):\n preActivation = np.dot(X, W) + b\n return (1.0)/(1.0 + np.exp(-preActivation))",
"def sigmoid_activation(x):\n return 1.0 / (1 + np.exp(-x))",
"def sigmoid(x):\r\n return 1 / (1 + ... | [
"0.8374216",
"0.8308304",
"0.8258762",
"0.8215258",
"0.8150142",
"0.8140216",
"0.8140216",
"0.8140216",
"0.8140216",
"0.8140216",
"0.8140216",
"0.8125962",
"0.81212926",
"0.81212926",
"0.80962545",
"0.8082652",
"0.8068939",
"0.80095696",
"0.80017805",
"0.79810584",
"0.7977735... | 0.0 | -1 |
Read global_name from file. | def get_global(file_name, global_name):
import os
globals = {}
exec(open(os.path.join(os.path.dirname(__file__), "python_thing", file_name)).read(), globals)
return globals[global_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_name(self):\n attr = self.get_attr(Name)\n return attr.read()",
"def read_fname(self):\n return self.read_value()",
"def read_keyname(self):\n self.show(f'cat {self.keyname_file}')\n with open(self.keyname_file) as f:\n keyname = f.readline().strip()\n ... | [
"0.59745985",
"0.58837634",
"0.5870485",
"0.58154154",
"0.58154154",
"0.58154154",
"0.58154154",
"0.58154154",
"0.58154154",
"0.5808376",
"0.5786394",
"0.5714963",
"0.5705623",
"0.5657871",
"0.5647314",
"0.56199205",
"0.5600802",
"0.5590424",
"0.5570223",
"0.54580796",
"0.542... | 0.6218074 | 0 |
Standardizes features by removing mean and scaling to unit variance | def standardize(X):
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
return X_scaled | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardiser(self):\n # Select only numeric features first\n\n #self.X = self.data.loc[:, self.data.columns != self.target].values\n numeric_columns = []\n for col in self.X.columns:\n if self.X[col].dtype!='object':\n numeric_columns.append(col)\n s... | [
"0.75487155",
"0.7521557",
"0.7495686",
"0.73947674",
"0.7385628",
"0.7354648",
"0.7334214",
"0.7319599",
"0.73069733",
"0.7256114",
"0.7221183",
"0.7215637",
"0.711634",
"0.7098721",
"0.7031819",
"0.69738495",
"0.6965499",
"0.69235337",
"0.6922812",
"0.6913396",
"0.6900623",... | 0.7419897 | 3 |
Sets the id of this WritableDeviceType. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDeviceID(self, id, unitCode=0):\n resp = self.XAPCommand('DID', id, unitCode=unitCode)\n return int(resp)",
"def device_id(self, device_id):\n\n self._device_id = device_id",
"def device_id(self, device_id):\n\n self._device_id = device_id",
"def set_id(self, id):\n ... | [
"0.6817009",
"0.68146956",
"0.68146956",
"0.6639847",
"0.6567267",
"0.6519578",
"0.6503319",
"0.64753264",
"0.63503236",
"0.63503236",
"0.63503236",
"0.63479704"
] | 0.6346724 | 90 |
Sets the display_name of this WritableDeviceType. | def display_name(self, display_name):
self._display_name = display_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_display_name(self, device_display_name):\n\n self._device_display_name = device_display_name",
"def set_display_name(self, display_name):\n self._call('set_display_name', display_name=display_name)",
"def display_name(self, display_name: str):\n\n self._display_name = display_na... | [
"0.8149548",
"0.77492887",
"0.7404001",
"0.7239476",
"0.7239476",
"0.7239476",
"0.7239476",
"0.7239476",
"0.7239476",
"0.6616066",
"0.6500954",
"0.6167301",
"0.6152523",
"0.60852706",
"0.5996601",
"0.5826999",
"0.57595956",
"0.5620252",
"0.56112677",
"0.5611023",
"0.5578111",... | 0.7334337 | 7 |
Sets the part_number of this WritableDeviceType. | def part_number(self, part_number):
if part_number is not None and len(part_number) > 50:
raise ValueError("Invalid value for `part_number`, length must be less than or equal to `50`") # noqa: E501
self._part_number = part_number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setPartedPartition(self, partition):\n log_method_call(self, self.name)\n\n if partition is not None and not isinstance(partition, parted.Partition):\n raise ValueError(\"partition must be None or a parted.Partition instance\")\n\n log.debug(\"device %s new partedPartition %s\"... | [
"0.6395709",
"0.60988855",
"0.59004223",
"0.5726002",
"0.5687503",
"0.5654937",
"0.56267947",
"0.558915",
"0.5586271",
"0.54778904",
"0.5474286",
"0.544489",
"0.53740853",
"0.5331987",
"0.530239",
"0.5277876",
"0.5263698",
"0.52300066",
"0.51880205",
"0.5113544",
"0.5093287",... | 0.6581171 | 0 |
Sets the custom_fields of this WritableDeviceType. | def custom_fields(self, custom_fields):
self._custom_fields = custom_fields | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_profile_fields(self, custom_profile_fields):\n\n self._custom_profile_fields = custom_profile_fields",
"def custom_attributes(self, custom_attributes):\n\n self._custom_attributes = custom_attributes",
"def custom_data(self, custom_data):\n\n self._custom_data = custom_data",
... | [
"0.6226463",
"0.5989527",
"0.581636",
"0.56390154",
"0.54586655",
"0.53973055",
"0.53265536",
"0.5280839",
"0.5248794",
"0.52340144",
"0.52213675",
"0.52056193",
"0.50984114",
"0.5086562",
"0.49868515",
"0.49772623",
"0.4970455",
"0.4970455",
"0.4943328",
"0.4910179",
"0.4861... | 0.70801896 | 3 |
Sets the last_updated of this WritableDeviceType. | def last_updated(self, last_updated):
self._last_updated = last_updated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_updated(self, last_updated: str):\n\n self._last_updated = last_updated",
"def last_updated(self, value):\n self._last_updated = value",
"def last_update_timestamp(self, last_update_timestamp):\n\n self._last_update_timestamp = last_update_timestamp",
"def last_update(self, last... | [
"0.7123917",
"0.68401974",
"0.6402652",
"0.6358405",
"0.63043034",
"0.62346876",
"0.6219971",
"0.60855293",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.60068226",
"0.59992325",
"0.598691",
"0... | 0.7263649 | 2 |
Sets the device_count of this WritableDeviceType. | def device_count(self, device_count):
self._device_count = device_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_count(self, count):\n self._count = count",
"def set_count(self, count, asset=None):\n self._set_property('pc:count', count, asset)",
"def set_count(self, count):\n\n\t\tif count is not None and not isinstance(count, int):\n\t\t\traise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: count E... | [
"0.633868",
"0.60808736",
"0.6021513",
"0.5986852",
"0.5986852",
"0.5986852",
"0.5986852",
"0.5958499",
"0.5933162",
"0.57999253",
"0.571162",
"0.57091904",
"0.56384456",
"0.55507433",
"0.55486226",
"0.5534559",
"0.55004245",
"0.5462561",
"0.5429859",
"0.5416078",
"0.54113406... | 0.8161956 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, WritableDeviceType):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Adds a new softmax and fullyconnected layer for training. We need to retrain the top layer to identify our new classes, so this function adds the right operations to the graph, along with some variables to hold the weights, and then sets up all the gradients for the backward pass. | def add_final_training_ops(class_count, final_tensor_name, bottleneck_tensor,
bottleneck_tensor_size):
with tf.name_scope('input'):
bottleneck_input = tf.placeholder_with_default(
bottleneck_tensor,
shape=[None, bottleneck_tensor_size],
name='BottleneckInputPlace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_pass(self):\n # Have to use one_hot labels since sparse softmax doesn't allow\n # second derivatives.\n one_hot_train_labels = tf.one_hot(self.data.train_labels, self.way)\n train_embeddings_ = self.embedding_fn(\n self.data.train_images,\n depth_multiplier=self.depth_multipli... | [
"0.69956243",
"0.68404883",
"0.6745722",
"0.67423326",
"0.66896594",
"0.66883427",
"0.66473544",
"0.65983844",
"0.6484846",
"0.6465325",
"0.64633745",
"0.6461249",
"0.6452662",
"0.6438398",
"0.6425403",
"0.63217443",
"0.6315425",
"0.6314847",
"0.6306606",
"0.6284461",
"0.6232... | 0.68008125 | 2 |
r"""Initializes the lowest metric checkpoint writer. | def __init__(
self,
metric: str,
group: str = "eval",
stdout: bool = True,
**kwds: Any,
) -> None:
prefix = lowest_checkpoint_prefix(metric_label=metric, group_label=group)
super().__init__(metric, group, prefix=prefix, **kwds)
console.log(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_reporter(self):\n self._reporter.open(mode='w')\n self._reporter.write_thermodynamic_states(self._thermodynamic_states,\n self._unsampled_states)\n\n # Store run metadata and ReplicaExchange options.\n self._store_options(... | [
"0.6337783",
"0.6126731",
"0.60819036",
"0.6079826",
"0.60106874",
"0.5996427",
"0.59381",
"0.59315497",
"0.5916804",
"0.5904727",
"0.58976996",
"0.5838126",
"0.5795011",
"0.5713546",
"0.5685055",
"0.56691206",
"0.5624299",
"0.55987364",
"0.5594259",
"0.5587432",
"0.55826426"... | 0.59055495 | 9 |
r"""Initializes the highest metric checkpoint writer. | def __init__(
self,
metric: str,
group: str = "eval",
stdout: bool = True,
**kwds: Any,
):
prefix = lowest_checkpoint_prefix(metric_label=metric, group_label=group)
super().__init__(metric, group, prefix=prefix, **kwds)
console.log(
f"The ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self) -> None:\n self.metrics = {}\n self.current = None\n self.run = None",
"def _initialize_reporter(self):\n self._reporter.open(mode='w')\n self._reporter.write_thermodynamic_states(self._thermodynamic_states,\n ... | [
"0.6221882",
"0.6209097",
"0.6012857",
"0.5991224",
"0.5984746",
"0.5981619",
"0.59674007",
"0.5937154",
"0.5867477",
"0.58594817",
"0.5857366",
"0.58413243",
"0.58328134",
"0.5820313",
"0.5699227",
"0.5695059",
"0.5695059",
"0.5642132",
"0.5617906",
"0.5594201",
"0.5580388",... | 0.59033865 | 8 |
String of data about the table. | def __str__(self):
return ', '.join([self.yftf_data, self.info_hash, str(self.num_pieces), str(self.peers)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n\n table_list = [self.headers]\n\n for row in self.data:\n table_list.append([row[col] or \"\" for col in self.headers])\n\n return create_table_string(table_list)",
"def html_data_table(self):\n return \"XXX\"",
"def get_string(self):\n this_co... | [
"0.7974366",
"0.7752018",
"0.7432076",
"0.7410597",
"0.73566025",
"0.73501647",
"0.72819215",
"0.72650623",
"0.7242251",
"0.70667744",
"0.70608014",
"0.7003432",
"0.7000975",
"0.6981335",
"0.6966772",
"0.6882096",
"0.6874453",
"0.6857732",
"0.67458314",
"0.67401105",
"0.66823... | 0.0 | -1 |
r""" Do the estimator optimization step. Usefull when computing gradients across several steps/batches and optimizing using the accumulated gradients. | def update_estimator(self):
self.optimizer.step()
self.optimizer.zero_grad() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimizer_step(self, epoch, batch_idx, optimizer, optimizer_idx, second_order_closure=None):\n # if self.trainer.use_tpu:\n # xm.optimizer_step(optimizer)\n # else:\n # optimizer.step()\n optimizer.step()\n optimizer.zero_grad()\n\n # need to define here... | [
"0.7033555",
"0.69779474",
"0.6892027",
"0.68874633",
"0.6860204",
"0.6856823",
"0.67698336",
"0.6745149",
"0.6743444",
"0.67368054",
"0.6672701",
"0.6638408",
"0.6638389",
"0.66371375",
"0.66343653",
"0.6616669",
"0.659877",
"0.65827596",
"0.6573586",
"0.6572765",
"0.6535152... | 0.74803805 | 1 |
download_latex Downloads latex from arxiv as a tar file in the `self.paper_root_path`. Ideally called seperately from the `mine_paper` method or from the ArxivPaper(build_paper=True) It will just download the latex tar source. | def download_latex(self):
try:
# $ Set the Arxiv Object to ensure Proper extraction
identity,paper = self.extract_meta_from_remote(self.paper_id)
self.identity = identity
if not dir_exists(self.paper_root_path):
os.makedirs(self.paper_root_path)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download(self):\n self._system.download(\"http://geant4.web.cern.ch/geant4/support/source/\" + self._tar_name)",
"def _build_paper(self,save_data=True,store_latex=False):\n try:\n # $ Set the Arxiv Object to ensure Proper extraction\n identity,paper = self.extract_meta_fr... | [
"0.5867368",
"0.5609417",
"0.55654997",
"0.55267787",
"0.5392388",
"0.53666675",
"0.5360486",
"0.5337258",
"0.5287813",
"0.52505654",
"0.52386224",
"0.52144915",
"0.51870066",
"0.51612914",
"0.514488",
"0.5143402",
"0.51158744",
"0.5086015",
"0.50707835",
"0.50592184",
"0.503... | 0.8018099 | 0 |
freezes weights of the input layer | def dfs_freeze(self, model):
for name, child in model.named_children():
for param in child.parameters():
param.requires_grad = False if self.freeze_flag else True
self.dfs_freeze(child) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self):\n\n self.weights -= self.loss_grads\n self.loss_grads = np.zeros(self.weights.shape)",
"def freeze_mo... | [
"0.7281546",
"0.69291824",
"0.68560183",
"0.6833448",
"0.6663273",
"0.6656298",
"0.66336745",
"0.66292495",
"0.66292495",
"0.66292495",
"0.6569869",
"0.656191",
"0.6555251",
"0.65177983",
"0.65020293",
"0.6495656",
"0.64764893",
"0.6455338",
"0.6452497",
"0.6452497",
"0.64461... | 0.0 | -1 |
adjust learning rate and weights decay | def weights_decay(self):
for param_group in self.optimizer.param_groups:
for param in param_group['params']:
param.data = param.data.add(-1.*self.weights_decay * param_group['lr'], param.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decay(self):\n if self.l_rate > self.l_rate_bound[0] and self.l_rate - self.decay_rate > 0.0:\n self.l_rate -= self.decay_rate\n elif self.l_rate - self.decay_rate <= 0.0 or self.l_rate < self.l_rate_bound[0]:\n self.l_rate = self.l_rate_bound[0]\n\n for layer in self... | [
"0.7796024",
"0.772269",
"0.772269",
"0.7708068",
"0.759695",
"0.759225",
"0.7583436",
"0.755238",
"0.7478743",
"0.74650764",
"0.7440892",
"0.743856",
"0.74214333",
"0.74017316",
"0.7381381",
"0.73758715",
"0.7356456",
"0.7342442",
"0.7333016",
"0.7304729",
"0.7276835",
"0.... | 0.76752096 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.