query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Generates a new access key on behalf of the user and stores the new access key in secrets manager. Then, send a notification email to users to notify them to rotate the key for their applications. It returns a JSON with status 200 if successful and 500 if error occurs. | def create_key(iam_username):
try:
response = iam.create_access_key(UserName=iam_username)
access_key = response["AccessKey"]["AccessKeyId"]
secret_key = response["AccessKey"]["SecretAccessKey"]
json_data = json.dumps({"AccessKey": access_key, "SecretKey": secret_key})
secre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def generate_new_refesh_key(payload: dict = Depends(get_jwt_payload)):\n if payload[\"type\"] != \"refresh\":\n raise HTTPException(\n status_code=status.HTTP_401_UNAUTHORIZED,\n detail=\"You gave the access key, but we need the refresh key\",\n headers={\"WWW-Authe... | [
"0.67813015",
"0.6723537",
"0.63754004",
"0.62938106",
"0.62400305",
"0.6215626",
"0.61407065",
"0.60760754",
"0.59956634",
"0.5931377",
"0.5928745",
"0.58910877",
"0.58691543",
"0.58685136",
"0.5854402",
"0.5829179",
"0.58209795",
"0.58133996",
"0.5811484",
"0.5800694",
"0.5... | 0.72491354 | 0 |
Finds the secret that stores the user's previous access key and mark it as inactive. Then, send a notification email to users to remind them to rotate the key for their applications. It returns a JSON with status 200 if successful and 500 if error occurs. | def deactive_key(iam_username):
try:
previous_secret_value = secretmanager.get_secret_value(
SecretId=iam_username, VersionStage="AWSPREVIOUS"
)
previous_secret_data = json.loads(previous_secret_value["SecretString"])
previous_access_key = previous_secret_data["AccessKey... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh():\n print(\"refresh request\")\n old_token = flask.request.get_data()\n new_token = guard.refresh_jwt_token(old_token)\n ret = {'access_token': new_token}\n return ret, 200",
"def delete_key(iam_username):\n try:\n previous_secret_value = secretmanager.get_secret_value(\n ... | [
"0.5759315",
"0.5734272",
"0.5650095",
"0.5646816",
"0.5642398",
"0.5619801",
"0.5599194",
"0.55985004",
"0.55931413",
"0.5589347",
"0.5573661",
"0.5572305",
"0.55686045",
"0.5555417",
"0.55408806",
"0.5533225",
"0.5484143",
"0.5463325",
"0.534115",
"0.533586",
"0.5316812",
... | 0.685774 | 0 |
Deletes the deactivated access key in the given iam user. Returns a JSON with status 200 if successful, 500 for error and 400 for if secrets don't match | def delete_key(iam_username):
try:
previous_secret_value = secretmanager.get_secret_value(
SecretId=iam_username, VersionStage="AWSPREVIOUS"
)
previous_secret_string = json.loads(previous_secret_value["SecretString"])
previous_access_key_id = previous_secret_string["Acces... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deactive_key(iam_username):\n\n try:\n previous_secret_value = secretmanager.get_secret_value(\n SecretId=iam_username, VersionStage=\"AWSPREVIOUS\"\n )\n previous_secret_data = json.loads(previous_secret_value[\"SecretString\"])\n previous_access_key = previous_secret... | [
"0.7378329",
"0.6966406",
"0.64946246",
"0.6346771",
"0.6233794",
"0.6199667",
"0.61746794",
"0.61187524",
"0.60900825",
"0.6088945",
"0.60781866",
"0.6069097",
"0.60592043",
"0.6021645",
"0.6012084",
"0.60058826",
"0.5992973",
"0.5984061",
"0.59763664",
"0.59674704",
"0.5959... | 0.75573766 | 0 |
Set shipping method code to session | def use_shipping_method(self, code):
self.reset_shipping_data()
self._set('shipping', 'method_code', code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shipping(self, shipping):\n\n self._shipping = shipping",
"def shipping_address(self, shipping_address):\n\n self._shipping_address = shipping_address",
"def testGetShippingMethod_1(self):\n sm = IShippingMethodManagement(self.shop)\n result = sm.getShippingMethod(\"standard\") ... | [
"0.602121",
"0.53840065",
"0.5270917",
"0.5183563",
"0.51068664",
"0.5073794",
"0.5042011",
"0.5003892",
"0.49591094",
"0.49442613",
"0.49238464",
"0.4921968",
"0.49034277",
"0.4883319",
"0.4882863",
"0.48542213",
"0.4845555",
"0.4836239",
"0.4805226",
"0.47952917",
"0.479377... | 0.7467533 | 0 |
Use an user address (from an address book) as the shipping address. | def ship_to_user_address(self, address):
self._set('shipping', 'user_address_id', address.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAddress(user):",
"def shipping_address(self):\n return Address(self._dict.get('shipping_address'))",
"def save(self, *args, **kwargs):\n # Save a hash of the address fields so we can check whether two\n # addresses are the same to avoid saving duplicates\n # self.hash = self.... | [
"0.68491834",
"0.6695661",
"0.6635431",
"0.66109383",
"0.64996356",
"0.6478959",
"0.6478959",
"0.6478959",
"0.6465444",
"0.6411921",
"0.63655895",
"0.61791503",
"0.6002287",
"0.5854126",
"0.5840045",
"0.5776004",
"0.5775618",
"0.57732123",
"0.5747832",
"0.5733758",
"0.5685640... | 0.75003034 | 0 |
Test whether a shipping address has been stored in the session. This can be from a new address or reusing an existing address. | def is_shipping_address_set(self):
new_fields = self.new_shipping_address_fields()
has_new_address = new_fields is not None
user_address_id = self.shipping_user_address_id()
has_old_address = user_address_id is not None and user_address_id > 0
pickup_address_id = self.shipping_pi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_address(self, address):\n\n if self.filter(to_address=address).count() > 0: # @@@ is there a better way?\n return True\n else:\n return False",
"def has_receipt_address(self):\n return self.receipt_address_uploaded_at is not None",
"def has_shipping_event_occ... | [
"0.6365854",
"0.6346233",
"0.6326736",
"0.60884136",
"0.58772856",
"0.5818822",
"0.5744287",
"0.56609917",
"0.5641724",
"0.56350905",
"0.56350905",
"0.56350905",
"0.56343895",
"0.5616543",
"0.553363",
"0.54556155",
"0.53936595",
"0.53936595",
"0.53936595",
"0.53936595",
"0.53... | 0.7609928 | 0 |
Compila el shader cargado | def compile(self):
if not self.isCompiled():
if self.file is not None:
try:
if self.tipo == VERTEX:
self.shader = glCreateShader(GL_VERTEX_SHADER)
else:
self.shader = glCreateShader(GL_FRAGMENT_SH... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_shaders(self):\n raise NotImplementedError()",
"def get_shader_codes(self):\n vs = VS_TEMPLATE\n fs = FS_TEMPLATE\n \n # Shader headers\n vs_header = self.get_header('vertex')\n fs_header = self.get_header('fragment')\n \n # Varyings\n ... | [
"0.68262887",
"0.662705",
"0.6518068",
"0.64967304",
"0.64866763",
"0.6429076",
"0.64011216",
"0.64011216",
"0.6198539",
"0.6187425",
"0.6128186",
"0.6126346",
"0.610296",
"0.60181737",
"0.6008351",
"0.59910846",
"0.59632754",
"0.59215707",
"0.5850446",
"0.5846655",
"0.583602... | 0.74690944 | 0 |
Retorna el fragment shader | def getFragmentShader(self):
return self.fshader | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_fragment_shader(source):\n fragment_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)\n gl.glShaderSource(fragment_shader, source)\n gl.glCompileShader(fragment_shader)\n # check compilation error\n result = gl.glGetShaderiv(fragment_shader, gl.GL_COMPILE_STATUS)\n if not(result):\n ... | [
"0.6890572",
"0.68132526",
"0.67081916",
"0.6055252",
"0.60140264",
"0.6013074",
"0.59677196",
"0.5960698",
"0.59439474",
"0.59253937",
"0.59027255",
"0.5896981",
"0.58820647",
"0.58708715",
"0.58189094",
"0.58176094",
"0.5803716",
"0.5782153",
"0.57444",
"0.5740447",
"0.5740... | 0.768557 | 0 |
Retorna el programa compilado | def getCompiled(self):
if self.isCompiled():
return self.program
else:
raise Exception("el programa no ha sido compilado aun") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_executable(self) -> str:\n ...",
"def prog():\n global program\n return program",
"def executable():\n return sys.executable",
"def get_program(report=MAIN_REPORT) -> str:\n return report.submission.main_code",
"def find_program(name):\r\n return name",
"def build(self, ... | [
"0.74845237",
"0.6837721",
"0.675287",
"0.6704828",
"0.6608522",
"0.6601868",
"0.6425982",
"0.6380863",
"0.6377142",
"0.6365536",
"0.63150835",
"0.6314957",
"0.6303876",
"0.6292931",
"0.62422407",
"0.61862063",
"0.6180889",
"0.6174088",
"0.6171033",
"0.6126043",
"0.6125988",
... | 0.71376365 | 1 |
Funcion que carga un shader y retorna un objeto del tipo ShaderProgram | def loadShader(shaderpath, shadername, vertexFormatList=None, fragmentFormatlist=None):
fragment = Shader(shaderpath + shadername + ".fsh", FRAGMENT, True, fragmentFormatlist)
vertex = Shader(shaderpath + shadername + ".vsh", VERTEX, True, vertexFormatList)
return ShaderProgram(vertex, fragment, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile(self, mode, shader):\n holder = self.holderDepend( mode.cache.holder(self,None) )\n # TODO: depend on shader.material as well...\n # TODO: the compiled shader needs to depend on *everything* \n # down the set of objects...\n program = glCreateProgram()\n holder... | [
"0.72277695",
"0.6766529",
"0.66922075",
"0.6681505",
"0.6595262",
"0.6556438",
"0.65519035",
"0.65351266",
"0.6511268",
"0.64995193",
"0.64350396",
"0.63047755",
"0.6298951",
"0.6298951",
"0.6281866",
"0.62657887",
"0.624835",
"0.6235149",
"0.6185762",
"0.6185244",
"0.616241... | 0.7750893 | 0 |
Apply the module's layers (the fully connected network, then the unflatten/reshaping) to feature maps to obtain decoded images. | def layers(self, features: Dict[str, torch.Tensor]) -> torch.Tensor:
features: torch.Tensor = features[self.in_feature] # type: ignore[no-redef]
decoded_images = self.network(features)["out"]
decoded_images = self.reshape(decoded_images)
return decoded_images | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def layers(self, features: Dict[str, torch.Tensor]) -> torch.Tensor:\n x: torch.Tensor\n for i, f in enumerate(self.in_features):\n if i == 0:\n x = self.scale_heads[i](features[f])\n else:\n x = x + self.scale_heads[i](features[f])\n x = sel... | [
"0.6359501",
"0.6348598",
"0.6348598",
"0.62784237",
"0.5992665",
"0.59650975",
"0.59417313",
"0.58667",
"0.5792423",
"0.57914174",
"0.5780968",
"0.5764337",
"0.5759375",
"0.5731812",
"0.5703725",
"0.57027936",
"0.56589323",
"0.56437796",
"0.56402093",
"0.5613541",
"0.5583868... | 0.69263995 | 0 |
Method to create A_B_X testing directories and return the corresponding answer key An A file is chosen from either the scenario one or two with a 50/50 probability. The B file is then from the scenario not chosen for A. An X file is then created with a 50/50 probability of being either a duplicate of A or B | def create_A_B_X_cases(A_B_cases_zip_list, output_path):
logging.info("Enter: create_A_B_X_cases ")
global scenario_one
global scenario_two
global answer_key
# create listening directories and record answer to each in answer_log
for case_num, case in enumerate(A_B_cases_zip_list):
#MRR I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_folders(rho, kappa, km, pa, analysis, dbase, analysisdbase):\n \n path1 = 'density_' + + str(rho) + \"_kappa_\" + \\\n str(kappa) + \"_km_\" + str(km) + \"_panti_\" + str(pa)\n path2 = analysis + '_density_' + + str(rho) + \"_kappa_\" + \\\n str(kappa) + \"_km_\" + str(km) + \"_panti... | [
"0.5836952",
"0.5745993",
"0.564938",
"0.5633649",
"0.56305355",
"0.5525796",
"0.5495101",
"0.54933995",
"0.54835606",
"0.5473215",
"0.54551697",
"0.5454278",
"0.54430914",
"0.5419843",
"0.540383",
"0.539461",
"0.535103",
"0.53062385",
"0.52939874",
"0.52791905",
"0.52594274"... | 0.7262688 | 0 |
Gets the notes that match the IDs in the given list | def get_notes_by_id(self, ids: List[str]) -> pd.Series:
return self.notes[self.notes.apply(lambda n: n.id in ids)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_notes_from_uuids(dictionary, uuid_list):\n titles = []\n texts = []\n notes = []\n for key in dictionary:\n if dictionary[key][\"content_type\"] == \"Note\" and dictionary[key][\"uuid\"] in uuid_list:\n try:\n titles.append(dictionary[key][\"content\"][\"title\"... | [
"0.7044959",
"0.6312594",
"0.6240239",
"0.61434144",
"0.61095756",
"0.6058194",
"0.5978123",
"0.59549475",
"0.58659506",
"0.5835077",
"0.58136547",
"0.58040994",
"0.57839704",
"0.57750845",
"0.5765075",
"0.5731137",
"0.57039005",
"0.56773746",
"0.5671533",
"0.56606317",
"0.56... | 0.73300874 | 0 |
Gets the notes that match the given type | def get_notes_by_type(self, typ: type) -> pd.Series:
# doesn't use isinstance() to prevent subtypes from being selected
return self.notes[self.notes.apply(lambda n: type(n) is typ)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_notes(notes_type=\"national\", area=None):\n query_menu = get_query_menu(area)\n query = query_menu[notes_type][\"query\"]\n collection = query_menu[notes_type][\"collection\"]\n notes = \"\"\n try:\n doc = next(collection.find(query).sort([(DATE_KEY, -1)]).limit(1))\n notes = ... | [
"0.7363224",
"0.6635593",
"0.63884705",
"0.6299145",
"0.6193865",
"0.6096751",
"0.60615337",
"0.5944401",
"0.59381264",
"0.5937519",
"0.58960897",
"0.58934313",
"0.5889689",
"0.5879493",
"0.586823",
"0.58652633",
"0.5864108",
"0.5845779",
"0.5845779",
"0.583218",
"0.578814",
... | 0.7819434 | 0 |
Gets ids of transactions that have been manually categorized as the given category | def manual_ids(self, cat: str) -> np.ndarray:
return self.notes[
# select from notes
self.notes.apply(
# the ones which are both a Category type and have a matching categorization
lambda n: isinstance(n, note.Category) and n.category == cat
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transactions_by_budget(self, category: BudgetCategory) -> list:\n return [transaction\n for transaction in self.transactions\n if transaction.budget_category == category]",
"def getCatIds(self, catNms=[], supNms=[], catIds=[]):\n catNms = catNms if _isArrayLike... | [
"0.6701687",
"0.64718974",
"0.6376415",
"0.62155205",
"0.59986377",
"0.59729415",
"0.58339447",
"0.58204085",
"0.5767695",
"0.5723693",
"0.56843686",
"0.54860526",
"0.5470421",
"0.5439508",
"0.5331767",
"0.5300631",
"0.522782",
"0.5191241",
"0.5157344",
"0.5154198",
"0.513863... | 0.65853906 | 1 |
Gets ids of transactions that target those in the given DataFrame Example Transactions A and B are both linked to transaction C, which appears in the given DataFrame Returns a Series of ids that include the ids of A and B Returns | def linked_ids(self, df: pd.DataFrame) -> np.ndarray:
return self.notes[
# select from notes
self.notes.apply(
# the ones which are both a Link type and have a target id in the given DataFrame
lambda n: isinstance(n, note.Link) and n.target in df['id'].va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_same_amount(df):\n ids = list(df['id'][df.duplicated(['amount','branch_id','exchange_id'],keep= False)==True].values)\n return ids",
"def txn_data(df, txns):\n return df[df.transaction_id.isin(txns)].copy()",
"def _find_transactions(self, df: DataFrame, transaction_column: str, status: Option... | [
"0.61653596",
"0.5769028",
"0.56417054",
"0.52235144",
"0.52106684",
"0.5191913",
"0.5150917",
"0.5081459",
"0.48569995",
"0.48390487",
"0.48366696",
"0.48233128",
"0.4806864",
"0.48062918",
"0.47854108",
"0.47808558",
"0.47644168",
"0.4763787",
"0.47513548",
"0.47412938",
"0... | 0.6334611 | 0 |
Applies Link notes in the given DataFrame, adding the value of each linked transaction onto the one it targets The DataFrame needs to include both the original transactions and the ones linked to them. The values of the linked transactions will be set to 0 as they are added onto the target transaction | def apply_linked(self, df: pd.DataFrame) -> pd.DataFrame:
link_notes = self.get_notes_by_type(note.Link)
source_in_df = link_notes.apply(lambda n: n.id in df['id'].values)
target_in_df = link_notes.apply(lambda n: n.target in df['id'].values)
# assert (target_in_df & ~source_in_df).any(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_target(self):\n df = self.get_all_data()\n target_df = self.get_target_df().copy(deep=True)\n target_df['ft_data_dt'] = target_df['ft_data_dt'].astype('datetime64[M]') - pd.DateOffset(months=2) + MonthEnd(1)\n df = df.merge(target_df, on=['idd', 'ft_data_dt'], how='left')\n ... | [
"0.57571226",
"0.56453544",
"0.55956817",
"0.52005714",
"0.5119747",
"0.50915694",
"0.5087886",
"0.5079737",
"0.50389576",
"0.50111914",
"0.49917713",
"0.49096105",
"0.48220557",
"0.48141253",
"0.47970462",
"0.47765523",
"0.4753686",
"0.47471696",
"0.47465235",
"0.47281483",
... | 0.83887 | 0 |
Get API_KEY that is set environment variant | def get_apikey(cls) -> str:
dotenv_path = Path(__file__).absolute().parents[2] / '.env'
if dotenv_path.exists():
load_dotenv(dotenv_path)
try:
apikey: str = os.environ["API_KEY"]
except KeyError:
print("API_KEY doesn't exist")
raise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_api_key():\n if not os.getenv(\"SPOON_API_KEY\"):\n raise RuntimeError(\"SPOON_API_KEY is not set\")\n return os.getenv(\"SPOON_API_KEY\")",
"def get_api_key():\n try:\n return os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"]\n except Exception:\n raise EnvErro... | [
"0.8036626",
"0.801071",
"0.79444003",
"0.7788649",
"0.7664907",
"0.7644209",
"0.7598372",
"0.7510571",
"0.73695594",
"0.7326174",
"0.7326174",
"0.73016196",
"0.72453666",
"0.7241101",
"0.7237927",
"0.7237927",
"0.7237927",
"0.7237927",
"0.72267175",
"0.71169055",
"0.71147156... | 0.8249006 | 0 |
Search 60 places that are nearby specified location. Parameter | def search_nearby(self, fields: dict) -> list[dict]:
results: list = []
if "location" not in fields.keys():
geolocate: dict = self.get_current_locate()
fields["location"] = geolocate["location"]
if "radius" not in fields.keys():
fields["radius"] = 10... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def near(self, meters):\n lng = self.position['coordinates'][0]\n lat = self.position['coordinates'][1]\n\n return Location.objects(position__near=[lng, lat], position__max_distance=meters)",
"def test_search_location(objectsearch):\n objectsearch.search(location=WithinDistance(Point(1000... | [
"0.6802248",
"0.6787309",
"0.6689226",
"0.65858716",
"0.64827025",
"0.64530396",
"0.64401865",
"0.63876253",
"0.631838",
"0.6256203",
"0.6209302",
"0.61736834",
"0.6144619",
"0.61386645",
"0.6098552",
"0.6091408",
"0.60741055",
"0.60671294",
"0.60598874",
"0.6050784",
"0.6034... | 0.71345127 | 0 |
Get photo image chunk from photo reference of google map api. The place photo will be converted to base64 to display on browser. ex) place = googlemaps.Client(key=apikey).place(place_id) photos = self.get_place_photo(place["result"]["photos"]["reference"]) Parameter | def get_place_photo(self, photo_ref: str) -> str:
photo_bin = self.gmaps.places_photo(photo_ref, max_width=1000)
photo = base64.b64encode(b''.join(photo_bin)).decode()
return photo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_photo(self, photo_id):\n uri = 'photos/' + photo_id\n return self.make_request(uri)",
"def get_photo(self):\n photo_box = self.soup.find(attrs={\"class\": \"woocommerce-product-gallery__wrapper\"}).contents\n return list(filter(lambda x: isinstance(x, Tag), photo_box))[0].contents[0].... | [
"0.6057941",
"0.576079",
"0.5713087",
"0.56178224",
"0.55563056",
"0.554258",
"0.55014175",
"0.54998815",
"0.54686993",
"0.54554206",
"0.5358555",
"0.53123784",
"0.5278585",
"0.5270665",
"0.52530926",
"0.5248939",
"0.52462256",
"0.52333075",
"0.52333075",
"0.5223155",
"0.5213... | 0.7682175 | 0 |
Formats the given date in RFC 3339 format for feeds. | def rfc3339date(date):
if not date: return ''
date = date + datetime.timedelta(seconds=-time.timezone)
if time.daylight:
date += datetime.timedelta(seconds=time.altzone)
return date.strftime('%Y-%m-%dT%H:%M:%SZ') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_date(self, data):\r\n if self.datetime_formatting == 'rfc-2822':\r\n return format_date(data)\r\n\r\n return data.isoformat()",
"def format_date(d):\n if type(d) == str:\n d = dateutil_parse(d)\n return d.isoformat()",
"def datetime_to_rfc3339(dt_obj):\n\n re... | [
"0.69384325",
"0.6525385",
"0.65015775",
"0.6357035",
"0.6209512",
"0.6191173",
"0.6157671",
"0.59872574",
"0.59804356",
"0.59689796",
"0.59643936",
"0.5922877",
"0.5816518",
"0.58079654",
"0.5753731",
"0.5708772",
"0.56648386",
"0.5654911",
"0.56407833",
"0.56145847",
"0.558... | 0.6728661 | 1 |
timer function for comparing running times of NN algorithms. Returns a tuple of runtime and predicted labels | def timer(trainX, trainY, testX, k, condensed=False):
gc.disable() # disable garbage collector for uninterrupted timing
initial = clock()
if condensed:
cnn = condenseData(trainX, trainY)
testY = testknn(trainX[cnn], trainY[cnn], testX, k)
else:
testY = testknn(trainX, tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runtime(self):\n return self.tmax_epochs - self.tmin_epochs",
"def time_models(x_tr, x_te, y_tr, y_te, mod_list, mod_labels, time_obj, count=0, keep=True, show=True, cls_lab=None):\n \n durations = {}\n \n for m in mod_list:\n if show:\n time_obj.start()\n eval... | [
"0.6847096",
"0.6172901",
"0.612823",
"0.60137117",
"0.60005206",
"0.5954866",
"0.59488994",
"0.59427047",
"0.59117776",
"0.5894083",
"0.58933216",
"0.5865234",
"0.582217",
"0.578797",
"0.57498205",
"0.57353336",
"0.5707557",
"0.5707501",
"0.5700795",
"0.5697903",
"0.5695413"... | 0.67268896 | 1 |
computes accuracy given a confusion matrix | def accuracy(confusion_matrix):
return confusion_matrix.diagonal().sum() / confusion_matrix.sum() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(y_true, y_pred):\r\n\r\n cm = confusion_matrix(y_true=y_true, y_pred=y_pred)\r\n cost_m = np.max(cm) - cm\r\n indices = linear_sum_assignment(cost_m)\r\n indices = np.asarray(indices)\r\n indexes = np.transpose(indices)\r\n total = 0\r\n for row, column in indexes:\r\n valu... | [
"0.82432413",
"0.8086844",
"0.7770486",
"0.76201636",
"0.7553393",
"0.7519348",
"0.748617",
"0.74300957",
"0.7417371",
"0.74166125",
"0.74125",
"0.7397998",
"0.7365483",
"0.7365483",
"0.73548406",
"0.7354824",
"0.7353345",
"0.7288637",
"0.7263474",
"0.7258797",
"0.725808",
... | 0.8702742 | 0 |
Thread worker function this does the actual pinging and records ping data in the ring buffers for processing into latency statistics as needed. | def run(self):
rate = WallRate(self.ping_frequency)
while True:
# In case of failure, this call will take approx 10s
try:
# Send 5 pings at an interval of 0.2s
output = subprocess.check_output("ping -c 1 %s" % self.ip,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ping_thread(state):\n while state.running:\n time.sleep(PING_FREQ)\n # for nick in users:\n # users[nick].queue.append(('SERVER', 'PING'))",
"def _ping(self):\n\n self.last_ping = time.time()\n try:\n logger.debug(\"(%s) PING\", self.device[\"ip\"])\n ... | [
"0.63765913",
"0.6280568",
"0.6060188",
"0.6038498",
"0.5961879",
"0.59072685",
"0.5780628",
"0.5774365",
"0.57292193",
"0.57025075",
"0.5629364",
"0.5629364",
"0.5629364",
"0.5629364",
"0.55843896",
"0.5569475",
"0.55366915",
"0.55338436",
"0.5515096",
"0.550321",
"0.5489618... | 0.7087622 | 0 |
Python method for retrieving local volatility matrix to have more control over the input parameters | def GetLocalVol(volInfo, isCall, forwardArray, strikeArray, timeGrid, valuationDate, skewExpiries):
if timeGrid.Size() == 0:
return acm.FRealMatrix()
return volInfo.LocalVolatilityMatrix(isCall, forwardArray, strikeArray, timeGrid, 0.001, valuationDate, skewExpiries) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_volatility(input_df, params=None):\n\n if params is None:\n raise ValueError(\"Please set the corresponding Interval parameter\"\n \"{interval:Ct.INTERVAL.MONTH|Ct.INTERVAL.DAY}\")\n\n if Ct.neg_volatility_key() not in params.keys():\n params[... | [
"0.57678425",
"0.5691322",
"0.5612303",
"0.55843663",
"0.55843663",
"0.5578491",
"0.5575503",
"0.555768",
"0.55442214",
"0.5471557",
"0.54699177",
"0.54637486",
"0.5463171",
"0.54377127",
"0.5412676",
"0.5388977",
"0.53818846",
"0.53685796",
"0.53279614",
"0.5318264",
"0.5287... | 0.7782742 | 0 |
Performs the GET/POST calls to the aXAPI REST interface. | def call_api(axobjectinstance, **args):
if AXAPI_LOGIN == 1:
args["session_id"] = AXAPI_SESSION_ID
if args.has_key("post_data"):
data = args["post_data"]
del args["post_data"]
url_str = _get_request_url()+"?"+urllib.urlencode(args)
else:
data = urllib.urlencode(args... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_GET(self):\n self.http_method = 'GET'\n self.response()",
"def do_POST(self):\r\n self.do_GET()",
"def do_GET(self):\n self._try_to_process_request(self._handle_get_request)",
"def make_api_call(action, parameters = {}, method = 'get', data = {}):\n headers = {\n ... | [
"0.6624271",
"0.6195906",
"0.61714697",
"0.6120261",
"0.61064416",
"0.6102867",
"0.6097652",
"0.6097652",
"0.60949004",
"0.60787547",
"0.6071082",
"0.6070743",
"0.60207456",
"0.5997099",
"0.59953606",
"0.5994118",
"0.5994118",
"0.5994118",
"0.5932638",
"0.5919009",
"0.5915908... | 0.6268135 | 1 |
Parses a JSON request string to an instance of the Request class. | def parse_request(json_data: str) -> Request:
logger.debug('Type: {}'.format(type(json_data)))
data = json.loads(json_data)
return Request(
data["text"],
PatternCategory(data["previous_pattern"]
) if "previous_pattern" in data else None,
data["mood"],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(json_string: str) -> AnalysisRequest:\n dict_obj = json.loads(json_string)\n\n # make sure the required parameters are present\n required_fields = [\"request_id\"]\n\n for field in required_fields:\n if field not in dict_obj:\n raise Exception(\"JSON string does not repr... | [
"0.6887064",
"0.66786635",
"0.6615436",
"0.6570916",
"0.65383154",
"0.6497711",
"0.6395444",
"0.6340051",
"0.6320801",
"0.6210021",
"0.6135562",
"0.6114312",
"0.61106163",
"0.60922366",
"0.6053376",
"0.6031963",
"0.6012315",
"0.5964775",
"0.5964775",
"0.5919758",
"0.58647394"... | 0.7143485 | 0 |
Test that viewlist does not show when not signed in | def testviewlist(self):
rv = self.app.get('/viewcategory')
self.assertEqual(rv.status_code, 302, "viewlist page should not load unless signed in") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_show_list_not_signed_in(self):\n with self.client as c:\n\n res = c.get(\"/lists/111111\")\n html = res.get_data(as_text=True)\n\n self.assertEqual(res.status_code, 200)\n self.assertIn(\"title1\", html)\n self.assertIn(\"tester1\", html)\n ... | [
"0.74585307",
"0.7115753",
"0.67430013",
"0.6679924",
"0.6672844",
"0.66420466",
"0.659895",
"0.6596849",
"0.65905243",
"0.65247446",
"0.6443451",
"0.6420938",
"0.64023024",
"0.63713837",
"0.6369523",
"0.6331869",
"0.632814",
"0.632814",
"0.632814",
"0.632814",
"0.6324371",
... | 0.7162531 | 1 |
Test that createlist does not show when not signed in | def testcreatelist(self):
rv = self.app.get('/createcategory')
self.assertEqual(rv.status_code, 302, "createlist page should not load unless signed in") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_show_list_not_signed_in(self):\n with self.client as c:\n\n res = c.get(\"/lists/111111\")\n html = res.get_data(as_text=True)\n\n self.assertEqual(res.status_code, 200)\n self.assertIn(\"title1\", html)\n self.assertIn(\"tester1\", html)\n ... | [
"0.73056394",
"0.7027877",
"0.6963746",
"0.69002676",
"0.6806317",
"0.6752402",
"0.66345125",
"0.66219074",
"0.66180396",
"0.66056967",
"0.649849",
"0.64591557",
"0.6421004",
"0.6416299",
"0.6413",
"0.6399706",
"0.63894516",
"0.63871354",
"0.63751173",
"0.6373486",
"0.6373189... | 0.74919474 | 0 |
Compare a numerical method with the exact values gotten from Rungekutta and refine it till it matches the exact values with the requried error tolerance. | def compare_exact_with(self, exact_details, method="", err_tolerance=0.001):
exact = exact_details[self.modified_t_z_label]
exact_2 = exact_details[self.modified_t_z__final_h_label]
# print("\n\nExact...")
# print(exact)
method_dict = self.get_t_z_from_step(self.h, method)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_newton_rhapson_system(testFunctions, tol, printFlag): \n pass",
"def test_newton_rhapson(testFunctions, tol, printFlag): \n pass",
"def test_exact_numerical_solution():\n a = 0.2\n b = 3\n\n def f(t, u):\n return a # + (u - u_exact(t))**5\n\n def u_exact(t):\n \"... | [
"0.66777176",
"0.6674214",
"0.66119117",
"0.6603316",
"0.63953465",
"0.62434554",
"0.6132904",
"0.6125514",
"0.60853845",
"0.6044942",
"0.59885657",
"0.5986625",
"0.59584916",
"0.5937307",
"0.5932568",
"0.5921156",
"0.5872071",
"0.5830867",
"0.5808483",
"0.58048725",
"0.57934... | 0.69235814 | 0 |
Balance tree starting from current node. Return root node of the whole tree. | def __balance(self) -> "Node":
current = self
while True:
current.__update_height()
if current.balance_factor == 2: # right subtree is higher
middle = current.right
if middle.balance_factor < 0: # left subtree of middle node is higher
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance(self, node=None):\n if node is None:\n node = self.root\n if self.root is None:\n return 0\n if not node.left and not node.right:\n return 0\n elif not node.left:\n return node.right.balance_number\n elif not node.ri... | [
"0.6771564",
"0.6751941",
"0.63523835",
"0.6316875",
"0.6222647",
"0.614931",
"0.60747343",
"0.6037365",
"0.6037229",
"0.6033708",
"0.60199666",
"0.6011532",
"0.599164",
"0.59402615",
"0.59167427",
"0.5903808",
"0.58831936",
"0.5879091",
"0.58385605",
"0.5831162",
"0.5786718"... | 0.7880483 | 0 |
Compute sum of all keys less than this one, sum of all keys greater than this one and then return them. | def split_sums(self, key: int) -> Tuple[int, int]:
current = self
less, greater = 0, 0
while key != current.key:
if key < current.key:
# add all greater keys
greater += current.right.sum if current.right is not None else 0
greater += c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keys_geq_threshold (Dict, threshold):\n for key, value in Dict.items ():\n if value >= threshold:\n yield key",
"def greedy(items, maxCost, keyFunction):\n result = []\n itemsCopy = sorted(items, key=keyFunction, reverse=True)\n totalValue , totalCalories = 0.0, 0.0\n for i i... | [
"0.5463783",
"0.53913",
"0.534185",
"0.52973485",
"0.52897525",
"0.5205245",
"0.5136367",
"0.5132484",
"0.50957704",
"0.50494",
"0.5003278",
"0.4997482",
"0.49951553",
"0.49840137",
"0.49699202",
"0.4968866",
"0.4947915",
"0.49443883",
"0.4915351",
"0.49105746",
"0.49093592",... | 0.6889541 | 0 |
Return sum of all keys of the tree. | def sum(self) -> int:
return self.root.sum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_keys(self):\n return self.derivable_keys() + self.loadable_keys()",
"def keys(self, _prec=\"\"):\n if self.isLeaf:\n yield _prec + self.ch\n\n for chld in self.children.values():\n yield from chld.keys(_prec + self.ch)",
"def keys(self):\n list_all_dict... | [
"0.6243261",
"0.6115674",
"0.60786986",
"0.6044694",
"0.600124",
"0.59922993",
"0.5934802",
"0.59175795",
"0.58326626",
"0.58262455",
"0.5817726",
"0.57651764",
"0.57523066",
"0.5744666",
"0.5722043",
"0.56711143",
"0.5642321",
"0.5563058",
"0.554552",
"0.554223",
"0.5522682"... | 0.6218519 | 1 |
Insert key (create new element) in the tree and return True on success or False on failure. | def insert(self, key: int) -> bool:
if self.empty(): # empty tree, so value becomes the root
self.root = Node(key)
return True
current = self.root # start at the root
while current.key != key:
if key < current.key:
if current.left is None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, key, value):\n\n if None == self.root:\n self.root = BSTNode(key,value)\n return True\n current_node = self.root\n while current_node:\n if key == current_node.key:\n print(\"The key does exist!\")\n re... | [
"0.79694563",
"0.7608",
"0.741988",
"0.73943967",
"0.7371206",
"0.73535365",
"0.7288143",
"0.7204981",
"0.7151826",
"0.6987604",
"0.6974992",
"0.6864278",
"0.6855692",
"0.685186",
"0.6831797",
"0.6830995",
"0.68205714",
"0.6766032",
"0.6742783",
"0.67291456",
"0.6685355",
"... | 0.7935399 | 1 |
Remove element with such key if it exists in the tree (return True), or return False otherwise. | def remove(self, key: int) -> bool:
current = self.root.find(key) if not self.empty() else None
if current is None: # if no such key, failure
return False
self.root = current.remove() # update root
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, key: str) -> bool:\n prev, cur = None, self.head\n while cur is not None:\n if cur.key == key:\n if prev:\n prev.next = cur.next\n else:\n self.head = cur.next\n self.size -= 1\n ... | [
"0.75203735",
"0.75203735",
"0.7404102",
"0.71876985",
"0.71672606",
"0.7156685",
"0.7156685",
"0.70719224",
"0.70339316",
"0.6950504",
"0.6842136",
"0.6808065",
"0.67540085",
"0.6747291",
"0.66998345",
"0.66405225",
"0.6625562",
"0.6594667",
"0.65882593",
"0.654039",
"0.6486... | 0.83262324 | 0 |
Compute sum of all tree keys in segment [left, right]. | def segment_sum(self, left, right):
if self.empty():
return 0
less, _ = self.root.split_sums(left)
_, greater = self.root.split_sums(right)
return self.sum - less - greater | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_sums(self, key: int) -> Tuple[int, int]:\n current = self\n less, greater = 0, 0\n while key != current.key:\n\n if key < current.key:\n # add all greater keys\n greater += current.right.sum if current.right is not None else 0\n ... | [
"0.6126532",
"0.6085298",
"0.58793104",
"0.5737918",
"0.5734543",
"0.5729074",
"0.5707821",
"0.56992847",
"0.56771207",
"0.56771207",
"0.56771207",
"0.56771207",
"0.56771207",
"0.5667496",
"0.5633278",
"0.56297845",
"0.55472666",
"0.54936486",
"0.5489435",
"0.5468155",
"0.544... | 0.6891316 | 0 |
`ready` should call `can_end` if all players are ready | def test_ready_true(self):
mock_player = Mock()
mock_stage = Mock()
mock_stage._ready_list = []
mock_stage.game.players = [mock_player]
JobStage.ready(mock_stage, mock_player)
mock_stage.can_end.assert_called_once_with() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ready(self):\n if self.game.has_started() or self.status == self.PLAYER_READY:\n return\n self.status = self.PLAYER_READY\n self.game.player_is_ready()",
"def set_player_ready(self, player_id):\n player = list(filter(lambda p: p.id() == player_id, self.players))\n\n... | [
"0.7003512",
"0.67559516",
"0.67270315",
"0.67098206",
"0.66954184",
"0.6675737",
"0.66499287",
"0.66488665",
"0.65081465",
"0.6504937",
"0.64455235",
"0.6342912",
"0.6293068",
"0.6222209",
"0.6178904",
"0.6166347",
"0.609085",
"0.6075545",
"0.6068318",
"0.605158",
"0.6047076... | 0.6897181 | 1 |
`ready` should not call `can_end` if not all players are ready | def test_ready_false(self):
mock_player = Mock()
mock_stage = Mock()
mock_stage._ready_list = []
mock_stage.game.players = [mock_player, Mock()]
JobStage.ready(mock_stage, mock_player)
self.assertFalse(mock_stage.can_end.called) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe_start(self):\r\n\t\tif not [p for p in self.players if not p.ready]\\\r\n\t\t and len(self.players) == self.max_players \\\r\n\t\t and not self.started:\r\n\t\t\tself.start()",
"def test_ready_true(self):\n\n mock_player = Mock()\n mock_stage = Mock()\n mock_stage._ready_list... | [
"0.7119717",
"0.7010591",
"0.6930685",
"0.68450433",
"0.6803973",
"0.6764692",
"0.6760834",
"0.66621125",
"0.6587352",
"0.65722364",
"0.6477461",
"0.64760566",
"0.643422",
"0.6404972",
"0.63692766",
"0.6325318",
"0.6322103",
"0.62534773",
"0.6178539",
"0.6136535",
"0.61189437... | 0.7149616 | 0 |
Entry; returns the ithjth entry of this matrix (1 based) >>> x = Matrix(2,3, data = [1,2,3,4,5,6]) >>> x.entry(1,3) 3 >>> x.entry(2,2) 5 | def entry(self, i, j):
return self.data[self.columns * (i - 1) + j - 1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readentry(self):\n # because of the complexity of the format, have to parse\n # the whole file at once.\n if self.__blocks is None:\n self.__parse()\n if self.__blocks.has_key('data') and self.__blocks['data'].has_key('matrix'):\n if self.__cursor < self.ntax:\... | [
"0.6118891",
"0.6007056",
"0.58842075",
"0.58260417",
"0.5769946",
"0.57105064",
"0.5682837",
"0.56327736",
"0.56249183",
"0.5607605",
"0.5488166",
"0.5438115",
"0.5431594",
"0.54276305",
"0.54154724",
"0.5404214",
"0.54035306",
"0.5368673",
"0.53595644",
"0.5352315",
"0.5312... | 0.72692525 | 0 |
Returns a new matrix that is the transpose of self >>> m = Matrix(2,3, data=[1,2,3,4,5,6]) >>> t = m.transpose() >>> t.size() (3, 2) >>> t.row(1) [1, 4] >>> t.column(1) [1, 2, 3] | def transpose(self):
transposed_data = []
for i in range(1, self.columns + 1):
transposed_data.extend(self.column(i))
return Matrix(rows = self.columns, columns = self.rows, data = transposed_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transpose(self):\n return Matrix([[self.data[r][c] for r in range(len(self.data))]\n for c in range(len(self.data[1]))])",
"def transpose(self) -> 'Matrix' :\n # -------------------------------------------------------\n # TODO: You write this one.\n # Hint: ... | [
"0.8752439",
"0.85724944",
"0.8400045",
"0.8335349",
"0.831839",
"0.82262737",
"0.81206936",
"0.7895389",
"0.7823492",
"0.7708143",
"0.7631627",
"0.7626189",
"0.7624763",
"0.76037854",
"0.7598147",
"0.7547677",
"0.7501236",
"0.74961007",
"0.74675936",
"0.7419194",
"0.7400781"... | 0.8630106 | 1 |
Matrix addition. Sizes must be the same >>> x = Matrix(2,2, data=[1,2,3,4]) >>> y = Matrix(2,2, data=[5,6,7,8]) >>> z = x + y >>> z.size() (2, 2) >>> z.row(1) [6, 8] >>> z.row(2) [10, 12] | def __add__(self, other):
if not issubclass(type(other), Matrix):
raise TypeError(type(other))
if self.rows != other.rows or self.columns != other.columns:
raise ValueError("Sizes should be equivalent")
result = [ x + y for x, y in zip(self.data, other.data)]
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __add__(self, other):\n if self.rows != other.rows or self.cols != other.cols:\n raise IndexError(\"Size of matrices are not equal: (%i, %i) != (%i, %i)\"%\n (self.rows, self.cols, other.rows, other.cols))\n\n newmat = make_matrix(self.rows, self.cols)\n ... | [
"0.76527125",
"0.73316",
"0.7228747",
"0.72221476",
"0.7185278",
"0.71340716",
"0.7105316",
"0.7027563",
"0.6926949",
"0.6924563",
"0.6908989",
"0.6772457",
"0.67577463",
"0.67482686",
"0.6723153",
"0.6702301",
"0.66788095",
"0.6625761",
"0.6618875",
"0.6610617",
"0.64467525"... | 0.7728473 | 0 |
Matrix equality. >>> m = Matrix(2,3, data=[1,2,3,4,5,6]) >>> n = Matrix(2,3, data=[1,2,3,4,5,6]) >>> m == n True >>> m = Matrix(2,3, data=[1,2,3,4,5,6]) >>> n = Matrix(3,2, data=[1,2,3,4,5,6]) >>> m == n False >>> m = Matrix(2,3, data=[1,2,3,4,5,6]) >>> n = Matrix(2,3, data=[1,5,3,4,2,1]) >>> m == n False | def __eq__(self, other):
if not issubclass(type(other), Matrix):
return False
if self.rows != other.rows or self.columns != other.columns:
return False
return self.data == other.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if isinstance(other, Matrix):\n return self.data == other.data\n else:\n raise TypeError('other is not a Matrix')",
"def __eq__(self, other):\n if not isinstance(other, Matrix):\n return NotImplemented\n\n if self.num_cols !=... | [
"0.77442706",
"0.7616774",
"0.7541274",
"0.73873246",
"0.7328286",
"0.7172422",
"0.7158907",
"0.70418817",
"0.69518113",
"0.6880581",
"0.6836746",
"0.67580706",
"0.6729691",
"0.66712886",
"0.66344106",
"0.6621957",
"0.65759283",
"0.65587467",
"0.65123016",
"0.64831966",
"0.64... | 0.7703764 | 1 |
Returns true iff other is the inverse of self. That is, if A = self, and B = other, then AB = I and BA = I. >>> A = Matrix(2,2, data = [0, 1, 1, 1]) >>> B = Matrix(2,2, data = [1, 1, 1, 0]) >>> A.is_inverse(B) True >>> A = Matrix(2,2, data = [0, 1, 1, 1]) >>> B = Matrix(2,2, data = [10, 5, 1, 0]) >>> A.is_inverse(B) Fa... | def is_inverse(self, other):
return (self * other).is_identity() and (other * self).is_identity() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse(self):\n myMatrix = np.array(self.Matrix)\n if np.linalg.det(myMatrix) == 0:\n print(\"This matrix has a determinant of 0, meaning it has no inverse\")\n else:\n self.Inverse = np.linalg.inv(myMatrix)\n print(\"This is the inverse to your matrix: \"... | [
"0.7129069",
"0.6737461",
"0.6689242",
"0.6599424",
"0.6501796",
"0.643704",
"0.64288276",
"0.6419187",
"0.6308084",
"0.62743753",
"0.62679845",
"0.6242612",
"0.6194581",
"0.6176031",
"0.6163293",
"0.61061764",
"0.6090794",
"0.60691524",
"0.60691524",
"0.60687166",
"0.6044863... | 0.8558719 | 0 |
Returns true iff this matrix is in row echelon format. >>> x = Matrix(2, 3, data=[1, 4, 5, 0, 0, 1]) >>> x.is_row_echelon() True >>> x = Matrix(2, 3, data=[1, 4, 5, 1, 0, 1]) >>> x.is_row_echelon() False | def is_row_echelon(self):
return self._is_row_echelon(False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_reduced_row_echelon(self):\n return self._is_row_echelon(True)",
"def _is_row(table):\n import astropy.io.fits.fitsrec\n import astropy.table.row\n if isinstance(table, (astropy.io.fits.fitsrec.FITS_record, astropy.table.row.Row)) or \\\n np.isscalar(table):\n return True\n ... | [
"0.7218277",
"0.62404424",
"0.59228235",
"0.58064455",
"0.57126516",
"0.5634151",
"0.5614468",
"0.56140757",
"0.55955386",
"0.55912507",
"0.55473727",
"0.55473727",
"0.55176824",
"0.5483205",
"0.54549736",
"0.5423712",
"0.54193264",
"0.5416869",
"0.5411696",
"0.54111826",
"0.... | 0.7599343 | 0 |
Returns true iff this matrix is in row echelon format. >>> x = Matrix(2, 3, data=[1, 4, 5, 0, 0, 1]) >>> x.is_reduced_row_echelon() False >>> x = Matrix(2, 3, data=[1, 4, 0, 0, 0, 1]) >>> x.is_reduced_row_echelon() True >>> x = IdentityMatrix(10) >>> x.is_reduced_row_echelon() True >>> x.is_row_echelon() True | def is_reduced_row_echelon(self):
return self._is_row_echelon(True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_row_echelon(self):\n return self._is_row_echelon(False)",
"def test_reduced_row_echelon(binary_matrix, result):\n\n # build row echelon form of the matrix\n shape = binary_matrix.shape\n for irow in range(shape[0]):\n pivot_index = 0\n if np.count_nonzero(binary_matrix[irow, ... | [
"0.73812956",
"0.6252131",
"0.6107828",
"0.5938595",
"0.57350224",
"0.5683577",
"0.5610796",
"0.55488193",
"0.5484749",
"0.54240733",
"0.54033965",
"0.5389416",
"0.53827727",
"0.5364936",
"0.5362654",
"0.53538454",
"0.5352314",
"0.5349867",
"0.53383005",
"0.5323401",
"0.52846... | 0.7947956 | 0 |
Apply the Gaussian Algorithm to produce a matrix in row echelon form. Returns the resulting matrix and a list of the elementary operations applied. >>> x = Matrix(4, 6, data = [0, 0, 0, 2, 1, 9, 0, 2, 6, 2, 0, 2, 0, 2, 6, 2, 2, 0, 0, 3, 9, 2, 2, 19]) >>> x.is_row_echelon() False >>> x.is_reduced_row_echelon() False >>>... | def to_reduced_row_echelon(self):
return self._to_row_echelon(fully_reduce = True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rowReduce(self):\n myMatrix = Matrix(self.Matrix)\n print(\"This is the row reduced echelon form of your matrix: \\n\", myMatrix.rref())",
"def to_reduced_echelon(self, return_ops=False):\n matrix, ops = reduce_to_red_echelon(self.data.copy(), True)\n if return_ops:\n r... | [
"0.6142419",
"0.5927133",
"0.5843437",
"0.58102345",
"0.5803057",
"0.574778",
"0.57285506",
"0.56704384",
"0.5545705",
"0.5516162",
"0.5460262",
"0.54235905",
"0.53553396",
"0.52844626",
"0.5037948",
"0.50374824",
"0.4956029",
"0.49052173",
"0.48710987",
"0.48451102",
"0.4820... | 0.6018045 | 1 |
Apply the Gaussian Algorithm to produce a matrix in row echelon form. Returns the resulting matrix and a list of the elementary operations applied. >>> x = Matrix(4, 6, data = [0, 0, 0, 2, 1, 9, 0, 2, 6, 2, 0, 2, 0, 2, 6, 2, 2, 0, 0, 3, 9, 2, 2, 19]) >>> x.is_row_echelon() False >>> y, ops = x.to_row_echelon() >>> y.is... | def to_row_echelon(self):
return self._to_row_echelon(fully_reduce = False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_echelon(self, return_ops=False):\n matrix, ops = reduce_to_echelon(self.data.copy(), True)\n if return_ops:\n return Matrix(matrix), ops\n else:\n return Matrix(matrix)",
"def row_echelon(self):\n # TODO: This can be refactored for better efficiency\n ... | [
"0.5780302",
"0.5641073",
"0.56297666",
"0.5594284",
"0.5564156",
"0.55236244",
"0.5496969",
"0.54073936",
"0.53759384",
"0.53267175",
"0.53152555",
"0.5219486",
"0.52194047",
"0.5208904",
"0.514854",
"0.5139676",
"0.51020676",
"0.50896704",
"0.5068453",
"0.5015525",
"0.49995... | 0.57338876 | 1 |
Matrix Inversion; attempt to find the inverted matrix, or 0 if self is not invertible. >>> A = Matrix(3, 3, data = [2, 7, 1, 1, 4, 1, 1, 3, 0]) >>> B = A.invert() >>> B.row(1) [1.5, 1.5, 5.5] >>> B.row(2) [0.5, 0.5, 1.5] >>> B.row(3) [0.5, 0.5, 0.5] >>> C = A B >>> C.is_identity() True >>> C = B A >>> C.is_identity() T... | def invert(self):
if self.rows != self.columns:
raise ValueError("Matrix must be square to invert")
A, operations = self.to_reduced_row_echelon()
if not A.is_identity():
return 0
# If A was reduced to the identity matrix, then the same set of operations will ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invert(M):\r\n M = isMatrix(M)\r\n return M.I",
"def inverse(self):\n # TODO\n # detA\n if not self.is_square():\n raise(\n ValueError, \"Non-square Matrix does not have an inverse.\")\n if self.h > 2:\n raise(\n NotImpleme... | [
"0.7704382",
"0.76001847",
"0.7530251",
"0.74286675",
"0.74248624",
"0.73785585",
"0.7336647",
"0.72138363",
"0.71350014",
"0.6985665",
"0.6985447",
"0.69736195",
"0.6948612",
"0.6948407",
"0.69344056",
"0.69318897",
"0.6927205",
"0.6905457",
"0.68185455",
"0.68137276",
"0.68... | 0.7955028 | 0 |
Returns the adjoint of A; that is, the transpose of the coefficient matrix of A. >>> A = Matrix(3, 3, data = [1, 3, 2, 0, 1, 5, 2, 6, 7]) >>> adj = A.adjoint() >>> adj.row(1) [37, 9, 17] >>> adj.row(2) [10, 3, 5] >>> adj.row(3) [2, 0, 1] | def adjoint(self):
data = []
for i in range(1, self.rows + 1):
for j in range(1, self.columns + 1):
data.append(self._cofactor(i, j))
mat = Matrix(self.rows, self.columns, data)
return mat.transpose() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjoint(self):\n return self.cofactorMatrix().transpose()",
"def adjoint(self):\n return self.conjugate().transpose()",
"def adjoint(self: T) -> types.Matrix:",
"def adj(self):\n\n d = self.rank\n permutation = [0] * d\n permutation[::2] = range(1, d, 2)\n permut... | [
"0.6551653",
"0.6530734",
"0.64267033",
"0.63263303",
"0.6166535",
"0.59153736",
"0.57950395",
"0.57607144",
"0.57337266",
"0.5668322",
"0.5640772",
"0.53950614",
"0.53656226",
"0.534205",
"0.5321159",
"0.5257715",
"0.52441967",
"0.52029216",
"0.51526463",
"0.5136503",
"0.513... | 0.65625477 | 0 |
Matrix rank; returns the number of leading 1's for the row echelon form of this matrix >>> a = Matrix(2,2, data = [1,0,0,1]) >>> a.rank() 2 >>> x = Matrix(4, 6, data = [0, 0, 0, 2, 1, 9, 0, 2, 6, 2, 0, 2, 0, 2, 6, 2, 2, 0, 0, 3, 9, 2, 2, 19]) >>> x.rank() 3 | def rank(self):
if self._rank >= 0:
return self._rank
reduced, operations = self.to_row_echelon()
non_leading_rows = 0
for i in range(self.rows, 0, -1):
if not reduce(lambda x,y: x or y, reduced.row(i)):
non_leading_rows += 1
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank(self):\n return self.matrix().rank()",
"def rank(self):\n rank = 0\n rho = self.array_form[:]\n n = self.size - 1\n size = n + 1\n psize = int(ifac(n))\n for j in xrange(size - 1):\n rank += rho[j]*psize\n for i in xrange(j + 1, size... | [
"0.8067183",
"0.73783314",
"0.71490616",
"0.7074801",
"0.69578046",
"0.68724763",
"0.6856519",
"0.6853919",
"0.6851567",
"0.6809577",
"0.6673834",
"0.66733974",
"0.6628821",
"0.66196465",
"0.6602372",
"0.65865684",
"0.65865684",
"0.65865684",
"0.65865684",
"0.65865684",
"0.65... | 0.81717306 | 0 |
Use the Eggleton formula for the given mass ratio. | def eggleton_formula(mass_ratio):
two_third = mass_ratio**(2.0/3.0)
one_third = mass_ratio**(1.0/3.0)
return 0.49 * two_third / ( 0.6 * two_third + numpy.log(1.0 + one_third)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mass_handling_gear(\n design_mass_TOGW: float,\n):\n return 3e-4 * design_mass_TOGW",
"def cal_mass(self):\n\n if not self.check_def(['E','px','py','pz']):\n sys.exit('Particle error: Quadri impulsion not define (error for mass routine)')\n\n\n \n if self.E**2-self.p... | [
"0.63537115",
"0.6162247",
"0.60934466",
"0.59891784",
"0.5960578",
"0.59431016",
"0.5865941",
"0.58302695",
"0.582781",
"0.58259535",
"0.581917",
"0.5815082",
"0.5781365",
"0.57289153",
"0.5706313",
"0.56988007",
"0.5674876",
"0.5646423",
"0.5644215",
"0.564418",
"0.56358486... | 0.83122075 | 0 |
Return the orbital separation in the same units as the semimajor axis | def separation(semimajor_axis, eccentricity, true_anomaly):
numerator = semimajor_axis * (1.0-eccentricity**2)
denominator = 1.0 + eccentricity * numpy.cos(true_anomaly)
return numerator / denominator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meridional_flattening(self):\n return (self.semimajor_axis - self.semiminor_axis) / self.semimajor_axis",
"def equatorial_flattening(self):\n return (self.semimajor_axis - self.semimedium_axis) / self.semimajor_axis",
"def volume(self):\n return (\n (4 / 3 * np.pi)\n ... | [
"0.5996191",
"0.5984223",
"0.561051",
"0.54374194",
"0.53562725",
"0.53526306",
"0.5332537",
"0.5291807",
"0.52586854",
"0.524699",
"0.51796347",
"0.51793784",
"0.51728964",
"0.51571953",
"0.5123603",
"0.50873727",
"0.5081909",
"0.5081216",
"0.5070296",
"0.50385815",
"0.50280... | 0.68385667 | 0 |
The Roche radius assumes a curcular orbit with the current separation. Note that this is not really correct for noncircular orbits. | def eggleton_roche_radius(self):
return self.eggleton_roche_over_separation() * self.separation() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCoreRadius(self):\n return self.getNumRings(indexBased=True) * self.getFirstBlock().getPitch()",
"def get_radius(self):\n return self.R",
"def polar_radius(self):\n return self.r * (1 - self.f)",
"def get_radius(self):\n return self.r",
"def get_radius(self):\n if ... | [
"0.72135687",
"0.71646565",
"0.71542245",
"0.7111596",
"0.6965158",
"0.6961741",
"0.6783084",
"0.6773276",
"0.6749259",
"0.6743605",
"0.6727208",
"0.6678665",
"0.66703546",
"0.66618556",
"0.66618556",
"0.66618556",
"0.66618556",
"0.66618556",
"0.6648548",
"0.66284496",
"0.662... | 0.7822275 | 0 |
Sets the current_page of this CampaignResults. | def current_page(self, current_page):
self._current_page = current_page | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_current_page(self, current_page):\n if not current_page:\n self.resolve_current_page()\n\n if not self._is_valid_page_number(current_page):\n return 1\n\n return current_page",
"def setCurrentPage(self):\n pass",
"def setCurrent(self, current):\n ... | [
"0.6972598",
"0.66612273",
"0.6332441",
"0.62680274",
"0.61401886",
"0.59123844",
"0.5841093",
"0.5832685",
"0.5758064",
"0.5451816",
"0.544512",
"0.54440594",
"0.54440594",
"0.5443152",
"0.5394257",
"0.53761125",
"0.53761125",
"0.5346131",
"0.5346131",
"0.5286656",
"0.524336... | 0.7866203 | 0 |
Sets the last_page of this CampaignResults. | def last_page(self, last_page):
self._last_page = last_page | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_last_page(self, page):\n self.last_page = page\n if self.get_page() > page:\n self.set_page(page)",
"async def last_page(self):\n await self.show_page(self.maximum_pages)",
"def set_max_per_page(self, max_per_page):\n if max_per_page > 0:\n self.max_per... | [
"0.7550727",
"0.6282344",
"0.61206865",
"0.59512246",
"0.5883743",
"0.5856963",
"0.58023655",
"0.56850874",
"0.566858",
"0.56101155",
"0.55056155",
"0.5464263",
"0.5453732",
"0.5417057",
"0.53806823",
"0.535176",
"0.52850085",
"0.5262985",
"0.5236791",
"0.5229718",
"0.5226469... | 0.8125105 | 0 |
Sets the next_page_url of this CampaignResults. | def next_page_url(self, next_page_url):
self._next_page_url = next_page_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page(self, next_page):\n\n self._next_page = next_page",
"def next_page(self, next_page):\n\n self._next_page = next_page",
"def next_page_token(self, next_page_token):\n\n self._next_page_token = next_page_token",
"def next_page_token(self, next_page_token):\n\n self._ne... | [
"0.7601188",
"0.7601188",
"0.69734037",
"0.69734037",
"0.6721128",
"0.66241163",
"0.63182557",
"0.62447685",
"0.6174846",
"0.6174846",
"0.6124761",
"0.6124421",
"0.6119208",
"0.60858077",
"0.5971115",
"0.58562934",
"0.5840121",
"0.5829555",
"0.5703028",
"0.5703028",
"0.569179... | 0.8298745 | 0 |
Sets the per_page of this CampaignResults. | def per_page(self, per_page):
self._per_page = per_page | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_per_page(self, per_page):\n\n\t\tif per_page is not None and not isinstance(per_page, int):\n\t\t\traise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: per_page EXPECTED TYPE: int', None, None)\n\t\t\n\t\tself.__per_page = per_page\n\t\tself.__key_modified['per_page'] = 1",
"def per_page(self,limit):\n ... | [
"0.7459994",
"0.6575422",
"0.6419122",
"0.6280519",
"0.61276126",
"0.6006649",
"0.59779066",
"0.59779066",
"0.5855797",
"0.5828105",
"0.57520276",
"0.56680346",
"0.5595086",
"0.55216813",
"0.5436072",
"0.53295976",
"0.53050065",
"0.52957696",
"0.52752906",
"0.52752906",
"0.52... | 0.7947656 | 0 |
Sets the prev_page_url of this CampaignResults. | def prev_page_url(self, prev_page_url):
self._prev_page_url = prev_page_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPrev(self, prev):\n\t\t\tself.prev = prev",
"def prev_page(self):\n if self._start == 0:\n raise ValueError('Already at the first page.')\n self._start = (self._start - self._num) if self._start > self._num else 0",
"def prev(self, prev):\n\n self._prev = prev",
"def pr... | [
"0.6999146",
"0.6881566",
"0.68198353",
"0.65889996",
"0.6501186",
"0.6464601",
"0.6144432",
"0.6135618",
"0.61000425",
"0.60942054",
"0.60596913",
"0.59559035",
"0.5934246",
"0.59099567",
"0.5888289",
"0.5879898",
"0.5819527",
"0.5816416",
"0.5723854",
"0.5703113",
"0.566889... | 0.8607853 | 0 |
Download and parse carbanak report Add facts for md5, sha256, c2 and campaigns | def carbanak_report(client, md5_lookup):
for row in get_xlsx_report(
"https://www.fireeye.com/content/dam/fireeye-www/blog/pdfs/carbanak-report.xlsx",
"Sheet1")[1:]: # First row is header
md5 = row[0]
campaign = row[3]
c2_list = row[4:]
sha256 = md5_lookup.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_report():\n entities = get_names()\n save_csv(entities)",
"def generate_report():\n\n # Fetch the top 3 most viewed articles and number of views and print them\n articles_query = get_articles_query()\n popular_articles = execute_query(articles_query)\n print_top_articles(popular_ar... | [
"0.5971737",
"0.59170586",
"0.5712726",
"0.5655848",
"0.5652123",
"0.5630745",
"0.5603499",
"0.55161214",
"0.550469",
"0.5469005",
"0.5433695",
"0.5389861",
"0.53547746",
"0.5329751",
"0.53189015",
"0.5305993",
"0.52918327",
"0.5261614",
"0.52371",
"0.5234515",
"0.5182869",
... | 0.7559763 | 0 |
Load the test application. | def load_app(name=application_name):
return TestApp(
loadapp(
'config:test.ini#%s' % name,
relative_to=getcwd(),
global_conf={
'test': 'true',
},
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadapp(self, app, params=None):\n if not TESTMODE:\n app = 'snakewm.' + app\n\n _app = importlib.import_module(app)\n _app.load(self.MANAGER, params)",
"def application(self):\n if not ApplicationFixture._test_app:\n app = self.APP_CLASS()\n app.r... | [
"0.77258044",
"0.7109625",
"0.68806225",
"0.6716948",
"0.6711598",
"0.6700527",
"0.66835386",
"0.6659268",
"0.6658796",
"0.6628215",
"0.6579791",
"0.65292",
"0.65046906",
"0.64945394",
"0.64836806",
"0.64803535",
"0.6447463",
"0.64245564",
"0.6387238",
"0.63587546",
"0.635781... | 0.7818834 | 0 |
guess ext from http header contentdisposition if have | def guess_ext_from_content_disposition(self):
# may be bug, Content-Disposition attachment; filename="MyspacePasswordDecryptor.zip";
if self.content_disposition:
file_name = self.content_disposition.split('filename=')[1]
# "MyspacePasswordDecryptor.zip"; maybe like this,so rstrip... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auto_get_file_extension(self):\n self.resolve_what_url()\n self.guess_ext_from_content_disposition()\n # guess ext from content_disposition success\n if None != self.save_file_ext:\n return\n else:\n self.guess_ext_from_url()",
"def filename_from_conte... | [
"0.75673074",
"0.7092939",
"0.7059339",
"0.70106417",
"0.6833142",
"0.6784279",
"0.6725442",
"0.6686875",
"0.66832995",
"0.6682858",
"0.66655725",
"0.6635333",
"0.6616339",
"0.65695876",
"0.6567338",
"0.65651006",
"0.65072256",
"0.6410441",
"0.64089173",
"0.6384786",
"0.63666... | 0.7806261 | 0 |
auto guess file ext if can not guess,self.save_file_ext is None self.save_file_ext always contain . | def auto_get_file_extension(self):
self.resolve_what_url()
self.guess_ext_from_content_disposition()
# guess ext from content_disposition success
if None != self.save_file_ext:
return
else:
self.guess_ext_from_url() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guess_ext_from_url(self):\n # http://docs.python.org/2.7/library/urlparse.html#urlparse.urlsplit\n # 0:scheme,1:netloc,2:path,3:query\n url_path = urlparse.urlsplit(self.what_url)[2]\n # path index is 2,Hierarchical path,may be empty string\n if '' == url_path:\n s... | [
"0.7523912",
"0.7404572",
"0.7143852",
"0.7004598",
"0.68470687",
"0.68027407",
"0.67417043",
"0.6739809",
"0.67318213",
"0.67291",
"0.66980743",
"0.6696827",
"0.6687871",
"0.6672721",
"0.6653054",
"0.6614688",
"0.6613101",
"0.66029036",
"0.6591592",
"0.65119296",
"0.6500482"... | 0.7854987 | 0 |
if down success,no Exception else, DenyMimes,CanNotGuessExtension,DownError will raise | def down(self):
try:
self.do_request()
info = self.response.info()
self.mime_type = info.gettype()
if self.mime_type in self.deny_mimes:
raise DenyMimes('Wrong Mime type: ' + self.mime_type)
self.header_file_bytes = int(info.getheader("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def down(self, url, save_dir, save_file_without_ext, downing_callback, max_try):\n i = 1\n while i <= max_try:\n try:\n down_file = DownFile(url, save_dir, save_file_without_ext, downing_callback)\n down_file.down()\n except DenyMimes, e:\n ... | [
"0.5871973",
"0.5744042",
"0.55904883",
"0.5551306",
"0.53614396",
"0.5281113",
"0.52707297",
"0.52616936",
"0.5223939",
"0.5185196",
"0.5180866",
"0.51550144",
"0.5139435",
"0.51048005",
"0.5104654",
"0.50947154",
"0.50901014",
"0.5078487",
"0.503687",
"0.49992308",
"0.49965... | 0.64185786 | 0 |
download file,do retry,if failed after retry,raise DownError(last error) if success, return DownFile object | def down(self, url, save_dir, save_file_without_ext, downing_callback, max_try):
i = 1
while i <= max_try:
try:
down_file = DownFile(url, save_dir, save_file_without_ext, downing_callback)
down_file.down()
except DenyMimes, e:
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_download_to_file_retry(req, tmpdir):\n req.get(ENTREZ_URL, response_list=[\n {\"text\": u'Whoa, slow down', \"status_code\": 429, \"headers\": {\"Retry-After\": \"0\"}},\n {\"text\": 'This works.'},\n ])\n outdir = tmpdir.mkdir('outdir')\n filename = outdir.join('foo')\n expec... | [
"0.7059918",
"0.6776302",
"0.67640513",
"0.6636897",
"0.6624669",
"0.6603147",
"0.6586782",
"0.6576608",
"0.6519625",
"0.6496943",
"0.6415385",
"0.6400185",
"0.63965535",
"0.63909674",
"0.63717085",
"0.63687694",
"0.6358797",
"0.6344714",
"0.633105",
"0.62940335",
"0.62891525... | 0.73766875 | 0 |
Returns the exact numerical values for the simplest linear case. angle_0 and omega_0 are defined at t[0]. | def LinSolution(t, angle_0, omega_0, a = 1):
if angle_0 == 0:
A = omega_0/np.sqrt(a)
phi = np.pi/2 - np.sqrt(a)*t[0]
else:
A = angle_0
phi = -(np.sqrt(a)*t[0])
angle = A*np.cos(np.sqrt(a)*t + phi)
omega = -A*np.sqrt(a)*np.sin(np.sqrt(a)*t + phi)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyticalLinearSol(self, t):\n return self.c*t + self.I",
"def get_rotationalAngularPosition(self, t): # returns [rad]\n angle = self.theta0 + self.rotationalAngularVelocity * t # angular position [rad]\n return angle",
"def test_linear():\n import ... | [
"0.64913964",
"0.61408496",
"0.57186455",
"0.5711257",
"0.5708967",
"0.56765664",
"0.5670049",
"0.5669253",
"0.56457156",
"0.5640341",
"0.5596435",
"0.5535654",
"0.5521166",
"0.5497934",
"0.5486453",
"0.54174477",
"0.5393143",
"0.53905046",
"0.53602314",
"0.5344014",
"0.53329... | 0.66398394 | 0 |
Solves the system defined by NonLinPendulum. 'angle_0' and 'omega_0' are defined at t[0]. The 'pendParas' tuple = (a, q, F, drivAngFreq). Returns an array of arrays of t, angle, and omega respectively | def Response(time, angle_0, omega_0, pendParas = (1,0,0,0)):
initCondition = [angle_0, omega_0]
solution = integrate.odeint(NonLinPendulum, y0 = initCondition, t = time, args = pendParas)
return np.array([time, solution[:,0], solution[:,1]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NonLinPendulum(y, t, a, q, F, drivAngFreq):\n \n angle = y[0]\n omega = y[1]\n return [omega, -a * np.sin(angle) - q*omega + F*np.sin(drivAngFreq * t)]",
"def pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -np.sin(x)\n\n return np.array([x_dot(... | [
"0.63242924",
"0.608133",
"0.5832184",
"0.57107306",
"0.53307015",
"0.5329514",
"0.5255126",
"0.5178632",
"0.51597184",
"0.51466376",
"0.50375164",
"0.50374746",
"0.5032686",
"0.50240195",
"0.49454242",
"0.49426398",
"0.4914326",
"0.4909257",
"0.48902348",
"0.48543915",
"0.48... | 0.690696 | 0 |
Estimates the time period from the roots of the angle | def EstimatePeriod(response):
#is a bit shoddy, requires long time periods to produce consistent results
roots = np.array([])
for i in range(len(response[1])):
try:
if response[1][i] == 0:
roots = np.append(roots, response[0][i])
#te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _period( self ):\r\n\treturn 2 * pi * sqrt( self.orbital_elements[0]**3 / self.mu_central_body )\r\n\t# http://en.wikipedia.org/wiki/Orbital_period#Calculation\r",
"def angle(self, angle: int, time: int = 0, /) -> None:",
"def calculation_time_analysis():\n\tfrom . import spectra as sp\n\tp_dict = {'Bfield... | [
"0.64856476",
"0.6065112",
"0.58533007",
"0.5810706",
"0.5689673",
"0.5661757",
"0.5571913",
"0.55633456",
"0.5542839",
"0.5487392",
"0.5485153",
"0.5473337",
"0.54439545",
"0.5437779",
"0.5433362",
"0.54300326",
"0.54269755",
"0.542375",
"0.5387012",
"0.5379332",
"0.53788733... | 0.6274342 | 1 |
build language models for each label each line in in_file contains a label and an URL separated by a tab(\t) | def build_LM(in_file):
print 'building language models...'
file_contents = open(in_file).readlines()
#for each line in the file, split the language type away from the text line
#split the text line into n grams and add it to the correct language type
#apply smoothing to the final dictionary
for line in file_conte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_labels():\n filename = os.path.join(config['inference']['model_dir'], 'output_labels.txt')\n global labels\n labels = [line.rstrip() for line in tf.gfile.FastGFile(filename)]",
"def data_word2vec_one_label(input_file,\n word2vec_model):\n vocab = dict([(k, v.index) for (... | [
"0.6121002",
"0.60678965",
"0.6030296",
"0.6011104",
"0.58951056",
"0.5844752",
"0.58388937",
"0.58198357",
"0.5803969",
"0.577673",
"0.57606786",
"0.57454324",
"0.56748664",
"0.56594414",
"0.5648475",
"0.56233543",
"0.5616996",
"0.5616996",
"0.56159705",
"0.56159556",
"0.560... | 0.67252654 | 0 |
test the language models on new URLs each line of in_file contains an URL you should print the most probable label for each URL into out_file | def test_LM(in_file, out_file, LM):
print "testing language models..."
# for each input line, break string into ngrams, then check it against each probability model
test_contents = open(in_file).readlines()
writer = open(out_file, 'w')
for line in test_contents:
fourgrams = ngram_from_line(line)
label = cal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_from_file():\r\n global default_input_path\r\n print \"JoomFind v 1.0\"\r\n print \"\\n\\nTrying to read URL(s) form \" + default_input_path + \" file...\\n\"\r\n try:\r\n if not default_input_path:\r\n f = open(\"urls.txt\")\r\n else:\r\n f=open(default_... | [
"0.5936029",
"0.588515",
"0.5828854",
"0.57115626",
"0.5708119",
"0.5675334",
"0.5600144",
"0.5572659",
"0.5535873",
"0.5482214",
"0.5419724",
"0.54142153",
"0.53940547",
"0.53932965",
"0.5390267",
"0.53900576",
"0.53776497",
"0.5375796",
"0.53728443",
"0.5371947",
"0.5368370... | 0.61964256 | 0 |
Computes the sum of two complex numbers | def complex_sum(c_1,c_2):
return c_1 + c_2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __add__(self,other):\n\t\treal = self.realPart + other.realPart\n\t\timaginary = self.imaginaryPart + other.imaginaryPart\n\n\t\t#create and return new complexnumber\n\t\treturn real,imaginary",
"def __add__(self, other):\n self.sum_complex_num = Complex((self.real + other.real), (self.imaginary + oth... | [
"0.7624584",
"0.75999624",
"0.7502954",
"0.7111853",
"0.70988506",
"0.69626987",
"0.6905546",
"0.6858077",
"0.6843162",
"0.68235654",
"0.6710978",
"0.6439652",
"0.64226973",
"0.62864447",
"0.62690204",
"0.62554526",
"0.62396747",
"0.622681",
"0.6223357",
"0.61860746",
"0.6164... | 0.8779998 | 0 |
Computes the difference of two complex numbers | def complex_difference(c_1,c_2):
return c_1 - c_2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __sub__(self,other):\n\t\treal = self.realPart - other.realPart\n\t\timaginary = self.imaginaryPart - other.imaginaryPart\n\n\t\t#create and return complexNumber\n\t\treturn real,imaginary",
"def complex_multiplication(c1,c2,cr):\n cr[0] = c1[0]*c2[0] - c1[1]*c2[1]\n cr[1] = c1[0]*c2[1] + c1[1]*c2[0]\n... | [
"0.7373653",
"0.6968793",
"0.6935681",
"0.67901456",
"0.66597664",
"0.66170543",
"0.65609694",
"0.65265906",
"0.65182287",
"0.6517005",
"0.6475885",
"0.6297457",
"0.6215812",
"0.60721135",
"0.60377276",
"0.59830225",
"0.59830225",
"0.5981429",
"0.59311086",
"0.5911546",
"0.59... | 0.87971735 | 0 |
Computes the multiplication of two complex numbers | def complex_multiplication(c1,c2,cr):
cr[0] = c1[0]*c2[0] - c1[1]*c2[1]
cr[1] = c1[0]*c2[1] + c1[1]*c2[0]
return cr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __mul__(self,other):\n\t\treal = (self.realPart * other.realPart) - (self.imaginaryPart * other.imaginaryPart)\n\t\timaginary = (self.realPart*other.imaginaryPart) + (self.imaginaryPart * other.realPart)\n\n\t\t# create and return complexNumber\n\t\treturn real,imaginary",
"def complex_mul(x1, x2):\n asse... | [
"0.81487364",
"0.7928165",
"0.7655769",
"0.76041526",
"0.7532301",
"0.7414728",
"0.73343265",
"0.7310516",
"0.72941613",
"0.72808546",
"0.7262667",
"0.70726156",
"0.69206005",
"0.69076085",
"0.6731359",
"0.6712134",
"0.6707488",
"0.6655004",
"0.6627308",
"0.6618786",
"0.65911... | 0.83556545 | 0 |
Reads a string and extracts complex numbers. Return, values of list each list per index and operation | def complex_reader(operation,input):
input = input[1:len(input)-1]
#extracts the first complex number and arranges the real part and imaginary part in list
complex_1 = input[: input.find(')')].split('+') #Creates a list with the imaginary and real part of the first complex number
complex_1[1] = complex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_machine_state():\n with open(DUMP_FILE) as f:\n lines = f.read().split('\\n')[1:-1]\n result = []\n for line in lines:\n expr = re.search(':(.*)==', line)\n if expr:\n expr = expr.group(1)\n expr = expr.replace(' ', '').replace('\\t', '')\n ex... | [
"0.6138027",
"0.6121127",
"0.61057687",
"0.6081849",
"0.59309167",
"0.5839512",
"0.57881254",
"0.5773945",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5751823",
"0.5670008",
"0.56388474",
"0.5634351",... | 0.7212362 | 0 |
Gives the inverse of a complex number | def complex_inverse(c1,cr): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complex(real, imag):",
"def complexInverseTransform(self,S,t=1):\n N=self.display_number\n wo=2*cmath.pi/N\n return sum([S[k+(N-1)//2]*cmath.exp(complex(0,n*k*wo))+S[-k+(N-1)//2]*cmath.exp(-complex(0,n*k*wo)) for k in range(-(N-1)//2,(N-1)//2+1)])",
"def imag(z):",
"def __neg__(self)... | [
"0.75154704",
"0.7147476",
"0.71311414",
"0.70612556",
"0.6978767",
"0.685777",
"0.684297",
"0.6775225",
"0.67699707",
"0.6692239",
"0.6612446",
"0.65299463",
"0.6499767",
"0.6498678",
"0.64635146",
"0.64537835",
"0.6441647",
"0.6425552",
"0.6421526",
"0.64170927",
"0.6392162... | 0.8684161 | 0 |
returns an example java class with the given content_to_add contained within a method. | def setup_java_class(content_to_add):
template = """
public class Lambda {
public static void main(String args[]) {
%s
}
}
"""
return template % content_to_add | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def massage_addcontent(self) -> str:\n pass",
"def add_cloud_plugin_content(self, content):",
"def add(self, name, content):\n raise NotImplementedError",
"def getContent(self) -> object:\n ...",
"def test_return_class_content_by_accepts(self,request,**kwargs):\n \n class... | [
"0.5688367",
"0.54588896",
"0.5404581",
"0.52152133",
"0.5206995",
"0.51938957",
"0.5191317",
"0.51689",
"0.50840485",
"0.5079633",
"0.5074098",
"0.50603074",
"0.5041213",
"0.49788374",
"0.4978159",
"0.49747655",
"0.49458024",
"0.49165416",
"0.48773998",
"0.4876406",
"0.48631... | 0.6938231 | 0 |
yields the result of filtering the given class for the given type inside the given method identified by its name. | def filter_type_in_method(clazz, the_type, method_name):
for path, node in clazz.filter(the_type):
for p in reversed(path):
if isinstance(p, tree.MethodDeclaration):
if p.name == method_name:
yield path, node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(self, type_cls=None, name=None, parent=None,\n recurse=True, **kwargs):\n for child in self.children:\n yield_child = True\n if type_cls is not None and not isinstance(child, type_cls):\n yield_child = False\n if name is not None and child... | [
"0.5579115",
"0.53889966",
"0.528693",
"0.5262764",
"0.51862615",
"0.51247376",
"0.50571483",
"0.5042777",
"0.5006179",
"0.4999712",
"0.49813497",
"0.49657267",
"0.49450383",
"0.49249393",
"0.48390722",
"0.4835218",
"0.48347494",
"0.480984",
"0.4767575",
"0.4765008",
"0.47650... | 0.7936781 | 0 |
asserts that the given tree contains a method with the supplied method name containing a lambda expression. | def assert_contains_lambda_expression_in_m(
self, clazz, method_name='main'):
matches = list(filter_type_in_method(
clazz, tree.LambdaExpression, method_name))
if not matches:
self.fail('No matching lambda expression found.')
return matches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def islambda(func):\n return getattr(func, 'func_name', False) == '<lambda>'",
"def assert_contains_method_reference_expression_in_m(\n self, clazz, method_name='main'):\n matches = list(filter_type_in_method(\n clazz, tree.MethodReference, method_name))\n if not matches:\n... | [
"0.617128",
"0.5958876",
"0.59074825",
"0.58203065",
"0.57157063",
"0.556877",
"0.5536857",
"0.5388039",
"0.5374837",
"0.5349017",
"0.53409475",
"0.5333413",
"0.52868044",
"0.52440864",
"0.524379",
"0.5243559",
"0.5231998",
"0.5187295",
"0.51686335",
"0.5007466",
"0.50063246"... | 0.76842254 | 0 |
tests support for lambda with no parameters and no body. | def test_lambda_support_no_parameters_no_body(self):
self.assert_contains_lambda_expression_in_m(
parse.parse(setup_java_class("() -> {};"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lambda_support_no_parameters_expression_body(self):\n test_classes = [\n setup_java_class(\"() -> 3;\"),\n setup_java_class(\"() -> null;\"),\n setup_java_class(\"() -> { return 21; };\"),\n setup_java_class(\"() -> { System.exit(1); };\"),\n ]\n ... | [
"0.80729127",
"0.74344873",
"0.7054373",
"0.6943764",
"0.68140686",
"0.6785688",
"0.67151034",
"0.65730524",
"0.6569661",
"0.65103257",
"0.6321599",
"0.622041",
"0.6170041",
"0.61402935",
"0.60839546",
"0.60623306",
"0.60555327",
"0.6037857",
"0.5954021",
"0.5940796",
"0.5938... | 0.84038466 | 0 |
tests support for lambda with no parameters and an expression body. | def test_lambda_support_no_parameters_expression_body(self):
test_classes = [
setup_java_class("() -> 3;"),
setup_java_class("() -> null;"),
setup_java_class("() -> { return 21; };"),
setup_java_class("() -> { System.exit(1); };"),
]
for test_class... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lambda_support_no_parameters_no_body(self):\n self.assert_contains_lambda_expression_in_m(\n parse.parse(setup_java_class(\"() -> {};\")))",
"def test_lambda_support_no_parameters_complex_expression(self):\n code = \"\"\"\n () -> {\n if (true) return 21... | [
"0.8237042",
"0.789812",
"0.7607614",
"0.7564053",
"0.66187334",
"0.65741956",
"0.6445725",
"0.6386267",
"0.6354214",
"0.6325873",
"0.6297597",
"0.61535287",
"0.611211",
"0.5986383",
"0.5968808",
"0.58981645",
"0.5860768",
"0.5787954",
"0.5779984",
"0.57482404",
"0.57293206",... | 0.8515129 | 0 |
tests support for lambda with no parameters and a complex expression body. | def test_lambda_support_no_parameters_complex_expression(self):
code = """
() -> {
if (true) return 21;
else
{
int result = 21;
return result / 2;
}
};"""
self.assert_contains_lambda_expression_in_m(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lambda_support_no_parameters_expression_body(self):\n test_classes = [\n setup_java_class(\"() -> 3;\"),\n setup_java_class(\"() -> null;\"),\n setup_java_class(\"() -> { return 21; };\"),\n setup_java_class(\"() -> { System.exit(1); };\"),\n ]\n ... | [
"0.81713456",
"0.78946006",
"0.7401666",
"0.7397606",
"0.6608615",
"0.6350853",
"0.6305207",
"0.6291583",
"0.6200168",
"0.61838084",
"0.6138141",
"0.61052096",
"0.5982921",
"0.5887537",
"0.5879176",
"0.587861",
"0.58647954",
"0.5796548",
"0.57135075",
"0.56640196",
"0.5648967... | 0.8347692 | 0 |
tests support for lambda with parameters with inferred types. | def test_parameter_no_type_expression_body(self):
test_classes = [
setup_java_class("(bar) -> bar + 1;"),
setup_java_class("bar -> bar + 1;"),
setup_java_class("x -> x.length();"),
setup_java_class("y -> { y.boom(); };"),
]
for test_class in test_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parameter_with_type_expression_body(self):\n test_classes = [\n setup_java_class(\"(int foo) -> { return foo + 2; };\"),\n setup_java_class(\"(String s) -> s.length();\"),\n setup_java_class(\"(int foo) -> foo + 1;\"),\n setup_java_class(\"(Thread th) -> ... | [
"0.6770001",
"0.6204754",
"0.61187667",
"0.60630196",
"0.59949774",
"0.58227783",
"0.5814336",
"0.5771875",
"0.5771835",
"0.5755774",
"0.5725813",
"0.57181853",
"0.56826234",
"0.5670141",
"0.56571966",
"0.56439734",
"0.5603067",
"0.5598782",
"0.5596302",
"0.558963",
"0.558932... | 0.6362877 | 1 |
tests support for lambda with parameters with formal types. | def test_parameter_with_type_expression_body(self):
test_classes = [
setup_java_class("(int foo) -> { return foo + 2; };"),
setup_java_class("(String s) -> s.length();"),
setup_java_class("(int foo) -> foo + 1;"),
setup_java_class("(Thread th) -> { th.start(); };"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parameter_no_type_expression_body(self):\n test_classes = [\n setup_java_class(\"(bar) -> bar + 1;\"),\n setup_java_class(\"bar -> bar + 1;\"),\n setup_java_class(\"x -> x.length();\"),\n setup_java_class(\"y -> { y.boom(); };\"),\n ]\n for ... | [
"0.6990295",
"0.68102306",
"0.6719189",
"0.64171845",
"0.63848317",
"0.63742936",
"0.6351296",
"0.63345313",
"0.6326092",
"0.6323855",
"0.63195014",
"0.61979765",
"0.61734456",
"0.61037934",
"0.61007315",
"0.6051868",
"0.6031708",
"0.602459",
"0.6006871",
"0.59679264",
"0.595... | 0.73754215 | 0 |
this tests that lambda inferred type parameters with modifiers are considered invalid as per the specifications. | def test_parameters_inferred_types_with_modifiers(self):
with self.assertRaises(parser.JavaSyntaxError):
parse.parse(setup_java_class("(x, final y) -> x+y;")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parameters_with_no_type_expression_body(self):\n self.assert_contains_lambda_expression_in_m(\n parse.parse(setup_java_class(\"(x, y) -> x + y;\")))",
"def test_wrong_parameters(self):\n with self.assertWarns(RuntimeWarning):\n Parameters(1, mu=3, lambda_=2)",
"def ... | [
"0.6253618",
"0.6095311",
"0.6067094",
"0.60574394",
"0.60560644",
"0.599869",
"0.5991231",
"0.592626",
"0.59158516",
"0.59147567",
"0.58882666",
"0.58656836",
"0.58415097",
"0.5812123",
"0.5801062",
"0.5665836",
"0.56471264",
"0.55471206",
"0.55354756",
"0.55250245",
"0.5479... | 0.68074924 | 0 |
asserts that the given class contains a method with the supplied method name containing a method reference. | def assert_contains_method_reference_expression_in_m(
self, clazz, method_name='main'):
matches = list(filter_type_in_method(
clazz, tree.MethodReference, method_name))
if not matches:
self.fail('No matching method reference found.')
return matches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"String::length;\")))",
"def test_method_reference_to_the_new_method(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_ja... | [
"0.705527",
"0.6993392",
"0.67777693",
"0.6380639",
"0.61472267",
"0.61190903",
"0.59145284",
"0.5907902",
"0.58824646",
"0.5840844",
"0.58133096",
"0.5741961",
"0.5727664",
"0.57094765",
"0.5708181",
"0.57038707",
"0.5659484",
"0.56593657",
"0.563125",
"0.5572199",
"0.556212... | 0.7993113 | 0 |
tests that method references are supported. | def test_method_reference(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("String::length;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference_to_the_new_method(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"String::new;\")))",
"def assert_contains_method_reference_expression_in_m(\n self, clazz, method_name='main'):\n matches = list(filter_t... | [
"0.6648142",
"0.65056455",
"0.63364893",
"0.6272095",
"0.6261892",
"0.6151495",
"0.59726846",
"0.5946151",
"0.59377086",
"0.5902228",
"0.5880807",
"0.58606213",
"0.5852694",
"0.58012897",
"0.5799396",
"0.5785118",
"0.5785118",
"0.57442874",
"0.5717935",
"0.5686207",
"0.568619... | 0.70096177 | 0 |
test support for method references to 'new'. | def test_method_reference_to_the_new_method(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("String::new;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # rea... | [
"0.74459124",
"0.74459124",
"0.74459124",
"0.74459124",
"0.74459124",
"0.74459124",
"0.73973083",
"0.73797446",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107",
"0.73705107"... | 0.7648247 | 0 |
test support for method references to 'new' with an explicit type. | def test_method_reference_to_the_new_method_with_explict_type(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("String::<String> new;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # real signature unknown\n pass",
"def __new__(*args, **kwargs): # rea... | [
"0.7321677",
"0.7321677",
"0.7321677",
"0.7321677",
"0.7321677",
"0.7321677",
"0.7182818",
"0.7158213",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"0.7104828",
"... | 0.7463056 | 0 |
test support for method references from 'super'. | def test_method_reference_from_super(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("super::toString;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference_from_super_with_identifier(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"String.super::toString;\")))",
"def _call_method(self, call, method):\n raise Exception(\"_call_method must be implemented by subclasses.\... | [
"0.68993855",
"0.62743145",
"0.61940485",
"0.6186825",
"0.6183579",
"0.6055899",
"0.59670895",
"0.5957449",
"0.59462684",
"0.59454656",
"0.5930068",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866",
"0.5926866... | 0.77726084 | 0 |
test support for method references from Identifier.super. | def test_method_reference_from_super_with_identifier(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("String.super::toString;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference_from_super(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"super::toString;\")))",
"def identify_method(self, func):",
"def test_method_reference_to_the_new_method_with_explict_type(self):\n self.assert_contains... | [
"0.76915973",
"0.6200483",
"0.6165793",
"0.61514074",
"0.61412233",
"0.6108134",
"0.5917158",
"0.5869482",
"0.58550006",
"0.5694843",
"0.5658008",
"0.55911136",
"0.5523074",
"0.5446574",
"0.5409539",
"0.53997695",
"0.5387169",
"0.53849185",
"0.53687805",
"0.53687805",
"0.5351... | 0.8169555 | 0 |
currently there is no support for method references for an explicit type. | def test_method_reference_explicit_type_arguments_for_generic_type(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("List<String>::size;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference_to_the_new_method_with_explict_type(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"String::<String> new;\")))",
"def test_method_reference_explicit_type_arguments(self):\n self.assert_contains_method_reference_ex... | [
"0.683861",
"0.68118775",
"0.63020563",
"0.6255957",
"0.6142858",
"0.5945745",
"0.5936603",
"0.58913815",
"0.5739358",
"0.56731254",
"0.5664965",
"0.5630714",
"0.5621771",
"0.561959",
"0.5577044",
"0.5565672",
"0.5471961",
"0.546955",
"0.5410558",
"0.5399276",
"0.5369267",
... | 0.6817279 | 1 |
test support for method references with an explicit type. | def test_method_reference_explicit_type_arguments(self):
self.assert_contains_method_reference_expression_in_m(
parse.parse(setup_java_class("Arrays::<String> sort;"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_method_reference_explicit_type_arguments_for_generic_type(self):\n self.assert_contains_method_reference_expression_in_m(\n parse.parse(setup_java_class(\"List<String>::size;\")))",
"def test_method_reference_to_the_new_method_with_explict_type(self):\n self.assert_contains_meth... | [
"0.74338806",
"0.72935617",
"0.6595524",
"0.647858",
"0.64493185",
"0.6399294",
"0.6076212",
"0.6066672",
"0.59705216",
"0.59512925",
"0.59246725",
"0.5907049",
"0.5875997",
"0.5838164",
"0.5815722",
"0.5778507",
"0.57668805",
"0.57507026",
"0.56757945",
"0.5651304",
"0.56393... | 0.74700195 | 0 |
Saves network architecture and parameters to network path | def save(self):
self.save_network_architecture( network_path=self.network_path )
self.save_network_parameters(
file_name='net_parameters', file_path=self.network_path ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_network(self, **kwargs):\n raise NotImplementedError",
"def save_network(network, fpath):\n\twith open(fpath, \"wb\") as f:\n\t\tpickle.dump(network, f)",
"def save_utility_network(self,path_save):\n print(\"Save the neural network to : \"+path_save)\n self.nn.save_on_file(path_sa... | [
"0.7553372",
"0.74460864",
"0.73969615",
"0.7264144",
"0.7263547",
"0.7254173",
"0.7172828",
"0.70739216",
"0.6998701",
"0.6983283",
"0.69021493",
"0.68638515",
"0.6846523",
"0.68310755",
"0.6790376",
"0.6757939",
"0.6755108",
"0.6725326",
"0.6595413",
"0.6586934",
"0.6565589... | 0.842718 | 0 |
Restores network parameters to last saved values | def restore(self):
if os.path.isfile( \
os.path.join(self.network_path,'net_parameters.nnprm.index')):
self.load_network_parameters(
file_name='net_parameters', file_path=self.network_path)
else:
self.log("Could not load previous network parameters fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self):\n pert_params = list(self.net.parameters())\n saved_params = list(self.saved_net.parameters())\n for perturbed, saved in zip(pert_params, saved_params):\n perturbed_shape = perturbed.shape\n saved_shape = saved.shape\n perturbed = perturbed.f... | [
"0.7624994",
"0.7181976",
"0.68304336",
"0.67606837",
"0.66665417",
"0.6624656",
"0.66192657",
"0.660528",
"0.65803695",
"0.65579176",
"0.65551466",
"0.654185",
"0.6491765",
"0.6453688",
"0.64398676",
"0.6435174",
"0.6413157",
"0.640428",
"0.6402615",
"0.6373396",
"0.6373396"... | 0.79007125 | 0 |
Loads the network architecture from the network path | def load_network_architecture(self,network_path):
net_architecture = np.load(
os.path.join(network_path,'net_architecture.npy')).item()
self.log("Network architecture loaded from file:\n{}".format(
os.path.join(network_path,'net_architecture.npy')))
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadNetwork(path, arch):\n if arch in resnet.__dict__:\n model = resnet.__dict__[arch]()\n model.load_state_dict(torch.load(path, map_location=device))\n return model\n elif arch in other_resnet.__dict__:\n model = other_resnet.__dict__[arch]()\n model.load_state_dict(t... | [
"0.7389239",
"0.7079259",
"0.6949794",
"0.68808204",
"0.6675771",
"0.6375226",
"0.6370736",
"0.6185641",
"0.61838895",
"0.6183848",
"0.6041023",
"0.6032674",
"0.5999657",
"0.5967387",
"0.5965837",
"0.5961188",
"0.59594095",
"0.59247637",
"0.58848923",
"0.58805215",
"0.5876722... | 0.79762596 | 0 |
Trains the network on a training set for a specified number of epochs. It loads a random training set from the annotated_image_set on every epoch | def train_epochs(self, annotated_image_set, n_epochs=100, report_every=10,
annotation_type='Bodies', m_samples=100,
sample_ratio=None, normalize_samples=False,
annotation_border_ratio=None,
morph_annotations=False, rotation_list=None,
scale_list_x=None, scale_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_batch(self, annotated_image_set, n_batches=10, n_epochs=100,\n annotation_type='Bodies', batch_size=1000, m_samples=100,\n sample_ratio=None, annotation_border_ratio=None,\n normalize_samples=False, morph_annotations=False,\n rotation_list=None, scale_list_x=No... | [
"0.72097707",
"0.7013612",
"0.6987202",
"0.6903588",
"0.6727891",
"0.6685835",
"0.6678328",
"0.6673476",
"0.66453606",
"0.66346186",
"0.66054946",
"0.66054946",
"0.66054946",
"0.66054946",
"0.65911376",
"0.6588606",
"0.6556185",
"0.6535054",
"0.65278286",
"0.6512619",
"0.6487... | 0.7328531 | 0 |
Trains the network on a training set for a specified number of batches of size batch_size. Every batch iteration it loads a random training batch from the annotated_image_set. Per batch, training is done for n_epochs on a random sample of size m_samples that is selected from the current batch. | def train_batch(self, annotated_image_set, n_batches=10, n_epochs=100,
annotation_type='Bodies', batch_size=1000, m_samples=100,
sample_ratio=None, annotation_border_ratio=None,
normalize_samples=False, morph_annotations=False,
rotation_list=None, scale_list_x=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_epochs(self, annotated_image_set, n_epochs=100, report_every=10,\n annotation_type='Bodies', m_samples=100,\n sample_ratio=None, normalize_samples=False,\n annotation_border_ratio=None,\n morph_annotations=False, rotation_list=None,\n scale_list_x=No... | [
"0.7335554",
"0.71551514",
"0.70479625",
"0.6945909",
"0.6860778",
"0.67783463",
"0.670956",
"0.66970265",
"0.6688352",
"0.6661267",
"0.6661267",
"0.6643149",
"0.6621342",
"0.66189015",
"0.6614666",
"0.66040385",
"0.6597011",
"0.6593609",
"0.6576911",
"0.65408987",
"0.6539638... | 0.78902054 | 0 |
Displays the network architecture | def display_network_architecture(self):
self.log("\n-------- Network architecture --------")
self.log("y_res: {}".format(self.y_res))
self.log("x_res: {}".format(self.x_res))
self.log("n_input_channels: {}".format(self.n_input_channels))
self.log("n_output_classes: {}".format(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_network_architecture(self):\n self.log(\"\\n-------- Network architecture --------\")\n self.log(\"y_res: {}\".format(self.y_res))\n self.log(\"x_res: {}\".format(self.x_res))\n self.log(\"n_input_channels: {}\".format(self.n_input_channels))\n self.log(\"n_output_cla... | [
"0.80215245",
"0.782012",
"0.65890074",
"0.6553099",
"0.65155137",
"0.6325483",
"0.6325483",
"0.61430705",
"0.61319727",
"0.6125435",
"0.6125435",
"0.61056787",
"0.6052028",
"0.5946873",
"0.59226936",
"0.58650655",
"0.58594865",
"0.58404994",
"0.58262026",
"0.58259773",
"0.58... | 0.8023673 | 0 |
Displays the network architecture | def display_network_architecture(self):
self.log("\n-------- Network architecture --------")
self.log("y_res: {}".format(self.y_res))
self.log("x_res: {}".format(self.x_res))
self.log("n_input_channels: {}".format(self.n_input_channels))
self.log("n_output_classes: {}".format(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_network_architecture(self):\n self.log(\"\\n-------- Network architecture --------\")\n self.log(\"y_res: {}\".format(self.y_res))\n self.log(\"x_res: {}\".format(self.x_res))\n self.log(\"n_input_channels: {}\".format(self.n_input_channels))\n self.log(\"n_output_cla... | [
"0.8023673",
"0.782012",
"0.65890074",
"0.6553099",
"0.65155137",
"0.6325483",
"0.6325483",
"0.61430705",
"0.61319727",
"0.6125435",
"0.6125435",
"0.61056787",
"0.6052028",
"0.5946873",
"0.59226936",
"0.58650655",
"0.58594865",
"0.58404994",
"0.58262026",
"0.58259773",
"0.581... | 0.80215245 | 1 |
This is a helper method to convert a string into a list with the string only Or if the input is already list, simply return itself Meanwhile if the email address is invalid, remove it from the list | def list_or_str_to_valid_list(self, list_or_string):
if isinstance(list_or_string, list):
for email in list_or_string:
if not self.validate_email_address(email):
list_or_string.remove(email)
return list_or_string
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str2list(input):\n if isinstance(input, str):\n return [input]\n\n else:\n return input",
"def test_get_and_clean_student_list(self):\r\n\r\n string = \"abc@test.com, def@test.com ghi@test.com \\n \\n jkl@test.com \\n mno@test.com \"\r\n cleaned_string, cleaned_string_lc... | [
"0.69745934",
"0.66313756",
"0.6629959",
"0.6556719",
"0.65227515",
"0.64520884",
"0.6336295",
"0.6326581",
"0.6313591",
"0.6305956",
"0.6301915",
"0.62475663",
"0.62469447",
"0.621201",
"0.61967224",
"0.6175047",
"0.6165419",
"0.61456656",
"0.61454946",
"0.6100574",
"0.60820... | 0.85227793 | 0 |
This is to send email by the email sender class and failover. It will also validate the from, to email address. Validate the subject and email content text. It will return an status code and message The to_list, cc_list and bcc_list could be None or an empty list [] or a string representing one email address, or a list... | def send_email(self, from_email, to_list, cc_list, bcc_list, subject, text):
if from_email is None or len(from_email) == 0 or not self.validate_email_address(from_email):
return 1, 'from email address invalid'
if to_list is None or len(to_list) == 0:
to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(self, from_email, to_list, cc_list, bcc_list, subject, text):\n\n to_address_list = []\n\n if len(to_list) > 0:\n for to_address in to_list:\n to_address_list.append(\n {\n \"email\": to_address,\n \"t... | [
"0.6779173",
"0.66605467",
"0.6638099",
"0.65904844",
"0.6572935",
"0.64000165",
"0.63079566",
"0.6267483",
"0.62407327",
"0.6211447",
"0.61672854",
"0.61475056",
"0.6124481",
"0.6114875",
"0.60997105",
"0.60990864",
"0.60969037",
"0.6058803",
"0.6044764",
"0.604214",
"0.5999... | 0.81770855 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.