query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Generate a random string of fixed length | def randomString(self, stringLength=2):
letters = string.ascii_uppercase
return ''.join(random.choice(letters) for i in range(stringLength)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8680464",
"0.8573714",
"0.85486245",
"0.85297275",
"0.85209286",
"0.84331024",
"0.8432044",
"0.84157014",
"0.84120053",
"0.8389201",
"0.8345882",
"0.8343962",
"0.83406156",
"0.83348686",
"0.83240855",
"0.82986933",
"0.82911193",
"0.8281826",
"0.82818025",
"0.82811046",
"0.... | 0.77776515 | 83 |
Test retrieving profile for logged in users | def test_retrieve_profile_success(self):
res = self.client.get(ME_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(res.data, {
'name': self.user.name,
'email': self.user.email
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_profiles(self):\n\n result = self.client.get(\"/profile/1\")\n self.assertIn(b'In house:',result.data)",
"def test_retrieve_profile(self):\n\n response = self.client.get(URL_ME)\n\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n\n # Check that the us... | [
"0.81711257",
"0.80854654",
"0.79636335",
"0.7941477",
"0.79225314",
"0.7913775",
"0.78914225",
"0.7851111",
"0.78483266",
"0.78402805",
"0.78152454",
"0.7808281",
"0.7798181",
"0.77953845",
"0.77234495",
"0.772056",
"0.7701586",
"0.76450664",
"0.7635928",
"0.7625624",
"0.761... | 0.7885846 | 7 |
Returns the SQS queue associated with the name provided | def get_queue_by_name(name):
sqs = boto3.resource('sqs')
return sqs.get_queue_by_name(QueueName=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue(self, task_name):\n for name, queue in self.queues.items():\n if task_name in queue:\n return name\n return self.default_queue",
"def sqs_lookup_url(session, queue_name):\n client = session.client('sqs')\n resp = client.get_queue_url(QueueName=queue_nam... | [
"0.7586098",
"0.70955753",
"0.70654523",
"0.6963068",
"0.66689426",
"0.66041845",
"0.65472215",
"0.6489761",
"0.64880717",
"0.6451502",
"0.6430923",
"0.6404732",
"0.6282781",
"0.62749827",
"0.6266604",
"0.62122804",
"0.6192859",
"0.61644053",
"0.6142807",
"0.61416143",
"0.609... | 0.89727956 | 0 |
Gets the source_id of this SourceSchema. | def source_id(self) -> str:
return self._source_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_id(self):\n return self._source_id",
"def source_id(self) -> Optional[str]:\n return pulumi.get(self, \"source_id\")",
"def source_identifier(self) -> str:\n return pulumi.get(self, \"source_identifier\")",
"def source_identifier(self) -> str:\n return pulumi.get(self, ... | [
"0.8383902",
"0.79836535",
"0.76179427",
"0.76179427",
"0.74200153",
"0.7084294",
"0.7084294",
"0.70629627",
"0.6992628",
"0.68882525",
"0.68882525",
"0.67980164",
"0.6670204",
"0.6665483",
"0.66482115",
"0.6584191",
"0.65593994",
"0.6546823",
"0.64896107",
"0.64815307",
"0.6... | 0.81867415 | 2 |
Sets the source_id of this SourceSchema. | def source_id(self, source_id: str):
if source_id is None:
raise ValueError("Invalid value for `source_id`, must not be `None`") # noqa: E501
self._source_id = source_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_id(self, source_id: str):\n\n self._source_id = source_id",
"def source_id(self, source_id):\n\n self._source_id = source_id",
"def source_id(self, source_id):\n\n self._source_id = source_id",
"def source_id(self, source_id):\n if source_id is None:\n raise ... | [
"0.8360772",
"0.828087",
"0.828087",
"0.798003",
"0.72521406",
"0.71138036",
"0.7015518",
"0.6578036",
"0.6526695",
"0.65239024",
"0.6492135",
"0.634931",
"0.634931",
"0.63388735",
"0.632033",
"0.62579215",
"0.62217927",
"0.6212664",
"0.6212622",
"0.6211954",
"0.6183537",
"... | 0.7979072 | 4 |
Sets the source of this SourceSchema. | def source(self, source: List[StateSchema]):
if source is None:
raise ValueError("Invalid value for `source`, must not be `None`") # noqa: E501
self._source = source | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_source(self, source):\n self.data['source'] = source",
"def source(self, source):\n\n self._source = source",
"def source(self, source):\n\n self._source = source",
"def source(self, source):\n\n self._source = source",
"def source(self, source):\n\n self._source ... | [
"0.7880129",
"0.75935674",
"0.75935674",
"0.75935674",
"0.75935674",
"0.75935674",
"0.75935674",
"0.75935674",
"0.75273",
"0.7499188",
"0.7447674",
"0.7394303",
"0.7374431",
"0.7339089",
"0.7145187",
"0.70432156",
"0.69777626",
"0.69777626",
"0.6923888",
"0.68695354",
"0.6804... | 0.747181 | 10 |
This function test the valid IP address will be saved | def valid_address_saved(addr,message):
adr = addr.split('.')
Debug.info(message)
doubleClick(Location(728, 516))
paste(str(adr[0]))
if len(adr[0])< 3:
type(Key.TAB)
else:
type ("a",KeyModifier.CTRL)
paste(str(adr[1]))
if len(adr[1]) < 3 :
type(Key.TAB)
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ip(self):\n ##Todo: Improve this check\n ip = socket.gethostbyname(socket.gethostname())\n ip = [int(i) for i in ip.split('.')]\n assert len(ip) == 4\n assert ip[0] == 10\n assert ip[1] == 137\n assert ip[2] == 1\n assert ip[3] >= 1 and ip[3] <= 255"... | [
"0.751344",
"0.7285146",
"0.7249641",
"0.7199421",
"0.7142184",
"0.7121088",
"0.70631504",
"0.6990609",
"0.695461",
"0.6885162",
"0.6871393",
"0.6852756",
"0.6837679",
"0.68362784",
"0.6824195",
"0.6816933",
"0.6713933",
"0.6711242",
"0.67022645",
"0.666929",
"0.6658758",
"... | 0.64658344 | 38 |
Test the unvalid IP address | def public_static_ip_range_tab_screen(n1,n2,n3,n4, message):
Debug.info(message)
doubleClick(Location(728, 516))
paste(str(n1))
if len(n1)< 3:
type(Key.TAB)
else:
type ("a",KeyModifier.CTRL)
paste(str(n2))
if len(n2) < 3 :
type(Key.TAB)
else:
type ("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __checkIPAddr(self,ip):\n if not iplib.checkIPAddrWithoutMask(ip):\n raise GeneralException(errorText(\"GENERAL\",\"INVALID_IP_ADDRESS\")%ip)",
"def is_valid_ip(ip):\n ...",
"def validateIP():\n try:\n s = socket.inet_aton(args.target)\n except socket.error:\n ... | [
"0.8100674",
"0.8080593",
"0.8072465",
"0.7915526",
"0.7725667",
"0.77133286",
"0.76433736",
"0.76405567",
"0.7635958",
"0.75719017",
"0.7571086",
"0.75484586",
"0.75292194",
"0.7521892",
"0.7507904",
"0.75061595",
"0.75057834",
"0.7476333",
"0.74688935",
"0.74586",
"0.744213... | 0.0 | -1 |
Mean Arctangent Absolute Percentage Error | def maape(actual: np.ndarray, predicted: np.ndarray):
return np.mean(np.arctan(np.abs((actual - predicted) / (actual + EPSILON)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maape(self) -> float:\n return float(np.mean(np.arctan(np.abs((self.true - self.predicted) / (self.true + EPS)))))",
"def mae(actual, predicted):\n rms = np.abs(actual-predicted)\n\n # Returning the sqaure root of the root mean square\n return float(rms.mean())",
"def mae(t, y):\n\treturn m... | [
"0.71263194",
"0.68211216",
"0.68203205",
"0.67147535",
"0.6604331",
"0.6600438",
"0.6564151",
"0.6525782",
"0.6479799",
"0.647424",
"0.6469288",
"0.6465817",
"0.6458842",
"0.64391905",
"0.6432964",
"0.6428075",
"0.6418386",
"0.6414736",
"0.6395974",
"0.6375605",
"0.6363231",... | 0.6611123 | 4 |
Symmetric Mean Absolute Percentage Error | def smape(actual: np.ndarray, predicted: np.ndarray):
return np.mean(np.divide(np.abs(actual - predicted), (np.abs(actual) + np.abs(predicted) + np.finfo(float).eps) * 0.5)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _symmetric_mean_absolute_percentage_error_compute(sum_abs_per_error: Tensor, num_obs: int) ->Tensor:\n return sum_abs_per_error / num_obs",
"def _mean_absolute_percentage_error_compute(sum_abs_per_error: Tensor, num_obs: int) ->Tensor:\n return sum_abs_per_error / num_obs",
"def _mean_absolute_error_... | [
"0.7984505",
"0.7271417",
"0.70238733",
"0.6960333",
"0.69289076",
"0.68264985",
"0.68179744",
"0.67925465",
"0.6789411",
"0.6787597",
"0.6661828",
"0.6661828",
"0.66364896",
"0.6633226",
"0.66244555",
"0.65166587",
"0.6485501",
"0.6461034",
"0.6442152",
"0.6438563",
"0.64290... | 0.6187274 | 46 |
Returns the absolute path to the indicated data file stored under the 'data/' folder colocated with this module. | def get_path(data_path):
return os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def get_data_path():\n\n # Get pathname absolute or relative.\n path = os.path.join(\n os.path.dirname(__file__), __malstor_data_directory__)\n\n abs_data_path = os.path.abspath(path)\n if not os.path.exists(abs_data_path):\n ... | [
"0.8665063",
"0.86533004",
"0.8613001",
"0.835773",
"0.8282328",
"0.81024015",
"0.8044464",
"0.80244017",
"0.8019964",
"0.7980718",
"0.7949705",
"0.7932424",
"0.7923546",
"0.7854824",
"0.78408027",
"0.7828998",
"0.7806845",
"0.7789293",
"0.77636874",
"0.77380025",
"0.77012616... | 0.81513727 | 5 |
Returns True if the types and values are the same. | def __eq__(self, other):
return self.type == other.type and self.value == other.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _values_of_same_type(self, val1, val2):\n if self.f_supports(val1) != self.f_supports(val2):\n return False\n\n if not self.f_supports(val1) and not self.f_supports(val2):\n raise TypeError(\n \"I do not support the types of both inputs (`%s` and `%s`),\"\n ... | [
"0.80351937",
"0.78741366",
"0.77644867",
"0.7698466",
"0.7614705",
"0.7556479",
"0.7370863",
"0.7100185",
"0.709661",
"0.70739865",
"0.7073445",
"0.70564276",
"0.6972106",
"0.68879265",
"0.6849391",
"0.68440783",
"0.6787801",
"0.670629",
"0.6698581",
"0.6692789",
"0.6691776"... | 0.6846985 | 15 |
The name of the company associated with this Stock. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_name(self):\n if \"companyName\" in self._prop_dict:\n return self._prop_dict[\"companyName\"]\n else:\n return None",
"def company_name(self) -> Optional[str]:\n return pulumi.get(self, \"company_name\")",
"def getCompanyName(self, stockSymbol):\n ... | [
"0.8355501",
"0.8252127",
"0.81619966",
"0.7995412",
"0.7614332",
"0.7614332",
"0.75054485",
"0.7444551",
"0.7430095",
"0.7424251",
"0.7085025",
"0.6762083",
"0.6760923",
"0.67401886",
"0.6685852",
"0.66094697",
"0.64340585",
"0.63975626",
"0.63522387",
"0.63446784",
"0.63136... | 0.0 | -1 |
Set the name of this Stock. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self._name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n ... | [
"0.82686764",
"0.8238836",
"0.8238836",
"0.8238836",
"0.8238836",
"0.8238836",
"0.82038474",
"0.8182663",
"0.8115692",
"0.8089347",
"0.8073546",
"0.805207",
"0.805207",
"0.8029298",
"0.8029298",
"0.8007828",
"0.7965118",
"0.7936267",
"0.7936267",
"0.7867074",
"0.78632426",
... | 0.7675622 | 39 |
The market this Stock is traded in. | def market(self):
return self._market | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMarket(self):\n return self.market",
"def ticker(self):\n return self.__train_prop[\"ticker\"]",
"def get_active_market_street(market):\r\n return market[-1]",
"def stock_exchange(self):\n return self._stock_exchange",
"def C_stock(self):\n return self._C_stock",
"d... | [
"0.8479414",
"0.6752942",
"0.6742229",
"0.6701783",
"0.66812474",
"0.66744",
"0.65810895",
"0.6480096",
"0.6410698",
"0.6272628",
"0.62642443",
"0.62600577",
"0.62460387",
"0.621263",
"0.621263",
"0.6204755",
"0.6177224",
"0.61157995",
"0.61031985",
"0.60630023",
"0.6054271",... | 0.86703336 | 0 |
Set the market this Stock is traded in. | def market(self, market):
self._market = market | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_portfolio_on_market(self, market: MarketEvent):\n self._portfolio.update_market_value(market)",
"def trade(self, trade: float):\n if trade is None:\n raise ValueError(\"Invalid value for `trade`, must not be `None`\") # noqa: E501\n\n self._trade = trade",
"def marke... | [
"0.6286877",
"0.60998654",
"0.60863835",
"0.600833",
"0.59894824",
"0.5924932",
"0.589315",
"0.58679235",
"0.58330905",
"0.5823143",
"0.57429796",
"0.5694203",
"0.5628661",
"0.5593688",
"0.55125326",
"0.5445756",
"0.5417705",
"0.5396171",
"0.53932947",
"0.53810024",
"0.537136... | 0.8283994 | 0 |
Set the revenue per market cap. | def pe_ratio(self, pe_ratio):
self._pe_ratio = pe_ratio | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_revenue(self) -> float:\n revenue_collections = self.demand_served() * self.inputs.revenue_per_m3\n return revenue_collections + self.revenue_landfill()",
"def r(x):\n revenue = per_widget_revenue * x\n return revenue",
"def set_current_rate(self, rate_to_set):\n pass",
"de... | [
"0.6061146",
"0.586547",
"0.58105975",
"0.578652",
"0.5729379",
"0.5641834",
"0.5556773",
"0.5544031",
"0.5524396",
"0.5474875",
"0.5360377",
"0.5360377",
"0.535134",
"0.5343912",
"0.5252631",
"0.521897",
"0.52160734",
"0.5207761",
"0.518836",
"0.5156886",
"0.5132023",
"0.5... | 0.0 | -1 |
Checks whether the region type is valid in CRTF format | def test_valid_region_type():
reg_str = 'hyperbola[[18h12m24s, -23d11m00s], 2.3arcsec]'
with pytest.raises(CRTFRegionParserError) as excinfo:
Regions.parse(reg_str, format='crtf')
assert 'Not a valid CRTF Region type: "hyperbola"' in str(excinfo.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_crtf(self):\n if self.region_type not in regions_attributes:\n raise ValueError(\"'{}' is not a valid region type in this package\"\n \"supported by CRTF\".format(self.region_type))\n\n if self.coordsys not in valid_coordsys['CRTF']:\n raise... | [
"0.76998967",
"0.6557505",
"0.62991804",
"0.6064255",
"0.6013864",
"0.60021484",
"0.5830083",
"0.5794553",
"0.5695507",
"0.56873155",
"0.5646396",
"0.5640338",
"0.5635461",
"0.56344134",
"0.55852085",
"0.5580561",
"0.55454314",
"0.5538473",
"0.54316336",
"0.54048306",
"0.5402... | 0.70973265 | 1 |
r"""Gets details of a single Cluster. | def Get(self, request, global_params=None):
config = self.GetMethodConfig('Get')
return self._RunMethod(
config, request, global_params=global_params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detail_cluster(cluster_name, znode):\n\n _cluster_info = dict()\n _cluster_info.update(app.clusters[cluster_name].__dict__)\n _cluster_info.pop(\"auth_data\", None)\n _cluster_info[\"connection\"] = app.managers[cluster_name]._client.state\n resp = Response(json.dumps(_cluster_info),\n ... | [
"0.7688785",
"0.75866675",
"0.73177177",
"0.7268437",
"0.7075167",
"0.7062712",
"0.7060756",
"0.7026709",
"0.700013",
"0.69541407",
"0.6943902",
"0.6943902",
"0.6932986",
"0.6873242",
"0.68467164",
"0.6832071",
"0.6754254",
"0.67508876",
"0.6710992",
"0.6682692",
"0.66444176"... | 0.0 | -1 |
r"""Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. | def GetIamPolicy(self, request, global_params=None):
config = self.GetMethodConfig('GetIamPolicy')
return self._RunMethod(
config, request, global_params=global_params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy(self) -> Optional[str]:\n return pulumi.get(self, \"policy\")",
"def GetPolicy(self, request, global_params=None):\n config = self.GetMethodConfig('GetPolicy')\n return self._RunMethod(\n config, request, global_params=global_params)",
"def policy(self) -> Optional[pulumi.I... | [
"0.6401397",
"0.6327003",
"0.6309178",
"0.6309178",
"0.6294312",
"0.6246665",
"0.6238207",
"0.6238207",
"0.62309676",
"0.6223123",
"0.61790425",
"0.61739725",
"0.61739725",
"0.61739725",
"0.61679745",
"0.6141191",
"0.612441",
"0.6118661",
"0.6116921",
"0.61140686",
"0.6087465... | 0.0 | -1 |
Returns the coverage for a given chromosome as a numpy.array. | def get_coverage_as_array(self, length):
coverage = np.array(zeros(length))
for i in range(0,length):
coverage[i] = self.coverage(sequence, i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_codon_arr(chromosome: Chromosome) -> np.ndarray:\n\n seq_len = len(chromosome.sequence)\n arr = np.zeros((seq_len - 2,), dtype=np.int)\n\n for f in chromosome.features:\n\n if f.type != 'CDS':\n continue\n if f.strand == '-':\n continue\n\n protein_len = ... | [
"0.7548198",
"0.6989481",
"0.6375022",
"0.6281755",
"0.6167503",
"0.611115",
"0.59425646",
"0.59393924",
"0.5873697",
"0.5763089",
"0.5592977",
"0.5540678",
"0.5533475",
"0.54621303",
"0.54189223",
"0.5390265",
"0.53751206",
"0.53498065",
"0.53346527",
"0.5306799",
"0.5235013... | 0.7295931 | 1 |
Returns True if n is a prime, and False it is a composite by trying to divide it by two and all the odd numbers lesser than or equal to the value in the position K. Returns None if test is inconclusive. | def basicIsPrime(n,K=100):
if n % 2 == 0:
return n == 2
if n in primesList.lessThanHundredThousand:
return True
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n, k):\n if n <= 1 or n == 4:\n return False\n if n <= 3:\n return True\n if is_even(n):\n return False\n while k > 0:\n\n # Take random int in [2, n-2]\n a = random.randint(2, n-1)\n\n # Check if a and n are co-prime.\n if gcd(n, a) != 1:\n... | [
"0.74357015",
"0.731782",
"0.7311119",
"0.717771",
"0.71527344",
"0.71204925",
"0.71063787",
"0.70990884",
"0.702568",
"0.7013384",
"0.69846207",
"0.6954042",
"0.690117",
"0.6888829",
"0.6875123",
"0.68724287",
"0.68572426",
"0.68443406",
"0.6841368",
"0.6841368",
"0.6827087"... | 0.7840354 | 0 |
The density of the sparse matrixthat is, the number of nonzero elements per row divided by the length of a row. | def density(self):
return self.nnz/self.dim | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_density(matrix):\n return matrix.getnnz() / (matrix.shape[0] * matrix.shape[1])",
"def density(self):\n return self.nnz / self.size",
"def density(tensor):\n # Using torch.nonzero(tensor) can lead to memory exhaustion on\n # very large tensors, so we count zeros \"manually\".\n nonze... | [
"0.7897565",
"0.7803707",
"0.6861916",
"0.6744389",
"0.66349286",
"0.6461354",
"0.6453647",
"0.6378891",
"0.627",
"0.61604875",
"0.6159487",
"0.6093237",
"0.6042236",
"0.6042236",
"0.6042236",
"0.60359555",
"0.60097235",
"0.5959616",
"0.5934346",
"0.5932718",
"0.5885556",
"... | 0.78363645 | 1 |
Get the representation of the operator in the (mask, sign, coefficient) | def get_MSC(self,shift_index=None,wrap=False):
if shift_index is None:
# the value of wrap doesn't matter if no shift index
if self._MSC is None:
self._MSC = self._get_MSC()
return self._MSC
else:
return self._get_MSC(shift_index,wrap=wrap) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_operator(key):\n # Check for simple operators\n if key.startswith('re_'):\n operator = np.real\n newkey = key[3:]\n elif key.startswith('im_'):\n operator = np.imag\n newkey = key[3:]\n elif key.startswith('abs_'):\n operator = np.abs\n newkey = key[4:]... | [
"0.65425664",
"0.61764455",
"0.6144061",
"0.6116314",
"0.61015916",
"0.60782915",
"0.6009125",
"0.5982865",
"0.59713227",
"0.59678555",
"0.5949723",
"0.59272075",
"0.58483416",
"0.5828794",
"0.5828794",
"0.58127415",
"0.5797213",
"0.5748041",
"0.5748041",
"0.5745424",
"0.5731... | 0.0 | -1 |
Test if user that is not registered can get the email | def test_email_not_registered(self):
response = self.client.post(self.password_reset_url,
self.email_not_registered,
format="json")
self.assertEqual(response. status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(json.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_email(self, value):\n if not User.objects.filter(email=value).exists():\n raise serializers.ValidationError('User with this email does not exist.')\n return value",
"def validate_email(self, value):\n if not User.objects.filter(email=value).exists():\n rais... | [
"0.7383407",
"0.7383407",
"0.73522377",
"0.7232632",
"0.71616143",
"0.71273553",
"0.7100953",
"0.70613974",
"0.7056952",
"0.7048699",
"0.7035696",
"0.70348406",
"0.7018469",
"0.70132256",
"0.70072025",
"0.69810826",
"0.69632065",
"0.6946505",
"0.69321537",
"0.6925532",
"0.690... | 0.69849044 | 15 |
Returns the position of the Knot whose statespace has the lowest entropy. | def min_entropy_pos(self):
min_entropy = float("inf")
for Knot in self.wait_to_collapse:
noise = random.random() / 1000
# Add some noise to mix things up a little
if self[Knot].entropy - noise < min_entropy:
position = Knot[:]
min_entro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_min_shannon_entropy(grid):\r\n curr_min = math.inf\r\n curr_best = []\r\n for i in range(len(grid[0])):\r\n for j in range(len(grid)):\r\n if not grid[j][i].collapsed:\r\n w = grid[j][i].block_weights\r\n shannon_entropy = sum([-math.log(el) for el i... | [
"0.6638354",
"0.6349472",
"0.6206943",
"0.6167542",
"0.61297476",
"0.6117415",
"0.6096334",
"0.6072252",
"0.6064889",
"0.60195637",
"0.6003861",
"0.59856623",
"0.5978985",
"0.596013",
"0.59564626",
"0.5954064",
"0.5947811",
"0.5898324",
"0.5881373",
"0.5878293",
"0.586943",
... | 0.7533803 | 0 |
Yields neighboring Knots and their directions of a given `position`. | def neighbor(self, position):
if self.options['PeriOpt']:
if position[0] == 0:
yield (self.size[0] - 1, position[1]), 0
elif position[0] == self.size[0] - 1:
yield (0, position[1]), 1
if position[1] == 0:
yield (position[0], sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterate_adjacent(position):\n return iter(_board_graph[position])",
"def get_neighbours_and_directions(self, from_position):\n \n # Transform index into board matrix into index into index into neighbour matrix\n from_row_index = self.board_to_connection_index(from_position)\n row = self.connec... | [
"0.61075956",
"0.6088314",
"0.57958126",
"0.57522845",
"0.56867534",
"0.5659933",
"0.5645656",
"0.5541702",
"0.55407655",
"0.5526952",
"0.5448167",
"0.53663176",
"0.536037",
"0.5325601",
"0.5317667",
"0.5218648",
"0.52039146",
"0.5163547",
"0.5154481",
"0.5150301",
"0.5141945... | 0.69416916 | 0 |
Returns total seconds represented by a datetime.timedelta object. | def get_total_seconds(td):
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1e6) / 1e6 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_seconds(td):\n return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6",
"def total_seconds(self):\n return (\n (self.days * 86400 + self.seconds) * 10**6 + self.microseconds\n ) / 10**6",
"def total_seconds(delta):\n try:\n return delta.tot... | [
"0.7785865",
"0.7658821",
"0.7639121",
"0.75352657",
"0.7376265",
"0.7234179",
"0.7190544",
"0.7107655",
"0.70819324",
"0.70671886",
"0.70211244",
"0.69546527",
"0.69546527",
"0.6851196",
"0.681582",
"0.6751442",
"0.6710503",
"0.6709221",
"0.6666859",
"0.6639251",
"0.6638927"... | 0.7707235 | 1 |
Computes the cumulative distribution of a dataset. | def CumulativeDistribution(data, nbins, range=None, normed=True, centerbins=False):
# 1) COMPUTE THE DISTRIBUTION OF THE DATA
ydata, xdata = np.histogram(data, nbins, range, normed)
# 1.1) Compute the cumulative sum of the probability
ydata = ydata.cumsum()
# 2) RETURN THE RESULTS
if centerbi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumulative_distribution(self, X):\n raise NotImplementedError",
"def test_cumulative_distribution_fit_call_pd(self):\n # Setup\n copula = GaussianMultivariate(GaussianUnivariate)\n copula.fit(self.data.to_numpy())\n X = np.array([2000., 200., 1.])\n expected_result =... | [
"0.76917243",
"0.7009624",
"0.6913743",
"0.68286425",
"0.6757748",
"0.675588",
"0.6751237",
"0.66086197",
"0.65746015",
"0.6514815",
"0.6475707",
"0.6403158",
"0.6369984",
"0.6340523",
"0.6304046",
"0.630065",
"0.6201614",
"0.61941814",
"0.61222583",
"0.6069135",
"0.6034362",... | 0.6789889 | 4 |
Finds the 1st, 2nd and 3rd quartiles of a dataset. | def Quartiles(data):
q = np.percentile(data, [25, 50, 75])
return q[0], q[1], q[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quartile_data(cls, data: tuple or list) -> tuple:\n cls._data_validation(data)\n from math import floor\n # Sort the data\n n = cls.get_n(data)\n if n == 0:\n # Empty dataset, returns zeroes\n return 0, 0, 0, 0\n sorted_data = sorted(list(data... | [
"0.77415645",
"0.7531217",
"0.7426699",
"0.7099109",
"0.6815998",
"0.67567486",
"0.6698048",
"0.662714",
"0.66183525",
"0.6597815",
"0.65792227",
"0.65275645",
"0.64962065",
"0.6422223",
"0.64112675",
"0.63897896",
"0.6355377",
"0.6345474",
"0.63252634",
"0.6306161",
"0.62980... | 0.79789907 | 0 |
Given a set, finds all combinations of given size. Returns a list with all possible permutations of length <= comblength of the elements in data. If N is the length of the data, the number of combinations of length 'comblength' is the binomial coefficient BinomialCoefficient(N,comblength). | def AllCombinations(data, comblength):
return [c for c in itertools.combinations(data, comblength)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AllBipartitionsGivenSize(data, comblength):\n # 0) SECURITY CHECKS\n comblength = int(comblength)\n if (comblength < 1 or comblength >= Ndata):\n raise ValueError( \"'comblength' out of range, please make sure 0 < comblength < len(data).\" )\n\n # 1) FIND ALL THE COMBINAT... | [
"0.7559354",
"0.7201703",
"0.69321585",
"0.67683893",
"0.67120063",
"0.66901094",
"0.6629796",
"0.6613789",
"0.659548",
"0.6494228",
"0.64605784",
"0.6448944",
"0.64423287",
"0.6392903",
"0.6278522",
"0.6266506",
"0.625203",
"0.62080836",
"0.6163596",
"0.61609024",
"0.6148451... | 0.78086025 | 0 |
Given a dataset, finds all bipartitions in which one of the subsets is of size 'comblength'. The size of the complementary subset is N 'comblength', where N is the size of the data. | def AllBipartitionsGivenSize(data, comblength):
# 0) SECURITY CHECKS
comblength = int(comblength)
if (comblength < 1 or comblength >= Ndata):
raise ValueError( "'comblength' out of range, please make sure 0 < comblength < len(data)." )
# 1) FIND ALL THE COMBINATIONS OF SIZE ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AllBipartitions(data, comblength=None):\n # 0) PREPARE FOR CALCULATIONS\n Ndata = len(data)\n iseven = Ndata % 2 == 0\n Nmax = Ndata // 2\n setdata = set(data)\n\n # Security check, avoid confusing comblength=0 with None\n if comblength == 0:\n raise ValueError( \"'comblength' out o... | [
"0.81097865",
"0.72212464",
"0.692126",
"0.67837775",
"0.6156119",
"0.61357164",
"0.60753214",
"0.60753214",
"0.6012841",
"0.5983464",
"0.59388417",
"0.59038335",
"0.580175",
"0.5754516",
"0.5632561",
"0.5603893",
"0.55912876",
"0.5579633",
"0.5574327",
"0.55675143",
"0.55494... | 0.84244347 | 0 |
Page not found in all apps. | def not_found(self, request):
return 'Not found' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_not_found(e):\n return 'Sorry, nothing at this URL.', 404",
"def page_not_found(e):\n return 'Sorry, nothing at this URL.', 404",
"def page_not_found(e):\n return 'Sorry, nothing at this URL.', 404",
"def page_not_found(e):\n return 'Sorry, nothing at this URL.', 404",
"def page_not_fo... | [
"0.77562106",
"0.77562106",
"0.77562106",
"0.77562106",
"0.77562106",
"0.77562106",
"0.77562106",
"0.7754001",
"0.7754001",
"0.7754001",
"0.7754001",
"0.7754001",
"0.7754001",
"0.7754001",
"0.7754001",
"0.77415085",
"0.7703986",
"0.7703785",
"0.77036",
"0.7700083",
"0.7672294... | 0.71450055 | 46 |
linfinity distance between vectors (AMDs). | def linf(v, v_):
return np.amax(np.abs(v-v_)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _vector_dist(self, vec1, vec2):\r\n return sqrt(sum([(float(v1) - float(v2)) ** 2 for v1, v2 in\r\n zip(vec1, vec2)]))",
"def distance_with_inf(v1, v2):\n result = []\n for i in range(0, len(v1)):\n if v1[i] == v2[i]:\n result.append(0)\n elif (v1... | [
"0.6396874",
"0.63282776",
"0.628249",
"0.6263486",
"0.6233567",
"0.6228044",
"0.61418283",
"0.61053854",
"0.60879314",
"0.6059225",
"0.6056888",
"0.6035465",
"0.6012867",
"0.6011812",
"0.59810036",
"0.59739274",
"0.5969925",
"0.59654856",
"0.5928009",
"0.59250295",
"0.591117... | 0.5631198 | 73 |
Earth mover's distance between two PDDs. | def emd(pdd, pdd_, metric='chebyshev', **kwargs):
from .core.Wasserstein import wasserstein
dm = cdist(pdd[:, 1:], pdd_[:, 1:], metric=metric, **kwargs)
return wasserstein(pdd[:, 0], pdd_[:, 0], dm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_along_ground(wp1,wp2):\n\n #**************************************************************************\n # Convert UTM coordinates to global coordinates\n #**************************************************************************\n if isinstance(wp1, UTMWaypoint):\n wp1 = wp1.to_... | [
"0.6616971",
"0.6608936",
"0.6606888",
"0.66053146",
"0.65984625",
"0.65682256",
"0.6524367",
"0.64684427",
"0.6455242",
"0.6446824",
"0.64438987",
"0.6438073",
"0.6433515",
"0.64135844",
"0.6387846",
"0.63837963",
"0.6370962",
"0.6358328",
"0.6355808",
"0.6355128",
"0.635052... | 0.0 | -1 |
Remove folder 'foo' and subfolders at setup and teardown. | def init_test_folders(request):
path = op.join("tests/data", "foo")
def cleanup():
if os.path.exists(path):
shutil.rmtree(path)
cleanup()
request.addfinalizer(cleanup)
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n for root, dirs, files in os.walk(TEMPDIR, topdown=False):\n for name in files:\n os.remove(os.path.join(root, name))\n for name in dirs:\n os.rmdir(os.path.join(root, name))\n os.rmdir(root)",
"def tearDown(self):\n ... | [
"0.72991216",
"0.7100837",
"0.70377254",
"0.7009992",
"0.7009992",
"0.7008049",
"0.69919807",
"0.6971281",
"0.69678265",
"0.69440514",
"0.6918657",
"0.6918657",
"0.6889609",
"0.68848073",
"0.6806415",
"0.6763796",
"0.67540056",
"0.6725217",
"0.6723914",
"0.6719491",
"0.670834... | 0.72521317 | 1 |
Test that correct emoji is returned for deleted status | def test_deleted_status_emoji(self):
self.assertEqual(get_emoji_for_status('DELETED'), ":x:") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fallback_status_emoji(self):\n self.assertEqual(get_emoji_for_status(None), \"\")",
"def test_drop_emojis():\n cleaner = TextCleaner()\n assert cleaner.transform([[\":test_emoji:\"]])[\"corpus\"][0] == \"\"\n assert not cleaner.drops[\"emoji\"].dropna().empty",
"def test_modified_statu... | [
"0.68940103",
"0.66425824",
"0.6634938",
"0.6180687",
"0.61600906",
"0.61288124",
"0.6064771",
"0.60625064",
"0.60175896",
"0.59569645",
"0.595349",
"0.59413576",
"0.5901302",
"0.5900255",
"0.5889953",
"0.5851411",
"0.5832148",
"0.57977325",
"0.5773636",
"0.57701564",
"0.5764... | 0.88308996 | 0 |
Check if the binary symbol s is a commutative operation in the model | def is_commutative(self, s):
return all(self.operations[s][x][y] == self.operations[s][y][x]
for x in range(self.cardinality) for y in range(self.cardinality)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_commutative(self, node):\n return node.name in commutative_operations",
"def is_op_commutative(wcr_str):\n if wcr_str == '' or wcr_str is None:\n return None\n\n # Get lambda function from string\n wcr = eval(wcr_str)\n\n # Run function through symbolic math engine\n a = sympy... | [
"0.7264537",
"0.67819613",
"0.6682001",
"0.6677731",
"0.6476577",
"0.6039049",
"0.5987633",
"0.59771204",
"0.5973414",
"0.597118",
"0.59017897",
"0.58713436",
"0.58385414",
"0.5799773",
"0.57830954",
"0.57505375",
"0.57452816",
"0.571884",
"0.5702474",
"0.5699611",
"0.5698572... | 0.7829457 | 0 |
Return True if some model of self is not a model of cls (in given time) | def is_not_subclass(self, cls, seconds=60):
st = '('+') & ('.join(cls.axioms)+')'
m = prover9(self.axioms, [st], seconds, 1, options=self.options)
if type(m)==list:
return True, m[0]
else:
return False, m | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, Other):\n return self.date != Other.date or self.time_of_day != Other.time_of_day",
"def is_time(self) -> bool:\n return self.times > 1",
"def test_issubclass(self):\n self.assertTrue(issubclass(self.rev.__class__, BaseModel), True)",
"def __ne__(self, other):\n i... | [
"0.64281946",
"0.63915133",
"0.62804604",
"0.6216732",
"0.6208856",
"0.6198486",
"0.6091048",
"0.608391",
"0.6062241",
"0.606158",
"0.5971495",
"0.59363204",
"0.5909583",
"0.59031135",
"0.58869886",
"0.58730865",
"0.5822353",
"0.58191556",
"0.5802999",
"0.5783695",
"0.5778052... | 0.6362145 | 2 |
Summarise a list with duplicates by counting how often each item appears | def counts(li):
d={}
for x in li:
d[x]=d.get(x,0)+1
return dict(sorted([x,d[x]] for x in d)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_duplicates(iterable):\n return {key for key, count in Counter(iterable).items() if count > 1}",
"def list_count(l):\n return dict((l.count(it), it) for it in l)",
"def duplicates(items):\n duplicate_items = set()\n for item in items:\n if items.count(item) > 1:\n duplicat... | [
"0.69966114",
"0.69915146",
"0.69504386",
"0.6765103",
"0.67624986",
"0.66214913",
"0.65832025",
"0.64946216",
"0.6478724",
"0.64211226",
"0.64114183",
"0.6399849",
"0.63565785",
"0.63376236",
"0.6330287",
"0.6317333",
"0.6273729",
"0.62722945",
"0.62408376",
"0.6224359",
"0.... | 0.6812722 | 3 |
Test case for otoroshi_controllers_adminapi_templates_controller_template_spec | def test_otoroshi_controllers_adminapi_templates_controller_template_spec(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_otoroshi_controllers_adminapi_templates_controller_create_from_template_tcp(self):\n pass",
"def test_create_template_subsciption(self):\n pass",
"def test_register_template(self):\n pass",
"def test_custom_action_response_descriptor_octopus_server_web_api_actions_deployment_tem... | [
"0.7717394",
"0.7430598",
"0.6890855",
"0.68571156",
"0.6749655",
"0.67490464",
"0.6648409",
"0.66386586",
"0.65750694",
"0.65576047",
"0.6533697",
"0.65316844",
"0.6503687",
"0.6503687",
"0.6488502",
"0.6450554",
"0.64130664",
"0.6384379",
"0.63842994",
"0.63751024",
"0.6369... | 0.95213 | 0 |
Returns a configuration key's value for a guild. | async def config_get(self, guild: Guild, name: str):
return await self.redis.get(f'{guild.id}:{name}', encoding='utf-8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_guild_config(self, guild: Guild):\n\n try:\n return self._config_cache.get(guild.id)\n except KeyError:\n # Let's just build it up anyway\n return self.config.hgetall(f\"guilds:{guild.id}\")",
"async def get_guild_config(ctx):\n\n guild_id = ctx.guild.id\... | [
"0.69600433",
"0.676314",
"0.66826135",
"0.65594995",
"0.6491908",
"0.64166313",
"0.6411674",
"0.6377647",
"0.6374771",
"0.634086",
"0.6278821",
"0.614717",
"0.6105389",
"0.6050673",
"0.60354257",
"0.60297847",
"0.60040516",
"0.5988258",
"0.59730566",
"0.5968486",
"0.59538025... | 0.7410673 | 0 |
returns a descriptive string representation of the model. | def __repr__(self):
return self.description | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model ... | [
"0.8336697",
"0.8336697",
"0.82503355",
"0.8227392",
"0.8159128",
"0.8042023",
"0.8004978",
"0.7982771",
"0.78100693",
"0.7746835",
"0.774553",
"0.77331215",
"0.7665885",
"0.76411104",
"0.7624742",
"0.7624446",
"0.7581699",
"0.7532804",
"0.7495108",
"0.7488425",
"0.7463667",
... | 0.0 | -1 |
The maximum number of artifacts allowed for the action type. | def maximum_count(self) -> pulumi.Input[int]:
return pulumi.get(self, "maximum_count") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_size(self):\n raise NotImplementedError()",
"def maxsize(self):\r\n return None",
"def max_size(self):\n size = 1\n for idx in self.config.index_specs:\n size *= len(idx.distribution)\n return size",
"def max_mireds(self):\n return 333",
"def num_actions(self) -> ... | [
"0.6428912",
"0.6199278",
"0.61662596",
"0.61324346",
"0.60740244",
"0.60708416",
"0.6055091",
"0.5998627",
"0.5983144",
"0.5941226",
"0.59152895",
"0.5893206",
"0.5884744",
"0.5855084",
"0.5848474",
"0.58325183",
"0.58257127",
"0.58237565",
"0.58155805",
"0.57958394",
"0.578... | 0.53188354 | 88 |
Whether the configuration property is a required value. | def required(self) -> pulumi.Input[bool]:
return pulumi.get(self, "required") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"required\")",
"def required(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"required\")",
"def is_required(self):\r\n return self.default == self.NotSpecified",
"def is_required(self) -> bo... | [
"0.76441187",
"0.76441187",
"0.7565553",
"0.7533416",
"0.75169975",
"0.749064",
"0.7403104",
"0.7316761",
"0.72501576",
"0.6990858",
"0.6949851",
"0.69027567",
"0.68969893",
"0.6861094",
"0.6774596",
"0.6774596",
"0.66953653",
"0.661187",
"0.6584321",
"0.6565778",
"0.65468174... | 0.7650305 | 0 |
The description of the action configuration property that is displayed to users. | def description(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "description") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description(self) -> ConfigNodePropertyString:\n return self._description",
"def description(self):\n return self.__class__.get_setting_description(self.key, **self.get_kwargs())",
"def description(self):\n if \"description\" in self._prop_dict:\n return self._prop_dict[\"de... | [
"0.7334889",
"0.7047611",
"0.6924214",
"0.6910781",
"0.6863423",
"0.6626874",
"0.6626874",
"0.6626874",
"0.6626874",
"0.6626874",
"0.6622725",
"0.6589058",
"0.652234",
"0.652234",
"0.65108716",
"0.6486574",
"0.6486574",
"0.6486574",
"0.6486574",
"0.6486574",
"0.6486574",
"0... | 0.0 | -1 |
Indicates that the property is used with PollForJobs. When creating a custom action, an action can have up to one queryable property. If it has one, that property must be both required and not secret.If you create a pipeline with a custom action type, and that custom action contains a queryable property, the value for ... | def queryable(self) -> Optional[pulumi.Input[bool]]:
return pulumi.get(self, "queryable") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def property(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"property\")",
"def limit_string(self) -> str:\n return f\"{self.action}={self.amount}/{self.per}\"",
"def validate(cls, **kwargs: Any) -> None:\n max_length = kwargs.get(\"max_length\", None)\n if max_len... | [
"0.5100465",
"0.49284878",
"0.49029276",
"0.49012324",
"0.48695537",
"0.48632783",
"0.4852182",
"0.48521236",
"0.4837107",
"0.48072967",
"0.4767597",
"0.4755014",
"0.4755014",
"0.4755014",
"0.4755014",
"0.473142",
"0.47312337",
"0.4729814",
"0.47288248",
"0.46953678",
"0.4688... | 0.0 | -1 |
Empirical confidence interval for a sample distribution | def CI(x, alpha=0.05):
x = np.asarray(x)
xs = x.size
s = np.argsort(x)
c = int((alpha / 2) * xs)
return Interval(x[s[c-1]], x[s[xs-c]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confidence(samples, confidence_level):\n mean = scipy.mean(samples)\n sdev = scipy.std(samples)\n n = len(samples)\n df = n - 1\n t = distributions.t.ppf((1+confidence_level)/2.0, df)\n interval = (interval_low, interval_high) = ( mean - t * sdev / math.sqrt(n) , mean + t * sdev / math.sqrt(n) )\... | [
"0.71988654",
"0.71415883",
"0.69903654",
"0.6807079",
"0.67864764",
"0.67781603",
"0.6731597",
"0.6720846",
"0.6642634",
"0.6642138",
"0.65838975",
"0.6542895",
"0.6412641",
"0.64099145",
"0.640758",
"0.63971215",
"0.638413",
"0.6299119",
"0.6294555",
"0.62855005",
"0.624820... | 0.0 | -1 |
Get the interquartile range with an additional factor extension | def IQR(x, factor=1.5):
xs = np.sort(np.asarray(x))
il, iu = int(0.25 * xs.size), int(0.75 * xs.size)
l = (xs[il-1] + xs[il]) / 2.0
u = (xs[iu-1] + xs[iu]) / 2.0
d = (u - l) * factor
return Interval(l - d, u + d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interquartile_range(x):\n return (quantile(x,0.75) - quantile(x,0.25))",
"def interquartile_range(xs: List[float]) -> float:\n return quantile(xs, 0.75) - quantile(xs, 0.25)",
"def interquartile_range(magnitudes):\n num_obs = magnitudes.shape[0]\n per_25 = int(num_obs / 4.0)\n\n q1 = magnitu... | [
"0.78446496",
"0.78361267",
"0.7329264",
"0.7277547",
"0.62848103",
"0.6220972",
"0.6212683",
"0.6126903",
"0.6076109",
"0.6013926",
"0.59599835",
"0.5945277",
"0.5944486",
"0.59132844",
"0.586369",
"0.586369",
"0.58502626",
"0.5838192",
"0.5810716",
"0.5797957",
"0.5788276",... | 0.5574511 | 34 |
Initialize the params for b and h from initsol, for all other params set some dummy values. Separate every param equation wise and stick it in a list | def _core_init_params(self) :
a_list,b_list = [],[]
g_list,h_list = [],[]
for eqnid,eqn in enumerate(self.equations) :
reg_p = self.regressors[eqnid]['prod']
reg_d = self.regressors[eqnid]['degrad']
h_eqn = self.initsol['h'][eqn-1]
g_eqn = self.initsol['g'][eqn-1]
a_list.append(self.initso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_init(self, sig=0.01):\n self.rhos = np.ones(self.Ndim)\n self.a = np.random.rand(self.Ndim, self.Nhidden)\n self.c = np.random.rand(self.Nhidden)\n self.W = np.random.randn(self.Nhidden, self.Ndim) * sig\n self.alphas = np.zeros((self.Ndim, self.Ncomponents))\n s... | [
"0.63768536",
"0.63639575",
"0.6344924",
"0.6274821",
"0.6249926",
"0.6177377",
"0.6169369",
"0.61526257",
"0.6076583",
"0.6076583",
"0.6076583",
"0.6069444",
"0.60591495",
"0.6057367",
"0.605526",
"0.601068",
"0.6004535",
"0.59952307",
"0.5956314",
"0.5923012",
"0.59117675",... | 0.7125334 | 0 |
Set the SSE values for the diff phases | def set_SSE(self,ssep,ssed,sse) :
if self.save_trace :
# save the ret codes from the last iter
self.ssep.append(ssep)
self.ssed.append(ssed)
self.sse.append(sse)
else :
self.ssep = [ssep]
self.ssed = [ssed]
self.sse = [sse] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_velocities(self):\r\n self.wx = np.copy(Turbine.wzero)\r\n self.wy = np.copy(Turbine.wzero)",
"def set_delta(self):\n self.delta = sc.Delta(self.noise_cov.noise_cov, self.signal_cov.cl_inv,\n self.mask.mask, self.params.pix_area)",
"def setTs(self, Ts):... | [
"0.59605914",
"0.5894171",
"0.5883996",
"0.5883996",
"0.55673504",
"0.5538108",
"0.5524605",
"0.5522457",
"0.54845953",
"0.5475106",
"0.5467689",
"0.5465241",
"0.5433536",
"0.5429207",
"0.54117715",
"0.53857094",
"0.5382142",
"0.5374937",
"0.5347513",
"0.5328624",
"0.5319871"... | 0.55466795 | 5 |
Returns a stream of velocity with units of cm/s. | def get_velocity(stream):
veloc_stream = Stream()
for trace in stream:
veloc_trace = trace.copy()
veloc_trace.integrate()
veloc_trace.stats['units'] = 'cm/s'
veloc_stream.append(veloc_trace)
return veloc_stream | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_velocity(self):\n return self.momentum/self.mass",
"def get_velocity(self):\n return (self._I85_msg_from_device(self.node.sdo[0x606c].phys)) / 10 # rad/s",
"def getVelocity(self):\n return self.v",
"def v(self):\n\n # TODO This translation formula works, but needs simplified.\n\... | [
"0.66958135",
"0.6647904",
"0.6483449",
"0.6325685",
"0.61784226",
"0.6153046",
"0.6153046",
"0.60536504",
"0.600734",
"0.5953955",
"0.59369403",
"0.59334874",
"0.58922356",
"0.5879083",
"0.5841358",
"0.5824808",
"0.5824002",
"0.5801865",
"0.579023",
"0.5747097",
"0.5718724",... | 0.7323536 | 0 |
Constructing an RL agent. Args | def __init__(self, alpha = 0.4, gamma=0.2, n=1):
self.epsilon = 0.3 # chance of taking a random action instead of the best
# stats part
self.reward=[]
self.totalCount=0
self.totalOnTarget=0
self.shootCount=0
self.phasesTemp=0
self.phasesOnTarget=[]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initiate_agent(self, env):\n from keras import Sequential\n from keras.optimizers import Adam\n from keras.layers import Dense, Dropout\n from rl.memory import SequentialMemory\n from rl.agents import DQNAgent\n\n self.env = env\n\n nb_actions = self.env.action_... | [
"0.6891245",
"0.68211496",
"0.6565846",
"0.6525725",
"0.64860606",
"0.64854795",
"0.6481379",
"0.64537036",
"0.6423636",
"0.6394675",
"0.63888",
"0.63830537",
"0.6369426",
"0.6365953",
"0.6358878",
"0.63076633",
"0.63023514",
"0.6282893",
"0.62804013",
"0.6277194",
"0.6248733... | 0.0 | -1 |
Compute the partials Tx and Ty, compute the absolute value of the gradients. | def getAbsGrad(Tx,Ty):
# These are place holders, you will overwrite them in your code.
dummy = torch.zeros(3,4)
absGradT = dummy
# TODO: your code here to compute absGradT = sqrt(Tx^2 + Ty^2)
return absGradT | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGradients(T,x,y):\n\n # These are place holders, you will overwrite them in your code.\n dummy = torch.zeros(3,4)\n Tx = dummy\n Ty = dummy\n\n # TODO: your code here to compute Tx, Ty\n \n return Tx, Ty",
"def calculate(self):\n\n fx_r = self.fx + self.r\n fy_r = self.f... | [
"0.6702647",
"0.6138296",
"0.59238213",
"0.5876406",
"0.5842837",
"0.5841584",
"0.5719233",
"0.57162446",
"0.56961256",
"0.5683851",
"0.5667813",
"0.5652793",
"0.5631196",
"0.561918",
"0.5611303",
"0.5597914",
"0.5596903",
"0.5592228",
"0.5567622",
"0.55403984",
"0.552168",
... | 0.6591556 | 1 |
Make sure input is either a string or a unicode string | def assert_is_string(object_to_test):
if( (type(object_to_test) == type("")) or (type(object_to_test) == type(u"")) ):
return
logging.error("assert_is_string() test failed!")
logging.critical(repr(locals()))
raise(ValueError) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's still inappropriate utf-8.\n str(data)\n except UnicodeError:\n rai... | [
"0.790888",
"0.73409545",
"0.71633554",
"0.7052878",
"0.7023568",
"0.6974539",
"0.69613564",
"0.6936988",
"0.6900525",
"0.6854773",
"0.6839094",
"0.6780258",
"0.6730281",
"0.67033863",
"0.6697373",
"0.6689518",
"0.666724",
"0.66563207",
"0.6652304",
"0.66450363",
"0.66232544"... | 0.62614244 | 41 |
Given a blog name or URL, mangle it into something the tumblr API will probably like | def clean_blog_url(raw_url):
# Example urls that need handling:
# http://jessicaanner.tumblr.com/post/113520547711/animated-versions-here-main-view-webm-gif
# http://havesomemoore.tumblr.com/
# http://pwnypony.com/
# (?:https?://)([^#/'"]+)
stripped_url = raw_url.strip("\r\n\t ")
logging.deb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tumblr2fields(api_key, blogname):\r\n from time import strftime, localtime\r\n try:\r\n # py3k import\r\n import json\r\n except ImportError:\r\n # py2 import\r\n import simplejson as json\r\n\r\n try:\r\n # py3k import\r\n import urllib.request as urllib_r... | [
"0.61286676",
"0.6038978",
"0.6011304",
"0.59003806",
"0.58796257",
"0.58796257",
"0.58136576",
"0.5779535",
"0.57519096",
"0.5750346",
"0.56949276",
"0.56673795",
"0.5591074",
"0.55716944",
"0.5560232",
"0.55318934",
"0.55102646",
"0.5483784",
"0.54791874",
"0.547159",
"0.54... | 0.6253625 | 0 |
Function to find related actors from related movies(movie_movie_similarity_matrix using pca) corresponding to the given movie | def most_similar_actors_pca(self, moviename):
movie_tag_frame = self.sim_act_diff_mov_tf.get_movie_tag_matrix()
movie_tag_matrix = movie_tag_frame.values
movies = list(movie_tag_frame.index.values)
tags = list(movie_tag_frame)
(U,s,Vh) = util.PCA(movie_tag_matrix)
tag_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_similar_actors_lda(self, moviename):\n data_frame = self.data_extractor.get_mlmovies_data()\n tag_data_frame = self.data_extractor.get_genome_tags_data()\n movie_data_frame = self.data_extractor.get_mltags_data()\n movie_tag_data_frame = movie_data_frame.merge(tag_data_frame, h... | [
"0.7175485",
"0.6909426",
"0.63776225",
"0.62654656",
"0.6224838",
"0.6164424",
"0.6101993",
"0.6034018",
"0.5978447",
"0.59721303",
"0.5884915",
"0.5859096",
"0.58271915",
"0.57516944",
"0.5731579",
"0.57142574",
"0.5711693",
"0.5708562",
"0.56976116",
"0.566409",
"0.5660183... | 0.7533873 | 0 |
Computes the logdensity of a multivariate normal. | def multivariate_normal(x, mu, L):
if x.shape.ndims is None:
logger.warn('Shape of x must be 2D at computation.')
elif x.shape.ndims != 2:
raise ValueError('Shape of x must be 2D.')
if mu.shape.ndims is None:
logger.warn('Shape of mu may be unknown or not 2D.')
elif mu.shape.ndim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_density_gaussian(x: torch.Tensor, mu: torch.Tensor, logvar: torch.Tensor):\n norm = -0.5 * (math.log(2 * math.pi) + logvar)\n log_density = norm - 0.5 * ((x - mu) ** 2 * torch.exp(-logvar))\n return log_density",
"def log_density_gaussian(x, mu, logvar):\n norm = - 0.5 * (math.log(2 * math.pi... | [
"0.7654462",
"0.75639415",
"0.7505977",
"0.74105865",
"0.7396801",
"0.71272033",
"0.7072902",
"0.69134814",
"0.6836898",
"0.67818326",
"0.67818326",
"0.67413074",
"0.67319477",
"0.67284095",
"0.66831315",
"0.66411316",
"0.65386975",
"0.6509908",
"0.6501521",
"0.6458814",
"0.6... | 0.59397495 | 65 |
Compute softmax probability over raw logits. | def _compute_softmax(scores):
if not scores:
return []
max_score = None
for score in scores:
if max_score is None or score > max_score:
max_score = score
exp_scores = []
total_sum = 0.0
for score in scores:
x = math.exp(score - max_score)
exp_scores.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(x):\r\n exps = np.exp(x)\r\n return exps / np.sum(exps)",
"def softmax(x):\n npX = np.array(x)\n expX = np.exp(x)\n\n return expX/sum(expX)",
"def softmax(inputs):\n probs = np.exp(inputs)\n # print(probs.shape)\n # t = np.sum(probs, axis=0)\n # print(t.shape)\n\n prob... | [
"0.7719119",
"0.7703024",
"0.7702844",
"0.7688321",
"0.7677464",
"0.7666627",
"0.7666627",
"0.76138234",
"0.7608393",
"0.75940377",
"0.7590872",
"0.75784117",
"0.757828",
"0.7574457",
"0.7565043",
"0.75643724",
"0.75629324",
"0.75555575",
"0.75555575",
"0.75555575",
"0.755555... | 0.0 | -1 |
Test running command 'netlookup subtract' with no subnets in arguments | def test_netlookup_subtract_add_no_subnets(monkeypatch):
script = NetLookupScript()
testargs = ['netlookup', 'subtract', NETWORKS_ARG]
with monkeypatch.context() as context:
validate_script_run_exception_with_args(script, context, testargs, exit_code=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_netlookup_subtract_splittable_network(capsys, monkeypatch, mock_prefixes_data, splittable_network):\n script = NetLookupScript()\n testargs = ['netlookup', 'subtract', NETWORKS_ARG, splittable_network]\n with monkeypatch.context() as context:\n validate_script_run_exception_with_args(scrip... | [
"0.77587587",
"0.7635609",
"0.7084993",
"0.6302656",
"0.6272366",
"0.6232334",
"0.62268305",
"0.6145294",
"0.6027609",
"0.5969381",
"0.5938036",
"0.58693135",
"0.5818498",
"0.5815863",
"0.579946",
"0.5781163",
"0.57450175",
"0.5731728",
"0.56986374",
"0.5622922",
"0.5622675",... | 0.81927127 | 0 |
Test running 'netlookup subtract' command with invalid address values and networks to subtract | def test_netlookup_subtract_invalid_network(capsys, monkeypatch, mock_prefixes_data, invalid_network):
script = NetLookupScript()
testargs = ['netlookup', 'subtract', NETWORKS_ARG, invalid_network]
with monkeypatch.context() as context:
validate_script_run_exception_with_args(script, context, testar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_netlookup_subtract_splittable_network(capsys, monkeypatch, mock_prefixes_data, splittable_network):\n script = NetLookupScript()\n testargs = ['netlookup', 'subtract', NETWORKS_ARG, splittable_network]\n with monkeypatch.context() as context:\n validate_script_run_exception_with_args(scrip... | [
"0.79214704",
"0.77665734",
"0.71630085",
"0.6055139",
"0.591273",
"0.5849006",
"0.5841514",
"0.5780265",
"0.57139343",
"0.5680476",
"0.56288505",
"0.5615075",
"0.55828816",
"0.55685705",
"0.55471915",
"0.5543619",
"0.55287814",
"0.55114233",
"0.5509118",
"0.54921347",
"0.548... | 0.81425565 | 0 |
Deprecated way to construct an elliptic curve. | def EllipticCurve_from_plane_curve(C, P):
from sage.misc.superseded import deprecation
deprecation(3416, 'use Jacobian(C) instead')
# Note: this function never used the rational point
from sage.schemes.elliptic_curves.jacobian import Jacobian
return Jacobian(C) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_ec_key(name='secp256r1'):\n if name not in EC_CURVES:\n raise ValueError('Unknown curve')\n return ec.generate_private_key(curve=EC_CURVES[name], backend=get_backend())",
"def create_object(self, version, key, **kwds):\n R, x = key\n\n if R is rings.QQ:\n from .ell_r... | [
"0.68211055",
"0.6293135",
"0.62561256",
"0.6152047",
"0.6108511",
"0.5980539",
"0.5926587",
"0.58709586",
"0.5851918",
"0.57889724",
"0.5739999",
"0.5735108",
"0.5721907",
"0.55185753",
"0.5482118",
"0.5480206",
"0.5474706",
"0.5418186",
"0.54138297",
"0.5376769",
"0.5375441... | 0.6286263 | 2 |
(list, object) > int Returns index of the value if it is in the list. Otherwise 1. | def binary_search(l, value):
e = len(l) - 1
b = 0
while e-b > 1:
mid = (b+e)// 2
key = l[mid]
if value < key:
e = mid - 1
elif value > key:
b = mid + 1
else: #found value :)
return mid
if l[b] == value:
return b
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(liste, value):\n\n for ii in range(len(liste)):\n if liste[ii] == value:\n return ii\n return None",
"def index(self, value):\n self.__validate_value(value)\n for index, v in enumerate(self.__list):\n if v == value:\n return index",
"def... | [
"0.7490516",
"0.7439186",
"0.7153286",
"0.7148641",
"0.6692753",
"0.66424334",
"0.66360354",
"0.6622841",
"0.6558355",
"0.65301293",
"0.65211374",
"0.6517865",
"0.64806134",
"0.6457434",
"0.64192706",
"0.641803",
"0.64075285",
"0.6403693",
"0.64026415",
"0.6381451",
"0.636967... | 0.0 | -1 |
(list, object) > bool Returns whether or not the value is in the list. | def my_binary_search(l, value):
g = list(l)
while len(g) > 2:
i = len(g) // 2
key = g[i]
if value < key:
g = g[:i]
elif value > key:
g = g[i:]
else:
return True
return g[0] == value or g[1] == value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_list(value, arg):\r\n return value in arg",
"def contains(self, value):\n return value in self.values",
"def is_isin(value):\n return True",
"def __contains__(self, elem):\n return elem in list(self)",
"def __contains__(self, value):\n found = False\n for i in range... | [
"0.7914151",
"0.74202615",
"0.73516726",
"0.72362846",
"0.7136208",
"0.70844555",
"0.7070305",
"0.70541096",
"0.7053552",
"0.70188075",
"0.69917583",
"0.6986972",
"0.6965379",
"0.6965379",
"0.6955131",
"0.6943398",
"0.69408166",
"0.6931493",
"0.6923744",
"0.6919824",
"0.69175... | 0.0 | -1 |
return the dot product of two vectors | def vdot(x, v, pub):
x_flatten = x.flatten()
v_flatten = v.flatten()
mul_res = paillier_gpu.mul_impl(v_flatten, x_flatten)
return paillier_gpu.sum_impl(mul_res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot(vector1, vector2):\n return sum(a1 * a2 for a1, a2 in zip(vector1, vector2))",
"def dot(a, b):\n\n if len(a) != len(b):\n raise Exception(\"Input vectors must be of same length, not %d and %d\" % (len(a), len(b)))\n\n return float(sum([a[i] * b[i] for i in range(len(a))]))",
... | [
"0.87734985",
"0.8756417",
"0.87003887",
"0.8695957",
"0.862431",
"0.86155766",
"0.86149144",
"0.85854644",
"0.8562527",
"0.85107267",
"0.8476932",
"0.8443784",
"0.84131616",
"0.8389263",
"0.83795774",
"0.83722675",
"0.83408594",
"0.83052945",
"0.83046186",
"0.8281802",
"0.82... | 0.7108971 | 97 |
Sends a 401 response that enables basic auth | def user_must_authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8093736",
"0.80926424",
"0.7958403",
"0.7852648",
"0.7843114",
"0.7824419",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
... | 0.74152935 | 45 |
Return flattened list of all targeting objects in self. By default all targeting objects are returned. Only one of includes_only or excludes_only may be True. | def flatten(self):
models = []
_, targets = self.get_data()
for t in targets:
if isinstance(t, ObjectModel):
models += [t]
elif isinstance(t, TargetingCriterion):
models += t.flatten()
return models | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_includes_and_excludes(self):\n # Get set of all targeting objects\n all_targets = set(self.flatten())\n # Get set of all included objects\n includes = set(self._get_includes())\n # Get the items from all_targets which are not in includes\n excludes = all_targets - ... | [
"0.6925103",
"0.6320384",
"0.57629085",
"0.5554401",
"0.5519762",
"0.550233",
"0.54872006",
"0.5448141",
"0.54426533",
"0.5405811",
"0.5403925",
"0.53145957",
"0.52995247",
"0.52929246",
"0.52929246",
"0.52929246",
"0.52929246",
"0.52929246",
"0.52929246",
"0.5288983",
"0.528... | 0.6522181 | 1 |
Get the median of a list of values | def median(values):
# Write the median() function
midpoint = int(len(values) / 2)
if len(values) % 2 == 0:
median = (values[midpoint - 1] + values[midpoint]) / 2
else:
median = values[midpoint]
return median | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_median(numlist):\n return np.median(numlist)",
"def median(v: List[float]) -> float:\n return _median_even(v) if len(v) % 2 == 0 else _median_odd(v)",
"def median(values):\n # Write the median() function\n midpoint = int(len(values) / 2)\n if len(values) % 2 == 0:\n median = (values[midpoin... | [
"0.856921",
"0.84415704",
"0.8278074",
"0.8212018",
"0.8115945",
"0.80988985",
"0.80986464",
"0.8095384",
"0.8089248",
"0.8082627",
"0.7885181",
"0.78799623",
"0.7876769",
"0.78682256",
"0.77975774",
"0.779382",
"0.7740889",
"0.77263594",
"0.77061564",
"0.7684539",
"0.7634215... | 0.82220733 | 3 |
Set learning rate and momentum parameter for generator updates. | def set_gn_sgd_params(self, learn_rate=0.02, momentum=0.9):
zero_ary = np.zeros((1,))
new_lr = zero_ary + learn_rate
self.lr_gn.set_value(new_lr.astype(theano.config.floatX))
new_mo = zero_ary + momentum
self.mo_gn.set_value(new_mo.astype(theano.config.floatX))
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setOptimizerParams(self,lr,momentum,decay):\n self.optimizer = SGD(lr=lr,momentum=momentum,decay=decay)",
"def update_learning_rate(self):\r\n self.scheduler.step(self.clock.epoch)",
"def update_learning_rate(self):\n self.scheduler.step()\n lr = self.optimizer.param_groups[0]['... | [
"0.74228674",
"0.7329358",
"0.72947824",
"0.7290991",
"0.7290991",
"0.7277119",
"0.72454304",
"0.7237406",
"0.7035165",
"0.70293164",
"0.7000631",
"0.6989692",
"0.6987262",
"0.6976322",
"0.695302",
"0.69255",
"0.691151",
"0.68654853",
"0.68213147",
"0.67984426",
"0.6776933",
... | 0.68282753 | 18 |
Set learning rate and momentum parameter for discriminator updates. | def set_in_sgd_params(self, learn_rate=0.02, momentum=0.9):
zero_ary = np.zeros((1,))
new_lr = zero_ary + learn_rate
self.lr_in.set_value(new_lr.astype(theano.config.floatX))
new_mo = zero_ary + momentum
self.mo_in.set_value(new_mo.astype(theano.config.floatX))
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_learning_rate(self):\r\n\r\n self.n_steps += 1\r\n lr = self.factor * self._get_lr_scale()\r\n for param_group in self._optimizer.param_groups:\r\n param_group['lr'] = lr",
"def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)",
"def updatelea... | [
"0.71230865",
"0.7075697",
"0.70593333",
"0.6855824",
"0.6855824",
"0.68059623",
"0.67984474",
"0.67955375",
"0.6752505",
"0.6743082",
"0.67331773",
"0.67205024",
"0.67056483",
"0.66563624",
"0.6650629",
"0.6643029",
"0.6630967",
"0.6628735",
"0.66276056",
"0.6617988",
"0.655... | 0.623723 | 72 |
Sets the torch device depending on whether cuda is avaiable or not. | def set_device(self, cuda=True):
if cuda and torch.cuda.is_available():
self.cuda = True
self.device = torch.device('cuda')
else:
self.cuda = False
self.device = torch.device('cpu')
if self.verbose:
if not cuda:
print('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_device(in_arg): \n \n return torch.device(\"cuda\" if torch.cuda.is_available() and in_arg.gpu == 1 else \"cpu\")",
"def set_device(device, backend='autograd'):\n if backend == 'autograd':\n return None\n elif backend == 'pytorch':\n try:\n tc.cuda.set_device(de... | [
"0.81103677",
"0.80256677",
"0.7868739",
"0.7843636",
"0.7546385",
"0.7499286",
"0.74311036",
"0.7422318",
"0.73199517",
"0.7247979",
"0.69833183",
"0.6976772",
"0.696156",
"0.69106805",
"0.68663025",
"0.6863663",
"0.6838263",
"0.6838263",
"0.6838263",
"0.6838263",
"0.6825775... | 0.8050536 | 1 |
Returns all the possible directions of a player in the game as a list of tuples. | def get_directions():
return [(1, 0), (0, 1), (-1, 0), (0, -1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def directions(self):\n return []",
"def directions(self):\n direction_list = []\n for direction in Maze.possible_directions:\n move = Maze.dirs_to_moves[direction]\n if (0 <= (self.location[0]+move[0]) < len(self.grid) and\n 0 <= (self.location[1]+mo... | [
"0.6781066",
"0.64884204",
"0.6440459",
"0.637943",
"0.6214856",
"0.6214856",
"0.6214856",
"0.6214856",
"0.6214856",
"0.6214856",
"0.6214856",
"0.6097705",
"0.59716326",
"0.58972955",
"0.5876937",
"0.5826856",
"0.58092165",
"0.5807536",
"0.5756365",
"0.5753964",
"0.57327217",... | 0.6883715 | 0 |
Checking if this player's board is end game board. | def is_end_game(self):
win = self.is_game_won()
tie = self.game_is_tied()
return win or tie | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_of_game(self, board):\n if self.if_board_full(board):\n return True\n #check if the board is full\n if not self.get_all_possible_moves(board, \"DARK\") and not self.get_all_possible_moves(board, \"LIGHT\"):\n return True\n return False",
"def check_ga... | [
"0.8172282",
"0.80690825",
"0.7710843",
"0.7679913",
"0.7551429",
"0.7535583",
"0.7451725",
"0.7346067",
"0.7346067",
"0.7323978",
"0.7293765",
"0.7132977",
"0.7093803",
"0.7090218",
"0.7085496",
"0.70617443",
"0.70607",
"0.7038597",
"0.69829273",
"0.6975814",
"0.68917024",
... | 0.7630672 | 4 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(lon1, lat1, lon2, lat2):
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 6371 # Radius of earth i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.81462395",
"0.7864918",
"0.7633203",
"0.76057166",
"0.7596984",
"0.7596038",
"0.7593975",
"0.75714296",
"0.7564067",
"0.75561523",
"0.75298584",
"0.7517076",
"0.74938124",
"0.7466481",
"0.74516803",
"0.7433787",
"0.73918307",
"0.73571837",
"0.73487705",
"0.73308617",
"0.73... | 0.0 | -1 |
Returns the Euclidean distance of two points in the Cartesian Plane. | def distance(point1, point2):
return ((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) ** 0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(self,):\n return sqrt(pow((self.pose1.x - self.pose2.x), 2) +\n pow((self.pose1.y - self.pose2.y), 2))",
"def euclidean_distance(x1, y1, x2, y2):\n distance = math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))\n return distance",
"def euclidean_distanc... | [
"0.77338606",
"0.7510308",
"0.74254733",
"0.7400938",
"0.73753047",
"0.7374873",
"0.73701894",
"0.73421",
"0.7308016",
"0.72965765",
"0.7244358",
"0.7219322",
"0.72136164",
"0.7209289",
"0.720309",
"0.71987426",
"0.71977013",
"0.7192439",
"0.7190426",
"0.71600986",
"0.7131179... | 0.0 | -1 |
Returns the firmware ID integer [in] self Pointer to the current object | def get_firmware_id(self):
build_id_addr = self._get_slt_entry(1)
build_id_int = self.get_data(build_id_addr)
if build_id_addr % Arch.addr_per_word != 0:
# in a 32 bit word, the 16 bit build ID int can be in either the 2
# MS bytes or 2 LS bytes
build_id_int >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_debug_firmware_id(self):\n # Read the address via get_var_strict; this will fetch the value\n # from chipdata as well, but we can ignore it.\n int_addr = self.debuginfo.get_var_strict(\n '$_build_identifier_integer'\n ).address\n build_id_int = self.debuginfo.g... | [
"0.6659042",
"0.66225123",
"0.65802544",
"0.65732455",
"0.65732455",
"0.65598106",
"0.6551785",
"0.65372795",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
"0.64972204",
... | 0.70307577 | 0 |
Get file/dir name of the last path component of the URL | def get_url_straight_filename(url, strip=[], allowdir=False):
path = urlunquote(urlsplit(url).path)
path_parts = path.split('/')
if allowdir:
# strip empty ones
while len(path_parts) > 1 and not path_parts[-1]:
path_parts = path_parts[:-1]
if strip:
while path_parts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_file_name(url: str) -> str:\n url = url.strip('/')\n result = findall(r'/(\\w+\\.\\w+)[?|$]', url)\n if result:\n return result[-1]\n return url.split('/')[-1]",
"def url_file_name(url):\r\n return url[url.rfind('/') + 1:]",
"def url_filename(url):\n return os.path.basename(ur... | [
"0.8238025",
"0.8194668",
"0.80590534",
"0.79775417",
"0.79524755",
"0.7868575",
"0.78201467",
"0.77797383",
"0.77455467",
"0.76903766",
"0.764131",
"0.7639165",
"0.7430447",
"0.74091035",
"0.7397713",
"0.7360638",
"0.7259495",
"0.7237766",
"0.72253394",
"0.72237957",
"0.7213... | 0.7490954 | 12 |
Given rfc2822 date/time format, return seconds since epoch | def rfc2822_to_epoch(datestr):
return mktime_tz(parsedate_tz(datestr)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_time(s):\n\n dt = dateutil.parser.parse(s)\n# epoch_time = int((dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds())\n epoch_time = int(dt.replace(tzinfo=timezone.utc).timestamp())\n\n return epoch_time",
"def epoch_seconds(date):\n td = date - epoch\n return td.days * 864... | [
"0.7403787",
"0.6994438",
"0.6994438",
"0.69930565",
"0.685609",
"0.67435235",
"0.6649992",
"0.6621337",
"0.6596144",
"0.6519827",
"0.6499239",
"0.6476053",
"0.64504117",
"0.64360934",
"0.64318186",
"0.6411012",
"0.6402909",
"0.6397291",
"0.6361673",
"0.63393",
"0.6302481",
... | 0.7470458 | 0 |
returns a list of all tables present in a folder of dimas because dimas may each have a different set of tables, this function goes through the list of tables per dima and appends any table not previously seen into an internal list which is ultimately returned. | def table_collector(path2mdbs):
containing_folder = path2mdbs
contained_files = os.listdir(containing_folder)
table_list = []
for mdb_path in contained_files:
if os.path.splitext(mdb_path)[1]=='.mdb' or os.path.splitext(mdb_path)[1]=='.accdb':
instance = arcno(os.path.join(containing... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tables(self):\n\t\tbuild = 'SELECT * FROM pg_catalog.pg_tables WHERE schemaname != \\'pg_catalog\\' AND schemaname != \\'information_schema\\';'\n\t\tself.cur.execute(build)\n\t\ttotal = self.cur.fetchall()\n\t\ttable_list = []\n\t\tfor a in total:\n\t\t\ttable_list.append(a[1])\n\t\treturn table_list",
... | [
"0.6735903",
"0.6700059",
"0.64749414",
"0.6401587",
"0.63755095",
"0.6251253",
"0.6218822",
"0.62172234",
"0.6214256",
"0.62109447",
"0.61893195",
"0.61316866",
"0.61200345",
"0.60726804",
"0.6050303",
"0.6016076",
"0.60112864",
"0.60105884",
"0.598312",
"0.58760774",
"0.582... | 0.6572763 | 2 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
plt.xticks(tick_marks, classes, rotation=30... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.819363",
"0.8094859",
"0.8028102",
"0.8018164",
"0.799278",
"0.79902315",
"0.7979656",
"0.7974647",
"0.79595697",
"0.7956129",
"0.7936602",
"0.79336774",
"0.7933392",
"0.79303294",
"0.79252326",
"0.7923459",
"0.79230803",
"0.79221183",
"0.79218185",
"0.7921176",
"0.7916744... | 0.0 | -1 |
Gated recurrent unit (GRU) with nunits cells. | def __call__(self, inputs, state, scope=None):
with tf.variable_scope(scope or type(self).__name__): # "GRUCell"
with tf.variable_scope("Gates"): # Reset gate and update gate.
# We start with bias of 1.0 to not reset and not update.
r, u = tf.split(1, 2, linear([inp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_gru_cell(num_units, dropout):\n cell = tf.nn.rnn_cell.GRUCell(num_units)\n if dropout:\n result = tf.nn.rnn_cell.DropoutWrapper(cell,\n output_keep_prob=1-dropout)\n return result",
"def _initialize_gru_cell(self, num_units):\n return gru_cell.Laye... | [
"0.72175235",
"0.6655495",
"0.62976027",
"0.62721103",
"0.58990526",
"0.5838161",
"0.57049847",
"0.56842643",
"0.56727964",
"0.56181496",
"0.56154644",
"0.5609967",
"0.55854005",
"0.5582328",
"0.55492055",
"0.55422336",
"0.55379236",
"0.5510886",
"0.5496667",
"0.54436517",
"0... | 0.49715042 | 72 |
Checks if currently occupied seat should become empty. | def check_occ(seats:List[str], i: int, j: int) -> bool:
occupied_count = (seats[i - 1][j] == "#") +\
(seats[i - 1][j - 1] == "#") +\
(seats[i - 1][j + 1] == "#") +\
(seats[i + 1][j] == "#") +\
(seats[i + 1][j - 1] == "#") +\
(seats[i + 1][j + 1] == "#") +\
(seats[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_empty(self):\n if self.allocated_spaces == 0:\n return True\n else:\n return False",
"def _is_full(self):\n if self.allocated_spaces == self.capacity:\n return True\n elif self.allocated_spaces < self.capacity:\n return False",
"de... | [
"0.7437178",
"0.73682714",
"0.734311",
"0.73328054",
"0.72996753",
"0.70801324",
"0.70765346",
"0.70733654",
"0.7031329",
"0.7031329",
"0.6998726",
"0.69886214",
"0.69592613",
"0.6955051",
"0.6933424",
"0.6933424",
"0.6832477",
"0.6823872",
"0.68231386",
"0.68132746",
"0.6802... | 0.0 | -1 |
get yvalue of marker in projection iproj | def get_yProj(self, iproj):
return self.yProj[iproj] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getY(self):\n return self.proj.getY()",
"def y(self):\n return self._kml['y']",
"def y(self):\n return self.coords[1]",
"def get_y(self):\n return self.coords[1]",
"def get_y_position(self):\n return self.actual_coordinates[1]",
"def findY(self):\n return sel... | [
"0.7142606",
"0.67305857",
"0.67297214",
"0.6583838",
"0.6561016",
"0.65312874",
"0.6529615",
"0.6420082",
"0.6401691",
"0.639421",
"0.6375033",
"0.6273069",
"0.6258696",
"0.62484866",
"0.62446666",
"0.62278455",
"0.6225121",
"0.6202938",
"0.619198",
"0.61858374",
"0.6178276"... | 0.74080366 | 0 |
Generate a test dataframe. | def get_test_dataframe(speakers=8):
df = generate_data_frame(
speakers=speakers,
genders=['M', 'F'],
factors=dict(
group=['HV', 'LV'],
test=['pre', 'post'],
vowel=['a', 'e', 'i', 'o', 'u']))
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_test(self):\n count = 500\n dates = []\n value = []\n now = datetime.datetime.now()\n # print(now)\n for i in range(count):\n some_date = now - datetime.timedelta(\n days=randrange(30),\n hour... | [
"0.72119564",
"0.71324366",
"0.71303165",
"0.709831",
"0.7094657",
"0.689761",
"0.6897407",
"0.68377",
"0.6835536",
"0.6696262",
"0.66905826",
"0.6660093",
"0.6643918",
"0.66403705",
"0.66339",
"0.6631358",
"0.6624133",
"0.6574618",
"0.6558131",
"0.65438545",
"0.65243506",
... | 0.7222912 | 0 |
Missing column raises value error. | def test_fx_list_spec(self):
df = self.df.copy()
normalizer = self.normalizer(
f0=['f0'], f1=['f1'], f2=['f2'], f3=['f3'], **self.kwargs)
normalizer.normalize(df)
self.assertListEqual(
normalizer.params['formants'],
['f0', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_run_missing_column(self):\n input_df = self.spark.createDataFrame(\n data=[\n (\"a\",),\n ],\n schema=StructType([\n StructField(\"baz\", StringType()),\n ])\n )\n with raises(AnalysisException):\n se... | [
"0.76126474",
"0.7157405",
"0.7103793",
"0.6851812",
"0.6728142",
"0.65092444",
"0.65023357",
"0.64211464",
"0.6418578",
"0.63758487",
"0.63549376",
"0.6326887",
"0.6316502",
"0.63009286",
"0.62852997",
"0.6267968",
"0.62452155",
"0.6219084",
"0.6199182",
"0.6198687",
"0.6193... | 0.0 | -1 |
Get the current installed version. Returns the version or None if no version file exists. | def get_current_version(self):
current_version = self.get_version(self.get_module_and_path(self._main_dir))
return current_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version():\n\n current_dir = os.path.dirname(os.path.realpath(__file__))\n version_path = os.path.join(current_dir, VERSION_FILE)\n\n with open(version_path, 'r') as version_fd:\n return version_fd.read().strip()",
"def getVersion(self):\n try:\n filepath = f\"{EXTERNAL_... | [
"0.8095902",
"0.76076704",
"0.7592984",
"0.75670975",
"0.75570583",
"0.75379413",
"0.7379542",
"0.733805",
"0.73287916",
"0.72015077",
"0.7171196",
"0.7165244",
"0.71251667",
"0.71168816",
"0.7110701",
"0.7095698",
"0.70243037",
"0.69658905",
"0.695611",
"0.69354236",
"0.6930... | 0.73910004 | 6 |
Load the resnet101 model pretrained on ImageNet | def load_resnet(self, resnet_dir, keep_last=False):
ckpt = tf.train.latest_checkpoint(resnet_dir)
with tf.Session(config=self.config) as sess:
# init model
init = [tf.global_variables_initializer(), tf.local_variables_initializer()]
sess.run(init)
if keep_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_resnet_image_encoder(model_stage=2):\n \n print('Load pretrained ResNet 101.')\n model = resnet101(pretrained=True)\n layers = [model.conv1, model.bn1, model.relu, model.maxpool]\n layers += [getattr(model, 'layer{}'.format(i+1)) for i in range(model_stage)]\n model = torch.nn.Sequential... | [
"0.8064356",
"0.8008273",
"0.7961586",
"0.7885667",
"0.7885667",
"0.7885667",
"0.7885667",
"0.7870148",
"0.78621346",
"0.77309686",
"0.7551257",
"0.7546857",
"0.75162166",
"0.74979",
"0.74630153",
"0.7414404",
"0.7409193",
"0.7409193",
"0.7197343",
"0.7164848",
"0.71325177",
... | 0.6505143 | 88 |
Add a vertex to the graph. | def add_vertex(self, vertex_id): # O(1) time complexity
self.vertices[vertex_id] = set()
# additional options (class)
'''
if vertex_id not in self.vertices:
self.vertices[vertex_id] = {}
else:
return "Vertex is already in Graph"
''' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex):\n if isinstance(vertex, Vertex):\n self.vertices.append(vertex)\n return\n raise TypeError('Is not vertex instance!')",
"def add_vertex(self, vertex_name: n):\n new_verte... | [
"0.87015903",
"0.84329987",
"0.8422056",
"0.840923",
"0.83646226",
"0.8317027",
"0.825337",
"0.808519",
"0.8081489",
"0.8038682",
"0.8035422",
"0.78834563",
"0.78711975",
"0.7838118",
"0.7838118",
"0.77608305",
"0.7757061",
"0.77158874",
"0.7711681",
"0.76663774",
"0.76616603... | 0.71924305 | 46 |
Return the status of the compute instance. | def _compute_status(self, instance, zone):
if self.compute_service is None:
logging.warning('Service unavailable: unable to start GCE VM: %s (%s)',
instance, zone)
return
info = self.compute_service.instances().get(
project=app_identity.get_application_id(),
in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status(self):\n if self.vm.get_cloud_status() != \"ACTIVE\":\n return \"stopped\"\n #wait for the vm to be ready and SSH-able\n self.vm.wait_ready()\n status = self.vm.run_command(\"ctool status\", indent=0, prefix='')\n return status.strip()",
"def status(se... | [
"0.73471135",
"0.7160243",
"0.69160175",
"0.68961394",
"0.68961394",
"0.68775284",
"0.68765116",
"0.6867322",
"0.6859501",
"0.6848467",
"0.6848467",
"0.6848467",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241",
"0.6834241... | 0.8565394 | 0 |
Annotate articles using annotations json files. | def annotate_articles(data_folder):
articles_files = os.listdir('data')
annotations = get_annotations()
all_articles = {}
for index, file_name in enumerate(articles_files):
article = json.load(open(f'{data_folder}/articles/{file_name}', 'r'))
print(f'{index} - {article["source"]["id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annotate_with_geonames(f_json, f_out_json):\n try:\n ef_json = read_paper_json(f_json)\n \n annot_json = {}\n annot_json['paper_id'] = ef_json['paper_id']\n \n for part, jpath in cfg.JSON_TEXT_MAP.items():\n entities = get_nested_dict_value(ef_json, [par... | [
"0.6431345",
"0.64294845",
"0.6428023",
"0.6102727",
"0.6102437",
"0.60699654",
"0.6040102",
"0.6018383",
"0.60061306",
"0.5958754",
"0.59436",
"0.5913444",
"0.5909411",
"0.58803177",
"0.5831984",
"0.58196276",
"0.57776195",
"0.5769035",
"0.57619584",
"0.5752534",
"0.57462245... | 0.7815861 | 0 |
Remove stopwords from lines. | def removeStopwordsLine(self, wordLines):
return self._doPerLine(wordLines, self.removeStopwords) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)",
"def removeOwnStopWords(self, sort=True, lc=False):\n\t\tself.textFile... | [
"0.7864564",
"0.773994",
"0.7738421",
"0.7503501",
"0.7501072",
"0.7354269",
"0.73199433",
"0.7313171",
"0.731213",
"0.7311197",
"0.728651",
"0.7267128",
"0.7253867",
"0.7249775",
"0.7240815",
"0.72347844",
"0.7202243",
"0.7201557",
"0.7190195",
"0.71899515",
"0.7173134",
"... | 0.7925392 | 0 |
Remove non valid (dictionary) words from lines. | def removeNonDictionaryWordsLine(self, wordLines):
return self._doPerLine(wordLines, self.removeNonDictionaryWords) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeNonDictionaryWords(self, words):\n\t\twordList = [w.strip() for w in words.split(' ')]\n\t\trtnWords = []\n\t\tfor word in wordList:\n\t\t\tif word.lower() in self.dictionary:\n\t\t\t\trtnWords.append(word)\n\t\treturn \" \".join(rtnWords)",
"def get_words(line):\n try:\n alphabet = \"abcdefg... | [
"0.75094044",
"0.65037674",
"0.64140123",
"0.62894666",
"0.62682337",
"0.614901",
"0.6137755",
"0.602115",
"0.600726",
"0.6004002",
"0.5996085",
"0.59231675",
"0.58709854",
"0.5848661",
"0.58485305",
"0.5821262",
"0.5814029",
"0.58028007",
"0.57997364",
"0.5784998",
"0.577965... | 0.78282195 | 0 |
Remove numbers from lines. | def removeNumbersLine(self, wordLines):
return self._doPerLine(wordLines, self.removeNumbers) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __remove_line_numbers(file_contents: str) -> str:\n\n spaces = ' ' * 6\n result = ''\n\n for line in file_contents.splitlines():\n new_line = spaces + line[6:72].rstrip()\n result += new_line + '\\n'\n\n return result",
"def remove_numbers_fun(self):\n ... | [
"0.7703879",
"0.7392791",
"0.70746034",
"0.7025942",
"0.7009733",
"0.68820417",
"0.68615",
"0.6765951",
"0.67536426",
"0.67536426",
"0.67536426",
"0.6735944",
"0.6724722",
"0.67224526",
"0.67015064",
"0.6620004",
"0.65745974",
"0.6524549",
"0.6472473",
"0.64109653",
"0.640440... | 0.79615754 | 0 |
Remove apostrophes from string, replace with no space. | def removeApostrophes(self, words):
return self.__apostropheRegex.sub('', words) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_apostrophes(text: str) -> str:\n apostrophes_re = re.compile(\"'\")\n return apostrophes_re.sub(' ', text)",
"def normalizeApostrophe(strText, oneSpace=False):\n if oneSpace:\n return re.sub(r\"'\", r\"' \", strText, flags=re.UNICODE)\n\n return re.sub(r\"'[ ]+\", r\"'\"... | [
"0.8106764",
"0.74617136",
"0.7287106",
"0.7152773",
"0.7135621",
"0.698787",
"0.6982936",
"0.6968641",
"0.6897641",
"0.6887271",
"0.6884099",
"0.6870498",
"0.6862608",
"0.6862608",
"0.6862608",
"0.68227553",
"0.68227553",
"0.68227553",
"0.67770875",
"0.67469656",
"0.6744332"... | 0.77596164 | 1 |
Remove apostrophes from string, replace with no space. | def removeApostrophesLine(self, wordLines):
return self._doPerLine(wordLines, self.removeApostrophes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_apostrophes(text: str) -> str:\n apostrophes_re = re.compile(\"'\")\n return apostrophes_re.sub(' ', text)",
"def removeApostrophes(self, words):\n\t\treturn self.__apostropheRegex.sub('', words)",
"def normalizeApostrophe(strText, oneSpace=False):\n if oneSpace:\n return re.... | [
"0.81055146",
"0.7758357",
"0.7461573",
"0.728601",
"0.71531105",
"0.71331555",
"0.69889706",
"0.6982105",
"0.69677263",
"0.6895639",
"0.68866587",
"0.68838227",
"0.6868516",
"0.68617475",
"0.68617475",
"0.68617475",
"0.6822003",
"0.6822003",
"0.6822003",
"0.67751116",
"0.674... | 0.0 | -1 |
Redirect / to home | def idx(_request):
return HttpResponseRedirect('/home') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home_page():\n return redirect(url_for(_DEFAULT_ROUTE, _external=True))",
"def homepage():\n return redirect('index.html')",
"def homepage():\n if g.user:\n return redirect(f\"/user/{g.user.id}\")\n else:\n return redirect(\"/landing\")",
"def go_home(request):\n\n url = requ... | [
"0.8082355",
"0.78268355",
"0.78140163",
"0.7697245",
"0.7662372",
"0.7662372",
"0.76204866",
"0.7586416",
"0.75657976",
"0.7239277",
"0.7239277",
"0.7239277",
"0.7199949",
"0.71403354",
"0.7117525",
"0.7111367",
"0.7101667",
"0.7037962",
"0.69972193",
"0.6955822",
"0.6952345... | 0.69453245 | 21 |
Iterate over items of dictionaries grouped by their keys. | def zip_dict(*dicts):
for key in set(chain(*dicts)): # set merge all keys
# Will raise KeyError if the dict don't have the same keys
yield key, tuple(d[key] for d in dicts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_values(self, dicts, *keys):\n grouped = self._group_by_keys(dicts, *keys)\n self._add_nested(*grouped)",
"def _group_by_keys(self, dicts, *keys):\n\n current = self._node\n queue = deque(keys)\n if not queue:\n yield _Node(value=dicts, prev=current)\n ... | [
"0.6725235",
"0.6567386",
"0.64867306",
"0.6466305",
"0.6280895",
"0.6240501",
"0.60855174",
"0.5997162",
"0.5971412",
"0.5961661",
"0.59095",
"0.5824047",
"0.5793823",
"0.5755697",
"0.5678185",
"0.5667236",
"0.5649095",
"0.564064",
"0.56278694",
"0.5627846",
"0.5627846",
"... | 0.5807228 | 12 |
Check whether a string is image filename. | def check_and_image_shape(item: ValueType, shape: List) -> List:
if len(item.shape) > 0:
item = str(item[0])
if item.endswith(('.jpg', '.jpeg', '.png')):
import cv2
im = cv2.imread(item)
if im is not None:
return list(im.shape)
return shape | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_image(filename: str) -> str:\n extension = filename.rsplit(\".\", 1)[-1].lower()\n assert (\n extension in image_extensions\n ), f\"Invalid image: {filename}. Allowed extensions: {image_extensions}\"\n return extension",
"def is_valid_filename(self, imageNode):\r\n src = self.par... | [
"0.7608436",
"0.76025814",
"0.7444619",
"0.7416114",
"0.73984385",
"0.7390316",
"0.73726195",
"0.73578465",
"0.73092675",
"0.7267071",
"0.7263729",
"0.72166276",
"0.7208612",
"0.7204594",
"0.7137469",
"0.7007611",
"0.6992768",
"0.6909233",
"0.69069165",
"0.6838164",
"0.677672... | 0.0 | -1 |
Add a product to a Wishlist This endpoint will add a product to a wishlist based on the customer ID, Wishlist ID, an product ID specified in the path | def add_product(cust_id,wishlist_id,pid):
# """ Add product ID to a wishlist """
# TODO add products changes as well, for now just asses the wishlists
if Customer.check_custid(cust_id):
message = Customer.find_by_id(cust_id,wishlist_id)
if message:
result = Customer.addProduct(cu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_wishlist(request, product_id):\n product = get_object_or_404(Product, pk=product_id)\n wishlist = get_object_or_404(Wishlist, user=request.user)\n\n if product not in wishlist.products.all():\n wishlist.products.add(product)\n messages.info(request,\n f\"{prod... | [
"0.78311646",
"0.7714367",
"0.72921324",
"0.7126104",
"0.6870437",
"0.6560975",
"0.65350527",
"0.6525585",
"0.6482619",
"0.64470387",
"0.64369",
"0.6409642",
"0.62782234",
"0.62294513",
"0.61490035",
"0.61102015",
"0.60411954",
"0.6031813",
"0.60058576",
"0.5950916",
"0.58347... | 0.83785206 | 0 |
List products of a Wishlist This endpoint will list products of a Wishlist based on the customer id and Wishlist id specified in the path | def get_wishlist(cust_id,wishlist_id):
# """ List the wishlist with the provided name"""
if Customer.check_custid(cust_id):
message = Customer.find_by_id(cust_id,wishlist_id)
if message:
return make_response(jsonify(message),status.HTTP_200_OK)
else:
message = {'E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wishlist(request):\n items = []\n user = get_object_or_404(UserProfile, user=request.user)\n wishlist = Wishlist.objects.get_or_create(user=user)\n wishlist_user = wishlist[0]\n existingWishlist = WishlistItem.objects.filter(\n wishlist=wishlist_user).exists()\n\n if existingWishlist:\... | [
"0.68854594",
"0.6711203",
"0.6709914",
"0.6668284",
"0.63757807",
"0.62108207",
"0.61958843",
"0.6093503",
"0.60550845",
"0.59716594",
"0.5942139",
"0.59314245",
"0.59195757",
"0.5884176",
"0.5883211",
"0.5881444",
"0.5870758",
"0.58315784",
"0.57774055",
"0.5734042",
"0.571... | 0.6725888 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.