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 |
|---|---|---|---|---|---|---|
Create or set a Dataset of interest. If argument is a string, creates a new Dataset with that name. If it is an integer, sets that Dataset ID as the Dataset of interest. If ``project_id`` is specified, new Dataset will be created in that Project. Parameter | def set_or_create_dataset(conn: BlitzGateway, project_id: Union[int, None],
dataset: Union[str, int],
across_groups: Optional[bool] = True
) -> Union[int, None]:
if isinstance(dataset, str):
if project_id:
dataset_id =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(project, dataset_name):\n dataset = dataset_name\n get_dataset = project.datasets.get(dataset_name=dataset)\n project.datasets.create(dataset_name=dataset_name)\n \n return get_dataset",
"def new_dataset(args):\n if not args.args:\n raise ParserError('you must specify ... | [
"0.7689911",
"0.70595676",
"0.6898516",
"0.6636758",
"0.66234565",
"0.6568854",
"0.6422174",
"0.63596046",
"0.63520086",
"0.6343059",
"0.6249331",
"0.62341964",
"0.61754906",
"0.6151975",
"0.6083525",
"0.60194254",
"0.5985418",
"0.597283",
"0.5936993",
"0.59360105",
"0.588947... | 0.74575466 | 1 |
Post map annotation (``self.ann``) to plates ``self.plate_ids``. Returns | def annotate_plates(self) -> Union[int, None]:
if not self.ann or not self.ns:
logging.warning("Missing annotation or namespace, "
"skipping annotations")
return None
if self.plate_ids:
if len(self.plate_ids) == 0:
logging.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map(self):\n map_rupture(self)",
"def _annotate(self, mfccs):\n if self.slices is None or self.ipa_regions is None:\n raise ValueError(\"No IPA regions. Call setup_regions() prior\")\n\n # Define some short hands\n slices = self.slices\n ipa_regions = self.ipa_re... | [
"0.55028427",
"0.5452543",
"0.53672034",
"0.53237504",
"0.52756447",
"0.5196939",
"0.51112473",
"0.50430375",
"0.4966098",
"0.49301258",
"0.49227238",
"0.49188647",
"0.49120802",
"0.4898514",
"0.48940176",
"0.4874233",
"0.48714116",
"0.4864093",
"0.48624974",
"0.4861023",
"0.... | 0.7041455 | 0 |
Checks that the value is between 0 and 255. Returns integer value If the value is not valid, return 255 (better to see something than nothing! ) | def checkRGBRange(value):
try:
v = int(value)
if 0 <= v <= 255:
return v
except:
return 255 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_0to255(value):\n return 0 <= value <= 255",
"def validate_channel_value(value: int) -> None:\n if 0 <= value <= 255:\n pass\n else:\n raise ValueError(\"Color channel has to be in range [0; 255]\")",
"def assert_int_255(i):\n i=int(i)\n if i<0:\n i=0\n ... | [
"0.81240916",
"0.76555705",
"0.74300504",
"0.7175796",
"0.71642464",
"0.68537974",
"0.67089367",
"0.6578702",
"0.61355793",
"0.610267",
"0.6063346",
"0.60376084",
"0.6001554",
"0.59483194",
"0.593981",
"0.590963",
"0.5880775",
"0.58275723",
"0.5820898",
"0.58207875",
"0.58207... | 0.88311684 | 0 |
Instantiate a connection to the InfluxDB. | def main(host='10.84.109.148', port=8086):
user = ""
password = ""
dbname = "ruuvi1"
dbuser = ""
dbuser_password = ""
client = InfluxDBClient(host, port, user, password, dbname)
for mac in roovi_macs:
query = "select last(humidity),temperature, time from ruuvi_measurements where mac =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def influx_get_conn(self):\n self.influx = InfluxDB(server=self.influx_server,\n user=self.influx_user,\n password=self.influx_password,\n measurement=self.work_group)",
"def __init__(self, host: str = None, port: in... | [
"0.7887511",
"0.77946764",
"0.69377893",
"0.680846",
"0.62472725",
"0.6230291",
"0.612745",
"0.5940817",
"0.5867417",
"0.58417076",
"0.57907414",
"0.5789952",
"0.5775348",
"0.57736087",
"0.5743452",
"0.5723149",
"0.57013756",
"0.5694053",
"0.56934035",
"0.5678701",
"0.5650137... | 0.0 | -1 |
Return the path to the .rmfriend/notebooks in the user's home. | def notebook_cache_director():
return str(rmfriend_dir() / 'notebooks') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rmfriend_dir():\n return Path.home() / '.rmfriend'",
"def path_notebooks():\n return os.path.abspath(\n os.path.join(os.path.dirname(__file__), os.path.pardir, \"examples\")\n )",
"def get_pypirc_path():\n return os.path.join(os.path.expanduser('~'), '.pypirc')",
"def personaldir():\n ... | [
"0.76980567",
"0.75803745",
"0.61626834",
"0.6044589",
"0.6009812",
"0.6000162",
"0.5964518",
"0.5706943",
"0.56439793",
"0.5618542",
"0.5615655",
"0.5595845",
"0.55260384",
"0.5511747",
"0.55059624",
"0.5490332",
"0.5487344",
"0.5473823",
"0.5460637",
"0.5459757",
"0.5449562... | 0.7132139 | 2 |
Project `x` into the range [0, 1] | def normalize(x):
return (x - math_ops.reduce_min(x)) / (math_ops.reduce_max(x) - math_ops.reduce_min(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_to_start(x):\n x = (x + eps) / (x[0] + eps)\n return x",
"def scale_1d(x):\n return (min(x), max(x), len(x))",
"def apply(cls, x):\n return np.maximum(-1, np.minimum(1, x))",
"def apply(cls, x):\n return np.maximum(0, np.minimum(1, 0.2*x + 0.5))",
"def forward(self, x):\n ... | [
"0.68482524",
"0.6782236",
"0.67437625",
"0.6622736",
"0.6591315",
"0.6496716",
"0.640152",
"0.639846",
"0.639846",
"0.639846",
"0.6358438",
"0.6304055",
"0.6271856",
"0.6268498",
"0.6260991",
"0.61823845",
"0.6180613",
"0.6172947",
"0.6166156",
"0.61338955",
"0.61338955",
... | 0.6107365 | 22 |
Returns the estimatated distance between two objects | def distance_between_objects(obj1, obj2, hfov, img_x):
distance = obj2.x - (obj1.x+obj1.w)
d = (obj1.d+obj2.d)/2
width = 2 * d*math.tan((hfov/2)*math.pi/180)
return (distance*width) / img_x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _object_distance(self, object1, object2):\n return np.linalg.norm(np.array(object1) - np.array(object2))",
"def calculate_distance(asteroid_1: Asteroid, asteroid_2: Asteroid) -> float:\n dy = asteroid_2.y - asteroid_1.y\n dx = asteroid_2.x - asteroid_1.x\n return math.sqrt(dy * dy + dx * dx)"... | [
"0.81385773",
"0.75308126",
"0.74892443",
"0.7482304",
"0.7419098",
"0.74067575",
"0.7396446",
"0.7392414",
"0.7382817",
"0.73563564",
"0.73439986",
"0.7317492",
"0.73123944",
"0.73088586",
"0.7303744",
"0.7289894",
"0.72821766",
"0.7278802",
"0.7277617",
"0.72537076",
"0.721... | 0.67790043 | 93 |
Draws a bounding box for each object on the color image | def draw_bounding_box(objects,color):
for i in range(len(objects)):
x, y, w, h, d = objects[i].get_attributes()
print(x, y, w, h, d)
corr = get_correction(d, a, hfov, x)
cv2.rectangle(color, (x-corr, y), (x+w-corr, y+h), (0, 255, 0), 4)
try:
real_x, real_y = ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __draw_boxes(self, img, bboxes, color=(128, 0, 0), thick=4):\n\n # Make a copy of the image\n imcopy = np.copy(img)\n # Iterate through the bounding boxes\n for bbox in bboxes:\n # Draw a rectangle given bbox coordinates\n cv2.rectangle(imcopy, bbox[0], bbox[1]... | [
"0.7597771",
"0.7572724",
"0.75466055",
"0.75066733",
"0.74624497",
"0.7406956",
"0.73561734",
"0.73243684",
"0.7296845",
"0.72515774",
"0.7206411",
"0.72036135",
"0.7202479",
"0.7199184",
"0.71903515",
"0.7187147",
"0.71545327",
"0.71491724",
"0.71165746",
"0.7088277",
"0.70... | 0.7399913 | 6 |
Convert degrees to quaternions | def to_quaternion(roll = 0.0, pitch = 0.0, yaw = 0.0):
t0 = math.cos(math.radians(yaw * 0.5))
t1 = math.sin(math.radians(yaw * 0.5))
t2 = math.cos(math.radians(roll * 0.5))
t3 = math.sin(math.radians(roll * 0.5))
t4 = math.cos(math.radians(pitch * 0.5))
t5 = math.sin(math.radians(pitch * 0.5))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_quaternion(self, q):\n self._normalise()\n return self * q * self.conjugate",
"def angle_to_quaternion(angle):\n\treturn Quaternion(*tf.transformations.quaternion_from_euler(0, 0, angle))",
"def angle_to_quaternion(angle):\n return Quaternion(*tf.transformations.quaternion_from_eul... | [
"0.7152074",
"0.7079169",
"0.6979342",
"0.68902564",
"0.688503",
"0.6838166",
"0.68257564",
"0.6786422",
"0.6782196",
"0.67521816",
"0.6745304",
"0.67351747",
"0.6730065",
"0.6655554",
"0.6650059",
"0.66377956",
"0.66352797",
"0.66168916",
"0.6613836",
"0.6551517",
"0.6550865... | 0.6106964 | 61 |
Remove words to a word_list. | def RemoveWords(cls, word_list, words):
entity = WordList.get_by_id(word_list)
if not entity:
return "word list {} does not exist".format(word_list)
entity.words = list(set(entity.words) - set(words))
entity.numWords = len(entity.words)
entity.put()
return Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopWord_removal(list_of_words):\n curated_list = [w for w in list_of_words if not w in STOP_WORDS]\n return curated_list",
"def stopword_removal(words):\n stops = set(stopwords.words('english'))\n words = [w for w in words if w not in stops]\n return words",
"def delete_words(self, words=No... | [
"0.7851758",
"0.7724405",
"0.763472",
"0.7603292",
"0.74906254",
"0.7482885",
"0.74648875",
"0.7452638",
"0.7338537",
"0.72449756",
"0.72103465",
"0.71710074",
"0.71606266",
"0.71414477",
"0.7125571",
"0.711526",
"0.7112146",
"0.7112146",
"0.7112146",
"0.7112146",
"0.7102582"... | 0.77556854 | 1 |
Given a URL, removes the query parameter and returns the modified URL. | def delete_query_parameter(url, param_name):
scheme, netloc, path, query_string, fragment = urlsplit(url)
query_params = parse_qs(query_string)
query_params.pop(param_name, None)
new_query_string = urlencode(query_params, doseq=True)
url = urlunsplit((scheme, netloc, path, new_query_string, fragment... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_url(self, url):\n return \"\".join(url.split(\"?\")[:1])",
"def clean_url(url):\n return url[:url.find('?')]",
"def remove_id(url):\n u = urlparse(url)\n query = parse_qs(u.query, keep_blank_values=True)\n query.pop(\"eo_id\", None)\n u = u._replace(query=urlencode(query, True)... | [
"0.74205333",
"0.73304033",
"0.7303196",
"0.7091062",
"0.68307376",
"0.6787165",
"0.6771821",
"0.673767",
"0.67075986",
"0.6707549",
"0.6660232",
"0.6659008",
"0.66486514",
"0.65948373",
"0.6558577",
"0.65344167",
"0.6518179",
"0.6486246",
"0.64208245",
"0.63585556",
"0.62422... | 0.7665952 | 0 |
Get the current config file and return as string | def readconfig(self):
files = [path.join(self.ccddpath, 'do_not_touch', 'LastSettings.ini'),
path.join(self.ccddpath, 'config', 'Config.ini'),
self.outputConfig]
last = sorted(files, reverse=True,
key=lambda f: path.getmtime(f) if path.isfile(f) el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_file(self):\n return self[CONFIG_FILE_KEY]",
"def current_config_file(self):\n return self.mp_conf_file.current_file",
"def getConfigFile(self):\n if not self.__args.configfile:\n msg = \"not set configfile\"\n self.__logger.error(msg)\n return \... | [
"0.8251951",
"0.81235313",
"0.7842329",
"0.77193254",
"0.7555629",
"0.75317407",
"0.74892527",
"0.7437479",
"0.74209017",
"0.7416657",
"0.7407642",
"0.73740304",
"0.7364225",
"0.7333094",
"0.7331118",
"0.7300617",
"0.7246858",
"0.71828306",
"0.7167634",
"0.71551657",
"0.71432... | 0.6341059 | 94 |
mote.x and mote.y are in km. This function returns the distance in m. | def _computeDistance(self, mote, neighbor):
return 1000*math.sqrt((mote.x - neighbor.x)**2 +
(mote.y - neighbor.y)**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_distance(x: float, y: float) -> float:\n # return geopy.distance.vincenty(x, y).km\n R = 6370\n lat1 = radians(x[0]) #insert value\n lon1 = radians(x[1])\n lat2 = radians(y[0])\n lon2 = radians(y[1])\n\n dlon = lon2 - lon1\n dlat = lat2- lat1\n\n a = sin(dlat / 2)**2 + cos... | [
"0.69916576",
"0.6941455",
"0.68443763",
"0.68390346",
"0.68390346",
"0.68390346",
"0.68390346",
"0.68390346",
"0.68241656",
"0.68186426",
"0.6757231",
"0.67562413",
"0.66565853",
"0.66351026",
"0.6605541",
"0.6573575",
"0.6517398",
"0.64951694",
"0.64602184",
"0.6456034",
"0... | 0.6935766 | 3 |
Loads the data necessary for train/test from a csv file into a Pandas.DataFrame object | def load_data_csv(inputfile, list_names, parse_dates_list):
logger.info("loading data...")
try:
os.path.exists(inputfile)
except:
raise IOError("Input file is missing")
dataframe = pd.read_csv(inputfile,
header=None,
names=list_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_import(path):\n train_path = os.path.join(path, \"train.csv\")\n test_path = os.path.join(path, \"test.csv\")\n df_train = pd.read_csv(train_path)\n df_test = pd.read_csv(test_path)\n return df_train, df_test",
"def load_data(path):\n train = pd.read_csv(os.path.join(path,'train.csv'))... | [
"0.77727044",
"0.7603334",
"0.7545617",
"0.7386479",
"0.7305891",
"0.72954035",
"0.7260921",
"0.7228206",
"0.72163826",
"0.7207404",
"0.7182295",
"0.71520036",
"0.71165663",
"0.7110831",
"0.7090227",
"0.7024755",
"0.70140123",
"0.6961308",
"0.69225365",
"0.6911867",
"0.691063... | 0.0 | -1 |
Set groupname of the report. | def set_group_name(self, name):
self.groupname = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_group_name(self):\n self._scene_gen.group_name = self._group_name_le.text()\n self._refresh_view()",
"def set_group_name(self, name):\n params = [('groupname', name, 'cdata')]\n\n self.get(COMMAND_UIC, 'SetGroupName', params)",
"def setName(self, *args):\n return _li... | [
"0.8050104",
"0.8012522",
"0.7570738",
"0.7243205",
"0.7023362",
"0.691728",
"0.68554384",
"0.6819145",
"0.66873676",
"0.66790146",
"0.6601459",
"0.65660447",
"0.65660447",
"0.65660447",
"0.6433492",
"0.6431331",
"0.6395295",
"0.6371179",
"0.63406974",
"0.6303644",
"0.6300549... | 0.850103 | 0 |
Return the groupname to the report | def get_group_name(self):
return self.groupname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_name(self, report):\n match = re.search(\"(.*)\\:\\s*\\(groupid\", report)\n if match:\n return match.group(1)",
"def group_name(self) -> str:\n return pulumi.get(self, \"group_name\")",
"def log_group_name(self) -> str:\n ...",
"def group_name(self) -> pulumi.... | [
"0.7974205",
"0.7860595",
"0.78541356",
"0.780368",
"0.7597937",
"0.7597937",
"0.7444693",
"0.7379144",
"0.72959626",
"0.7257613",
"0.7162392",
"0.7162392",
"0.7162392",
"0.7162392",
"0.70845395",
"0.7060209",
"0.7049915",
"0.7048752",
"0.70115834",
"0.7011294",
"0.7011294",
... | 0.7755499 | 4 |
Destructor close the connection. | def __del__(self):
self.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.connection = None",
"def close(self): \n\t\tself.connection = None",
"def close(self):\n try:\n self.connection.Close()\n del self.connection\n except:\n pass",
"def close(self): \n self.connection.close()",
"def close(sel... | [
"0.835186",
"0.8313247",
"0.822382",
"0.8159104",
"0.80491763",
"0.80447197",
"0.80311203",
"0.80311203",
"0.80311203",
"0.80311203",
"0.80311203",
"0.80311203",
"0.80311203",
"0.8021504",
"0.7963166",
"0.7963166",
"0.7954358",
"0.79502004",
"0.7932271",
"0.7932271",
"0.79322... | 0.7325219 | 70 |
Multiply holdings by their current price to get the total account value. | def calc_total_btc():
total_btc_val = 0
for holding in val["accHoldings"]:
free = val["accHoldings"][holding]["free"]
locked = val["accHoldings"][holding]["locked"]
total = float(free) + float(locked)
if holding + "BTC" in val["coins"]:
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_total(price):\n\n quantity = 20\n return price * quantity",
"def total_price(self) -> Decimal:\n return self.unit_price * self.quantity",
"def get_total_price(self):\n i = self.get_copy_with_resolved_dependencies()\n total_price = Decimal(0)\n for product in i['pro... | [
"0.67340297",
"0.67209387",
"0.6670469",
"0.6566266",
"0.6467524",
"0.6405414",
"0.6363964",
"0.6346994",
"0.6338643",
"0.62725943",
"0.6270498",
"0.6205983",
"0.61875796",
"0.61362714",
"0.6086991",
"0.6072024",
"0.60573834",
"0.60513294",
"0.60445607",
"0.6036161",
"0.60040... | 0.652557 | 4 |
Unnormalized target density as a function of the parameters. | def target(w, z):
return log_joint(data_dim=data_dim,
latent_dim=latent_dim,
num_datapoints=num_datapoints,
stddv_datapoints=stddv_datapoints,
w=w, z=z, x=x_train) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tensor_density(self):\r\n from .converter import Converter\r\n return Converter.convert_density(self)",
"def target_distribution(q):\n weight = q ** 2 / q.sum(0)\n return (weight.T / weight.sum(1)).T",
"def predict_density(self, Fmu, Fvar, Y):\n integrand = self.log_prob\n ... | [
"0.62130064",
"0.59175223",
"0.5897693",
"0.58926237",
"0.58926237",
"0.58926237",
"0.5857558",
"0.58128786",
"0.579412",
"0.5789747",
"0.5788625",
"0.57870674",
"0.5770031",
"0.5739464",
"0.5731856",
"0.56917477",
"0.56654096",
"0.56610537",
"0.56277674",
"0.561409",
"0.5607... | 0.0 | -1 |
Return initials of first, last and middle name. If the middle name is 'NA', return only the initials of the first and the last name. >>> get_initials("Alfred E. Newman") >>> 'A.E.N.' >>> get_initials("John NA Smith") >>> 'J.S.' | def get_initials(name):
# your code here
result = ''
na = name.find(' NA ')
if na != -1:
name = name[:na] + name[na+3:]
name += ' '
while name.find(' ') != -1:
result += name[0] + '.'
name = name[name.find(' ')+1:]
print(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_initials(fullname):\r\n \r\n saved_name = fullname\r\n names_listed = saved_name.split()\r\n initials = ''\r\n\r\n for name in names_listed:\r\n\t initials += name[0].upper()\r\n\r\n return initials",
"def get_initials(fullname):\n\n initials = [name[0] for name in fullname.upper(... | [
"0.69112736",
"0.67183125",
"0.67066884",
"0.6628296",
"0.6561825",
"0.6561313",
"0.63261825",
"0.6227578",
"0.6145859",
"0.6134692",
"0.6113913",
"0.6100391",
"0.5971214",
"0.59453726",
"0.58944106",
"0.5863364",
"0.58330166",
"0.58330166",
"0.5827056",
"0.57931167",
"0.5789... | 0.6945922 | 0 |
Get Current User UUID | def get_current_user(uuid='1000211211101'):
logger.info("User Detail get", data={'uuid': str(uuid)})
return uuid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUserUuid(userId):\n return searchForUser(userId)['uuid']",
"def get_user_id():\n return os.getuid()",
"def context_user_id(self) -> str | None:\n return bytes_to_uuid_hex_or_none(self.context_user_id_bin)",
"def get_uid(self):\n value = unicode(self.id) + self.password + app.config... | [
"0.7867684",
"0.7715434",
"0.75741965",
"0.7508477",
"0.7493808",
"0.7413881",
"0.7413881",
"0.74003136",
"0.7391101",
"0.7391101",
"0.7387345",
"0.7385178",
"0.7378221",
"0.7360182",
"0.7344115",
"0.7332247",
"0.7316385",
"0.72946906",
"0.7293174",
"0.72898847",
"0.72608984"... | 0.82801807 | 0 |
Tests that a ValueError is raised if the input contains negative values. | def test_negative_input(self):
negative_data_down = np.full_like(
self.cube_uv_down.data, dtype=np.float32, fill_value=-0.1
)
negative_uv_down = self.cube_uv_down.copy(data=negative_data_down)
msg = (
"The radiation flux in UV downward contains data "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_negative_values_not_allowed(self, test_input, expected, sc):\n expected_err_msg = f'negatives not allowed {expected}'\n with pytest.raises(ValueError):\n sc.add(test_input)\n\n try:\n sc.add(test_input)\n except ValueError as e:\n assert str(e) ... | [
"0.7965208",
"0.7622697",
"0.7287201",
"0.7174587",
"0.71631014",
"0.7154273",
"0.71208745",
"0.705993",
"0.7004512",
"0.7004377",
"0.6962989",
"0.6890664",
"0.6882747",
"0.68790656",
"0.68640274",
"0.6821007",
"0.6797254",
"0.6782866",
"0.6735116",
"0.6693284",
"0.6680623",
... | 0.7293097 | 2 |
Creates a copy of this settings object | def clone(self):
settings = SettingsManager(None)
self.copy_settings(settings)
return settings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return self.__class__(dict(self))",
"def settings() -> Settings:\n return Settings()",
"def __copy__(self):\n cls = self.__class__\n result = cls.__new__(cls)\n to_copy = {\"_cache\", \"_buffers\", \"_parameters\", \"_modules\"}\n result.__dict__.update(\... | [
"0.69388205",
"0.6916724",
"0.6896143",
"0.68879104",
"0.6752529",
"0.6737952",
"0.669271",
"0.6628516",
"0.6611892",
"0.6594127",
"0.6550692",
"0.6547415",
"0.6545567",
"0.6543936",
"0.65056056",
"0.64693385",
"0.6463498",
"0.6460856",
"0.64513016",
"0.64467436",
"0.6443725"... | 0.80444247 | 0 |
Group elements of an iterable by chunks of size `n`, e.g. grouper(range(9), 4) > (0, 1, 2, 3), (4, 5, 6, 7), (8, None, None, None) | def _grouper(iterable: Iterable[Any], n: int, fillvalue=None) -> Iterator[Tuple[Any]]:
it = iter(iterable)
while True:
values = []
for _ in range(n):
try:
value = next(it)
except StopIteration:
values.extend([fillvalue] * (n - len(values)))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grouper(iterable, n):\n it = iter(iterable)\n while True:\n chunk = tuple(islice(it, n))\n if not chunk:\n return\n yield chunk",
"def grouper(n, iterable):\n\tit = iter(iterable)\n\twhile True:\n\t\tchunk = tuple(itertools.islice(it, n))\n\t\tif not chunk:\n\t\t\treturn... | [
"0.8758496",
"0.8743048",
"0.87405896",
"0.8343799",
"0.81411135",
"0.8027102",
"0.7934969",
"0.7934969",
"0.792317",
"0.7900938",
"0.7859235",
"0.7850651",
"0.7850651",
"0.7835211",
"0.7829011",
"0.7823224",
"0.78225815",
"0.78007966",
"0.77558225",
"0.7744267",
"0.7739982",... | 0.76326203 | 37 |
Retrieves the list of all State objects. | def all_States():
new_dict = []
for state in storage.all('State').values():
new_dict.append(state.to_dict())
return jsonify(new_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_states(self):\n return self._states",
"def all_states():\n states = []\n states_values = storage.all(\"State\").values()\n for obj in states_values:\n states.append(obj.to_dict())\n return jsonify(states)",
"def all_states():\n dict = storage.all(State)\n list = []\n... | [
"0.8187568",
"0.81388557",
"0.80957466",
"0.80015796",
"0.7976024",
"0.79692847",
"0.7947132",
"0.7883743",
"0.7725651",
"0.7645042",
"0.75137657",
"0.74623036",
"0.74593973",
"0.74432606",
"0.74324256",
"0.7422732",
"0.7330608",
"0.7307734",
"0.7259946",
"0.71988535",
"0.719... | 0.7461146 | 12 |
GET the list of all State objects. | def get_state(state_id):
try:
state = jsonify(storage.get(State, state_id).to_dict())
return state
except:
abort(404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_states():\n states = storage.all(State).values()\n return jsonify([state.to_dict() for state in states]), 200",
"def get_states():\n try:\n ''' Returns a list of states in list named result '''\n data = State.select()\n return ListStyle.list(data, request), 200\n exce... | [
"0.804309",
"0.79606843",
"0.7934324",
"0.78133273",
"0.779238",
"0.7787049",
"0.77503985",
"0.77433527",
"0.76419014",
"0.759356",
"0.75911593",
"0.7582023",
"0.74751246",
"0.74538344",
"0.74288446",
"0.7404129",
"0.7403648",
"0.7346524",
"0.73350185",
"0.73136795",
"0.73089... | 0.0 | -1 |
GET the list of all State objects. | def delete_state(state_id):
state = storage.get(State, state_id)
if state:
state.delete(), storage.save()
return {}
else:
abort(404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_states():\n states = storage.all(State).values()\n return jsonify([state.to_dict() for state in states]), 200",
"def get_states():\n try:\n ''' Returns a list of states in list named result '''\n data = State.select()\n return ListStyle.list(data, request), 200\n exce... | [
"0.8043281",
"0.7960459",
"0.7935524",
"0.7815175",
"0.77933246",
"0.77880335",
"0.7750822",
"0.7745067",
"0.7642498",
"0.7595429",
"0.7592909",
"0.75810033",
"0.74763393",
"0.74545527",
"0.7429209",
"0.7404886",
"0.7402878",
"0.73480237",
"0.7336812",
"0.73147243",
"0.731052... | 0.0 | -1 |
Given a node and the head pointer of a linked list, adds the node before the linked list head and returns the head of the list | def addNodeFront(node, head, tail) :
if head is None :
head = node
tail = node
return (head, tail)
head.prev = node
node.next = head
head = node
return (head, tail) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_node(self, head, node):\n prev, curr = None, head\n while curr.val < node.val:\n prev, curr = curr, curr.next\n if not prev:\n head = node\n else:\n prev.next = node\n node.next = curr\n return head",
"def add_before(self, data... | [
"0.7588011",
"0.7484849",
"0.7422113",
"0.72437185",
"0.7157142",
"0.7155171",
"0.71177197",
"0.7100277",
"0.7091714",
"0.7079606",
"0.70743525",
"0.70183945",
"0.69417465",
"0.6889334",
"0.68776405",
"0.68761235",
"0.6865713",
"0.6800091",
"0.678998",
"0.6779727",
"0.6779602... | 0.7801628 | 0 |
Backward step of the network. Implemented by default, but deriving classes must define an attribute "optimizer" in their __init__ method. | def optimize(self, loss):
loss.backward()
self.optimizer.step()
self.optimizer.zero_grad() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward(self, gradient):\n raise NotImplementedError()",
"def backward_and_step(self, loss):\n self.opt.zero_grad()\n loss.backward()\n self.opt.step()",
"def backward(self):\n gradient = blah\n return gradient",
"def backward(self):\n gradient = blah\n ... | [
"0.720881",
"0.7107114",
"0.7046352",
"0.7046352",
"0.700538",
"0.6989039",
"0.6989039",
"0.6869203",
"0.68565017",
"0.68139684",
"0.6796907",
"0.6796907",
"0.6791386",
"0.6767325",
"0.67176676",
"0.6711689",
"0.66982853",
"0.6681044",
"0.66780317",
"0.66405785",
"0.66174036"... | 0.6187517 | 57 |
Xavier initialization for a parameter matrix. Initializes with torch.nn.init.xavier_uniform with the right gain given | def xavier_uniform(self, weight, activation):
if activation == 'none':
nn.init.xavier_uniform(weight, gain=layers.gain(activation))
elif activation == 'sigmoid':
nn.init.xavier_uniform(weight, gain=layers.gain(activation))
elif activation == 'tanh':
nn.init.xa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xavier_init(module, gain=1, bias=0, distribution='normal'):\n # assert distribution in ['uniform', 'normal']\n if distribution == 'uniform':\n nn.init.xavier_uniform_(module.weight, gain=gain)\n else:\n nn.init.xavier_normal_(module.weight, gain=gain)\n if hasattr(module, 'bias') and ... | [
"0.7348751",
"0.7156634",
"0.69509864",
"0.69090307",
"0.68615836",
"0.6831558",
"0.68271464",
"0.68123025",
"0.68107855",
"0.68107855",
"0.6795408",
"0.67653316",
"0.66074896",
"0.65894556",
"0.65408325",
"0.6387895",
"0.6247495",
"0.6240593",
"0.6230728",
"0.6230728",
"0.62... | 0.58623767 | 37 |
Create a new TextModel. Expects config to have a boolean "tune_embeds". | def __init__(self, name, config, embed_mat):
if 'tune_embeds' not in config.keys():
raise ValueError('config must define "tune_embeds".')
super(TextModel, self).__init__(name, config)
self.embeds = nn.Embedding(embed_mat.shape[0], embed_mat.shape[1])
self.embeds.weight = nn.P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model(cfg, char_voca, word_voca=None, gazet=None, pos_voca=None):\n\n # Build Embedder\n embedder = Embedder(\n window=cfg.window,\n char_voca=char_voca,\n word_voca=word_voca,\n jaso_dim=cfg.jaso_dim,\n char_dim=cfg.char_dim,\n word_dim=cfg.word_dim,\n ... | [
"0.619802",
"0.61185306",
"0.6046575",
"0.587386",
"0.58679396",
"0.584264",
"0.58395857",
"0.5760611",
"0.57515085",
"0.56368214",
"0.5616541",
"0.5616476",
"0.56148154",
"0.56109905",
"0.55994916",
"0.55810153",
"0.554015",
"0.5535818",
"0.55322784",
"0.55292284",
"0.549724... | 0.7290144 | 0 |
Returns name of single column. | def get_single_col_by_input_type(input_type, column_definition):
cols = [tup[0] for tup in column_definition if tup[2] == input_type]
if len(cols) != 1:
raise ValueError('Invalid number of columns for {}'.format(input_type))
return cols[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_name(self) -> Optional[str]:\n return pulumi.get(self, \"column_name\")",
"def get_name(self):\n return self.col_name",
"def columnName(self):\n return self.__column",
"def column_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"column_name\")",
"def colum... | [
"0.83465815",
"0.83181846",
"0.82387584",
"0.81312305",
"0.81312305",
"0.8106126",
"0.7688238",
"0.7624985",
"0.7624985",
"0.75644904",
"0.7555113",
"0.74406916",
"0.7410737",
"0.7350416",
"0.72444785",
"0.7188926",
"0.71315175",
"0.7110793",
"0.7038446",
"0.69953305",
"0.699... | 0.0 | -1 |
Splits data frame into trainingvalidationtest data frames. This also calibrates scaling object, and transforms data for each split. | def split_data(self, df, valid_boundary=1315, test_boundary=1339):
print_info('Formatting train-valid-test splits.')
index = df['days_from_start']
train = df.loc[index < valid_boundary]
valid = df.loc[(index >= valid_boundary - 7) & (index < test_boundary)]
test = df.loc[index ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_data(self, df, valid_boundary=2016, test_boundary=2018):\n\n stock_count = len(self.sl)\n test_ratio = 0.2\n print('Stock count:%d'% stock_count)\n train_x = []\n test_x = []\n for label_, d_ in enumerate(self.sl):\n stock_train_len = int(len(d_.train_... | [
"0.7087161",
"0.6930378",
"0.6849551",
"0.68191576",
"0.6818978",
"0.6805677",
"0.67629784",
"0.6714202",
"0.6682093",
"0.6676112",
"0.6672567",
"0.6661679",
"0.6619192",
"0.661823",
"0.6614971",
"0.6606569",
"0.6591506",
"0.6540361",
"0.6525998",
"0.65153104",
"0.64898115",
... | 0.6824166 | 3 |
Get the probability that this thermal works | def P_work(self):
return self._P | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_probability(self):\n return 0",
"def p(self) -> Probability:\n ...",
"def prob(self):\n\t\treturn self._prob",
"def get_dist_probability(self):\n return self.dist_probability",
"def p(self) -> float:\n return self._pwr.real",
"def prob(self, w):\n return s... | [
"0.76133156",
"0.7272944",
"0.7110367",
"0.7082187",
"0.6998625",
"0.6956375",
"0.6784665",
"0.6710955",
"0.6710955",
"0.6710378",
"0.6665556",
"0.66268814",
"0.66107345",
"0.66082555",
"0.6600521",
"0.6567769",
"0.6559627",
"0.6541004",
"0.6538538",
"0.6513874",
"0.6506042",... | 0.0 | -1 |
compute the index for prob based on parents | def counterCompute(line, nodes, rowname):
counter = 0
if nodes != 1: #node has parents
parent = line[1: nodes]
for par in parent:
if ("Not " + par) in rowname: #one parent is "Not par"
counter = counter + math.pow(2, nodes - 2 - parent.index(par))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_idx(idx):\n return (idx - 1) >> 1",
"def get_parent_index(self, child):\n return (child-1)//2",
"def parent_index(self, parent, parent_names):\n if parent == 'mother' or parent == 'm':\n return [np.where(parent_names == x)[0][0] for x in self.mothers]\n if parent =... | [
"0.65415597",
"0.6504456",
"0.6354823",
"0.6158009",
"0.61444426",
"0.61141616",
"0.6108109",
"0.60908926",
"0.6076263",
"0.60275435",
"0.60132444",
"0.59842616",
"0.5982496",
"0.58825904",
"0.58802086",
"0.5876402",
"0.58465517",
"0.5840753",
"0.58221555",
"0.58136576",
"0.5... | 0.57556546 | 21 |
Helps user choose a specialty for their character. | def chooseSpecialties(self):
#specialties = {}
def createSpecialties(fileName):
""" (str) -> None
Helper function to create specialties dict from file.
"""
specialtyFile = open(fileName,'r')
current_specialty = ''
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specialty(self, specialty):\n\n self._specialty = specialty",
"def specialty(self, specialty):\n\n self._specialty = specialty",
"def specialty(self):\n return self._specialty",
"def specialty(self):\n return self._specialty",
"def select_character(self):\n pass",
"... | [
"0.7121746",
"0.7121746",
"0.6523552",
"0.6523552",
"0.61076",
"0.607969",
"0.6074597",
"0.6035614",
"0.58869815",
"0.58264095",
"0.57167387",
"0.5711908",
"0.5689773",
"0.566196",
"0.56461483",
"0.5622803",
"0.55687475",
"0.55495965",
"0.55199516",
"0.5499366",
"0.548861",
... | 0.5849819 | 9 |
Calculates the number of days between two dates. | def days_between_dates(year1, month1, day1, year2, month2, day2):
month_days_mapper = {1: 0, 2: 31, 3: 59, 4: 90, 5: 120, 6: 151, 7: 181, 8: 212, 9: 243, 10: 273, 11: 304, 12: 334}
leap_year_month_days_mapper = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 181, 8: 213, 9: 244, 10: 274, 11: 305,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_days(start: date, end: date) -> int:\n delta = end - start\n return delta.days + 1",
"def days_between(self, d1, d2):\n self.is_not_used()\n try:\n d1 = self.format_date(d1)\n d2 = self.format_date(d2)\n d1 = datetime.strptime(d1, '%Y-%m-%d')\n ... | [
"0.8247624",
"0.81360364",
"0.8124675",
"0.798206",
"0.7979802",
"0.7881164",
"0.7860623",
"0.7787762",
"0.77590597",
"0.77543473",
"0.76151407",
"0.76122016",
"0.7607027",
"0.75962883",
"0.75622046",
"0.7500045",
"0.7493242",
"0.7490776",
"0.7411161",
"0.7269492",
"0.7241104... | 0.6807958 | 26 |
Return a service suitable for creating an application object. | def foghord_service():
# create a resource to serve static files
foghorn = Main()
factory = FoghornDNSServerFactory(
clients=[foghorn.foghorn, client.Resolver(resolv='/etc/resolv.conf')]
)
udp_protocol = dns.DNSDatagramProtocol(controller=factory)
udp_server = internet.UDPServer(foghor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_app_factory(global_conf, **local_conf):\n conf = global_conf.copy()\n conf.update(local_conf)\n return ServiceApi(conf)",
"def app():\n app = create_app()\n return app",
"def createService(data):\n return Service(data).create()",
"def _create_app_instance(script_info):\n retu... | [
"0.7375327",
"0.71511126",
"0.706859",
"0.7045131",
"0.6989277",
"0.68644583",
"0.68249923",
"0.67974627",
"0.670759",
"0.6687094",
"0.6684016",
"0.66556597",
"0.66489196",
"0.6644253",
"0.6644253",
"0.6610243",
"0.6579993",
"0.6537548",
"0.6528282",
"0.6515839",
"0.6509325",... | 0.0 | -1 |
Get all students from given class | def get_students_of_class(students, class_name):
for row in students:
class_list = [row for row in students if row[4]== class_name]
return class_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_student_classes():\n class_data = query_db(\n \"SELECT classes.id, classes.name FROM classes JOIN roster \"\n \"ON roster.class_id = classes.id where people_id=?;\",\n [flask.session[\"id\"]],\n )\n classes = []\n for class_info in class_data:\n student_class = {}\n ... | [
"0.74630594",
"0.7432237",
"0.73098016",
"0.7240487",
"0.71658707",
"0.68208814",
"0.67006475",
"0.6684132",
"0.6672435",
"0.6664255",
"0.6644078",
"0.6603159",
"0.6539757",
"0.6496716",
"0.6462748",
"0.6403005",
"0.6377992",
"0.623983",
"0.6238557",
"0.62188524",
"0.61859757... | 0.77778774 | 0 |
Returns rounded average presence of all students. For instance, if average presence is 35.4912, returned value should be 35, if average presence is 41.5, returned value should be 42, | def get_average_presence_of_students(students):
total_presence = 0
for row in students:
total_presence += int(row[6])
average_presence = str(total_presence/len(students))
if average_presence.find(".5") != -1:
average_presence = float(average_presence) + 1
else:
average_prese... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_grade_of_students(students):\n total_grade = 0\n for row in students:\n total_grade += int(row[5])\n return total_grade/len(students)",
"def find_mean(values):\n return sum(values) / len(values)",
"def get_mean_score(rating_scores):\n return sum(rating_scores) / len(rating_s... | [
"0.6793108",
"0.6641982",
"0.6615014",
"0.6582941",
"0.6582941",
"0.6580033",
"0.6579478",
"0.65237385",
"0.64735353",
"0.6432729",
"0.64266616",
"0.64026177",
"0.63828",
"0.63405037",
"0.6329886",
"0.6328724",
"0.6323382",
"0.631193",
"0.6307633",
"0.62993544",
"0.6295011",
... | 0.8302717 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.81922984",
"0.80933887",
"0.80272716",
"0.8016492",
"0.79913706",
"0.79885876",
"0.79777396",
"0.79729784",
"0.7958926",
"0.7954523",
"0.79347897",
"0.7931899",
"0.7931772",
"0.7928666",
"0.7923684",
"0.7921764",
"0.79213995",
"0.7920191",
"0.792016",
"0.7919876",
"0.79153... | 0.7826094 | 80 |
Transforms a given YIQ image into the RGB color space. | def yiq2rgb(imYIQ):
return __image_color_conversion(imYIQ, YIQ_TO_RGB_MATRIX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transformYIQ2RGB(imgYIQ: np.ndarray) -> np.ndarray:\r\n yiq_from_rgb = np.array([[0.299, 0.587, 0.114],\r\n [0.59590059, -0.27455667, -0.32134392],\r\n [0.21153661, -0.52273617, 0.31119955]])\r\n rgb_from_yiq = np.linalg.inv(yiq_from_rgb)\r\n\r\n ... | [
"0.83588094",
"0.8076694",
"0.79933584",
"0.7953755",
"0.76621914",
"0.75707406",
"0.7206099",
"0.70664865",
"0.7037151",
"0.70197064",
"0.68764114",
"0.6860504",
"0.6794821",
"0.672972",
"0.6726538",
"0.6599862",
"0.6410962",
"0.6409459",
"0.637483",
"0.628344",
"0.6238949",... | 0.82749236 | 1 |
Preforms optimal quantization of a given image (grayscale or RGB). | def quantize(im_orig, n_quant, n_iter):
if im_orig.ndim == RGB_DIM:
# Quantize only Y channel.
im_yiq = rgb2yiq(im_orig)
result = __gray_quantize(im_yiq[:, :, Y_CHANNEL], n_quant, n_iter)
im_yiq[:, :, Y_CHANNEL] = result[IMAGE_LOCATION]
# Convert back to RGB space.
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantize(im_orig, n_quant, n_iter):\n shape_len = len(im_orig.shape)\n if shape_len == 2: # grayscale\n return quantization_helper(im_orig, n_quant, n_iter)\n\n elif shape_len == 3: # rgb\n im_yiq = rgb2yiq(im_orig)\n y = im_yiq[:, :, 0]\n y_quant, error = quantization_hel... | [
"0.63148415",
"0.61105555",
"0.6054566",
"0.58383334",
"0.5813454",
"0.5726609",
"0.5710445",
"0.56961125",
"0.5647151",
"0.5623341",
"0.56224835",
"0.55868816",
"0.55237335",
"0.5523436",
"0.55145216",
"0.54795593",
"0.54795593",
"0.54795593",
"0.5456748",
"0.5440898",
"0.54... | 0.5952959 | 3 |
Return the error rate based on dense predictions and 1hot labels. | def error_rate(predictions, labels):
return 100.0 - (
100.0 *
np.sum(np.argmax(predictions, 1) == np.argmax(labels, 1)) /
predictions.shape[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_rate(predictions, labels):\n return 100.0 - (\n 100.0 *\n np.sum(np.argmax(predictions, 1) == np.argmax(labels, 1)) /\n predictions.shape[0])",
"def error_rate(predictions, labels):\n return 100.0 - (100*(np.sum(predictions == labels)/float(predictions.shape[0]*predictions.shape[1]))... | [
"0.7713525",
"0.7706645",
"0.768706",
"0.7657484",
"0.7649344",
"0.69118077",
"0.67318577",
"0.6703902",
"0.6648914",
"0.6630919",
"0.6536632",
"0.6529188",
"0.6512682",
"0.6361774",
"0.6340082",
"0.63257635",
"0.6299813",
"0.6283828",
"0.6265644",
"0.62428445",
"0.6220013",
... | 0.7678756 | 3 |
Exchange should not take into account price value for orders of type `market`. | def get_safe_price(side: str):
return (
const.MIN_SUM if side == const.BUY
else const.MAX_SUM
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_market(self):\n return(not self.is_pending)",
"def clear_market(self, price):\n self.price = price\n\n electricity_sales = self.plant.power_generation * price.electricity\n display_as(electricity_sales, \"kUSD\")\n\n self.plant.revenue = electricity_sales\n self.p... | [
"0.65249014",
"0.62295175",
"0.61289155",
"0.61225677",
"0.59502697",
"0.5920626",
"0.5864169",
"0.5808525",
"0.5722322",
"0.5699494",
"0.5633749",
"0.56108063",
"0.5590586",
"0.5586731",
"0.55675805",
"0.55476373",
"0.55409825",
"0.55065954",
"0.54952604",
"0.54935783",
"0.5... | 0.5387944 | 27 |
Simple statistics from vector. | def descriptive_stats(array, verbose=True, label='', mean=False, plot=False):
if mean:
mean_ = np.mean(array)
median = np.median(array)
mini = np.min(array)
maxi = np.max(array)
first_qu = np.percentile(array, 25)
third_qu = np.percentile(array, 75)
if verbose:
if mean:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_stats(v):\n total = sum(v)\n num = len(v)\n avg = format(total / num, \".2f\")\n return total, num, avg",
"def unit(vector):\r\n result = [[0] for row in range(len(vector))]\r\n # creates the initial value for result of this function, which is a vector full of 0s with the same lenght of a g... | [
"0.67131037",
"0.6269503",
"0.60756177",
"0.58886397",
"0.58527386",
"0.58332264",
"0.58134127",
"0.5774788",
"0.5744754",
"0.57419086",
"0.5688798",
"0.5660893",
"0.565367",
"0.564969",
"0.5627847",
"0.56275856",
"0.56129134",
"0.5599646",
"0.55935854",
"0.5580781",
"0.55641... | 0.0 | -1 |
Build a dataloader for object detection with some default features. This interface is experimental. | def build_video_detection_train_loader(
dataset, *, mapper, sampler=None, total_batch_size,
aspect_ratio_grouping=True, num_workers=0, sampler_pair_offsets=(-1,),
sampler_cur_frame_weight=0, num_frames=2
):
if isinstance(dataset, list):
dataset = DatasetFromList(dataset, copy=False)
if mappe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_dataloader(opt, dataobj):\n\n def load_data(name):\n with open(name, 'rb') as f:\n data = pickle.load(f)\n num_types = 1 # There is no event type prediction, hence using a dummy value, this will basically be a constant value field\n return data, num_types\n\n ... | [
"0.6775494",
"0.6466005",
"0.6463042",
"0.64553905",
"0.6447685",
"0.639675",
"0.6371912",
"0.62702376",
"0.62687045",
"0.6215597",
"0.616361",
"0.6156148",
"0.6116725",
"0.609703",
"0.607448",
"0.6058748",
"0.6057012",
"0.60405445",
"0.6025452",
"0.6015313",
"0.6004665",
"... | 0.0 | -1 |
Returns the number of possible moves which don't cause collapse. | def all_valid(self, tower) -> int:
count = 0
for layer in range(1, len(tower.tower)):
for index in range(1, 4):
if self.is_valid(layer, index, tower):
count += 1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_moves(self):\n return self._move_seq.length()",
"def get_number_of_moves(self):\n return self._number_of_moves",
"def count_legal_moves(board, color):\n return len(legal_moves(board, color))",
"def possible_moves(self): \n return [a + 1 for a, b in enumerate(self.... | [
"0.7577585",
"0.71031594",
"0.70244104",
"0.679448",
"0.6702531",
"0.66602",
"0.66050065",
"0.65337217",
"0.6384787",
"0.6343273",
"0.6337484",
"0.61112654",
"0.6107738",
"0.61033475",
"0.6093635",
"0.60793257",
"0.6057988",
"0.60496545",
"0.60301095",
"0.601779",
"0.59898984... | 0.0 | -1 |
Returns a list of all valid pieces which won't cause the tower to collapse. | def __find_all_moves(self, tower) -> list:
choice = []
for height in range(1,len(tower.tower)-2):
for index in range(1,4):
if self.stat_brain.is_valid(height, index, tower):
choice.append((height, index))
r.shuffle(choice)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legalMoves(self):\n return [c for c in range(self.getWidth()) if len([r for r in range(self.getHeight()) if self.cell[c][r]==EMPTY])>0 ]",
"def known_safes(self):\n #if the bomb count is zero\n if(self.count == 0):\n #all spaces are safe, which returns all spots that are safe\... | [
"0.6829048",
"0.6798015",
"0.6770593",
"0.6714685",
"0.64326066",
"0.641522",
"0.61822975",
"0.61021334",
"0.6030621",
"0.60048497",
"0.5995306",
"0.5987993",
"0.59824765",
"0.597919",
"0.59699184",
"0.59573984",
"0.5950054",
"0.594396",
"0.5920193",
"0.589289",
"0.58871657",... | 0.6226447 | 6 |
Set the color of one of the y axes. | def color_axis(self, name, color):
axis = self._find_axis(name)
axis.axis_line_color = color
axis.axis_label_text_color = color
axis.major_label_text_color = color
axis.major_tick_line_color = color
axis.minor_tick_line_color = color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_axis_y(self, new_axis_point):\r\n self.__y_axis = new_axis_point",
"def set_y(self, new_y):\r\n self.y = new_y",
"def setY(ax1: Union[object, List], ax2: Union[object, List]):\n if type(ax1) is list:\n print(\"PlotHelpers: cannot use list as source to set Y axis\")\n retu... | [
"0.6719952",
"0.6486638",
"0.64714205",
"0.643498",
"0.643498",
"0.6299649",
"0.6285837",
"0.6277758",
"0.6262305",
"0.6248778",
"0.6224376",
"0.62188476",
"0.6202156",
"0.61754656",
"0.61743337",
"0.61179596",
"0.60991496",
"0.6031786",
"0.5986648",
"0.5910659",
"0.5906186",... | 0.56212723 | 34 |
Add another y axis to the graph. You must provide a name for the axis and an optional fixed range min/max. The name is used to refer to the axis later if you need to modify it. If you want to color the entire axis you can pass a color string in color and it will be as if you separately called color_yaxis. | def add_yaxis(self, name, y_range=None, location="right", label=None, color=None):
if y_range is not None and not isinstance(y_range, Range1d):
y_min, y_max = y_range
y_range = Range1d(start=y_min, end=y_max)
elif y_range is None:
y_range = DataRange1d()
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secondaryYaxis(low,high,first,step,length,name,direction,x,y,log=0):\n if log:\n dislin.yaxlg(low,high,first,step,length,name,direction,x,y)\n else:\n dislin.yaxis(low,high,first,step,length,name,direction,x,y)",
"def SetYAxisRange(self, lower, upper):\n self.Y_AXIS_RANGE = (lower,... | [
"0.7278966",
"0.70447606",
"0.6858119",
"0.66691744",
"0.66637146",
"0.64535874",
"0.6381331",
"0.63398725",
"0.6313267",
"0.6251686",
"0.610915",
"0.6105304",
"0.6100539",
"0.60935795",
"0.60545325",
"0.6036133",
"0.5798117",
"0.5798117",
"0.57692707",
"0.5694506",
"0.568625... | 0.79296404 | 0 |
Convert a word from snake_case to CamelCase | def snake_to_camel(word):
return ''.join(x.capitalize() or '_' for x in word.split('_')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_to_camel_case(snake_str: str) -> str:\n\n words = snake_str.strip(\"_\").split(\"_\")\n return words[0] + \"\".join(word[:1].upper() + word[1:] for word in words[1:])",
"def snake_to_camel_case(value):\n words = value.strip(\"_\").split(\"_\")\n return words[0].lower() + \"\".join([word.cap... | [
"0.82117194",
"0.8184621",
"0.8055713",
"0.7987699",
"0.7959458",
"0.793636",
"0.7929527",
"0.7913796",
"0.79018044",
"0.78817326",
"0.7881123",
"0.7801666",
"0.780064",
"0.7789993",
"0.7783078",
"0.77676845",
"0.77478725",
"0.7743818",
"0.7742133",
"0.7741626",
"0.7685414",
... | 0.8670039 | 1 |
Return a list of vertices in the given path that can be skipped. | def get_skippables(self, path):
skippables = []
anchor = path[0]
for i in range(2, len(path)):
(x, y) = path[i]
if x == anchor[0] or y == anchor[1]:
skippables.append(i - 1)
else:
anchor = path[i - 1]
return skippabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_non_repeat_nodes(G, path):\n sing_nodes = []\n for nd in path:\n if G.out_degree(nd)==1 and G.in_degree(nd)==1:\n sing_nodes.append(nd)\n return sing_nodes",
"def find_isolated_vertices(self):\n graph = self.__graph_dict\n isolated = []\n for vertex in grap... | [
"0.6570381",
"0.6568938",
"0.64174247",
"0.6050132",
"0.5975988",
"0.5941784",
"0.5758482",
"0.57537216",
"0.574467",
"0.5722135",
"0.564122",
"0.56201977",
"0.5597687",
"0.5592003",
"0.55676085",
"0.5519077",
"0.5511452",
"0.5511452",
"0.54983044",
"0.54336345",
"0.54190695"... | 0.7190466 | 0 |
Returns if the word is in the trie. | def search(self, word: str) -> bool:
nroot=self.root
for j in word:
# index=ord(j)-ord('a')
if j not in nroot.children:
return False
nroot=nroot.children[j]
return nroot.endofword | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_trie(self, trie, word):\n current_dict = trie\n for letter in word:\n if letter in current_dict:\n current_dict = current_dict[letter]\n else:\n return False\n else:\n if '_end_' in current_dict:\n return curr... | [
"0.838632",
"0.8150416",
"0.8123471",
"0.7856802",
"0.7830664",
"0.77935004",
"0.7792806",
"0.77642965",
"0.7753436",
"0.7747724",
"0.7711298",
"0.76816714",
"0.7677101",
"0.7664614",
"0.76506114",
"0.76338875",
"0.7628353",
"0.76114196",
"0.7577657",
"0.75695884",
"0.756079"... | 0.7540419 | 22 |
Return all primes less than N > 0 int | def primes_lt3(N):
# test every number less than N/2
primes = [ i for i in xrange(2,N)
if not any( ( i % p == 0 for p in xrange(2,int(sqrt(i))+1) ) )]
return primes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]",
"def primes(n, DEBUG=False):\n\n return [x[0] for x in enumerate(_sieve(n, DEBUG=DEBUG)[0:n+1]) if x[1]]",
"def primes_less(n):\n test_nums = list(range(3, int(floor(sqrt(n))), 2))\n prime_flags = [True] * ((n - 2) // 2)\n fo... | [
"0.82766366",
"0.7859006",
"0.7837744",
"0.77796274",
"0.77788043",
"0.76730186",
"0.76580447",
"0.7605357",
"0.75656956",
"0.7546704",
"0.7539737",
"0.7534046",
"0.7525946",
"0.75065154",
"0.75006855",
"0.75006855",
"0.74906963",
"0.74829483",
"0.7478759",
"0.74624544",
"0.7... | 0.8036131 | 2 |
Return today's current date. | def default_date(self):
return datetime.datetime.now().strftime('%Y-%m-%d') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_date():\n return datetime.datetime.today().strftime(constants.DATE_FORMAT)",
"def get_today_date():\n return date.today()",
"def today():\n return date.today()",
"def today(self):\n return(datetime.date.today().isoformat())",
"def get_date_today() -> str:\n return... | [
"0.90341836",
"0.88500696",
"0.8741568",
"0.873721",
"0.87168944",
"0.8703407",
"0.86363167",
"0.86101377",
"0.85336226",
"0.85325897",
"0.8396499",
"0.8363865",
"0.80986935",
"0.80817646",
"0.8068665",
"0.80164665",
"0.79793465",
"0.7923089",
"0.79134023",
"0.7896989",
"0.78... | 0.69872785 | 55 |
Returns the data directory that contains example files for tests and documentation. | def data_dir():
return os.path.join(os.path.dirname(__file__), 'test', 'data') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_dir():\n return os.path.join(os.path.dirname(_here), 'test', 'data')",
"def test_data_dir(self):\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
"def data_dir():\n #data_path = os.path.dirname(intervene.__file__)\n #data_path = os.path.join(os.path.dirname(o... | [
"0.8644757",
"0.85354745",
"0.85181457",
"0.83150315",
"0.82705426",
"0.80189484",
"0.78715575",
"0.7675246",
"0.76445234",
"0.76364595",
"0.7556643",
"0.75523055",
"0.7508913",
"0.74403983",
"0.7434062",
"0.73755974",
"0.736221",
"0.7321423",
"0.7316419",
"0.7295012",
"0.727... | 0.84917355 | 3 |
This function returns a dataset given a name | def dataset(name):
t = "unknown"
if name =="boston":
# regression (506x13feat)
from sklearn.datasets import load_boston
X, y = load_boston(return_X_y=True)
t = "R"
#X,y = shap.datasets.boston()
#return X,y
elif name == "iris":
# classification (150x4fe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_by_name(name):\n return _datasets[name.lower()]",
"def get_by_name(self, name: str) -> Optional[\"Dataset\"]:\n raise NotImplementedError",
"def get_dataset(name):\n if name == 'cityscapes':\n return Cityscapes",
"def get(self, name):\n assert name, \"Must input a valid... | [
"0.8607529",
"0.83464855",
"0.82256806",
"0.7852492",
"0.7813678",
"0.7763326",
"0.7721633",
"0.75102246",
"0.7509347",
"0.7382239",
"0.7374121",
"0.7345599",
"0.7337575",
"0.73302966",
"0.72971225",
"0.72971225",
"0.72971225",
"0.72799456",
"0.72209847",
"0.72158206",
"0.719... | 0.6758709 | 35 |
Generates a random string | def random_string(length, characters=string.ascii_letters + string.digits):
return "".join(random.choice(characters) for i in range(length)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateRandomString():\n return ''.join(b64encode(urandom(32)).decode('utf-8'))",
"def generate_random_string():\n return \"\".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16)) # nosec",
"def __generate_random_string():\n return uuid4().hex[:6].upper()",
"def g... | [
"0.8501226",
"0.8365816",
"0.8131039",
"0.8034402",
"0.7969038",
"0.7911282",
"0.7877835",
"0.78391755",
"0.77556413",
"0.7743602",
"0.77284604",
"0.77163345",
"0.77062607",
"0.76907265",
"0.76739115",
"0.7659855",
"0.7651115",
"0.76346433",
"0.7608985",
"0.7585705",
"0.75794... | 0.71625876 | 88 |
retrive the absolute number corresponding a color set by color_dict | def get_color(color_dict, colors):
for i, color in enumerate(colors):
for data in color:
equal = True
for k, v in data.items():
if k not in color_dict or v != color_dict[k]:
equal = False
break
if equal:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize_color(color, palette):\n min_distance = np.inf\n most_similar_color = None\n for cname, cvalue in palette.items():\n distance = np.sum(np.abs(np.array(color) - np.array(cvalue)))\n if distance < min_distance:\n min_distance = distance\n most_similar_color ... | [
"0.66252863",
"0.64983225",
"0.64983225",
"0.64983225",
"0.64983225",
"0.64947146",
"0.641681",
"0.6416515",
"0.6276939",
"0.6272706",
"0.6251824",
"0.6251427",
"0.6225441",
"0.61851877",
"0.6166958",
"0.6163546",
"0.6162326",
"0.6146577",
"0.61382896",
"0.6124847",
"0.61191"... | 0.72337514 | 0 |
Computes the state features for the current environment, used for learning successor feature representations. First introduced in [1]. | def features(self, state, action, next_state):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def features(self, state):\n jdecays = state[\"decays\"]\n cor_mean = state[\"means\"] / (1 - jdecays**(state[\"iteration\"]))\n # longest running decay\n approx_max = cor_mean[1:]\n cor_mean = cor_mean[0:-1]\n running_min = state[\"running_min\"][0:-1]\n\n den = jnp.maximum(1e-8, (approx_max ... | [
"0.68842745",
"0.66246444",
"0.65144205",
"0.6364238",
"0.6316186",
"0.6307906",
"0.62123454",
"0.61723757",
"0.61723757",
"0.6166173",
"0.6166173",
"0.6166173",
"0.60888404",
"0.6080914",
"0.60174423",
"0.60174423",
"0.5976067",
"0.597429",
"0.5970136",
"0.59532595",
"0.5952... | 0.6795559 | 1 |
Claim a spawn area for a player. | def assign_spawn_point(self) -> StaticTile:
spawn_tile = self.spawn_points[self.active_spawns]
self.active_spawns += 1
return spawn_tile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawnPlayer( player ):\r\n \r\n room = random.sample(world.maps.World.roomsList, 1)[0]\r\n \r\n # Uncomment below to force spawn in a certain room\r\n room = \"544\"\r\n \r\n player.room = room\r\n world.maps.World.mapGrid[room].players[player.name] = player\r\n player.status = PLAYI... | [
"0.6607727",
"0.60198927",
"0.5947014",
"0.581006",
"0.5697158",
"0.56204367",
"0.5615963",
"0.5615663",
"0.55920047",
"0.5581495",
"0.5524649",
"0.55061984",
"0.5461361",
"0.5451105",
"0.5441521",
"0.5422089",
"0.5339114",
"0.53207463",
"0.5317568",
"0.53112024",
"0.5298919"... | 0.49711335 | 62 |
Reset the Map, generating new terrain. | def reset(self) -> None:
self.map = []
for col in range(self.width):
self.map.append([])
for cell in range(self.height):
if col > 1 and col < self.width - 2:
if cell == 0:
# World Barrier - Top Middle
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_map(self):\n self.reset_world(self._filename)",
"def reset(self):\n self._maps = {}",
"def reset_map(self):\n self.x = None\n self.X = None\n self.y = None\n self.Y = None\n self.data = None\n self.sampling = None\n self.size = None",
"... | [
"0.8340485",
"0.7814636",
"0.7714848",
"0.7546125",
"0.7176139",
"0.70904243",
"0.6958451",
"0.6937241",
"0.6854199",
"0.6848153",
"0.67214006",
"0.6716702",
"0.665488",
"0.65983194",
"0.65538466",
"0.65506506",
"0.6546146",
"0.65159065",
"0.65112704",
"0.6497466",
"0.6496066... | 0.7257658 | 4 |
Get all tiles above, below, left, and right, or a tile on the map, up to a certain distance. Return any destructable tiles which are in this path. The path stops if a barrier is reached in that direction. | def get_around(self, current_tile:Union[StaticTile, DynamicTile], *, index_pair:Tuple[int,int]=False, distance=1) -> Tuple[List[Union[StaticTile, DynamicTile]], List[DynamicTile]]:
# Context Tiles = (tile:Tile, direction:string, is_tip:bool)
tiles = list()
destructables = list()
if not i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path(self):\r\n path = [self.city_map.get_tile_at_position(self.position)]\r\n destination_tile = self.city_map.get_tile_at_position(self.destination)\r\n\r\n neighbors = self.city_map.get_adjacent_intersections(self.position)\r\n closest_neighbor = None\r\n closest_neigh... | [
"0.63396156",
"0.5877377",
"0.5496356",
"0.5309188",
"0.5213295",
"0.5203265",
"0.51913476",
"0.5187629",
"0.5152763",
"0.51138145",
"0.5112393",
"0.5110904",
"0.5023932",
"0.50177085",
"0.5011518",
"0.50005704",
"0.4994868",
"0.4987901",
"0.4964236",
"0.49553922",
"0.4954156... | 0.6375283 | 0 |
Get the tile left of the current tile by a certain distance, if it can be reached and exists. | def get_left(self, current_tile, index_pair=False, distance=1) -> Union[bool, StaticTile, DynamicTile]:
col = 0
row = 0
if index_pair:
col, row = index_pair
else:
col, row = self.__get_index_pair__(current_tile)
if col - distance > -1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left(self, distance):\r\n return self.move('left', distance)",
"def left(self):\n x, y = (self.loc[0] - 1, self.loc[1])\n\n if x < 0:\n return None # None\n\n return self.garden.cells[y][x]",
"def get_node_left(self, n: MazeCell) -> MazeCell:\n if n.x == ... | [
"0.6865605",
"0.67106944",
"0.65296406",
"0.6513841",
"0.64631736",
"0.6458576",
"0.64040285",
"0.62715584",
"0.61174405",
"0.61159855",
"0.6052846",
"0.59626025",
"0.59385645",
"0.5923389",
"0.5913304",
"0.5897043",
"0.5887529",
"0.58849573",
"0.5883524",
"0.5870967",
"0.586... | 0.76418984 | 0 |
Updates internal Interface Host map with the one provided. | def update_endpoints(self, iface_hosts):
self._ep_hosts.update(iface_hosts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update(self, host):\n pass",
"def configure_host_ips(h3, h4, ip_address_hs):\n\n h3.libs.ip.flush_ip('eth1')\n h3.libs.ip.interface('eth1', up=False)\n\n h4.libs.ip.flush_ip('eth1')\n h4.libs.ip.interface('eth1', up=False)\n\n h3.libs.ip.interface(portlbl='eth1', addr=\"{}/{}\".format(... | [
"0.6308416",
"0.6024745",
"0.60238177",
"0.6001568",
"0.5860795",
"0.5848572",
"0.57871246",
"0.576296",
"0.57545036",
"0.5726918",
"0.5707263",
"0.55879205",
"0.55879205",
"0.55616415",
"0.5507871",
"0.5500331",
"0.5467735",
"0.5467638",
"0.54652095",
"0.54511243",
"0.543662... | 0.6351433 | 0 |
Load VCF file from the specified filepath into a pandas DataFrame. | def load_vcf(filepath: str, no_header: bool=False) -> DataFrame:
if not os.path.exists(filepath):
raise ValueError("The file %s does not exist." % filepath)
else:
if no_header:
df_vcf = pd.read_csv(
filepath_or_buffer = filepath,
sep = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_file_to_dataframe(self, file_path: str) -> pd.DataFrame:\n return pd.read_csv(file_path, sep=\"\\t\")",
"def read_data(filepath):\n df = pd.read_csv(filepath)\n return df",
"def read_data(filepath):\n df = pd.read_csv(filepath)\n return df",
"def read_data(filepath... | [
"0.7254276",
"0.72066075",
"0.72066075",
"0.72066075",
"0.69053006",
"0.68979806",
"0.6855319",
"0.677828",
"0.67745626",
"0.67113507",
"0.67105025",
"0.6655318",
"0.6623691",
"0.6562519",
"0.65015006",
"0.6488918",
"0.6468184",
"0.6462298",
"0.6424285",
"0.6404753",
"0.64037... | 0.7969923 | 0 |
Retorna el identificador del ultimo cambio hecho. '0' si no hay cambios aun. | def getIdUltimoCambio(self):
r = self.conexion.ejecutarSQL("select max(id) from cambios")
if r != []:
return r[0][0]
else:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIdUltimaCompra(self):\n r = self.conexion.ejecutarSQL(\"select max(id) from Compras\")\n if r != []:\n return r[0][0]\n else:\n return -1",
"def getIdUltimaVenta(self):\n r = self.conexion.ejecutarSQL(\"select max(id) from Ventas\")\n if r != []:\n ... | [
"0.67472816",
"0.6467683",
"0.6301732",
"0.6233101",
"0.6054237",
"0.583177",
"0.5816363",
"0.5770967",
"0.56777394",
"0.56623906",
"0.56313",
"0.5617503",
"0.5613781",
"0.5552413",
"0.5549618",
"0.55448884",
"0.5513219",
"0.5494642",
"0.5444722",
"0.5437362",
"0.5436255",
... | 0.8175232 | 0 |
Retorna todos los productos si codigo y desc = ''. Si no, intenta buscar los productos que coincidan con el codigo y descripcion. | def getProductos(self, codigo, desc):
if codigo != "" and desc != "":
return self.conexion.ejecutarSQL("select codigo, descripcion, cantidad_disponible, porcentaje_IVA, precio_venta, fecha_modificacion, hora_modificacion, usuario_colaborador \
from produc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buscarProd(self):\n medicamento = str(self.lineMedicamento.text())\n monodroga = str(self.lineMonodroga.text())\n data = self.getAllTabla(self.tableProductos)\n\n if medicamento != \"\":\n dataMedic = filter(lambda x: x[1].upper() == medicamento.upper(), data.values())\n ... | [
"0.6292344",
"0.62869674",
"0.5975231",
"0.5742191",
"0.565152",
"0.55668926",
"0.5548551",
"0.5497096",
"0.54048437",
"0.533548",
"0.5281548",
"0.5265666",
"0.523141",
"0.5226794",
"0.5159198",
"0.5148133",
"0.5136589",
"0.5117091",
"0.51019305",
"0.50663704",
"0.5056129",
... | 0.76655644 | 0 |
Retorna todos los productos (items) asociados al id de venta dado. | def getProductosVenta(self,idVenta):
return self.conexion.ejecutarSQL("""
select pv.numero_item, pv.codigo_producto,v.fecha, pv.valor_unitario, pv.cantidad, pv.iva, pv.valor_total
from ProductosXVentas pv, Ventas v
where v.id = pv.id_venta and pv.id_venta=%s"""%(idVenta)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(self, id_pedido):\n c = self.db.con.cursor()\n c.execute(\"\"\"SELECT id_pedido, id_produto, quantidade, valor, observacao \n FROM tb_pedido_produtos WHERE id_pedido = %s\"\"\", id_pedido)\n list_all: List[PedidoProduto] = []\n for row in c:\n prod =... | [
"0.70006377",
"0.66886306",
"0.6663955",
"0.66551065",
"0.6610465",
"0.6145359",
"0.6092134",
"0.6020505",
"0.6004737",
"0.5963669",
"0.5929189",
"0.58916116",
"0.58850473",
"0.5882673",
"0.58709425",
"0.58539003",
"0.58463013",
"0.5832599",
"0.5796138",
"0.5748111",
"0.57428... | 0.6926555 | 1 |
Plots model training history | def plot_training_history(history):
fig, (ax_loss, ax_acc) = plt.subplots(1, 2, figsize=(15, 5))
ax_loss.plot(history.epoch, history.history["loss"], label="Train loss")
ax_loss.plot(history.epoch, history.history["val_loss"], label="Validation loss")
ax_loss.legend()
ax_acc.plot(history.epoch, hist... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_training_history(self):\n hist = [i.history[\"loss\"][0] for i in self.history]\n plt.plot(hist)",
"def plots(self, history):\n print(history.history.keys())\n plt.plot(history.history['acc'])\n plt.plot(history.history['val_acc'])\n plt.title('model accuracy')\... | [
"0.82401586",
"0.7935673",
"0.78775716",
"0.7823915",
"0.77255815",
"0.77200186",
"0.7586564",
"0.75072414",
"0.74860954",
"0.7451733",
"0.7429674",
"0.7427417",
"0.7399193",
"0.73766375",
"0.7319645",
"0.7273112",
"0.7201136",
"0.7190596",
"0.7172979",
"0.71628356",
"0.71151... | 0.7615606 | 6 |
The database name this payload currently working on | def current_db(self):
return self._current_db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database_name(self) -> str:\n return pulumi.get(self, \"database_name\")",
"def database_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"database_name\")",
"def get_name(self) -> str:\n return self.dbname",
"def db_name(self):\n return self._db_name",
"def getD... | [
"0.8450223",
"0.8345573",
"0.8303672",
"0.82961017",
"0.82167125",
"0.8098321",
"0.8057028",
"0.800557",
"0.79648614",
"0.7941366",
"0.7939747",
"0.7869585",
"0.77553934",
"0.7545281",
"0.7477879",
"0.74658847",
"0.7445888",
"0.7396163",
"0.73662823",
"0.72655034",
"0.7233812... | 0.6326813 | 61 |
Name of the original table. Because we don't support table name change in OSC, name of the existing table should be the exactly the same as the one in the sql file. We are using 'self._new_table.name' here instead of _old_table, because _new_table will be instantiated before _old_table at early stage. It will be used b... | def table_name(self):
return self._new_table.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_table_name(self):\n if len(self._old_table.name) < constant.MAX_TABLE_LENGTH - 10:\n return constant.NEW_TABLE_PREFIX + self.table_name\n elif (\n len(self._old_table.name) >= constant.MAX_TABLE_LENGTH - 10\n and len(self._old_table.name) < constant.MAX_TABLE_... | [
"0.83689046",
"0.81319666",
"0.77321255",
"0.6975121",
"0.68180895",
"0.6691855",
"0.66842467",
"0.6669268",
"0.66486424",
"0.6642103",
"0.6642103",
"0.6642103",
"0.6603652",
"0.660285",
"0.6598055",
"0.6587416",
"0.65479726",
"0.6543308",
"0.6502082",
"0.64987206",
"0.649572... | 0.8034087 | 2 |
Full file path of the outfile for data dumping/loading. It's the prefix of outfile chunks. A single outfile chunk will look like '/__osc_tbl_.1' | def outfile(self):
return os.path.join(self.outfile_dir, constant.OUTFILE_TABLE + self.table_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_file_path(self) -> str:\n return pulumi.get(self, \"dump_file_path\")",
"def output_abspath(self):\n return os.path.join(self.queue.data_abspath, self.id)",
"def get_file_save_path(self):\n return self.out",
"def outpath(self):\n return None",
"def output_path(self):\r\... | [
"0.66116244",
"0.65815306",
"0.6553026",
"0.6503871",
"0.6483075",
"0.6320126",
"0.6251857",
"0.617819",
"0.61211365",
"0.611907",
"0.6086719",
"0.6068082",
"0.60396117",
"0.6037719",
"0.6002661",
"0.60003155",
"0.5995911",
"0.5992983",
"0.59095967",
"0.59020895",
"0.5893097"... | 0.71626526 | 0 |
Name of the outfile which contains the data which will be loaded to self.tmp_table_include_id soon. See docs in self.outfile_exclude_id for more | def outfile_include_id(self):
return os.path.join(
self.outfile_dir, constant.OUTFILE_INCLUDE_ID + self.table_name
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outfile_exclude_id(self):\n return os.path.join(\n self.outfile_dir, constant.OUTFILE_EXCLUDE_ID + self.table_name\n )",
"def outfile(self):\n return os.path.join(self.outfile_dir, constant.OUTFILE_TABLE + self.table_name)",
"def tmp_table_include_id(self):\n return \... | [
"0.7889191",
"0.719267",
"0.6740138",
"0.6453129",
"0.63397664",
"0.63265944",
"0.6209516",
"0.59877",
"0.5968869",
"0.5925593",
"0.59049386",
"0.59049386",
"0.59049386",
"0.59049386",
"0.58755195",
"0.58435696",
"0.58015734",
"0.57990247",
"0.57979035",
"0.57813084",
"0.5769... | 0.7761676 | 1 |
Given a table_name check whether this table already exist under current working database | def table_exists(self, table_name):
table_exists = self.query(
sql.table_existence,
(
table_name,
self._current_db,
),
)
return bool(table_exists) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_exists(self, dbname, tablename):\n if not hasattr(self, 'existing_table_names'):\n self.cursor.execute(\n \"SELECT schemaname, tablename FROM pg_tables WHERE schemaname NOT LIKE 'pg_%';\")\n self.existing_table_names = set()\n for schema, table in se... | [
"0.8456124",
"0.8307638",
"0.82668525",
"0.8193051",
"0.81889457",
"0.81709075",
"0.8168559",
"0.8116464",
"0.8114336",
"0.80955714",
"0.80763996",
"0.8062981",
"0.7968321",
"0.7946387",
"0.79383266",
"0.7923553",
"0.79218584",
"0.7900687",
"0.7878978",
"0.78449094",
"0.78105... | 0.81615937 | 7 |
Check whether there's any trigger already exist on the table we're about to touch | def trigger_check(self):
triggers = self.query(
sql.trigger_existence,
(self.table_name, self._current_db),
)
if triggers:
trigger_desc = [
"Trigger name: {}, Action: {} {}".format(
trigger["TRIGGER_NAME"],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_triggers(self):\n triggers = self.get_source_triggers()\n if not triggers:\n self.create_insert_trigger()\n self.create_update_trigger()\n self.create_delete_trigger()\n self.commit()",
"def check_exists(self):\n trigger_manager = Trigge... | [
"0.64453816",
"0.6337567",
"0.6290975",
"0.59551674",
"0.589527",
"0.5786908",
"0.5783182",
"0.57606995",
"0.5739344",
"0.5735986",
"0.5677502",
"0.56678724",
"0.5618815",
"0.55443114",
"0.551252",
"0.5508987",
"0.550588",
"0.5505603",
"0.55053425",
"0.5494182",
"0.54832786",... | 0.80294794 | 0 |
Check whether the table has been referred to any existing foreign definition | def foreign_key_check(self):
# MyRocks doesn't support foreign key
if self.is_myrocks_table:
log.info(
"SKip foreign key check because MyRocks doesn't support " "this yet"
)
return True
foreign_keys = self.query(
sql.foreign_key_cnt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_foreign_key_exists(self, table_name, column_name, referenced_table, referenced_column):\n ans = self.execute(self.commands.foreign_key_exists(self.db.name, table_name, column_name, referenced_table, referenced_column))\n if not ans:\n return False\n return True",
"def _i... | [
"0.71930707",
"0.6790084",
"0.67055964",
"0.65026635",
"0.6341681",
"0.63144815",
"0.62982523",
"0.62335765",
"0.62195027",
"0.61962855",
"0.6185308",
"0.6123952",
"0.6094759",
"0.60313463",
"0.5960257",
"0.5959753",
"0.59272605",
"0.5926592",
"0.589575",
"0.5890752",
"0.5879... | 0.76372933 | 0 |
Check when going from old schema to new, whether bootstraping column using CURRENT_TIMESTAMP is involved. This is a dangerous thing to do out of replication and is disallowed by default | def ts_bootstrap_check(self):
if not need_default_ts_bootstrap(self._old_table, self._new_table):
return
if self.allow_unsafe_ts_bootstrap:
log.warning(
"Bootstraping timestamp column using current time is required. "
"Bypassing the safety check as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_bootstrap(self):\n return (\n not self.bootstrapped\n or (\n datetime.utcnow() - self.last_bootstrapped > timedelta(seconds=self.bootstrap_interval)\n and self.run_migrations\n )\n )",
"def table_has_any_timestamp_fields(table... | [
"0.61286116",
"0.5696035",
"0.5584914",
"0.5544259",
"0.5467294",
"0.54037863",
"0.5376856",
"0.53457",
"0.53402257",
"0.5193318",
"0.51582706",
"0.515345",
"0.51425266",
"0.5103681",
"0.50989544",
"0.5079292",
"0.5046312",
"0.50092685",
"0.5006087",
"0.5005218",
"0.5002471",... | 0.7535812 | 0 |
Return the Hamming distance between equallength sequences. | def hamming(s1, s2):
s1 = str(s1)
s2 = str(s2)
if len(s1) != len(s2):
raise ValueError("Undefined for sequences of unequal length.")
return sum(el1 != el2 for el1, el2 in zip(s1, s2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __hamming_distance(s1, s2):\n if len(s1) != len(s2):\n raise ValueError(\"Undefined for sequences of unequal length\")\n return sum(el1 != el2 for el1, el2 in zip(s1, s2))",
"def hamming_dist(self):\r\n distance = 0\r\n distance = abs(len(self.s1) - len(self.s2))\r\n ... | [
"0.7354546",
"0.73521936",
"0.72160065",
"0.72134346",
"0.70732856",
"0.6965175",
"0.69385105",
"0.6933624",
"0.6933623",
"0.69076073",
"0.68864363",
"0.6866735",
"0.6864924",
"0.68400425",
"0.6821013",
"0.6810209",
"0.6743045",
"0.67136675",
"0.66247284",
"0.66125095",
"0.65... | 0.592187 | 47 |
Add as much postfix'_' to `name` as necessary to make unique name for new node in `graph`. | def make_unique_node(graph, name):
if name not in graph:
return name
ctr = 1
while True:
name_ = name + '_' * ctr
if name_ not in graph:
return name_
ctr += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_edge_node_name(node_name, node_number):\n return node_name.replace('block_' + str(node_number), 'block_' + str(node_number+1))",
"def append_name(name, postfix):\n if name is None:\n ret = None\n elif name == '':\n ret = postfix\n else:\n ret = '%s_%s' % (name, postfix... | [
"0.7101214",
"0.7021869",
"0.6990403",
"0.6695465",
"0.66796595",
"0.6602708",
"0.6552253",
"0.6512948",
"0.6511243",
"0.64467347",
"0.6371417",
"0.6350457",
"0.63197666",
"0.6293913",
"0.6274568",
"0.6266234",
"0.6255",
"0.6198743",
"0.61780596",
"0.6174894",
"0.6167656",
... | 0.76182467 | 0 |
Load an MDF YAML file | def load_mdf_yaml(filename):
from neuromllite.utils import load_yaml, _parse_element
data = load_yaml(filename)
print(f"Loaded a graph from {filename}, Root(s): {data.keys()}")
if data.keys() == "graphs":
data = {"UNSPECIFIED": data}
model = Model()
model = _parse_element(data, model)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_yaml():\n yamlfullpath = os.path.join(THISDIR, 'ff_data.yaml')\n\n with open(yamlfullpath, 'r') as stream:\n ff_data = yaml.safe_load(stream)\n\n FF_DATA_SCHEMA(ff_data)\n return ff_data",
"def get_ymal_load(yamlfile):\n with open(yamlfile, 'r', encoding='utf-8') as fr:\n fi... | [
"0.7497511",
"0.6960878",
"0.689935",
"0.68939227",
"0.685871",
"0.68554664",
"0.6804139",
"0.6793138",
"0.678672",
"0.6772547",
"0.6770666",
"0.67283976",
"0.6709563",
"0.67020124",
"0.66975576",
"0.66956043",
"0.6682741",
"0.6676056",
"0.66741556",
"0.66610104",
"0.66529715... | 0.72860926 | 1 |
Returns the string which identifies the info's data environment. All data stored in redis must be prefixed in order to distinguish it from other environment's data. | def get_prefix(self) -> str:
return self.env_type.value + '_' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def realization_config_data_id(self) -> str:\n return self.config_data_id",
"def prefix(self):\n return str(self.data)",
"def cache(self):\n return f'var/cache/{self.environment}'",
"def get_env_prefix(instrument):\n return \"crds://\"",
"def set_envdata():\n\n\t\tenv = ArgvParserOb... | [
"0.56671536",
"0.5649849",
"0.56486887",
"0.558967",
"0.5580435",
"0.5477214",
"0.5439477",
"0.5421324",
"0.5419613",
"0.5415776",
"0.5368546",
"0.5334344",
"0.53277147",
"0.53179795",
"0.53112936",
"0.5298852",
"0.52673304",
"0.52555513",
"0.5255027",
"0.5245117",
"0.5240671... | 0.5513011 | 5 |
range(self) > (int, int) Returns the lowest and highest base (or mark) numbers as a tuple | def range(self):
lows, highs = [], []
for graph in self._graphs.values():
low, high = graph.range()
lows.append(low)
highs.append(high)
return (min(lows), max(highs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_range(self) -> tuple[int, int]:\n return self.range_from, self.range_to",
"def high_and_low(numbers):\n highest = max(numbers)\n lowest = min(numbers)\n return (highest,lowest)",
"def high_and_low(numbers):\n highest = max(numbers)\n lowest = min(numbers)\n return (highest,... | [
"0.77327585",
"0.76069903",
"0.76045334",
"0.7413059",
"0.72966814",
"0.72524565",
"0.7213038",
"0.72043234",
"0.7188785",
"0.68761945",
"0.6848078",
"0.6798056",
"0.67777914",
"0.67740226",
"0.6493975",
"0.6486107",
"0.6479042",
"0.6412818",
"0.63933337",
"0.6369475",
"0.636... | 0.6841185 | 11 |
data_quartiles(self) > (float, float, float, float, float) Returns the (minimum, lowerQ, medianQ, upperQ, maximum) values as a tuple | def data_quartiles(self):
data = []
for graph in self._graphs.values():
data += graph.data.values()
data.sort()
datalen = len(data)
return(data[0], data[datalen/4], data[datalen/2],
data[3*datalen/4], data[-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quartile_data(cls, data: tuple or list) -> tuple:\n cls._data_validation(data)\n # Sort the data\n sorted_data = sorted(list(data))\n # Get q2, which is the median\n q2 = cls.get_median(data)\n first_half_data = list()\n second_half_data = list()\n # ... | [
"0.83821607",
"0.8121575",
"0.7897723",
"0.70060784",
"0.69994015",
"0.68657535",
"0.67933774",
"0.6759093",
"0.67418",
"0.66643023",
"0.664464",
"0.65720695",
"0.6556922",
"0.65453535",
"0.6534935",
"0.64335966",
"0.64138824",
"0.64058405",
"0.6341472",
"0.6160518",
"0.61557... | 0.76545143 | 3 |
__len__(self) > int Return the number of graphs in the set | def __len__(self):
return len(self._graphs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self) -> int:\n return len(self.graphs)",
"def __len__(self):\n return len(self.subgraph_list)",
"def ngraphs(self):\n return len(self.__graph_list)",
"def __len__(self):\n\n if self.is_finite_set:\n size = 0\n for set in self.sets:\n ... | [
"0.8453121",
"0.82309824",
"0.78586483",
"0.76788986",
"0.76528215",
"0.76221275",
"0.759722",
"0.75839025",
"0.75105155",
"0.74206346",
"0.7230994",
"0.72208416",
"0.7207798",
"0.7184245",
"0.71823716",
"0.7181236",
"0.7154576",
"0.7147937",
"0.7144422",
"0.7138025",
"0.7128... | 0.8246311 | 1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(y_true, y_pred, classes,
normalize=False,
title=None,
cmap=plt.cm.Blues):
if not title:
if normalize:
title = 'Normalized confusion matrix'
else:
title = 'Confusion matrix,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix_boosting(cm_mean, cm_std,
classes,
title=None,
cmap=plt.cm.Blues):
fig, ax = plt.subplots()
im = ax.imshow(cm_mean, interpolation='nearest', cmap=cmap)
ax.figure.colorbar(im, ax=ax)
# We want to show... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194366",
"0.8095442",
"0.8029135",
"0.8019134",
"0.7993755",
"0.7991176",
"0.79808146",
"0.79755133",
"0.79609716",
"0.7956584",
"0.79375756",
"0.79346216",
"0.79343396",
"0.7931212",
"0.7926087",
"0.7924503",
"0.7923946",
"0.79228765",
"0.79227114",
"0.7921956",
"0.79178... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',save = True,
cmap=plt.cm.Blues):
cmNorm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
plt.imshow(cmNorm, interpolation='nearest', cmap=c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194366",
"0.8095442",
"0.8029135",
"0.8019134",
"0.7993755",
"0.7991176",
"0.79808146",
"0.79755133",
"0.79609716",
"0.7956584",
"0.79375756",
"0.79346216",
"0.79343396",
"0.7931212",
"0.7926087",
"0.7924503",
"0.7923946",
"0.79228765",
"0.79227114",
"0.7921956",
"0.79178... | 0.0 | -1 |
Before each test, set up a blank database | def setUp(self):
self.app = create_app("configmodule.TestingConfig")
self.app.testing = True
self.client = self.app.test_client()
with self.app.app_context():
db.drop_all()
db.create_all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n db.create_all()",
"def setUp(self):\n INFLUX_DB_NAME = 'test_device_parameters'\n EmptyDBTestCase.client.create_database(INFLUX_DB_NAME)\n EmptyDBTestCase.client.drop_database(INFLUX_DB_NAME)\n EmptyDBTestCase.client.create_database(INFLUX_DB_NAME)",
"def s... | [
"0.84847945",
"0.8479566",
"0.84005684",
"0.8322551",
"0.83078533",
"0.8287008",
"0.82728577",
"0.8267613",
"0.81266093",
"0.80993634",
"0.8042919",
"0.80200016",
"0.79937464",
"0.79836535",
"0.7974095",
"0.79731756",
"0.79731756",
"0.79731756",
"0.796644",
"0.7962328",
"0.79... | 0.7628734 | 68 |
convert from homogeneous coordinate | def from_homogeneous(x):
if not isinstance(x, np.ndarray):
x = np.array(x)
if len(x.shape) == 1:
h = x[-1]
if h != 0:
x = x/h
return x[0:-1]
else:
return None
else:
assert len(x.shape) == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coords_to_structure(self) -> None:\n ...",
"def convert(coordinates):\n center = np.mean(coordinates, axis=0, dtype=np.float32)\n x = np.subtract(np.array(coordinates, dtype=np.float32), center)\n rho, phi = cart2pol(x[:, 0], x[:, 1])\n result = np.swapaxes(np.array([rho, phi], dtype=np.fl... | [
"0.6701313",
"0.6389736",
"0.63092554",
"0.62131184",
"0.6074555",
"0.60677767",
"0.606009",
"0.6059314",
"0.6055873",
"0.60514957",
"0.6047438",
"0.6046863",
"0.5993339",
"0.59814477",
"0.59688413",
"0.5962919",
"0.5933198",
"0.5906031",
"0.5897998",
"0.58731884",
"0.5866257... | 0.5638418 | 36 |
Check whether the obj is a UserFrame/UserSeries | def _is_user_class(obj):
type_dict = type(obj).__dict__
is_user_class = '_pandas_type' in type_dict
return is_user_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isinstance_blender_object(self, b_obj):\n # lame and slow, but functional\n return b_obj in Blender.Object.Get()",
"def isframe(object):\r\n return isinstance(object, types.FrameType)",
"def _is_object_type(df, field):\n return df[field].dtype.name == 'object'",
"def verify_type(self,... | [
"0.68187636",
"0.6818268",
"0.66365314",
"0.6457728",
"0.6374606",
"0.63729733",
"0.6277007",
"0.6207408",
"0.61955017",
"0.6183452",
"0.6174419",
"0.61655194",
"0.616307",
"0.6157472",
"0.6125783",
"0.61166936",
"0.6103373",
"0.6081705",
"0.604055",
"0.6035522",
"0.6027859",... | 0.7492857 | 0 |
Get base attribute. Not pandas object | def _get(self, name):
return object.__getattribute__(self, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_base_patch_attribute(self, name):\n return getattr(self.patches[0],name)",
"def get_attribute(self, attr):\n super().get_attribute(attr) # Keep this line, it triggers the parent class method.\n return getattr(self, attr)",
"def __getattribute__(self, name):\n # special att... | [
"0.70235664",
"0.6671475",
"0.6580095",
"0.6540233",
"0.6485864",
"0.6412031",
"0.64007384",
"0.63869065",
"0.6342761",
"0.6294118",
"0.62887853",
"0.62887853",
"0.62887853",
"0.62873656",
"0.62873656",
"0.62873656",
"0.62731767",
"0.62731767",
"0.6251906",
"0.62453336",
"0.6... | 0.6011788 | 30 |
Finds the item at a given index of the dataset. | def __getitem__(self, index):
return self.features[index], self.labels[index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(self,item):\n sig = str(item)\n try:\n return self.index[sig]\n except:\n return None",
"def findAt(self, index):\n saveCursor = self.cursor\n i = 0\n if self.first():\n if index == i:\n return self.cursor\n ... | [
"0.74308175",
"0.73403585",
"0.70901126",
"0.702017",
"0.68277675",
"0.6793971",
"0.6763183",
"0.6754829",
"0.67278427",
"0.6718874",
"0.6704729",
"0.6655916",
"0.662999",
"0.66170394",
"0.6600515",
"0.65915823",
"0.65840006",
"0.65704894",
"0.65704894",
"0.6567293",
"0.65621... | 0.0 | -1 |
Creates a training set dataloader for a dataset. Uses a sampler to load the same number of datapoints from both classes. | def author_prediction_loader(dataset, train=True, batch_size=None):
if batch_size is None:
batch_size = len(dataset)
if train:
weights, num_samples = sampler_weights(dataset)
sampler = WeightedRandomSampler(weights=weights, num_samples=num_samples, replacement=True)
return DataLo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataloader(dataset, batchsize):\n\n train_set_size = int(0.8 * dataset.__len__())\n train_indices = np.random.choice(np.arange(dataset.__len__()),\n train_set_size, replace=False)\n train_sampler = SubsetRandomSampler(train_indices)\n\n val_indices = np.setdi... | [
"0.7859735",
"0.7786429",
"0.7671017",
"0.75144434",
"0.7442596",
"0.74277455",
"0.73852205",
"0.7373633",
"0.727863",
"0.72112715",
"0.71695685",
"0.7167275",
"0.7122262",
"0.71122074",
"0.7108538",
"0.70987",
"0.7097492",
"0.70960736",
"0.7038325",
"0.70163757",
"0.6998902"... | 0.67478544 | 32 |
Accessing a non existing document should return an error state. | def test_document_not_existing(self):
response = self.client.get(f"/documents/{uuid.uuid4()}")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<html>")
content = response.content.decode("utf-8")
match = re.search(
'<div id="marsha-frontend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_document_inexistent(empty_index):\n with pytest.raises(Exception):\n empty_index().get_document(\"123\")",
"def is_doc_not_found(self):\n return self._tag == 'doc_not_found'",
"def is_doc_not_found(self):\n return self._tag == 'doc_not_found'",
"def get_document_or_error(... | [
"0.7235429",
"0.7170117",
"0.7170117",
"0.6884102",
"0.68640137",
"0.6829696",
"0.65739876",
"0.64379674",
"0.6394899",
"0.6380063",
"0.62764215",
"0.6249761",
"0.6208855",
"0.6207596",
"0.62023085",
"0.61406183",
"0.6112369",
"0.6051739",
"0.60457087",
"0.6043899",
"0.603898... | 0.67650986 | 6 |
Determine appearance based on whether the button is currently selected, hovered, or neither. Then draw the button to the target surface. | def draw(self, surface, offset=(0,0)):
mouse = pg.mouse.get_pos()
pos = mouse[0]-offset[0], mouse[1]-offset[1]
if self.clicked:
fill_color = pg.Color("white")
text = self.selected_text
elif self.rect.collidepoint(pos):
fill_color = (198, 226, 255)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DrawButton(self, dc, wnd, item, rect):\r\n\r\n bmp_rect, text_rect = self.GetToolsPosition(dc, item, rect)\r\n \r\n if not item.GetState() & AUI_BUTTON_STATE_DISABLED:\r\n \r\n if item.GetState() & AUI_BUTTON_STATE_PRESSED:\r\n \r\n dc.SetPen(wx.... | [
"0.6891096",
"0.6877097",
"0.66876537",
"0.66528046",
"0.6585761",
"0.6577838",
"0.6566489",
"0.6552494",
"0.646753",
"0.6439249",
"0.64233786",
"0.6376643",
"0.6354991",
"0.62912065",
"0.62578833",
"0.6215322",
"0.6210393",
"0.6161457",
"0.6135734",
"0.6121985",
"0.6117337",... | 0.6308813 | 13 |
Bind a key to a function and place it in the key_binding dict. | def bind_key(self, key, command):
self.key_bindings[key] = command | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_key(self, key):\n self.key_bindings.append(key)",
"def add_key_command(self, key, command):\n\n self.keybindings[key] = command",
"def set_handler(key):\n def wrapper(func):\n func.set_key = key\n return func\n\n return wrapper",
"def bind(self, keys... | [
"0.7758536",
"0.68353283",
"0.6754631",
"0.6718578",
"0.6685522",
"0.66740334",
"0.6664187",
"0.6461574",
"0.61550534",
"0.6086511",
"0.60782737",
"0.60704535",
"0.6050391",
"0.59863377",
"0.59380573",
"0.58823806",
"0.58508134",
"0.5848402",
"0.58358115",
"0.58337885",
"0.58... | 0.7727474 | 1 |
The error page URI. When something turns error, it will redirect to this error page. | def error_uri(self):
error_uri = self.app.config.get('OAUTH2_PROVIDER_ERROR_URI')
if error_uri:
return error_uri
error_endpoint = self.app.config.get('OAUTH2_PROVIDER_ERROR_ENDPOINT')
if error_endpoint:
return self.app.get_url(error_endpoint)
return '/oaut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_page(e):\n \n return render_template('error-page.html'), 404",
"def page_error(e):\n\n return render_template('404.html')",
"def error_redirect(err):\n error = err\n return render_template('error.html',\n title='That doesn\\'t exist!',\n ... | [
"0.74367976",
"0.71508193",
"0.7060348",
"0.70593727",
"0.7015937",
"0.6962619",
"0.6921293",
"0.68967605",
"0.6846279",
"0.6846279",
"0.68243843",
"0.6785139",
"0.6774148",
"0.6723248",
"0.6533435",
"0.6529946",
"0.6512388",
"0.6512388",
"0.6512388",
"0.6512388",
"0.6512388"... | 0.7280159 | 1 |
Ensure client_id belong to a valid and active client. | def validate_client_id(self, client_id, request, *args, **kwargs):
log.debug('Validate client %r', client_id)
client = request.client or self._clientgetter(client_id)
if client:
# attach client to request object
request.client = client
return True
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def check_client(self, client_id: Identity) -> AuthResult:\n raise NotImplementedError",
"def validate_client_id(self, client_id, *args, **kwargs):\n raise NotImplementedError('Subclasses must implement this method.')",
"def verify_client_id(self, client_id):\n raise NotImplementedEr... | [
"0.72002316",
"0.718416",
"0.71544945",
"0.65263003",
"0.65066254",
"0.62903386",
"0.6221523",
"0.62120324",
"0.62021244",
"0.61069316",
"0.60568583",
"0.6044632",
"0.6017563",
"0.6000858",
"0.5943714",
"0.5935367",
"0.5929335",
"0.58794475",
"0.5879365",
"0.5879365",
"0.5870... | 0.7385171 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.