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 |
|---|---|---|---|---|---|---|
Replaces periods in strings with 3 or more periods with dashes as long as the leading 4 components between the dashes look like numbers an IP address. | def filter_ip_address(self, string):
count = string.count('.')
newstring = string
if count < 3:
# Not enough components to matter
return newstring
dot_split = string.split('.')
# Count the number of components that convert to an integer
int_count... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_dots(data):\n data = re.sub(':', ' : ', data)\n return data",
"def replace_dot(data):\n data = re.sub(\"[.]\", \" . \", data)\n return data",
"def handle_dots(string):\n if '.' in string:\n if string[-1] == '.':\n string = string[:-1]\n else:\n str... | [
"0.63875085",
"0.6364134",
"0.6260922",
"0.610741",
"0.6088775",
"0.6059924",
"0.6007397",
"0.5946681",
"0.59328276",
"0.5922121",
"0.5913037",
"0.58847386",
"0.5750502",
"0.5738902",
"0.57303065",
"0.55810773",
"0.55789346",
"0.55214417",
"0.5520872",
"0.55051035",
"0.549597... | 0.7367527 | 0 |
Convert datetime date to string | def to_str(date):
try:
return datetime.datetime.strftime(date,"%Y/%m/%d %H:%M")
except Exception as e:
print (date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def date_to_final_str(date_obj: datetime) -> str:\n return date_obj.strftime(\"%Y-%m-%d\")",
"def datetime_t... | [
"0.8060318",
"0.8060318",
"0.79113466",
"0.78988934",
"0.78527915",
"0.78250253",
"0.7750232",
"0.7698675",
"0.7698123",
"0.7606957",
"0.75023055",
"0.7455791",
"0.744852",
"0.7401903",
"0.7337236",
"0.7322363",
"0.72673017",
"0.7251834",
"0.72113276",
"0.7206824",
"0.7178846... | 0.77321136 | 7 |
Returns a representation of the object. | def __repr__(self):
return "\'{}\'".format(self.__str__()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __repr__(self):\n return repr(self.__dict__['_obj'])",
"def __repr__(self) -> str:\n return str(self.as_dict())",
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(self):\n ret... | [
"0.77530897",
"0.7726905",
"0.7713159",
"0.76251704",
"0.76251704",
"0.76251704",
"0.76251704",
"0.76251704",
"0.7594132",
"0.75403976",
"0.7513629",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
"0.75079787",
... | 0.0 | -1 |
Remove Duplicates from Sorted Array Given an integer array nums sorted in nondecreasing order, remove the duplicates inplace such that each unique element appears only once. The relative order of the elements should be kept the same. Template Use two pointers as slow runner and fast runner. Each of them flags a key poi... | def remove_duplicates(nums: List[int]) -> int:
if not nums:
return 0
slow = 0
for fast in range(1, len(nums)):
# compare element with a next one in order to find a duplicate in a non-decreasing array
# if current element is unique,
# slow runner ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeDuplicates(nums):\n i = 0\n j = 1\n for r in range(len(nums)):\n if j >= len(nums):\n print(i + 1, nums)\n return i + 1\n if nums[i] != nums[j]:\n i = i + 1\n nums[i] = nums[j]\n j = j + 1",
... | [
"0.7241946",
"0.71542543",
"0.7111343",
"0.69293445",
"0.6653721",
"0.66279733",
"0.6554121",
"0.63949096",
"0.63597584",
"0.6309953",
"0.6261221",
"0.62611413",
"0.62338734",
"0.6165492",
"0.6122644",
"0.61188316",
"0.6011663",
"0.59921974",
"0.5910376",
"0.58862835",
"0.581... | 0.804234 | 0 |
Given an array, rotate the array to the right by k steps, where k is nonnegative. Do not return anything, modify nums inplace instead. | def rotate(nums: List[int], k: int) -> None:
if not nums:
return []
if len(nums) == 1:
return nums
if k == 0:
return nums
while k > len(nums):
k = k - len(nums)
head = nums[-k:]
tail = nums[:-k]
nums[:-k] = head
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(self, nums, k):\n n = len(nums)\n k = k % n\n nums.reverse()\n self.reverse(nums, 0, k-1)\n self.reverse(nums, k, n-1)\n return nums",
"def rotate(self, nums: List[int], k: int) -> None: \n if k > len(nums):\n k = k % len(nums) \n ... | [
"0.8039892",
"0.7924553",
"0.7879363",
"0.78608406",
"0.7834987",
"0.783488",
"0.78181744",
"0.78050715",
"0.7794533",
"0.7786658",
"0.77861804",
"0.77858526",
"0.77518845",
"0.7739036",
"0.7724267",
"0.7721172",
"0.7718322",
"0.7688961",
"0.7684774",
"0.7680727",
"0.7679206"... | 0.7364185 | 47 |
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. | def contains_duplicate(self, nums: List[int]) -> bool:
if not nums:
return
nums.sort()
if len(nums) == 1:
return False
for i in range(1, len(nums)):
if nums[i - 1] == nums[i]:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def containsDuplicateSet(self, nums):\n distinct_nums = set()\n for number in nums:\n if number in distinct_nums:\n return True\n distinct_nums.add(number)\n return False",
"def containsDuplciateOptimized(self, nums):\n nums = sorted(nums)\n ... | [
"0.7904651",
"0.75048727",
"0.74690074",
"0.74619067",
"0.74397707",
"0.6928344",
"0.68338954",
"0.68146574",
"0.6761789",
"0.66982555",
"0.6673401",
"0.656232",
"0.6522875",
"0.634206",
"0.6299513",
"0.6274968",
"0.62723076",
"0.6241891",
"0.6223191",
"0.622109",
"0.6176163"... | 0.7343182 | 5 |
Given a nonempty array of integers nums, every element appears twice except for one. Find that single one. | def single_number(self, nums: List[int]) -> int:
if not nums:
return False
if len(nums) == 1:
return nums[0]
visited = set()
for i in nums:
if i not in visited:
visited.add(i)
else:
visited.remove(i)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singleNonDuplicate(self, nums):\n \n #Every element appears exactly twice, except for one\n #O(log n) time\n #O(1) space\n #0 1 2 3 4\n #1 3 3 5 5 \n \n \n #0 1 2 3 4 5 6 \n #1 3 3 5 5 7 7\n \n \n #O log(n) solution ... | [
"0.82943034",
"0.8010177",
"0.75305516",
"0.7293964",
"0.7226113",
"0.7161746",
"0.7042642",
"0.70283836",
"0.6988253",
"0.68567514",
"0.6816714",
"0.6807289",
"0.679402",
"0.6635931",
"0.65919363",
"0.6576328",
"0.65356535",
"0.6486501",
"0.64720595",
"0.6459612",
"0.6438533... | 0.70969296 | 6 |
Move all the 0's to the end of array. All the nonzero elements must retain their original order. Both the requirements are mutually exclusive, i.e., you can solve the individual subproblems and then combine them for the final solution. | def move_zeroes(nums: List[int]) -> None:
if not nums:
return False
if len(nums) == 1:
return nums[0]
left = 0
right = 0
while right < len(nums):
if nums[right] == 0:
right += 1
else:
nums[left], nu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moveZeroes(self, arr: List[int]) -> None: \n n = len(arr)\n p = 0 # 1 + index of last non-zero \n\n for i in range(n):\n if arr[i] != 0:\n arr[p], arr[i] = arr[i], arr[p]\n p += 1",
"def moveZeroes(self, arr: List[int]) -> None:\n ... | [
"0.78979033",
"0.7817946",
"0.7686987",
"0.7433844",
"0.7423874",
"0.74073523",
"0.731577",
"0.72963625",
"0.7277429",
"0.7272681",
"0.7216337",
"0.7191074",
"0.7190564",
"0.71798235",
"0.71504074",
"0.71458954",
"0.7137183",
"0.71324986",
"0.70946014",
"0.7079781",
"0.707671... | 0.6665174 | 58 |
Returns the sibling node (left child of parent if self is right child, right child of parent if self is left). Returns None only if self is root of tree | def get_sibling(self):
if (not self) or (self.parent is None):
return None
else:
if self is self.parent.left:
return self.parent.right
else:
return self.parent.left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sibling(self, p):\n parent = self.parent(p)\n if parent is None: # p must be the root\n return None # root has no sibling\n else:\n if p == self.left(parent):\n return self.right(parent) # possibly None\n else:\n return se... | [
"0.8419404",
"0.83174646",
"0.81958777",
"0.81597024",
"0.81597024",
"0.8137325",
"0.7997988",
"0.769926",
"0.740854",
"0.7248096",
"0.6782336",
"0.6686932",
"0.6502433",
"0.64476603",
"0.64324677",
"0.63804215",
"0.6275101",
"0.62561476",
"0.6247123",
"0.62424713",
"0.621764... | 0.8633754 | 0 |
Rotate the subtree with root og_root to the left so that right subtree of og_root replaces og_root | def _rotate_left(self, og_root):
new_root = og_root.right
og_root.right = new_root.left
if new_root.left:
new_root.left.parent = og_root
new_root.parent = og_root.parent
if og_root is self.root: # if our original root of the rotation is the tree root, replace t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_right(self, og_root):\r\n new_root = og_root.left\r\n og_root.left = new_root.right\r\n if new_root.right:\r\n new_root.right.parent = og_root\r\n new_root.parent = og_root.parent\r\n if og_root.value == self.root.value: # og_root is tree root\r\n ... | [
"0.8312841",
"0.75870675",
"0.7470943",
"0.7381008",
"0.71160847",
"0.7096916",
"0.70756596",
"0.6935957",
"0.6901457",
"0.6879151",
"0.6784041",
"0.66718173",
"0.6651459",
"0.66211325",
"0.65959084",
"0.65879023",
"0.65866673",
"0.6556684",
"0.6509696",
"0.6486408",
"0.64847... | 0.85385555 | 0 |
Rotate the subtree with root og_root to the right so that left subtree of og_root replaces og_root | def _rotate_right(self, og_root):
new_root = og_root.left
og_root.left = new_root.right
if new_root.right:
new_root.right.parent = og_root
new_root.parent = og_root.parent
if og_root.value == self.root.value: # og_root is tree root
self.root = new_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_left(self, og_root):\r\n new_root = og_root.right\r\n og_root.right = new_root.left\r\n if new_root.left:\r\n new_root.left.parent = og_root\r\n new_root.parent = og_root.parent\r\n if og_root is self.root: # if our original root of the rotation is the tre... | [
"0.8179777",
"0.7446383",
"0.74284",
"0.74184376",
"0.72502136",
"0.71544296",
"0.7125958",
"0.68610346",
"0.6859764",
"0.6743175",
"0.6742859",
"0.67380977",
"0.6656167",
"0.66395295",
"0.66172427",
"0.66020566",
"0.6571421",
"0.65558964",
"0.65217704",
"0.6481041",
"0.64529... | 0.85993487 | 0 |
Returns data derived from the basic blockchain DataFrame | def compute_derived_blockchain_data(df):
original_join_state = SETTINGS.join
SETTINGS.join = False
result = pd.concat([trade_vol_VS_tx_vol(df),
miners_revenue_VS_tx_volume(df),
block_reward_USD(df),
tx_fees_VS_miners_revenue(df),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(self)->pd.DataFrame:\n pass",
"def fetch_data(self) -> pd.DataFrame:\r\n os.chdir(r'\\\\192.168.8.90\\投研部\\Jessica\\test_data')\r\n if self.tic in ['RB.CCRI', 'HC.CCRI', 'I.CCRI', 'J.CCRI', 'JM.CCRI', 'ZC.CCRI']:\r\n f = pd.read_hdf('data.h5', 'snc')\r\n if sel... | [
"0.67881644",
"0.62799525",
"0.6242277",
"0.616254",
"0.6149799",
"0.61404604",
"0.6117782",
"0.6116031",
"0.60899264",
"0.60821575",
"0.6071679",
"0.60555667",
"0.6052496",
"0.600108",
"0.5985591",
"0.59716797",
"0.59537053",
"0.59427994",
"0.5934149",
"0.59320253",
"0.59038... | 0.6909557 | 0 |
Plots a scatterplot with real values in the x axis, predictions in the y axis and a red horizontal and vertical lines separating the zones in 4 quadrants | def scatter(target, predictions, threshold=0, ideal_prediction_line=True):
plt.plot(target, predictions, linewidth=0, marker='o', zorder=1);
if threshold is not None:
xlim = plt.xlim()
ylim = plt.ylim()
plt.hlines(threshold, xlim[0], xlim[1], linestyles='dotted', color='red')
pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_scatter(self):\n if Trainer.y_pred is None or Trainer.y_true is None:\n messagebox.showerror(\"Information\", \"Please train the model first before plotting\")\n return\n\n fig = plt.figure(figsize=(8, 4))\n plt.xlabel(\"Prediction\")\n plt.ylabel(\"Target... | [
"0.68587255",
"0.66916996",
"0.66838413",
"0.6602369",
"0.6565054",
"0.64943194",
"0.64906085",
"0.64604956",
"0.64604956",
"0.6384037",
"0.63759816",
"0.6339998",
"0.6262751",
"0.6249279",
"0.6241288",
"0.62313336",
"0.62307835",
"0.62071365",
"0.6205134",
"0.61783296",
"0.6... | 0.6256542 | 13 |
Standarizes train and test features by removing the mean and scaling to unit variance Calendar data should be calculated after this process. If not, when we standarize data that has a timespan minor than a full year, some columns will have only zeros and that produces nans in that col when dividing by std=0 | def standarize(train_data, test_data, dropna=True):
mean = train_data.mean(axis=0)
train_data -= mean
std = train_data.std(axis=0)
train_data /= std
test_data -= mean
test_data /= std
if dropna:
train_data = train_data.dropna()
test_data = test_data.dropna()
return train... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardize(train_data_jets, test_data_jets):\n \n nbr_jets = train_data_jets.shape[0]\n \n for jet in range(nbr_jets):\n # extract features for standardization\n train_data_features = train_data_jets[jet][:,2:] \n test_data_features = test_data_jets[jet][:,2:] \n # stor... | [
"0.71275145",
"0.6948807",
"0.65836394",
"0.65139884",
"0.64715713",
"0.6403804",
"0.6340759",
"0.6327488",
"0.62782335",
"0.6251162",
"0.6219763",
"0.62193185",
"0.62051016",
"0.619239",
"0.6185001",
"0.61542916",
"0.614145",
"0.6134322",
"0.6114143",
"0.609232",
"0.6087027"... | 0.7344126 | 0 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1, 5)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
# one-hot case
if target.ndimension() > 1:
target = target.max(1)[1]
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Initialize Slash Command object. Must be called in SlashCommand.create() | def __init__(
self,
# Required Parameters
application_id: int,
name: str,
description: str = '',
# Optional Parameters
command_id: Optional[int] = None, # Can be set later : code-based creation
options: Optional[List[Union... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(self):\n return Command.initialize(self)",
"def __init__(self, cmd):\n # Build command + options \n self.cmd = cmd \n setattr(self, 'command', \"%s\" % (cmd))",
"def wrapper(callback):\n self.commands[name] = SlashCommand(callback, name, description, option... | [
"0.7083515",
"0.679926",
"0.67539054",
"0.6698255",
"0.6640125",
"0.6559244",
"0.6537631",
"0.6522668",
"0.64335483",
"0.6419807",
"0.6415119",
"0.6410869",
"0.6382036",
"0.62938076",
"0.62771904",
"0.62484235",
"0.621903",
"0.6161678",
"0.6154704",
"0.61311066",
"0.6129969",... | 0.60857457 | 22 |
Patch interaction (response from discord api call) to SlashCommand. | def _patch(self, interaction: JSON) -> NoReturn:
self._id = interaction['id']
self._data.patch_dpy(interaction) # Update data. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_patch(self, api, command):\n return self._make_request_from_command('PATCH', command)",
"def patch(self, *args, **kwargs):\n return self.handle_patch_request()",
"def _patch(self, path=None, version=None, params=None,\n data=None, json=None, header=None):\n return ... | [
"0.67583317",
"0.56459194",
"0.5578068",
"0.5490595",
"0.54414564",
"0.54056513",
"0.525488",
"0.52006984",
"0.519727",
"0.51751995",
"0.51456666",
"0.51253086",
"0.51237875",
"0.5119075",
"0.5116107",
"0.5107349",
"0.50819653",
"0.5074591",
"0.50660837",
"0.50494766",
"0.504... | 0.6213335 | 1 |
Name of the team. | def name(self) -> str:
return self.data['name'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_name(self):\n return 'Team Name'",
"def teamname(record):\n\n tname = \"\"\n if record and record.name:\n tname = \"%s \" % record.name.strip()\n return tname",
"def get_name(self):\n # <<-- Creer-Merge: get-name -->> - Code you add between this comment an... | [
"0.93073976",
"0.7660612",
"0.75933665",
"0.7109071",
"0.70854",
"0.70756435",
"0.7048052",
"0.7048052",
"0.7048052",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
"0.703738",
... | 0.0 | -1 |
Retrieves the id of the team. | def id(self) -> int:
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_id(self):\n return self._team_id",
"def get_team_id(team_name):\n\n team_name = team_name.lower()\n endpoint = \"/teams\"\n response = api.nhl_api(endpoint)\n\n if not response:\n raise ConnectionError(\"An invalid response was returned from the NHL Teams API.\")\n\n teams_j... | [
"0.83466834",
"0.79193324",
"0.7843409",
"0.783742",
"0.7437544",
"0.6948306",
"0.69137067",
"0.688815",
"0.6887566",
"0.6784414",
"0.6759271",
"0.6712722",
"0.66642225",
"0.66009885",
"0.643723",
"0.643723",
"0.643723",
"0.643723",
"0.643723",
"0.643723",
"0.643723",
"0.64... | 0.0 | -1 |
Returns the description of this team. | def description(self) -> str:
return self.data['description'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description(self) -> str:\n return pulumi.get(self, \"description\")",
"def description(self) -> str:\n return pulumi.get(self, \"description\")",
"def description(self) -> str:\n return pulumi.get(self, \"description\")",
"def description(self) -> str:\n return pulumi.get(sel... | [
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"0.7873573",
"... | 0.7596957 | 36 |
Checks if given username is member of this team. | def is_member(self, username):
usernames = [user.username for user in self.members]
return True if username in usernames else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_user(self, username):\n\t\treturn username in self.users",
"def has_user(self, username):\n return username in self.user_table",
"def is_member(self, id, user):\n request = self.request_builder('orgs.teams.is_member',\n id=id, user=user)\n retu... | [
"0.7683422",
"0.72694814",
"0.7006653",
"0.69890326",
"0.69736445",
"0.69623685",
"0.69288564",
"0.68338823",
"0.6801138",
"0.676671",
"0.67643404",
"0.6637709",
"0.6634723",
"0.66093934",
"0.6607121",
"0.65958714",
"0.6553017",
"0.64932686",
"0.6481825",
"0.6472868",
"0.6424... | 0.82886475 | 0 |
Convert float value with 2 decimal points to convenient notation in cents, with no CPU calculation error. | def _float2int(x: float) -> int:
return round(x * 100) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_currency(cents: int) -> str:\n return f\"${cents / 100:.2f}\"",
"def to_btc(value):\n value = float(value) / 100000000\n value = format(value, \".9f\")\n return value",
"def convert_currency(val):\n new_val = val.replace(',','').replace('$', '')\n return float(new_val)",
"def two_dec... | [
"0.67535645",
"0.65676445",
"0.6526521",
"0.6326507",
"0.6324261",
"0.6322565",
"0.6311756",
"0.62608147",
"0.6258478",
"0.62052387",
"0.61886716",
"0.6181782",
"0.6147108",
"0.6146781",
"0.61276376",
"0.61226666",
"0.60358703",
"0.60196894",
"0.60118896",
"0.6009876",
"0.600... | 0.0 | -1 |
return the best action under the given state | def getBestAction(self, state):
best_action = 0
max_Q = -9999
for action in self.getLegalActions(state):
Q = self.getQValue(state, action)
if Q > max_Q:
best_action = action
max_Q = Q
return best_action | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _best_action(self, state):\n actions_rewards = list(self.Q[state].items())\n return max(actions_rewards, key=lambda x: x[1])[0]",
"def best_action(self, state):\n return random.choice(self.possible_actions)",
"def get_best_action(self, state):\n possible_actions = self.get_legal... | [
"0.8675456",
"0.85595685",
"0.8558812",
"0.8328124",
"0.8321985",
"0.8202494",
"0.8191028",
"0.8160193",
"0.8090762",
"0.80100876",
"0.78961176",
"0.7891263",
"0.7889298",
"0.7866562",
"0.78625715",
"0.78556114",
"0.78362435",
"0.7834988",
"0.7834988",
"0.7833415",
"0.7824164... | 0.8515501 | 3 |
return the legal actions in a list | def getLegalActions(self, state):
actions = [i for i in range(-5, 6)]
for action in actions:
if action > state[0] or action < -state[1]:
actions.remove(action)
return actions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_legal_actions(self):\n pass",
"def legal_actions(self):\n return self.env.legal_actions()",
"def _get_legal_actions(self):\n return self.game.get_legal_actions()",
"def _get_legal_actions(self):\n raise NotImplementedError",
"def legal_actions(self):\n\n if self.p... | [
"0.79865885",
"0.7828782",
"0.78167766",
"0.78039813",
"0.75765353",
"0.75328493",
"0.750651",
"0.75038755",
"0.74802357",
"0.74355984",
"0.7368722",
"0.7315193",
"0.728173",
"0.72049516",
"0.7188177",
"0.717713",
"0.70360416",
"0.7034684",
"0.7006532",
"0.6984803",
"0.698434... | 0.70602053 | 16 |
return the water required to keep this trunk and its children alive | def water_needed(self):
water = self.water_needed_by_trunk()
water += sum(map(lambda e: e.water_needed(), self.children))
return water | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cargo_water(self):\n return self._cargo_water",
"def eat(self, available_water, seconds):\n\n if available_water <= 0:\n\n return 0\n\n water_needed = 0\n\n if self.energy < 1.0:\n\n #a trunk can eat Trunk.MAX_FOOD_INTAKE_ONE_SECOND per second at most\n ... | [
"0.6473496",
"0.6079244",
"0.5927126",
"0.5713389",
"0.5682852",
"0.56561494",
"0.56467444",
"0.56467444",
"0.55330366",
"0.54771626",
"0.5385118",
"0.53786075",
"0.5358966",
"0.534224",
"0.53165305",
"0.5262672",
"0.5253935",
"0.524385",
"0.52223206",
"0.52211064",
"0.521568... | 0.7421926 | 0 |
a trunk can eat water_needed_by_trunk() units of water per second; if its energy is already full the plant does not eat any food returns the amount of food eaten by this trunk and its children | def eat(self, available_water, seconds):
if available_water <= 0:
return 0
water_needed = 0
if self.energy < 1.0:
#a trunk can eat Trunk.MAX_FOOD_INTAKE_ONE_SECOND per second at most
usable_water = Trunk.MAX_FOOD_INTAKE_ONE_SECOND * seconds
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def water_needed(self):\n water = self.water_needed_by_trunk()\n\n water += sum(map(lambda e: e.water_needed(), self.children))\n\n return water",
"def energy_needed(self, seconds):\n energy = Trunk.ENERGY_NEEDED_TO_LIVE_ONE_SECOND * seconds\n\n if self.current_length < self.ma... | [
"0.7078841",
"0.6088168",
"0.57321054",
"0.5730118",
"0.5623443",
"0.5612998",
"0.5554157",
"0.5539106",
"0.5533572",
"0.55184585",
"0.5504299",
"0.54693604",
"0.54564077",
"0.5448783",
"0.5438823",
"0.54317206",
"0.54107034",
"0.54056156",
"0.5405184",
"0.53913087",
"0.53908... | 0.76951647 | 0 |
This class will help make quick buttons for use with pygame. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def __init__(self, type_of_button, file_or_text, position, midpoint = False, surface = None, **kargs):
# Initialize pygame font and sprite class
pygame.sprite.Sprite.__init__(self)
pygame.font.init()
# Unpack the **kargs dictionary into the possible inputs (resize,
# fontsize a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def button(msg, font_size, x, y, w, h, color, action):\r\n mouse = pygame.mouse.get_pos() # Grabbing cursor position\r\n click = pygame.mouse.get_pressed() # Mouse button status\r\n \r\n # Check if cursor is on the button\r\n if x + w > mouse[0] > x and y + h > mouse[1] > y:\r\n ... | [
"0.7145189",
"0.7065786",
"0.70314455",
"0.7028198",
"0.6979546",
"0.6947997",
"0.6863535",
"0.68572813",
"0.68508434",
"0.68401754",
"0.6808504",
"0.6775183",
"0.6704682",
"0.66736704",
"0.66577274",
"0.6607368",
"0.6607031",
"0.6585147",
"0.65716285",
"0.65532285",
"0.65359... | 0.68172944 | 10 |
Deletes the Update Request with the given ID Deletes the Update Request with the given ID. After a request is created via a POST to /nifiapi/parametercontexts/updaterequests, it is expected that the client will properly clean up the request by DELETE'ing it, once the Update process has completed. If the request is dele... | def delete_update_request(self, context_id, request_id, **kwargs):
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.delete_update_request_with_http_info(context_id, request_id, **kwargs)
else:
(data) = self.delete_update_request_with_http_inf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_update_request_with_http_info(self, context_id, request_id, **kwargs):\n\n all_params = ['context_id', 'request_id', 'disconnected_node_acknowledged']\n all_params.append('callback')\n all_params.append('_return_http_data_only')\n all_params.append('_preload_content')\n ... | [
"0.6885061",
"0.5545423",
"0.5508578",
"0.53958887",
"0.53924894",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
"0.5259999",
... | 0.707182 | 0 |
Deletes the Update Request with the given ID Deletes the Update Request with the given ID. After a request is created via a POST to /nifiapi/parametercontexts/updaterequests, it is expected that the client will properly clean up the request by DELETE'ing it, once the Update process has completed. If the request is dele... | def delete_update_request_with_http_info(self, context_id, request_id, **kwargs):
all_params = ['context_id', 'request_id', 'disconnected_node_acknowledged']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_param... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_update_request(self, context_id, request_id, **kwargs):\n kwargs['_return_http_data_only'] = True\n if kwargs.get('callback'):\n return self.delete_update_request_with_http_info(context_id, request_id, **kwargs)\n else:\n (data) = self.delete_update_request_wit... | [
"0.7068541",
"0.55439806",
"0.5509152",
"0.5398281",
"0.5394413",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
"0.5259594",
... | 0.68843573 | 1 |
String representation of the class instance. | def __str__(self):
return 'Token({type}, {value})'.format(
type=self.type,
value=repr(self.value)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n class_dictionary = vars(self)\n out = self.__class__.__name__\n for k,v in class_dictionary.items():\n if v > 0:\n out += ' : ' + str(k) + ' = ' + str(v)\n return out",
"def __repr__(self):\n outl = 'class :'+self.__class__.__name_... | [
"0.81528825",
"0.810694",
"0.80485237",
"0.7923295",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921295",
"0.7910681",
"0.79043895",
"0.79043895",
"0.79043895",
"0.78848475",
"0.78608793",
"0.7854687",
"0.78356767",
"0.7828303",
"0.7778142",
"0.777691... | 0.0 | -1 |
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.Blues):
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.8195189",
"0.8096179",
"0.80311364",
"0.80207354",
"0.79955184",
"0.799279",
"0.7982649",
"0.7977064",
"0.7962826",
"0.7958447",
"0.7939309",
"0.79364014",
"0.7936101",
"0.7932949",
"0.7927847",
"0.792615",
"0.7925553",
"0.79244494",
"0.7924244",
"0.79234385",
"0.79194653"... | 0.784538 | 51 |
Gets the min_time of this MinMaxTime. | def min_time(self) -> str:
return self._min_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_time(self):\n return self._ll_tree_sequence.get_min_time()",
"def min(self):\n\n return time_stat(self, stat=\"min\")",
"def get_min_tim(self):\n return self.get_shortest_mode().tim",
"def initialtime_min(self):\n return self._get_time_info([\"Initial_Time_M\", \"initialTimeMi... | [
"0.76898676",
"0.7553372",
"0.7425068",
"0.7188609",
"0.71787214",
"0.71787214",
"0.716263",
"0.7018072",
"0.6976983",
"0.6974105",
"0.6902702",
"0.6895809",
"0.686499",
"0.68540794",
"0.68540794",
"0.6770346",
"0.6729454",
"0.67254734",
"0.6702896",
"0.6680941",
"0.66434777"... | 0.7773085 | 0 |
Gets the max_time of this MinMaxTime. | def max_time(self) -> str:
return self._max_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self):\n return self._max_time",
"def max_time(self):\n return self._ll_tree_sequence.get_max_time()",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def max_time(self):\n #{{{ function to return time of last sample\n\n if self.maxtime == -1:\n ... | [
"0.8018337",
"0.7294417",
"0.7201416",
"0.68990785",
"0.6893825",
"0.67320746",
"0.666565",
"0.65903956",
"0.64807147",
"0.6451287",
"0.6427186",
"0.635573",
"0.63448894",
"0.633819",
"0.6329412",
"0.62928826",
"0.62928826",
"0.62874156",
"0.62802833",
"0.6259219",
"0.6240102... | 0.7592021 | 1 |
Returns the reward of the Field the Agent is currently standing on. | def get_reward(self) -> float:
field = self.fields[self.agent_x][self.agent_y]
if field == Field.EMPTY:
return self.rew_empty
elif field == Field.POS_TERMINAL:
return self.rew_pos
elif field == Field.NEG_TERMINAL:
return self.rew_neg
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reward(self):\n return self._reward",
"def reward(self) -> float:\n\n if not self._reward_provided:\n self._reward_provided = True\n return self._reward\n\n return 0",
"def reward(self) -> Reward:\n return self.__reward",
"def _get_reward(self):\n if self.... | [
"0.8136167",
"0.79707164",
"0.78876454",
"0.78794473",
"0.7757538",
"0.77485365",
"0.7710405",
"0.7677108",
"0.7554422",
"0.75010574",
"0.7427453",
"0.7424858",
"0.7401111",
"0.7399987",
"0.7363481",
"0.733592",
"0.7286132",
"0.7262007",
"0.72553086",
"0.7237115",
"0.7171856"... | 0.80022824 | 1 |
Make a sane guess for whether a value represents true or false. Intended for strings, mostly in the context of environment variables, but if you pass it something that's not a string that is falsy, like an empty list, it will cheerfully return False. | def str_bool(s):
if not s:
return False
if type(s) != str:
# It's not a string and it's not falsy, soooo....
return True
s = s.lower()
if s in ["false", "0", "no", "n"]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bool_(val):\n if isinstance(val, six.string_types) and val.lower() == 'false':\n return False\n return bool(val)",
"def boolean(value):\n if isinstance(value, str):\n if value.lower() in [\"0\", \"no\", \"n\", \"false\", \"f\", \"off\"]:\n return False\n elif value.lo... | [
"0.8127616",
"0.7938532",
"0.7791793",
"0.77752143",
"0.77390826",
"0.7656398",
"0.7606657",
"0.7606657",
"0.76040477",
"0.76035583",
"0.7564559",
"0.7556861",
"0.7536293",
"0.7533807",
"0.7529131",
"0.7518459",
"0.749517",
"0.74747086",
"0.747453",
"0.7468262",
"0.7462596",
... | 0.73769677 | 27 |
Used for taking character (usually comma)separated string lists and returning an actual list, or the empty list. Useful for environment parsing. Sure, you could pass it integer zero and get [] back. Don't. | def listify(item, delimiter=","):
if not item:
return []
if type(item) is str:
item = item.split(delimiter)
if type(item) is not list:
raise TypeError("'listify' must take None, str, or list!")
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_as_list(arg):\n if arg is None:\n return []\n elif isinstance(arg, str):\n return [arg]\n else:\n return arg",
"def process_list_arg(arg):\n if isinstance(arg, list):\n return arg\n elif isinstance(arg, basestring):\n args = []\n... | [
"0.6990241",
"0.6901065",
"0.6785267",
"0.6517368",
"0.6447577",
"0.6427502",
"0.6422685",
"0.63777125",
"0.6370333",
"0.62720543",
"0.6240634",
"0.62268925",
"0.62225294",
"0.62196887",
"0.62142175",
"0.62134427",
"0.6196978",
"0.61959445",
"0.6195478",
"0.61931235",
"0.6181... | 0.6347089 | 9 |
Camera modified event callback. Copies the parameters of the renderer camera into the camera of the overlay so they stay synced at all times. | def _syncCameras(self, camera, ev):
self.rendererOverlay.GetActiveCamera().ShallowCopy(camera) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_camera(self, render=False):\n self._renderer.set_camera(\n # needs fix, distance moves when focal point updates\n distance=self._renderer.plotter.camera.distance * 0.9,\n focalpoint=tuple(self._ras),\n reset_camera=False)",
"def newCameraCallback(cam... | [
"0.6701847",
"0.6607499",
"0.6299443",
"0.62217945",
"0.5975981",
"0.5767857",
"0.5767857",
"0.56019837",
"0.5599338",
"0.5573424",
"0.5512632",
"0.5494639",
"0.54508895",
"0.54394376",
"0.53984785",
"0.5369832",
"0.53563553",
"0.5353637",
"0.5353453",
"0.53264856",
"0.527592... | 0.64325815 | 2 |
Get updates milestone object by milestone name. | def get_updates_milestone_for(self, milestone_name, project_name):
updates_milestone_name = milestone_name + '-updates'
project = self.get_lp_client().projects[project_name]
milestone = project.getMilestone(name=updates_milestone_name)
if not milestone:
self.logging.error(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_milestone(self, req):\n\n milestone_id = req.args['id']\n try:\n milestone = Milestone(self.env, milestone_id)\n except ResourceNotFound:\n milestone = None\n\n return milestone",
"def milestone(self, milestone_id):\r\n return milestones.Milestone... | [
"0.6762724",
"0.6599832",
"0.6339248",
"0.61973125",
"0.6056077",
"0.5964101",
"0.58747196",
"0.5804352",
"0.57563096",
"0.57071567",
"0.5670678",
"0.5595964",
"0.55112755",
"0.54563946",
"0.543796",
"0.53301877",
"0.52887803",
"0.5281733",
"0.52786416",
"0.5194582",
"0.51752... | 0.83628935 | 0 |
Returns True if every possible node is dead and thus the language described must have been fully explored. | def is_exhausted(self):
return self.root.is_exhausted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_all_visited(self):\n cond = [node.visited if node and node.belongs and node.valid else True for node in self.nodes.flatten()]\n return all(cond)",
"def is_expanded(self) -> bool:\n return len(self._untried_edges) == 0",
"def validate(self, solution: list) -> (bool, float):\n start = ... | [
"0.6540636",
"0.63844794",
"0.63435",
"0.62395066",
"0.61263067",
"0.5950962",
"0.59468424",
"0.59468424",
"0.59289646",
"0.5886938",
"0.5883987",
"0.58696204",
"0.585728",
"0.5849022",
"0.582246",
"0.5807122",
"0.57667685",
"0.5761561",
"0.57547295",
"0.5751525",
"0.5748555"... | 0.5465969 | 53 |
Generate a short random string that (after rewriting) is not a prefix of any buffer previously added to the tree. The resulting prefix is essentially arbitrary it would be nice for it to be uniform at random, but previous attempts to do that have proven too expensive. | def generate_novel_prefix(self, random):
assert not self.is_exhausted
novel_prefix = bytearray()
def append_int(n_bits, value):
novel_prefix.extend(int_to_bytes(value, bits_to_bytes(n_bits)))
current_node = self.root
while True:
assert not current_node.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_novel_prefix(self):\n return self.tree.generate_novel_prefix(self.random)",
"def uniqid(prefix = None, more_entropy = False):\n out = ''\n num = (23 if more_entropy else 13)\n if prefix != None:\n random.seed(prefix)\n for i in range(0, num):\n out += random.choice(\\\n ... | [
"0.72163147",
"0.69266003",
"0.6887314",
"0.6780469",
"0.674671",
"0.67011696",
"0.6699596",
"0.6655057",
"0.655681",
"0.6520119",
"0.6501565",
"0.6457501",
"0.64455724",
"0.6444582",
"0.6411006",
"0.63653207",
"0.63562566",
"0.6348863",
"0.6343493",
"0.63121897",
"0.62833875... | 0.6942301 | 1 |
Create a dataset for training a HotspotPredictor. | def hotspot_dataset(data_dir, num_timestamps=5):
def generator_fn():
"""
Generate hotspot data points.
"""
for thumbs, counts in data_dir.hotspot_data(num_timestamps=num_timestamps):
for thumb, count in zip(thumbs, counts):
yield thumb, count
dataset =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_forecast_dataset(self):\n pass",
"def create_dataset():\n ds_train_raw, ds_test_raw = load_raw_datasets()\n vectorize_layer = create_vectorizer(ds_train_raw)\n ds_train = ds_train_raw.map(\n lambda text, label: (vectorize_layer(text), label)\n ).prefetch(tf.data.experimental.... | [
"0.6939402",
"0.692519",
"0.6786978",
"0.66502875",
"0.6607561",
"0.6594242",
"0.6566705",
"0.65532476",
"0.65393883",
"0.65263176",
"0.65143764",
"0.6509632",
"0.6509302",
"0.6494027",
"0.64723533",
"0.64480984",
"0.6442804",
"0.6424168",
"0.641678",
"0.63667053",
"0.6355052... | 0.6606435 | 5 |
Create a dataset for training a PopularityPredictor. | def popularity_dataset(data_dir):
def generator_fn():
"""
Generate tagger data points.
"""
for video_id, timestamp, metadata in data_dir.shuffled_thumbnails():
total_votes = metadata['votes_up'] + metadata['votes_down']
if total_votes == 0:
lik... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(base_path, batch_size, is_train):\n columns_list = [\"feature\", \"label\"]\n num_consumer = 4\n\n if is_train:\n path = os.path.join(base_path, 'aclImdb_train.mindrecord0')\n else:\n path = os.path.join(base_path, 'aclImdb_test.mindrecord0')\n\n data_set = ds.MindDa... | [
"0.6870661",
"0.6789739",
"0.6782478",
"0.6680735",
"0.65786254",
"0.6533469",
"0.6514081",
"0.65076685",
"0.64667386",
"0.6411124",
"0.64064044",
"0.6380432",
"0.6367895",
"0.6360568",
"0.6354586",
"0.63263965",
"0.63175255",
"0.63153154",
"0.6297235",
"0.628478",
"0.6249293... | 0.66336125 | 4 |
Create a dataset for training a CategoryTagger. | def category_dataset(data_dir, labels):
def generator_fn():
"""
Generate category data points.
"""
for video_id, timestamp, metadata in data_dir.shuffled_thumbnails():
yield (video_id, timestamp), [l in metadata['categories'] for l in labels]
dataset = tf.data.Dataset... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(opt):\n\tdata_loader = CustomDatasetDataLoader(opt)\n\tdataset = data_loader.load_data()\n\treturn dataset",
"def dataset(request):\n X, y = make_classification(\n n_samples=700, n_features=10, n_informative=8, n_redundant=2,\n n_classes=2, n_clusters_per_class=2, random_state... | [
"0.6686469",
"0.66252875",
"0.6566861",
"0.65663487",
"0.64527243",
"0.64157265",
"0.638086",
"0.6369624",
"0.6362777",
"0.6338802",
"0.6329528",
"0.6323302",
"0.63225543",
"0.6312522",
"0.62976384",
"0.6295028",
"0.6294824",
"0.6281759",
"0.624647",
"0.62344795",
"0.6229982"... | 0.6599429 | 2 |
Return a list of classes that this event clears. if we have specified clearClasses always return them if we ave a 0 severity return ourself as well. | def clearClasses(self):
clearcls = self._clearClasses
evclass = getattr(self, "eventClass", None)
sev = getattr(self, 'severity', None)
if evclass and sev == 0:
clearcls.append(self.eventClass)
# collapse out duplicates
clearcls = list(set(clearcls))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classes(self):\n if self.classname:\n return [self.classname]\n return []",
"def getClasses(self):\n self._process()\n return self._sets",
"def classes(self):\r\n return self._classes",
"def get_classes(self):\n return self._classes",
"def return_cla... | [
"0.6119085",
"0.599748",
"0.5900857",
"0.5846479",
"0.5772792",
"0.5750061",
"0.57468855",
"0.5737551",
"0.5562209",
"0.5492706",
"0.5492706",
"0.5480077",
"0.5423068",
"0.54123044",
"0.53430897",
"0.5323492",
"0.5320482",
"0.5319803",
"0.5250079",
"0.5241286",
"0.5228308",
... | 0.8316633 | 0 |
Learning rate schedule Learning rate is scheduled to be reduced after 80, 120, 160, 180 epochs. Called automatically every epoch as part of callbacks during training. | def lr_schedule(epoch):
lr = 0.0001
if epoch > 40:
lr *= 1e-2
elif epoch > 30:
lr *= 5e-2
elif epoch > 20:
lr *= 1e-1
elif epoch > 10:
lr *= 5e-1
print ('Learning rate: ', lr)
return lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_rate_schedule(current_epoch,\n current_batch,\n batches_per_epoch,\n batch_size):\n del current_batch, batches_per_epoch # not used\n initial_learning_rate = common.BASE_LEARNING_RATE * batch_size / 128\n learning_rate =... | [
"0.76366574",
"0.7578418",
"0.75262225",
"0.7505482",
"0.7504923",
"0.7504923",
"0.7504923",
"0.7504923",
"0.74779534",
"0.73872876",
"0.7375264",
"0.73453933",
"0.7344404",
"0.73407984",
"0.7325908",
"0.7304084",
"0.72959185",
"0.72923243",
"0.7260382",
"0.7252061",
"0.71681... | 0.7284644 | 18 |
Init weight by Normal method. | def normal_init(module, mean=0, std=1, bias=0):
nn.init.normal_(module.weight, mean, std)
if hasattr(module, 'bias') and module.bias is not None:
nn.init.constant_(module.bias, bias) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_bn(self.norm0)",
"def init_weights(self) -> None:\n nn.init.kaiming_normal_(self._U)\n nn.init.kaiming_normal_(self._W)\n nn.init.kaiming_normal_(self._V)\n\n nn.init.normal_(self._b)",
"def _init_weights(self):\n nn.init.xavier_normal_(se... | [
"0.831713",
"0.8085553",
"0.80807173",
"0.796603",
"0.7903031",
"0.7850807",
"0.7715034",
"0.7643742",
"0.7604993",
"0.7561458",
"0.75551206",
"0.7549813",
"0.75366294",
"0.7532035",
"0.7500379",
"0.7481552",
"0.74757004",
"0.74719775",
"0.74667174",
"0.74517894",
"0.74461776... | 0.7248174 | 42 |
`XavierFill` in Caffe2 corresponds to `kaiming_uniform_` in PyTorch. | def caffe2_xavier_init(module, bias=0):
kaiming_init(
module,
a=1,
mode='fan_in',
nonlinearity='leaky_relu',
distribution='uniform') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def c2_xavier_fill(module: nn.Module) -> None:\n # Caffe2 implementation of XavierFill in fact\n # corresponds to kaiming_uniform_ in PyTorch\n nn.init.kaiming_uniform_(module.weight, a=1) # pyre-ignore\n if module.bias is not None: # pyre-ignore\n nn.init.constant_(module.bias, 0)",
"def au... | [
"0.7151739",
"0.5579394",
"0.5514689",
"0.54571915",
"0.54315835",
"0.53815776",
"0.5330892",
"0.53282917",
"0.53282917",
"0.5319363",
"0.5197649",
"0.5164576",
"0.5145303",
"0.5145123",
"0.5139179",
"0.5123952",
"0.51025397",
"0.51021457",
"0.5093831",
"0.50870615",
"0.50799... | 0.5037535 | 25 |
Create a flask app instance. | def create_app(config_name):
app = FlaskAPI(__name__)
app.config.from_object(app_config[config_name])
app.url_map.strict_slashes = False
return app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app() -> Flask:\r\n app = Flask(__name__.split('.')[0])\r\n init_config(app)\r\n app.register_blueprint(observer)\r\n app.teardown_appcontext(close_db)\r\n app.cli.add_command(init_db)\r\n\r\n return app",
"def make_app() -> Flask:\n logger.info('creating flask application')\n ... | [
"0.86607707",
"0.8581789",
"0.85197973",
"0.8515256",
"0.85137236",
"0.84740174",
"0.8471304",
"0.8457581",
"0.84510535",
"0.8448848",
"0.8389615",
"0.83864117",
"0.83808243",
"0.8352965",
"0.83415806",
"0.8327184",
"0.8319127",
"0.8294796",
"0.8287966",
"0.82464087",
"0.8237... | 0.0 | -1 |
Query Ethereum node to get the number of committed transactions. | def _get_num_transactions(self, address):
params = [f"0x{address}", __class__.DEFAULT_BLOCK_LATEST]
nonce = self._json_call("eth_getTransactionCount", params)
return nonce | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n return len(self.transactions)",
"def test_get_tree_count_query(self): # noqa\n # from datetime import datetime\n self.session.commit()\n\n ... | [
"0.6192195",
"0.6192195",
"0.6150255",
"0.60612446",
"0.5926973",
"0.5878157",
"0.57187593",
"0.5669754",
"0.5649288",
"0.56251365",
"0.56251365",
"0.5578647",
"0.5572768",
"0.556773",
"0.5564168",
"0.5525931",
"0.5510498",
"0.5499462",
"0.54752654",
"0.5465094",
"0.5449316",... | 0.62320256 | 0 |
This function will calculate the mean absolute percentage error (MAPE) for two desired arrays. | def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mape(actual: np.ndarray, predicted: np.ndarray):\n return np.mean(np.abs(_percentage_error(actual, predicted)))",
"def mean_absolute_percentage_error(y_true, y_pred):\n if len(y_true.shape) > 1 or len(y_pred.shape) > 1:\n raise TypeError('Arrays need to be one-dimensional.')\n \n mape ... | [
"0.7713531",
"0.7276977",
"0.7049133",
"0.69912463",
"0.6972102",
"0.69687265",
"0.6832212",
"0.66360855",
"0.66117257",
"0.65924656",
"0.6556284",
"0.6548711",
"0.64739",
"0.6436331",
"0.64331067",
"0.6359646",
"0.63554955",
"0.63439304",
"0.6336525",
"0.6330876",
"0.628604"... | 0.6167609 | 35 |
split the dataframe for train and test for the timeseries | def test_train_spl(data, testsize):
test = data.tail(testsize)
train = data.head(data.shape[0] - testsize)
return test, train | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_test_train(df, num_months_test = 1):\n train_set = df.iloc[0:len(df)-num_months_test]\n test_set = df.iloc[len(df)-num_months_test:len(df)]\n \n return train_set, test_set",
"def timeseries_train_test_split(X, y, test_size):\n\n # get the index after which test set starts\n te... | [
"0.7975927",
"0.7749126",
"0.7743486",
"0.77423155",
"0.77122474",
"0.7681449",
"0.7672021",
"0.76094157",
"0.7569454",
"0.7470933",
"0.7428895",
"0.74199414",
"0.7393188",
"0.7386696",
"0.73555213",
"0.7341691",
"0.73380315",
"0.7337256",
"0.7333543",
"0.7300885",
"0.7297646... | 0.0 | -1 |
Checks if phone is valid phone or not. Valid here means, if it is of 10 digits or not. | def is_valid_phone(phone):
assert phone is not None
phone = str(phone)
return len(phone) == 10 and is_valid_integer(phone) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_phone(phone:str) -> bool:\r\n phone = phone.replace(\"-\", \"\").replace(\"(\", \"\").replace(\")\", \"\")\r\n return phone.isdigit() and len(phone) == 10",
"def check_format_user_phone(phone):\n match = re.match(r'^\\+[0-9]{10,}$', phone)\n if not match:\n raise excep... | [
"0.8286341",
"0.8002125",
"0.7900401",
"0.7885044",
"0.7880986",
"0.7750703",
"0.76681495",
"0.7538628",
"0.73775315",
"0.7313057",
"0.7282374",
"0.72755474",
"0.72622615",
"0.72607726",
"0.72371083",
"0.7191936",
"0.7138544",
"0.71186227",
"0.71163964",
"0.7108755",
"0.71014... | 0.83913714 | 0 |
Checks if password is a valid password or not. Valid passwords are >=8, and have at least one lowercase, uppercase, and numeric character. | def is_valid_password(password):
assert password is not None
password = str(password)
return len(password) >= 8 and any(s.islower() for s in password) \
and any(s.isupper() for s in password) \
and any(s.isdigit() for s in password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_password(password):\n return isinstance(password, str) and len(password) >= 8 and \\\n re.search(r'[A-Z]', password) and re.search(r'[0-9]', password)",
"def valid_password(password):\n val = True\n\n if len(password) < 8:\n val = False\n return val\n\n i... | [
"0.8845628",
"0.8600601",
"0.8543269",
"0.84767944",
"0.84203374",
"0.840255",
"0.83854854",
"0.8236793",
"0.8175922",
"0.81603867",
"0.814628",
"0.8130607",
"0.8114034",
"0.81056494",
"0.8100817",
"0.80894923",
"0.80869913",
"0.80655414",
"0.8044165",
"0.80438393",
"0.803467... | 0.8483338 | 3 |
Checks the validity of a province string | def is_valid_province(province):
assert province is not None
return province.lower() in province_complete or \
province.upper() in province_abbr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is True\n assert valid_country(\"kraznoviklandstan\") is True\n assert valid_country(\"KRAZNOVIKLANDSTAN\") is True\n\n assert valid_country(\"Democratic_Republi... | [
"0.6674741",
"0.6414825",
"0.6413322",
"0.6344948",
"0.6281746",
"0.62671626",
"0.6247253",
"0.62199146",
"0.5997689",
"0.5961791",
"0.5898139",
"0.5849102",
"0.5840405",
"0.58350855",
"0.58006436",
"0.5762743",
"0.5723167",
"0.5697127",
"0.5662112",
"0.5641132",
"0.5640995",... | 0.7743876 | 0 |
Takes in the applicable mask, and creates a pixel filter for it. The background pixels, assumed to be white (255,255,255) are converted to ones. The pixels inside the mask are converted to zeros. | def create_norm(mask):
gray = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)
norm = np.zeros_like(mask)
for i in range(mask.shape[0]):
for j in range(mask.shape[1]):
if gray[i][j] == 255:
norm[i][j] = np.ones(3)
else:
norm[i][j] = np.zeros(3)
return norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_and_grayscale(mask):\n r, _, _, _ = Image.Image.split(mask)\n\n r = np.asarray(r)\n\n water = np.logical_and(r <= 190, r > 63)\n buildings = r > 190\n\n np_mask = np.zeros_like(r)\n np_mask[water] = 127\n np_mask[buildings] = 255\n\n gray_mask = Image.fromarray(np_mask)\n\n re... | [
"0.6854223",
"0.6695744",
"0.6627597",
"0.6497229",
"0.64386386",
"0.6426713",
"0.6423747",
"0.6394374",
"0.63767695",
"0.6368477",
"0.63562834",
"0.6342203",
"0.6286734",
"0.6275203",
"0.6267934",
"0.6260985",
"0.62432826",
"0.62356585",
"0.62305033",
"0.6224321",
"0.6224261... | 0.0 | -1 |
Computes Average Precision at cutoff k. | def batch_apk(logits, pos_mask, k):
ranks = np.argsort(logits, axis=1)[:, ::-1] # for example [1, 0, 3, 2]
actual = np.zeros_like(logits)
predicted = np.zeros_like(logits)
for ii in range(logits.shape[0]):
actual[ii] = pos_mask[ii, ranks[ii]]
predicted[ii] = logits[ii, ranks[ii]]
num_items = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\n return np.mean(r)",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance sco... | [
"0.7487966",
"0.7466151",
"0.7297455",
"0.720025",
"0.71487975",
"0.6972522",
"0.6899926",
"0.6899926",
"0.6813976",
"0.6764953",
"0.67397326",
"0.672801",
"0.6713552",
"0.67112005",
"0.66797125",
"0.6649427",
"0.6635555",
"0.6631519",
"0.66018105",
"0.6542898",
"0.65079445",... | 0.0 | -1 |
Computes Average Precision at cutoff k. | def apk(logits, pos_mask, k):
ranks = np.argsort(logits)[::-1] # for example [1, 0, 3, 2]
# print('ranks', ranks)
actual = np.array(pos_mask)[ranks]
# print('sorted', actual)
# print('logits', logits)
predicted = np.array(logits)[ranks]
#log.info("actual: {}".format(actual))
#log.info("predicte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\n return np.mean(r)",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance sco... | [
"0.7487966",
"0.7466151",
"0.7297455",
"0.720025",
"0.71487975",
"0.6972522",
"0.6899926",
"0.6899926",
"0.6813976",
"0.6764953",
"0.67397326",
"0.672801",
"0.6713552",
"0.67112005",
"0.66797125",
"0.6649427",
"0.6635555",
"0.6631519",
"0.66018105",
"0.6542898",
"0.65079445",... | 0.0 | -1 |
Clip boxes to image boundaries. boxes must be tensor or Variable, im_shape can be anything but Variable | def clip_boxes(boxes, im_shape):
if not hasattr(boxes, 'data'):
boxes_ = boxes.numpy()
boxes = boxes.view(boxes.size(0), -1, 4)
boxes = torch.stack([
boxes[:, :, 0].clamp(0, im_shape[1] - 1),
boxes[:, :, 1].clamp(0, im_shape[0] - 1),
boxes[:, :, 2].clamp(0, im_shape[1] - 1),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_boxes(boxes, im_shape):\n boxes[:, 0::2]=threshold(boxes[:, 0::2], 0, im_shape[1]-1)\n boxes[:, 1::2]=threshold(boxes[:, 1::2], 0, im_shape[0]-1)\n return boxes",
"def clip_boxes(boxes, im_shape):\n boxes[:, 0::2]=threshold(boxes[:, 0::2], 0, im_shape[1]-1)\n boxes[:, 1::2]=threshold(boxe... | [
"0.82911456",
"0.82911456",
"0.8147877",
"0.8112098",
"0.8080549",
"0.8059412",
"0.8059412",
"0.8025268",
"0.78824383",
"0.7839416",
"0.7827699",
"0.7574378",
"0.75495154",
"0.73735785",
"0.72157484",
"0.7072005",
"0.70256233",
"0.6909916",
"0.66580474",
"0.66089386",
"0.6597... | 0.81829756 | 2 |
Return a 4tup of normalized coordinates, given screenshot dimensions. | def get_normcoord_from_screenshot(canv_width, canv_height,
left_offset=None, right_offset=None, bot_offset=None, top_offset=None,
obj_width=None, obj_height=None):
# A fraction of the total width.
x_min = left_offset / float(canv_width)
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized_screen_coordinates(x, y) -> (int, int):\n res_x, res_y = get_screen_resolution()\n return int(x * 65536 / res_x), int(y * 65536 / res_y)",
"def to_grid(screen_pos):\n if isinstance(screen_pos, list):\n return tuple((int((x / (Globals.instance.GRID_SIZE * 1.0))) for x in screen_pos)... | [
"0.6372897",
"0.61740065",
"0.59522426",
"0.5823643",
"0.5787744",
"0.57871443",
"0.57787746",
"0.5733082",
"0.56963056",
"0.56893736",
"0.5685459",
"0.5577846",
"0.5554742",
"0.5520703",
"0.5517424",
"0.54969555",
"0.54957014",
"0.54957014",
"0.5484297",
"0.54815376",
"0.547... | 0.597146 | 2 |
Return the reciprocal version of this rational | def reciprocal(self):
return Rational(self.denominator, self.numerator) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reciprocal(self):\n recip = RationalFrac(0, empty=True)\n if 0 in self.numer:\n raise ZeroDivisionError('the reciprocal of zero is undefined.')\n recip.numer = self.denom.copy()\n recip.denom = self.numer.copy()\n recip.neg = bool(self.neg)\n return recip",
... | [
"0.8447303",
"0.80559045",
"0.6966935",
"0.68982375",
"0.68424946",
"0.6740115",
"0.6721009",
"0.66886157",
"0.6631034",
"0.6556745",
"0.6512884",
"0.64744276",
"0.64670575",
"0.64157546",
"0.6391257",
"0.6316457",
"0.6268871",
"0.6232937",
"0.6224103",
"0.6211755",
"0.616556... | 0.9095893 | 0 |
Return the sum of this rational and the specified other | def add(self, other):
return Rational(self.numerator * other.denominator + other.numerator * self.denominator,
self.denominator * other.denominator) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __add__(self, other):\n try:\n new_num = (self._num * other._den) + (self._den * other._num)\n new_den = (self._den * other._den)\n return Rational(new_num, new_den)\n except AttributeError:\n return (self + Rational.parse_number(other))",
"def __add_... | [
"0.8370582",
"0.8320178",
"0.78976333",
"0.78123873",
"0.76839614",
"0.7653905",
"0.73464394",
"0.7343277",
"0.7333337",
"0.7279984",
"0.71204865",
"0.71000504",
"0.7077521",
"0.70052063",
"0.70052063",
"0.6970627",
"0.6969484",
"0.69491756",
"0.69240856",
"0.68912005",
"0.68... | 0.8328403 | 1 |
Return true if this rational is less than the specified other, false otherwise | def less(self, other):
return self.numerator * other.demoninator < other.numerator * self.denominator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n self.numerator=self.numerator*other.denominator\n other.numerator=self.denominator*other.numerator\n if(self.numerator<other.numerator):\n return True\n else:\n return False",
"def __lt__(self, other):\n try:\n lhs = (... | [
"0.8527415",
"0.8494084",
"0.84258354",
"0.83202803",
"0.8184852",
"0.8124288",
"0.7998516",
"0.79609406",
"0.7586666",
"0.7580267",
"0.75228965",
"0.74616617",
"0.74484605",
"0.74271744",
"0.74100935",
"0.74100935",
"0.7345702",
"0.7343107",
"0.7279283",
"0.7279283",
"0.7272... | 0.8497469 | 1 |
Return the larger of this rational and the specified other | def max(self, other):
return other if self.less(other) else self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gt__(self, other):\n self.numerator = abs(self.numerator)\n self.denominator = abs(self.denominator)\n other.numerator = abs(other.numerator)\n other.denominator = abs(other.denominator)\n\n num1 = (self.numerator/other.numerator)\n num2 = (self.denominator/other.den... | [
"0.75641996",
"0.74302745",
"0.73240954",
"0.7223124",
"0.72217417",
"0.70630133",
"0.70288",
"0.70043695",
"0.69452447",
"0.68012196",
"0.6760717",
"0.670144",
"0.6697768",
"0.6694735",
"0.66561496",
"0.6594676",
"0.6570197",
"0.65643084",
"0.6529228",
"0.64955217",
"0.64886... | 0.69333756 | 9 |
Return the string representation of this rational | def __repr__(self):
return str(self.numerator) + '/' + str(self.denominator) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self) -> str:\n return str(self._numerator) + \"/\" + str(self._denominator)",
"def return_string(self):\n\n if self.__numerator * self.__denominator < 0:\n sign = \"-\"\n else:\n sign = \"\"\n return \"{:s}{:d}/{:d}\".format(sign, abs(self.__numerato... | [
"0.8152605",
"0.7863458",
"0.7712844",
"0.7708229",
"0.76031685",
"0.7602594",
"0.7599968",
"0.7579995",
"0.74055827",
"0.739488",
"0.7360274",
"0.73505414",
"0.7323696",
"0.72206986",
"0.7149929",
"0.70774734",
"0.70774734",
"0.7075957",
"0.7075957",
"0.7075957",
"0.7075957"... | 0.7576243 | 8 |
return the current value of a configuration parameter | def get_parameter_value(self, parameter_name):
if parameter_name in self.description["config"]["values"].keys():
return self.description["config"]["values"][parameter_name]["value"]
else:
return "No such parameter" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getConfigParam(self, name, default=None):\n return self.config.get(self._configPrefix + name.lower(), default)",
"def get_config_value(self, name):\r\n if name in self.config_values:\r\n return self.config_values[name]",
"def value(self) -> str:\n return self._config.get('v... | [
"0.7355216",
"0.7179929",
"0.7144047",
"0.6995993",
"0.69809175",
"0.68770003",
"0.6831153",
"0.6829399",
"0.6825949",
"0.6824083",
"0.6729543",
"0.6714612",
"0.6706525",
"0.6693459",
"0.6669157",
"0.66686666",
"0.66561323",
"0.66532326",
"0.6650613",
"0.66387266",
"0.6594361... | 0.7635072 | 0 |
Test that the `last_name` method prefers the `romanized_last_name` field, and falls back on `last_name` field. | def test_last_name(self, unromanized, romanized, expected):
with mute_signals(post_save):
profile = ExamProfileFactory(
profile__last_name=unromanized,
profile__romanized_last_name=romanized,
)
assert CDDWriter.last_name(profile) == expected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_last_name_first_name(self):\n current_resume = resume.objects.first()\n expected = 'Bielinski, Nicholas'\n case = current_resume.last_name_first_name()\n self.assertEqual(case, expected)",
"def test_first_last_name(self):\n formatted_name = get_formatted_name('jimi', '... | [
"0.7462502",
"0.73019266",
"0.7267468",
"0.7249882",
"0.7249882",
"0.7226231",
"0.7025035",
"0.6827705",
"0.68229175",
"0.68227214",
"0.6734558",
"0.66262174",
"0.6624894",
"0.661185",
"0.661185",
"0.65678793",
"0.65644515",
"0.65555114",
"0.6553704",
"0.65166277",
"0.6400914... | 0.778702 | 0 |
A profile with a valid phone number should be parsed correctly | def test_profile_phone_number_functions(self, input_number, expected_country_code, expected_number):
with mute_signals(post_save):
profile = ExamProfileFactory(profile__phone_number=input_number)
assert CDDWriter.profile_phone_number_to_raw_number(profile) == expected_number
assert C... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_format_user_phone(phone):\n match = re.match(r'^\\+[0-9]{10,}$', phone)\n if not match:\n raise exceptions.ValidationError('phone is not valid!')\n return phone",
"def validate_phone(value):\n if value.strip() == \"\":\n return\n try:\n ... | [
"0.7363195",
"0.72308403",
"0.70126206",
"0.6967565",
"0.6954217",
"0.69332784",
"0.6872621",
"0.6840999",
"0.6617075",
"0.6594472",
"0.65869284",
"0.65801764",
"0.6537829",
"0.6511794",
"0.64849555",
"0.6477637",
"0.6468209",
"0.6447355",
"0.64282095",
"0.64078885",
"0.64054... | 0.68583184 | 7 |
Return the analog_input_mode flag. | def analog_input_mode(self):
return self._analog_input_mode | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __int__(self):\n flags = self._analog_input_mode\n flags = set_bit(flags, 2, self._send_on_sensor_alarm)\n flags = set_bit(flags, 3, self._send_on_input_port_change)\n flags = set_bit(flags, 4, self._enable_1_wire_port)\n flags = set_bit(flags, 5, self._enable_all_link_aliasi... | [
"0.6887114",
"0.6222076",
"0.613213",
"0.6002839",
"0.59865963",
"0.59605205",
"0.5950149",
"0.5917787",
"0.5846322",
"0.5829329",
"0.5825463",
"0.5813624",
"0.5803458",
"0.580242",
"0.57936394",
"0.57936394",
"0.57741266",
"0.57628095",
"0.5753946",
"0.5746238",
"0.57193464"... | 0.9088243 | 0 |
Return the send_on_sensor_alarm flag. | def send_on_sensor_alarm(self):
return self._send_on_sensor_alarm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_alarm():\n return _alarm",
"def _isalarm(self):\n return self.dp.state()==PyTango.DevState.ALARM",
"def is_on(self):\n return self._sensor_state()",
"def is_on(self):\n if self._sensor_type != DEVICE_TYPE_DOORBELL:\n return self._camera_data[\"event_on\"]\n re... | [
"0.7273817",
"0.69461244",
"0.6902556",
"0.6806057",
"0.6415222",
"0.6391175",
"0.6213526",
"0.621152",
"0.61985254",
"0.6179117",
"0.61689496",
"0.6164844",
"0.60556906",
"0.6011994",
"0.59273",
"0.59177333",
"0.58980465",
"0.5893863",
"0.5856948",
"0.58119935",
"0.5787196",... | 0.85742277 | 0 |
Return the enable_output_timers flag. | def enable_output_timers(self):
return self._enable_output_timers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enable_timestamp_write():\n global enable_timestamp_write\n return enable_timestamp_write",
"def time_enabled(self):\n return self._time_enabled",
"def get_output(self):\r\n return self.on",
"def is_timer_on(self):\n return self.status == 'ON'",
"def _get_enable(self):\n ... | [
"0.6433603",
"0.5940663",
"0.5916283",
"0.5738133",
"0.56973654",
"0.56973654",
"0.56570226",
"0.5625595",
"0.5624499",
"0.55969304",
"0.5585749",
"0.5579384",
"0.55361307",
"0.55151075",
"0.55151075",
"0.55151075",
"0.55151075",
"0.54999506",
"0.54857606",
"0.5474222",
"0.54... | 0.84544075 | 0 |
Create a IOPortConfigFlags from a byte value. | def create_from_byte(cls, value):
analog_input_mode = value & 0x03
send_on_sensor_alarm = bit_is_set(value, 2)
send_on_input_port_change = bit_is_set(value, 2)
enable_1_wire_port = bit_is_set(value, 2)
enable_all_link_aliasing = bit_is_set(value, 2)
send_on_outut_port_cha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_value(cls, value):\n value = value if value else 0\n try:\n flags = [flag.name for flag in cls.enum_class if flag.value & value]\n except TypeError:\n flags = [flag.name for flag in cls.enum_class if flag.name == value]\n\n return cls(*flags)",
"def _fro... | [
"0.5315999",
"0.52840596",
"0.52248985",
"0.51001847",
"0.5049011",
"0.5016992",
"0.4843069",
"0.48379126",
"0.48180452",
"0.47073126",
"0.46995822",
"0.46911868",
"0.46823964",
"0.46774733",
"0.4667887",
"0.46528277",
"0.46406937",
"0.45963296",
"0.45961842",
"0.4590913",
"0... | 0.59410995 | 0 |
Sample a vector of (number) deltas from the fitted Gaussian | def sample_deltas(self, number):
return (torch.randn(number, 1) + self.delta_mean) * self.delta_std | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n (x - mu) / sigma, 2) / 2)",
"def gaussian(mu, wid, x):\n return np.exp(-((x - mu) / (0.6005612 * wid))**2)",
"def mutate(vecto... | [
"0.65304977",
"0.65078706",
"0.6441759",
"0.6437199",
"0.6409361",
"0.63679",
"0.63458383",
"0.63280684",
"0.6294276",
"0.62795615",
"0.62331444",
"0.62236345",
"0.6203261",
"0.6201773",
"0.62010115",
"0.6107586",
"0.6093211",
"0.6072608",
"0.60632694",
"0.6062222",
"0.606086... | 0.59226537 | 35 |
Just sample from self.raw_data and self.raw_labels according to the idx. | def __getitem__(self, idx):
if torch.is_tensor(idx):
idx = idx.tolist()
if self.for_print:
shot_sample = self.raw_data[self.print_ids, ...][idx, ...]
label_sample = self.raw_labels[self.print_ids, ...][idx, ...]
else:
shot_sample = self.raw_data[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, index):\n\n # get and load sample from index file\n sample = self.samples[index]\n # labels = self.labels\n return load_sample(sample, self.imgTransform,\n self.use_s1, self.use_s2, self.use_RGB)",
"def __getitem__(self, idx):\n r... | [
"0.7042597",
"0.6869325",
"0.6812664",
"0.67701495",
"0.67607373",
"0.67556775",
"0.6745774",
"0.6728316",
"0.6705804",
"0.66796887",
"0.6618347",
"0.6616341",
"0.65521604",
"0.65520835",
"0.6459788",
"0.64566356",
"0.6449388",
"0.64409304",
"0.6440253",
"0.6396518",
"0.63942... | 0.7327663 | 0 |
Create a cube of all zeros | def zeros(self):
super(TimeCube, self).zeros()
self.data = np.zeros([self.time_range[1]-self.time_range[0]]+self.cubesize, np.uint8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube(n):\n return n**3",
"def cube(n):\n result = [num*num*num for num in range(n)]\n\n return result[1:]",
"def generate_cube():\n \n num_voxels = 31\n\n data_x = []\n data_y = []\n data_z = []\n data_intensity = []\n\n volume = numpy.zeros((num_voxels, num_voxels, num_voxels... | [
"0.7027687",
"0.7023051",
"0.6918217",
"0.6877029",
"0.6877029",
"0.6856294",
"0.6709744",
"0.6689326",
"0.65018374",
"0.6432957",
"0.6422741",
"0.6410308",
"0.6361555",
"0.6359317",
"0.6343851",
"0.62892145",
"0.628593",
"0.62821823",
"0.62522525",
"0.62462974",
"0.618771",
... | 0.65935415 | 8 |
Pack a sequence of differentiae together into a compact string representation. Returns a string with base 64 encoded concatenation of diffferentiae. If `differentia_bit_width` is not an even byte multiple, the first encoded byte tells how many empty padding bits, if any, were placed at the end of the concatenation in o... | def pack_differentiae_str(
strata: typing.Iterable[HereditaryStratum],
differentia_bit_width: int,
) -> str:
buffer = pack_differentiae_bytes(strata, differentia_bit_width)
return stringify_packed_differentia_bytes(buffer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_packed_encoder(wrapped_encoder):\n def length_wrapper(values):\n \"\"\"Encode repeat values and prefix with the length\"\"\"\n output = bytearray()\n for value in values:\n output += wrapped_encoder(value)\n length = varint.encode_varint(len(output))\n ... | [
"0.5182468",
"0.51296633",
"0.50786614",
"0.5052259",
"0.4919786",
"0.4863465",
"0.48548102",
"0.48389608",
"0.47969294",
"0.47860432",
"0.47655174",
"0.475634",
"0.4749195",
"0.47287458",
"0.47143117",
"0.4706284",
"0.46964794",
"0.46833417",
"0.46700457",
"0.4668338",
"0.46... | 0.7440856 | 0 |
Return a tuple (upper, lower) describing the expected range of states for this system | def state_limits(self) -> Tuple[torch.Tensor, torch.Tensor]:
# define upper and lower limits based around the nominal equilibrium input
upper_limit = torch.ones(self.n_dims)
upper_limit[TurtleBot2D.X] = 2.0
upper_limit[TurtleBot2D.Y] = 2.0
upper_limit[TurtleBot2D.THETA] = 2 * np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStatesBounds(self):\n return (0, 0), (self._width - 1, self._height - 1)",
"def getRange(self) -> Tuple[int, int]:\n return self.validator().bottom(), self.validator().top()",
"def bcRange(self):\n\t\treturn fabs(self.Upper - self.Lower)",
"def get_range(self) -> tuple[int, int]:\n ... | [
"0.6894532",
"0.6853945",
"0.65013313",
"0.64370793",
"0.6309505",
"0.63058215",
"0.62840694",
"0.62822354",
"0.6272151",
"0.6260246",
"0.6188617",
"0.61856526",
"0.6182357",
"0.6182202",
"0.61065006",
"0.606575",
"0.5981184",
"0.59791803",
"0.59361506",
"0.59266293",
"0.5919... | 0.7177566 | 0 |
Return a tuple (upper, lower) describing the range of allowable changes to control for this system | def intervention_limits(self) -> Tuple[torch.Tensor, torch.Tensor]:
upper_limit = torch.ones(self.n_controls)
upper_limit[TurtleBot2D.V] = 1.0
upper_limit[TurtleBot2D.THETA_DOT] = 2.0 * np.pi
lower_limit = torch.ones(self.n_controls)
lower_limit[TurtleBot2D.V] = -1.0
low... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def control_limits(self) -> Tuple[torch.Tensor, torch.Tensor]:\n # define upper and lower limits based around the nominal equilibrium input\n # These are relaxed for now, but eventually they should be measured on hardware\n upper_limit = torch.ones(self.n_controls)\n upper_limit[TurtleB... | [
"0.6868183",
"0.67772573",
"0.666613",
"0.6619348",
"0.6572531",
"0.6528172",
"0.63338536",
"0.6299599",
"0.6265506",
"0.6189901",
"0.61834913",
"0.61564565",
"0.613949",
"0.6118119",
"0.61016905",
"0.6098414",
"0.6089789",
"0.6086147",
"0.6084366",
"0.6081033",
"0.6080719",
... | 0.6428247 | 6 |
Return the controlindependent part of the controlaffine dynamics. | def _f(self, x: torch.Tensor, params: Scenario):
# Extract batch size and set up a tensor for holding the result
batch_size = x.shape[0]
# memoize the tensor
if not hasattr(self, "f_tensor"):
self.f_tensor = torch.zeros(self.n_dims, 1)
return self.f_tensor.expand(ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_real_leg(self):\n if self.invert_y:\n inv = -1\n else:\n inv = 1\n\n c = self.C[-1]\n\n c = Coordinate(\n x=c.x + self.structure_offset.x,\n y=c.y * inv + self.structure_offset.y,\n z=c.z + self.structure_offset.z\n )... | [
"0.5842499",
"0.5781906",
"0.55973613",
"0.5593811",
"0.5591012",
"0.5550116",
"0.5467778",
"0.54417115",
"0.5363111",
"0.5300538",
"0.5275563",
"0.5260108",
"0.5256807",
"0.5254449",
"0.5236301",
"0.5227761",
"0.51986957",
"0.5173537",
"0.5166362",
"0.51543397",
"0.5132983",... | 0.0 | -1 |
Return the x, y, theta configuration of this system at the given states. | def planar_configuration(self, x: torch.Tensor) -> torch.Tensor:
# The state is just the planar configuration
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\n\n return self.t, self.x",
"def lattice_settings(self):\n return (self.a, self.b, self.c,\n self.alpha*radians, self.beta*radians, self.gamma*radians)",
"def _config(self):\r\n return (\r\n self.destructive,\r\n self.output... | [
"0.57717943",
"0.56263703",
"0.56176376",
"0.5615044",
"0.53807443",
"0.53741276",
"0.5361967",
"0.53569305",
"0.53484184",
"0.53349704",
"0.53251255",
"0.5317624",
"0.530086",
"0.52976495",
"0.5250443",
"0.5230861",
"0.5225545",
"0.5221872",
"0.5215205",
"0.51962173",
"0.514... | 0.0 | -1 |
Returns the path to the id.txt file. | def get_id_path():
root = os.path.dirname(os.path.abspath(__file__))[:-5]
id_path = os.path.join(root, "client\\files\\id.txt")
return id_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getID(filePath):\r\n\r\n fileID = rmn.fstopenall(filePath,rmn.FST_RO)\r\n return fileID",
"def idfname(self):\n if self._idfname is None:\n idfname = StringIO(f\"VERSION, {self.as_version};\")\n idfname.seek(0)\n self._idfname = idfname\n else:\n ... | [
"0.715112",
"0.71239233",
"0.7118113",
"0.6877116",
"0.66784066",
"0.6554015",
"0.65528977",
"0.65134394",
"0.64945537",
"0.64932996",
"0.6486824",
"0.6419497",
"0.6408774",
"0.64031917",
"0.63873464",
"0.63319975",
"0.6321611",
"0.6297355",
"0.6265827",
"0.62309515",
"0.6212... | 0.8837145 | 0 |
Get attribute from current task's space. | def __getattribute__(self, name):
if name in ('__setattr__', '__getattr__', '__delattr__', '_loop', '__curtask__'):
return object.__getattribute__(self, name)
return getattr(self.__curtask__, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getattribute__(self, name):\n if name in ('__setattr__', '__getattr__', '__delattr__', '_loop', '__curtask__'):\n return object.__getattribute__(self, name)\n\n if self._loop.is_running():\n return getattr(self.__curtask__, name)\n return getattr(tlocals, name)",
... | [
"0.6848543",
"0.6767172",
"0.6495903",
"0.64659494",
"0.63059324",
"0.6248323",
"0.6228822",
"0.618367",
"0.61331815",
"0.61324036",
"0.603426",
"0.6022826",
"0.5999773",
"0.5996572",
"0.5982172",
"0.5967806",
"0.59463024",
"0.59168863",
"0.59162194",
"0.5914162",
"0.5909439"... | 0.69251484 | 0 |
Get attribute from current task's space. | def __getattribute__(self, name):
if name in ('__setattr__', '__getattr__', '__delattr__', '_loop', '__curtask__'):
return object.__getattribute__(self, name)
if self._loop.is_running():
return getattr(self.__curtask__, name)
return getattr(tlocals, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getattribute__(self, name):\n if name in ('__setattr__', '__getattr__', '__delattr__', '_loop', '__curtask__'):\n return object.__getattribute__(self, name)\n return getattr(self.__curtask__, name)",
"def __getattr__(self, name):\n container = self.__dict__.get(\"_data\")\n ... | [
"0.69251484",
"0.6767172",
"0.6495903",
"0.64659494",
"0.63059324",
"0.6248323",
"0.6228822",
"0.618367",
"0.61331815",
"0.61324036",
"0.603426",
"0.6022826",
"0.5999773",
"0.5996572",
"0.5982172",
"0.5967806",
"0.59463024",
"0.59168863",
"0.59162194",
"0.5914162",
"0.5909439... | 0.6848543 | 1 |
Serialize the given object into JSON. | def dumps(obj, skipkeys=True, default=str, **params):
try:
return json.dumps(obj, skipkeys=skipkeys, default=default, **params)
except (TypeError, ValueError):
return default(obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self, obj):\n return json.dumps(obj)",
"def toJSON(cls, obj):\n return json.dumps(obj)",
"def serialize(cls, obj):\n return json.dumps(obj, cls=CustomTypeEncoder)",
"def toJSON(object):\n\treturn json.dumps(object, ensure_ascii=False)",
"def encode_json(obj):\n\treturn js... | [
"0.8428157",
"0.8394948",
"0.78829616",
"0.78448844",
"0.7829075",
"0.76699",
"0.76656634",
"0.75775355",
"0.7546415",
"0.75331676",
"0.7433279",
"0.74025476",
"0.73990226",
"0.73990226",
"0.73990226",
"0.73990226",
"0.73936313",
"0.73913765",
"0.7386714",
"0.7381187",
"0.736... | 0.0 | -1 |
Test that hexlify and b2a_hex are binary versions of bytes.hex. | def test_hex_separator(self):
# Logic of separators is tested in test_bytes.py. This checks that
# arg parsing works and exercises the direct to bytes object code
# path within pystrhex.c.
s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unhexlify_not_python():\n assert '' == uflash.unhexlify(\n ':020000040003F7\\n:10E000000000000000000000000000000000000010')",
"def test_unhexlify():\n hexlified = uflash.hexlify(TEST_SCRIPT)\n unhexlified = uflash.unhexlify(hexlified)\n assert unhexlified == TEST_SCRIPT.decode('utf... | [
"0.6966817",
"0.67673844",
"0.6649072",
"0.65729934",
"0.6571348",
"0.6467908",
"0.6399302",
"0.63925326",
"0.63686347",
"0.6325996",
"0.63253886",
"0.6321911",
"0.63130945",
"0.62925464",
"0.62900186",
"0.6286824",
"0.6278131",
"0.6277138",
"0.6273923",
"0.6243617",
"0.62434... | 0.5859543 | 43 |
Load image from a given path and pad it on the sides, so that eash side is divisible by 32 (network requirement) | def pad(img, shape):#pad_size=32):
if shape == 0:
return img
pad_shape = np.int16(np.ceil((np.array(shape) - np.array(img.shape[:2]))))
height, width = img.shape[:2]
# if height % shape == 0:
# y_min_pad = 0
# y_max_pad = 0
# else:
y_pad = pad_shape[0]
y_min_pad = i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pil_loader(path):\n with open(path, 'rb') as f:\n with Image.open(f) as img:\n sqrWidth = np.ceil(np.sqrt(img.size[0]*img.size[1])).astype(int)\n return img.convert('L').resize((sqrWidth, sqrWidth))",
"def preprocessing(image_path, side=416):\n\... | [
"0.616795",
"0.61333394",
"0.60095197",
"0.5848159",
"0.5772759",
"0.5656954",
"0.5650549",
"0.54881823",
"0.5449667",
"0.5378097",
"0.5336648",
"0.5326188",
"0.53256345",
"0.5320389",
"0.5310851",
"0.5270405",
"0.52534175",
"0.5249455",
"0.5243269",
"0.5230036",
"0.5218337",... | 0.0 | -1 |
Sets the id of this DeterminantDisease. | def id(self, id):
if id is None:
raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.__id = id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def SetId(self, id):\n self.id = int(id)",
"def id(self, id):\n if id is None:\n raise ValueError(\"Invalid value for `id`, must not be `None`\")\n\n self._id = id",
"def id(... | [
"0.7438892",
"0.74044544",
"0.73169297",
"0.70647836",
"0.70647836",
"0.70647836",
"0.7056256",
"0.7035133",
"0.70211035",
"0.6967908",
"0.6903157",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"0.68682384",
"... | 0.6975336 | 16 |
Sets the name of this DeterminantDisease. | def name(self, name):
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name):\n self._name = name",
"def set_name(self, name):\r\n self.__name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, na... | [
"0.72977024",
"0.72977024",
"0.72880435",
"0.72781557",
"0.7270582",
"0.7270582",
"0.7270582",
"0.7270582",
"0.7270582",
"0.7260632",
"0.7260632",
"0.7247664",
"0.7238392",
"0.7238392",
"0.72378117",
"0.7213834",
"0.72013",
"0.71996456",
"0.71768844",
"0.71544075",
"0.7125006... | 0.0 | -1 |
Sets the biology_spread_pathogen of this DeterminantDisease. | def biology_spread_pathogen(self, biology_spread_pathogen):
self._biology_spread_pathogen = biology_spread_pathogen | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pathogen_morphology(self, pathogen_morphology):\n\n self._pathogen_morphology = pathogen_morphology",
"def home_point_spread(self, home_point_spread):\n\n self._home_point_spread = home_point_spread",
"def away_point_spread(self, away_point_spread):\n\n self._away_point_spread = away_p... | [
"0.5970008",
"0.5342568",
"0.5157027",
"0.48848188",
"0.47976685",
"0.47703573",
"0.47528386",
"0.47006908",
"0.46924806",
"0.4640696",
"0.46322238",
"0.46070376",
"0.45368108",
"0.4515343",
"0.45134032",
"0.44890362",
"0.44881514",
"0.44835293",
"0.44549873",
"0.44398916",
"... | 0.86131316 | 0 |
Sets the disease_harmfulness of this DeterminantDisease. | def disease_harmfulness(self, disease_harmfulness):
self._disease_harmfulness = disease_harmfulness | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def economic_threshold_of_harmfulness(self, economic_threshold_of_harmfulness):\n\n self._economic_threshold_of_harmfulness = economic_threshold_of_harmfulness",
"def treatDisease(self, disease = None):\r\n self.city.treat(self.DISEASE_CURE_AMOUNT,disease)",
"def add_disease(self, disease):\n ... | [
"0.59182364",
"0.50079805",
"0.49216032",
"0.4848669",
"0.46271923",
"0.4536078",
"0.45351195",
"0.4524381",
"0.44951496",
"0.43968138",
"0.43812108",
"0.436679",
"0.43571442",
"0.43479702",
"0.4334108",
"0.4334059",
"0.43298295",
"0.4303823",
"0.42682964",
"0.42630604",
"0.4... | 0.9064781 | 0 |
Sets the economic_threshold_of_harmfulness of this DeterminantDisease. | def economic_threshold_of_harmfulness(self, economic_threshold_of_harmfulness):
self._economic_threshold_of_harmfulness = economic_threshold_of_harmfulness | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disease_harmfulness(self, disease_harmfulness):\n\n self._disease_harmfulness = disease_harmfulness",
"def set_eht(self, target_eht):\n self.target_eht = round(target_eht, 2)\n # Setting SEM to target EHT must be implemented in child class!",
"def wall_energy_efficiency(self, wall_ener... | [
"0.66685575",
"0.50977784",
"0.4999993",
"0.49307144",
"0.49231547",
"0.48430198",
"0.48425034",
"0.48360926",
"0.47816694",
"0.47583735",
"0.47419366",
"0.4729318",
"0.4729318",
"0.4729318",
"0.4729318",
"0.4729318",
"0.4711202",
"0.46917084",
"0.4686041",
"0.4671596",
"0.46... | 0.8641288 | 0 |
Sets the subgroup of this DeterminantDisease. | def subgroup(self, subgroup):
if subgroup is None:
raise ValueError("Invalid value for `subgroup`, must not be `None`") # noqa: E501
self._subgroup = subgroup | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_subgroup(self, subgroup):\n self.schedule['subgroup'] = subgroup",
"def set_main_group(self, sub_group):\n self.attrs[\"MAIN_GROUP\"] = sub_group",
"def add_subgroup(self, new_subgroup):\n self.subgroups[new_subgroup.get_title()] = new_subgroup",
"def set_group(self, group):\n ... | [
"0.78277284",
"0.65610945",
"0.6334544",
"0.6149302",
"0.61127234",
"0.59693044",
"0.59693044",
"0.59693044",
"0.59109634",
"0.58241326",
"0.57126844",
"0.5711142",
"0.5687875",
"0.56675637",
"0.56482035",
"0.5628782",
"0.5628782",
"0.5567436",
"0.55410093",
"0.5534816",
"0.5... | 0.7124084 | 1 |
Sets the causative_agent of this DeterminantDisease. | def causative_agent(self, causative_agent):
if causative_agent is None:
raise ValueError("Invalid value for `causative_agent`, must not be `None`") # noqa: E501
self._causative_agent = causative_agent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_agent(self, agent: Agent):\n self.agent = agent\n return self",
"def __init__(self, agent: AEA) -> None:\n self._agent = agent\n super().__init__()",
"def agent_id(self, agent_id):\n\n self._agent_id = agent_id",
"def set_agents(self, agents):\n if self.sing... | [
"0.5552585",
"0.5387177",
"0.53348297",
"0.5256439",
"0.50591224",
"0.50468266",
"0.498001",
"0.48996314",
"0.4843679",
"0.48327622",
"0.47013524",
"0.47009754",
"0.46979696",
"0.46907756",
"0.46498543",
"0.46432987",
"0.4630803",
"0.46287802",
"0.46013987",
"0.4569359",
"0.4... | 0.81589407 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, DeterminantDisease):
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 |
replaces chars which need to be escaped with a '_' in the filename; Returns | def _filepath_clean(file_path):
dir_name, file_name = os.path.split(file_path)
name, ext = os.path.splitext(file_name)
if re.search(r'[,\s|:\'\.]', name):
clean_name = re.sub(r'[,\s|:\'\.]', '_', name)
clean_file_name = clean_name + ext
clean_file_path = os.path.join(dir_name, clean_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_filename(input: str) -> str:\n\n output = re.sub(r\"[^\\w\\-_\\.]\", \"_\", input)\n return output",
"def safe_filename(filename):\n string = str(filename).strip().replace(\" \", \"_\")\n string = re.sub(r\"(?u)[^-\\w.]\", \"_\", string)\n return re.sub(r\"_+\", \"_\", string)",
"def ... | [
"0.83261395",
"0.7648104",
"0.7570827",
"0.75050944",
"0.74838173",
"0.74229556",
"0.73367715",
"0.7327531",
"0.7297298",
"0.72880167",
"0.71594447",
"0.71594447",
"0.71594447",
"0.7159035",
"0.7156342",
"0.7146029",
"0.70739406",
"0.7054663",
"0.70276",
"0.7001686",
"0.69815... | 0.0 | -1 |
Checks if a password is valid, with scheme 1 | def is_valid_password_v1(password):
letter_count = sum([x == password["letter"] for x in list(password["password"])])
return password["low"] <= letter_count <= password["high"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def password_validator(username, password):\n digits = re.search(r'\\d+', password)\n capital_letters = re.search(r'[A-Z]+', password)\n len... | [
"0.7622952",
"0.7551223",
"0.74881816",
"0.7415057",
"0.7395938",
"0.73912114",
"0.73893994",
"0.7363374",
"0.72863233",
"0.7271751",
"0.7271157",
"0.720352",
"0.7166715",
"0.716442",
"0.7132431",
"0.71306264",
"0.7115087",
"0.71105266",
"0.7092746",
"0.7074758",
"0.70439756"... | 0.714659 | 14 |
Checks if a password is valid, with scheme 1 | def is_valid_password_v2(password):
low = password["letter"] == password["password"][password["low"] - 1]
high = password["letter"] == password["password"][password["high"] - 1]
return xor(low, high) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def password_validator(username, password):\n digits = re.search(r'\\d+', password)\n capital_letters = re.search(r'[A-Z]+', password)\n len... | [
"0.7622952",
"0.7551223",
"0.74881816",
"0.7415057",
"0.7395938",
"0.73912114",
"0.73893994",
"0.7363374",
"0.72863233",
"0.7271751",
"0.7271157",
"0.720352",
"0.7166715",
"0.716442",
"0.714659",
"0.71306264",
"0.7115087",
"0.71105266",
"0.7092746",
"0.7074758",
"0.70439756",... | 0.7132431 | 15 |
Takes a tensor with 3 or more dimensions and does a masked softmax over the last dimension. We assume the tensor has shape ``(batch_size, ..., sequence_length)`` and that the mask (if given) has shape ``(batch_size, sequence_length)``. We first unsqueeze and expand the mask so that it has the same shape as the tensor, ... | def last_dim_softmax(tensor, mask=None) -> torch.Tensor:
tensor_shape = tensor.size()
reshaped_tensor = tensor.view(-1, tensor.size()[-1])
if mask is not None:
while mask.dim() < tensor.dim():
mask = mask.unsqueeze(1)
mask = mask.expand_as(tensor).contiguous().float()
mas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_softmax(input_layer,n_nodes, batch_size):\n mask_lower = K.theano.tensor.tril(K.ones((n_nodes, n_nodes)))\n mask_upper = \\\n K.theano.tensor.triu(-100. * K.ones((n_nodes, n_nodes)), 1)\n mask_layer = mask_lower * input_layer + mask_upper\n mask_layer = mask_layer + 0 * K.eye(n_nodes)... | [
"0.71165323",
"0.7075206",
"0.7071419",
"0.69743407",
"0.6725347",
"0.6511336",
"0.6511336",
"0.62604046",
"0.6201142",
"0.61417633",
"0.6057791",
"0.6053653",
"0.5998028",
"0.5972897",
"0.5966857",
"0.5955956",
"0.5906229",
"0.58919215",
"0.58829355",
"0.5867445",
"0.5865584... | 0.7286914 | 0 |
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a softmax on just the nonmasked portions of ``vector``. Passing ``None`` in for the mask is also acceptable; you'll just get a regular softmax. We assume that both ``vector`` and ``mask`` (if given) have... | def masked_softmax(vector, mask):
if mask is None:
result = torch.nn.functional.softmax(vector)
else:
# To limit numerical errors from large vector elements outside mask, we zero these out
mask = mask.type(torch.cuda.FloatTensor)
result = torch.nn.functional.softmax(vector * mask... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_log_softmax(vector, mask):\n if mask is not None:\n mask = mask.float()\n vector = vector + mask.log()\n return torch.nn.functional.log_softmax(vector)",
"def masked_log_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1) -> torch.Tensor:\n if mask is not None:\n ... | [
"0.7535603",
"0.7293102",
"0.6928308",
"0.6838001",
"0.66837287",
"0.6578135",
"0.6423333",
"0.64198464",
"0.62158144",
"0.60617775",
"0.60617775",
"0.6005175",
"0.5972017",
"0.5943187",
"0.59140325",
"0.59140325",
"0.59057933",
"0.59057933",
"0.588318",
"0.57248515",
"0.5694... | 0.8542619 | 0 |
Replaces all masked values in ``tensor`` with ``replace_with``. ``mask`` must be broadcastable to the same shape as ``tensor``. We require that ``tensor.dim() == mask.dim()``, as otherwise we won't know which dimensions of the mask to unsqueeze. | def replace_masked_values(tensor, mask, replace_with):
# We'll build a tensor of the same shape as `tensor`, zero out masked values, then add back in
# the `replace_with` value.
mask = mask.type(torch.cuda.FloatTensor)
one_minus_mask = 1.0 - mask
values_to_add = replace_with * one_minus_mask
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_nans(tensor, replace_with=0.):\n mask = tensor == tensor\n output = torch.full_like(tensor, replace_with)\n output[mask] = tensor[mask]\n return output",
"def zero_by_mask(mask, vals, replace_with=0.0):\n assert mask.dtype == tf.as_dtype(np.bool)\n ms = mask.get_shape().as_list()\n vs =... | [
"0.6893617",
"0.6622081",
"0.6090168",
"0.6028957",
"0.6028957",
"0.59458894",
"0.5904072",
"0.5835109",
"0.56860477",
"0.5659949",
"0.55450374",
"0.5537312",
"0.55277264",
"0.5478058",
"0.5342162",
"0.5332975",
"0.53244233",
"0.53127044",
"0.5261783",
"0.52472067",
"0.524595... | 0.81713766 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.