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 |
|---|---|---|---|---|---|---|
The MAC Security (MACsec) CKN to associate with the dedicated connection. The valid values are 64 hexadecimal characters (09, AE). Required if using `cak`. | def ckn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "ckn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mac_string():\n mac_int = getnode()\n mac_str = ':'.join((\"%012x\" % mac_int)[i:i + 2] for i in range(0, 12, 2))\n return mac_str",
"def getMacName(self):\r\n return CipherSuite.canonicalMacName(self.cipherSuite)",
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_z... | [
"0.634334",
"0.6328112",
"0.6265812",
"0.616471",
"0.61055714",
"0.59995866",
"0.59923273",
"0.59923273",
"0.5942146",
"0.5940359",
"0.5921319",
"0.58917916",
"0.58917916",
"0.5867987",
"0.58056605",
"0.579108",
"0.57757354",
"0.5723496",
"0.5694966",
"0.56643826",
"0.5660127... | 0.57556146 | 17 |
The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key to associate with the dedicated connection. | def secret_arn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "secret_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secret_arn(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"secret_arn\")",
"def secret_key(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"secret_key\")",
"def kms_key_arn(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"kms_key_arn\")",
"def get_a... | [
"0.65348244",
"0.63320506",
"0.6222377",
"0.62009203",
"0.60361683",
"0.5993174",
"0.59830666",
"0.59830666",
"0.59204143",
"0.59123325",
"0.5901042",
"0.5901042",
"0.58347666",
"0.576516",
"0.57376236",
"0.57158595",
"0.57022244",
"0.5697687",
"0.5680451",
"0.5667175",
"0.56... | 0.6154829 | 4 |
The MAC Security (MACsec) CAK to associate with the dedicated connection. The valid values are 64 hexadecimal characters (09, AE). Required if using `ckn`. | def cak(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "cak") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_zero_vector(16))\n return engine.encrypt(data)[-16:]",
"def getMacName(self):\r\n return CipherSuite.canonicalMacName(self.cipherSuite)",
"def macFor(cls, board):\n return cls.MAC_PREFIX + '{:02X}'.format(int(board))",
"def... | [
"0.6890307",
"0.6483881",
"0.61452806",
"0.6109432",
"0.608284",
"0.60670954",
"0.60127324",
"0.5965188",
"0.5965188",
"0.59520465",
"0.58886176",
"0.58886176",
"0.5854882",
"0.5834354",
"0.5799104",
"0.57475615",
"0.56925696",
"0.5676094",
"0.56540793",
"0.56383044",
"0.5614... | 0.0 | -1 |
The MAC Security (MACsec) CKN to associate with the dedicated connection. The valid values are 64 hexadecimal characters (09, AE). Required if using `cak`. | def ckn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "ckn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mac_string():\n mac_int = getnode()\n mac_str = ':'.join((\"%012x\" % mac_int)[i:i + 2] for i in range(0, 12, 2))\n return mac_str",
"def getMacName(self):\r\n return CipherSuite.canonicalMacName(self.cipherSuite)",
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_z... | [
"0.634334",
"0.6328112",
"0.6265812",
"0.616471",
"0.61055714",
"0.59995866",
"0.59923273",
"0.59923273",
"0.5942146",
"0.5940359",
"0.5921319",
"0.58917916",
"0.58917916",
"0.5867987",
"0.58056605",
"0.579108",
"0.57757354",
"0.5723496",
"0.5694966",
"0.56643826",
"0.5660127... | 0.57556146 | 18 |
The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key to associate with the dedicated connection. | def secret_arn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "secret_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secret_arn(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"secret_arn\")",
"def secret_key(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"secret_key\")",
"def kms_key_arn(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"kms_key_arn\")",
"def get_a... | [
"0.65333796",
"0.63317716",
"0.6219413",
"0.61991936",
"0.60343134",
"0.5992395",
"0.59799904",
"0.59799904",
"0.5920522",
"0.5912278",
"0.590071",
"0.590071",
"0.58352315",
"0.5764725",
"0.5735273",
"0.5716099",
"0.57024133",
"0.5698535",
"0.56805",
"0.56659544",
"0.56536514... | 0.61532855 | 6 |
The date in UTC format that the MAC Security (MACsec) secret key takes effect. | def start_on(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "start_on") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUserSignupDate(self):\r\n userinfo = self.getUserInfo()\r\n timestamp = int(float(userinfo[\"signupTimeSec\"]))\r\n return time.strftime(\"%m/%d/%Y %H:%M\", time.gmtime(timestamp))",
"def get_date():\n\n return datetime.datetime.utcnow().isoformat()",
"def get_date(self):\n ... | [
"0.66778237",
"0.64367825",
"0.6328016",
"0.62454045",
"0.6227865",
"0.620385",
"0.6143129",
"0.60557044",
"0.6052782",
"0.60320383",
"0.60202897",
"0.6004045",
"0.5986499",
"0.5981786",
"0.590914",
"0.5895016",
"0.58807665",
"0.5877013",
"0.5874824",
"0.58704966",
"0.5868146... | 0.0 | -1 |
The MAC Security (MACsec) CAK to associate with the dedicated connection. The valid values are 64 hexadecimal characters (09, AE). Required if using `ckn`. | def cak(self) -> pulumi.Output[Optional[str]]:
return pulumi.get(self, "cak") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_zero_vector(16))\n return engine.encrypt(data)[-16:]",
"def getMacName(self):\r\n return CipherSuite.canonicalMacName(self.cipherSuite)",
"def macFor(cls, board):\n return cls.MAC_PREFIX + '{:02X}'.format(int(board))",
"def... | [
"0.6891271",
"0.6485267",
"0.61469626",
"0.61116815",
"0.6084731",
"0.6069341",
"0.6015226",
"0.59660095",
"0.59660095",
"0.5954819",
"0.589143",
"0.589143",
"0.5856658",
"0.5836837",
"0.5800456",
"0.574984",
"0.5693216",
"0.56777513",
"0.5656449",
"0.56402016",
"0.5616092",
... | 0.0 | -1 |
The MAC Security (MACsec) CKN to associate with the dedicated connection. The valid values are 64 hexadecimal characters (09, AE). Required if using `cak`. | def ckn(self) -> pulumi.Output[str]:
return pulumi.get(self, "ckn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mac_string():\n mac_int = getnode()\n mac_str = ':'.join((\"%012x\" % mac_int)[i:i + 2] for i in range(0, 12, 2))\n return mac_str",
"def getMacName(self):\r\n return CipherSuite.canonicalMacName(self.cipherSuite)",
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_z... | [
"0.63453543",
"0.6329982",
"0.6266284",
"0.6167232",
"0.6106864",
"0.6002593",
"0.59943235",
"0.59943235",
"0.594347",
"0.59427184",
"0.59227896",
"0.5893499",
"0.5893499",
"0.580731",
"0.579305",
"0.57776695",
"0.5753917",
"0.5753917",
"0.572496",
"0.5696964",
"0.5666311",
... | 0.5866067 | 13 |
The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key to associate with the dedicated connection. | def secret_arn(self) -> pulumi.Output[str]:
return pulumi.get(self, "secret_arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secret_key(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"secret_key\")",
"def kms_key_arn(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"kms_key_arn\")",
"def get_ami_keyname ( app_name ) :\n return app_name + '.ami'",
"def secret_arn(self) -> Optional[pulum... | [
"0.63301337",
"0.62196976",
"0.61981744",
"0.6154028",
"0.6154028",
"0.6154028",
"0.60333073",
"0.5990695",
"0.5979796",
"0.5979796",
"0.59181714",
"0.59101564",
"0.5898456",
"0.5898456",
"0.5833226",
"0.5762903",
"0.5733999",
"0.57136726",
"0.5699928",
"0.5698245",
"0.568074... | 0.65344346 | 0 |
The date in UTC format that the MAC Security (MACsec) secret key takes effect. | def start_on(self) -> pulumi.Output[str]:
return pulumi.get(self, "start_on") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUserSignupDate(self):\r\n userinfo = self.getUserInfo()\r\n timestamp = int(float(userinfo[\"signupTimeSec\"]))\r\n return time.strftime(\"%m/%d/%Y %H:%M\", time.gmtime(timestamp))",
"def get_date():\n\n return datetime.datetime.utcnow().isoformat()",
"def get_date(self):\n ... | [
"0.6677898",
"0.64363104",
"0.6328461",
"0.6244495",
"0.622804",
"0.62006503",
"0.61413103",
"0.60531515",
"0.60512644",
"0.6032967",
"0.60202944",
"0.6003988",
"0.5984427",
"0.5979833",
"0.59069",
"0.58951735",
"0.58780396",
"0.5877223",
"0.58764714",
"0.5871618",
"0.5868083... | 0.0 | -1 |
batch_condition list[str]. str values MUST refer to cell metadata keys in obs. | def test_batch_condition_is_column_from_obs(self):
self.validator.adata.uns["batch_condition"] = ["NO_COLUMN"]
self.validator.validate_adata()
self.assertEqual(
self.validator.errors,
[
"ERROR: Value 'NO_COLUMN' of list 'batch_condition' is not a "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_conditional(self, buffer):\n\t\tret = []\n\t\t\n\t\twhile True:\n\t\t\tcondition = Condition(self.__read_until(buffer, \"[\"))\n\t\t\tbuffer.seek(-1, SEEK_CUR)\n\t\t\tvalue = self.__read_block(buffer, startchr=\"[\", endchr=\"]\")\n\t\t\tvalue = SpellString(value).format(self.obj, proxy=self.proxy)\n\t... | [
"0.5601627",
"0.52959913",
"0.5249884",
"0.51418024",
"0.50576925",
"0.50552845",
"0.5029249",
"0.50261825",
"0.50045973",
"0.491102",
"0.4886363",
"0.48753417",
"0.4835975",
"0.483392",
"0.47915676",
"0.47807896",
"0.47803938",
"0.47614968",
"0.4711902",
"0.47084954",
"0.470... | 0.5621609 | 0 |
Helper function to cast JSON unicode data to plain str | def json_str(item):
if isinstance(item, dict):
#return {json_str(key): json_str(value) for key, value in item.iteritems()}
return dict((json_str(key), json_str(value)) for key, value in item.iteritems())
elif isinstance(item, list):
return [json_str(element) for element in item]
eli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toString(data):\n\tif isString(data):\n\t\treturn data\n\telse:\n\t\treturn data.decode(\"latin-1\")",
"def to_unicode(data):\n return to_string(data)",
"def to_unicode(data):\n if isinstance(data, bytes):\n return data.decode('utf-8')\n else:\n return data",
"d... | [
"0.7320742",
"0.7196213",
"0.7165662",
"0.70806295",
"0.70713603",
"0.701533",
"0.699519",
"0.6953077",
"0.694383",
"0.6941315",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0.6936791",
"0... | 0.7295068 | 1 |
Helper method for selecting taskspecific head. | def select_output_head(self, output, head_ids: Iterable) -> torch.Tensor:
# TODO: improve performance by vectorizing this operation.
# However, not too bad for now since number of classes is small (usually 2 or 5).
for i, head in enumerate(head_ids):
offset1 = int((head - 1) * self.n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(self) -> TaskHead:\n return self._model.head",
"def head(self) -> tf.estimator.Head:\n\n task_type = self._problem_statement.tasks[0].type\n if task_type.HasField('one_dimensional_regression'):\n return tf.estimator.RegressionHead()\n num_classes = (\n self._tf_transform_outp... | [
"0.6484909",
"0.6195095",
"0.60027295",
"0.57025117",
"0.5634299",
"0.5621204",
"0.5615446",
"0.55770695",
"0.5478022",
"0.5463404",
"0.5348855",
"0.5325524",
"0.52829325",
"0.5192925",
"0.5184258",
"0.5182757",
"0.51746035",
"0.5145915",
"0.5118654",
"0.5113379",
"0.5071875"... | 0.47473708 | 83 |
Return the first_name plus the last_name, with a space in between. | def get_full_name(self):
full_name = '%s %s' % (self.first_name, self.last_name)
return full_name.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n\t\n\treturn first_name + \" \" + last_name",
"def get_formated_name(first_name,last_name):\n\tfull_name = first_name + '' + last_name\n\treturn full_name.title()",
"def get_full_name(se... | [
"0.83421856",
"0.82273436",
"0.80990887",
"0.8067676",
"0.80525744",
"0.8043721",
"0.7993416",
"0.7992513",
"0.7992513",
"0.7992513",
"0.7978309",
"0.7963202",
"0.7957057",
"0.79399455",
"0.7936728",
"0.79338795",
"0.79154027",
"0.7901051",
"0.7892942",
"0.787005",
"0.7855431... | 0.77777326 | 58 |
Is the user a member of staff? | def is_staff(self):
# Simplest possible answer: All admins are staff
return self.is_admin | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def is_staff(ctx):\n member = ctx.message.author\n vipRole = discord.utils.get(member.guild.roles, name=ROLE_VIP)\n staffRole = discord.utils.get(member.guild.roles, name=ROLE_STAFF)\n return vipRole in member.roles or staffRole in member.roles",
"def is_staff(self):\n\t\treturn self.is_admin",... | [
"0.80926746",
"0.7837715",
"0.77254343",
"0.7695358",
"0.76053584",
"0.76053584",
"0.75437886",
"0.75398374",
"0.74684024",
"0.7419359",
"0.74095607",
"0.7408753",
"0.74056166",
"0.71173227",
"0.7050053",
"0.7050053",
"0.7017228",
"0.6948149",
"0.687611",
"0.6858756",
"0.6831... | 0.794206 | 3 |
Get the min number of jumps to get thru the array. | def solve(k=[]):
if len(k) < 2:
return 1
min_jumps = len(k)
for i in reversed(range(k[0])):
if i > len(k):
return 1
if k[i] != 0:
sub_jumps = solve(k[i + 1 :])
min_jumps = min(min_jumps, sub_jumps)
return min_jumps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minNumbersOfJumbs(array):\n\n # case array is empty or has 1 element\n if len(array) < 2:\n return 0\n jump = array[0]\n max_reach = array[0]\n # case for number is enough to reach end\n if jump >= len(array) - 1:\n return 1\n step = 1\n idx = 1",
"def jump(self, A):\n ... | [
"0.7533833",
"0.69635075",
"0.6425989",
"0.6175034",
"0.6122982",
"0.6098591",
"0.5974532",
"0.59527886",
"0.5949562",
"0.5938186",
"0.5921373",
"0.59158945",
"0.58979535",
"0.5887581",
"0.58844537",
"0.58525664",
"0.58522713",
"0.58485454",
"0.58103365",
"0.5806879",
"0.5760... | 0.65343475 | 2 |
Parse a string into a list separated by commas with whitespace stripped | def process_list_arg(arg):
if isinstance(arg, list):
return arg
elif isinstance(arg, basestring):
args = []
for part in arg.split(","):
args.append(part.strip())
return args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_comma_separated_str_to_list(input_str: str, trim: bool = True) -> List[str]:\n comma_separated_str = input_str.strip() if trim else input_str\n if not comma_separated_str:\n return []\n\n result = []\n for part_str in comma_separated_str.split(\",\"):\n value = part_str\n ... | [
"0.7855387",
"0.76898867",
"0.76311827",
"0.7567656",
"0.7567617",
"0.74576783",
"0.74000555",
"0.73943484",
"0.73612314",
"0.7328455",
"0.7289234",
"0.7264855",
"0.7228451",
"0.7192716",
"0.71903723",
"0.71417856",
"0.70785284",
"0.7055804",
"0.7055656",
"0.7037711",
"0.7027... | 0.694682 | 26 |
Rounds down a number to the nearest 10 | def round_down(x):
return int(math.floor(x / 10.0)) * 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_to_ten(number):\n count = len(str(int(number)))\n if number == 1:\n count = 0\n elif number % 10 == 0:\n count = count - 1\n return 10 ** count",
"def roundUP(x):\n\treturn int(ceil(x / 10.0)) * 10",
"def downround(x, base):\n return base * math.floor(float(x) / base)",
... | [
"0.7303302",
"0.7223872",
"0.70913875",
"0.7025419",
"0.69031435",
"0.6885205",
"0.6861663",
"0.6761798",
"0.67119575",
"0.66520786",
"0.663425",
"0.66286135",
"0.65602136",
"0.6533005",
"0.65300715",
"0.65176994",
"0.6515406",
"0.6511412",
"0.65047",
"0.6490064",
"0.6481942"... | 0.80097455 | 0 |
Gets the enable_gateway of this GatewayJson. [DEPRECATED] 'enableGateway' is no longer needed to determine if gateway needs to be launched or not. Presence of gateway definition in request is suffucicient. This value is only used in legacy requests, when 'topologyName' or 'exposedServices' is defined in the root of Gat... | def enable_gateway(self):
return self._enable_gateway | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gateway(self):\n return self.gateway",
"def gateway_config(self) -> 'outputs.GatewayConfigResponse':\n return pulumi.get(self, \"gateway_config\")",
"def enable_gateway(self, enable_gateway):\n\n self._enable_gateway = enable_gateway",
"def gateway_disabled(self) -> Optional[pulu... | [
"0.65902597",
"0.65182024",
"0.6453676",
"0.6213959",
"0.6213959",
"0.6187215",
"0.6100538",
"0.59662163",
"0.58852714",
"0.57671726",
"0.57671726",
"0.57396525",
"0.57111204",
"0.5595449",
"0.5595449",
"0.5556147",
"0.5533451",
"0.5506964",
"0.55048907",
"0.5494863",
"0.5483... | 0.81349915 | 0 |
Sets the enable_gateway of this GatewayJson. [DEPRECATED] 'enableGateway' is no longer needed to determine if gateway needs to be launched or not. Presence of gateway definition in request is suffucicient. This value is only used in legacy requests, when 'topologyName' or 'exposedServices' is defined in the root of Gat... | def enable_gateway(self, enable_gateway):
self._enable_gateway = enable_gateway | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_gateway(self):\n return self._enable_gateway",
"def setGateway(self, gateway):\n # type: (str)->None\n\n self._validator.validate_one(\n 'gateway', VALID_OPTS['gateway'], gateway)\n self._ifAttributes['gateway'] = gateway",
"def setGateway(self):\n\t\tself.gate... | [
"0.73123914",
"0.6551886",
"0.6418623",
"0.5841547",
"0.57586265",
"0.57031846",
"0.5613399",
"0.5599404",
"0.55926114",
"0.55864024",
"0.5570483",
"0.5496303",
"0.54810447",
"0.5477156",
"0.54306054",
"0.5427417",
"0.53842473",
"0.5382908",
"0.536696",
"0.53518987",
"0.53518... | 0.83516294 | 0 |
Gets the topology_name of this GatewayJson. [DEPRECATED] Use the 'topologyName' inside the 'topologies' part of the request. If 'topologyName' is specified, other deprecated properties ('exposedServices' and 'enableGateway') will be used as well, and 'topologies' will be ignored. | def topology_name(self):
return self._topology_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def layer_protocol_name(self) -> str:\n return self._layer_protocol_name",
"def stoptopology(topologyName='all'):\n if topologyName == 'all':\n middleware.protocolObj.stopAllProtocols()\n return\n\n queryData = {'from': '/',\n 'nodes': [{'node': 'topo... | [
"0.6048493",
"0.6005688",
"0.58802223",
"0.5795874",
"0.5704052",
"0.56624806",
"0.55516773",
"0.54985213",
"0.5465749",
"0.5370797",
"0.53402466",
"0.53007513",
"0.527173",
"0.52542615",
"0.52429044",
"0.52349746",
"0.52072144",
"0.5204542",
"0.52032834",
"0.5191515",
"0.519... | 0.753291 | 0 |
Sets the topology_name of this GatewayJson. [DEPRECATED] Use the 'topologyName' inside the 'topologies' part of the request. If 'topologyName' is specified, other deprecated properties ('exposedServices' and 'enableGateway') will be used as well, and 'topologies' will be ignored. | def topology_name(self, topology_name):
self._topology_name = topology_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topology_name(self):\n return self._topology_name",
"def stoptopology(topologyName='all'):\n if topologyName == 'all':\n middleware.protocolObj.stopAllProtocols()\n return\n\n queryData = {'from': '/',\n 'nodes': [{'node': 'topology', 'properti... | [
"0.6206906",
"0.6195226",
"0.5827934",
"0.56365514",
"0.5487861",
"0.54839885",
"0.5411289",
"0.5265941",
"0.52323633",
"0.5163254",
"0.5066797",
"0.49757662",
"0.49562454",
"0.48964873",
"0.4895961",
"0.4873745",
"0.48552898",
"0.4829231",
"0.48174635",
"0.48174635",
"0.4786... | 0.7716903 | 0 |
Sets the token_cert of this GatewayJson. SSO Provider certificate | def token_cert(self, token_cert):
self._token_cert = token_cert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_cert(self):\n return self._token_cert",
"def __set_authentication_token(self, token):\n cache = {\"authentication_token\": token}\n save_json(self._tokenPath, cache)",
"def cert(self, value):\n self._cert = value",
"def device_token(self, device_token):\n \n ... | [
"0.66838616",
"0.6263847",
"0.62306666",
"0.6105429",
"0.5924381",
"0.581866",
"0.581866",
"0.5814446",
"0.57270914",
"0.5695224",
"0.56216717",
"0.55282295",
"0.5387907",
"0.53699404",
"0.5335598",
"0.52814615",
"0.5266987",
"0.5257765",
"0.5257765",
"0.52570313",
"0.5171606... | 0.83835876 | 0 |
Gets the gateway_type of this GatewayJson. Knox gateway type | def gateway_type(self):
return self._gateway_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gateway(self):\n return self.gateway",
"def gateway(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"gateway\")",
"def gateway_name(self) -> str:\n return pulumi.get(self, \"gateway_name\")",
"def device_type(self) -> str:\n return \"urn:schemas-upnp-org:d... | [
"0.70418024",
"0.6706364",
"0.65264463",
"0.64050907",
"0.6376307",
"0.6313232",
"0.6311951",
"0.6297783",
"0.62910956",
"0.62910956",
"0.62734497",
"0.6262733",
"0.6237657",
"0.6224973",
"0.62071085",
"0.62032014",
"0.61929935",
"0.61929935",
"0.61686707",
"0.6162472",
"0.61... | 0.8537298 | 0 |
Sets the gateway_type of this GatewayJson. Knox gateway type | def gateway_type(self, gateway_type):
allowed_values = ["CENTRAL", "INDIVIDUAL"]
if gateway_type not in allowed_values:
raise ValueError(
"Invalid value for `gateway_type` ({0}), must be one of {1}"
.format(gateway_type, allowed_values)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gateway_type(self):\n return self._gateway_type",
"def setGateway(self, gateway):\n # type: (str)->None\n\n self._validator.validate_one(\n 'gateway', VALID_OPTS['gateway'], gateway)\n self._ifAttributes['gateway'] = gateway",
"def gateway_id(self, gateway_id):\n\n ... | [
"0.7202106",
"0.71934044",
"0.6324061",
"0.62779903",
"0.61850834",
"0.60042584",
"0.60042584",
"0.5862711",
"0.57108074",
"0.56767",
"0.56477064",
"0.5628769",
"0.56277716",
"0.5603521",
"0.5600941",
"0.559608",
"0.55518806",
"0.55115426",
"0.55115426",
"0.55036163",
"0.5489... | 0.8208303 | 0 |
Gets the sso_type of this GatewayJson. Knox SSO type | def sso_type(self):
return self._sso_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type (self):\n return self._stype",
"def get_type(self) -> str:\n # Note: this name conflicts with existing python builtins\n return self[\"Sns\"][\"Type\"]",
"def stype(self):\n\n return self.__stype",
"def get_type(self):\n return self._sType",
"def type(self):\... | [
"0.6630452",
"0.6524108",
"0.63855284",
"0.63320684",
"0.6229308",
"0.60349715",
"0.5983019",
"0.5964124",
"0.5919682",
"0.58400786",
"0.5810087",
"0.5808363",
"0.57935923",
"0.57750833",
"0.577089",
"0.577089",
"0.577089",
"0.577089",
"0.577089",
"0.57663316",
"0.57591665",
... | 0.82010865 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, GatewayJson):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Yield successive nsized chunks from lst. | def chunks(lst: list, n: int):
for i in range(0, len(lst), n):
yield lst[i : i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst,... | [
"0.83063734",
"0.81902164",
"0.81902164",
"0.81893295",
"0.8125869",
"0.81209576",
"0.81209576",
"0.80765504",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.805255",
"0.8052... | 0.8193033 | 1 |
Calculate normalized entropy for df divided by values of col | def get_inf(df: pd.DataFrame, col: str) -> int:
inf = 0
# for each unique value in col
for val in np.unique(df[col]):
# create subtable where df[col]=val
df_temp = df[df[col] == val]
# calculate normalized entropy
inf += get_entropy(df_temp) * df_temp.shape[0] / df.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entropy(df: pd.DataFrame) -> int:\r\n\r\n # get unique values and their counts for the last column of df\r\n values, val_freq = np.unique(df[df.columns[-1]], return_counts=True)\r\n val_freq = val_freq / val_freq.sum()\r\n\r\n entropy = 0\r\n for freq in val_freq:\r\n entropy -= freq ... | [
"0.78840464",
"0.7454076",
"0.735403",
"0.7340924",
"0.7262452",
"0.7237606",
"0.7190942",
"0.71153885",
"0.70694304",
"0.7005223",
"0.67457134",
"0.67329663",
"0.6724891",
"0.67233914",
"0.67178714",
"0.6692816",
"0.66803086",
"0.66776246",
"0.6670356",
"0.66673625",
"0.6659... | 0.7137522 | 7 |
Constructs a string representation for the Syllogism object. Returns str String representation containing the premise, quantifier, figure, and term information. | def __str__(self):
rep = 'Generalized Syllogism:\n'
rep += '\ttask: {}\n'.format(self.task)
rep += '\tencoded_task: {}\n'.format(self.encoded_task)
rep += '\tp1: {}\n'.format(self.p1)
rep += '\tp2: {}\n'.format(self.p2)
rep += '\tquantifier_p1: {}\n'.format(self.quantifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sympystr(self, printer: StrPrinter, *args: Any) -> str:\n return self.__str__()",
"def __str__(self):\n astr = ' variables:\\t[ '\n for var in self.variables:\n astr += str(var) + ', '\n astr = astr[:-2] + ' ]\\n assumptions :\\t[ '\n for assumption in se... | [
"0.64853954",
"0.64393795",
"0.6382738",
"0.6356776",
"0.6245419",
"0.6243633",
"0.6222121",
"0.6222121",
"0.62065995",
"0.61915296",
"0.61815387",
"0.61764973",
"0.6171148",
"0.616779",
"0.616753",
"0.61641216",
"0.6157323",
"0.6152924",
"0.613991",
"0.61339176",
"0.6124678"... | 0.769338 | 0 |
(Freebie) Converts a tensor of classes to onehot, useful in XELoss | def to_one_hot(arr, num_classes):
arr = arr.data.astype(int)
a = np.zeros((arr.shape[0], num_classes))
a[np.arange(len(a)), arr] = 1
return tensor.Tensor(a, requires_grad=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class2onehot(class_labels, seq_len, batchsize, num_task):\n\n\n one_hot = torch.FloatTensor(batchsize,seq_len,num_task)\n one_hot.zero_()\n one_hot = one_hot.scatter_(1, seq_len,class_labels, 1)\n\n return one_hot",
"def one_hot(x, num_classes, dtype=jnp.float32):\n return jax.nn.one_hot(x, num_... | [
"0.8471393",
"0.846585",
"0.83316827",
"0.81466115",
"0.8116723",
"0.809805",
"0.79266226",
"0.79055566",
"0.7881197",
"0.7842058",
"0.78201616",
"0.77601755",
"0.7723799",
"0.7715799",
"0.7697902",
"0.7680006",
"0.7664918",
"0.76599306",
"0.7659867",
"0.7650168",
"0.7645842"... | 0.83317983 | 3 |
Gets the size of a Conv1d output. | def get_conv1d_output_size(input_size, kernel_size, stride):
return ((input_size - kernel_size)//stride) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n num_x, num_y = self.conv_dims()\n return num_x * num_y",
"def output_size(self) -> int:\n return self.output_dim",
"def batch_size(self):\n return self._first_rgb.shape[0]",
"def output_dim(self):\n return self._output_dim",
"def get_output_dim(self) -> i... | [
"0.733717",
"0.72851783",
"0.6900208",
"0.6826479",
"0.6802014",
"0.670692",
"0.670348",
"0.6688676",
"0.66867673",
"0.6644342",
"0.6598016",
"0.6598016",
"0.6598016",
"0.6587136",
"0.6587136",
"0.6565159",
"0.65495265",
"0.65477896",
"0.6533459",
"0.6522282",
"0.6513689",
... | 0.78305423 | 1 |
Test string version of ValidationError when no name provided. | def testStr_NoFieldName(self):
self.assertEquals('Validation error',
str(messages.ValidationError('Validation error'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name_validation_error(name):\n return '' if name else accounts.REQUIRED_FIELD_NAME_MSG",
"def test_nonreserved_name(self):\n try:\n field_name_validator('_identifier')\n except ValidationError:\n self.fail('Field name raised ValidationError unexpectedly')",
"def t... | [
"0.7852545",
"0.7554146",
"0.7413365",
"0.7374408",
"0.71972394",
"0.7195476",
"0.7113838",
"0.69740844",
"0.6969488",
"0.6844451",
"0.68431634",
"0.6808134",
"0.67888844",
"0.6654927",
"0.6641623",
"0.66348976",
"0.65368605",
"0.65334266",
"0.6525892",
"0.65234107",
"0.65124... | 0.7588466 | 1 |
Test string version of ValidationError when no name provided. | def testStr_FieldName(self):
validation_error = messages.ValidationError('Validation error')
validation_error.field_name = 'a_field'
self.assertEquals('Validation error', str(validation_error)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name_validation_error(name):\n return '' if name else accounts.REQUIRED_FIELD_NAME_MSG",
"def testStr_NoFieldName(self):\n self.assertEquals('Validation error',\n str(messages.ValidationError('Validation error')))",
"def test_nonreserved_name(self):\n try:\n ... | [
"0.7852545",
"0.7588466",
"0.7554146",
"0.7413365",
"0.7374408",
"0.71972394",
"0.7113838",
"0.69740844",
"0.6969488",
"0.6844451",
"0.68431634",
"0.6808134",
"0.67888844",
"0.6654927",
"0.6641623",
"0.66348976",
"0.65368605",
"0.65334266",
"0.6525892",
"0.65234107",
"0.65124... | 0.7195476 | 6 |
Test that names iterates over enum names. | def testNames(self):
self.assertEquals(
set(['BLUE', 'GREEN', 'INDIGO', 'ORANGE', 'RED',
'VIOLET', 'YELLOW']),
set(Color.names())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_enum(self):\n\n # XXX should test null or empty lists, ill-formed names\n name = 'george'\n pairs = [('abc', 3), ('def', 5), ('ghi', 7)]\n enum = M.EnumSpec.create(name, pairs)\n # self.assertEqual( ','.join(pairs), enum.__repr__())\n self.assertEqual(3, enum.valu... | [
"0.69922745",
"0.698766",
"0.68470335",
"0.6798778",
"0.6685075",
"0.649295",
"0.63822585",
"0.63719535",
"0.6292803",
"0.62737626",
"0.6246769",
"0.62300885",
"0.61811304",
"0.6144995",
"0.6118305",
"0.6058772",
"0.60319513",
"0.60229594",
"0.5974705",
"0.59691167",
"0.59451... | 0.70752907 | 0 |
Test that constructor lookup by name or number. | def testConstructor(self):
self.assertEquals(Color.RED, Color('RED'))
self.assertEquals(Color.RED, Color(u'RED'))
self.assertEquals(Color.RED, Color(20))
if six.PY2:
self.assertEquals(Color.RED, Color(long(20)))
self.assertEquals(Color.RED, Color(Color.RED))
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_constructors(self, name, obj):\n assert getattr(forge, name) == obj",
"def test_constructors(self, name, obj):\n assert getattr(forge, name) == obj",
"def test_constructor_params(self):\n registry = ClassRegistry(attr_name='element')\n registry.register(Bulbasaur)\n\n ... | [
"0.66405135",
"0.66405135",
"0.6618267",
"0.6500247",
"0.62838584",
"0.6279893",
"0.6246566",
"0.6128897",
"0.5946253",
"0.590966",
"0.58919764",
"0.5734203",
"0.571058",
"0.56694764",
"0.5629002",
"0.5628987",
"0.5621229",
"0.56011915",
"0.56001717",
"0.5587909",
"0.5579258"... | 0.6106837 | 8 |
Test that it is not possible to subclass enum classes. | def testNoSubclasses(self):
def declare_subclass():
class MoreColor(Color):
pass
self.assertRaises(messages.EnumDefinitionError,
declare_subclass) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cannot_subclass():\n with pytest.raises(TypeError):\n\n class Subclass(StrEnum):\n B = \"b\"",
"def testNonInt(self):\n self.assertRaises(messages.EnumDefinitionError,\n messages.Enum.def_enum,\n {'Bad': '1'},\n ... | [
"0.8088814",
"0.7381176",
"0.7281386",
"0.7190367",
"0.70609534",
"0.7038123",
"0.70115834",
"0.6951529",
"0.6796058",
"0.67302275",
"0.6634347",
"0.6608742",
"0.6562331",
"0.6552754",
"0.6508182",
"0.6501598",
"0.64333487",
"0.6384052",
"0.63721174",
"0.6327543",
"0.6311986"... | 0.7841519 | 1 |
Test that enum classes themselves are not mutable. | def testClassNotMutable(self):
self.assertRaises(AttributeError,
setattr,
Color,
'something_new',
10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_enum(self):\n i = Organism(state='LIVING')\n print(i)\n print(i.state)\n print(i.state.code)\n print(i.state.code.text)\n print(type(i.state))\n print(StateEnum.LIVING)\n assert str(i.state) == 'LIVING'\n assert i.state.code == StateEnum.LIVIN... | [
"0.6887683",
"0.6689893",
"0.6686943",
"0.6573635",
"0.652777",
"0.6431901",
"0.642446",
"0.627235",
"0.62585884",
"0.62579864",
"0.6214114",
"0.62074876",
"0.6195464",
"0.6193258",
"0.6190906",
"0.61887383",
"0.6182773",
"0.6137542",
"0.60859716",
"0.60665727",
"0.6059495",
... | 0.6196592 | 12 |
Test that enum instances are not mutable. | def testInstancesMutable(self):
self.assertRaises(TypeError,
setattr,
Color.RED,
'something_new',
10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_test_enum_parameters(self):\n pass",
"def testDeleteEnumValue(self):\n self.assertRaises(TypeError, delattr, Color, 'RED')",
"def test_enum_aliases():\n class RedundantStatus(OrderedStrEnum):\n\n draft = 'draft'\n unpublished = 'draft'\n published = 'published'\n ... | [
"0.657697",
"0.6526673",
"0.6460343",
"0.64444536",
"0.64360857",
"0.63570243",
"0.6351252",
"0.6328925",
"0.6234092",
"0.61893916",
"0.6144923",
"0.6127281",
"0.6127104",
"0.6109343",
"0.60295874",
"0.5972383",
"0.59673816",
"0.59616953",
"0.59588724",
"0.5912825",
"0.590454... | 0.6341409 | 7 |
Test that zero is accepted by enum def. | def testLowerBound(self):
class NotImportant(messages.Enum):
"""Testing for value zero"""
VALUE = 0
self.assertEquals(0, int(NotImportant.VALUE)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNegativeInt(self):\n self.assertRaises(messages.EnumDefinitionError,\n messages.Enum.def_enum,\n {'Bad': -1},\n 'BadEnum')",
"def testNonInt(self):\n self.assertRaises(messages.EnumDefinitionError,\n ... | [
"0.7602643",
"0.7408601",
"0.6989304",
"0.6851257",
"0.67956066",
"0.6636969",
"0.65762377",
"0.6494661",
"0.6482349",
"0.6433868",
"0.6414908",
"0.64125925",
"0.63825727",
"0.6295969",
"0.6196025",
"0.6191418",
"0.6177731",
"0.61717844",
"0.61537784",
"0.610948",
"0.61057794... | 0.7145924 | 2 |
Test duplicated numbers are forbidden. | def testRepeatedInt(self):
self.assertRaises(messages.EnumDefinitionError,
messages.Enum.def_enum,
{'Ok': 1, 'Repeated': 1},
'BadEnum') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canBeWritten(n):\n for a in abundantNumbersList:\n if a >= n: break\n if (n - a) in abundantNumbersSet:\n return True\n return False",
"def containsDuplicateSet(self, nums):\n distinct_nums = set()\n for number in nums:\n if number in distinct_nums:\n retu... | [
"0.65833473",
"0.65705496",
"0.6536712",
"0.6530836",
"0.64698064",
"0.64655197",
"0.6447277",
"0.6399993",
"0.63913417",
"0.63548684",
"0.6326235",
"0.63232464",
"0.6302651",
"0.62813985",
"0.6270448",
"0.6258638",
"0.62436175",
"0.619907",
"0.61540246",
"0.61496186",
"0.614... | 0.0 | -1 |
Test that enum values cannot be deleted. | def testDeleteEnumValue(self):
self.assertRaises(TypeError, delattr, Color, 'RED') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNonInt(self):\n self.assertRaises(messages.EnumDefinitionError,\n messages.Enum.def_enum,\n {'Bad': '1'},\n 'BadEnum')",
"def testNegativeInt(self):\n self.assertRaises(messages.EnumDefinitionError,\n ... | [
"0.6908722",
"0.68509686",
"0.6744683",
"0.6659874",
"0.66562176",
"0.6312567",
"0.6271532",
"0.62666756",
"0.62070537",
"0.61610836",
"0.6121907",
"0.61174816",
"0.61117727",
"0.6075593",
"0.606299",
"0.60499424",
"0.60385823",
"0.6023158",
"0.5957477",
"0.5937778",
"0.59223... | 0.76320446 | 0 |
Test comparing various enums to different types. | def testComparison(self):
class Enum1(messages.Enum):
VAL1 = 1
VAL2 = 2
class Enum2(messages.Enum):
VAL1 = 1
self.assertEquals(Enum1.VAL1, Enum1.VAL1)
self.assertNotEquals(Enum1.VAL1, Enum1.VAL2)
self.assertNotEquals(Enum1.VAL1, Enum2.VAL1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assert_enum_types_equal(self, type1, type2):\n self.assertEqual(type1.name, type2.name)\n self.assertEqual(type1.description, type2.description)\n self.assertEqual(type1.func_descriptor, type2.func_descriptor)",
"def test_test_enum_parameters(self):\n pass",
"def test_enum_data... | [
"0.7618909",
"0.7297068",
"0.71660525",
"0.7050482",
"0.6901546",
"0.6642597",
"0.6582936",
"0.65039986",
"0.6500808",
"0.6477391",
"0.638795",
"0.6263912",
"0.6262335",
"0.62503576",
"0.61707455",
"0.61585224",
"0.6154037",
"0.6147419",
"0.61307144",
"0.6094133",
"0.6074393"... | 0.7182442 | 2 |
Test the default for enum fields. | def testDefaultFields_Enum(self):
class Symbol(messages.Enum):
ALPHA = 1
BETA = 2
GAMMA = 3
field = messages.EnumField(Symbol, 1, default=Symbol.ALPHA)
self.assertEquals(Symbol.ALPHA, field.default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefaultFields_EnumInvalidDelayedResolution(self):\n field = messages.EnumField(\n 'apitools.base.protorpclite.descriptor.FieldDescriptor.Label',\n 1,\n default=200)\n\n self.assertRaisesWithRegexpMatch(TypeError,\n 'No s... | [
"0.7850738",
"0.767179",
"0.7604393",
"0.75172764",
"0.74597985",
"0.7141603",
"0.69071805",
"0.6875163",
"0.6871458",
"0.6558437",
"0.6467741",
"0.6462426",
"0.6388132",
"0.6356718",
"0.6331292",
"0.6285885",
"0.62647843",
"0.62253904",
"0.62253904",
"0.61446935",
"0.6105986... | 0.8057588 | 0 |
Test enum fields accept valid default values when type is known. | def testDefaultFields_EnumOkIfTypeKnown(self):
field = messages.EnumField(descriptor.FieldDescriptor.Label,
1,
default='REPEATED')
self.assertEquals(
descriptor.FieldDescriptor.Label.REPEATED, field.default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefaultFields_EnumForceCheckIfTypeKnown(self):\n self.assertRaisesWithRegexpMatch(TypeError,\n 'No such value for NOT_A_LABEL in '\n 'Enum Label',\n messages.EnumField,\n ... | [
"0.786471",
"0.78351843",
"0.7684259",
"0.7630801",
"0.7334507",
"0.724025",
"0.69479555",
"0.69375086",
"0.6876105",
"0.6597608",
"0.6488649",
"0.6474032",
"0.64602745",
"0.6295398",
"0.6283682",
"0.61974555",
"0.6195642",
"0.61881745",
"0.6130701",
"0.61290604",
"0.6096515"... | 0.7740982 | 2 |
Test that enum fields validate default values if type is known. | def testDefaultFields_EnumForceCheckIfTypeKnown(self):
self.assertRaisesWithRegexpMatch(TypeError,
'No such value for NOT_A_LABEL in '
'Enum Label',
messages.EnumField,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefaultFields_EnumInvalidDelayedResolution(self):\n field = messages.EnumField(\n 'apitools.base.protorpclite.descriptor.FieldDescriptor.Label',\n 1,\n default=200)\n\n self.assertRaisesWithRegexpMatch(TypeError,\n 'No s... | [
"0.78986794",
"0.7757604",
"0.7684634",
"0.75887585",
"0.7447553",
"0.7367554",
"0.72267896",
"0.6832946",
"0.6770132",
"0.66414297",
"0.6593828",
"0.6437191",
"0.6280121",
"0.62752575",
"0.6244526",
"0.6226337",
"0.6206059",
"0.61502427",
"0.612854",
"0.6121739",
"0.60703844... | 0.80181134 | 0 |
Tests initializing nested fields from dict. | def testInitializeNestedFieldFromDict(self):
class SimpleMessage(messages.Message):
required = messages.IntegerField(1, required=True)
class NestedMessage(messages.Message):
simple = messages.MessageField(SimpleMessage, 1)
class RepeatedMessage(messages.Message):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_from_dict(self):\n cd = ConfigDict.from_dict({\n 'x': 1,\n 'y': {\n 'z': 2,\n 'w': [1,2, {'v': 22}]\n }\n })\n\n self.assertEquals(cd.x, 1)\n self.assertEquals(cd['x'], 1)\n self.assertEquals(cd.y.z, 2)\n ... | [
"0.7155329",
"0.7135814",
"0.7081419",
"0.6749261",
"0.6727118",
"0.6556593",
"0.64841324",
"0.641289",
"0.63878983",
"0.6306532",
"0.62942207",
"0.6276404",
"0.62739915",
"0.6234808",
"0.62086767",
"0.62051576",
"0.620174",
"0.61937636",
"0.6188055",
"0.61597556",
"0.6141780... | 0.7599895 | 0 |
Test attribute assignment on Message classes is not allowed. | def testNestedAttributesNotAllowed(self):
def int_attribute():
class WithMethods(messages.Message):
not_allowed = 1
def string_attribute():
class WithMethods(messages.Message):
not_allowed = 'not allowed'
def enum_attribute():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDisallowClassAssignments(self):\n class MyMessage(messages.Message):\n pass\n\n self.assertRaises(AttributeError,\n setattr,\n MyMessage,\n 'x',\n 'do not assign')",
"def testStric... | [
"0.8118892",
"0.7606112",
"0.6561863",
"0.6499201",
"0.62957966",
"0.6242465",
"0.61155164",
"0.60972804",
"0.60857403",
"0.60814947",
"0.6072642",
"0.60660076",
"0.6011382",
"0.6005267",
"0.5998869",
"0.5993389",
"0.5971787",
"0.5943228",
"0.5914259",
"0.5909385",
"0.5899644... | 0.70725846 | 2 |
Not permitted to create subclasses of message classes. | def testSubclassingMessageDisallowed(self):
class SuperClass(messages.Message):
pass
def action():
class SubClass(SuperClass):
pass
self.assertRaises(messages.MessageDefinitionError,
action) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDisallowClassAssignments(self):\n class MyMessage(messages.Message):\n pass\n\n self.assertRaises(AttributeError,\n setattr,\n MyMessage,\n 'x',\n 'do not assign')",
"def testAllow... | [
"0.62968034",
"0.6091969",
"0.6006056",
"0.5942203",
"0.5712671",
"0.56922156",
"0.55952567",
"0.5550872",
"0.5507227",
"0.5468906",
"0.54688823",
"0.54675394",
"0.5416633",
"0.53874284",
"0.53740114",
"0.5371319",
"0.53657067",
"0.53164726",
"0.5283719",
"0.5225013",
"0.5224... | 0.7756037 | 0 |
Test allowing nested enums in a message definition. | def testAllowNestedEnums(self):
class Trade(messages.Message):
class Duration(messages.Enum):
GTC = 1
DAY = 2
class Currency(messages.Enum):
USD = 1
GBP = 2
INR = 3
# Sorted by name order seems to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testMessageDefinition(self):\n class OuterEnum(messages.Enum):\n pass\n\n self.assertEquals(None, OuterEnum.message_definition())\n\n class OuterMessage(messages.Message):\n\n class InnerEnum(messages.Enum):\n pass\n\n self.assertEquals(\n ... | [
"0.7443277",
"0.7113204",
"0.70678514",
"0.690198",
"0.6726821",
"0.669236",
"0.66888726",
"0.668191",
"0.6675376",
"0.66639453",
"0.66409945",
"0.6588712",
"0.6538406",
"0.6531824",
"0.6368488",
"0.63350827",
"0.6306954",
"0.62504727",
"0.61600363",
"0.6150363",
"0.6130172",... | 0.80088055 | 0 |
Test message class equality. | def testEquality(self):
# Comparison against enums must work.
class MyEnum(messages.Enum):
val1 = 1
val2 = 2
# Comparisons against nested messages must work.
class AnotherMessage(messages.Message):
string = messages.StringField(1)
class MyMes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, message):\n return (self.source == message.source and\n self.destination == message.destination and\n self.size_bytes == message.size_bytes and\n self.message_type == message.message_type and\n self.data == message.data)",
"def _... | [
"0.7344584",
"0.69156027",
"0.6772732",
"0.67279756",
"0.6687771",
"0.66845286",
"0.6625576",
"0.65741235",
"0.64978456",
"0.64972967",
"0.64322907",
"0.63935477",
"0.6388816",
"0.6368704",
"0.6365063",
"0.6363504",
"0.63597316",
"0.63538635",
"0.6352487",
"0.6343266",
"0.633... | 0.75720865 | 0 |
Test that Enums are found. | def testFindEnum(self):
class Color(messages.Enum):
pass
A = self.DefineMessage('a', 'A', {'Color': Color})
self.assertEquals(
Color,
messages.find_definition('Color', A, importer=self.Importer)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_enum(self):\n with sphinx_build('pyexample'):\n with open('_build/text/docfx_yaml/example.enum_type.EnumFoo.yml') as yml_file:\n data = yaml.safe_load(yml_file)\n for item in data['items']:\n if item['uid'] == 'example.enum_type.EnumFoo':\... | [
"0.73005867",
"0.72388184",
"0.7150594",
"0.7072543",
"0.70191026",
"0.6923182",
"0.6814975",
"0.6765079",
"0.666039",
"0.66602975",
"0.6659067",
"0.66451603",
"0.66037697",
"0.65739936",
"0.65699494",
"0.6549572",
"0.6526382",
"0.6406287",
"0.6378296",
"0.63611513",
"0.63607... | 0.73138624 | 0 |
Update an existing post. | def mutate(self, info, **arguments):
post_id = from_global_id(arguments.pop('id'))[1]
post = PostModel.objects.get(pk=post_id)
if not post:
print("=" * 100)
print("schema.py@41")
print("Erro while updating post")
print("=" * 100)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_post(post_id):\n\n post = Post.query.get_or_404(post_id)\n post.title = request.form[\"edit_post_title\"]\n post.content = request.form[\"edit_post_content\"]\n tag_ids = [int(num) for num in request.form.getlist(\"tags\")]\n post.tags = Tag.query.filter(Tag.id.in_(tag_ids)).all()\n\n ... | [
"0.77233607",
"0.7450944",
"0.7264696",
"0.7071551",
"0.70528066",
"0.6966255",
"0.6850572",
"0.67310226",
"0.6657074",
"0.66340834",
"0.6580428",
"0.6550912",
"0.6476071",
"0.6458061",
"0.64543605",
"0.64482594",
"0.6400658",
"0.63092726",
"0.62942237",
"0.62768227",
"0.6256... | 0.63880545 | 17 |
Unload a config entry. | async def async_unload_entry(opp: OpenPeerPower, entry: ConfigEntry) -> bool:
unload_ok = await opp.config_entries.async_unload_platforms(entry, PLATFORMS)
return unload_ok | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.69724077",
"0.68874407",
"0.67794776",
"0.6747554",
"0.6690105",
"0.66575706",
"0.6615711",
"0.6602761",
"0.6592408",
"0.6559057",
"0.654105",
"0.6507526",
"0.6507526",
"0.6507526",
"0.6507526",
"0.64986694",
"0.64931244",
"0.6486496",
"0.6486496",
"0.6486496",
"0.6486496"... | 0.58749133 | 75 |
Generate a pandas series of the month as a string in YYYYMM format from the date column. | def get_month_as_str_col(df, date_col):
return df[date_col].dt.to_period("M").astype(str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_month(date):\n return date.month",
"def get_month(self, indate):\n return indate.strftime(\"%B\") + \"-\" + indate.strftime(\"%Y\")",
"def MONTH(date):\n return _make_datetime(date).month",
"def get_months_to_date():\n month_sequence = [5, 4, 3, 2, 1, 12, 11, 10, 9, 8] # season is Aug... | [
"0.6820479",
"0.6816802",
"0.67744964",
"0.6645461",
"0.65257865",
"0.65239125",
"0.6504214",
"0.6417957",
"0.6161367",
"0.60417557",
"0.5985766",
"0.59812903",
"0.59743094",
"0.5946948",
"0.5943847",
"0.5914783",
"0.58986276",
"0.5883355",
"0.5837632",
"0.5800411",
"0.578265... | 0.7873443 | 0 |
Load the evictions data, filter for the correct years, and add a column that contains the month. | def load_evictions_data(data_path, date_col, min_year, max_year, create_geoid = True):
ev_raw = (
pd.read_csv(
data_path,
parse_dates=[date_col],
infer_datetime_format=True,
)
.dropna(how="all")
.drop_duplicates()
)
ev_raw["year"] = ev_raw[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_data(self, year, month):\n data = _download_to_df(self.url, self.table_name, year, month)\n if 'INTERVENTION' in data.columns:\n data = data[data['INTERVENTION'] == 0]\n data = data.loc[:, self.table_columns]\n with self.con:\n data.to_sql(self.table_name, ... | [
"0.61134815",
"0.5813346",
"0.56931615",
"0.5646574",
"0.56113833",
"0.55939126",
"0.5563639",
"0.553234",
"0.5529593",
"0.55283165",
"0.5522799",
"0.5511767",
"0.54909074",
"0.54862744",
"0.54622716",
"0.54586345",
"0.5457239",
"0.5455451",
"0.54375064",
"0.54339886",
"0.540... | 0.7239205 | 0 |
Build a dictionary where the keys are the current column names and the values are new column names based on an input dictionary that contains substrings to rename. For example, if the dataframe contains the columns 'evictions2016' and 'evictions2017', and the | def build_rename_mapper_from_df(df, chunk_name_mapper):
rename_mapper = {}
for column_name_chunk in chunk_name_mapper:
for c in df.columns:
if column_name_chunk in c:
rename_mapper[c] = c.replace(
column_name_chunk, chunk_name_mapper[column_name_chunk]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def col_rename(col_dict, df_con_rename):\n\n for ex, nex in col_dict.items():\n df_con_rename = df_con_rename.withColumnRenamed(ex, nex)\n return df_con_rename",
"def _clean_up_table_column_names(loop_dict):\n \n # Make the column names all lowercase\n # and remove any underscores from the ... | [
"0.69809294",
"0.6678324",
"0.65761524",
"0.6243225",
"0.62233025",
"0.5953338",
"0.5882547",
"0.58742905",
"0.58526826",
"0.5795768",
"0.5744195",
"0.57226086",
"0.5706661",
"0.5697401",
"0.5667592",
"0.5647275",
"0.5643964",
"0.56303316",
"0.55835027",
"0.55698323",
"0.5568... | 0.624491 | 3 |
Iterate a dict in order. If k from order not found in d yield rest of d elements. | def dictsort_by(d, order, items = False, skip=True):
_d = d.copy()
while _d:
for ko in order:
if ko in _d:
v = _d.pop(ko)
yield ko if not items else (ko, v)
if not skip:
# return the rest of the dict
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_items(dic, key_order, other_keys_too=True):\n d = dic.copy()\n for key in key_order:\n if key in d:\n yield key, d.pop(key)\n if other_keys_too:\n for key, value in d.iteritems():\n yield key, value",
"def dfilter(d: dict, *keys: Iterable, reverse=False) -... | [
"0.73893416",
"0.6519104",
"0.6155327",
"0.61162204",
"0.6020384",
"0.59583277",
"0.5868979",
"0.58036005",
"0.5773749",
"0.57537943",
"0.5752917",
"0.57030284",
"0.5700442",
"0.5700442",
"0.5676789",
"0.56406915",
"0.5603756",
"0.55927795",
"0.55480206",
"0.55439466",
"0.551... | 0.71858793 | 1 |
Create subset of the given data by selecting only the indices of the given labels | def filter_dataset_by_labels(labels, data, num_each_label):
first = True
all_ds = None
for label in labels:
ds_l = data.filter(lambda d: d.get("label") == label).take(num_each_label)
if first:
all_ds = ds_l
first = False
else:
all_ds = all_ds.conca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setSubset(self, label, indices):\n\n for label in FLAG_ALIASES.get(label, [label]):\n self._subsets[label] = indices",
"def demo_select_indexes():\n\n ps = tf.constant([[0.2, 0.8],\n [0.4, 0.6],\n [0.25, 0.75]])\n\n idxs = tf.constant([1, 0, ... | [
"0.63808423",
"0.63712794",
"0.63355976",
"0.633141",
"0.62201077",
"0.6169739",
"0.61553794",
"0.6152089",
"0.613982",
"0.6090856",
"0.6062694",
"0.6053092",
"0.5947956",
"0.5934873",
"0.59190375",
"0.5914073",
"0.59030604",
"0.58853525",
"0.5884873",
"0.588486",
"0.58557004... | 0.6385612 | 0 |
Return the class of this sensor, from DEVICE_CLASSES. | def device_class(self):
return self._device_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return DEVICE_CLASSES.get(self.sensor_data[\"model\"])",
"def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")",
"def device_class(self):\n if self.sensor_class... | [
"0.906293",
"0.89478695",
"0.8810025",
"0.87471527",
"0.8745711",
"0.8745711",
"0.8733673",
"0.8711787",
"0.85650563",
"0.85650563",
"0.85538274",
"0.8434772",
"0.8431975",
"0.8389737",
"0.8317508",
"0.8282632",
"0.8270846",
"0.81682813",
"0.81074876",
"0.80012065",
"0.791262... | 0.7797398 | 30 |
Return moving average for period n. | def smooth(x, n):
w = np.ones((n, )) / n
return np.convolve(x, w, mode='valid') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moving_average(a, n=3) :\n ret = np.cumsum(a, dtype=float)\n ret[n:] = ret[n:] - ret[:-n]\n return ret[n - 1:] / n",
"def moving_average(self, a, n=3):\n ret = np.nancumsum(a, dtype=float)\n ret[n:] = ret[n:] - ret[:-n]\n return ret[n - 1:] / n",
"def moving_average(a, n: int ... | [
"0.8287956",
"0.8283606",
"0.8266164",
"0.8246738",
"0.80869025",
"0.77691054",
"0.77690303",
"0.76028115",
"0.7515389",
"0.74885786",
"0.7335399",
"0.73217386",
"0.72419006",
"0.7233745",
"0.7210514",
"0.7081684",
"0.7007917",
"0.6938337",
"0.6930907",
"0.6889293",
"0.687886... | 0.0 | -1 |
Sets the head count of the attention. | def head_count(self, head_count):
if head_count < 1:
raise ValueError('The `head_count` must be > 0.')
self._internal.set_head_count(int(head_count)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_first(self, n):\r\n self.__head = n",
"def head(self, head):\n\n self._head = head",
"def __init__(self, count = 0):\n self.head = Head()\n self.count = count",
"def head_count(self):\n return self._internal.get_head_count()",
"def setMancount(self, cnt):\n ... | [
"0.65809035",
"0.6445961",
"0.617921",
"0.6014255",
"0.59382504",
"0.5737634",
"0.57234514",
"0.571104",
"0.5688065",
"0.56128544",
"0.55491555",
"0.54813504",
"0.547836",
"0.54562634",
"0.54312384",
"0.5401055",
"0.5390539",
"0.5390539",
"0.5390539",
"0.5390539",
"0.53676426... | 0.766384 | 0 |
Gets the hidden size of the attention. | def hidden_size(self):
return self._internal.get_hidden_size() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hidden_layer_size(self):\r\n return self.hidden_layer_size",
"def hidden_size(self) ->int:\n return self._cell.hidden_size",
"def hidden_dim(self):\n\n return self.__hidden_dim",
"def get_num_hidden(self) -> int:\n return self.config.model_size",
"def get_num_hid... | [
"0.79684895",
"0.7961351",
"0.7703686",
"0.76353836",
"0.76116514",
"0.74885184",
"0.7055191",
"0.70409167",
"0.7007014",
"0.6997245",
"0.69751203",
"0.6902821",
"0.66552347",
"0.64709866",
"0.6442421",
"0.6323084",
"0.6273863",
"0.61940056",
"0.61748314",
"0.6121945",
"0.608... | 0.8266202 | 0 |
Sets the hidden size of the attention. Must be a multiple of the head_count. | def hidden_size(self, hidden_size):
if hidden_size < 1:
raise ValueError('The `hidden_size` must be > 0.')
self._internal.set_hidden_size(int(hidden_size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, hidden_size):\n self.hidden_size = hidden_size",
"def init_hidden(self, batch_size):\r\n \r\n self.hidden_state = (\r\n torch.zeros(((1+self.bidirectional)*self.num_layers,\r\n batch_size,\r\n self.hidden_size)).to... | [
"0.6589588",
"0.6148756",
"0.61280423",
"0.61280423",
"0.61184096",
"0.61184096",
"0.61184096",
"0.61184096",
"0.61184096",
"0.61184096",
"0.61184096",
"0.61184096",
"0.60918623",
"0.5944475",
"0.5942377",
"0.5916657",
"0.5914759",
"0.58672327",
"0.5853337",
"0.5853337",
"0.5... | 0.75677925 | 0 |
Gets the dropout rate. | def dropout(self):
return self._internal.get_dropout() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dropout_rate(data, sample_period=None):\n if sample_period is None:\n sample_period = get_sample_period(data)\n\n N_SAMPLES = 100\n if len(data) < N_SAMPLES:\n raise TooFewSamplesError\n\n index = _get_index(data)\n assert(index[-1] > index[0])\n duration = index[-1] - index... | [
"0.6945431",
"0.65463257",
"0.65403146",
"0.6514084",
"0.6437919",
"0.63834643",
"0.63766336",
"0.62054086",
"0.615905",
"0.61472106",
"0.6141882",
"0.6135444",
"0.61030954",
"0.60875463",
"0.6058535",
"0.6058535",
"0.6032272",
"0.60243934",
"0.6021965",
"0.60163975",
"0.6003... | 0.6576083 | 1 |
Sets the hidden size of the attention. Must be a multiple of the head_count. | def dropout(self, dropout):
if dropout >= 1.0:
raise ValueError('The `dropout` must be < 1.')
self._internal.set_dropout(float(dropout)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hidden_size(self, hidden_size):\n if hidden_size < 1:\n raise ValueError('The `hidden_size` must be > 0.')\n self._internal.set_hidden_size(int(hidden_size))",
"def __init__(self, hidden_size):\n self.hidden_size = hidden_size",
"def init_hidden(self, batch_size):\r\n ... | [
"0.7566179",
"0.65882117",
"0.6148157",
"0.61292315",
"0.61292315",
"0.61172795",
"0.61172795",
"0.61172795",
"0.61172795",
"0.61172795",
"0.61172795",
"0.61172795",
"0.61172795",
"0.6092045",
"0.59438396",
"0.59433156",
"0.5916527",
"0.5913501",
"0.5868034",
"0.58528376",
"0... | 0.0 | -1 |
Gets the feed forward size. | def feed_forward_size(self):
return self._internal.get_feed_forward_size() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self) -> int:\n return self._fock.size",
"def size(self):\n\n size = 1\n traverse = self.front\n if self.front == None:\n return 0\n\n while traverse.next != None:\n traverse = traverse.next\n size += 1\n return size",
"def siz... | [
"0.6808853",
"0.6768787",
"0.6768787",
"0.6710059",
"0.6706399",
"0.6704614",
"0.66999125",
"0.6667812",
"0.6648937",
"0.6632664",
"0.65750706",
"0.6566084",
"0.65445834",
"0.6543137",
"0.65260184",
"0.6517553",
"0.64991826",
"0.6496363",
"0.64908564",
"0.6486411",
"0.6476608... | 0.9190133 | 0 |
Sets the feed forward size. | def feed_forward_size(self, feed_forward_size):
if feed_forward_size < 1:
raise ValueError('The `feed_forward_size` must be > 0.')
self._internal.set_feed_forward_size(int(feed_forward_size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed_forward_size(self):\n return self._internal.get_feed_forward_size()",
"def setsize(self, size):\n self.__size = size",
"def setFrameSize(self, frame_size):\n \n self.frame_size = frame_size",
"def set_batch_size(self, batch_size):\n final_sz = self.full_dataset_size % ... | [
"0.71544653",
"0.6409734",
"0.6228593",
"0.62118036",
"0.6199784",
"0.6147276",
"0.6143206",
"0.6134795",
"0.6125311",
"0.60741043",
"0.60501254",
"0.5996163",
"0.5996163",
"0.5996163",
"0.5996163",
"0.5980893",
"0.59804636",
"0.5972744",
"0.597004",
"0.59648114",
"0.5964567"... | 0.8610295 | 0 |
Parse dependencies from 'requirements.txt' file. | def get_requirements():
with open('requirements.txt') as fd:
lines = fd.read().splitlines()
requires, links = [], []
for line in lines:
if line.startswith('git+'):
links.append(line)
elif line:
requires.append(line)
return requi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_requirements_txt():\n root = os.path.dirname(os.path.abspath(__file__))\n\n requirements = []\n dependencies = []\n\n with open(os.path.join(root, 'requirements.txt'), 'r') as f:\n for line in f.readlines():\n line = line.rstrip()\n if not line or line.startswith(... | [
"0.8206447",
"0.76028156",
"0.75480306",
"0.74831784",
"0.7437083",
"0.73807997",
"0.7366033",
"0.7342791",
"0.7295425",
"0.72740453",
"0.7225313",
"0.7213678",
"0.72097725",
"0.7171425",
"0.7153191",
"0.710717",
"0.70973235",
"0.7024207",
"0.7006107",
"0.6994257",
"0.6955289... | 0.7310824 | 8 |
Find a rectangular perspective to represent a headon view of the image | def get_perspective(feed, hex_color, tolerance=0.10, img_map=False):
contour = None
while contour is None:
read_success, frame = feed.read()
logger.info("Frame: %s" % str(frame))
if not read_success:
logger.info("No frame read; continuing loop...")
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flattener(image, pts, w, h):\n temp_rect = np.zeros((4,2), dtype = \"float32\")\n\n s = np.sum(pts, axis = 2)\n\n tl = pts[np.argmin(s)]\n br = pts[np.argmax(s)]\n\n diff = np.diff(pts, axis = -1)\n tr = pts[np.argmin(diff)]\n bl = pts[np.argmax(diff)]\n\n # Need to create an array list... | [
"0.7054508",
"0.70284677",
"0.67805535",
"0.66709024",
"0.659098",
"0.65166163",
"0.6490359",
"0.64517283",
"0.64311296",
"0.63075954",
"0.6292712",
"0.6260339",
"0.6258728",
"0.62430644",
"0.620262",
"0.6184208",
"0.61833113",
"0.6148804",
"0.61446136",
"0.6126091",
"0.61115... | 0.6234256 | 14 |
Computes the average absolute residual and the maximum residual of the current problem. | def compute_residual_stats(problem):
if len(problem.constraints) == 0:
return (None, None)
sum_residuals = 0
max_residual = 0
n_residuals = 0
for constraint in problem.constraints:
# print(constraint.residual.is_constant())
res = constraint.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _residual_edp(self, params):\n data = self.F**2\n model = np.absolute(self._model())**2\n sigma = self.sigma\n return (data[self.mask]-model[self.mask]) / sigma[self.mask] \n \n # The following three lines do not reproduce Sun's results, which proves\n # that the fits were done through... | [
"0.6610154",
"0.64421856",
"0.6346543",
"0.6078119",
"0.59952325",
"0.5995135",
"0.599471",
"0.59737897",
"0.5953753",
"0.5899667",
"0.5875445",
"0.5873756",
"0.58345604",
"0.58321524",
"0.583054",
"0.57942235",
"0.5776996",
"0.57658285",
"0.576345",
"0.576341",
"0.57485074",... | 0.6731548 | 0 |
Return ``True`` if the object is a PyVista wrapped dataset. | def is_pyvista_dataset(obj):
return isinstance(obj, (pyvista.DataSet, pyvista.MultiBlock)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dataset(obj):\n return isinstance(obj, (DictDataset, ImageDataset, LabeledImageDataset,\n TupleDataset, DatasetMixin))",
"def is_dataset(self):\n return self._dataset is not None",
"def _is_dataclass_instance(obj):\n return hasattr(type(obj), '__dataclass_fields__')",... | [
"0.73545504",
"0.7327032",
"0.6368359",
"0.6291285",
"0.62759346",
"0.6096682",
"0.60780764",
"0.5947328",
"0.59174824",
"0.5889254",
"0.58726484",
"0.58560395",
"0.58471984",
"0.56990296",
"0.56704766",
"0.56632715",
"0.5662434",
"0.56430274",
"0.5630162",
"0.5613805",
"0.56... | 0.8464892 | 0 |
Check if a point is inside a set of bounds. This is implemented through recursion so that this is Ndimensional. | def is_inside_bounds(point, bounds):
if isinstance(point, (int, float)):
point = [point]
if isinstance(point, (np.ndarray, collections.abc.Sequence)) and not isinstance(
point, collections.deque
):
if len(bounds) < 2 * len(point) or len(bounds) % 2 != 0:
raise ValueError(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inside_limits(self, point):\n if not self.regions:\n # Use rectangle check\n lat, lon = point.latitude, point.longitude\n if (lon > self.limits[0] and lat > self.limits[1] and\n lon < self.limits[2] and lat < self.limits[3]):\n return True\n ... | [
"0.768995",
"0.75680894",
"0.75473225",
"0.74699265",
"0.74127054",
"0.7320254",
"0.7282582",
"0.7282582",
"0.7221446",
"0.7217512",
"0.71895313",
"0.71818227",
"0.71689713",
"0.7152845",
"0.7121815",
"0.7119088",
"0.71156454",
"0.7104448",
"0.70702684",
"0.7021193",
"0.70211... | 0.8008371 | 0 |
Get the leaderboard; a (paginated) list of all users ordered by ranking | def get_leaderboard(request):
includedUsers = User.objects.filter(hide_leaderboard=False, is_staff=False)
# ordered list of points, index denoting leaderboard position (rank)
# distinct values means that everyone with the same points has the same rank
rankings = []
for item in includedUsers.values... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_leaderboard(n, user_id):\r\n sql = text('''\r\n WITH global_rank AS (\r\n WITH scores AS (\r\n SELECT user_id, COUNT(*) AS score FROM task_run\r\n WHERE user_id IS NOT NULL GROUP BY user_id)\r\n SELECT user... | [
"0.79070354",
"0.77093476",
"0.7407578",
"0.7333305",
"0.7133642",
"0.70422405",
"0.70004654",
"0.69224864",
"0.68573904",
"0.6790573",
"0.6720614",
"0.6710295",
"0.6698099",
"0.66826874",
"0.6633133",
"0.659641",
"0.65196115",
"0.6483807",
"0.64620525",
"0.6413542",
"0.64006... | 0.8249403 | 0 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.80820704",
"0.7890804",
"0.75346106",
"0.7278855",
"0.7278855",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
"0.7226189",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
moves = 0
for row in range(len(board)):
for column in range(len(board[row])):
if board[row][column] != EMPTY:
moves+=1
if moves % 2 == 0:
return X
return O
# raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.0 | -1 |
Returns the optimal action for the current player on the board. | def minimax(board):
move = None
if player(board) == X:
highValue = float("-inf")
for action in actions(board):
value = minValue(result(board,action))
if value == 1:
move = action
highValue = value
elif value >= highValue:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.7766856",
"0.76323676",
"0.75855315",
"0.75285065",
"0.75175256",
"0.74667144",
"0.7460485",
"0.74263537",
"0.7416421",
"0.73943585",
"0.7375846",
"0.7333894",
"0.73147565",
"0.7306611",
"0.7284639",
"0.72650313",
"0.72650313",
"0.7250975",
"0.72331834",
"0.7203267",
"0.71... | 0.0 | -1 |
Stops the old thread in case it's running, then sets self.run_thread to a new thread and starts it. | def start_thread(self):
self.stop_thread()
self.running = True
self.run_thread = threading.Thread(target=self.run, daemon=True)
self.run_thread.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_thread(self):\n self.running = False\n if self.run_thread.is_alive():\n self.run_thread.join()",
"def toggle_run_button(self, event):\n if not self.running:\n self.start_thread()\n else:\n self.stop_thread()",
"def start(self) -> None:\n ... | [
"0.6862558",
"0.65574116",
"0.6437334",
"0.6378661",
"0.6230949",
"0.61385745",
"0.60549134",
"0.6039228",
"0.60317194",
"0.5894547",
"0.58698094",
"0.5855439",
"0.58414084",
"0.5814953",
"0.5810383",
"0.5767305",
"0.5763817",
"0.57442796",
"0.5736026",
"0.57241386",
"0.57155... | 0.72492087 | 0 |
Stops the current self.run_thread and joins it (if its alive) Also sets self.running to false | def stop_thread(self):
self.running = False
if self.run_thread.is_alive():
self.run_thread.join() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n self.running = False\n self.join()",
"def stop(self):\n self.should_run = False\n if self.is_alive():\n self.join()",
"def stop(self) -> None:\n assert self.is_alive(), \"Thread not alive\"\n self.stopped.set()",
"def stop(self) -> None:\... | [
"0.82010823",
"0.8177459",
"0.8049424",
"0.7927743",
"0.76515746",
"0.76512253",
"0.7572489",
"0.7568743",
"0.7547752",
"0.749612",
"0.749612",
"0.74943596",
"0.7460452",
"0.7433511",
"0.741764",
"0.74045336",
"0.74045336",
"0.74045336",
"0.74045336",
"0.74045336",
"0.7404533... | 0.89871633 | 0 |
Check if a target object is within a certain distance in front of a reference object. | def is_within_distance_ahead(target_transform, current_transform, max_distance):
target_vector = np.array([target_transform.location.x - current_transform.location.x,
target_transform.location.y - current_transform.location.y])
norm_target = np.linalg.norm(target_vector)
# If ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_within_distance_ahead(target_transform, current_transform, max_distance):\n target_vector = np.array([target_transform.location.x - current_transform.location.x, target_transform.location.y - current_transform.location.y])\n norm_target = np.linalg.norm(target_vector)\n\n # If the vector is too sho... | [
"0.67105824",
"0.6610936",
"0.6604438",
"0.62496036",
"0.6109051",
"0.6100768",
"0.6066971",
"0.60583895",
"0.60580266",
"0.6042359",
"0.6024932",
"0.60143125",
"0.60143125",
"0.59996426",
"0.5911124",
"0.5896701",
"0.58761185",
"0.5869878",
"0.585845",
"0.58277917",
"0.58230... | 0.67055386 | 1 |
Check if a target object is within a certain distance from a reference object. A vehicle in front would be something around 0 deg, while one behind around 180 deg. | def is_within_distance(target_location, current_location, orientation, max_distance, d_angle_th_up, d_angle_th_low=0):
target_vector = np.array([target_location.x - current_location.x, target_location.y - current_location.y])
norm_target = np.linalg.norm(target_vector)
# If the vector is too short, we can ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_within_distance_ahead(target_transform, current_transform, max_distance):\n target_vector = np.array([target_transform.location.x - current_transform.location.x, target_transform.location.y - current_transform.location.y])\n norm_target = np.linalg.norm(target_vector)\n\n # If the vector is too sho... | [
"0.68747115",
"0.6852998",
"0.68305814",
"0.66423887",
"0.6258163",
"0.62306774",
"0.6138802",
"0.6053951",
"0.59971404",
"0.59574085",
"0.59158725",
"0.583687",
"0.58301014",
"0.5828046",
"0.58103186",
"0.58055717",
"0.5805144",
"0.57984054",
"0.57963645",
"0.57429403",
"0.5... | 0.7003688 | 1 |
Returns the unit vector from location_1 to location_2 | def vector(location_1, location_2):
x = location_2.x - location_1.x
y = location_2.y - location_1.y
z = location_2.z - location_1.z
norm = np.linalg.norm([x, y, z]) + np.finfo(float).eps
return [x / norm, y / norm, z / norm] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_vector(i, j):\n magnitude = np.sqrt(i ** 2 + j ** 2)\n unit_i = i / magnitude\n unit_j = j / magnitude\n\n return unit_i, unit_j",
"def _unit_vector(pt0, pt1):\n dis_0_to_1 = sqrt((pt0[0] - pt1[0])**2 + (pt0[1] - pt1[1])**2)\n return (pt1[0] - pt0[0]) / dis_0_to_1, \\\n (pt1[... | [
"0.669603",
"0.64839983",
"0.6461275",
"0.6202012",
"0.6096269",
"0.6096269",
"0.6075195",
"0.6074927",
"0.59702754",
"0.59530854",
"0.58330834",
"0.5821186",
"0.5800835",
"0.57945806",
"0.57792443",
"0.5778809",
"0.5718374",
"0.56765264",
"0.56091136",
"0.56066215",
"0.56054... | 0.79359806 | 1 |
Return the given number if positive, else 0 | def positive(num):
return num if num > 0.0 else 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(num: float):\n return 1 if num >= 0 else -1",
"def make_negative(number):\n if number < 0:\n return number\n else:\n return number * -1",
"def sign(x):\n if x >= 0:\n return 1\n return -1",
"def absolute_value(num):\r\n\r\n\tif num >= 0:\r\n\t\treturn num\r\n\tels... | [
"0.76395184",
"0.7575793",
"0.74351966",
"0.741846",
"0.7392237",
"0.72629845",
"0.7190364",
"0.70063263",
"0.70010287",
"0.6966823",
"0.69396806",
"0.6908973",
"0.6895083",
"0.6792521",
"0.6791796",
"0.6758046",
"0.67472285",
"0.66796434",
"0.66732603",
"0.66656125",
"0.6664... | 0.79707485 | 1 |
Test unauthorized API calls to return a 401 status. | def test_unauthed_calls(self):
expected_response = {"errors": [{
"message": "No valid client certificate presented",
"status": 401
}],
"message": "No valid client certificate presented"}
responses.add(
responses.GET,
f'{os.environ["AIVE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unauthenticated_request(self):\n url = self.get_url(self.active_user.id)\n response = self.client.get(url)\n\n expected_status_code = 401\n self.assertEqual(response.status_code, expected_status_code)",
"def test_unauthorized(self):\n self._error_test(fitbit_exceptions... | [
"0.819252",
"0.8151366",
"0.7993992",
"0.7941144",
"0.7932271",
"0.78789127",
"0.78682816",
"0.78585535",
"0.78585535",
"0.78150344",
"0.77118576",
"0.7686576",
"0.76751953",
"0.76529926",
"0.7623709",
"0.762161",
"0.7601887",
"0.7543062",
"0.75382644",
"0.74732697",
"0.74326... | 0.7744796 | 10 |
Create a list of variable declaraitons from a sequence of symbols. | def genVDeclList(syms):
sortedsyms = sorted(syms, key = lambda s: s.name)
return [dha.VDecl(sym) for sym in sortedsyms] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables(names, **kwargs):\n return symbols(names, cls=Variable, seq=True, **kwargs)",
"def new_declaration (var_names) :\r\n\r\n\ttokens = [\"::\"]\r\n\tfor n in var_names :\r\n\t\ttokens += tokenizer.tokenize(n) + [\",\"]\r\n\tdel tokens[-1]\r\n\r\n\tresult = declaration (tokens)\r\n\r\n\treturn result... | [
"0.7055602",
"0.643417",
"0.64259595",
"0.6159599",
"0.6030119",
"0.6029027",
"0.5929945",
"0.5878523",
"0.5877973",
"0.58494115",
"0.5782728",
"0.5743262",
"0.5719109",
"0.55911773",
"0.55839455",
"0.5573902",
"0.5565973",
"0.5558817",
"0.55486465",
"0.55438215",
"0.5507727"... | 0.5885893 | 7 |
Check if queue is empty | def is_empty(self):
return len(self.__queue) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.queue == []",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.the_queue) == 0",
"def empty(self):\r\n return self.queue == []",
"def empty(... | [
"0.89253086",
"0.8843133",
"0.8843133",
"0.8786258",
"0.87190884",
"0.8708457",
"0.8640375",
"0.8627408",
"0.8615782",
"0.8543514",
"0.849978",
"0.8486712",
"0.8471584",
"0.84412205",
"0.84367406",
"0.8436225",
"0.8400864",
"0.8363655",
"0.8363655",
"0.8253498",
"0.82298285",... | 0.88034135 | 3 |
Returns a JSON response, transforming 'context' to make the payload. | def render_to_json_response(self, context, **response_kwargs):
return HttpResponse(
self.convert_context_to_json(context),
content_type='application/json',
**response_kwargs
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_to_response(self, context):\n return self.get_json_response(self.convert_context_to_json(context))",
"def render_to_response(self, context):\n\t\treturn self.get_json_response(self.convert_context_to_json(context))",
"def render_to_json_response(self, context, **response_kwargs):\n ret... | [
"0.7900071",
"0.78258467",
"0.7558514",
"0.75040793",
"0.7409266",
"0.7409266",
"0.7409266",
"0.7409266",
"0.7409266",
"0.73804635",
"0.73667556",
"0.7348796",
"0.73462486",
"0.73103166",
"0.7131352",
"0.6942184",
"0.6894355",
"0.67183167",
"0.66316086",
"0.66316086",
"0.6631... | 0.7675795 | 3 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Purples):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
# plt.colorbar()
tick_marks = np.arange(len(classes))
... | {
"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.8194586",
"0.8095255",
"0.802963",
"0.80189276",
"0.7994091",
"0.79910594",
"0.798075",
"0.79766196",
"0.79603124",
"0.7957427",
"0.7937533",
"0.7934523",
"0.79342",
"0.7931087",
"0.7926079",
"0.7924241",
"0.79235566",
"0.79232305",
"0.7922709",
"0.7921817",
"0.79173964",
... | 0.7884335 | 35 |
This function creates a DCM that preforms a rotation about the zaxis (3 axis). | def R3(theta):
DCM = np.array([[np.cos(theta), np.sin(theta), 0],
[-np.sin(theta), np.cos(theta), 0],
[0, 0, 1]])
return DCM | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotation3Dz(theta):\n rmat = np.zeros((3,3))\n rmat[0,0] = rmat[1,1] = np.cos(theta)\n rmat[0,1] = np.sin(theta)\n rmat[1,0] = -rmat[0,1]\n rmat[2,2] = 1\n return rmat",
"def matrix_rotate_3d_z(deg: float) -> np.matrix:\n from numpy import cos, sin, pi\n rad_z = -deg * pi/180\n c_z... | [
"0.65059143",
"0.64175415",
"0.6373884",
"0.6362556",
"0.6320967",
"0.62811476",
"0.6274837",
"0.60981184",
"0.6050329",
"0.6046051",
"0.600447",
"0.5984605",
"0.5929926",
"0.5896152",
"0.5891834",
"0.5864436",
"0.585169",
"0.58416396",
"0.5838819",
"0.5838819",
"0.5838819",
... | 0.64006656 | 2 |
Test that a 'block_info' transaction is injected at the end of the block and confirming that all other batches only contains intkey transactions | def test_block_end_injection(self):
intkey_batch1 = create_batch(self.signer, [('inc', 'abcd', 60)])
intkey_batch2 = create_batch(self.signer, [('inc', 'abcd', 70)])
intkey_batch3 = create_batch(self.signer, [('inc', 'abcd', 80)])
batches = create_batch_list(
[intkey_batch1, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_block_extra_batch(self):\n pass",
"def test_after_batch_injection(self):\n intkey_batch1 = create_batch(self.signer, [('inc', 'abcd', 30)])\n intkey_batch2 = create_batch(self.signer, [('inc', 'abcd', 40)])\n intkey_batch3 = create_batch(self.signer, [('inc', 'abcd', 50)])\n ... | [
"0.72756666",
"0.69867986",
"0.6981504",
"0.69490194",
"0.69209087",
"0.6768449",
"0.66532993",
"0.64360857",
"0.641834",
"0.63452566",
"0.6337501",
"0.63339204",
"0.63058966",
"0.6212282",
"0.6200093",
"0.6192124",
"0.61651856",
"0.61635095",
"0.6151241",
"0.61487454",
"0.61... | 0.7343181 | 0 |
Set up test data for the whole TestCase (only run once for the TestCase) | def setUpTestData(cls):
data_gen.run() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n\n self.test_data_path = 'testing/test_data/'",
"def setUp(self):\n self.dataset = get_test_dataset()",
"def setUpTestData(cls):\n # volunteer user\n common.initialize_empty_volunteer()",
"def setUp(self):\n self.dataset = self.dataset_cls()",
"def setUp... | [
"0.8151888",
"0.81410164",
"0.80503845",
"0.7757677",
"0.77493596",
"0.7736056",
"0.7572924",
"0.75631404",
"0.75584584",
"0.75548816",
"0.7549482",
"0.750721",
"0.7504551",
"0.747803",
"0.74672127",
"0.74611723",
"0.744",
"0.74319816",
"0.74318194",
"0.7431639",
"0.74084747"... | 0.80497265 | 6 |
Randomly chooses the parent from the population using the fitness function | def random_select(population, lamda):
fitness_population = []
for i in population:
f_i = fitness_function(i, lamda)
fitness_population.append(f_i)
pList = selection_probability(fitness_population)
rnd_indices = np.random.choice(len(population), p=pList)
choice = population[rnd_indice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_parents(self, population):\n random.shuffle(population)\n return population",
"def stochastic_universal_selection(self, fitness, num_parents):\n\n fitness_sum = numpy.sum(fitness)\n if fitness_sum == 0:\n self.logger.error(\"Cannot proceed because the sum of fitn... | [
"0.73776245",
"0.73322403",
"0.72496444",
"0.6942053",
"0.6917391",
"0.66672504",
"0.6664995",
"0.6656062",
"0.6622094",
"0.661794",
"0.6607694",
"0.6549053",
"0.6543015",
"0.65422386",
"0.6531151",
"0.6485542",
"0.6443142",
"0.6438492",
"0.64118516",
"0.6404566",
"0.6392959"... | 0.62174225 | 31 |
Should return (or generate) querysets for all model instances used by this view. Each instance should have an updated_at field. These querysets are not actually evaluated directly, but union'd together and only their updated_at fields are used without constructing full instances. If None or an empty list is returned, n... | def instances_used(self):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return NoneToEmptyQuerySet(self.model, using=self._db)",
"def queryset(self, request):\n qs = self.model.all_objects.get_query_set()\n ordering = self.ordering or ()\n if ordering:\n qs = qs.order_by(*ordering)\n return qs",
"def queryset(... | [
"0.66364944",
"0.66241235",
"0.65386075",
"0.6535596",
"0.64999497",
"0.64172775",
"0.64170253",
"0.6392134",
"0.636157",
"0.63219714",
"0.63193613",
"0.63077426",
"0.6292829",
"0.6292147",
"0.6286735",
"0.62738156",
"0.6264164",
"0.6264164",
"0.6264164",
"0.6264164",
"0.6264... | 0.0 | -1 |
Initializes normalization or structure functions or planes Initializes the parameters __mean_SF, __std_SF, and __covList. | def __InitializeNorms(self, norm_SF, norm_plane):
# Initializes values
nc = self.__nc_RSoft_I
n_SF = self.__n_SF_rad+self.__n_SF_ang
mean_SF = np.zeros(n_SF)
std_SF = np.zeros(n_SF)
cov_SF = np.zeros((n_SF,n_SF))
n_parts = 0
for idx_type, type_ in enumerate(self.__types_unique):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(self):\n\t\tmu = 0\n\t\tsigma = np.sqrt(2 / self.dataset[\"d\"])\n\n\t\tself.F1 = np.random.normal(mu, sigma, self.F1.shape)\n\t\tself.F2 = np.random.normal(mu, sigma, self.F2.shape)\n\t\tself.W = np.random.normal(mu, sigma, self.W.shape)\n\n\t\tself.F1_momentum = np.zeros(self.F1.shape)\n\t\tself.F... | [
"0.65832454",
"0.63023007",
"0.62800795",
"0.6202261",
"0.6172763",
"0.6146519",
"0.6143242",
"0.6084042",
"0.60765284",
"0.6054672",
"0.6052164",
"0.6051793",
"0.6033074",
"0.60097814",
"0.59851605",
"0.59336513",
"0.5923808",
"0.59172606",
"0.5891708",
"0.58734405",
"0.5860... | 0.7421072 | 0 |
Saving model using torch.save and log into Weight & Biases | def save(self, obj,
path:str,
epoch:int=None,
scores:float or dict=None):
parent_path = os.path.normpath(os.path.join(path, os.path.pardir))
if not os.path.exists(parent_path):
os.makedirs(parent_path)
if epoch is not None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_model(self, name): \n torch.save(dict(params=self.model.encoder.state_dict()), osp.join(self.args.save_path, name + '.pth'))",
"def save_model(self):\n save_folder = os.path.join(self.log_path, \"models\", \"weights_{}\".format(self.epoch))\n if not os.path.exists(save_folder):\n ... | [
"0.7809711",
"0.7795389",
"0.77638984",
"0.7655282",
"0.7605489",
"0.7602631",
"0.7539826",
"0.7528425",
"0.7454979",
"0.74478394",
"0.74478394",
"0.74478394",
"0.74478394",
"0.74478394",
"0.7403449",
"0.7383622",
"0.7383622",
"0.73601675",
"0.73477906",
"0.73159313",
"0.7261... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(self, x):
e_x = np.exp(x)
return e_x / e_x.sum(axis=1, keepdims=True) # only difference | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.0 | -1 |
Returns the contents of ``tensor`` at the multidimensional integer array ``indexes``. Leading dimensions of ``tensor`` must match the dimensions of ``indexes``. | def select_at_indexes(indexes, tensor):
dim = len(indexes.shape)
assert indexes.shape == tensor.shape[:dim]
num = indexes.numel()
t_flat = tensor.view((num,) + tensor.shape[dim:])
s_flat = t_flat[torch.arange(num), indexes.view(-1)]
return s_flat.view(tensor.shape[:dim] + tensor.shape[dim + 1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _index(tensor_3d, tensor_2d):\n x, y, z = tensor_3d.size()\n t = tensor_3d.reshape(x * y, z)\n tt = tensor_2d.reshape(x * y)\n v = t[torch.arange(x * y), tt]\n v = v.reshape(x, y)\n return v",
"def get_data_by_indexes(indexes: list, data: np.ndarray) -> np.ndarray:\n return np.asarray([d... | [
"0.64149225",
"0.6126187",
"0.6071101",
"0.6060197",
"0.588927",
"0.5819812",
"0.5786708",
"0.57190686",
"0.57071954",
"0.57068115",
"0.55868393",
"0.55305433",
"0.54998374",
"0.54585403",
"0.54585403",
"0.54585403",
"0.54482704",
"0.54353964",
"0.54137176",
"0.53959394",
"0.... | 0.7669653 | 0 |
Converts integer values in multidimensional tensor ``indexes`` to onehot values of size ``num``; expanded in an additional trailing dimension. | def to_onehot(indexes, num, dtype=None):
if dtype is None:
dtype = indexes.dtype
onehot = torch.zeros(indexes.shape + (num,),
dtype=dtype, device=indexes.device)
onehot.scatter_(-1, indexes.unsqueeze(-1).type(torch.long), 1)
return onehot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexes_to_one_hot(indexes, n_dims=None):\n indexes = indexes.type(torch.int64).view(-1, 1)\n n_dims = n_dims if n_dims is not None else int(torch.max(indexes)) + 1\n one_hots = torch.zeros(indexes.size()[0], n_dims).scatter_(1, indexes, 1)\n one_hots = one_hots.view(*(indexes.shape-1))\n return... | [
"0.7503348",
"0.6753746",
"0.6663001",
"0.6660671",
"0.6437275",
"0.6323957",
"0.62498003",
"0.620212",
"0.60491776",
"0.60330254",
"0.60330254",
"0.60330254",
"0.60330254",
"0.60288876",
"0.59250796",
"0.59086674",
"0.58900535",
"0.5878305",
"0.5868206",
"0.5860303",
"0.5844... | 0.7845459 | 0 |
Argmax over trailing dimension of tensor ``onehot``. Optional return dtype specification. | def from_onehot(onehot, dim=-1, dtype=None):
indexes = torch.argmax(onehot, dim=dim)
if dtype is not None:
indexes = indexes.type(dtype)
return indexes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onehot_argmax(logits):\n return T.extra_ops.to_one_hot(T.argmax(logits,-1),logits.shape[-1])",
"def argmax(tensor):\n raise NotImplementedError",
"def max_arg_one_hot(arr: np.ndarray) -> np.ndarray:\n # using argmin because inverted indices in binary_to_one_hot\n return binary_to_one_hot(np... | [
"0.7159098",
"0.6866533",
"0.65986437",
"0.65517324",
"0.64722866",
"0.6426143",
"0.6316279",
"0.63162196",
"0.6247499",
"0.6243214",
"0.6121572",
"0.6085835",
"0.60520595",
"0.5940435",
"0.5937668",
"0.59348476",
"0.59251",
"0.5905805",
"0.59022623",
"0.5891443",
"0.58218545... | 0.69066066 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.