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 |
|---|---|---|---|---|---|---|
Generates a random ID of n number of elements. | def id_generator(n, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(n)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_id(n: int = 5):\n\n return ''.join(random.choices(string.ascii_lowercase + string.digits, k=n)).lower()",
"def make_id_dict(n=5, int_len=8, keyname='id'):\n values = [generate_random_int(int_len) for i in range(n)]\n return {keyname: values}",
"def id_generator(size=6, chars=string.ascii_lo... | [
"0.7711474",
"0.72350776",
"0.70949394",
"0.7093684",
"0.7090876",
"0.7030385",
"0.70089173",
"0.6972072",
"0.69661176",
"0.69163483",
"0.68460906",
"0.681665",
"0.68084586",
"0.6808248",
"0.67791635",
"0.674715",
"0.6740107",
"0.66610134",
"0.6639413",
"0.6632142",
"0.663198... | 0.778758 | 0 |
Attempts to convert a binary array to a string without trailing spaces. | def format_param(self, param):
try:
out = param.decode(self.decodeFormat).strip(' ')
except:
pdb.set_trace()
print(param)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binToStr(binary):\n string = ''\n\n while 0 < len(binary):\n string += chr(int(binary.pop(), 2))\n\n string = string.strip('\\x00')\n\n return string",
"def bitarray_to_string(cls,ba):\n return ba.__repr__()[10:len(ba.__repr__())-2]",
"def char_array_to_string(arr):\n return arr.tost... | [
"0.71047425",
"0.7024827",
"0.6836232",
"0.67201614",
"0.657427",
"0.6478047",
"0.6358435",
"0.62805575",
"0.6242268",
"0.61465114",
"0.6116572",
"0.6017497",
"0.59979993",
"0.59969205",
"0.5987377",
"0.5942185",
"0.5928272",
"0.5884705",
"0.5883855",
"0.58541703",
"0.5828049... | 0.0 | -1 |
Initialize the metric object as a child, i.e. when it has labels (if any) set. This is factored as a separate function to allow for deferred initialization. | def _metric_init(self): # pragma: no cover
raise NotImplementedError('_metric_init() must be implemented by %r' % self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_metrics(self):\n raise NotImplementedError()",
"def __init__(self, metric: str = 'ConfusionMatrixMetric'):\n super().__init__(metric)\n self.confusion_matrix = None # ConfusionMatrix",
"def __init__(__self__, *,\n metric: str,\n value: float):\n ... | [
"0.66170615",
"0.62155783",
"0.6177482",
"0.6140618",
"0.60817593",
"0.6061672",
"0.6045636",
"0.6028152",
"0.58914983",
"0.58592",
"0.57655513",
"0.5756875",
"0.572345",
"0.5684962",
"0.5680658",
"0.5660091",
"0.5615302",
"0.56020296",
"0.56000435",
"0.5567396",
"0.5558202",... | 0.6894452 | 0 |
Changes every image to a gray image | def turnImageToGray(image_path):
img_obj = loadImage(image_path)
return cv2.cvtColor(img_obj, gray_scale) # change image to gray | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greyscale(self, *args):\n if not args:\n args = self.images.keys()\n for i in args:\n self.images[i] = cv2.cvtColor(self.images[i], cv2.COLOR_BGR2GRAY)",
"def gray():\r\n check()\r\n # check if any image is loaded\r\n\r\n global img, allundo\r\n img=img.graysca... | [
"0.7937894",
"0.71015793",
"0.70886505",
"0.7017131",
"0.69264334",
"0.69051594",
"0.686505",
"0.6765255",
"0.6640941",
"0.6635768",
"0.65772253",
"0.65389514",
"0.6496378",
"0.6476765",
"0.64435285",
"0.64002526",
"0.63391876",
"0.63307494",
"0.62907803",
"0.62652427",
"0.62... | 0.61932385 | 27 |
saves the gray image as gray_imageName.imagetype | def saveImage(image, newImageName):
cv2.imwrite(newImageName, image) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gray():\r\n check()\r\n # check if any image is loaded\r\n\r\n global img, allundo\r\n img=img.grayscale() # convert and store the Image class file\r\n\r\n allundo.append(img) # saves an instant to have the previous states later\r\n\r\n # save in a temporary file and view the image\r\n \r\... | [
"0.71804225",
"0.6842731",
"0.6764352",
"0.67374694",
"0.6633879",
"0.6588725",
"0.65559447",
"0.65542346",
"0.6543403",
"0.65430766",
"0.65401953",
"0.6530263",
"0.6520567",
"0.6507579",
"0.6471066",
"0.6466114",
"0.6448078",
"0.6439442",
"0.6406077",
"0.63337827",
"0.632362... | 0.65063775 | 14 |
Return the private IP address of the node. | def ip_address(self) -> str:
return self.params.get("ip") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ip_address(self) -> str:\n return pulumi.get(self, \"private_ip_address\")",
"def private_ip(self) -> str:\n return pulumi.get(self, \"private_ip\")",
"def private_ip(self):\n return self._private_ip",
"def private_ip(self):\n return self._private_ip",
"def private_i... | [
"0.8628727",
"0.8531572",
"0.825755",
"0.825755",
"0.81608826",
"0.81608826",
"0.8128364",
"0.7727676",
"0.766714",
"0.766714",
"0.766714",
"0.7478324",
"0.74469995",
"0.7423222",
"0.73306155",
"0.72095776",
"0.72095776",
"0.72095776",
"0.72095776",
"0.72095776",
"0.72095776"... | 0.6790603 | 79 |
Return root password for the machine | def root_password(self) -> str:
return self.params.get("root_password", "passwd") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_password(self):\n return self._root_password",
"def root_password(self) -> Optional[str]:\n return pulumi.get(self, \"root_password\")",
"def get_password():\n return getpass.getpass()",
"def password(self):\n return self._server.password",
"def password(self) -> str:\n ... | [
"0.8297325",
"0.80976284",
"0.73293906",
"0.7195042",
"0.71679425",
"0.7101054",
"0.7098648",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
"0.70637286",
... | 0.83864087 | 0 |
Return the shortform of the hostname. | def shortname(self) -> str:
return self.hostname.split(".")[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_hostname(hostname: str) -> str:\n return hostname.split(\".\")[0]",
"def short_name(hostname):\n m = short_name.p.match(hostname)\n if m:\n return m.group('name')\n return hostname",
"def hostname(long=False):\n if long:\n rval = socket.gethostname()\n else:\n r... | [
"0.8624433",
"0.82592547",
"0.7572653",
"0.7310991",
"0.72680134",
"0.71974134",
"0.7173261",
"0.705357",
"0.6912254",
"0.6900875",
"0.68183583",
"0.6802902",
"0.6797644",
"0.6785571",
"0.6771488",
"0.6761981",
"0.67429703",
"0.672568",
"0.672568",
"0.672568",
"0.6714901",
... | 0.8444915 | 1 |
Evaluates trained model on data from ``loader`` or ``self.loaders.validation`` if the former is not specified. | def evaluate(self, description, loader=None, preserve_states=False, *args, **kwargs):
self.clear_stats()
loader = loader or self.loaders.validation
if self.model is None:
raise ValueError('You must train the model first.')
self.model = self.model.eval()
progress_bar ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self):\n\n def _evaluate(_model, data_loader_label, label):\n # dist.barrier()\n if self.conf.graph.rank == 0:\n print(f\"Evaluating: {data_loader_label}---{label}.\")\n\n # define stat.\n tracker = RuntimeTracker(\n metr... | [
"0.71640503",
"0.684841",
"0.6736764",
"0.66778857",
"0.6641558",
"0.6605937",
"0.6604189",
"0.65711987",
"0.6517206",
"0.6499514",
"0.6419593",
"0.63666326",
"0.6353445",
"0.6348328",
"0.6323784",
"0.6315656",
"0.6310883",
"0.63025117",
"0.6302205",
"0.6286207",
"0.62607145"... | 0.6326304 | 14 |
Returns the config information | def load_config(simulator=[]):
_config = dict()
# This is global
_log_file = '{}/log.yaml'.format(os.getenv('POCS'))
_config_file = '{}/config.yaml'.format(os.getenv('POCS'))
if not os.path.exists(_config_file):
sys.exit("Problem loading config file, check that it exists: {}".format(_confi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self):\n\n request_path = \"{api_path}info\".format(api_path=self.api_path)\n return self.connection.get_request(request_path)",
"def get_config(self):\n return self.config.config",
"def get_config(self):\n return self.full_config",
"def get_config(self):\n r... | [
"0.8339613",
"0.81032205",
"0.8093094",
"0.8071654",
"0.8071654",
"0.80658",
"0.8008371",
"0.79585564",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"0.7907044",
"... | 0.0 | -1 |
This function creates new columns in pandas.DataFrame uses existing columns with category datatype as input and pd.get_dummies for creation. | def Dummies(df):
columns=['availability','unit','salesIndex','campaignIndex']
dumm=pd.get_dummies(df[columns])
df=pd.concat([df, dumm], axis=1)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_dummies(df, col):\n dummyfied_col = pd.get_dummies(df[col], prefix=col)\n df = df.join(dummyfied_col)\n\n return df",
"def dummify_var(df, cat_vars, drop=False):\n return pd.get_dummies(df, columns=cat_vars, drop_first=drop)",
"def dummies(\n data: pd.DataFrame,\n columns_to_convert... | [
"0.747519",
"0.7300482",
"0.7249321",
"0.721315",
"0.71317536",
"0.7009983",
"0.70016056",
"0.6894592",
"0.6888001",
"0.6868532",
"0.6860225",
"0.6843709",
"0.6718383",
"0.6713121",
"0.6672791",
"0.6666739",
"0.6622291",
"0.6621842",
"0.6568191",
"0.6562943",
"0.65578705",
... | 0.7534264 | 0 |
This function creates new columns in items DataFrame uses existing columns with category datatype and high cardinality as input. | def solveCategorical(c1,df1,df2,flag):
columns=['group','content','pharmForm','category','manufacturer']
for L in range(1, 4):
for col in it.combinations(columns, L):
t1=df1.groupby(list(col))
t2=t1[c1].mean()
str1='_'.join(col)
t2 = t2.reset_index()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toCategorical(df):\n columns=['availability','group','content','unit','pharmForm',\n 'campaignIndex','salesIndex', 'category', 'manufacturer']\n for col in columns:\n if col in df.columns:\n df[col]=df[col].astype('category')\n return df",
"def _make_feature_columns() -... | [
"0.6087613",
"0.59613305",
"0.59036523",
"0.58002806",
"0.57382137",
"0.5665432",
"0.5610085",
"0.55897766",
"0.5514973",
"0.5514095",
"0.55065864",
"0.55038416",
"0.54450965",
"0.54238373",
"0.53741664",
"0.53675276",
"0.53495115",
"0.5334186",
"0.53276825",
"0.52980447",
"0... | 0.0 | -1 |
Number of shares or contracts held currently in the portfolio. Positive value means this is a Long position Negative value corresponds to a Short position. | def quantity(self) -> int:
return self._quantity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_number_of_shares(self):\n return self.current_number_of_shares",
"def num_shares(self):\n num_shares = 0.\n for s in self.book:\n num_shares += s.num_\n return num_shares",
"def total_shares(portfolio): #8 points\n #initialize total to 0\n total = 0\... | [
"0.71198153",
"0.7003025",
"0.6660272",
"0.6554182",
"0.65098596",
"0.62759906",
"0.62290984",
"0.6155938",
"0.6046269",
"0.599648",
"0.5970569",
"0.5938923",
"0.5911335",
"0.58772904",
"0.58729094",
"0.57516545",
"0.5697809",
"0.5683923",
"0.56679845",
"0.5662875",
"0.565121... | 0.0 | -1 |
Sum of all commissions of transactions. | def total_commission(self) -> float:
return self._commission | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allcommission_sum(self):\n return self.descendants.aggregate(models.Sum(\"commission\"))[\"commission__sum\"] or Decimal(\"0\")",
"def sum_all_emissions(self):\n sum = Emission()\n for emission in self.emissions_by_step:\n sum += emission\n return sum",
"def totals(se... | [
"0.7400442",
"0.64810896",
"0.640559",
"0.6349972",
"0.6336648",
"0.6333689",
"0.61875683",
"0.6174145",
"0.6100267",
"0.6094495",
"0.60427946",
"0.6009539",
"0.6001818",
"0.5957363",
"0.59424907",
"0.59383285",
"0.59309185",
"0.58776164",
"0.5854826",
"0.58535135",
"0.584610... | 0.60040593 | 12 |
Calculates the distance between two gps coordinates using the Haversine forumla | def haversine(coords1, coords2):
lat1, lon1, lat2, lon2 = map(math.radians, [coords1[0], coords1[1], coords2[0], coords2[1]])
dlat = lat2 - lat1
dlon = lon2 - lon1
a = math.sin(dlat / 2.) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2.) ** 2
c = 2 * math.asin(math.sqrt(a))
dist = E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2):\n d_lat = to_rad(latitude_1 - latitude_2)\n d_lon = to_rad(longitude_1 - longitude_2)\n lat1 = to_rad(latitude_1)\n lat2 = to_rad(latitude_2)\n\n #pylint: disable=invalid-name\n a = math.sin(d_lat/2) * math.sin(d_lat/2) + \... | [
"0.80088145",
"0.80087125",
"0.7915842",
"0.78985864",
"0.7895133",
"0.7865851",
"0.7720843",
"0.7701787",
"0.7632024",
"0.7598163",
"0.7538684",
"0.7538684",
"0.74871886",
"0.7471168",
"0.74659604",
"0.7450768",
"0.74491274",
"0.7436734",
"0.7431341",
"0.740932",
"0.7391105"... | 0.74727005 | 14 |
Places RHT data into cube binned by theta. | def bin_data_by_theta(data_fn, nbins = 10):
# Separate into indices and R(theta) arrays
ipoints, jpoints, rthetas, naxis1, naxis2 = RHT_tools.get_RHT_data(data_fn)
npoints, nthetas = rthetas.shape
print("There are %d theta bins" %nthetas)
cube_thetas = np.zeros((naxis2, naxis1, nthetas), np.float_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coadd_by_angle():\n # Define channels\n channels = [19, 20]\n \n # Number of desired theta bins\n nthetabins = 10\n \n # Initial data\n data, data_fn = get_data(channels[0], verbose = False)\n theta_separated_backprojection = bin_data_by_theta(data_fn, nbins = nthetabins)\n \n ... | [
"0.5203124",
"0.5118028",
"0.49823174",
"0.49736643",
"0.48941532",
"0.48615158",
"0.47762793",
"0.47750604",
"0.4768607",
"0.47336742",
"0.47265238",
"0.47172964",
"0.47154328",
"0.46970263",
"0.46193624",
"0.4613842",
"0.4612993",
"0.45967472",
"0.4572803",
"0.4547748",
"0.... | 0.5685577 | 0 |
Make a gaussian footprint | def make_gaussian_footprint(theta_0 = 0, wlen = 50):
fp = np.zeros((wlen, wlen), np.float_)
mnvals = np.indices(fp.shape)
mvals = mnvals[:, :][0] # These are the y points
nvals = mnvals[:, :][1] # These are the x points
initial_cov = np.asarray([[10, 0], [0, 1]])
psi = np.radians(theta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _makeGaussian(self, height, width, sigma = 3, center=None):\n\t\tx = np.arange(0, width, 1, float)\n\t\ty = np.arange(0, height, 1, float)[:, np.newaxis]\n\t\tif center is None:\n\t\t\tx0 = width // 2\n\t\t\ty0 = height // 2\n\t\telse:\n\t\t\tx0 = center[0]\n\t\t\ty0 = center[1]\n\t\treturn np.exp(-4*np.log(2... | [
"0.71789294",
"0.7137438",
"0.7039902",
"0.7005107",
"0.6985983",
"0.69275147",
"0.69242704",
"0.6896969",
"0.6880216",
"0.68795776",
"0.6878017",
"0.6863631",
"0.6851588",
"0.68349427",
"0.68349427",
"0.68335885",
"0.68081325",
"0.6791924",
"0.67772216",
"0.67570585",
"0.674... | 0.6705417 | 22 |
return command line argument list. | def get_query() -> List:
if len(sys.argv) <= 1:
print("Please provide valid query arguments.")
sys.exit(0)
return sys.argv[1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def args(self) -> List[str]:\n cmd: List[str] = self._data.get(\"cmd\", [])\n assert len(cmd)\n for x in cmd:\n assert isinstance(x, str)\n return cmd[1:]",
"def GetCommandLineArgs():\n pass",
"def args(self):\n return self.parser.parse_args()",
"def list_argume... | [
"0.77183074",
"0.7609149",
"0.7559782",
"0.74468493",
"0.7409455",
"0.73312145",
"0.7323776",
"0.7323776",
"0.7323776",
"0.7323776",
"0.7323776",
"0.7323776",
"0.72713464",
"0.7246728",
"0.7234998",
"0.72174925",
"0.72126585",
"0.7209498",
"0.7196506",
"0.71908075",
"0.716431... | 0.0 | -1 |
Normalize features for every sample Example features = [[3, 4], [1, 1], [0, 0]] return [[0.6, 0.8], [0.707107, 0.707107], [0, 0]] | def __call__(self, features):
nom_features = []
for feature in features:
s = 0
nom_feature = []
for i in range(len(feature)):
s += feature[i] ** 2
for i in range(len(feature)):
if s == 0:
nom_feature.appe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_features(inputs):\n # for all columns\n for i in range(inputs.shape[1]):\n inputs[:, i] -= np.mean(inputs[:, i])\n inputs[:, i] /= np.std(inputs[:, i])\n return inputs",
"def feature_normalize(x: np.array):\n def normalize(vec):\n return (vec - np.mean(vec)) / np.st... | [
"0.8114281",
"0.8082939",
"0.7660298",
"0.7616847",
"0.7577924",
"0.75718534",
"0.7562279",
"0.7509543",
"0.7467378",
"0.7424207",
"0.7395885",
"0.735149",
"0.7317382",
"0.72203916",
"0.7170238",
"0.7164845",
"0.7135004",
"0.7126796",
"0.7126506",
"0.7115388",
"0.7110177",
... | 0.0 | -1 |
normalize the feature vector for each sample . For example, if the input features = [[2, 1], [1, 5], [0, 0]], the output should be [[1, 0], [0, 1], [0.333333, 0.16667]] | def __call__(self, features):
self.count+=1
if self.count<=1:
for i in range(len(features[0])):
max = 0
min = 0
for j in range(len(features)):
if max<features[j][i]:
max=features[j][i]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_normalize(x: np.array):\n def normalize(vec):\n return (vec - np.mean(vec)) / np.std(vec)\n\n for i in range(1, x.shape[1]):\n x[:, i] = normalize(x[:, i])",
"def normalize_features(inputs):\n # for all columns\n for i in range(inputs.shape[1]):\n inputs[:, i] -= np.m... | [
"0.81923556",
"0.78645223",
"0.7715758",
"0.7694661",
"0.7653671",
"0.7424455",
"0.74186385",
"0.73874384",
"0.72381645",
"0.7234837",
"0.71674836",
"0.71590984",
"0.7150417",
"0.71415025",
"0.71103007",
"0.71049637",
"0.70212287",
"0.7019126",
"0.7013339",
"0.6986395",
"0.69... | 0.0 | -1 |
Creates our model with access to intermediate layers. This function will load the VGG19 model and access the intermediate layers. These layers will then be used to create a new model that will take input image and return the outputs from these intermediate layers from the VGG model. | def get_model(style_layers, content_layers):
# Load our model. We load pretrained VGG, trained on imagenet data
vgg = tf.keras.applications.vgg19.VGG19(include_top=False, weights='imagenet')
vgg.trainable = False
# Get output layers corresponding to style and content layers
style_outputs = [vgg.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(self):\n VGG19_model = tf.keras.applications.VGG19(include_top=False,\n weights='imagenet')\n VGG19_model.save(\"VGG19_base_model\")\n custom_objects = {'MaxPooling2D': tf.keras.layers.AveragePooling2D}\n\n vgg = tf.keras.m... | [
"0.78287303",
"0.7525899",
"0.74115026",
"0.72314626",
"0.7092963",
"0.70835793",
"0.70629346",
"0.706238",
"0.70358026",
"0.7018425",
"0.6997379",
"0.69502056",
"0.6938333",
"0.68114996",
"0.67071366",
"0.67071366",
"0.6697961",
"0.66642195",
"0.66519094",
"0.66466",
"0.6616... | 0.70098084 | 10 |
Method to calculate Distance between two sets of Lat/Lon. Modified from Amyth's StackOverflow answer of 22/5/2012; | def HaversineDistance(location1, location2):
lat1 = location1.lat
lon1 = location1.lon
lat2 = location2.lat
lon2 = location2.lon
earth = 6378137 #Earth's equatorial radius in metres.
#Calculate distance based on Haversine Formula
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance_between_points(lat1,lon1,lat2,lon2):\n \treturn Geodesic.WGS84.Inverse(lat1,lon1, lat2, lon2)['s12']",
"def distance(latitudes, longitudes, lat, lon):\n delta_lat = latitudes - lat\n delta_lon = longitudes - lon\n return numpy.sqrt(delta_lat ** 2 + delta_lon ** 2)",
"def distance(lat1... | [
"0.7692516",
"0.76182914",
"0.75574106",
"0.75084513",
"0.7491952",
"0.74814045",
"0.7391052",
"0.7368058",
"0.7363073",
"0.73212606",
"0.7232648",
"0.719606",
"0.7185747",
"0.71768284",
"0.7165111",
"0.71514624",
"0.71510524",
"0.71487355",
"0.7127762",
"0.7097668",
"0.70591... | 0.0 | -1 |
Blurs the image and then apply a threshold filter | def safeblur(img, avg_size, thr):
blur = cv2.GaussianBlur(img, (avg_size, avg_size), 0)
blur = rescalevalues(blur)
img_thres2 = thresholder(blur, thr)
return img_thres2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _threshold_image(self, img):\n #print(\"Apply thresholding to image\")\n abs_image = self._abs_sobel_thresh(img, thresh=(90,255))\n mag_grad_image = self._mag_thresh(img, mag_thresh=(110,255))\n dir_image = self._dir_threshold(img, sobel_kernel=15, thresh=(0.7, 1.3))\n s_imag... | [
"0.716214",
"0.68943167",
"0.6872891",
"0.68549514",
"0.68074316",
"0.67948496",
"0.6781292",
"0.6694311",
"0.667334",
"0.667078",
"0.6558705",
"0.65551317",
"0.6516151",
"0.65062904",
"0.65062904",
"0.64611655",
"0.6458584",
"0.6458584",
"0.6450899",
"0.64332306",
"0.6432687... | 0.64635706 | 15 |
Applies the threshold filter (if the pixel value is under lv it is black, else white) | def thresholder(blur, lv):
_img = numpy.zeros((len(blur), len(blur[0])))
for i in range(0, len(blur)):
for j in range(0, len(blur[0])):
if blur[i, j] < lv:
_img[i, j] = 0
else:
_img[i, j] = 255
return _img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thresholding(im, threshold):\n im[im < threshold] = 0\n im[im >= threshold] = 1\n return im",
"def ThresholdPixels(pixels, threshold=0.0001):\n pixels[pixels < threshold] = 0\n pixels[pixels >= threshold] = 1",
"def apply_threshold(heatmap, threshold):\n heatmap[heatmap <= threshold] = 0\... | [
"0.69616824",
"0.67154855",
"0.6707009",
"0.66686654",
"0.66686654",
"0.66442275",
"0.6547749",
"0.65182084",
"0.6498496",
"0.644885",
"0.63830495",
"0.62575394",
"0.6186154",
"0.61843646",
"0.6158736",
"0.61554354",
"0.6139608",
"0.6118008",
"0.61077297",
"0.6103391",
"0.608... | 0.7232499 | 0 |
blur image with given blur type | def blur_img(img_f, blur_type):
if not os.path.exists(LR_DIR):
os.makedirs(LR_DIR)
img = cv2.imread(img_f)
if blur_type == 'Avg':
kernerl_size = random.randint(5, 10)
blurry_img = cv2.blur(img, (kernerl_size, kernerl_size)) # Avg Blur
cv2.imwrite(os.path.join(LR_DIR, img_f.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Blur(*args, **kwargs):\n return _core_.Image_Blur(*args, **kwargs)",
"def blur(img):\n\n new_img = SimpleImage.blank(img.width, img.height)\n\n for r in range(img.height):\n for c in range(img.width):\n pixel = img.get_pixel(c, r)\n pixel_blur = new_img.get_pixel(c, ... | [
"0.78753656",
"0.7728113",
"0.75207627",
"0.7396505",
"0.7361843",
"0.7345597",
"0.72885454",
"0.72243387",
"0.71660703",
"0.7163727",
"0.71319276",
"0.71292526",
"0.70614254",
"0.7015341",
"0.69790965",
"0.6976411",
"0.69369483",
"0.6899597",
"0.6889134",
"0.6841938",
"0.681... | 0.7940246 | 0 |
Applies the ``torch.quantize_per_tensor`` logic to DDP using ``allgather`` protocol. Workers first allgather the scale and zero point of their own ``GradBucket`` prior to the quantization. After all workers have that information, the first ``then`` callback called ``quantize_and_allgather`` quantizes worker's own gradi... | def quantization_pertensor_hook(
process_group: dist.ProcessGroup, bucket: dist.GradBucket
) -> torch.futures.Future:
group_to_use = process_group if process_group is not None else dist.group.WORLD
rank = process_group.rank() if process_group is not None else dist.get_rank()
world_size = group_to_u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantization_perchannel_hook(\r\n process_group: dist.ProcessGroup, bucket: dist.GradBucket, bucket_size=512\r\n) -> torch.futures.Future:\r\n group_to_use = process_group if process_group is not None else dist.group.WORLD\r\n rank = process_group.rank() if process_group is not None else dist.get_rank... | [
"0.602256",
"0.55252707",
"0.5508379",
"0.5507275",
"0.5324772",
"0.5213951",
"0.5180836",
"0.510841",
"0.5049357",
"0.4967025",
"0.49668744",
"0.49313566",
"0.49167925",
"0.4856525",
"0.48405403",
"0.47934368",
"0.47809795",
"0.47499767",
"0.47478214",
"0.47478214",
"0.47478... | 0.6721358 | 0 |
Applies the ``torch.quantize_per_channel`` logic to DDP using ``allgather`` protocol. Compared to pertensor, the main motivation of perchannel is for considerably large tensors such as a tensor that contains 6 million elements quantizing per a bucket size of 512 (or 128) elements may significantly increase the resoluti... | def quantization_perchannel_hook(
process_group: dist.ProcessGroup, bucket: dist.GradBucket, bucket_size=512
) -> torch.futures.Future:
group_to_use = process_group if process_group is not None else dist.group.WORLD
rank = process_group.rank() if process_group is not None else dist.get_rank()
world... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantization_pertensor_hook(\r\n process_group: dist.ProcessGroup, bucket: dist.GradBucket\r\n) -> torch.futures.Future:\r\n group_to_use = process_group if process_group is not None else dist.group.WORLD\r\n rank = process_group.rank() if process_group is not None else dist.get_rank()\r\n world_si... | [
"0.6754321",
"0.54265934",
"0.5410167",
"0.5185607",
"0.49571896",
"0.49422127",
"0.49099907",
"0.4877862",
"0.48258203",
"0.47935143",
"0.46728885",
"0.46623728",
"0.46414518",
"0.4575314",
"0.45688543",
"0.45503706",
"0.45090455",
"0.4487074",
"0.44447023",
"0.44002837",
"0... | 0.74660265 | 0 |
function to convert a number in the assigned month | def deMonth(m):
if m == 1:
return "Enero"
elif m == 2:
return "Febreo"
elif m == 3:
return "Marzo"
elif m == 4:
return "Abril"
elif m == 5:
return "Mayo"
elif m == 6:
return "Junio"
elif m == 7:
return "Julio"
elif m == 8:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def m(dt):\n return '%02d' % dt.month",
"def time_to_month(time):\n\treturn str(time)[4:6]",
"def get_month(dataset, date):\n dataset['month'] = (dataset[date] % 10 ** 6 // 10000).astype(int)\n # return(['month'])",
"def from_int(month_int: int) -> 'Month':\n year = month_int // 12\n ... | [
"0.74779284",
"0.7272932",
"0.72232956",
"0.71008074",
"0.7009622",
"0.68534493",
"0.6821199",
"0.6789497",
"0.67818046",
"0.67615974",
"0.67251915",
"0.66927886",
"0.65655285",
"0.65547925",
"0.6550052",
"0.6513428",
"0.6501169",
"0.64970446",
"0.64779145",
"0.6400693",
"0.6... | 0.6882295 | 5 |
Parse and return the commandline arguments. | def parse_args():
parser = argparse.ArgumentParser(
description='Retrieve movie box office sales figures for fridays within the given range.')
parser.add_argument(
'start_date', help='the start date for the data scraping (inclusive).')
parser.add_argument(
'end_date', help='the end d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_args(self):\n return self.parser.parse_args()",
"def args(self):\n return self.parser.parse_args()",
"def parse_args():\n parser = argparse.ArgumentParser()\n build_args(parser)\n args = parser.parse_args()\n return args",
"def _parse_command_line_arguments():\n parser ... | [
"0.7775303",
"0.77435166",
"0.7740846",
"0.75675565",
"0.75388634",
"0.7524652",
"0.75242186",
"0.7523293",
"0.75105053",
"0.7483709",
"0.7459201",
"0.7398859",
"0.7390369",
"0.7383153",
"0.7352838",
"0.73440534",
"0.73070514",
"0.72909373",
"0.7284111",
"0.72810376",
"0.7274... | 0.71136457 | 54 |
Generates two 128bit keys from the given password using PBKDF2SHA256. We use PBKDF2SHA256 because we want the native output of PBKDF2 to be 256 bits. If we stayed at the default of PBKDF2SHA1, then the entire algorithm would run twice, which is slow for normal users, but doesn't slow things down for attackers. password... | def make_keys(password, salt=None, iterations=100000):
if salt is None:
# Generate a random 8-byte salt
salt = Random.new().read(8)
# Generate a 32-byte (256-bit) key from the password
# prf = lambda p, s: HMAC.new(p, s, SHA256).digest()
key = PBKDF2(password, salt, 32, iterations)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_keys(password, salt=None, iterations=100000):\n if salt is None:\n # Generate a random 16-byte salt\n salt = Random.new().read(16)\n\n # Generate a 32-byte (256-bit) key from the password\n prf = lambda p,s: HMAC.new(p, s, SHA256).digest()\n key = PBKDF2(password, salt, 32, itera... | [
"0.7812464",
"0.7451189",
"0.73334706",
"0.68932194",
"0.6877169",
"0.68700826",
"0.6818897",
"0.66975754",
"0.66500163",
"0.66260755",
"0.65964866",
"0.64180315",
"0.62307316",
"0.6125497",
"0.61195517",
"0.60969853",
"0.6038151",
"0.59985965",
"0.5965297",
"0.5948787",
"0.5... | 0.78016174 | 1 |
Encrypts a given message with the given key, using AESCFB. message The message to encrypt (byte string). key The AES key (16 bytes). returns (ciphertext, iv). Both values are byte strings. | def encrypt(message, key):
# The IV should always be random
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
ciphertext = cipher.encrypt(message)
return (ciphertext, iv) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_ecb_block(message, key):\n if len(message) % len(key) != 0:\n message = set_two.implement_pkcs_padding(message, 16)\n encryptor = Cipher(\n AES(key), ECB(), backend=default_backend()\n ).encryptor()\n return encryptor.update(message) + encryptor.finalize()",
"def _encrypt(me... | [
"0.75761235",
"0.7080325",
"0.70403033",
"0.7034198",
"0.69967",
"0.687166",
"0.6767157",
"0.67483",
"0.6741113",
"0.6660601",
"0.6611643",
"0.6577687",
"0.6567749",
"0.655019",
"0.651048",
"0.6507285",
"0.6504757",
"0.64895016",
"0.6470408",
"0.6412208",
"0.6382271",
"0.63... | 0.83600897 | 0 |
Override tornado's xsrf cookie check. S3 doesn't require XSRF, so we won't expect it for the file object store in the local server. | def check_xsrf_cookie(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_xsrf_cookie(self):\r\n token = (self.get_argument(\"_xsrf\", None) or\r\n self.request.headers.get(\"X-Xsrftoken\") or\r\n self.request.headers.get(\"X-Csrftoken\"))\r\n if not token:\r\n raise HTTPError(403, \"'_xsrf' argument missing from POST\")... | [
"0.7112589",
"0.7112589",
"0.7050491",
"0.702875",
"0.6145424",
"0.6093435",
"0.6091407",
"0.60626113",
"0.59989053",
"0.59989053",
"0.58626163",
"0.584505",
"0.5751428",
"0.57365894",
"0.5729026",
"0.57204175",
"0.56340116",
"0.5561076",
"0.5556977",
"0.5544383",
"0.5535387"... | 0.7014792 | 4 |
Randomly roll a vector to the left or to the right. We fill the otherside with 0s | def roll_x(self, x):
x = x.reshape(-1)
roll_idx = int(self.roll*self.sample)
roll_offset = np.random.randint(-roll_idx, +roll_idx)
left_extra = 0 if roll_offset <= 0 else roll_offset
right_extra = 0 if roll_offset >= 0 else -roll_offset
extra = ((left_extra), (right_extra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll(self):\n self.value = randint(1, self.max_value)",
"def roll(a, b):\n return random.randint(a, b)",
"def roll(self):\n return randint(1, self.sides)",
"def roll(self):\n self.value = randint(1, 6)",
"def roll(self):\n return randint(1, self.nsides)",
"def roll(self... | [
"0.69265395",
"0.67724365",
"0.6725304",
"0.6707039",
"0.6667631",
"0.66436404",
"0.6641144",
"0.645561",
"0.64439666",
"0.6427352",
"0.6386948",
"0.6067414",
"0.6028569",
"0.60089034",
"0.5998875",
"0.595684",
"0.58146757",
"0.5812528",
"0.58031064",
"0.57873535",
"0.5754135... | 0.7088087 | 0 |
Check that the form correctly raises an error when the slug is too long. The path built by combining the slug of the page with the slug of its parent page, should not exceed 255 characters in length. | def test_cms_wizards_subject_submit_form_max_lengths(self):
# A parent page with a very long slug
create_page(
"y" * 200, "richie/fullwidth.html", "en", reverse_id=Subject.ROOT_REVERSE_ID
)
# A subject with a slug at the limit length should work
form = SubjectWizardF... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cms_wizards_subject_submit_form_slug_too_long(self):\n # A parent page should pre-exist\n create_page(\n \"Sujects\", \"richie/fullwidth.html\", \"en\", reverse_id=Subject.ROOT_REVERSE_ID\n )\n\n # Submit a slug that is too long and a title that is ok\n invali... | [
"0.77503026",
"0.76596594",
"0.67078805",
"0.6685946",
"0.66169167",
"0.659339",
"0.610195",
"0.605997",
"0.5843325",
"0.575583",
"0.5668593",
"0.5594042",
"0.5590796",
"0.5573187",
"0.54981774",
"0.5438828",
"0.5404969",
"0.53900623",
"0.5375312",
"0.5372417",
"0.5354875",
... | 0.7132094 | 2 |
When generating the slug from the title, we should respect the slug's "max_length" | def test_cms_wizards_subject_submit_form_slugify_long_title(self):
# A parent page should pre-exist
create_page(
"Subjects",
"richie/fullwidth.html",
"en",
reverse_id=Subject.ROOT_REVERSE_ID,
)
# Submit a title at max length
data =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self):\n if not self.slug:\n suffix = get_random_string(\n length=10, allowed_chars=string.ascii_lowercase + string.digits\n )\n\n self.slug = f\"{slugify(self.title)}-{suffix}\"",
"def slugify(story_name, max_length=25):\n # Inspired by Django.... | [
"0.768986",
"0.75367206",
"0.74175996",
"0.7397101",
"0.70296407",
"0.7024168",
"0.69581157",
"0.6950037",
"0.6945967",
"0.6816243",
"0.6815898",
"0.6806401",
"0.6770927",
"0.6724309",
"0.6638838",
"0.65879166",
"0.65815806",
"0.65666074",
"0.6563319",
"0.65323323",
"0.650604... | 0.69311196 | 9 |
Trying to set a slug that is too long should make the form invalid | def test_cms_wizards_subject_submit_form_slug_too_long(self):
# A parent page should pre-exist
create_page(
"Sujects", "richie/fullwidth.html", "en", reverse_id=Subject.ROOT_REVERSE_ID
)
# Submit a slug that is too long and a title that is ok
invalid_data = {"title":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cms_wizards_organization_submit_form_slug_too_long(self):\n # Submit a slug that is too long and a title that is ok\n invalid_data = {\"title\": \"t\" * 255, \"slug\": \"s\" * 201}\n\n form = OrganizationWizardForm(data=invalid_data)\n self.assertFalse(form.is_valid())\n ... | [
"0.77995396",
"0.74258596",
"0.7113522",
"0.6967658",
"0.6772898",
"0.6690143",
"0.66881424",
"0.6541216",
"0.6539533",
"0.64628386",
"0.6462233",
"0.64421016",
"0.6325378",
"0.6298855",
"0.6285143",
"0.6236383",
"0.62210006",
"0.6192855",
"0.6182633",
"0.618178",
"0.61685467... | 0.7593975 | 1 |
l2 norm fitness function | def fitness_function(self):
total_biomass = sum([(spec.get_biomass() * 1e12) for spec in self.culture.species_list])
fitness = 0.0
for spec_name in self.objective:
init_biomass = self.data_watcher.get_init_biomass(spec_name)
biomass = self.data_watcher.get_biomass(spec_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_L2_norm(gradient_of_cost_function):\n return np.linalg.norm(gradient_of_cost_function)",
"def fitness_F2(phenos, theta, sigma):\n\tdist = np.linalg.norm(phenos - theta) #phenotypic distance from optimum\n\tw = np.exp(-0.5 * sigma * dist**2) #fitness\n\treturn w",
"def l2(f, h):\n with tf.name... | [
"0.6652518",
"0.65588087",
"0.6507469",
"0.64840066",
"0.6478624",
"0.63999015",
"0.6319535",
"0.629568",
"0.62042046",
"0.6184405",
"0.616467",
"0.616236",
"0.61463267",
"0.61336595",
"0.60774106",
"0.60516065",
"0.6035993",
"0.6032657",
"0.59673697",
"0.5937818",
"0.5932868... | 0.0 | -1 |
Convert class labels from scalars to onehot vectors | def dense_to_one_hot(labels_dense, num_classes=2):
num_labels = labels_dense.shape[0]
#index_offset = np.arange(num_labels)# * num_classes
labels_one_hot = np.zeros((num_labels, num_classes))
#labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
index = 0
for i in range(num_labels):
if labels_dense[i] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_label(classes, label):\n m = label.shape[0]\n new_label = np.zeros((classes, m))\n for i in range(m):\n clas = label[i]\n new_label[clas,i] = 1\n return new_label",
"def one_hot(labels, n_classes):\n # n_classes = len(set(labels))\n label = np.array(labels).reshape(-1)... | [
"0.8544448",
"0.83098537",
"0.82484514",
"0.8205544",
"0.8201196",
"0.8192587",
"0.8166491",
"0.8095945",
"0.8029382",
"0.8023228",
"0.79729146",
"0.7969277",
"0.7932171",
"0.7930149",
"0.79171485",
"0.7895879",
"0.787608",
"0.78452086",
"0.78369415",
"0.7832216",
"0.78311586... | 0.75498927 | 62 |
Pads dictionary so that all columns have the same number of rows Params | def pad_dic_list(dic, pad):
lmax = 0
for lname in dic.keys():
lmax = max(lmax, len(dic[lname]))
for lname in dic.keys():
ll = len(dic[lname])
if ll < lmax:
dic[lname] += [pad] * (lmax - ll)
return dic | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_collate(self, batch):\n if isinstance(batch[0], dict):\n return {k: self.pad_collate([sample[k] for sample in batch]) for k in batch[0]}\n\n max_len = max([len(sample) for sample in batch])\n base_pad = (0, 0) * (batch[0].dim() - 1)\n for i in range(len(batch)):\n ... | [
"0.65327036",
"0.6256548",
"0.6063065",
"0.6054071",
"0.58448964",
"0.58078116",
"0.57712424",
"0.5706084",
"0.56885463",
"0.563026",
"0.554428",
"0.552122",
"0.54483575",
"0.5384175",
"0.53191847",
"0.5277573",
"0.52520305",
"0.52488214",
"0.5247734",
"0.5222681",
"0.5214931... | 0.66057235 | 0 |
Returns an I2CDevice subclass to handle ``device`` or ``None`` if one is not available. | def getDeviceClass(device: str) -> t.Union[t.Type[I2CDevice], None]:
dev_classes: t.Dict[str, t.Type[I2CDevice]] = {}
dev_classes.update(mcp230xx.SUPPORTED_DEVICES)
return dev_classes.get(device, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_device(self, device):\n use_device_noise = (self.noise == 'device')\n if device is None:\n return None\n if isinstance(device, str):\n try:\n back = get_qc(device, noisy=use_device_noise)\n return back\n except:\n ... | [
"0.6726724",
"0.67038524",
"0.65954447",
"0.65133953",
"0.62028074",
"0.6162644",
"0.61565983",
"0.61416185",
"0.61329895",
"0.6130066",
"0.61038893",
"0.6102773",
"0.610133",
"0.60921496",
"0.5981611",
"0.5957281",
"0.5948169",
"0.59415615",
"0.5863526",
"0.58557326",
"0.585... | 0.7734229 | 0 |
Starting index negative test. | def test_sub_edge_begin_neg() -> None:
assert sub([10, 20, 30, 40], -1, 3) == [10, 20, 30] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_negative(self):\r\n self._check({\"pagesize\": 15, \"pagenumber\": -2}, (15, 1))",
"def test_sub_start_is_neg() -> None:\n xs: list[int] = [0, 1, 2, 3, 5]\n assert sub(xs, -3, 3) == [0, 1, 2]",
"def negative(self):\n return self.len and self.diff[-1] < 0",
"def test_sub_end_is_ne... | [
"0.6952146",
"0.6858386",
"0.67993766",
"0.65757096",
"0.6573598",
"0.6558707",
"0.6546855",
"0.6537968",
"0.6379102",
"0.6260464",
"0.6237764",
"0.61891156",
"0.6169181",
"0.60950506",
"0.60256106",
"0.6025052",
"0.6013944",
"0.59998333",
"0.5996013",
"0.5865287",
"0.5864052... | 0.6191983 | 11 |
Ending index out of bounds test. | def test_sub_edge_end_out_of_bounds() -> None:
assert sub([10, 20, 30, 40], 1, 100) == [20, 30, 40] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def out_of_bounds(self, *args):\n pass",
"def out_of_bound(self, row, col):\n return row > self.board_size() - 1 or row < 0 or col > self.board_size() - 1 or col < 0",
"def test_slice_bad_negative_index(self):\n with self.assertRaises(IndexError):\n self.paginated_list[:-30]",
... | [
"0.73361284",
"0.707709",
"0.69337404",
"0.67770725",
"0.6757415",
"0.67171097",
"0.66379774",
"0.66051865",
"0.63369167",
"0.63101023",
"0.62764806",
"0.6243179",
"0.61749375",
"0.6150529",
"0.61491895",
"0.611813",
"0.6082136",
"0.6048502",
"0.6016771",
"0.59968305",
"0.596... | 0.6164971 | 13 |
Ending index negative test. | def test_sub_edge_neg_end() -> None:
assert sub([10, 20, 30, 40], 100, -1) == [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def negative(self):\n return self.len and self.diff[-1] < 0",
"def test_negative(self):\r\n self._check({\"pagesize\": 15, \"pagenumber\": -2}, (15, 1))",
"def _is_valid_index(self, i):\r\n n = self._count\r\n return -n <= i < n",
"def test_sub_end_is_neg() -> None:\n xs: list[... | [
"0.7064434",
"0.6660456",
"0.66316044",
"0.661237",
"0.6378287",
"0.6319854",
"0.62087846",
"0.61845016",
"0.6137223",
"0.6091073",
"0.6080893",
"0.6070431",
"0.60684615",
"0.60379934",
"0.59706163",
"0.5968411",
"0.59652895",
"0.59518135",
"0.59176373",
"0.5879601",
"0.58735... | 0.6094215 | 9 |
Returns ``DataCls`` with args, kwargs | def getdata(cls, *args, **kwargs):
return cls.DataCls(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __factory(cls, data):\n return cls(data)",
"def __factory(cls, data):\n return cls(data)",
"def __factory(cls, data):\n return cls(data)",
"def __factory(cls, data):\n return cls(data)",
"def __factory(cls, data):\n return cls(data)",
"def __factory(cls, data):\n ... | [
"0.71004033",
"0.71004033",
"0.71004033",
"0.71004033",
"0.71004033",
"0.71004033",
"0.70731425",
"0.6798897",
"0.67395854",
"0.6564071",
"0.65494037",
"0.6336311",
"0.6329168",
"0.62547016",
"0.6238797",
"0.6231678",
"0.6225139",
"0.6218488",
"0.6207604",
"0.61787677",
"0.61... | 0.83489466 | 0 |
finds how long the snake is | def selfLength(data):
return len(data["you"]["body"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_score():\n # @4.4 Return the current score, which is equal to the snake's length\n # minus its starting length.\n return 0",
"def bake_time_remaining(elasped_bake_time) -> int:\n\n return EXPECTED_BAKE_TIME - elasped_bake_time",
"def get_dry_length(self):\n if not self.dry_lyric:... | [
"0.667025",
"0.57633376",
"0.5603083",
"0.5553286",
"0.55411583",
"0.55119616",
"0.5494494",
"0.54695374",
"0.545218",
"0.5422102",
"0.5392057",
"0.5375834",
"0.53647053",
"0.5362838",
"0.53467757",
"0.5344673",
"0.5332811",
"0.5321362",
"0.5320887",
"0.53188133",
"0.53063864... | 0.0 | -1 |
Testing of method Line2d.__eq__. | def test_equal(self):
line_a = Line2d(Point2d(0.0, 2.0), Vector2d(4.0, 0.0))
line_b = Line2d(Point2d(0.0, 2.0), Vector2d(4.0, 0.0))
line_c = Line2d(Point2d(3.0, 0.0), Vector2d(0.0, 4.0))
assert_that(line_a, equal_to(line_b))
assert_that(line_a, is_not(equal_to(line_c)))
a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, *args):\n return _almathswig.Position2D___eq__(self, *args)",
"def __eq__(self, *args):\n return _almathswig.Position2D___eq__(self, *args)",
"def __eq__(self, *args):\n return _almathswig.Pose2D___eq__(self, *args)",
"def __eq__(self, *args):\n return _almathswig... | [
"0.71486616",
"0.71486616",
"0.69021404",
"0.69021404",
"0.68480533",
"0.6844759",
"0.67536104",
"0.6753524",
"0.66813827",
"0.66593945",
"0.6639934",
"0.6576576",
"0.6570551",
"0.65433955",
"0.65340436",
"0.65238976",
"0.6485256",
"0.64793694",
"0.6472707",
"0.6376852",
"0.6... | 0.75681925 | 0 |
Get the "configuration weights" for each geom, i.e. the weights chosen to evenly sample each cluster for each species. | def all_spec_config_weights(props,
ref_nxyz_dic,
spec_dic,
device,
extra_category,
extra_rmsd):
weight_dic = {}
num_geoms = len(props['nxyz'])
num_clusters = max([len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def per_spec_config_weights(spec_nxyz,\n ref_nxyzs,\n ref_idx,\n num_clusters,\n extra_category,\n extra_rmsd,\n device='cpu'):\n\n # a dictionary tha... | [
"0.70641255",
"0.6502413",
"0.6342964",
"0.6280017",
"0.62464577",
"0.6189246",
"0.61617213",
"0.6080407",
"0.6018672",
"0.60145324",
"0.60145324",
"0.60145324",
"0.594604",
"0.594604",
"0.59341466",
"0.59327936",
"0.59323066",
"0.5907227",
"0.5875486",
"0.58714193",
"0.58714... | 0.7213528 | 0 |
Combine config weights, ZhuNakamura weights, and random weights to get the final weights for each geom. | def combine_weights(balanced_config,
imbalanced_config,
balanced_zhu,
imbalanced_zhu,
balanced_rand,
imbalanced_rand,
spec_weight,
config_weight,
zhu_weight):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_weights(config):\n Ne = config[\"N\"][\"e\"]\n Ni = config[\"N\"][\"i\"]\n e_scale = config[\"scale\"][\"e\"]\n i_scale = config[\"scale\"][\"i\"]\n architecture = config[\"architecture\"]\n\n if architecture == \"small-world\":\n # Create binary weights with a small world struc... | [
"0.6536309",
"0.6407377",
"0.64008623",
"0.6309096",
"0.6268416",
"0.61848885",
"0.61562943",
"0.61477",
"0.6144344",
"0.614183",
"0.6141363",
"0.61074626",
"0.60857296",
"0.6084493",
"0.6073466",
"0.60665864",
"0.60647905",
"0.6062663",
"0.60592836",
"0.605143",
"0.60489434"... | 0.73062927 | 0 |
Add a directed edge to the graph. | def add_edge(self, v1, v2): # add 1 vert iD to the set of the source vertex
self.vertices[v1].add(v2) # add v2 as a neighbor to v1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge_directed(self, edge):\n\n edge = set(edge)\n (vertex1, vertex2) = tuple(edge)\n\n if vertex1 in self.graph_dict:\n self.graph_dict[vertex1].append(vertex2)\n else:\n self.graph_dict[vertex1] = [vertex2]",
"def addEdge(self, edge):\n src = edge... | [
"0.7879625",
"0.7598539",
"0.7531638",
"0.75199306",
"0.7519453",
"0.74541354",
"0.7421374",
"0.7410977",
"0.7408705",
"0.73501205",
"0.733787",
"0.7325284",
"0.73140705",
"0.71935874",
"0.71735585",
"0.716555",
"0.71343327",
"0.71341527",
"0.70988363",
"0.70957637",
"0.70910... | 0.6880844 | 40 |
Initializes an empty list of measurements | def __init__(self, measurement_type):
self.measurements = []
self.measurement_type = measurement_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,num_state,num_measurement,states_name_list=[],measurements_name_list=[],unit_list=[]):\n self.num_state = num_state\n self.num_measurement = num_measurement\n self.states_name_list = states_name_list\n self.unit_list = unit_list\n self.meas_name_list = measureme... | [
"0.6543146",
"0.65365046",
"0.6486732",
"0.6413972",
"0.63926065",
"0.63585347",
"0.62342465",
"0.6143583",
"0.6138182",
"0.61285824",
"0.6104451",
"0.60373807",
"0.60372937",
"0.6034392",
"0.60161173",
"0.5969256",
"0.5947703",
"0.59361637",
"0.59348243",
"0.5934192",
"0.592... | 0.7444964 | 0 |
Create and return a new object. See help(type) for accurate signature. | def __new__(*args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(cls, *args, **kwargs):\n return cls(*args, **kwargs)",
"def _factory(*args_, **kwargs_):\n return ObsType(*args_, **kwargs_)",
"def make_instance(self, cls, args, kw):\n return Object(cls, args, kw)",
"def __new__(cls):\n raise TypeError(\"%s may not be instantiated.\" ... | [
"0.7054317",
"0.6987691",
"0.69416267",
"0.69366497",
"0.6921373",
"0.6838605",
"0.678635",
"0.6770919",
"0.6770919",
"0.6714767",
"0.6669912",
"0.6667306",
"0.66537184",
"0.66509956",
"0.664091",
"0.6627614",
"0.661465",
"0.66108847",
"0.6591579",
"0.6586",
"0.6557733",
"0... | 0.0 | -1 |
Wrapper for inserting int64 features into Example proto. | def _int64_feature(value):
if isinstance(value, np.ndarray):
value = value.flatten().tolist()
elif not isinstance(value, list):
value = [value]
return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _int64_feature(value: Union[Sequence[int], int]):\n if isinstance(value, int):\n value = [value]\n return tf.train.Feature(int64_list=tf.train.Int64List(value=value))",
"def _int64_features(value):\n return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))",
"def _int64_feature... | [
"0.7307733",
"0.7300425",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7300225",
"0.7295905",
"0.7295905",
"0.7289835",
"0.7289835",
"0.7289835",
"0.7289835",
"0.7289835",
"0.7289835",
"0.7276353",
"0.7276353",
"... | 0.71249944 | 44 |
Wrapper for inserting float64 features into Example proto. | def _float64_feature(value):
if isinstance(value, np.ndarray):
value = value.flatten().tolist()
elif not isinstance(value, list):
value = [value]
return tf.train.Feature(float_list=tf.train.FloatList(value=value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _float_feature(list_of_floats):\n return tf.train.Feature(float_list=tf.train.FloatList(value=list_of_floats))",
"def _float64_feature(value):\n if not isinstance(value, list):\n value = value.tolist()\n return tf.train.Feature(float_list=tf.train.FloatList(value=value))",
"def _float_featu... | [
"0.7221246",
"0.7204797",
"0.70964277",
"0.70962584",
"0.70962584",
"0.70962584",
"0.70962584",
"0.70962584",
"0.70792973",
"0.70792973",
"0.70792973",
"0.70792973",
"0.70792973",
"0.70508254",
"0.704545",
"0.70312214",
"0.7026225",
"0.7026225",
"0.70091665",
"0.70091665",
"0... | 0.7147253 | 2 |
Generate a random blood pressure range. Returns a dictionary with min and max blood pressure. | def random_bp():
bp_min = random.randrange(60, 90)
bp_max = random.randrange(100, 220)
bp = [bp_min, bp_max]
return bp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_range(random_number):\r\n if random_number <= 10:\r\n return 10\r\n elif random_number <= 25:\r\n return 25\r\n elif random_number <= 50:\r\n return 50\r\n elif random_number <= 75:\r\n return 70\r\n else:\r\n return 100",
"def get_bpm_range():\n retur... | [
"0.60734725",
"0.6048016",
"0.6032077",
"0.5981885",
"0.5950663",
"0.58844835",
"0.5817606",
"0.5793637",
"0.5724275",
"0.572406",
"0.57178897",
"0.5619655",
"0.55945355",
"0.55639863",
"0.5532432",
"0.5532207",
"0.55197334",
"0.5502484",
"0.54847693",
"0.54828614",
"0.546762... | 0.7340271 | 0 |
Create object to update labels. | def create_read_labels(self):
return {'removeLabelIds': ['UNREAD'], 'addLabelIds': []} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_labels(self, w):\r\n \r\n pass",
"def create_labels(self):\n self.label = Tk.Label(self.tk,\n textvariable=self.name,\n bg=self.bg,\n fg=self.fg,\n font=\"Font\")\n\n sel... | [
"0.6751607",
"0.667704",
"0.6514043",
"0.6485933",
"0.6380231",
"0.63640785",
"0.63047695",
"0.6263167",
"0.6184944",
"0.6179615",
"0.6178849",
"0.61618155",
"0.61618155",
"0.61496174",
"0.61058736",
"0.61057115",
"0.6037394",
"0.6019633",
"0.6005563",
"0.5987727",
"0.5987727... | 0.0 | -1 |
Check if the response from the server is not an unexpected error | def _check_response(self, response):
if response.status_code >= 500:
logger.critical(everything_broken.format(response.request.headers, response.request.body, response.text))
raise MISPServerError('Error code 500:\n{}'.format(response.text))
elif 400 <= response.status_code < 500... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_error(self, response):\n pass",
"def _check_response_for_request_errors(self):\n\n pass",
"def check_error_in_response(response):\n if 'error' in response:\n raise requests.exceptions.HTTPError(response['error'])",
"def is_error(response):\n return isinstance(response, Ex... | [
"0.8393974",
"0.78234774",
"0.76534075",
"0.74495786",
"0.7447122",
"0.74411607",
"0.7408042",
"0.7386814",
"0.7318152",
"0.73003095",
"0.72914505",
"0.72735405",
"0.7271929",
"0.72584134",
"0.7208832",
"0.7185603",
"0.71330154",
"0.71319395",
"0.7122583",
"0.71044016",
"0.70... | 0.7181444 | 16 |
Testing markdown_escape with '>' for standard text | def test_markdown_escape_gt_text(self):
self.assertEqual(markdown_escape('<foo>'), r'<foo>') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_markdown_escape_gt_blockquotes(self):\n self.assertEqual(markdown_escape('>'), r'\\>')\n self.assertEqual(markdown_escape('> foo'), r'\\> foo')\n self.assertEqual(markdown_escape(' > foo'), r' \\> foo')\n self.assertEqual(markdown_escape('> > foo'), r'\\> \\> foo')\n s... | [
"0.80633014",
"0.7929097",
"0.7798014",
"0.76725996",
"0.72600216",
"0.7257733",
"0.72504526",
"0.7220199",
"0.7170765",
"0.7067565",
"0.7050864",
"0.6942522",
"0.69139725",
"0.68968236",
"0.6885855",
"0.687639",
"0.67933726",
"0.6781986",
"0.6781083",
"0.67547363",
"0.673910... | 0.8465268 | 0 |
Testing Markdown WYSIWYG rendering with 1 blank lines between lists | def test_lists_1_blank_line(self):
# This really just results in a single list. This is Python Markdown
# behavior.
self.assertEqual(
self.render_markdown(
'1. item\n'
'\n'
'1. item'),
('<ol>\n'
'<li>\n'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lists_2_blank_line(self):\n self.assertEqual(\n self.render_markdown(\n '1. item\\n'\n '\\n'\n '\\n'\n '1. item'),\n ('<ol>\\n'\n '<li>item</li>\\n'\n '</ol>\\n'\n '<p></p>\\n'\n ... | [
"0.8145702",
"0.80619717",
"0.7161114",
"0.7105459",
"0.7028751",
"0.7007354",
"0.6974216",
"0.69612783",
"0.68976927",
"0.68969715",
"0.687313",
"0.66749716",
"0.664507",
"0.66441786",
"0.66169065",
"0.6591705",
"0.6530505",
"0.64842606",
"0.6464146",
"0.6443653",
"0.6347468... | 0.78480107 | 2 |
Testing Markdown WYSIWYG rendering with 2 blank lines between lists | def test_lists_2_blank_line(self):
self.assertEqual(
self.render_markdown(
'1. item\n'
'\n'
'\n'
'1. item'),
('<ol>\n'
'<li>item</li>\n'
'</ol>\n'
'<p></p>\n'
'<ol>\n'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lists_3_blank_line(self):\n self.assertEqual(\n self.render_markdown(\n '1. item\\n'\n '\\n'\n '\\n'\n '\\n'\n '1. item'),\n ('<ol>\\n'\n '<li>item</li>\\n'\n '</ol>\\n'\n ... | [
"0.8056",
"0.77679765",
"0.7257639",
"0.71295834",
"0.6969906",
"0.6947459",
"0.6937785",
"0.693361",
"0.68710667",
"0.68152624",
"0.6761451",
"0.66027695",
"0.65844977",
"0.65813076",
"0.6572584",
"0.6529584",
"0.6523482",
"0.6507998",
"0.6507494",
"0.64988816",
"0.6378481",... | 0.82099557 | 0 |
Testing Markdown WYSIWYG rendering with 3 blank lines between lists | def test_lists_3_blank_line(self):
self.assertEqual(
self.render_markdown(
'1. item\n'
'\n'
'\n'
'\n'
'1. item'),
('<ol>\n'
'<li>item</li>\n'
'</ol>\n'
'<p></p>\n'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lists_2_blank_line(self):\n self.assertEqual(\n self.render_markdown(\n '1. item\\n'\n '\\n'\n '\\n'\n '1. item'),\n ('<ol>\\n'\n '<li>item</li>\\n'\n '</ol>\\n'\n '<p></p>\\n'\n ... | [
"0.8075712",
"0.7657583",
"0.7234953",
"0.7141116",
"0.6860586",
"0.6859152",
"0.68503535",
"0.68440187",
"0.67987365",
"0.67471755",
"0.6688414",
"0.6665311",
"0.6652905",
"0.65191925",
"0.6517593",
"0.65107286",
"0.6506422",
"0.650061",
"0.6496713",
"0.6447656",
"0.644022",... | 0.81278634 | 0 |
Associate a floating IP to a VM | def associate_floating_ip(self, vm_id, floating_ip):
my_url = "%s/%s/%s/%s" % (
self.url_openstack, "servers", vm_id, "action")
payload = '{ "addFloatingIp": {"address": "' + floating_ip + '" } }'
loggers.set_info_log(my_url)
response = http.post(my_url, self.header, payload)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _allocate_floatingip(self, context, obj):\n try:\n db_namespace = fortinet_db.query_record(context,\n fortinet_db.Fortinet_ML2_Namespace,\n tenant_id=obj['tenant_id'])\n\n db_fip = utils.add_record(self, ... | [
"0.6941581",
"0.68765056",
"0.6820204",
"0.6641519",
"0.66089976",
"0.6595353",
"0.6507105",
"0.64032567",
"0.63906205",
"0.63830537",
"0.6378995",
"0.63713646",
"0.6326684",
"0.6256907",
"0.62555754",
"0.62289715",
"0.619745",
"0.616646",
"0.6164672",
"0.615525",
"0.6154051"... | 0.76817876 | 0 |
Gets the current gain setting for the device. | def gain(self):
return self._gain_current | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gain(self):\n return self.get('gain')",
"def getGain(self):\n return self.__gain",
"def getGain(self):\n return self.__gain",
"def gain(self):\n return lookup.array_properties.get('gain')",
"def getGain(self):\n return _yarp.IFrameGrabberControls_getGain(self)",
"de... | [
"0.83861476",
"0.8277792",
"0.8277792",
"0.8015757",
"0.77846813",
"0.7703703",
"0.7478806",
"0.7322806",
"0.72549736",
"0.72227716",
"0.72188216",
"0.71955466",
"0.7186111",
"0.71034956",
"0.70800114",
"0.7005519",
"0.69261914",
"0.6901974",
"0.6814106",
"0.6614997",
"0.6519... | 0.8269057 | 3 |
Change the language of the window according to the chosen previously | def reload_text(self):
self.language = LANGUAGE.get(self.lang)
self.attack_button.setText(self.language["attack"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __change_language_to(self, l):\n if language.get_current_language() != l:\n write_xml(\"conf.xml\", \"language\", l)\n self.master.status_message(get_text(\"chang_lang\"))",
"def onLanguageChanged(self, argsList):\r\n\t\tiLanguage = argsList[0]",
"def change_language(self):\n ... | [
"0.72224855",
"0.7034228",
"0.70067495",
"0.6996227",
"0.69957757",
"0.6898986",
"0.68540937",
"0.67620194",
"0.67271954",
"0.66184175",
"0.65841883",
"0.6567563",
"0.65389836",
"0.6467625",
"0.64458525",
"0.6440841",
"0.6269599",
"0.6229683",
"0.6206138",
"0.6180778",
"0.616... | 0.65622187 | 12 |
Check the enemy survivor ships | def check_enemy_fleet(self):
if len(self.enemyShips) > 0:
response = False
for ship in self.enemyShips:
if ship.afloat == True:
response = True
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_place_enemy_ships(self):\n board = [[student_submission.WATER for i in range(5)] for i in range(5)]\n student_submission.place_enemy_ships(board)\n\n count_boats = sum(row.count(student_submission.SHIP) for row in board)\n self.assertEqual(count_boats, student_submission.NUMBER... | [
"0.6595194",
"0.6468159",
"0.6421285",
"0.64056975",
"0.62957275",
"0.6261788",
"0.626027",
"0.6247655",
"0.6189777",
"0.61811805",
"0.6148261",
"0.6137636",
"0.6133552",
"0.6108636",
"0.6085173",
"0.60817474",
"0.60536194",
"0.6051601",
"0.6044045",
"0.60200053",
"0.59909976... | 0.68263066 | 0 |
Populates the metadata dictionary from the supplied metadata. | def populate_metadata(self, metadata):
# type: (Dict[Any, Any]) -> "SetupInfo"
_metadata = ()
for k, v in metadata.items():
if k == "extras" and isinstance(v, dict):
extras = ()
for extra, reqs in v.items():
extras += ((extra, tupl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_metadata(self, **kwargs):\n meta = self.metadata(**kwargs)\n self.Metadata = meta",
"def fill_metadata(self) -> Dict[str, str]:\n return {}",
"def addMetadataInfo(self, metadata):\n metadata[\".dataHash\"] = self.objectHash\n metadata[\".uniqueID\"] = self.uniqueID\n... | [
"0.7079697",
"0.70673525",
"0.6989029",
"0.6888964",
"0.6832804",
"0.6797692",
"0.6797692",
"0.6796509",
"0.67595154",
"0.67442554",
"0.67442554",
"0.67442554",
"0.67442554",
"0.67442554",
"0.67442554",
"0.67442554",
"0.67442554",
"0.6625959",
"0.65228295",
"0.65088415",
"0.6... | 0.80841243 | 0 |
Populates the pyproject.toml metadata if available. | def run_pyproject(self):
# type: () -> "SetupInfo"
if self.pyproject and self.pyproject.exists():
result = get_pyproject(self.pyproject.parent)
if result is not None:
requires, backend = result
if self.build_requires is None:
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_metadata(self):\n with self.lock:\n from renku.models._jsonld import asjsonld\n from renku.models.projects import Project\n\n path = str(self.renku_metadata_path)\n\n if self.renku_metadata_path.exists():\n with open(path, 'r') as f:\n ... | [
"0.6790729",
"0.6710669",
"0.66148907",
"0.62072223",
"0.61090434",
"0.59428734",
"0.58522296",
"0.5794909",
"0.5770357",
"0.5740304",
"0.57070434",
"0.5705024",
"0.5658176",
"0.56355464",
"0.5600949",
"0.5589396",
"0.5587447",
"0.55867946",
"0.55529207",
"0.5535742",
"0.5507... | 0.54528815 | 24 |
For a given dict, recursively build the AttrDict. | def _build_attr_dict_from_dict(d):
root = AttrDict()
for k, v in d.items():
if isinstance(v, dict):
root[k] = _build_attr_dict_from_dict(v)
else:
root[k] = v
return root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_nested_dict(data):\n if not isinstance(data, dict):\n return data\n else:\n return AttrDict({key: AttrDict.from_nested_dict(data[key])\n for key in data})",
"def from_dict(self, d):\n self.freeze(False)\n for k, v in d.item... | [
"0.6813633",
"0.66158456",
"0.6466841",
"0.6365543",
"0.631969",
"0.60904086",
"0.6077416",
"0.60300136",
"0.59590846",
"0.59371924",
"0.5931377",
"0.5931377",
"0.5840385",
"0.57235765",
"0.57012135",
"0.56965774",
"0.567708",
"0.5625192",
"0.5607354",
"0.5594724",
"0.5586697... | 0.8062461 | 0 |
Validate that a has the same structure as b. Returns a pruned version of a where the coerced entries are removed. | def _validate_structure(a, b, stack=None):
assert isinstance(a, AttrDict) and isinstance(b, AttrDict)
d = AttrDict()
for k, v in a.items():
# check key
full_key = '.'.join(stack) + '.' + k if stack is not None else k
if k not in b:
raise KeyErr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(self, a):\n a = _convert_other(a, raiseit=True)\n return a.normalize(context=self)",
"def __ne__(self, other):\n if not isinstance(other, ComputeBoardAllOf):\n return True\n\n return self.to_dict() != other.to_dict()",
"def copy_negate(self, a):\n a =... | [
"0.56486493",
"0.53622884",
"0.5313524",
"0.52817774",
"0.5263051",
"0.5226347",
"0.5167517",
"0.51274216",
"0.51108384",
"0.5093876",
"0.5088227",
"0.5072656",
"0.50705564",
"0.50615954",
"0.5042209",
"0.50400597",
"0.5034061",
"0.50150746",
"0.5010366",
"0.4999841",
"0.4999... | 0.49723193 | 24 |
Parse port name from the resource full name | def _parse_port(self, full_name):
port_name = full_name.split("/")[-1]
return port_name.replace("_", "/") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_full_port_name(cls, host, options, port_name):\n # Subclasses will usually override this.\n assert port_name.startswith(cls.port_name)\n return port_name",
"def port_name(self, *args):\n return sub_unvalid_chars(self.get('variable-name'))",
"def extract_port_name(port)... | [
"0.70764786",
"0.70205945",
"0.7016115",
"0.68315697",
"0.65025645",
"0.64482117",
"0.64482117",
"0.6401097",
"0.6283807",
"0.61762697",
"0.6171443",
"0.6159286",
"0.61448884",
"0.60689896",
"0.605052",
"0.6048675",
"0.60026723",
"0.5950655",
"0.5881092",
"0.5874316",
"0.5860... | 0.88113725 | 0 |
Parse switch name from the resource full name | def _parse_switch(self, full_name):
return full_name.split("/")[-2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_name_from_resource(resource: str) -> str:\n _, name = resource.rsplit(\"/\", maxsplit=1)\n return name",
"def _decode_name(self, name):\n return name",
"def _parse_port(self, full_name):\n port_name = full_name.split(\"/\")[-1]\n return port_name.replace(\"_\", \"/\")",
"d... | [
"0.66840863",
"0.619275",
"0.61472327",
"0.60113084",
"0.59772825",
"0.5972817",
"0.5828512",
"0.5814534",
"0.5786828",
"0.5716539",
"0.56498027",
"0.5616404",
"0.5613349",
"0.5609858",
"0.5579124",
"0.5560559",
"0.55503494",
"0.55285025",
"0.5515222",
"0.55135745",
"0.549679... | 0.8540036 | 0 |
Returns the distance between its own position and a new one with the maximun norm. Notes Since the particles can move in diagonal, we're assuming a diagonal movement to be equal to one. | def _calculate_distance(self, new_position):
return max(abs(self.position - new_position)) # use broadcasting | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self) -> float:\n xdiff = self.position[0] - self.target[0]\n ydiff = self.position[1] - self.target[1]\n zdiff = self.position[2] - self.target[2]\n res = math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff)\n if res == 0:\n res = 0.001\n retur... | [
"0.66288465",
"0.6472556",
"0.64150584",
"0.6357694",
"0.63104075",
"0.63004416",
"0.6293054",
"0.6206478",
"0.62031317",
"0.61964935",
"0.6183476",
"0.617755",
"0.617755",
"0.61764413",
"0.61738473",
"0.6138762",
"0.60850567",
"0.60697824",
"0.6058008",
"0.6047231",
"0.60440... | 0.7435217 | 0 |
Sample from a multivariate Gaussian (parameterized by a mean and a covariance matrix). | def sample_gaussian(mean, sigma, n):
samples = multivariate_normal.rvs(mean=mean, cov=sigma, size=n).T
if n == 1:
samples = samples.reshape((-1, 1))
return samples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multivariate_gaussian(x, mean, cov):\n dim = x.shape[0]\n # reshape x to a column vector\n x = x.reshape(-1, 1)\n mean = mean.reshape(-1, 1)\n return np.power(2 * np.pi, -dim / 2.) * np.power(np.linalg.det(cov), -0.5) * np.exp(-0.5 * (x - mean).T @ np.linalg.inv(cov) @ (x - mean))[0, 0]",
"de... | [
"0.79420525",
"0.708215",
"0.68116486",
"0.6783155",
"0.6731988",
"0.67123336",
"0.67122823",
"0.6628693",
"0.6608162",
"0.65979594",
"0.6589951",
"0.65045124",
"0.6472694",
"0.64724815",
"0.64646643",
"0.644891",
"0.64333224",
"0.6432825",
"0.64158416",
"0.6344225",
"0.63277... | 0.69902766 | 2 |
Compute log(np.sum(np.exp(matrix), dim)) in a numerically stable way. | def logsumexp(matrix, dim=None):
max_val = np.nan_to_num(matrix.max(axis=dim, keepdims=True))
with np.errstate(under='ignore', divide='ignore'):
return np.log(np.sum(np.exp(matrix - max_val), dim, keepdims=True)) + max_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_sum_exp(arr):\n a = arr.max(axis=1)\n return a + np.log(np.sum(np.exp(arr - a[:,None]), axis=1))",
"def log_sum_exp(x):\n # TF ordering\n axis = len(x.size()) - 1\n m, _ = torch.max(x, dim=axis)\n m2, _ = torch.max(x, dim=axis, keepdim=True)\n return m + torch.log(torch.sum(t... | [
"0.7751567",
"0.7600328",
"0.75993377",
"0.75966525",
"0.758414",
"0.75196236",
"0.7347268",
"0.73289335",
"0.7266463",
"0.7234689",
"0.7234689",
"0.72119266",
"0.7110559",
"0.7072044",
"0.70623463",
"0.70560455",
"0.70341533",
"0.7026994",
"0.70204",
"0.69638234",
"0.6948257... | 0.80910915 | 0 |
Delete a Question from the database This API will delete a question from the database. | def delete_question(question_id):
try:
question = Question.query.filter(Question.id
== question_id).one_or_none()
if question is None:
abort(404)
question.delete()
return jsonify({
'success': True,
'delet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_question(self, question_id):\n pass",
"def delete_question(question_id):\n try:\n question = Question.query.filter(\n Question.id == question_id).one_or_none()\n\n if not question:\n abort(404)\n\n question.delete()\n\n ... | [
"0.7696212",
"0.7650863",
"0.7360308",
"0.72966135",
"0.727083",
"0.6948556",
"0.6812428",
"0.68124014",
"0.65464437",
"0.65143764",
"0.6479704",
"0.6449494",
"0.6331646",
"0.629369",
"0.62801296",
"0.6249368",
"0.62245005",
"0.6201409",
"0.61988217",
"0.61664283",
"0.6099626... | 0.72983485 | 3 |
Retrieve Trivia Categories This API will retrive a list of trivia categories. | def retrieve_category():
selection = Category.query.order_by(Category.id).all()
if len(selection) == 0:
abort(404)
return jsonify({
'success': True,
'categories': [cat.type for cat in selection],
'total_categories': len(selection)
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_categories(self):\n response = (\n self.youtube.videoCategories()\n .list(part=\"snippet\", regionCode=\"US\")\n .execute()\n )\n return youtube_api.parse_categories(response)",
"def getCategories(self): \n self.send(\"getCategories\")... | [
"0.7052503",
"0.7029121",
"0.6984553",
"0.6688072",
"0.65568304",
"0.6551679",
"0.6548443",
"0.6518865",
"0.6509257",
"0.646114",
"0.6426403",
"0.6426403",
"0.63852197",
"0.63831663",
"0.6375955",
"0.6345813",
"0.63047636",
"0.62715137",
"0.62302595",
"0.61723477",
"0.6164102... | 0.5420305 | 81 |
Retrieve Category Questions This API will retrieve a list of questions by category Id. | def retrieve_category_questions(category_id):
# Fix the category from what the front end sent.
category_id += 1
selection = Question.query.filter(Question.category == category_id).all()
current_questions = paginate_questions(request, selection)
# Abort if no questions
if len(current_questions) =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_questions_by_category(category_id):\n try:\n category = Category.query.get(category_id)\n selection = Question.query.filter_by(\n category=str(category_id)).all()\n current_questions = paginate_quetions(request, selection)\n if not curr... | [
"0.72524285",
"0.7009685",
"0.6733558",
"0.6337118",
"0.5909222",
"0.5671592",
"0.56405777",
"0.5575477",
"0.5524205",
"0.5507112",
"0.5483539",
"0.5452147",
"0.54236656",
"0.5390793",
"0.5374443",
"0.5353938",
"0.534142",
"0.5334719",
"0.52970874",
"0.5287191",
"0.52852225",... | 0.7146724 | 1 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(SyncTimeMonitor, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.header is None:
self.header = std_msgs.msg.Header()
if self.image_raw is None:
self.image_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(BasicSafetyMessage, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.communication_header is ... | [
"0.806142",
"0.80587703",
"0.7872186",
"0.7872186",
"0.7872186",
"0.7872186",
"0.7601677",
"0.76000494",
"0.7524568",
"0.75007737",
"0.75007737",
"0.74567354",
"0.74496144",
"0.7443776",
"0.7426577",
"0.73908865",
"0.7355341",
"0.7333042",
"0.7324639",
"0.73181033",
"0.729167... | 0.0 | -1 |
serialize message with numpy array types into buffer | def serialize_numpy(self, buff, numpy):
try:
_x = self
buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
_x = self.header.frame_id
length = len(_x)
if python3 or type(_x) == unicode:
_x = _x.encode('utf-8')
length = len(_x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_numpy(self, buff, numpy):\n self.serialize(buff)",
"def serialize_numpy(self, buff, numpy):\n try:\n pass\n except struct.error as se: self._check_types(struct.error(\"%s: '%s' when writing '%s'\" % (type(se), str(se), str(locals().get('_x', self)))))\n except TypeError as te: ... | [
"0.79519945",
"0.7893365",
"0.785495",
"0.77772063",
"0.7765444",
"0.77629846",
"0.7758146",
"0.7753108",
"0.7752819",
"0.7736317",
"0.7675474",
"0.7673923",
"0.7667761",
"0.7663843",
"0.760332",
"0.7587286",
"0.7566181",
"0.75634706",
"0.7555974",
"0.7554196",
"0.7543482",
... | 0.7351773 | 62 |
rotate an image while keeping its center | def rotate(self,angle):
self.image = pygame.transform.rotozoom(self.baseImage, degrees(angle), 1)
self.rect = self.image.get_rect(center=self.rect.center)
self.angle = degrees(angle)
self.image.set_colorkey((0, 0, 0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(img, angle, resample=False, expand=False, center=None):\n \n return img.rotate(angle, resample, expand, center)",
"def rotate(self):\n\t\tlast_center = self.rect.center\n\t\tself.image = pg.transform.rotate(self.image_copy, self.angle)\n\t\tself.rect = self.image.get_rect() #... | [
"0.8185137",
"0.7912543",
"0.77528554",
"0.7742826",
"0.77231175",
"0.77231175",
"0.7686228",
"0.7655114",
"0.7654274",
"0.7648917",
"0.7648917",
"0.7621207",
"0.7620978",
"0.76203805",
"0.76203805",
"0.7608846",
"0.74975437",
"0.7489052",
"0.72788185",
"0.7261446",
"0.716457... | 0.7437148 | 18 |
Get the primary IP address for the given network interface. | def get_current_ipaddr(dev='defaultroute'):
if dev == 'defaultroute':
dev = get_defaultroute()[1]
if not dev:
return
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
for line in fd.readlines():
m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ip_addr(interface):\n return netifaces.ifaddresses(interface)[2][0]['addr']",
"def ip_addr(interface=\"eth0\"):\n osc = OSCommands(\"network\")\n ipaddress = osc.cmdoutput(\n \"ifconfig | grep \" + interface + \" -A5 | grep -w inet\"\n + \"| awk 'BEGIN {FS = \\\" \\\"}; {print $2}'... | [
"0.8116569",
"0.77856094",
"0.7563628",
"0.7524565",
"0.7487561",
"0.7465029",
"0.7453109",
"0.7417736",
"0.739409",
"0.7391304",
"0.73605734",
"0.72905135",
"0.7228888",
"0.7208329",
"0.7207045",
"0.71950775",
"0.7177905",
"0.7048119",
"0.7024545",
"0.70076597",
"0.6990204",... | 0.65180624 | 60 |
Computes temperature correction factor. | def _calc_alpha(self, tr):
return (1.0 + self.__m*(1.0 - np.sqrt(tr)))**2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def temperature_correction(self, res):\n ab = self.get_value(\"alpha_beta_dkmppc4\", \"1/C\")\n t_piston = res.pick(\"Temperature\", \"dkmppc4\", \"C\")\n corr = 1.0 + ab * (t_piston - 20.0)\n\n res.store(\"Correction\", \"temperature\", corr, \"1\")",
"def temperatur_correction(self)... | [
"0.74858165",
"0.7315215",
"0.6949619",
"0.6770121",
"0.6726348",
"0.6666645",
"0.6664119",
"0.66156095",
"0.6533722",
"0.6478211",
"0.646552",
"0.6457518",
"0.64449495",
"0.6424982",
"0.63704544",
"0.63606066",
"0.63510036",
"0.6341412",
"0.6324381",
"0.6311845",
"0.62803304... | 0.0 | -1 |
Computes coefficients of the cubic equation of Zfactor. Paramters | def _zfactor_cubic_eq(A, B):
return [1.0, -1.0, A - B - B**2, -A*B] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cubicformula(coeffs):\n a, b, c, d = coeffs\n\n if d==0: return quadraticformula(a, b, c)\n\n Delta0 = c**2 - 3*d*b\n Delta1 = 2*c**3 - 9*d*c*b + 27*d**2*a\n\n if Delta0 == Delta1 == 0: return np.array([-c / (3*d)])\n\n C = ((Delta1 + (1 if Delta1>0 else -1) * (Delta1**2 - 4*Delta0**3 + 0j)**0.5) / 2) **... | [
"0.7260356",
"0.6753687",
"0.6669983",
"0.65692616",
"0.6567086",
"0.64729404",
"0.62248325",
"0.6180545",
"0.61393535",
"0.60875595",
"0.60875595",
"0.60875595",
"0.60875595",
"0.6074426",
"0.6068857",
"0.6068857",
"0.6068857",
"0.6060933",
"0.6033648",
"0.6029178",
"0.59752... | 0.6937132 | 1 |
Gets first element of a list | def head(xs):
return xs[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(lst):\n for element in lst:\n return element",
"def _select_first_in_list(lst):\n return lst[0] if isinstance(lst, list) else lst",
"def get_first(l, default=None):\n if l:\n for item in l:\n return item\n return default",
"def first(l):\n\tfor i in l:\n\t\tif i... | [
"0.85444164",
"0.85228336",
"0.83765185",
"0.81949776",
"0.8056868",
"0.7903661",
"0.77698964",
"0.77541375",
"0.76706165",
"0.76406986",
"0.7633779",
"0.76130587",
"0.75821316",
"0.75659406",
"0.75426245",
"0.7448638",
"0.73877966",
"0.7385915",
"0.73812634",
"0.7379764",
"0... | 0.7427465 | 16 |
Constructs response headers. `more_headers` is a dict to send additional headers | def make_response_headers(self, mime_type="text/html; charset=UTF-8", more_headers=None):
headers = {
"Content-Type": mime_type,
"Date": formatdate(timeval=None, localtime=False, usegmt=True),
}
if more_headers:
headers.update(more_headers)
return "\... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_response_headers(self, response_dict):\n\t\theaders_string = response_dict['version'] + \" \" + response_dict['status']\n\t\tfor key, val in response_dict.iteritems():\n\t\t\theaders_string += key + ': ' + val + '\\r\\n'\n\t\theaders_string += '\\r\\n'\n\t\treturn headers_string",
"def make_headers(sel... | [
"0.65168446",
"0.650959",
"0.6417784",
"0.63312495",
"0.6289225",
"0.6248947",
"0.62316513",
"0.61842066",
"0.6168209",
"0.61594194",
"0.6158859",
"0.61561835",
"0.6135521",
"0.6135063",
"0.6129359",
"0.60744256",
"0.60622203",
"0.604708",
"0.6046611",
"0.59968084",
"0.598659... | 0.78338504 | 0 |
Constructs response line from HTTP version, status code and message HTTP version Status code Message HTTP/1.1 200 OK | def make_response_line(self, status_code=200):
return " ".join([self.http_version, str(status_code), responses[status_code]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_response(version, status, headers):\n message = []\n message.append('HTTP/{} {}\\r\\n'.format(version, status))\n for name, value in headers:\n message.append(name)\n message.append(': ')\n message.append(value)\n message.append('\\r\\n')\n message.append('\\r\\n'... | [
"0.734392",
"0.69465476",
"0.69401747",
"0.68742317",
"0.68369454",
"0.6825986",
"0.6721808",
"0.66455907",
"0.66011244",
"0.65856487",
"0.6568785",
"0.65585476",
"0.6557429",
"0.6509541",
"0.6492308",
"0.6459376",
"0.64056754",
"0.63787603",
"0.63625467",
"0.6343523",
"0.634... | 0.77018034 | 0 |
Sort by text relevance. This only works if the query includes at least one text query, leading to a weighted result. This method raises TypeError if the result is not weighted. A weighted result is a dictionaryish object that has docids as keys and floating point weights as values. This method sorts the dictionary by w... | def sort(self, result, reverse=False, limit=None, sort_type=None,
raise_unsortable=True):
if not result:
return result
if not hasattr(result, 'items'):
raise TypeError(
"Unable to sort by relevance because the search "
"result does no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(self, result, reverse=False, limit=None, sort_type=None):\n if not result:\n return result\n\n if not hasattr(result, 'items'):\n raise TypeError(\n \"Unable to sort by relevance because the search \"\n \"result does not contain weights. To... | [
"0.769862",
"0.62459683",
"0.56856513",
"0.5651745",
"0.5550262",
"0.5520081",
"0.54923403",
"0.54591274",
"0.545545",
"0.545211",
"0.5433013",
"0.5428791",
"0.54052484",
"0.5384614",
"0.53741837",
"0.53669137",
"0.5344551",
"0.5335832",
"0.52692294",
"0.5257034",
"0.52561176... | 0.76745045 | 1 |
humanizes time in seconds to human readable format | def _jinja2_filter_humanizetime(dt, fmt=None):
days = int(dt / 86400)
hours = int(dt / 3600) % 24
minutes = int(dt / 60) % 60
seconds = int(dt) % 60
microseconds = int(((dt % 1.0) * 1000))
fmtstr = ''
if days > 0:
fmtstr += '{}d '.format(days)
if hours > 0:
fmtstr += '{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def human_time(seconds):\n assert seconds >= 0\n hours = seconds / (60 * 60)\n minutes = (seconds / 60) % 60\n seconds = seconds % 60\n return '%02d:%02d:%02d' % (hours, minutes, seconds)",
"def humanize_seconds(seconds, precision=1):\n\n minute = 60\n hour = minute * 60\n\n hours = secon... | [
"0.81414795",
"0.78992957",
"0.78610444",
"0.7708326",
"0.76969475",
"0.76903355",
"0.76617444",
"0.7653923",
"0.76497704",
"0.7472526",
"0.7462382",
"0.74563617",
"0.7415267",
"0.73627645",
"0.73619026",
"0.7340067",
"0.73322576",
"0.72944987",
"0.72865564",
"0.7231589",
"0.... | 0.6520569 | 95 |
Checks if a string is safe based on the defined rules. | def _is_string_safe(token):
# Check if it is explicitly allowed or the wrong type
if type(token) is not str and type(token) is not unicode:
return True
if token in _STR_BAD:
return False
if token in _STR_OK:
return True
# Check all the prohibited sub-strings
for forbidden_substring in _STR_NOT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_safe(string: str, safe: str = \"/\") -> bool:\n NON_ESCAPED_CHARS = UNRESERVED_CHARACTERS + safe + \"%\"\n\n # All characters must already be non-escaping or '%'\n for char in string:\n if char not in NON_ESCAPED_CHARS:\n return False\n\n # Any '%' characters must be valid '%xx... | [
"0.7564668",
"0.71553063",
"0.69712675",
"0.67810714",
"0.66642785",
"0.6602999",
"0.65758634",
"0.65217817",
"0.6372591",
"0.6292574",
"0.62550265",
"0.6254048",
"0.6210372",
"0.61911124",
"0.6172565",
"0.61180884",
"0.6075504",
"0.6060744",
"0.6055353",
"0.6042301",
"0.6022... | 0.7535187 | 1 |
Add a created_date attribute an astropy Time object based on created_gpstime. | def gps2Time(self):
self.created_date = Time(self.created_gpstime, format="gps") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def created_time(self, created_time: float):\n\n self._created_time = created_time",
"def creation_date_time(self, creation_date_time):\n self._creation_date_time = creation_date_time",
"def time_created(self, time_created):\n self._time_created = time_created",
"def time_created(self, t... | [
"0.72743833",
"0.71880615",
"0.7177237",
"0.7177237",
"0.7177237",
"0.7177237",
"0.71585864",
"0.7077209",
"0.7057029",
"0.7057029",
"0.6905167",
"0.6905167",
"0.6905167",
"0.6905167",
"0.6905167",
"0.6905167",
"0.6905167",
"0.6883079",
"0.6522999",
"0.65083694",
"0.65083694"... | 0.6910548 | 10 |
Class constructor for BaseTransform | def __init__(self,
size,
mean):
super(BaseTransform, self).__init__()
self.size = size
self.mean = np.array(mean, dtype=np.float32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n this = _almathswig.new_Transform(*args)\n try: self.this.append(this)\n except: self.this = this",
"def __init__(self, scale):\n Transformation.__init__(self)\n self.scale = scale\n return",
"def __init__(self,\n transforms)... | [
"0.790111",
"0.7749764",
"0.74141455",
"0.73264414",
"0.7294997",
"0.72529775",
"0.72261727",
"0.7145591",
"0.71410656",
"0.70888084",
"0.7033444",
"0.70277894",
"0.70159423",
"0.6994654",
"0.69792235",
"0.69792235",
"0.693774",
"0.69351447",
"0.6901614",
"0.68937296",
"0.678... | 0.62698835 | 47 |
combine self with other, return closure. | def __add__(self, other):
result = self.share_eqs()
se = self.eqs
oe = other.eqs
if (se is not oe) and (se != oe):
result.eqs = se + oe
result.closed = 0
ra= result.assns = self.assns + other.assns
result.clean = result.clean and (ra.Clean() is not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, other):\n return self._f(other)",
"def do_combine(a, b):\n combine(a, b)\n return a",
"def then(self, other):\n other = action(other)\n return action(lambda *a: other(self(*a), *a[1:]))",
"def _combine(self, other, conn='and'):\n f = Filter()\n\n ... | [
"0.66447943",
"0.65542233",
"0.63712746",
"0.63303053",
"0.6316842",
"0.63055646",
"0.62538946",
"0.61516315",
"0.61490965",
"0.60953313",
"0.60627973",
"0.60195833",
"0.5984454",
"0.59515357",
"0.5923121",
"0.5852472",
"0.5787912",
"0.5762198",
"0.5758135",
"0.5756216",
"0.5... | 0.0 | -1 |
Degrees of freedom used in the fit. | def df_model(self):
return self.order + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dof(self):\n return self.__dof",
"def _model_fit_term(self):\n if self.likelihood.YYT is None:\n tmp, _ = dtrtrs(self.L, np.asfortranarray(self.likelihood.Y), lower=1)\n return -0.5 * np.sum(np.square(tmp))\n #return -0.5 * np.sum(np.square(np.dot(self.Li, self.... | [
"0.6209266",
"0.61872",
"0.611762",
"0.60746896",
"0.5923093",
"0.5908099",
"0.5908082",
"0.5878032",
"0.587247",
"0.58480424",
"0.57804495",
"0.5750363",
"0.5718743",
"0.57137054",
"0.5699571",
"0.5690812",
"0.5690688",
"0.56855905",
"0.56798714",
"0.5666576",
"0.5666576",
... | 0.0 | -1 |
Emit returns True when handlers are registered on an event, and false otherwise. | def test_emit_return():
call_me = Mock()
ee = EventEmitter()
assert ee.event_names() == set()
# make sure emitting without a callback returns False
assert not ee.emit("data")
# add a callback
ee.on("data")(call_me)
# should return True now
assert ee.emit("data") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_event(self, event):\r\n if self._get_event_handler(event) is not None:\r\n return True\r\n return False",
"def can_trigger(self, event):\n return hasattr(self._env.get('on_' + event, None), '__call__')",
"def __nonzero__(self):\n\n return self.has_handlers ()",
... | [
"0.60047233",
"0.59289837",
"0.5824848",
"0.57577825",
"0.5728145",
"0.5728037",
"0.57038534",
"0.570214",
"0.56317794",
"0.5597302",
"0.55324477",
"0.54730034",
"0.54304636",
"0.5415103",
"0.539745",
"0.5376505",
"0.53071034",
"0.5207352",
"0.519578",
"0.517029",
"0.51334924... | 0.6229991 | 0 |
3x3 convolution with padding | def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=dilation, groups=groups, bias=False, dilation=dilation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv3x3(in_planes, out_planes, stride=1, padding=1, groups=1, dilation=1, zero_init=False):\n conv = nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=padding, groups=groups, bias=False, dilation=dilation)\n if zero_init:\n conv.weight.data.zero_()\n return conv",
"def co... | [
"0.73706514",
"0.7335249",
"0.7216377",
"0.72037584",
"0.72037584",
"0.7199952",
"0.7192902",
"0.7183875",
"0.7178802",
"0.7172082",
"0.71645725",
"0.71645725",
"0.716185",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",
"0.7156602",... | 0.70940775 | 40 |
Constructs a ResNet34 model. | def resnet34_taskonomy(pretrained=False, **kwargs):
return _resnet('resnet34', BasicBlock, [3, 4, 6, 3], pretrained,
**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet34(pretrained=False, **kwargs):\n model = ResNetlist(BasicBlock, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet34']))\n return model",
"def resnet34(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [3, 4, 6, 3], **kwarg... | [
"0.74619204",
"0.7425328",
"0.7425328",
"0.73675907",
"0.73485917",
"0.73485917",
"0.73485917",
"0.73114467",
"0.7231324",
"0.72123164",
"0.7105468",
"0.7098438",
"0.70858634",
"0.70610267",
"0.7053645",
"0.7035042",
"0.7001086",
"0.694085",
"0.69312596",
"0.69155324",
"0.672... | 0.0 | -1 |
Constructs a ResNet50 model. | def resnet50_taskonomy(pretrained=False, **kwargs):
return _resnet('resnet50', Bottleneck, [3, 4, 6, 3], pretrained,
**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet50(self):\n\n base_model = ResNet50(weights=self.weights, include_top=self.include_top,\n pooling=self.pooling)\n x = base_model.layers[-1]\n out = Dense(units=self.num_classes, activation=self.activation, name='output',\n use_bias=True... | [
"0.7858666",
"0.78175455",
"0.74759895",
"0.74759895",
"0.74557495",
"0.7448512",
"0.7448512",
"0.7448512",
"0.74316454",
"0.7386862",
"0.7386862",
"0.7386862",
"0.73798925",
"0.7372855",
"0.7316456",
"0.730408",
"0.7277307",
"0.72542447",
"0.7217906",
"0.7214323",
"0.7126571... | 0.63772786 | 44 |
Constructs a ResNet152 model. | def resnet152_taskonomy(pretrained=False, **kwargs):
return _resnet('resnet152', Bottleneck, [3, 8, 36, 3], pretrained,
**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet152(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet152']))\n return model",
"def resnet152(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 8, 36, 3], **kwar... | [
"0.7401452",
"0.7401452",
"0.7401452",
"0.7401452",
"0.73894",
"0.73894",
"0.73894",
"0.7376017",
"0.7327499",
"0.73165274",
"0.7314516",
"0.7308635",
"0.72929835",
"0.7069768",
"0.7023296",
"0.700969",
"0.69409674",
"0.67528486",
"0.6752301",
"0.6571621",
"0.655332",
"0.65... | 0.63261443 | 37 |
Changing tuple of lists with characters into readable form of account number. | def lines_on_numbers(given_example: str, valid_list_of_numbers=None):
given_account = reading(given_example)
if valid_list_of_numbers is None:
valid_list_of_numbers = num_val_list
account_checked = ''
invalid_char = []
for num_ac in given_account:
if num_ac in valid_list_of_numbers:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapt_tuple(t):\r\n return \",\".join(str(num) for num in t)",
"def number_to_password(number: List[int]) -> str:\n return ''.join(list(map(digit_to_char, number)))",
"def friendly_number(self, value):\r\n if self.code not in (\"en\", \"en_US\"):\r\n return str(value)\r\n val... | [
"0.6191797",
"0.6104651",
"0.5944151",
"0.5944151",
"0.591586",
"0.5845921",
"0.5806497",
"0.57820684",
"0.57535744",
"0.5752745",
"0.57399803",
"0.56972116",
"0.5645385",
"0.559966",
"0.5583519",
"0.55830127",
"0.55400884",
"0.5534557",
"0.5428991",
"0.5404197",
"0.5396377",... | 0.4907236 | 89 |
Encodes a tree to a single string. | def serialize(self, root: TreeNode) -> str:
if not root:
return json.dumps([])
arr = []
queue = [[root, -1]]
while queue:
tmp = queue.pop(0)
cur, parentIdx = tmp[0], tmp[1]
arr.append([cur.val, parentIdx])
if cur.left:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodeTree(self, tree, key):\n return self.encode(pickle.dumps(tree), key)",
"def serialize(self, root):\n if not root:\n return \"n\"\n s = \"\"\n stack = [root]\n while (stack):\n root = stack.pop(0)\n if root:\n s += str(ro... | [
"0.78278124",
"0.7515946",
"0.71304095",
"0.7053364",
"0.7031874",
"0.6999469",
"0.6999095",
"0.69672054",
"0.69332165",
"0.68838483",
"0.68657243",
"0.68548083",
"0.6809354",
"0.6801677",
"0.67984694",
"0.6773517",
"0.6766546",
"0.6754318",
"0.67507386",
"0.6745785",
"0.6664... | 0.64601576 | 39 |
The ID of the forwarding router instance. | def transit_router_id(self) -> pulumi.Input[str]:
return pulumi.get(self, "transit_router_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetID(self):\n return self.Route_ID",
"def _get_tunnel_id(self):\n return self.__tunnel_id",
"def _get_tunnel_id(self):\n return self.__tunnel_id",
"def _get_tunnel_id(self):\n return self.__tunnel_id",
"def _get_tunnel_id(self):\n return self.__tunnel_id",
"def router(self) -> int... | [
"0.7289573",
"0.7114021",
"0.7114021",
"0.7114021",
"0.7114021",
"0.70918983",
"0.6985108",
"0.6985108",
"0.6985108",
"0.6985108",
"0.6985108",
"0.6985108",
"0.6985108",
"0.6985108",
"0.69826233",
"0.69826233",
"0.69826233",
"0.69826233",
"0.69147724",
"0.68635005",
"0.684534... | 0.6904439 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.