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 |
|---|---|---|---|---|---|---|
Get absolute path to resource, works for dev and for PyInstaller | def resourcePath(relative):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(os.path.join(os.path.dirname(sys.modules[__name__].__file__), 'assets'))
return os.path.join(base_path, rela... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep",
"def resourcePath(relative, dirname=\"data\"):\n # first look in pyinstaller bundle\n if hasattr(sys, \"_MEIPASS\"):\n path = os.path.join(sys._MEIPASS, dirname)\n \n else:\n # th... | [
"0.83695436",
"0.82485795",
"0.8139178",
"0.8114118",
"0.80985415",
"0.80940944",
"0.80797124",
"0.80677074",
"0.80673695",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.80569947",
"0.80545217",
"0.80448323",
"0.80448323",
"0.80... | 0.8280479 | 1 |
Change the base rate. X and Y rate are calculated accordingly | def rate(self, rate):
# Get the sign of the rates before calculating
x_sign = copysign(1, self.x_rate)
y_sign = copysign(1, self.y_rate)
self._rate = rate
# Multiply by the original sign to retain direction
self.x_rate = x_sign * fabs(rate * cos(self._angle))
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_rate(self):\r\n interval = self.data.iloc[2, 0] - self.data.iloc[1, 0]\r\n self.rate = int(1 / interval)",
"def set_current_rate(self, rate_to_set):\n pass",
"def _do_set_rate(self, rate):\n self.set_remote_status(1)\n if rate == 0:\n self.set_to_slow()\n ... | [
"0.75314206",
"0.70942456",
"0.6440234",
"0.6368743",
"0.6368743",
"0.6339693",
"0.6272585",
"0.6251951",
"0.62460387",
"0.62019753",
"0.6159835",
"0.61460805",
"0.6097298",
"0.6093949",
"0.6093949",
"0.6093949",
"0.6083731",
"0.6060527",
"0.6033135",
"0.6031751",
"0.5984844"... | 0.71468544 | 1 |
Record the referencing definition to allow the entry to be fleshed out from a terminology service | def __init__(self, *args, defn: EnumDefinition, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._defn = defn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_ref_record(\n self, term: str, concept_id: str, ref_type: str, src_name: SourceName\n ) -> None:\n label_and_type = f\"{term.lower()}##{ref_type}\"\n record = {\n \"label_and_type\": label_and_type,\n \"concept_id\": concept_id.lower(),\n \"src_name... | [
"0.599984",
"0.59904665",
"0.59625703",
"0.58341914",
"0.57917273",
"0.5695974",
"0.5665501",
"0.5600924",
"0.55685264",
"0.55575866",
"0.55575866",
"0.5517547",
"0.5516355",
"0.54679763",
"0.5437258",
"0.54230094",
"0.53992796",
"0.5399171",
"0.5369875",
"0.5364281",
"0.5342... | 0.0 | -1 |
Function to load pretrained weights including byte embeddings. | def _load_weights(self):
self.npz_weights = np.load(self._weight_file)
self._load_byte_embedding()
self._load_cnn_weights()
self._load_highway()
self._load_projection() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pretrained_embeddings(self, embeddings):\r\n self.embedding.weight = nn.Parameter(embeddings)",
"def load_pretrained_embeddings(self, embeddings):\n self.embedding.weight = nn.Parameter(embeddings)",
"def load_embedding_weights(self, weights):\n assert self.model is not None, (\n ... | [
"0.7462192",
"0.73917234",
"0.73451287",
"0.72220963",
"0.70587224",
"0.69935733",
"0.69540274",
"0.68838245",
"0.688021",
"0.68129414",
"0.67892236",
"0.67828256",
"0.6781798",
"0.67410046",
"0.6704381",
"0.66755116",
"0.6659469",
"0.6606231",
"0.65974414",
"0.6596222",
"0.6... | 0.7540144 | 0 |
Function to load the weights associated with the pretrained CNN filters. For this to work correctly, the cnn params specified in the input arguments should match up with the pretrained architecture. | def _load_cnn_weights(self):
convolutions = []
for i, (num_filters, kernel_size) in enumerate(self.convolutions_params):
conv = torch.nn.Conv1d(in_channels=self.char_embed_dim, out_channels=num_filters, kernel_size=kernel_size, padding=kernel_size, bias=True)
weight = self.npz_we... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n if isinstance(self.pretrained, str):\n logger = get_root_logger()\n logger.info(f'load model from: {self.pretrained}')\n load_checkpoint(self, self.pretrained, strict=False, logger=logger)\n elif self.pretrained is None:\n for m in... | [
"0.65309024",
"0.653025",
"0.6505148",
"0.64951867",
"0.63941133",
"0.6366967",
"0.6366967",
"0.6366967",
"0.6366967",
"0.63181883",
"0.63012546",
"0.6275861",
"0.620356",
"0.6143983",
"0.6137789",
"0.6118419",
"0.60354614",
"0.60354614",
"0.60354614",
"0.6018268",
"0.5986158... | 0.7489214 | 0 |
Initializes a combination strategy with explicit weights. | def __init__(self, out_embed_dims, vocab_size, vocab_reduction_module=None, fixed_weights=None, hidden_layer_size=32, activation_fn=torch.nn.ReLU, logit_fn=torch.exp):
super().__init__(out_embed_dims, vocab_size, vocab_reduction_module)
if fixed_weights is None:
self.fixed_weights = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_bn(self.norm0)",
"def init_weights_(self):\n raise NotImplementedError",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def init_weight(self):\n i... | [
"0.7054682",
"0.6975355",
"0.6859268",
"0.6822358",
"0.67325836",
"0.66748327",
"0.6637847",
"0.65824926",
"0.65188146",
"0.6506243",
"0.6492994",
"0.6450341",
"0.6408442",
"0.63985825",
"0.6371664",
"0.6348808",
"0.6313254",
"0.62899643",
"0.6261524",
"0.62600356",
"0.618957... | 0.0 | -1 |
Calculates the number of ways (different combinations of coin denominations) an amount can be made up. | def change(amount: int, coins: [int]) -> int:
# DP array to hold the number of ways an amount i can be made up, where i is
# the index of the array.
# Base case, there is only 1 way to make an amount = 0,
# i.e. select nothing.
combinations = [1] + [0] * (amount - 1)
# For all available denomin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_ways(n):\n if n < 0:\n return 0\n elif n == 0:\n return 1\n else:\n total = 0\n for i in range(1, min(n, 3) + 1):\n total += count_ways(n - i)\n return total",
"def number_of_ways(n):\r\n return number_of_ways_helper([1, 5, 10, 25], n)",
"def ... | [
"0.7227765",
"0.7136858",
"0.69071966",
"0.66785073",
"0.6504434",
"0.6490219",
"0.64813673",
"0.6461526",
"0.638636",
"0.6351638",
"0.63436687",
"0.6307004",
"0.6283011",
"0.62261945",
"0.61865056",
"0.6171076",
"0.616499",
"0.6124965",
"0.6110241",
"0.6101955",
"0.6099533",... | 0.750894 | 0 |
Returns a custom loader. | def get_custom_loader(self, class_indexes, mode="test", data_source="train"):
if not isinstance(class_indexes, list): # TODO: deprecated, should always give a list
class_indexes = [class_indexes]
if data_source == "train":
x, y = self.data_train, self.targets_train
elif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loader(self):\n return self.loader_class()",
"def create_loader(self, *args, **kwargs):\n def loader():\n return self.load(*args, **kwargs)\n return loader",
"def get_loader(self) -> BaseLoader:\n return FileSystemLoader(getattr(self, \"cwd\"))",
"def loader(self):\... | [
"0.8012801",
"0.78891385",
"0.76175666",
"0.73485845",
"0.7032267",
"0.6971443",
"0.6805687",
"0.6781582",
"0.67494315",
"0.6725805",
"0.6657884",
"0.6625881",
"0.66048205",
"0.6603149",
"0.64205146",
"0.64128256",
"0.64062995",
"0.6362129",
"0.6333374",
"0.6333374",
"0.63124... | 0.0 | -1 |
Takes a string in MCNP scientific notation (without 'E' character), and returns a string of standard scientific notation. | def scinot(string):
"""If there is no '+' or '-' character in string, returns it as it is."""
"""If the argument is not string, returns the argument"""
if type(string) != str:
return string
else:
retstr = string[0]
for char in string[1:]:
if ((char == '-')|(char == '+')):
retstr += 'E' + char
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scientific(c, e):\n return Scientific(long(c), long(e))",
"def scientific_notation(value, error):\n if value is None:\n return ''\n\n if error is None or error == 0:\n value_str = '{0:f}'.format(value)\n return value_str\n\n exponent = int('{:e}'.format(value).split('e')[-1])... | [
"0.74597716",
"0.70214176",
"0.6881691",
"0.6774469",
"0.6637826",
"0.632412",
"0.63075936",
"0.61780727",
"0.60546654",
"0.5990677",
"0.5952867",
"0.5830016",
"0.58208406",
"0.5717853",
"0.5687657",
"0.5616853",
"0.5613464",
"0.5510803",
"0.53716177",
"0.5322863",
"0.5321948... | 0.5052678 | 34 |
constructor can take either 4 numbers top, right, bottom and left or a single string with these values commaseparated | def __init__(self, *args):
# 4 arguments - we need numbers then
if len(args) == 4:
self.corners = tuple(args)
# 1 argument - a string then
elif len(args) == 1:
self.corners = [ float(x) for x in args[0].split(',') ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, upper_left, lower_right):\n self.upper_left = upper_left\n self.lower_right = lower_right",
"def __init__(self, from_bottom=0, from_top=0):\n self._x = 7\n self._top = from_top\n self._bottom = from_bottom",
"def __init__(self, left, top, width, height):\n ... | [
"0.6719464",
"0.65701663",
"0.6462065",
"0.6446701",
"0.6125667",
"0.61058784",
"0.6098417",
"0.6064531",
"0.5912162",
"0.58796394",
"0.58796394",
"0.5838798",
"0.5812972",
"0.5739763",
"0.57044375",
"0.56799686",
"0.56454986",
"0.5617758",
"0.5598101",
"0.55604035",
"0.55581... | 0.6850653 | 0 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
"*** YOUR CODE HERE ***"
best_move = self.alphabeta(gameState, 0, 0, float('-inf'), float('inf'))
return best_move[1]
#util.raiseNotDefined() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.7482665",
"0.7383559",
"0.71806973",
"0.7110041",
"0.70884514",
"0.70694935",
"0.70683014",
"0.7048308",
"0.70055133",
"0.69651455",
"0.69642085",
"0.69604385",
"0.6945924",
"0.68998593",
"0.6895832",
"0.688605",
"0.6826282",
"0.6767276",
"0.6758028",
"0.6751636",
"0.67054... | 0.0 | -1 |
Return new node based on an existing one. This is normally for when a node dies, this will copy the spec of the existing node and create a new one with a new id. The new node will have been setup so it will start calling the "worker_" hooks and do work soon. | def _clone_node(self, node):
spec = node.gateway.spec
spec.id = None
self.nodemanager.group.allocate_id(spec)
node = self.nodemanager.setup_node(spec, self.queue.put)
self._active_nodes.add(node)
return node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _new_node(self):\n self._size += 1\n return self._node_factory()",
"def get_create_named_node(self, node_id_name):\n n = node_id_name.split(\"_\", 1)\n node_id = int(n[0], 16)\n if node_id in self.nodes_dict:\n node = self.nodes_dict[node_id]\n else:\n ... | [
"0.6489138",
"0.631051",
"0.6182159",
"0.6132729",
"0.6010302",
"0.593933",
"0.57952356",
"0.5762141",
"0.5748071",
"0.57378775",
"0.5725274",
"0.57094586",
"0.5674931",
"0.5674931",
"0.56417817",
"0.56274694",
"0.55876166",
"0.5568984",
"0.55587673",
"0.55493504",
"0.5531338... | 0.68288845 | 0 |
Sets description, by language. | def set_description(self, text, lang=0):
self.localized_strings[lang] = text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_description(self, description):\n self.description = description",
"def set_description(self, desc: str) -> None:\n self.metadata.data[\"description\"] = desc",
"def set_description(self, description):\r\n self.__description = description",
"def SetDescription(self, description):... | [
"0.76654494",
"0.7546616",
"0.753271",
"0.7442488",
"0.7427447",
"0.74117786",
"0.73881984",
"0.7380124",
"0.7322692",
"0.724601",
"0.7170518",
"0.7170518",
"0.7170518",
"0.7170518",
"0.71691734",
"0.71508515",
"0.7078678",
"0.7078678",
"0.7078678",
"0.7078678",
"0.7078678",
... | 0.83818585 | 0 |
Clears the training metrics. | def reset_train_results(self):
self.train_loss_results = {}
self.train_accuracy_results = {}
self.train_pred_results = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_metrics(self):\n self.metrics['loss'] = 0.0\n self.metrics['num_tokens'] = 0\n self.metrics['correct_tokens'] = 0\n self.metrics['correct_pred'] = 0\n self.metrics['pred_count'] = 0",
"def clear(self):\n self.sum_hit_at_one = 0.0\n self.sum_perr = 0.0\n self.... | [
"0.7699302",
"0.74666023",
"0.7301678",
"0.7299467",
"0.69678223",
"0.6857025",
"0.68367165",
"0.6819333",
"0.66976494",
"0.6671613",
"0.66600174",
"0.6655227",
"0.6614516",
"0.65974563",
"0.6569835",
"0.65679455",
"0.65582794",
"0.65553874",
"0.6551352",
"0.6545235",
"0.6535... | 0.6737694 | 8 |
Calculating error to obtain the optimal kvalue for the dataset | def rms(trained_data, dist):
sum = 0
for i in trained_data:
point = i[:-2]
centroid = i[-1]
distance = (calculate_distance(point,centroid, dist)**2)
sum +=distance
return sum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_error_dist(self):\n pass",
"def bootstrap_errors(self, arr, k=100):\n val = np.zeros(k)\n\n for i in range(k):\n rand_selection = np.random.choice(arr, len(arr))\n val[i] = self.varience(rand_selection)\n sigma = np.sqrt(np.average(np.square(val))\n ... | [
"0.67932993",
"0.6700016",
"0.66932",
"0.6686011",
"0.6676811",
"0.66694754",
"0.6669115",
"0.66292346",
"0.6615639",
"0.6536943",
"0.65050805",
"0.6494703",
"0.64735985",
"0.64611983",
"0.6440695",
"0.64224815",
"0.63958454",
"0.6390992",
"0.62632686",
"0.62570316",
"0.62475... | 0.0 | -1 |
Check if a table with the same name already exists in the database | def check_table_exist(conn, tablename: str):
cur = conn.cursor()
statement = f"""
SELECT count(name)
FROM sqlite_master
WHERE type ='table' AND name = '{tablename}';
"""
cur.execute(statement)
if cur.fetchone()[0] == 1:
return True
else:
return False | {
"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.836695",
"0.83259714",
"0.8322077",
"0.82974344",
"0.82870066",
"0.82675856",
"0.82639545",
"0.8263584",
"0.8060237",
"0.8034812",
"0.80214226",
"0.79850197",
"0.795955",
"0.7941069",
"0.7920342",
"0.7894434",
"0.78599817",
"0.78429747",
"0.78311336",
"0.77981627",
"0.7768... | 0.8109343 | 8 |
Load a table in the database as a pandas DataFrame | def load_table_as_pd(conn, tablename: str):
# get table as a pandas dataframe
statement = f"""
SELECT *
FROM '{tablename}';
"""
df = pd.read_sql_query(statement, conn)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_data(table):\n engine = create_engine(myDB, encoding='latin1') \n conn = engine.connect()\n select = conn.execute('select * from ' + table)\n\n df = pd.DataFrame(select.fetchall()) \n df.columns = select.keys()\n\n conn.close()\n return df",
"def sqlite_to_df(db_name: str, table_nam... | [
"0.8088912",
"0.7869987",
"0.7538217",
"0.7527204",
"0.7513636",
"0.7467348",
"0.7441683",
"0.7390268",
"0.73354167",
"0.72772354",
"0.7203501",
"0.7194859",
"0.71773535",
"0.7149098",
"0.71177626",
"0.7099741",
"0.7091411",
"0.70857525",
"0.7074693",
"0.70737654",
"0.7072798... | 0.81693804 | 0 |
Load a table of the curency in the database as a pandas DataFrame | def load_table_currency(conn, currency: str):
# if there is no such table, generate new one
if not check_table_exist(conn, f"Rates{currency}"):
gen_table_for_currency(conn, currency)
# get table as a pandas dataframe
statement = f"""
SELECT *
FROM 'Rates{currency}';
"""
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_data(table):\n engine = create_engine(myDB, encoding='latin1') \n conn = engine.connect()\n select = conn.execute('select * from ' + table)\n\n df = pd.DataFrame(select.fetchall()) \n df.columns = select.keys()\n\n conn.close()\n return df",
"def load_table_as_pd(conn, tablename: st... | [
"0.78023773",
"0.7424493",
"0.73484117",
"0.727258",
"0.72290534",
"0.7226803",
"0.7160951",
"0.71449363",
"0.71263856",
"0.7122035",
"0.70911366",
"0.70701575",
"0.7059977",
"0.70596564",
"0.7015013",
"0.6989768",
"0.69760424",
"0.69547784",
"0.6950367",
"0.6926932",
"0.6894... | 0.68263096 | 25 |
Load a table of timeseries of the year in the database as a pandas DataFrame | def load_table_history(conn, year: str):
# if there is no such table, generate new one
if not check_table_exist(conn, f"History{year}"):
gen_table_for_history(conn, year)
# get table as a pandas dataframe
statement = f"""
SELECT *
FROM 'History{year}';
"""
df = pd.read_sq... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time_series_data():\r\n # Grab the requested years and columns from the query arguments\r\n ls_year = [int(year) for year in request.args.getlist(\"n\")]\r\n ls_col = request.args.getlist(\"m\")\r\n\r\n # Generate a list of all the months we need to get\r\n all_years = [str(year) for year in... | [
"0.69370514",
"0.63788116",
"0.6256225",
"0.6213389",
"0.6161521",
"0.6069812",
"0.60681385",
"0.60541844",
"0.603321",
"0.60000306",
"0.5973641",
"0.5961304",
"0.59595996",
"0.5948979",
"0.5938011",
"0.5937477",
"0.5931679",
"0.5930218",
"0.59213066",
"0.5918005",
"0.5909139... | 0.7440471 | 0 |
Export pandas DataFrame to CSV | def output_csv(df):
# remove existing plot
if os.path.exists("files/converted.csv"):
os.remove("files/converted.csv")
# save csv
df.to_csv('files/converted.csv') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info2csv(df, csv_path):\n df.to_csv(csv_path, index=False)",
"def save_dataframe(dataframe, filename):\n with open(filename, \"w\", encoding=\"utf8\") as outfile: \n dataframe.to_csv(outfile, sep=\",\")",
"def export_csv(self, outpath):\n\n\t\tself.df.to_csv(outpath)",
"def save_df(data_fram... | [
"0.80433214",
"0.79368186",
"0.7906283",
"0.7839405",
"0.7778279",
"0.77277255",
"0.7722361",
"0.7544903",
"0.75092834",
"0.7477185",
"0.7466811",
"0.7437803",
"0.7431381",
"0.74128705",
"0.7409397",
"0.74043673",
"0.7387264",
"0.736328",
"0.7346379",
"0.7261907",
"0.7261906"... | 0.7785138 | 4 |
Initialize weights for tensorflow layer. | def init_weights(shape, initializer):
weights = tf.Variable(
initializer(shape),
trainable=True,
dtype=tf.float32
)
return weights | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_weights(self):\n tf.nest.map_structure(\n weights_initializer.WeightsInitializer.initialize_layer_or_model,\n self._layer_nest)",
"def initialize_weights(self):\n weights_initializer.WeightsInitializer.initialize_layer_or_model(\n self._batch)",
"def init_weights(w_sha... | [
"0.85037297",
"0.83079433",
"0.79877687",
"0.78269964",
"0.77068573",
"0.76946485",
"0.7638297",
"0.7628985",
"0.7592498",
"0.757538",
"0.7532976",
"0.75083584",
"0.7476698",
"0.73930746",
"0.734607",
"0.73225415",
"0.73225415",
"0.73225415",
"0.73194355",
"0.7294545",
"0.727... | 0.7730297 | 4 |
Initialize weights and hyperparameters. | def __init__(self,
input_size,
output_size,
hidden_size=[50, 50],
weights_initializer=tf.initializers.glorot_uniform(),
bias_initializer=tf.initializers.zeros(),
optimizer=tf.optimizers.Adam,
**optimiz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.8493989",
"0.83139014",
"0.82661945",
"0.81840676",
"0.8183706",
"0.8009665",
"0.8006323",
"0.7952544",
"0.7916819",
"0.78977674",
"0.7891346",
"0.7853015",
"0.782073",
"0.78200436",
"0.7807652",
"0.77586985",
"0.771543",
"0.7699972",
"0.76815027",
"0.76677597",
"0.7641777... | 0.0 | -1 |
Initialize and store weights. | def initialize_weights(self, weights_initializer, bias_initializer):
wshapes = [
[self.input_size, self.hidden_size[0]],
[self.hidden_size[0], self.hidden_size[1]],
[self.hidden_size[1], self.output_size]
]
bshapes = [
[1, self.hidden_size[0]],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def in... | [
"0.8760085",
"0.85652477",
"0.853351",
"0.8439914",
"0.8235251",
"0.8154851",
"0.7991382",
"0.79808295",
"0.7961325",
"0.78972507",
"0.7793824",
"0.77911556",
"0.7770366",
"0.77412283",
"0.77387094",
"0.77172196",
"0.77166384",
"0.7709533",
"0.7707807",
"0.7707807",
"0.768146... | 0.79080516 | 9 |
Add an experience to the buffer. | def add(self, experience):
self.buffer.append(experience) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, experience):\n self.buffer.append(experience)\n self.number += 1",
"def add_experience(self, action, state, reward, terminal):\n self.replay_buffer.add_experience(action, state, reward, terminal)",
"def append(self, experience: Experience) -> None:\n self.buffer.app... | [
"0.8337222",
"0.83237666",
"0.8282279",
"0.7766111",
"0.74063545",
"0.7144045",
"0.71393096",
"0.7102068",
"0.7003351",
"0.67246324",
"0.6662076",
"0.66429764",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253",
"0.6640253"... | 0.8822968 | 0 |
Sample a batch of experiences from the buffer. | def sample(self, batch_size):
buffer_size = len(self.buffer)
print("**",buffer_size)
index = np.random.choice(np.arange(buffer_size), size=batch_size, replace=False)
return [self.buffer[i] for i in index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, batch_size):\n if len(self._buffer) <= batch_size:\n print(\"There are only %d batches in the experience buffer.\" % len(self._buffer))\n return self._buffer\n idxes = [random.randint(0, len(self._buffer) - 1) for _ in range(batch_size)]\n return [self._b... | [
"0.7795274",
"0.7335111",
"0.73113096",
"0.7277236",
"0.712738",
"0.6983128",
"0.6642507",
"0.66353726",
"0.6613009",
"0.661174",
"0.6598743",
"0.65634197",
"0.6540795",
"0.6540663",
"0.65390074",
"0.6538082",
"0.6538082",
"0.65302044",
"0.649684",
"0.6485478",
"0.6442047",
... | 0.6673076 | 6 |
Observe state and rewards, select action. It is assumed that `observation` will be an object with a `state` vector and a `reward` float or integer. The reward corresponds to the action taken in the previous step. | def step(self, state, reward, training=True):
last_state, last_action = self.last_state, self.last_action
last_reward = reward
state = state
action = self.policy(state, training)
if training:
self.steps += 1
print("## step:",self.steps)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, reward, observation):\n self._last_observation = self._observation\n self._record_observation(observation)\n\n if not self.eval_mode:\n self._store_transition(self._last_observation, self.action, reward, False)\n self._train_step()\n\n self._rng, self.action = select_action(sel... | [
"0.7473589",
"0.7425496",
"0.7397878",
"0.72876394",
"0.70123124",
"0.70074385",
"0.6965692",
"0.6916903",
"0.6916642",
"0.6888424",
"0.6880794",
"0.68677384",
"0.68677384",
"0.68677384",
"0.6807062",
"0.67767084",
"0.67669153",
"0.6663682",
"0.66545737",
"0.6638474",
"0.6623... | 0.0 | -1 |
Epsilongreedy policy for training, greedy policy otherwise. | def policy(self, state, training):
explore_prob = self.max_explore - (self.steps * self.anneal_rate)#probabilidad de exploracion decreciente
explore = max(explore_prob, self.min_explore) > np.random.rand()
if training and explore: #hacer exploracion
action = np.random.randint(self.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def training_policy(self, state):\n if self.epsilon > random.random():\n return random.randint(0, 1)\n return self.policy(state)",
"def get_epsilongreedy_policy(epsilon):\n \n def epsilongreedy_policy(Qvalues_oa):\n \"\"\"Returns softmax action probabilites from Qvalues\"\"\... | [
"0.6861612",
"0.6850285",
"0.681551",
"0.67847323",
"0.6529303",
"0.65170807",
"0.65159696",
"0.6508535",
"0.64166343",
"0.64057946",
"0.6400463",
"0.63690525",
"0.63523644",
"0.6281904",
"0.6272008",
"0.6264072",
"0.6185272",
"0.6123318",
"0.6068625",
"0.6043868",
"0.6042495... | 0.6433922 | 8 |
Update online network weights. | def train_network(self):
batch = self.memory.sample(self.batch_size)
inputs = np.array([b["state"] for b in batch]) #####
actions = np.array([b["action"] for b in batch])
rewards = np.array([b["reward"] for b in batch])
next_inputs = np.array([b["next_state"] for b in batch])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weights(self):\r\n\r\n ined... | [
"0.80856913",
"0.80193734",
"0.7843222",
"0.7478405",
"0.7373049",
"0.736091",
"0.71097535",
"0.70364237",
"0.69313693",
"0.6928467",
"0.692263",
"0.68590105",
"0.68505967",
"0.6791082",
"0.6754766",
"0.6733757",
"0.6723729",
"0.67213994",
"0.6636391",
"0.66216546",
"0.658497... | 0.0 | -1 |
Configures the learning rate. | def configure_learning_rate(num_samples_per_epoch, global_step):
decay_steps = int(num_samples_per_epoch / FLAGS.train_batch_size *
FLAGS.num_epochs_per_decay)
if FLAGS.sync_replicas:
decay_steps /= FLAGS.replicas_to_aggregate
if FLAGS.learning_rate_decay_type == 'exponential':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)",
"def adjust_lr(self):\n learning_rate = self.params.base_lr * (1 - float(self.epoch) / self.params.num_epoch) ** self.params.power\n for param_group in self.opt.param_groups:\n param_group['lr'] = learning_rat... | [
"0.78584015",
"0.75900924",
"0.7427212",
"0.7404084",
"0.7396091",
"0.7319627",
"0.7319627",
"0.7295977",
"0.72530454",
"0.72282887",
"0.72092336",
"0.7206724",
"0.71975446",
"0.71927536",
"0.71794474",
"0.7169843",
"0.71698046",
"0.71642774",
"0.7139493",
"0.7109515",
"0.710... | 0.0 | -1 |
Return Deck representation of self. | def __repr__(self):
return self._to_deck() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return f\"{self.deck}\"",
"def __repr__(self):\n return f\"Deck({self.cards})\"",
"def get_deck(self):\n deck = Deck(self.get_cards())\n return deck.as_string()",
"def __repr__(self):\n return f'Deck.ordered_deck(\\\"{str(self.cards)}\\\")'",
"def __... | [
"0.7688002",
"0.74870914",
"0.7357664",
"0.71053725",
"0.7036348",
"0.66280764",
"0.6538443",
"0.6429727",
"0.64045805",
"0.64045805",
"0.63063467",
"0.6207211",
"0.6195336",
"0.6169427",
"0.61638373",
"0.6135511",
"0.6123057",
"0.6083293",
"0.60538083",
"0.60538083",
"0.6018... | 0.80429655 | 0 |
Return self == other. | def __eq__(self, other):
return hash(self) == hash(other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return self is other",
"def __eq__(self, other):\n return self is other",
"def __eq__(self, other):\n return equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, othe... | [
"0.9198537",
"0.9198537",
"0.9066762",
"0.9051376",
"0.9051376",
"0.90299064",
"0.8804954",
"0.87542135",
"0.87542135",
"0.8745204",
"0.87217265",
"0.87139297",
"0.8660616",
"0.8639041",
"0.8623532",
"0.8623532",
"0.861087",
"0.86094683",
"0.85829055",
"0.8562941",
"0.8560450... | 0.83540225 | 92 |
Return outputs. Since self is already a dict, return self. | def _get_outputs(self):
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputs(self):\n return super().outputs",
"def outputs(self):\n return super().outputs",
"def outputs(self):\n return super().outputs",
"def outputs(self):\n return super().outputs",
"def _get_output_dictionary(self):\n\n return_dictionary = {}\n\n for output_p... | [
"0.71566135",
"0.71566135",
"0.71566135",
"0.71566135",
"0.7097892",
"0.6913532",
"0.689619",
"0.6853556",
"0.6844908",
"0.68018454",
"0.6796605",
"0.6787412",
"0.6776301",
"0.6730959",
"0.6685601",
"0.6685601",
"0.6682933",
"0.66184855",
"0.65915674",
"0.65530384",
"0.651933... | 0.74015105 | 0 |
Get a configuration value | def get(self, key):
return self.config.get(key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_value(self, name):\r\n if name in self.config_values:\r\n return self.config_values[name]",
"def _get_config_value(self, section, key):\n return config.get(section, key)",
"def config_value(name):\n def get():\n try:\n return config.get('yourls', nam... | [
"0.81580204",
"0.80021924",
"0.7716644",
"0.76146567",
"0.7552247",
"0.7436073",
"0.7433305",
"0.73812354",
"0.73596334",
"0.73546726",
"0.7316289",
"0.73043233",
"0.72968733",
"0.7289041",
"0.72404987",
"0.7240444",
"0.72051775",
"0.72000396",
"0.71932673",
"0.71781653",
"0.... | 0.7786543 | 2 |
Return the action that gives the biggest reward | def _take_action(self, state):
feed = {self.inputs_: state.reshape((1, *state.shape))}
Qs = sess.run(self.output, feed_dict=feed)
return np.argmax(Qs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _best_action(self, state):\n actions_rewards = list(self.Q[state].items())\n return max(actions_rewards, key=lambda x: x[1])[0]",
"def getBestAction(self, state):\n best_action = 0\n max_Q = -9999\n\n for action in self.getLegalActions(state):\n Q = self.getQValu... | [
"0.86051244",
"0.7885426",
"0.7791627",
"0.7726242",
"0.7674674",
"0.761413",
"0.7510653",
"0.7505526",
"0.74816924",
"0.74333274",
"0.74302655",
"0.7428957",
"0.742741",
"0.7420358",
"0.74079823",
"0.73952883",
"0.7368436",
"0.73469406",
"0.7340752",
"0.7336696",
"0.7318386"... | 0.0 | -1 |
Return the height of the window | def getHeight(self):
return self.height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window_height(self):\n return self._window_size()[1]",
"def height(self):\n _, ymin, _, ymax = self.viewport\n return self.parent.window_size[1] * (ymax - ymin)",
"def height(self):\n return(self.SCREEN_H)",
"def height(self) -> int:\n return self.screen.getmaxyx()[0]",... | [
"0.8742522",
"0.86418915",
"0.81723183",
"0.8047453",
"0.7829384",
"0.76832265",
"0.76553386",
"0.7527061",
"0.75238705",
"0.75062746",
"0.74959934",
"0.7469232",
"0.74500936",
"0.74455863",
"0.74455863",
"0.7442378",
"0.74163246",
"0.7395741",
"0.7395741",
"0.7395741",
"0.73... | 0.74715227 | 11 |
Initializes the ArchiveAPI class. Raises an exception if no API key is given. | def __init__(self, key=None):
self.key = key
self.root = 'http://api.nytimes.com/svc/archive/v1/{}/{}.json?api-key={}'
if not self.key:
nyt_dev_page = 'http://developer.nytimes.com/docs/reference/keys'
exception_str = 'Warning: API Key required. Please visit {}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, api_key=None):\n self.api_key = api_key",
"def __init__(self, api_key: str):\n self.api_key = api_key",
"def __init__(self, api_key):\r\n self.api_key = api_key",
"def __init__(self, key=None):\n self._key = key or os.environ['HERE_API_KEY']",
"def __init__(se... | [
"0.7586055",
"0.7584554",
"0.7354341",
"0.72374195",
"0.70340335",
"0.7021993",
"0.7005954",
"0.6962782",
"0.693065",
"0.68832505",
"0.68404746",
"0.6824382",
"0.68131804",
"0.6797382",
"0.6764293",
"0.676184",
"0.6737302",
"0.67324036",
"0.6724489",
"0.66729605",
"0.65933204... | 0.71142834 | 4 |
Gets KL divergence from logits parameterizing categorical distributions. | def kl_divergence_from_logits(self, logits_a, logits_b):
distribution1 = tf.contrib.distributions.Categorical(logits=logits_a)
distribution2 = tf.contrib.distributions.Categorical(logits=logits_b)
return tf.contrib.distributions.kl_divergence(distribution1, distribution2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kl_divergence(mu, logvar):\n klds = -0.5*(1 + logvar - mu.pow(2) - logvar.exp())\n total_kld = klds.sum(1).mean(0, True)\n dimension_wise_kld = klds.mean(0)\n mean_kld = klds.mean(1).mean(0, True)\n\n return total_kld, dimension_wise_kld, mean_kld",
"def kl_divergence(self) -> Tensor:\n ... | [
"0.7628804",
"0.7506403",
"0.74137914",
"0.73204887",
"0.7240375",
"0.7128194",
"0.70689493",
"0.7061434",
"0.7040683",
"0.70135397",
"0.68758696",
"0.6874601",
"0.6865892",
"0.6780502",
"0.67629963",
"0.67596984",
"0.6739606",
"0.6738244",
"0.67353237",
"0.67282236",
"0.6616... | 0.7467578 | 2 |
create a dictionary for authorization header | def create_auth_header(api_token):
return {'Authorization': f'token {api_token}'} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_auth_headers(self):\n auth_headers = {**self.get_headers()}\n auth_headers['Authorization'] = 'Bearer ' + self.get_access_token()\n return auth_headers",
"def _auth_headers(self):\n if self.token_str:\n return {'Authorization': 'Bearer {}'.format(self.token_str)... | [
"0.8264521",
"0.7927267",
"0.76397985",
"0.76089954",
"0.7604729",
"0.758013",
"0.7575318",
"0.7524147",
"0.7471987",
"0.7467711",
"0.73492914",
"0.7334809",
"0.72946584",
"0.72717977",
"0.72471035",
"0.72339875",
"0.7229519",
"0.7199857",
"0.7178627",
"0.7173208",
"0.7160983... | 0.6809453 | 42 |
Any categories that have less than min_percent_of_total are replaced with the replacement_value. Works inplace. | def bin_categorical(X, columns_to_bin="all", min_percent_of_total=0.05,
replacement_value="Other", rows_to_scan=5000, test=False):
# Handles convenience args
if rows_to_scan is None or rows_to_scan == "all":
rows_to_scan = X.shape[0]
else:
if rows_to_scan > X.shape[0]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_rare_labels(df: pd.DataFrame, categorical_variables: list, percentage_rare: float = 0.01) -> pd.DataFrame:\n\n for var in categorical_variables:\n # Percentage occurency\n per_occ = df[var].value_counts()/len(df)\n # Find rare labels\n rare_labels = per_occ[per_occ < 0.01... | [
"0.52312654",
"0.50210625",
"0.50116533",
"0.49039388",
"0.48764372",
"0.48223853",
"0.4799416",
"0.47939923",
"0.47829977",
"0.4761669",
"0.4743391",
"0.4712804",
"0.46678007",
"0.4660977",
"0.46191442",
"0.46059975",
"0.46015292",
"0.45974833",
"0.45706776",
"0.45701098",
"... | 0.44903806 | 33 |
All values outside the range are set to the nearest valid value. | def fix_numeric_outliers(X, variable, min_value=None, max_value=None, values_to_skip=["Missing"]):
if values_to_skip is None:
values_to_skip = True
else:
temp_mask = ~X[variable].isin(values_to_skip)
if min_value is not None:
values_below_min = (X[variable] < min_value) & temp_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __limit_value(self, value, v_range):\n if np.isnan(value):\n print('Warning: trying to limit nan value in range {0}'.format(v_range))\n return value\n\n return np.min([v_range[1], np.max([value, v_range[0]])])",
"def __init__(self, value):\n self.value = max(min(val... | [
"0.67280084",
"0.6585768",
"0.6585768",
"0.657881",
"0.64627224",
"0.64221936",
"0.6351401",
"0.6333806",
"0.6284913",
"0.6262647",
"0.6227503",
"0.6202661",
"0.61818296",
"0.61785764",
"0.6146637",
"0.61062104",
"0.6043377",
"0.60346806",
"0.6034154",
"0.60000426",
"0.599856... | 0.54342437 | 99 |
Compute lagged exponentially weighted moving average. | def compute_lagged_ewma(
df, lag=48, com=None, span=None, halflife=None, alpha=None, min_periods=50
):
lagged_ma = (
df[["store", "sales"]]
.assign(sales=lambda x: x["sales"].replace(0, np.nan))
.groupby("store")["sales"]
.ewm(
com=com,
span=span,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ExpMovingAverage(values, window):\n weights = np.exp(np.linspace(-1.0, 0.0, window))\n weights /= weights.sum()\n a = np.convolve(values, weights, mode=\"full\")[: len(values)]\n a[:window] = a[window]\n return a",
"def __ExpMovingAverage(self, values, window):\n weights = np.exp(np.lin... | [
"0.7023559",
"0.6888799",
"0.65116787",
"0.6456053",
"0.6296926",
"0.6290129",
"0.6229095",
"0.62237096",
"0.612746",
"0.6107962",
"0.60603446",
"0.59731215",
"0.59587514",
"0.59493566",
"0.59398824",
"0.5933048",
"0.59273845",
"0.59166074",
"0.59030247",
"0.588305",
"0.58558... | 0.6553851 | 2 |
Wrapper for ray casting that moves the ray into object space | def obj_ray_cast(obj, matrix):
# get the ray relative to the object
matrix_inv = matrix.inverted()
ray_origin_obj = matrix_inv @ ray_origin
ray_target_obj = matrix_inv @ ray_target
ray_direction_obj = ray_target_obj - ray_origin_obj
# cast the ray
success, locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_ray_cast(obj, matrix):\r\n \r\n # get the ray relative to the object\r\n matrix_inv = matrix.inverted()\r\n ray_origin_obj = matrix_inv * ray_origin\r\n ray_target_obj = matrix_inv * ray_target\r\n ray_direction_obj = ray_target_obj - ray_origin_ob... | [
"0.71598464",
"0.7108806",
"0.7093949",
"0.700609",
"0.62521666",
"0.61117506",
"0.60194856",
"0.59293383",
"0.5882952",
"0.5871332",
"0.5810898",
"0.58108354",
"0.576089",
"0.5749889",
"0.5703415",
"0.56720555",
"0.560589",
"0.5594175",
"0.5577506",
"0.55460733",
"0.5533887"... | 0.6975007 | 4 |
Verify calls made by _filter_relationships_by_concept_type for 'subject' attr. | def test_filter_relationships_by_concept_type__subject(self):
# Set up mocks and test data
concept_type = 'birds'
mock_match_0 = Mock(name='mock_match_0',
subject=Mock(name='mock_subject_0',
concept_name='mock_subject_0',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkSubject(self, subject):\n if ((self.isDone(subject))\n or (subject not in self._subjects)\n or ((subject in self._topLevels) and (self.depth > 1))\n or (isinstance(subject, URIRef) and (self.depth >= self.maxDepth))\n ):\n return False\n ... | [
"0.6293298",
"0.601306",
"0.59035575",
"0.57108295",
"0.5619436",
"0.5606152",
"0.5568829",
"0.55426836",
"0.5521416",
"0.5487015",
"0.5482857",
"0.5463503",
"0.5461148",
"0.54554766",
"0.54209936",
"0.5403768",
"0.53760767",
"0.53603387",
"0.53412795",
"0.5331514",
"0.526793... | 0.692777 | 0 |
Factory function to create ccp.molecule.ChemComp.ChemAtom | def newChemAtom(self, **attrlinks):
return ChemAtom(self, **attrlinks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newChemTorsion(self, **attrlinks):\n return ChemTorsion(self, **attrlinks)",
"def test_set_molecule(self):\n mol = Molecule.from_smiles(\"CCO\")\n atom = Atom(6, 0, False)\n atom.molecule = mol",
"def parse_pyscf_atom(atom):\n\n atom_split = atom.split()\n atoms = []\n xyz ... | [
"0.6056511",
"0.6035366",
"0.602897",
"0.59488595",
"0.5935293",
"0.57687217",
"0.5704038",
"0.56735724",
"0.5615816",
"0.55815077",
"0.5561653",
"0.5555727",
"0.5513816",
"0.55053157",
"0.5492147",
"0.5482265",
"0.54704016",
"0.54588264",
"0.5447981",
"0.54237646",
"0.539665... | 0.79114217 | 0 |
getter for derived attribute molecularMass | def getMolecularMass(self):
dataDict = self.__dict__
# get formula dictionary
dd = {}
for ca in self.chemAtoms:
if isinstance(ca, ChemAtom):
ss = ca.elementSymbol
ii = dd.get(ss)
if ii is None:
dd[ss] = 1
else:
dd[ss] = ii + 1
# calculat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMass(self):\n return self.mass",
"def mass(self):\n return self._getAttribute(Attribute.mass)",
"def get_mass(self):\n return self.m",
"def get_mass(elem):\n return mass[get_num(elem)]",
"def get_mass(self):\n _pal.lib.geometry_get_mass.restype = c.c_float\n return _pal... | [
"0.7758728",
"0.76035815",
"0.74402684",
"0.7271214",
"0.6975921",
"0.6815242",
"0.6815242",
"0.67686343",
"0.67518306",
"0.6698567",
"0.6671718",
"0.6611475",
"0.65937376",
"0.658786",
"0.6516276",
"0.64765406",
"0.6416973",
"0.64056027",
"0.640463",
"0.638148",
"0.6337404",... | 0.7478707 | 2 |
getter for derived attribute 'name'. | def getName(self):
dataDict = self.__dict__
result = self.varName
if result is None:
result = self.chemComp.name
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attribute(self, name):\n\n pass",
"def get_attr(self, name: str):\n return self.call(name)",
"def getattribute(self, name):\n return self.attributes[name]",
"def getAttribute(self, name):\n \n return self[self._name][name]",
"def __getattr__(self, name):\n ... | [
"0.8022654",
"0.77704996",
"0.7563914",
"0.75631404",
"0.75395125",
"0.7315027",
"0.7291857",
"0.72904366",
"0.72522384",
"0.72522384",
"0.72522384",
"0.72479707",
"0.72443295",
"0.7235993",
"0.7215743",
"0.7215743",
"0.7197754",
"0.71435183",
"0.71343774",
"0.71202534",
"0.7... | 0.0 | -1 |
Returns a truncated normal random popularity between 0 and 1 that follows the PDF f(y) = exp( a (y c)^2 ) where a is the curvature and c is the bell center. This is a truncated normal distribution. | async def random_album_popularity():
center_popularity = 0.8
curvature = 40
lower_bound = -1
upper_bound = erf(math.sqrt(curvature) * (1 - center_popularity))
x = random.uniform(lower_bound, upper_bound)
y = erfinv(x) / math.sqrt(curvature) + center_popularity
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_normal():\r\n return inverse_normal_cdf(random.random())",
"def random_normal():\n return inverse_normal_cdf(random.random())",
"def approx_standard_normal_cdf(x):\n return 0.5 * (1.0 + torch.tanh(np.sqrt(2.0 / np.pi) * (x + 0.044715 * torch.pow(x, 3))))",
"def normal_cdf(x: float, mu: fl... | [
"0.7072904",
"0.70413464",
"0.6549087",
"0.64577645",
"0.6391812",
"0.6340278",
"0.6327663",
"0.6321923",
"0.62710714",
"0.6222938",
"0.6205376",
"0.6193061",
"0.6190687",
"0.6186813",
"0.61738265",
"0.6139713",
"0.6136385",
"0.61146873",
"0.6102311",
"0.609306",
"0.6056159",... | 0.0 | -1 |
Initialize a DaosServerDumpTest object. | def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.start_servers_once = False
self.setup_start_agents = False
# force test status !!
# use mangling trick described at
# https://stackoverflow.com/questions/3385317/private-variables-and-methods-in-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_tests(self):\n # Access the sentries for inspecting service units\n self.compute_sentry = self.d.sentry['nova-compute'][0]\n self.rabbitmq_sentry = self.d.sentry['rabbitmq-server'][0]\n self.neutron_api_sentry = self.d.sentry['neutron-api'][0]\n self.n_ovs_sentry ... | [
"0.6330861",
"0.6286964",
"0.6216757",
"0.6216359",
"0.61715674",
"0.6135942",
"0.61085504",
"0.6100424",
"0.60896116",
"0.60408473",
"0.6010684",
"0.599684",
"0.5903705",
"0.5881801",
"0.5861641",
"0.57719654",
"0.5767447",
"0.5721207",
"0.57200617",
"0.57200617",
"0.5716647... | 0.5936979 | 12 |
Create entities, assignments and execute the test plan. The standard method to call to create entities and assignments and execute the tests as specified in the test_plan. The test_data dict is returned so that, if required, the caller can execute additional manual tests with the entities and assignments created. | def execute_assignment_plan(self, test_plan):
test_data = self.create_entities(test_plan['entities'])
if 'implied_roles' in test_plan:
self.create_implied_roles(test_plan['implied_roles'], test_data)
if 'group_memberships' in test_plan:
self.create_group_memberships(test_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_assignment_cases(self, test_plan, test_data):\n def check_results(expected, actual, param_arg_count):\n if param_arg_count == 0:\n # It was an unfiltered call, so default fixture assignments\n # might be polluting our answer - so we take into account\n ... | [
"0.6115073",
"0.57431996",
"0.5491718",
"0.5467591",
"0.5430116",
"0.54054946",
"0.5393962",
"0.53546107",
"0.53440744",
"0.53411573",
"0.53249675",
"0.5315105",
"0.52941453",
"0.5288204",
"0.5285796",
"0.5266986",
"0.52587986",
"0.5256776",
"0.52383655",
"0.5225149",
"0.5206... | 0.79944634 | 0 |
Test retrieving projects for a list of groups. | def test_list_projects_for_groups(self):
domain1 = unit.new_domain_ref()
self.resource_api.create_domain(domain1['id'], domain1)
domain2 = unit.new_domain_ref()
self.resource_api.create_domain(domain2['id'], domain2)
project1 = unit.new_project_ref(domain_id=domain1['id'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_projects(self):\n pass",
"def test_list_projects(self):\n pass",
"def test_get_projects(self):\n for project in ['TEST', 'NEWTEST', 'MYPROJECT']:\n self.db.insert_single_result(generate_mock_result(project=project))\n projects = self.db.get_projects()\n ... | [
"0.7426615",
"0.7426615",
"0.73840016",
"0.73089945",
"0.72755104",
"0.71810687",
"0.70579064",
"0.70225734",
"0.70167893",
"0.70132345",
"0.6997497",
"0.6947873",
"0.6947873",
"0.693407",
"0.69186646",
"0.6916463",
"0.6916463",
"0.6861962",
"0.6839103",
"0.6831126",
"0.68193... | 0.7768443 | 0 |
Test deleting user assignments when user_id == group_id. In this scenario, only user assignments must be deleted (i.e. USER_DOMAIN or USER_PROJECT). | def test_delete_user_assignments_user_same_id_as_group(self):
# Create a common ID
common_id = uuid.uuid4().hex
# Create a project
project = unit.new_project_ref(
domain_id=CONF.identity.default_domain_id)
project = self.resource_api.create_project(project['id'], proj... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_groups_group_users_user_delete(self):\n pass",
"def test_groups_group_users_user_delete(self):\n pass",
"def test_groups_group_users_delete(self):\n pass",
"def test_groups_group_users_delete(self):\n pass",
"def test_delete_group_assignments_group_same_id_as_user(self)... | [
"0.79228497",
"0.79228497",
"0.7834778",
"0.7834778",
"0.7796741",
"0.7780306",
"0.7382477",
"0.73678774",
"0.7234542",
"0.72126406",
"0.72126406",
"0.7167291",
"0.71258175",
"0.7112196",
"0.7018552",
"0.6981585",
"0.6902135",
"0.6896833",
"0.6896833",
"0.68877214",
"0.686941... | 0.78866005 | 2 |
Test deleting group assignments when group_id == user_id. In this scenario, only group assignments must be deleted (i.e. GROUP_DOMAIN or GROUP_PROJECT). | def test_delete_group_assignments_group_same_id_as_user(self):
# Create a common ID
common_id = uuid.uuid4().hex
# Create a project
project = unit.new_project_ref(
domain_id=CONF.identity.default_domain_id)
project = self.resource_api.create_project(project['id'], pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_user_assignments_user_same_id_as_group(self):\n # Create a common ID\n common_id = uuid.uuid4().hex\n # Create a project\n project = unit.new_project_ref(\n domain_id=CONF.identity.default_domain_id)\n project = self.resource_api.create_project(project[... | [
"0.78340346",
"0.781498",
"0.7760736",
"0.7760736",
"0.77535963",
"0.7728384",
"0.7728384",
"0.7675892",
"0.7675892",
"0.76373875",
"0.75707597",
"0.75002474",
"0.74699146",
"0.7442749",
"0.7415445",
"0.73626935",
"0.7360754",
"0.73507035",
"0.7295921",
"0.72706264",
"0.72243... | 0.80244184 | 0 |
Test that you can intermix inherited and implied roles. | def test_role_assignments_inherited_implied_roles(self):
test_plan = {
'entities': {'domains': {'users': 1, 'projects': 1},
'roles': 4},
# Simply one level of implied roles
'implied_roles': [{'role': 0, 'implied_roles': 1}],
# Assign to to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_has_role_inherit(self):\n self.make_assignment(self.category, self.user_bob, self.role_delegate)\n self.make_assignment(\n self.category, self.user_carol, self.role_contributor\n )\n self.make_assignment(self.category, self.user_dan, self.role_guest)\n self.as... | [
"0.7462091",
"0.7140938",
"0.69557977",
"0.68221325",
"0.6816837",
"0.681397",
"0.6728274",
"0.6512486",
"0.6467647",
"0.6336051",
"0.62864375",
"0.6258244",
"0.6255183",
"0.6197079",
"0.6185463",
"0.61453575",
"0.61228216",
"0.6106559",
"0.6086041",
"0.6081349",
"0.60646516"... | 0.6733843 | 6 |
Return the input series as a list of dictionaries. | def to_dict(self) -> List[dict]:
return asyncio.run(self.parse(key="series")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dict(self):\n return self.time_series_data[:]",
"def series_to_dict(self, into=dict): # noqa: PR01\n return SeriesDefault.register(pandas.Series.to_dict)(self, into)",
"def _extract_data_points_from_series(series: dict) -> List[dict]:\n data_points = series[\"generic:Obs\"]\n if typ... | [
"0.6929916",
"0.6721533",
"0.66943806",
"0.63228506",
"0.63228506",
"0.6235433",
"0.6157189",
"0.61374766",
"0.60968953",
"0.60905844",
"0.60497814",
"0.60417616",
"0.600812",
"0.59725934",
"0.5893963",
"0.5873206",
"0.5870149",
"0.5850827",
"0.5763742",
"0.57211214",
"0.5714... | 0.73827493 | 0 |
Set list of the markets divided by comma. Default (["Nasdaq", "Dow Jones & Company", "Standard & Poor's", "EURO STOXX 50", "OMX Vilnius", "MICEX"]) | def set_markets(self, markets=None):
if markets and isinstance(markets, str):
if markets.find(',') != -1:
market_list = markets.split(',')
for item in market_list:
self.markets.append(item.strip())
else:
self.markets.app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markets(self, irc, msg, args):\n locationIDs = self._sql(\"\"\"\n SELECT \"locationID\" FROM evecentral_market\"\"\", None, single=False)\n if len(locationIDs) == 0:\n irc.reply('No prices have been indexed yet.', prefixNick=False)\n return\n output = []\n ... | [
"0.58979124",
"0.5510508",
"0.54082114",
"0.54040486",
"0.53525615",
"0.5322153",
"0.52954507",
"0.52458686",
"0.521425",
"0.5132477",
"0.51164764",
"0.5114516",
"0.5101415",
"0.50314766",
"0.5030474",
"0.5030234",
"0.5011241",
"0.49688765",
"0.49075285",
"0.49054503",
"0.487... | 0.83249456 | 0 |
Returns an instance of the Chrome webdriver ready to use | def create_driver(custom_config: list = None) -> Chrome:
# Create folders, if needed
_create_folders(tmp_folder=TMP_FOLDER)
# Configure Chromedriver and Headless Chromium
options: Options = Options()
options.binary_location = HEADLESS_CHROMIUM_EXEC_PATH
logging.info(
"Headless Chromium... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_webdriver(self):\n driver = webdriver.Chrome(self.CHROME_DRIVER_PATH, options=self.CHROME_DRIVER_OPTIONS)\n driver.implicitly_wait(1)\n driver.set_window_size(1024, 768)\n\n return driver",
"def _instantiate_driver(self) -> webdriver:\n\n if self.driver is None: return... | [
"0.8035484",
"0.8015173",
"0.80048656",
"0.76857805",
"0.7680195",
"0.76355606",
"0.75565946",
"0.75337106",
"0.7512366",
"0.7510683",
"0.7451064",
"0.74450004",
"0.743815",
"0.7410527",
"0.7170391",
"0.7132587",
"0.7088704",
"0.70682955",
"0.7027501",
"0.70139647",
"0.698260... | 0.62389475 | 56 |
Custom function to break a list or string into an array of a certain size | async def split_list(arr, size=100):
arrs = []
while len(arr) > size:
pice = arr[:size]
arrs.append(pice)
arr = arr[size:]
arrs.append(arr)
return arrs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expand_dim_str(lstring):\n a = np.array(lstring)\n dim = len(a.shape)\n new_2d=[]\n if dim == 1:\n ### ele is string\n for ele in a:\n new_list=ele.split()\n new_2d.append(new_list)\n return new_2d",
"def splitList(arr, size):\n arrs = []\n while len(a... | [
"0.6751881",
"0.65950465",
"0.6509575",
"0.6386776",
"0.626208",
"0.6217358",
"0.6140288",
"0.6089471",
"0.6070355",
"0.6008839",
"0.5995368",
"0.59863514",
"0.596613",
"0.59531623",
"0.59454334",
"0.59348375",
"0.5918103",
"0.5917018",
"0.58951515",
"0.5887069",
"0.5879641",... | 0.64134973 | 3 |
[Bot Owner] Sets how long the bot should wait to delete text only messages from gallery channels. Can be provided as | async def cmd_galsetexpirehours(self, ctx, timepat):
# ===== CHECK IF VALID
new_time = Gallery.time_pat_to_hrs(timepat)
if not new_time:
await ctx.send_help("galsetexpirehours", delete_after=15)
return
# ===== SAVE COG SETTINGS
self.cogset['text_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def channel_(self, ctx, number=10):\n number = number if number <= 100 else 100\n question = await ctx.send(f\"this will delete the last {number} messages from ALL users. Continue?\")\n await question.add_reaction(self.reactions[0])\n await question.add_reaction(self.reactions[1])... | [
"0.6113266",
"0.6052656",
"0.6047526",
"0.58043826",
"0.57594407",
"0.57352984",
"0.5661724",
"0.56213427",
"0.5594964",
"0.5562828",
"0.55388004",
"0.5536573",
"0.5486905",
"0.54839855",
"0.5447579",
"0.543499",
"0.5430403",
"0.5425167",
"0.5425054",
"0.5414159",
"0.5383205"... | 0.0 | -1 |
Get the name of the file containing the job stderr output. | def efile_name(self):
return self.efile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errfile(self):\n\n return f\"{self.name}.err.out\"",
"def stderr_path(self):\n return self.log_path\n # return self.path / 'stderr.txt'",
"def errorpath():\n stdoutfile=pdbid()+\".error.log\"\n stdout = os.path.join(output_dir(), stdoutfile)\n\n return stdout",
"def get_err... | [
"0.79207146",
"0.7657718",
"0.6944597",
"0.6936976",
"0.6919918",
"0.6895317",
"0.6619028",
"0.6527949",
"0.64424354",
"0.64291555",
"0.64257",
"0.6410295",
"0.64065486",
"0.63821495",
"0.63387674",
"0.6331221",
"0.6330184",
"0.6288577",
"0.62616384",
"0.623459",
"0.62326014"... | 0.59688014 | 38 |
Return a handle to the file containing the job stderr output. | def efile_handle(self):
if not self.status == "finished":
raise NameError("redhawk: unfinished efile check")
tries = 0
while not self.efile_exists() and ties < self.file_limit:
time.sleep(self.file_delay)
tries = tries+1
if os.path.isfile(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stderr_path(self):\n return self.log_path\n # return self.path / 'stderr.txt'",
"def get_stderr(self):\n _ = self.get() # force finished wait\n if self._stderr is not None:\n if wait_until_exists(self._stderr):\n with open(self._stderr) as f:\n ... | [
"0.71674186",
"0.6878812",
"0.6830592",
"0.6689355",
"0.6668842",
"0.66134876",
"0.6605577",
"0.656073",
"0.65606123",
"0.6469733",
"0.64606935",
"0.6327932",
"0.62799186",
"0.6192154",
"0.61756",
"0.606629",
"0.6008639",
"0.60084134",
"0.600642",
"0.597382",
"0.59637195",
... | 0.0 | -1 |
Return the entire contents of the stderr file as a single string. | def efile_string(self):
fp = self.efile_handle()
if (fp):
return "\n".join([line.rstrip() for line in fp])
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stderr(self) -> str:\n _args: list[Arg] = []\n _ctx = self._select(\"stderr\", _args)\n return _ctx.execute_sync(str)",
"def stderr(self):\n if self._stderr is None:\n stderr = [p.stderr.read() for p in self.processes if p.stderr]\n output = b'\\n'.join(stder... | [
"0.7354133",
"0.70606244",
"0.68572485",
"0.6843937",
"0.68411696",
"0.68175966",
"0.67416906",
"0.6697875",
"0.6669653",
"0.6584444",
"0.64751357",
"0.64382833",
"0.63950884",
"0.63558584",
"0.63240755",
"0.6187304",
"0.6110022",
"0.6109217",
"0.5936329",
"0.5845833",
"0.582... | 0.5876308 | 19 |
Returns an empty square in the board (denoted by 0) or None | def find_empty(game_board):
for row in range(len(game_board)):
for col in range(len(game_board[row])):
if len(game_board[row][col]) == 2:
return row, col
for row in range(len(game_board)):
for col in range(len(game_board[row])):
if len(game_board[row][col]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_empty_squares(board):\n for i in range(len(board)):\n for j in range(len(board[0])):\n if board[i][j] == 0:\n return (i,j) #row , column\n\n #if there are no blank squres\n return None",
"def find_blank_square(self, state):\n\n return state.index(0)",
... | [
"0.7926117",
"0.7580522",
"0.7457676",
"0.73076075",
"0.7188301",
"0.7162848",
"0.7140008",
"0.7102084",
"0.70862204",
"0.7081004",
"0.70434135",
"0.7040654",
"0.69779015",
"0.69036084",
"0.68470305",
"0.6822679",
"0.67158467",
"0.66648215",
"0.661563",
"0.65856814",
"0.65141... | 0.68548316 | 14 |
Creates minibatch tensors from the list of tuples (image, word). We should build custom collate_fn rather than using default collate_fn, because merging word tensor creates jagged array. | def collate_fn(self, batch):
# Sort a data list by caption length (descending order).
#sample.sort(key=lambda x: len(x[1]), reverse=True)
images, words = [b.get('image') for b in batch], [b.get('word') for b in batch]
# Merge images (from tuple of 3D tensor to 4D tensor).
im... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collate_fn(batch):\n images, word_seqs, ex_lengths, question_seqs, question_lengths = zip(*batch)\n\n word_seqs = [torch.LongTensor(seq) for seq in word_seqs]\n ex_lengths = torch.LongTensor(ex_lengths)\n # Targets as next-word predictions:\n targets = [x[1:, ] for x in word_... | [
"0.6550434",
"0.62762785",
"0.6275038",
"0.62643844",
"0.6185859",
"0.61502814",
"0.6087124",
"0.6030415",
"0.6030415",
"0.5898426",
"0.58704895",
"0.58089006",
"0.57687855",
"0.57661927",
"0.57654643",
"0.57545185",
"0.5748627",
"0.57456136",
"0.5705521",
"0.5700728",
"0.569... | 0.60958594 | 6 |
This function performs the projective transform on generalized coordinates in the camera reference frame. | def projective_transform(self, x):
x = np.asarray(x)
# Assume no intensity column
x0, y0, z0 = x
# Camera coors to pixel coors
u = ((x0 / z0) * self.f) + (self.sensor_size[0] // 2)
v = ((y0 / z0) * self.f) + (self.sensor_size[1] // 2)
u_min = np.min(u)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project(points, camera_params, theta):\n \"\"\"\n Function takes input of 3d_points, transformations and Convert 3-D points to 2-D by projecting onto images. \n Input:\n points: 3D points in world frame\n camera_params: parameters of camera corrosponding to the point\n theta: Need... | [
"0.7182992",
"0.6840343",
"0.67974097",
"0.6712718",
"0.65696365",
"0.653324",
"0.6518825",
"0.636312",
"0.62609214",
"0.6226265",
"0.6213532",
"0.6204459",
"0.61659306",
"0.615992",
"0.607",
"0.6055714",
"0.60392445",
"0.6021425",
"0.60152227",
"0.59850276",
"0.5955878",
"... | 0.68798894 | 1 |
This function adjusts the pose vector such that the difference between the observed pixel coordinates u_gcp and the projected pixels coordinates of X_gcp is minimized. | def estimate_pose(self, X_gcp, u_gcp, p0):
self.p = p0.copy()
def residuals(p, X_gcp, u_gcp):
self.p = p.copy()
xuv = self.ene_to_camera(X_gcp)
return xuv.ravel() - u_gcp.ravel()
res = least_squares(residuals, self.p, args=(X_gcp, u_gcp))
self.p = r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_translation(X_gcp, u_gcp, t0, R, P0):\n # Note: u_gcp is of the form [u1, v1, u2, v2]\n x1, x2 = u_gcp[:, :2], u_gcp[:, 2:]\n t = t0.copy()\n\n def residuals(t, X_gcp, x1, x2, R, P0):\n\n t_tmp = t.copy()\n P1 = np.column_stack((R, t_tmp))\n\n xyz = get_point_estimates... | [
"0.5871056",
"0.56272286",
"0.54839903",
"0.545051",
"0.52724147",
"0.52062786",
"0.51885563",
"0.5137682",
"0.5124193",
"0.5123715",
"0.5088529",
"0.5086157",
"0.5085519",
"0.50504535",
"0.5019286",
"0.5019286",
"0.5019286",
"0.49988604",
"0.4996057",
"0.49950585",
"0.499136... | 0.71052176 | 0 |
Implementation of the vgg16 network architecture. | def ModelFashionMnis(input_shape):
X_train_input = Input(input_shape)
X_padded = ZeroPadding2D(padding=2, data_format="channels_last")(X_train_input)
X = Conv2D(6, (5, 5),strides=(1, 1), padding='same')(X_padded)
# normalize the third component colors
X = BatchNormalization(axis=3)(X)
X = Act... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_cnn_vgg16(num_classes):\n\n inputs = tf.keras.layers.Input(\n shape=(IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_CHANNELS)\n )\n\n x = inputs\n x = tf.keras.applications.vgg16.preprocess_input(x)\n vgg16 = tf.keras.applications.VGG16(\n input_shape=(IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_CHAN... | [
"0.67830545",
"0.6643874",
"0.6568722",
"0.65050983",
"0.64804304",
"0.6469104",
"0.64690965",
"0.64683026",
"0.64546573",
"0.6388197",
"0.63545346",
"0.63419306",
"0.6182508",
"0.617667",
"0.61656755",
"0.60965544",
"0.6080285",
"0.60774344",
"0.602638",
"0.60162467",
"0.597... | 0.0 | -1 |
Return number of days in month of year. | def num_of_day(month, year):
if month in _31_DAYS_MONTHS:
return 31
elif month in _30_DAYS_MONTHS:
return 30
elif month == 2:
return 29 if year % 400 == 0 or (((year % 4) == 0) and ((year % 100) != 0)) else 28 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days_in_month(year, month):\n num_days = monthrange(year, month)[1]\n return num_days",
"def number_of_days_in_month(year=2019, month=1):\n return monthrange(year, month)[1]",
"def numDays(month, year):\n\tif month in [9, 4, 6, 11]:\n\t\treturn 30\n\telif month == 2 and year % 4 == 0 and (year % 1... | [
"0.7850374",
"0.78414345",
"0.7811324",
"0.7803339",
"0.76533324",
"0.7599156",
"0.7533657",
"0.75104845",
"0.7328186",
"0.73274964",
"0.7270841",
"0.726649",
"0.72438234",
"0.72214925",
"0.7188591",
"0.7174663",
"0.71469605",
"0.7141674",
"0.7141674",
"0.7141674",
"0.7047025... | 0.7540683 | 6 |
Updates the bot's info. It makes a request to the Telegram API method getMe for your bot. So, it can take a second, and you probably shouldn't use this in any situation where getting a result is timesensitive (e.g. for a web application). | def update_info(self):
r = requests.get(self.url + 'getMe')
if r.status_code == 200:
response = json.loads(r.text)
if response['ok']:
bot_info = response['result']
self.user_id = bot_info['id']
self.first_name = bot_info['first_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def botinfo(ctx, bot: typing.Union[discord.Member, discord.User]):\n if not bot.bot:\n return await r(ctx, 'Not a bot.')\n\n data = await make_request(\"https://www.motiondevelopment.top/api/v1.2/bots/\", bot.id)\n \n e = discord.Embed(\n title=f'Available bot info for {bot}',\n ... | [
"0.6754105",
"0.65667605",
"0.656062",
"0.63868964",
"0.62784415",
"0.62165785",
"0.6199801",
"0.6149475",
"0.60541046",
"0.6011569",
"0.5946093",
"0.59267515",
"0.5906734",
"0.5880165",
"0.58717114",
"0.58524954",
"0.5824999",
"0.58095723",
"0.576604",
"0.57542145",
"0.57483... | 0.83398795 | 0 |
Basic CRUD test for customization templates. | def test_customization_template_crud():
template_crud = pxe.CustomizationTemplate(
name=generate_random_string(size=8),
description=generate_random_string(size=16),
image_type='RHEL-6',
script_type='Kickstart',
script_data='Testing the script')
template_crud.create()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_template_subsciption(self):\n pass",
"def test_otoroshi_controllers_adminapi_templates_controller_template_spec(self):\n pass",
"def test_custom_templates_and_themes(self):\n new_templates_dir = os.path.join(self.temp_usable_dir, 'templates')\n manage_tmpl_file = os.... | [
"0.7407133",
"0.72310233",
"0.7001032",
"0.6997639",
"0.68266696",
"0.6733864",
"0.66688555",
"0.6545972",
"0.6540119",
"0.653132",
"0.6530678",
"0.6510409",
"0.6483457",
"0.6456371",
"0.64347017",
"0.6415115",
"0.6361497",
"0.6323861",
"0.6322545",
"0.62937975",
"0.6239249",... | 0.82386756 | 0 |
Get words from a sentence. | def _find_words(string: str):
if string:
cursor, i, string = 0, 0, string + " "
while i <= len(string) - 1:
if string[i] in (' ', '\n', ',', '.', ')', ']', ';'):
if i - 1 >= cursor:
yield string[cursor:i]
delta = 1
while... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getWords(speech):\r\n return speech.split()",
"def get_words_from_sentence(sentence):\n cursor, i, sentence = 0, 0, sentence.strip().lower() + \" \"\n\n while i <= len(sentence) - 1:\n if not sentence[i].isalpha() and not sentence[i] == \"'\":\n if i - 1 >= cursor:\... | [
"0.7646374",
"0.74929106",
"0.74613297",
"0.726714",
"0.7245001",
"0.7224486",
"0.7224486",
"0.7215456",
"0.71920544",
"0.71547645",
"0.7063934",
"0.7059494",
"0.7035133",
"0.7028391",
"0.70210713",
"0.70199937",
"0.69354343",
"0.69054306",
"0.68417287",
"0.68199134",
"0.6802... | 0.0 | -1 |
Get a set of nonnumeric primitives for a given dataset and a list of primitives. | def _recommend_non_numeric_primitives(
entityset: EntitySet,
target_dataframe_name: str,
valid_primitives: List[str],
) -> set:
recommended_non_numeric_primitives: set[str] = set()
# Only want to run feature generation on non numeric primitives
numeric_columns_to_ignore = list(
entityse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_recommended_primitives(\n entityset: EntitySet,\n include_time_series_primitives: bool = False,\n excluded_primitives: List[str] = DEFAULT_EXCLUDED_PRIMITIVES,\n) -> List[str]:\n es_dataframe_list = entityset.dataframes\n if len(es_dataframe_list) == 0:\n raise IndexError(\"No DataFra... | [
"0.620877",
"0.55920696",
"0.5544416",
"0.54853773",
"0.53882384",
"0.52771014",
"0.51838106",
"0.50448173",
"0.50376505",
"0.5023514",
"0.498675",
"0.49738827",
"0.49458063",
"0.4915414",
"0.4899456",
"0.48959982",
"0.48929536",
"0.48797107",
"0.48574507",
"0.48506698",
"0.4... | 0.66251254 | 0 |
Shows the pdf for a normal distribution | def test_normal(self):
s = np.random.normal(-0.42, 0.55, 5000)
plt.hist(s, 30, density=False)
plt.xlabel('Interlayer point energy [eV]')
plt.ylabel('Frequency')
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf(data, args):\n return Plot._dist(data, args)",
"def normal_pdf(x: torch.Tensor) -> torch.Tensor:\n return torch.exp(-(x ** 2 / 2)) / np.sqrt(2 * np.pi)",
"def norm_pdf(x, mu, sigma):\n\n prefac = 1 / (sigma * math.sqrt(2 * math.pi))\n expt = np.exp(-(x - mu)**2 / (2 * sigma**2))\n\n ... | [
"0.71322227",
"0.7120219",
"0.7118275",
"0.6871644",
"0.67907304",
"0.67692435",
"0.6742873",
"0.67155707",
"0.6639947",
"0.65659255",
"0.65286",
"0.6508396",
"0.6501852",
"0.65008205",
"0.64638674",
"0.6451759",
"0.6426927",
"0.6408007",
"0.6402361",
"0.638713",
"0.6371099",... | 0.6525473 | 11 |
Returns a list of rooms adjacent to the opposite side of the wall/railing from the given room. | def rooms_opposite(self, room):
if room in self.adjacencies:
room_side = self.adjacencies[room][0].self_edge_index
other_side = 0 if room_side == 2 else 2
return self.adjacencies.filter(lambda obj, info: isinstance(obj, Room) and info.self_edge_index == other_side) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wallsAndGates(self, rooms: List[List[int]]) -> None:\n lenm = len(rooms)\n lenn = len(rooms[0])\n \n queue = []\n visited = set()\n \n direction = [(0,1),(1,0),(0,-1),(-1,0)]\n \n for i in range(lenm):\n for j in range(lenn):\n ... | [
"0.7182474",
"0.71004254",
"0.70025134",
"0.69944274",
"0.695812",
"0.6947057",
"0.69322765",
"0.6931394",
"0.6693629",
"0.66728497",
"0.66448057",
"0.66133136",
"0.6564108",
"0.6488827",
"0.63808286",
"0.6323494",
"0.62701184",
"0.6006804",
"0.59742105",
"0.59700954",
"0.595... | 0.7258249 | 0 |
Returns the total area of the floor. | def area(self):
area = 0
for room in self.rooms:
area += room.polygon.area()
for wall in self.walls:
area += wall.polygon.area()
return area | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_area(self):\n return self._total_area",
"def area(\n self):\n pi = numpy.pi\n area0 = 4.0 * pi / 8.0\n areadiv = 4.0 ** self.depth\n area = area0 / areadiv * (180.0 / pi) ** 2\n return area",
"def area(self):\n area = 0\n last = self.... | [
"0.7603641",
"0.7495594",
"0.74398786",
"0.74268794",
"0.74074984",
"0.7326943",
"0.7316738",
"0.7309322",
"0.7296285",
"0.7292403",
"0.72820085",
"0.72534865",
"0.7242216",
"0.7230589",
"0.7217491",
"0.7204747",
"0.72001916",
"0.71613634",
"0.7156542",
"0.714826",
"0.7116177... | 0.7664809 | 0 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
# TODO: our current credentials logic in merchants/models is confusing,
# this may change when that improves
if self.value() == 'none':
return queryset.filter(basecredential=None)
if self.value() == 'some':
return queryset.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.7541626",
"0.74203515",
"0.72454756",
"0.7205669",
"0.70897406",
"0.7050602",
"0.69765645",
"0.6783343",
"0.67632455",
"0.67323023",
"0.6682762",
"0.6658436",
"0.6589408",
"0.6472066",
"0.6416623",
"0.63815427",
"0.63685715",
"0.63504004",
"0.63493055",
"0.6278321",
"0.626... | 0.64032143 | 15 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
if self.value() == 'ignore':
return queryset.filter(ignored_at__isnull=False)
if self.value() == 'active':
return queryset.filter(ignored_at=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.75412977",
"0.7420519",
"0.7245913",
"0.72053033",
"0.708998",
"0.7050834",
"0.69776845",
"0.67845905",
"0.6763999",
"0.67335665",
"0.6682345",
"0.6656384",
"0.6589473",
"0.64718145",
"0.6416493",
"0.64035666",
"0.6382932",
"0.63685006",
"0.63506263",
"0.6349897",
"0.62753... | 0.6131109 | 36 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
if self.value() == 'examine':
return queryset.filter(ignored_at=None, address_1__isnull=False, longitude_position=None).exclude(address_1='')
if self.value() == 'done':
return queryset.filter(longitude_position__isnull=False)
if self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.7541626",
"0.74203515",
"0.72454756",
"0.7205669",
"0.70897406",
"0.7050602",
"0.69765645",
"0.6783343",
"0.67632455",
"0.67323023",
"0.6682762",
"0.6658436",
"0.6589408",
"0.6472066",
"0.6416623",
"0.64032143",
"0.63815427",
"0.63685715",
"0.63504004",
"0.63493055",
"0.62... | 0.59107053 | 65 |
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. | def queryset(self, request, queryset):
if self.value() == 'syndicated':
return queryset.filter(syndicated_at__isnull=False)
if self.value() == 'ready_to_syndicate':
return queryset.filter(ignored_at=None,
syndicated_at=None,
longitude_posit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.75412977",
"0.7420519",
"0.7245913",
"0.72053033",
"0.708998",
"0.7050834",
"0.69776845",
"0.67845905",
"0.6763999",
"0.67335665",
"0.6682345",
"0.6656384",
"0.6589473",
"0.64718145",
"0.6416493",
"0.64035666",
"0.6382932",
"0.63685006",
"0.63506263",
"0.6349897",
"0.62753... | 0.57845014 | 80 |
Return the key in the time range item provided. | def get_key(self, item):
return item[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(self):\n if self._key is None:\n # Use _END_OF_TIME so that it is ordered after all real dates\n return _END_OF_TIME, _END_OF_TIME\n return self._key",
"def getKeyIndexFromTime(self, *args):\n return _osgAnimation.QuatInterpolator_getKeyIndexFromTime(self, *args... | [
"0.63833964",
"0.63783056",
"0.6365131",
"0.60051596",
"0.598787",
"0.59118116",
"0.59033597",
"0.5852847",
"0.5835955",
"0.5811163",
"0.5778256",
"0.57092255",
"0.57080275",
"0.5663525",
"0.5643951",
"0.5629618",
"0.5622848",
"0.5622848",
"0.5622848",
"0.5622848",
"0.5622848... | 0.70954573 | 0 |
Initialize the class with your optional user_id and required api_key. If `enabled` is not True, these methods become noops. This is particularly useful for testing or disabling with configuration. | def __init__(self, mc_api=None, mc_user='python-mailchimp', access_token=None, enabled=True, timeout=None,
request_hooks=None, request_headers=None):
super(MailChimpClient, self).__init__()
self.enabled = enabled
self.timeout = timeout
if access_token:
self.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, enabled: bool, api_key: str, http: HTTPService):\n self._enabled = enabled\n self._api_key = api_key\n self._http = http",
"def __init__(self, api_key=None):\n self.api_key = api_key",
"def __init__(__self__, *,\n is_enabled: pulumi.Input[bool],\n ... | [
"0.7125185",
"0.6903266",
"0.67840827",
"0.6696757",
"0.6618441",
"0.6596863",
"0.6547762",
"0.653303",
"0.6471451",
"0.64387834",
"0.6338419",
"0.6333017",
"0.6306855",
"0.6298272",
"0.62426645",
"0.62043023",
"0.6187669",
"0.61372864",
"0.6135107",
"0.61208785",
"0.6110617"... | 0.58934003 | 49 |
Returns a gaussian function with the given parameters | def gaussian(height, center_x, center_y, width_x, width_y):
width_x = float(width_x)
width_y = float(width_y)
return lambda x,y: height*exp(
-(((center_x-x)/width_x)**2+((center_y-y)/width_y)**2)/2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(x, *parameters):\n position, sigma, amplitude, background = parameters\n return amplitude * np.exp(-(x - position)**2 / (2.0 * sigma**2)) + background",
"def gaussian(pars, x):\n A, b, mu, sigma = pars\n # return b + A/(np.sqrt(2*np.pi)*sigma**2) \\\n return b + A \\\n * np.exp... | [
"0.79345214",
"0.7810653",
"0.7587596",
"0.7489787",
"0.74641114",
"0.73853296",
"0.73745215",
"0.7267242",
"0.7267242",
"0.7267242",
"0.722654",
"0.7221817",
"0.71300167",
"0.7127061",
"0.7118297",
"0.7089313",
"0.70826656",
"0.707121",
"0.7059532",
"0.7031942",
"0.7013216",... | 0.7243077 | 10 |
Returns a zero sparse tensor with the specified size | def spzeros(size, device='cuda:0'):
return SparseTensor(size=size).to(device=device) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros_target(size):\n data = torch.zeros(size, 1)\n return data",
"def get_zeros(self, size, device):\n if device > -1:\n return torch.cuda.LongTensor(size, device=device).zero_()\n else:\n return torch.zeros(size, dtype=torch.long)",
"def _generate_zero_filled_sta... | [
"0.743911",
"0.73009026",
"0.714754",
"0.71230614",
"0.70675737",
"0.6979969",
"0.6864765",
"0.6810804",
"0.68089503",
"0.6736027",
"0.6711662",
"0.669438",
"0.66750693",
"0.6610675",
"0.660573",
"0.659686",
"0.6534611",
"0.65210265",
"0.6486046",
"0.64770997",
"0.6471863",
... | 0.84438 | 0 |
Stops the display from scrolling. | def stop_scroll():
send_command(0x2E) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __stopScrolling(self):\n self.__view.inputWidget().releaseMouse()\n QApplication.restoreOverrideCursor()\n \n self.__indicator.hide()\n self.__indicator.setParent(None)\n self.__scroller.stopScrolling()",
"def stop(self):\n\t\tself._front_left_wheel.stop()\n\t\tself.... | [
"0.82298183",
"0.6923742",
"0.68166476",
"0.6798954",
"0.6618601",
"0.6599855",
"0.64804274",
"0.64618",
"0.6443012",
"0.6213652",
"0.6213652",
"0.6160245",
"0.61358446",
"0.6118504",
"0.6099247",
"0.60812646",
"0.60807157",
"0.60807157",
"0.6055953",
"0.6055953",
"0.6041202"... | 0.80752945 | 1 |
Sets the start and end page pointers, resetting the current page to the start page. | def set_page_address(start_page, end_page):
send_command(0x22)
send_command(start_page)
send_command(end_page) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.page_number = 0\n self.next_page_token = None",
"def reset(self):\n\t\tself.offsets = self.start_off.copy()",
"def reset(self):\n\n # TODO Need to redo this so that it doesn't scrap cached page data each time this is run.\n\n self.page_current = self.pages[-1... | [
"0.623242",
"0.61812",
"0.606417",
"0.60623056",
"0.59414965",
"0.5851583",
"0.5745234",
"0.5703578",
"0.5604226",
"0.55716586",
"0.5544691",
"0.5535073",
"0.5525594",
"0.54878366",
"0.5426956",
"0.54262084",
"0.5414779",
"0.5410225",
"0.5399898",
"0.53922284",
"0.5386435",
... | 0.69816923 | 0 |
Simple equality test. 0.0 if the labels are identical, 1.0 if they are different. >>> from nltk.metrics import binary_distance >>> binary_distance(1,1) 0.0 >>> binary_distance(1,3) 1.0 | def binary_distance(label1, label2):
return 0.0 if label1 == label2 else 1.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not self._is_valid_operand(other):\n return NotImplemented\n # If we get a NodeContainer were comparing distance and if we get an\n # Int were comparing node labels\n if type(other) is NodeContainer:\n return self.distance == other.dis... | [
"0.6363347",
"0.626547",
"0.62157947",
"0.61984026",
"0.61840206",
"0.6132605",
"0.6064498",
"0.6031347",
"0.60034025",
"0.5975839",
"0.5956005",
"0.59147084",
"0.5893037",
"0.58677495",
"0.5866163",
"0.5859819",
"0.5853765",
"0.5840896",
"0.5825877",
"0.5823348",
"0.58187515... | 0.82261974 | 0 |
This should update `image` inplace, either using `DeepCopy`, or by manually resizing, allocating, etc. If the image is updated, this should return True. Otherwise, it should return False. | def update_image(self, image):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reassign(self, img):\n retVal = copy.deepcopy(self)\n if( self.image.width != img.width or\n self.image.height != img.height ):\n warnings.warn(\"DON'T REASSIGN IMAGES OF DIFFERENT SIZES\")\n retVal.image = img\n\n return retVal",
"def update_image(self):\n ... | [
"0.64929295",
"0.6457721",
"0.63917315",
"0.6196578",
"0.61103255",
"0.6057602",
"0.586549",
"0.5859385",
"0.58530337",
"0.5808924",
"0.573383",
"0.5701352",
"0.5683223",
"0.56756186",
"0.56732184",
"0.5652435",
"0.5566104",
"0.5566104",
"0.5562456",
"0.5549277",
"0.5533348",... | 0.71274424 | 0 |
The distance in miles for a change in latitude. | def delta_lat_miles(self, delta_lat):
return delta_lat.dist_from_radius(EARTH_RADIUS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_in_meters(self, latlng):\n return self.distance_to(latlng)",
"def distance_miles(self):\n return self._distance_miles",
"def delta_long_miles(self, lat, delta_long):\n\n return delta_long.dist_from_radius(self.parallel_radius(lat))",
"def get_distance(self) -> int:\n retu... | [
"0.73949796",
"0.72696966",
"0.7180514",
"0.7028076",
"0.6993027",
"0.6883771",
"0.68653023",
"0.6749199",
"0.6749199",
"0.6749199",
"0.6749199",
"0.6749199",
"0.674772",
"0.6740009",
"0.6728708",
"0.67266905",
"0.6693411",
"0.6679949",
"0.6663511",
"0.6655859",
"0.66452295",... | 0.7885562 | 0 |
The distance in miles at the given change in longitude at latitude. | def delta_long_miles(self, lat, delta_long):
return delta_long.dist_from_radius(self.parallel_radius(lat)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_lat_miles(self, delta_lat):\n\n return delta_lat.dist_from_radius(EARTH_RADIUS)",
"def distance_in_meters(self, latlng):\n return self.distance_to(latlng)",
"def coord_dist_meters(lat1, lon1, lat2, lon2):\n # convert decimal degrees to radians\n lon1, lat1, lon2, lat2 = map(math.radia... | [
"0.7795151",
"0.7317499",
"0.7004313",
"0.6870824",
"0.68681264",
"0.68371147",
"0.6829037",
"0.680252",
"0.6768636",
"0.6743632",
"0.6704095",
"0.6661468",
"0.66495156",
"0.66495156",
"0.66495156",
"0.66495156",
"0.66495156",
"0.66494733",
"0.6645965",
"0.6643864",
"0.663505... | 0.7508539 | 1 |
Compute the distance between a change in x, y. | def cartesian_dist(self, delta_x, delta_y):
return math.sqrt(delta_x * delta_x + delta_y * delta_y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to(self, x, y):\n\t\tdx = x - self.x\n\t\tdy = y - self.y\n\t\treturn math.sqrt((dx**2)+(dy**2))",
"def dist(self,x, y):\n\n x1, y1 = x\n x2, y2 = y\n return np.sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2))",
"def dist(x, y):\n dx = x[0] - y[0]\n dy = x[1] ... | [
"0.77608776",
"0.76845706",
"0.75960684",
"0.75827575",
"0.7542325",
"0.72796583",
"0.72158736",
"0.7186083",
"0.7148195",
"0.70903724",
"0.70885015",
"0.7084954",
"0.70790374",
"0.70709085",
"0.70588005",
"0.7050752",
"0.7040894",
"0.70228314",
"0.69629025",
"0.6886406",
"0.... | 0.68216133 | 24 |
Compute the distance between two Coordinates. | def distance(self, coord1, coord2):
delta_x = self.delta_long_miles(coord1.lat, coord1.delta_long(coord2))
delta_y = self.delta_lat_miles(coord1.delta_lat(coord2))
return self.cartesian_dist(delta_x, delta_y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(coords1, coords2):\n dx = coords1.x - coords2.x\n dy = coords1.y - coords2.y\n return math.sqrt(dx * dx + dy * dy)",
"def distance(self,coord_1, coord_2):\n return np.sqrt(np.sum((np.array(coord_1)-np.array(coord_2))**2))",
"def _distance(coord1, coord2):\n xdist = coord1[0] - c... | [
"0.81758565",
"0.81234795",
"0.7836912",
"0.7826782",
"0.7776414",
"0.7770053",
"0.7747081",
"0.770035",
"0.7637538",
"0.7618674",
"0.7589781",
"0.75655276",
"0.7548084",
"0.7537825",
"0.75143826",
"0.74880904",
"0.7478515",
"0.7460281",
"0.74149233",
"0.7410896",
"0.7408894"... | 0.78078043 | 4 |
Compute the distance using the great circle. | def distance(self, coord1, coord2):
sinsin_lat = coord1.lat.sin() * coord2.lat.sin()
coscos_lat = coord1.lat.cos() * coord2.lat.cos()
cos_deltalong = coord1.delta_long(coord2).cos()
angle = AngleDeg().acos(sinsin_lat + coscos_lat * cos_deltalong)
return angle.dist_from_radius(EARTH_RADIUS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to(self, circle):\n diff = tuple(map(sub, self.pos, circle.pos))\n return math.hypot(*diff)",
"def _greatCircleDistance(self, long1, lat1, long2, lat2):\n # convert decimal degrees to radians \n long1, lat1, long2, lat2 = map(radians, [float(long1), float(lat1), float(lon... | [
"0.73143226",
"0.71714073",
"0.7020941",
"0.70152754",
"0.6983358",
"0.68966514",
"0.68209356",
"0.67474055",
"0.6742805",
"0.6732465",
"0.66978043",
"0.6675536",
"0.6671146",
"0.66174257",
"0.6616936",
"0.66168183",
"0.65885496",
"0.6570979",
"0.6561479",
"0.6552933",
"0.654... | 0.0 | -1 |
At the end of the web request, this makes sure to close the database connection. If you don't, the database could run out of memory! | def teardown_request(exception):
try:
g.conn.close()
except Exception as e:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_request():\n db.close()",
"def close(self):\r\n self.conn.close()\r\n gc.collect()",
"def cleanup(_):\n self.db.close()",
"def close(self): \n self.connection.close()",
"def after_request(response):\n g.db.close()\n return response",
"def after_reque... | [
"0.79487187",
"0.7743723",
"0.75628585",
"0.7458552",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7452353",
"0.7359539",
"0.73334867",
"0.73334867",
"0.7331413",
"0.73311794",
"0.7329911"... | 0.0 | -1 |
Validate that there are at least two columns to evaluate. This is used for the MulticollinearityFilterer, as it requires there be at least two columns. | def _validate_cols(cols):
if cols is not None and len(cols) < 2:
raise ValueError('too few features') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkcolumnstest(chosen_columns, chosen_df):\n if not all([item in chosen_columns for item in chosen_df.columns]):\n raise ValueError('Columns do not match')",
"def _validate_columns(data, ip_column, lat_column, long_column, other_columns):\n if not ip_column and not (lat_column and long_column)... | [
"0.63007146",
"0.62730986",
"0.6261995",
"0.6172241",
"0.61509734",
"0.61489624",
"0.59735453",
"0.58488107",
"0.58254385",
"0.5805848",
"0.58003217",
"0.57759917",
"0.57619196",
"0.5761685",
"0.575194",
"0.57383364",
"0.571718",
"0.5715198",
"0.56939083",
"0.56931704",
"0.56... | 0.7518125 | 0 |
Set internal lane offset (unused). | def setLane(self, offset):
command = struct.pack("<Bf", 0x2c, offset)
self.sendCommand(command) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setOffset(self, offset):\n\t\tself.out_offs = offset",
"def set_offset(self, offset):\n self.offset = offset",
"def set_offset(self, offset):\n self.offset = offset",
"def set_offset(self, offset):\r\n for b in self.buf:\r\n b.set_offset(offset)",
"def set_offset(self, offset):\n ... | [
"0.70886636",
"0.65208024",
"0.65208024",
"0.6284529",
"0.6246572",
"0.6175693",
"0.60711926",
"0.5977688",
"0.5936572",
"0.59300625",
"0.58256346",
"0.58256346",
"0.58256346",
"0.58156615",
"0.58062506",
"0.58062506",
"0.58062506",
"0.58062506",
"0.578426",
"0.5772362",
"0.5... | 0.74085814 | 0 |
Get notifications received count. | def getNotificationsReceived(self):
return self._delegate.notificationsRecvd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_count(self):\n return self._notify_count",
"def notification_count(request):\n\n # Check if logged in\n user = request.user\n if not user.is_authenticated():\n return {}\n\n return {\n 'notification_count': len(user.profile.notifications.filter(read=False))\n }",
... | [
"0.74030477",
"0.70884264",
"0.6943244",
"0.6853357",
"0.67557317",
"0.67393297",
"0.6732005",
"0.67178196",
"0.67118806",
"0.67022634",
"0.6688418",
"0.66589236",
"0.66345876",
"0.6630026",
"0.6602556",
"0.6602556",
"0.66025066",
"0.65950054",
"0.65489393",
"0.6541053",
"0.6... | 0.74696016 | 0 |
removes stopwords from the document | def remove_stopwords(data):
stop_words = stopwords.words('english')
words = word_tokenize(str(data))
new = ""
for word in words:
if word not in stop_words and len(word) > 1:
new = new + " " + word
return new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)",
"def remove_stop_words(document):\n\n stop_words = stopwords.words(... | [
"0.8954958",
"0.8570293",
"0.8339957",
"0.80649686",
"0.7897418",
"0.7846063",
"0.7817743",
"0.7810578",
"0.78101593",
"0.78101593",
"0.78101593",
"0.78101593",
"0.77941626",
"0.7778723",
"0.77598935",
"0.7750641",
"0.77385473",
"0.7718202",
"0.76887405",
"0.76880676",
"0.768... | 0.76810414 | 21 |
Returns a term frequency dictionary for each document, with keys that are unique tokens in the document and values are the corresponding term frequencies | def calcTFdict(doc):
TFDict = {}
#counts number of appearances of term in document
for term in doc:
if term in TFDict.keys():
TFDict[term] +=1
else:
TFDict[term] = 1
#Computing tf for each term
for key in TFDict:
TFDict[key] = TFDict[key]/len(doc)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_doc_frequencies(self, docs):\n frequencyIndex = {}\n doc_id = 0\n for doc in docs:\n for term in doc:\n if term not in frequencyIndex:\n frequencyIndex[term] = [doc_id]\n else:\n for id in frequencyIn... | [
"0.80503917",
"0.7767786",
"0.7710711",
"0.76916707",
"0.76675",
"0.7652626",
"0.7579404",
"0.7465514",
"0.74649125",
"0.7460507",
"0.74378973",
"0.7394977",
"0.7377244",
"0.73751295",
"0.7369895",
"0.7363354",
"0.7289726",
"0.7270914",
"0.72544914",
"0.72527176",
"0.72497433... | 0.7920206 | 1 |
Returns dictionary whose keys are all unique words in dataset and values are corresponding Inverse Document Frequencies | def calcIDFDict(countDict, numfiles):
IDFDict = {}
for term in countDict:
IDFDict[term] = math.log(numfiles / countDict[term])
return IDFDict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _count_word_frequency(self, data):\n _dict = {}\n for _docs in data:\n for _word in _docs:\n if _word in _dict:\n _dict[_word] += 1\n else:\n _dict[_word] = 1\n return _dict",
"def frequencies(self):\n ... | [
"0.73733556",
"0.721703",
"0.71198237",
"0.7083923",
"0.6993667",
"0.6964663",
"0.68719226",
"0.6867172",
"0.6827491",
"0.68192333",
"0.6812137",
"0.6780089",
"0.67771214",
"0.6769273",
"0.676461",
"0.67548084",
"0.6679879",
"0.6674313",
"0.6654548",
"0.66537184",
"0.66521066... | 0.0 | -1 |
returns dot product of two vectors | def dot_product(a, b):
dp = 0.0
for i, j in zip(a, b):
dp += i * j
return dp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot(vector1, vector2):\n return sum(a1 * a2 for a1, a2 in zip(vector1, vector2))",
"def dotproduct(vec1, vec2):\n return sum((a*b) for a, b in zip(vec1, vec2))",
"def dotproduct(vec1, vec2):\n import operator\n return sum(map(operator.mul, vec1, vec2))",
"def dot(a, b):\n\n if len(a) !... | [
"0.8837562",
"0.8809799",
"0.8740419",
"0.87311006",
"0.8716438",
"0.8689305",
"0.8658536",
"0.86536276",
"0.86420465",
"0.85264826",
"0.8502088",
"0.84995735",
"0.84892875",
"0.8473024",
"0.84492874",
"0.84423",
"0.84378564",
"0.843059",
"0.840513",
"0.83310735",
"0.83062017... | 0.77543175 | 46 |
returns the norm or magnitude of a vector | def norm(vec):
n = 0.0
for i in vec:
n += math.pow(i, 2)
return math.sqrt(n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude_of_vector(v):\n return math.sqrt(sum_of_squares(v))",
"def magni(vector):\n return(np.linalg.norm(vector))",
"def magnitude(vector):\n return math.sqrt(sum_of_squares(vector))",
"def magnitude(v: Vector) -> float:\n return math.sqrt(sum_of_squares(v)) #math.sqrt() is a square root f... | [
"0.8318155",
"0.82915425",
"0.8271868",
"0.8176854",
"0.8149822",
"0.8025927",
"0.7974649",
"0.7942382",
"0.7936313",
"0.79277396",
"0.77760696",
"0.7678774",
"0.76491886",
"0.76464576",
"0.7627023",
"0.75956297",
"0.753126",
"0.7530118",
"0.75246096",
"0.75228816",
"0.751371... | 0.7294981 | 42 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.