query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Create an instance of LightlyModelV3 from a JSON string | def from_json(cls, json_str: str) -> 'LightlyModelV3':
return LightlyModelV3(json.loads(json_str)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(cls, string):\n dct = json.loads(string)\n return cls.from_dict(dct)",
"def from_json_str(cls, json_str):\n return cls.from_json(simplejson.loads(json_str))",
"def from_json(cls, json_string:str):\n data = json.loads(json_string)\n validate(data, schema)\n in... | [
"0.73394865",
"0.73179334",
"0.7191719",
"0.71659875",
"0.7031926",
"0.7031926",
"0.6845915",
"0.6794968",
"0.67890495",
"0.67549574",
"0.6697536",
"0.6688773",
"0.65750945",
"0.6540394",
"0.65164083",
"0.64945",
"0.6421235",
"0.63542867",
"0.6344258",
"0.6339547",
"0.6327416... | 0.92721796 | 0 |
Return the raw data string. | def raw_data(self) -> str:
return self._raw_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rawdata(self) -> str:\n return self._data",
"def raw(self):\n return self.data",
"def raw(self):\n return self._raw_string",
"def raw_data(self):\n return self._raw_data",
"def raw_data(self):\n return self._raw_data",
"def get_raw_data(self):\n return self._... | [
"0.84875673",
"0.7983556",
"0.77763337",
"0.77476984",
"0.77476984",
"0.7621193",
"0.72472167",
"0.7167859",
"0.7160063",
"0.7132178",
"0.70709205",
"0.70709205",
"0.7062733",
"0.701383",
"0.6999737",
"0.69873065",
"0.68944025",
"0.67517936",
"0.6746663",
"0.67074406",
"0.668... | 0.84395015 | 2 |
Set the new value for the attribute separator. When the new value is assigned a new tree is generated. | def attr_sep(self, new_sep: str) -> None:
self._attr_sep = new_sep
self._filters_tree = self._generate_filters_tree() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_separator(self, separator):\n self._separator = separator",
"def set_tag_separator(self, tag_separator):\n\n self._tag_separator = tag_separator",
"def attr_sep(self) -> str:\n return self._attr_sep",
"def setDeviceInstanceSeparator(string: str) -> None:\n ...",
"def setAnno... | [
"0.68419844",
"0.68219495",
"0.61919963",
"0.61319524",
"0.57220167",
"0.5585897",
"0.5486652",
"0.54742694",
"0.54734194",
"0.5412231",
"0.53953534",
"0.5320774",
"0.5250122",
"0.5227051",
"0.5220068",
"0.5214759",
"0.52070975",
"0.5192201",
"0.51881516",
"0.51815903",
"0.51... | 0.7648239 | 0 |
Compute separation distance vs time for two aircraft | def calc_sep_distance_vs_time(df):
callsigns = df['callsign'].unique()
def extract_single_ac_data(callsign):
return df.loc[df['callsign'] == callsign, ['time','latitude','longitude']].set_index('time').resample('1T').mean()
df1 = extract_single_ac_data(callsigns[0])
df2 = extract_single_ac_data(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_distance(reindeer, race_time):\n interval = reindeer.flight_time + reindeer.rest_time\n cycles = race_time // interval\n flight_time = min(reindeer.flight_time, race_time - interval * cycles)\n total_flying_time = reindeer.flight_time * cycles + flight_time\n return tota... | [
"0.654372",
"0.6313945",
"0.62410563",
"0.6156887",
"0.6084207",
"0.6078479",
"0.6056227",
"0.6047061",
"0.598338",
"0.5952483",
"0.59504575",
"0.5943111",
"0.591082",
"0.59087956",
"0.5894991",
"0.5878406",
"0.5860748",
"0.5819277",
"0.5799398",
"0.5793071",
"0.57924813",
... | 0.58576626 | 17 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
id = dictionary.get('id')
name = dictionary.get('name')
mtype = dictionary.get('type')
usage_bytes = dictionary.get('usage... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(cls, dictionary):\n return cls(**dictionary)",
"def create(cls, dictionary):\n return cls(**dictionary)",
"def from_dictionary(cls,\r\n dictionary):\r\n if dictionary is None:\r\n return None\r\n\r\n # Extract variables from the dictionar... | [
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
... | 0.83181584 | 0 |
Use the result of a2/c_clustering/cluster_iris_dataset_again() as the color of a scatterplot made from the original (unprocessed) iris dataset. Choose among the numeric values to be the x and y coordinates. | def plotly_scatter_plot_chart():
df = read_dataset(Path('..', '..', 'iris.csv'))
model_data = cluster_iris_dataset_again()
df['clusters'] = model_data['clusters']
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="clusters")
return fig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_iris_dataset(data, classes, feature_names, target_names, title = \"Grafica de las caracteristicas y sus clases\"):\n\n # Tomo las coordenadas de la matriz de datos, es decir, separo coordenadas\n # x e y de una matriz de datos que contiene pares de coordenadas\n data = np.array(data)\n x_value... | [
"0.69293845",
"0.67778987",
"0.6643818",
"0.6636636",
"0.64274466",
"0.633624",
"0.61768866",
"0.60314035",
"0.5999474",
"0.5996509",
"0.5983723",
"0.5970134",
"0.59626067",
"0.59622264",
"0.5935947",
"0.59115016",
"0.5876328",
"0.5862914",
"0.5862883",
"0.58469504",
"0.58422... | 0.6802073 | 1 |
Use the result of a2/c_clustering/cluster_iris_dataset_again() and use x as 3 groups of bars (one for each iris species) and each group has multiple bars, one for each cluster, with y as the count of instances in the specific cluster/species combination. | def plotly_bar_plot_chart():
df = read_dataset(Path('..', '..', 'iris.csv'))
model_data = cluster_iris_dataset_again()
df['clusters'] = model_data['clusters']
# Species wise clusters count
count_df = df.groupby(["species", "clusters"]).size().unstack(fill_value=0).stack().reset_index()
count_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_clusters_bar(ensemble, grouping, clustering, normalize):\n\tif grouping not in ['cluster','annotation','dataset','NeuN']:\n\t\tgrouping = 'cluster'\n\tclusters = get_clusters(ensemble, grouping, clustering)\n\n\tif (normalize=='true'):\n\t\tclusters['ncells_norm'] = clusters.groupby('groups')['ncells'].tra... | [
"0.6334525",
"0.6040452",
"0.5980195",
"0.5950546",
"0.58891207",
"0.5843836",
"0.5835403",
"0.56842405",
"0.568189",
"0.5607096",
"0.5584441",
"0.55693865",
"0.5505744",
"0.54946405",
"0.5483851",
"0.54524964",
"0.5449958",
"0.543382",
"0.5429583",
"0.542188",
"0.54188997",
... | 0.55996513 | 10 |
Use the data from a1/e_/process_life_expectancy_dataset and show in a single graph on year on x and value on y where there are 5 line charts of 5 countries (you choose which) and one bar chart on the background with the total value of all 5 countries added up. | def plotly_composite_line_bar():
df = process_life_expectancy_dataset("regression")
# Countries selected: India, Pakistan, United States, Canada, Brazil
# Since the dataset is already one hot encoded, I will be restructuring it with new column called country
country_columns = ["x0_Canada", "x0_United S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(self, context=None):\n\n response = requests.get(self.url).content\n table = pd.read_html(response, attrs={\"id\": \"main_table_countries_today\"})\n df = table[0].fillna(0)\n # df.drop(df.index[0], inplace=True) # World\n df.drop([\"ActiveCases\", 'Serious,Critical', '... | [
"0.6880452",
"0.63883895",
"0.6301685",
"0.62748003",
"0.61700785",
"0.6049233",
"0.5949727",
"0.59438294",
"0.5929299",
"0.5904815",
"0.5872059",
"0.5859305",
"0.5832631",
"0.5817938",
"0.57731",
"0.5757217",
"0.572407",
"0.5721182",
"0.56887305",
"0.5686658",
"0.5682012",
... | 0.6764106 | 1 |
It computes the normalized average absolute difference (NMAE) between predicted and actual ratings for users. | def normalized_mean_absolute_error(y_real, y_pred, max_rating, min_rating):
y_real, y_pred = check_arrays(y_real, y_pred)
mae = mean_absolute_error(y_real, y_pred)
return mae / (max_rating - min_rating) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mae(actual, predicted):\n rms = np.abs(actual-predicted)\n\n # Returning the sqaure root of the root mean square\n return float(rms.mean())",
"def nmaef(actual: np.ndarray, predicted: np.ndarray):\n mage = np.mean(np.fabs(predicted - actual))\n avg_m = np.mean(predicted)\n avg_o = np.mean(a... | [
"0.72299695",
"0.7021169",
"0.69571465",
"0.6913473",
"0.6866883",
"0.68385893",
"0.6802428",
"0.67989236",
"0.67648023",
"0.67394906",
"0.665671",
"0.66284096",
"0.6608152",
"0.6569761",
"0.65651315",
"0.6560341",
"0.64920413",
"0.64866465",
"0.64711404",
"0.6464214",
"0.643... | 0.7104985 | 1 |
Check expiration of event. | def filter(self, event, *args, **kwargs):
return event["expiration_datetime"] <= datetime.now() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verify_timeout(self, doc):\n expires = doc['expires']\n if expires == 0:\n return False\n if expires >= self._time():\n return False\n return True",
"def is_expired(self):\n return timeutils.utcnow_ts() > self.expire_ts",
"def is_expired(self):\n ... | [
"0.69349533",
"0.6930439",
"0.69218874",
"0.68743914",
"0.68694174",
"0.6833796",
"0.6828024",
"0.6810472",
"0.67406076",
"0.67347264",
"0.6734034",
"0.67314774",
"0.67037255",
"0.66740805",
"0.6669488",
"0.66579276",
"0.66231096",
"0.65912795",
"0.6590676",
"0.653355",
"0.65... | 0.729283 | 0 |
Constructs a ResNet50 model. | def detnet59(pretrained=False):
model = DetNet(Bottleneck, [3, 4, 6, 3, 3])
if pretrained:
path = 'data/pretrained/detnet59.pth'
state_dict = torch.load(path)
model.load_state_dict(state_dict)
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet50(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet50']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet50(**kwargs):\n model = ResNet(... | [
"0.7557751",
"0.75548905",
"0.74759895",
"0.74759895",
"0.74759895",
"0.74759895",
"0.74557495",
"0.7386862",
"0.7386862",
"0.73601955",
"0.7355623",
"0.724254",
"0.724254",
"0.7191571",
"0.7158499",
"0.7101107",
"0.70165247",
"0.69687796",
"0.68687624",
"0.6822836",
"0.68010... | 0.0 | -1 |
If an invalid uuid passes the canned test as it should not? | def test_bad_uuid_lowercase():
bad_uiid_lower = "7cfb2470-b600-4eb3-a2cd-c1439e45b91g"
m = CannedRe.UUID.match(bad_uiid_lower)
assert m is None, "Canned RegEx uiid test succeeded for %s while it should not" % bad_uiid_lower | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uuid(data):\n\n if not uuidutils.is_uuid_like(data):\n raise exceptions.DiagnoseException(\n \"'%s' is not a valid UUID\" % data)",
"def validate_uuid(self, uuid):\n match = re.match(\n r'([a-z0-9]+)-([a-z0-9]+)-([a-z0-9]+)-([a-z0-9]+)-([a-z0-9]+)',\n ... | [
"0.7704808",
"0.767874",
"0.76275545",
"0.7606703",
"0.7480097",
"0.7366447",
"0.72534823",
"0.7173291",
"0.71532226",
"0.7087797",
"0.6990087",
"0.69868934",
"0.6924805",
"0.6924805",
"0.6909956",
"0.69026476",
"0.68927425",
"0.6847186",
"0.679067",
"0.6751819",
"0.6750672",... | 0.7733557 | 0 |
If an invalid UUID passes the canned test as it should not? | def test_bad_uuid_uppercase():
bad_uiid_upper = "7CFB2470-B600-4EB3-A2CD-C1439E45B91G"
m = CannedRe.UUID.match(bad_uiid_upper)
assert m is None, "Canned RegEx uiid test succeeded for %s while it should not" % bad_uiid_upper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_uuid(data):\n\n if not uuidutils.is_uuid_like(data):\n raise exceptions.DiagnoseException(\n \"'%s' is not a valid UUID\" % data)",
"def test_bad_uuid_lowercase():\n bad_uiid_lower = \"7cfb2470-b600-4eb3-a2cd-c1439e45b91g\"\n m = CannedRe.UUID.match(bad_uiid_lower)\n as... | [
"0.7691767",
"0.76576686",
"0.7603823",
"0.7480244",
"0.74230444",
"0.7322755",
"0.72880507",
"0.71923727",
"0.7107921",
"0.7029507",
"0.69792104",
"0.69535047",
"0.6917059",
"0.6899024",
"0.6899024",
"0.6885109",
"0.6869247",
"0.6853023",
"0.68520606",
"0.6841701",
"0.682563... | 0.75993633 | 3 |
Sends a 401 response that enables basic auth | def authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8093736",
"0.80926424",
"0.7958403",
"0.7852648",
"0.7843114",
"0.7824419",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
"0.7810746",
... | 0.774767 | 36 |
Returns the units in this subsection. | def units(self):
return self.children() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def units(self):\n return self._units",
"def units(self):\n return self._units",
"def totalUnits(self):\n\t\treturn self.units",
"def units(self):\n pass",
"def getUnits(self):\n return _libsbml.Compartment_getUnits(self)",
"def unitsofmeasure(self):\n return self._unit... | [
"0.79314274",
"0.79314274",
"0.78476715",
"0.7679931",
"0.7642868",
"0.75465053",
"0.75405955",
"0.7512169",
"0.7371975",
"0.73332566",
"0.7317006",
"0.729691",
"0.7257862",
"0.7235953",
"0.7196872",
"0.7123052",
"0.7112282",
"0.709685",
"0.70856714",
"0.7078319",
"0.7022666"... | 0.7824549 | 3 |
Returns a list of the CourseOutlineSubsections of this section | def subsections(self):
return self.children() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_courses(self, depth=0):\r\n return self.courses.values()",
"def sections(self) -> List[Section]:\n\n if self.beam is None:\n return [self.section]\n\n return self.beam.sections",
"def get_sections(self, course):\n return course.available_sections if self.free_sect... | [
"0.6576088",
"0.62941235",
"0.6280448",
"0.60720336",
"0.6029529",
"0.5974616",
"0.5971371",
"0.5964166",
"0.58750033",
"0.5803342",
"0.5716017",
"0.5663813",
"0.5637327",
"0.56083244",
"0.5589105",
"0.55617845",
"0.556104",
"0.552413",
"0.54754376",
"0.5463932",
"0.54006135"... | 0.7436124 | 0 |
Returns the text of the first selected option for the element. | def get_selected_option_text(self, element):
if element:
select = Select(element)
return select.first_selected_option.text
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text(self):\n\n selected_option = self.select_elem.first_selected_option\n return selected_option.text",
"def first_selected_option(self):\n try:\n return self.all_selected_options[0]\n except IndexError:\n raise ValueError(\"No options are selected\")",
"d... | [
"0.8311545",
"0.7626869",
"0.7181507",
"0.7064244",
"0.68068016",
"0.67647314",
"0.6660198",
"0.662143",
"0.66095257",
"0.65532583",
"0.63003266",
"0.62097794",
"0.6151715",
"0.60264874",
"0.59833866",
"0.5952768",
"0.59479356",
"0.59143287",
"0.59075046",
"0.5893097",
"0.589... | 0.9092087 | 0 |
Override returns True if staff_only is set. | def is_explicitly_locked(self):
return self.subsection_visibility == 'staff_only' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_staff(self) -> bool:\n return self.is_admin",
"def is_staff(self):\n\t\treturn self.is_admin",
"def is_staff(self):\n return self.is_admin",
"def is_staff(self):\n return self.is_admin",
"def is_staff(self):\n # Simplest possible answer: All admins are staff\n retu... | [
"0.8185713",
"0.8137082",
"0.8104924",
"0.8104924",
"0.807576",
"0.807576",
"0.807576",
"0.8047729",
"0.7878363",
"0.76933694",
"0.76933694",
"0.7268977",
"0.72549087",
"0.7180817",
"0.714731",
"0.6984951",
"0.6965611",
"0.6962048",
"0.695493",
"0.68493533",
"0.6596659",
"0... | 0.67651683 | 20 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.77288336",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.764... | 0.74379355 | 97 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ExerciseDetailData):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Returns True if the robot can move right or False if it's at the end of the list. | def can_move_right(self):
return self._position < len(self._list) - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_move_right(self):\r\n return self._position < len(self._list) - 1",
"def move_right(self):\n self._time += 1\n if self._position < len(self._list) - 1:\n self._position += 1\n return True\n else:\n return False",
"def move_right(self):\r\n ... | [
"0.84276205",
"0.7928889",
"0.7926562",
"0.7616977",
"0.7231846",
"0.6955946",
"0.6891664",
"0.68436426",
"0.6814479",
"0.67863053",
"0.665358",
"0.6600383",
"0.6598947",
"0.657011",
"0.6544402",
"0.64383525",
"0.6416842",
"0.6415617",
"0.63951963",
"0.6350403",
"0.6342096",
... | 0.8452943 | 0 |
Returns True if the robot can move left or False if it's at the start of the list. | def can_move_left(self):
return self._position > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_move_left(self):\r\n return self._position > 0",
"def _move_left(self) -> bool:\n current_agent_node = self._maze.get_player_node()\n\n if current_agent_node.x == 0:\n # Can't go left. Already at the left-most row.\n return False\n else:\n next... | [
"0.8286945",
"0.7470075",
"0.73369575",
"0.73301274",
"0.7308069",
"0.7300477",
"0.7169686",
"0.71679443",
"0.7164279",
"0.695377",
"0.6820526",
"0.6532877",
"0.65060246",
"0.6477855",
"0.6476443",
"0.64754057",
"0.6461609",
"0.6454559",
"0.6453352",
"0.6395174",
"0.63787866"... | 0.82680565 | 1 |
If the robot can move to the right, it moves to the right and returns True. Otherwise, it stays in place and returns False. This will increment the time counter by 1. | def move_right(self):
self._time += 1
if self._position < len(self._list) - 1:
self._position += 1
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_right(self):\r\n self._time += 1\r\n if self._position < len(self._list) - 1:\r\n self._position += 1\r\n return True\r\n else:\r\n return False",
"def _move_right(self) -> bool:\n current_agent_node = self._maze.get_player_node()\n\n i... | [
"0.79661775",
"0.74957323",
"0.7470367",
"0.7470266",
"0.73417145",
"0.7307837",
"0.7291168",
"0.71269256",
"0.7096487",
"0.6933112",
"0.6858477",
"0.68372464",
"0.66559815",
"0.66397625",
"0.66316515",
"0.6587609",
"0.6557985",
"0.6535831",
"0.65162396",
"0.647864",
"0.64270... | 0.79544264 | 1 |
Turn off the robot's light | def set_light_off(self):
self._light = "OFF" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light",
"def set_light_off(self):\r\n self._light = \"OFF\"",
"def lightning_turnoff(self):\n self.turnOff()",
"def turn_off(self, **kwargs: Any) -> None:\n self._device.power_on = False\n _LOGGER.debug(\"Turn ... | [
"0.86348635",
"0.84360194",
"0.83788353",
"0.8316623",
"0.8311838",
"0.8304517",
"0.820827",
"0.81927854",
"0.815375",
"0.80797386",
"0.80159813",
"0.79644084",
"0.7959992",
"0.78213656",
"0.77047175",
"0.76935154",
"0.768451",
"0.7644186",
"0.76071763",
"0.757453",
"0.757188... | 0.8385892 | 2 |
Returns True if the robot's light is on and False otherwise. | def light_is_on(self):
return self._light == "ON" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light_is_on(self):\r\n return self._light == \"ON\"",
"def is_on(self):\n return self._light_on",
"def is_light(self) -> bool:\n return ATTRIBUTE.Light.value in self.type_data.attributes",
"def is_light(self) -> bool:\n return ATTRIBUTE.Light.value in self.type_data.attributes... | [
"0.87283224",
"0.8306702",
"0.7586803",
"0.7586803",
"0.7564179",
"0.74899966",
"0.73714936",
"0.73338795",
"0.70835525",
"0.7082115",
"0.7067962",
"0.7059329",
"0.7052127",
"0.70485437",
"0.70421416",
"0.69646126",
"0.69385916",
"0.6931243",
"0.6931243",
"0.6931243",
"0.6930... | 0.8645753 | 1 |
Test related user profile model also contains user data. | def test_user_profile_creation_is_successful(self):
user_profile = UserProfile.objects.get(user_id=self.user_1.id)
user_profile_count = UserProfile.objects.count()
self.assertEqual(user_profile_count, 2)
self.assertEqual(
str(user_profile), "{}'s profile".format(user_profile.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_associated_with_users(self):\n profile = ImagerProfile.objects.first()\n self.assertTrue(hasattr(profile, 'user'))\n self.assertIsInstance(profile.user, User)",
"def test_user_profile_relationship(self):\r\n user = self._create_test_user()\r\n profile = self._c... | [
"0.81381285",
"0.76104003",
"0.74030334",
"0.72471625",
"0.712884",
"0.6899452",
"0.6880256",
"0.6879465",
"0.68536013",
"0.6823468",
"0.6820838",
"0.67547375",
"0.67006195",
"0.6697245",
"0.6678262",
"0.66434765",
"0.66427237",
"0.66318303",
"0.6551391",
"0.6545062",
"0.6538... | 0.68736017 | 8 |
Manually set axes ticks on a plot. This works on both x and y axes. | def set_axes_ticks(
ax: object,
xticks:Union[List, None]=None,
xticks_str:Union[List, None]=None,
xticks_pad:Union[List, None]=None,
x_minor:Union[List, None] = None,
x_rotation:float=0.,
major_length: float=3.0,
minor_length: float=1.5,
yticks:Union[List, None]=None,
yticks_str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def py_apply_ticks(self, plot):\n if self.x_ticks is not None:\n plot.set_xticks(self.x_ticks)\n if self.x_labels is not None:\n plot.set_xticklabels(self.x_labels)\n if self.y_ticks is not None:\n plot.set_yticks(self.y_ticks)\n if self.y_labels is not ... | [
"0.8227052",
"0.751157",
"0.6852938",
"0.6852938",
"0.6852938",
"0.68470937",
"0.681978",
"0.67993045",
"0.6775618",
"0.6732604",
"0.67204344",
"0.6720418",
"0.6692094",
"0.66291505",
"0.6622836",
"0.66008484",
"0.65780103",
"0.65470105",
"0.6542259",
"0.645243",
"0.64437854"... | 0.7511499 | 2 |
Show all the axis ticks and the lines. | def showaxes(axl: Union[object, List], whichaxes: str = "xy"):
axl = _ax_tolist(axl)
for ax in axl:
if ax is None:
continue
if "x" in whichaxes:
ax.spines["bottom"].set_visible(True)
ax.tick_params(bottom=True, labelbottom=True)
if "y" in whichaxes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_axes():\n\n plt.axes(frameon=False)\n plt.axvline(0, PlotParameter.y_axis_bot_lim, PlotParameter.y_axis_top_lim, color='k')\n plt.tick_params(which='both', bottom='off', top='off', right='off', labelbottom='off')\n plt.xlim(0, PlotParameter.x_axis_right_lim)\n plt.ylim(PlotParameter.y_axi... | [
"0.6877955",
"0.68757534",
"0.68544704",
"0.6832434",
"0.6743903",
"0.6733606",
"0.66385466",
"0.6563157",
"0.65567064",
"0.6487614",
"0.6424288",
"0.64200515",
"0.63967943",
"0.6393792",
"0.6343417",
"0.6324413",
"0.6320306",
"0.6299543",
"0.6287635",
"0.6277586",
"0.6241045... | 0.6484859 | 10 |
Set the Y limits for an axes from a source axes to the target axes. | def setY(ax1: Union[object, List], ax2: Union[object, List]):
if type(ax1) is list:
print("PlotHelpers: cannot use list as source to set Y axis")
return
ax2 = _ax_tolist(ax2)
# if type(ax2) is not list:
# ax2 = [ax2]
refy = ax1.get_ylim()
for ax in ax2:
ax.set_ylim(re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_ylimits(self, ylim1, ylim2):\n self.axplot.set_ylim(ylim1, ylim2)\n self.fig.canvas.draw()\n return",
"def SetYAxisRange(self, lower, upper):\n self.Y_AXIS_RANGE = (lower, upper)",
"def ylim(self, bottom=None, top=None):\r\n for ax in self._subaxes:\r\n ... | [
"0.7516328",
"0.71141165",
"0.68276185",
"0.6814975",
"0.67129445",
"0.6579535",
"0.6561174",
"0.64597774",
"0.6297541",
"0.6276706",
"0.62525755",
"0.6144087",
"0.60784286",
"0.60540503",
"0.6034295",
"0.60327905",
"0.6023544",
"0.60069805",
"0.5964345",
"0.5884205",
"0.5876... | 0.7485839 | 1 |
Manually set axes ticks on a plot. This works on both x and y axes. | def set_axes_ticks(
ax: object,
xticks:Union[List, None]=None,
xticks_str:Union[List, None]=None,
xticks_pad:Union[List, None]=None,
x_minor:Union[List, None] = None,
x_rotation:float=0.,
major_length: float=3.0,
minor_length: float=1.5,
yticks:Union[List, None]=None,
yticks_str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def py_apply_ticks(self, plot):\n if self.x_ticks is not None:\n plot.set_xticks(self.x_ticks)\n if self.x_labels is not None:\n plot.set_xticklabels(self.x_labels)\n if self.y_ticks is not None:\n plot.set_yticks(self.y_ticks)\n if self.y_labels is not ... | [
"0.8227052",
"0.7511499",
"0.6852938",
"0.6852938",
"0.6852938",
"0.68470937",
"0.681978",
"0.67993045",
"0.6775618",
"0.6732604",
"0.67204344",
"0.6720418",
"0.6692094",
"0.66291505",
"0.6622836",
"0.66008484",
"0.65780103",
"0.65470105",
"0.6542259",
"0.645243",
"0.64437854... | 0.751157 | 1 |
Return the strings that should be placed next to ticks. This method is called when redrawing the axis and is a good method to override in subclasses. | def tickStrings(
values: Union[list, np.ndarray],
scale: float = 1,
spacing: Union[float, None] = None,
tickPlacesAdd: int = 1,
floatAdd: int = None,
) -> list:
# print ('tickplacesadd: ', tickPlacesAdd)
if spacing is None:
spacing = np.mean(np.diff(values))
places = tickPlac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_xticks_labels(self):\n xticks = np.arange(-1, self.space_between_glyphs * len(self.positions))\n xticklabels = [' ']\n for p in self.positions:\n xticklabels.append(str(p))\n xticklabels += [' '] * self.space_between_glyphs\n return xticks, xticklabels",
... | [
"0.78397",
"0.7624095",
"0.6501215",
"0.6492352",
"0.63792896",
"0.6331712",
"0.63057184",
"0.62749124",
"0.6262596",
"0.6200152",
"0.6151941",
"0.61433965",
"0.61407983",
"0.6114693",
"0.6090897",
"0.6063146",
"0.60558593",
"0.6042808",
"0.60372144",
"0.60286033",
"0.595644"... | 0.57986957 | 31 |
draw a reference line at a particular level of the data on the y axis returns the line object. | def referenceline(
axl: object,
reference: Union[float, None]=None,
limits: Union[float, None]=None,
color: float="0.33",
linestyle: str="--",
linewidth: float=0.5,
dashes: Union[str, None]=None,
):
axl = _ax_tolist(axl)
# if type(axl) is not list:
# axl = [axl]
if refer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yline(y,farright, width, dash, grayamount):\r\n aline([[0,y],[farright,y]],width, dash, grayamount)",
"def line(\n self, x: Hashable | None = None, y: Hashable | None = None, **kwargs\n ) -> PlotAccessor:\n return self(kind=\"line\", x=x, y=y, **kwargs)",
"def line(self, x, y):\n ... | [
"0.6597832",
"0.62690103",
"0.62548614",
"0.6254381",
"0.6121353",
"0.60698295",
"0.599574",
"0.59520334",
"0.5925594",
"0.5899377",
"0.5871035",
"0.5857244",
"0.58555025",
"0.5812753",
"0.5776932",
"0.5739642",
"0.5738931",
"0.57373977",
"0.5725293",
"0.5720802",
"0.56657374... | 0.6378374 | 1 |
Hide the figure grid in the figure | def hide_figure_grid(fig: object, grid: object) -> None:
grid.grid(False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cells_off(self):\n self.plotter.cells_off(self.ax)\n self.fig.canvas.draw()",
"def hide(self):\n self.geometry(\"%dx%d%+d%+d\" % (0, 0, 0, 0))",
"def delete_figure_grid(fig: object, grid: object) -> None:\n\n mpl.delete(grid)",
"def make_patch_spines_invisible(ax):\r\n ax.set_f... | [
"0.7047676",
"0.70297813",
"0.68988466",
"0.6796349",
"0.67299616",
"0.6620176",
"0.6612076",
"0.65799737",
"0.65392315",
"0.653496",
"0.64558256",
"0.6455507",
"0.6452754",
"0.6451081",
"0.64433354",
"0.6389912",
"0.63645524",
"0.6346707",
"0.63374066",
"0.6330263",
"0.63278... | 0.911055 | 0 |
Given two images containing pixel annotations, calculates agreement. If a substrate_idx is provided, calculates IoU over that substrate, otherwise calculates pixel accuracy | def calculate_agreement(pixel_image_1, pixel_image_2, substrate_idx=None):
intersection = ((pixel_image_1 == substrate_idx) *
(pixel_image_2 == substrate_idx)).sum()
union = ((pixel_image_1 == substrate_idx) +
(pixel_image_2 == substrate_idx)).sum()
# If there is no pixel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_iou_metrics_run(pixel_annotations_gt,\n pixel_annotations_participant):\n intersection_per_substrate = defaultdict(int)\n union_per_substrate = defaultdict(int)\n\n for image in tqdm.tqdm(pixel_annotations_gt.keys()):\n for substrate_name, substrate_idx in... | [
"0.6669386",
"0.60677356",
"0.5994295",
"0.59527326",
"0.59527326",
"0.57825994",
"0.57823753",
"0.5700432",
"0.5691588",
"0.5669964",
"0.565506",
"0.56381494",
"0.563136",
"0.5595641",
"0.5591643",
"0.5590119",
"0.55770004",
"0.5547028",
"0.554653",
"0.5519034",
"0.551428",
... | 0.79069084 | 0 |
Compute the density using the simplified EOS | def compute_rho(
T,
S,
z,
rn_lambda1=rn_lambda1,
rn_lambda2=rn_lambda2,
rn_a0=rn_a0,
rn_b0=rn_b0,
rn_mu1=rn_mu1,
rn_mu2=rn_mu2,
rn_nu=rn_nu,
):
Ta = T - T0
Sa = S - S0
rho = (
rho0
- rn_a0 * (1 + 0.5 * rn_lambda1 * Ta + rn_mu1 * z) * Ta
+ rn_b0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _density(self):\n fraction = np.array([0.]+[m.value for m in self.fraction])\n # TODO: handle invalid fractions using penalty functions\n # S = sum(fraction)\n # scale = S/100 if S > 100 else 1\n # fraction[0] = 100 - S/scale\n # penalty = scale - 1\n fraction[0... | [
"0.6899088",
"0.6735469",
"0.6676664",
"0.66023666",
"0.65880615",
"0.657711",
"0.6553591",
"0.6545843",
"0.6496512",
"0.649109",
"0.6488794",
"0.6464219",
"0.6453814",
"0.6435498",
"0.6394814",
"0.6392401",
"0.6388438",
"0.63717675",
"0.63460886",
"0.62834775",
"0.62756175",... | 0.0 | -1 |
Round a datetime object to any time lapse in seconds | def _round_time(dt=None, round_to=60):
if hasattr(dt, 'tzinfo'):
dt.replace(tzinfo=None)
diff = dt - dt.replace(hour=0, minute=0, second=0, microsecond=0)
seconds = diff.seconds
rounding = (seconds + round_to / 2) // round_to * round_to
return dt + datetime.timedelta(0, rounding-seconds, -dt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_time(time):\n t_min = time.minute % 5\n t_sec = time.second\n t_mic = time.microsecond\n time = time - timedelta(minutes=t_min, seconds=t_sec, microseconds=t_mic)\n return time",
"def round_time(dt=None, round_to=60):\n if dt == None : dt = datetime.now()\n seconds = (dt.replace(tzin... | [
"0.7319746",
"0.71368575",
"0.7098589",
"0.70558184",
"0.69927",
"0.69684905",
"0.6829757",
"0.6818082",
"0.68054426",
"0.66659987",
"0.6533629",
"0.63276696",
"0.6323017",
"0.63170487",
"0.6301285",
"0.6299775",
"0.6283563",
"0.622859",
"0.6186915",
"0.6161188",
"0.6160083",... | 0.71509767 | 1 |
Return the Django CMS page's url that this Entity has attached to it (or to its nearest parent) | def get_website_url(self):
if self.website:
return self.website.get_absolute_url()
elif self.external_url:
return self.external_url.url
elif self.parent:
# try
return self.parent.get_website_url()
else: # except
return defaul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n\n if self.redirect:\n return self.redirect\n\n if self == Page.tree.root_nodes()[0]:\n return reverse('ostinato_page_home')\n\n path = []\n for parent in self.get_ancestors():\n path.append(parent.slug)\n\n path.appen... | [
"0.7395588",
"0.73515296",
"0.70522416",
"0.70473766",
"0.7042088",
"0.7036055",
"0.7021756",
"0.701494",
"0.69864625",
"0.6944052",
"0.6916468",
"0.69100386",
"0.68751824",
"0.68729883",
"0.68711525",
"0.6868451",
"0.68536216",
"0.6846103",
"0.6841438",
"0.6805998",
"0.67978... | 0.6827559 | 19 |
Layers will be in the order they are first used. Use this method declare the order of all layers initially if that is more convenient. Example svg.declare_layers(["foo", "bar"]) svg["bar"].circle(...) svg["foo"].circle(...) | def declare_layers(self, names):
for name in names:
self[name]
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_layers(self):\n\n # get caching layers activated\n caching_layers = G3WCachingLayer.objects.all()\n for caching_layer in caching_layers:\n self.add_layer(str(caching_layer), caching_layer)",
"def _setLayer(items, layer):\n for i in items:\n i.setZValue(l... | [
"0.6521296",
"0.60912186",
"0.6073792",
"0.6043184",
"0.59845",
"0.59835064",
"0.5904451",
"0.5867343",
"0.5645457",
"0.5634773",
"0.5614134",
"0.5607074",
"0.55846554",
"0.55837303",
"0.55254525",
"0.5511223",
"0.5505191",
"0.54991955",
"0.54805404",
"0.5435835",
"0.5401328"... | 0.6691811 | 1 |
Yield successive tuples of slices defining patches of size `patch_size` from an array of dimensions `dims`. The iteration starts from position `start_pos` in the array, or starting at the origin if this isn't provided. Each patch is chosen in a contiguous grid using a first dimension as least significant ordering. | def iter_patch_slices(dims, patch_size, start_pos=()):
# ensure patchSize and startPos are the right length
ndim = len(dims)
patch_size = get_valid_patch_size(dims, patch_size)
start_pos = ensure_tuple_size(start_pos, ndim)
# collect the ranges to step over each dimension
ranges = tuple(starma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_patch_slices(\n image_size: Sequence[int],\n patch_size: Sequence[int] | int,\n start_pos: Sequence[int] = (),\n overlap: Sequence[float] | float = 0.0,\n padded: bool = True,\n) -> Generator[tuple[slice, ...], None, None]:\n\n # ensure patch_size has the right length\n patch_size_ = ... | [
"0.7605126",
"0.68866265",
"0.68019587",
"0.6716003",
"0.6668529",
"0.6636184",
"0.6457288",
"0.639002",
"0.63698727",
"0.6058741",
"0.5978948",
"0.596932",
"0.5887997",
"0.5831623",
"0.5824264",
"0.5628391",
"0.56025636",
"0.55978453",
"0.55938584",
"0.5566723",
"0.5549259",... | 0.84265006 | 0 |
Enumerate all slices defining 2D/3D patches of size `patch_size` from an `image_size` input image. | def dense_patch_slices(image_size, patch_size, scan_interval):
num_spatial_dims = len(image_size)
if num_spatial_dims not in (2, 3):
raise ValueError("image_size should has 2 or 3 elements")
patch_size = get_valid_patch_size(image_size, patch_size)
scan_interval = ensure_tuple_size(scan_interval... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_patch_slices(\n image_size: Sequence[int],\n patch_size: Sequence[int] | int,\n start_pos: Sequence[int] = (),\n overlap: Sequence[float] | float = 0.0,\n padded: bool = True,\n) -> Generator[tuple[slice, ...], None, None]:\n\n # ensure patch_size has the right length\n patch_size_ = ... | [
"0.74667376",
"0.7214571",
"0.6946546",
"0.67794037",
"0.66863877",
"0.6623078",
"0.6539736",
"0.6448639",
"0.6441259",
"0.6380542",
"0.6360427",
"0.6165405",
"0.61171037",
"0.6110804",
"0.60667384",
"0.6039885",
"0.5972813",
"0.59668595",
"0.5953215",
"0.5951258",
"0.5846345... | 0.74851185 | 0 |
Yield successive patches from `arr` of size `patch_size`. The iteration can start from position `start_pos` in `arr` but drawing from a padded array extended by the `patch_size` in each dimension (so these coordinates can be negative to start in the padded region). If `copy_back` is True the values from each patch are ... | def iter_patch(
arr: np.ndarray, patch_size, start_pos=(), copy_back: bool = True, mode: str = "wrap", **pad_opts,
):
# ensure patchSize and startPos are the right length
patch_size = get_valid_patch_size(arr.shape, patch_size)
start_pos = ensure_tuple_size(start_pos, arr.ndim)
# pad image by maxim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_patch(\n arr: NdarrayOrTensor,\n patch_size: Sequence[int] | int = 0,\n start_pos: Sequence[int] = (),\n overlap: Sequence[float] | float = 0.0,\n copy_back: bool = True,\n mode: str | None = NumpyPadMode.WRAP,\n **pad_opts: dict,\n) -> Generator[tuple[NdarrayOrTensor, np.ndarray], No... | [
"0.8052687",
"0.68469435",
"0.68047655",
"0.64481837",
"0.63350564",
"0.62117356",
"0.6032768",
"0.60040605",
"0.5822174",
"0.5779093",
"0.57770807",
"0.5759318",
"0.5751497",
"0.5708546",
"0.56990117",
"0.5604038",
"0.5602812",
"0.558997",
"0.5578437",
"0.5569295",
"0.555285... | 0.833687 | 0 |
Given an image of dimensions `dims`, return a patch size tuple taking the dimension from `patch_size` if this is not 0/None. Otherwise, or if `patch_size` is shorter than `dims`, the dimension from `dims` is taken. This ensures the returned patch size is within the bounds of `dims`. If `patch_size` is a single number t... | def get_valid_patch_size(dims, patch_size):
ndim = len(dims)
try:
# if a single value was given as patch size, treat this as the size of the patch over all dimensions
single_patch_size = int(patch_size)
patch_size = (single_patch_size,) * ndim
except TypeError: # raised if the patc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_valid_patch_size(image_size: Sequence[int], patch_size: Sequence[int] | int | np.ndarray) -> tuple[int, ...]:\n ndim = len(image_size)\n patch_size_ = ensure_tuple_size(patch_size, ndim)\n\n # ensure patch size dimensions are not larger than image dimension, if a dimension is None or 0 use whole d... | [
"0.70552206",
"0.6140606",
"0.6106958",
"0.6088183",
"0.57691526",
"0.5652423",
"0.55327773",
"0.5506837",
"0.54655063",
"0.5415204",
"0.5341019",
"0.52009356",
"0.5147486",
"0.5119845",
"0.5087839",
"0.50872743",
"0.50498927",
"0.50302655",
"0.49074468",
"0.49024823",
"0.488... | 0.7945127 | 0 |
To make column norm of `affine` the same as `scale`. If diagonal is False, returns an affine that combines orthogonal rotation and the new scale. This is done by first decomposing `affine`, then setting the zoom factors to `scale`, and composing a new affine; the shearing factors are removed. If diagonal is True, retur... | def zoom_affine(affine, scale, diagonal: bool = True):
affine = np.array(affine, dtype=float, copy=True)
if len(affine) != len(affine[0]):
raise ValueError("affine should be a square matrix")
scale = np.array(scale, dtype=float, copy=True)
if np.any(scale <= 0):
raise ValueError("scale m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom_affine(affine: np.ndarray, scale: np.ndarray | Sequence[float], diagonal: bool = True):\n\n affine = np.array(affine, dtype=float, copy=True)\n if len(affine) != len(affine[0]):\n raise ValueError(f\"affine must be n x n, got {len(affine)} x {len(affine[0])}.\")\n scale_np = np.array(scale... | [
"0.7194488",
"0.5994049",
"0.59912354",
"0.5915723",
"0.5384092",
"0.5365139",
"0.53525025",
"0.5346628",
"0.5248908",
"0.5242017",
"0.5241914",
"0.52233315",
"0.51467407",
"0.5132126",
"0.5115379",
"0.5028426",
"0.50227356",
"0.50128067",
"0.501081",
"0.50019133",
"0.4982473... | 0.7144264 | 1 |
Source path for the static document with missing file fallback. | def source_pod_path(self):
source_path = self.pod.path_format.format_static(
self.source_format, locale=self.locale)
# Fall back to the pod path if using locale and the localized
# version does not exist.
if self.use_locale and self.use_fallback and not self.pod.file_exists(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_path(self):\n path = self.config.get('static_dir')\n if path:\n return path\n for source_path in self.source_paths:\n if self.pod_path.startswith(source_path):\n return source_path\n # Default to the same index as the base source path for ... | [
"0.7844096",
"0.6985158",
"0.69540066",
"0.6874629",
"0.67333215",
"0.67305684",
"0.6673397",
"0.66175884",
"0.6610678",
"0.6584124",
"0.6580565",
"0.6478843",
"0.6329997",
"0.63059056",
"0.6305837",
"0.62678605",
"0.6242955",
"0.6191759",
"0.61828184",
"0.61820614",
"0.61753... | 0.69644463 | 2 |
Total seconds in the duration. | def total_seconds(self):
return (
(self.days * 86400 + self.seconds) * 10**6 + self.microseconds
) / 10**6 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_seconds(self):\n return 0",
"def duration_in_seconds(self):\n return self.get_data(\"duration_in_seconds\")",
"def seconds(self):\n end = self.end or timezone.now()\n result = end - self.start\n return result.seconds",
"def seconds(self):\n return self._sec... | [
"0.86587787",
"0.8130925",
"0.8093025",
"0.80003345",
"0.80003345",
"0.7957805",
"0.7933309",
"0.7810196",
"0.77947843",
"0.7788315",
"0.77819175",
"0.77526325",
"0.7730897",
"0.76528883",
"0.76338065",
"0.7621815",
"0.76131994",
"0.75891864",
"0.7588751",
"0.7588751",
"0.758... | 0.832391 | 1 |
Construct a date from a POSIX timestamp (like time.time()). | def fromtimestamp(cls, t):
y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t)
return cls(y, m, d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromtimestamp(cls, timestamp):\n return date()",
"def date_from(timestamp): \n return datetime.fromtimestamp(timestamp)",
"def _create_date(timestamp):\n mdate = matplotlib.dates.date2num(datetime.fromtimestamp(timestamp))\n return mdate",
"def timestamp_to_date(timestamp=None):\n if t... | [
"0.7942078",
"0.7566127",
"0.7346331",
"0.7313906",
"0.7031769",
"0.6900633",
"0.6759771",
"0.66030014",
"0.6595869",
"0.64605874",
"0.64407605",
"0.6329673",
"0.6324291",
"0.6314442",
"0.6277952",
"0.62235487",
"0.62194335",
"0.619535",
"0.61585677",
"0.6134754",
"0.6121105"... | 0.670045 | 7 |
Construct a date from a proleptic Gregorian ordinal. January 1 of year 1 is day 1. Only the year, month and day are nonzero in the result. | def fromordinal(cls, n):
y, m, d = _ord2ymd(n)
return cls(y, m, d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromordinal(cls, ordinal):\n return date()",
"def gregorian_date(year, julian_day):\n result = datetime.date(year, 1, 1)\n result += datetime.timedelta(days=julian_day - 1)\n return result",
"def from_ordinal(cls, ordinal: int) -> Date:\n return cls.fromordinal(ordinal)",
"def Date... | [
"0.68265814",
"0.67379045",
"0.60325325",
"0.5935473",
"0.59110737",
"0.5880265",
"0.58587164",
"0.5836866",
"0.58030343",
"0.57922894",
"0.57751685",
"0.57751065",
"0.57534164",
"0.5610511",
"0.5606185",
"0.5604394",
"0.55926335",
"0.5586711",
"0.55856985",
"0.5570371",
"0.5... | 0.51085943 | 63 |
Return the date formatted according to ISO. This is 'YYYYMMDD'. References | def isoformat(self):
return "%04d-%02d-%02d" % (self._year, self._month, self._day) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isoformat(self):\n s = '{0:04}'.format(self._year)\n if self._month:\n s += '-{0:02}'.format(self._month)\n if self._day:\n s += '-{0:02}'.format(self._day)\n return s",
"def iso_date(self):\n return self.strftime(self.FORMAT_PRECISION_DAY)",
... | [
"0.77984023",
"0.76661795",
"0.746209",
"0.70012194",
"0.6944533",
"0.6926987",
"0.68108386",
"0.6770215",
"0.67618424",
"0.6738082",
"0.6707987",
"0.6693457",
"0.6690283",
"0.6666362",
"0.6665504",
"0.66532874",
"0.66341037",
"0.65845925",
"0.6533149",
"0.6532402",
"0.649018... | 0.7877379 | 0 |
Return local time tuple compatible with time.localtime(). | def timetuple(self):
return _build_struct_time(self._year, self._month, self._day, 0, 0, 0, -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestampfromlocal(local):\n return local.timestamp()",
"def local_time():\n return datetime.datetime.now().isoformat()[:len('2017-01-24T10:44:00')]",
"def local_time(self) -> SmartNvmeLocalTime:\n return self._local_time",
"def timetuple(self):\n dst = self.dst()\n if dst is N... | [
"0.6868456",
"0.6759091",
"0.65390295",
"0.6408829",
"0.63834465",
"0.62887186",
"0.61896205",
"0.61795753",
"0.607105",
"0.60601085",
"0.6057456",
"0.5984415",
"0.5928824",
"0.59073496",
"0.5851447",
"0.5801418",
"0.5798117",
"0.579025",
"0.57557595",
"0.57342637",
"0.568197... | 0.5837053 | 15 |
Add a date to a timedelta. | def __add__(self, other):
if isinstance(other, real_timedelta):
o = self.toordinal() + other.days
if 0 < o <= _MAXORDINAL:
return date.fromordinal(o)
raise OverflowError("result out of range")
return NotImplemented | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(dt, days=0, seconds=0):\n return dt + datetime.timedelta(days=days, seconds=seconds)",
"def dayadd(date, numdays):\n return date + datetime.timedelta(days=numdays)",
"def DATEADD(start_date, days=0, months=0, years=0, weeks=0):\n return DATE(start_date.year + years, start_date.month + months... | [
"0.7117301",
"0.69542116",
"0.6441337",
"0.63574463",
"0.6329362",
"0.6204943",
"0.6188563",
"0.6146536",
"0.6090541",
"0.5954821",
"0.59144026",
"0.58906394",
"0.58857566",
"0.5845158",
"0.5799688",
"0.57790095",
"0.5754718",
"0.5746537",
"0.5703588",
"0.5583959",
"0.5534856... | 0.67089677 | 2 |
datetime > string name of time zone. | def tzname(self, dt):
raise NotImplementedError("tzinfo subclass must override tzname()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_zone_name(self):\n return icemac.addressbook.preferences.utils.get_time_zone_name()",
"def time_zone(self):\n # type: () -> string_types\n return self._time_zone",
"def time_zone():\n return timezone('Etc/GMT-10')",
"def time_zone(self) -> str:\n return pulumi.get(... | [
"0.7105962",
"0.7041414",
"0.7003352",
"0.69928",
"0.6902011",
"0.6801389",
"0.67753494",
"0.65253943",
"0.65072775",
"0.64584714",
"0.64381987",
"0.6407766",
"0.63468724",
"0.6344794",
"0.6329056",
"0.6229834",
"0.6158494",
"0.60979545",
"0.607531",
"0.6074766",
"0.60470253"... | 0.6104339 | 17 |
datetime > timedelta, positive for east of UTC, negative for west of UTC | def utcoffset(self, dt):
raise NotImplementedError("tzinfo subclass must override utcoffset()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_datetime(dt):\n return dt - datetime.timedelta(seconds=utc_offset)",
"def is_after(self, dt: datetime) -> bool:\n return self.target_time >= make_tz_aware(dt)",
"def is_in_the_future(dt):\n if dt > datetime.now(pytz.utc):\n return True\n return False",
"def test_datetime(self... | [
"0.6280276",
"0.62306535",
"0.6190972",
"0.6161588",
"0.61297816",
"0.6075623",
"0.6027141",
"0.60217035",
"0.5961634",
"0.5950339",
"0.5911102",
"0.5795746",
"0.5745029",
"0.5665904",
"0.5653349",
"0.565006",
"0.56416893",
"0.56246936",
"0.5614236",
"0.558975",
"0.5577295",
... | 0.0 | -1 |
datetime > DST offset as timedelta, positive for east of UTC. Return 0 if DST not in effect. utcoffset() must include the DST offset. | def dst(self, dt):
raise NotImplementedError("tzinfo subclass must override dst()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _local_time_offset():\n if time.localtime().tm_isdst and time.daylight:\n return -time.altzone\n else:\n return -time.timezone",
"def _get_utcoffset(self, tzname):\n # SQL Server has no built-in support for tz database\n # see http://blogs.msdn.com/b/sqlprogrammability/archi... | [
"0.6781972",
"0.65637696",
"0.6371492",
"0.63614273",
"0.635369",
"0.6341991",
"0.6338954",
"0.6217189",
"0.61945367",
"0.61535645",
"0.6119937",
"0.611382",
"0.6091785",
"0.5993934",
"0.5993787",
"0.59794426",
"0.595639",
"0.5945905",
"0.59220064",
"0.5755463",
"0.5681006",
... | 0.57366914 | 20 |
datetime in UTC > datetime in local time. | def fromutc(self, dt):
if not isinstance(dt, real_datetime):
raise TypeError("fromutc() requires a datetime argument")
if dt.tzinfo is not self:
raise ValueError("dt.tzinfo is not self")
dtoff = dt.utcoffset()
if dtoff is None:
raise ValueError("fromu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_datetime(dt):\n return dt - datetime.timedelta(seconds=utc_offset)",
"def datetime_from_utc_to_local(utc_datetime):\n now_timestamp = time.time()\n offset = datetime.fromtimestamp(now_timestamp) - datetime.utcfromtimestamp(now_timestamp)\n return utc_datetime + offset",
"def local_to_utc(... | [
"0.7222915",
"0.71106786",
"0.7003666",
"0.68234694",
"0.6767893",
"0.6763946",
"0.6753816",
"0.6749853",
"0.6681044",
"0.6662721",
"0.6610653",
"0.6511649",
"0.65026426",
"0.6498716",
"0.6488153",
"0.6449673",
"0.6439356",
"0.64143956",
"0.6378257",
"0.6378257",
"0.6378257",... | 0.0 | -1 |
Return the time formatted according to ISO. | def isoformat(self, timespec="auto"):
s = _format_time(
self._hour, self._minute, self._second, self._microsecond, timespec
)
tz = self._tzstr()
if tz:
s += tz
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iso_date(self, t=None):\n if t is None:\n t = time.time()\n time_str = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(t))\n\n return time_str",
"def timet_iso(t=time.time()):\n return datetime.datetime.now().isoformat()[0:19]",
"def ISO(self):\n return \"%.4d-... | [
"0.7798619",
"0.7565409",
"0.741238",
"0.7212931",
"0.72082263",
"0.7107972",
"0.70813596",
"0.70811695",
"0.70491254",
"0.696224",
"0.6916769",
"0.69164604",
"0.6907902",
"0.69023085",
"0.68958104",
"0.6894289",
"0.6883305",
"0.6821868",
"0.6804137",
"0.67717224",
"0.6728617... | 0.7143134 | 5 |
Return the timezone offset as timedelta, positive east of UTC (negative west of UTC). | def utcoffset(self):
if self._tzinfo is None:
return None
offset = self._tzinfo.utcoffset(None)
_check_utc_offset("utcoffset", offset)
return offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow()\n # XXX: `return -time.timezone`?\n return timedelta.total_seconds()",
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def get_tz_offset(self) -> float:\n return self.AD.tz.utcoffset(se... | [
"0.77070475",
"0.7264717",
"0.71097314",
"0.701621",
"0.6957274",
"0.6934106",
"0.6725874",
"0.67047375",
"0.6629715",
"0.64883184",
"0.63960767",
"0.63786894",
"0.624489",
"0.6116624",
"0.60631806",
"0.6032272",
"0.5977205",
"0.59698105",
"0.5927816",
"0.5925971",
"0.5921354... | 0.56652105 | 29 |
Return 0 if DST is not in effect, or the DST offset (as timedelta positive eastward) if DST is in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no need to consult dst() unless you're interested in displaying the DST info. | def dst(self):
if self._tzinfo is None:
return None
offset = self._tzinfo.dst(None)
_check_utc_offset("dst", offset)
return offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dst(self):\n if self._tzinfo is None:\n return None\n offset = self._tzinfo.dst(self._realized_if_concrete_tzinfo())\n _check_utc_offset(\"dst\", offset)\n return offset",
"def _local_time_offset():\n if time.localtime().tm_isdst and time.daylight:\n return -t... | [
"0.79034424",
"0.6852501",
"0.6627189",
"0.6487176",
"0.6445749",
"0.62509197",
"0.6102271",
"0.59712857",
"0.5833469",
"0.58159745",
"0.580037",
"0.5784196",
"0.57792485",
"0.5762912",
"0.5729294",
"0.5607387",
"0.5595929",
"0.559285",
"0.55924326",
"0.5586443",
"0.5575912",... | 0.7982787 | 0 |
Construct a UTC datetime from time.time(). | def utcnow(cls):
t = _time.time()
return cls.utcfromtimestamp(t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FromNowUTC(cls):\n t = pytime.time()\n utcTime = pytime.gmtime(t)\n return cls.FromStructTime(utcTime).WithZone(zDirection=0)",
"def utcTime():\r\n return calendar.timegm(time.gmtime())",
"def utcdatetime(self):\n utc = self.toZone('UTC')\n second = int(utc._second)\n ... | [
"0.72356766",
"0.6852686",
"0.684078",
"0.68388003",
"0.6772385",
"0.6708112",
"0.6695378",
"0.65758073",
"0.6472742",
"0.64718795",
"0.6450979",
"0.6445946",
"0.64225674",
"0.64049816",
"0.64049816",
"0.64049816",
"0.6388486",
"0.63750064",
"0.6366122",
"0.6355113",
"0.63551... | 0.70411646 | 1 |
Return local time tuple compatible with time.localtime(). | def timetuple(self):
dst = self.dst()
if dst is None:
dst = -1
elif dst:
dst = 1
else:
dst = 0
return _build_struct_time(
self.year, self.month, self.day, self.hour, self.minute, self.second, dst
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestampfromlocal(local):\n return local.timestamp()",
"def local_time():\n return datetime.datetime.now().isoformat()[:len('2017-01-24T10:44:00')]",
"def local_time(self) -> SmartNvmeLocalTime:\n return self._local_time",
"def local_datetime(rdd_tuple):\n timezone = rdd_tuple[0].split(\... | [
"0.6868456",
"0.6759091",
"0.65390295",
"0.63834465",
"0.62887186",
"0.61896205",
"0.61795753",
"0.607105",
"0.60601085",
"0.6057456",
"0.5984415",
"0.5928824",
"0.59073496",
"0.5851447",
"0.5837053",
"0.5801418",
"0.5798117",
"0.579025",
"0.57557595",
"0.57342637",
"0.568197... | 0.6408829 | 3 |
Return integer POSIX timestamp. | def _mktime(self):
epoch = datetime(1970, 1, 1)
max_fold_seconds = 24 * 3600
t = (self - epoch) // timedelta(0, 1)
def local(u):
y, m, d, hh, mm, ss = _time.localtime(u)[:6]
return (datetime(y, m, d, hh, mm, ss) - epoch) // timedelta(0, 1)
# Our goal is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_timestamp() -> int:\n\n return int(time.time() * 1000)",
"def timestamp():\n return int(time.time())",
"def get_timestamp():\n return int(time.time())",
"def get_timestamp():\n\n # Convert timestamp to int after multiply by 1000 to get millisecond timestamp in int.\n return int... | [
"0.8753553",
"0.8677451",
"0.8522794",
"0.8515965",
"0.84376234",
"0.7841757",
"0.78202295",
"0.7729608",
"0.76771694",
"0.76251274",
"0.7621465",
"0.76189464",
"0.7497464",
"0.7426284",
"0.7425352",
"0.7419928",
"0.740653",
"0.7405725",
"0.7387691",
"0.7354451",
"0.7330909",... | 0.0 | -1 |
Return POSIX timestamp as float | def timestamp(self):
if self._tzinfo is None:
s = self._mktime()
return s + self.microsecond / 1e6
else:
return (self - _EPOCH).total_seconds() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_to_float(t, epoch=None):\n if epoch is None:\n epoch = np.datetime64(0, \"s\")\n return (t - epoch) / np.timedelta64(1, \"s\")",
"def __time_to_float(time_value):\n return time_value.hour/24 + time_value.minute/(24*60) + time_value.second/(24*60*60) + round(time_value.microsecond... | [
"0.6992535",
"0.6878568",
"0.68192965",
"0.6736622",
"0.6731897",
"0.668916",
"0.6476074",
"0.6426588",
"0.6326478",
"0.6303143",
"0.62882674",
"0.6234106",
"0.621217",
"0.6149554",
"0.61409074",
"0.613869",
"0.608031",
"0.6065234",
"0.6041819",
"0.6016021",
"0.59996104",
"... | 0.6259493 | 11 |
Return the time part, with same tzinfo. | def timetz(self):
return time(
self.hour,
self.minute,
self.second,
self.microsecond,
self._tzinfo,
fold=self.fold,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time(self):\n return datetime.datetime.now(self.time_zone)",
"def __get_stock_time(stock_tz: timezone) -> datetime:\n return datetime.now().astimezone(stock_tz)",
"def get_time():\n\teastern = timezone('US/Eastern')\n\tnow = datetime.datetime.now(eastern).time()\n\treturn(now)",
"def get_time(o... | [
"0.6948679",
"0.6842157",
"0.66398674",
"0.65428716",
"0.6479562",
"0.6439625",
"0.64161605",
"0.64099103",
"0.63855416",
"0.63758206",
"0.62873507",
"0.62810874",
"0.62722397",
"0.62676567",
"0.625785",
"0.62470746",
"0.6242392",
"0.6237184",
"0.6237141",
"0.6221848",
"0.619... | 0.7869794 | 0 |
Return the time formatted according to ISO. | def isoformat(self, sep="T", timespec="auto"):
s = "%04d-%02d-%02d%c" % (
self._year,
self._month,
self._day,
sep,
) + _format_time(
self._hour, self._minute, self._second, self._microsecond, timespec
)
off = self.utcoffset()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iso_date(self, t=None):\n if t is None:\n t = time.time()\n time_str = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(t))\n\n return time_str",
"def timet_iso(t=time.time()):\n return datetime.datetime.now().isoformat()[0:19]",
"def ISO(self):\n return \"%.4d-... | [
"0.7798619",
"0.7565409",
"0.741238",
"0.7212931",
"0.72082263",
"0.7143134",
"0.7107972",
"0.70813596",
"0.70811695",
"0.70491254",
"0.696224",
"0.6916769",
"0.69164604",
"0.6907902",
"0.69023085",
"0.68958104",
"0.6894289",
"0.6883305",
"0.6804137",
"0.67717224",
"0.6728617... | 0.6821868 | 18 |
Return the timezone offset as timedelta positive east of UTC (negative west of UTC). | def utcoffset(self):
if self._tzinfo is None:
return None
offset = self._tzinfo.utcoffset(self._realized_if_concrete_tzinfo())
_check_utc_offset("utcoffset", offset)
return offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow()\n # XXX: `return -time.timezone`?\n return timedelta.total_seconds()",
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def _local_time_offset():\n if time.localtime().tm_isdst and time.dayl... | [
"0.7738117",
"0.72315204",
"0.7050119",
"0.7044904",
"0.6883803",
"0.68589586",
"0.6666285",
"0.66511524",
"0.65661156",
"0.6400021",
"0.6351908",
"0.63440007",
"0.6241571",
"0.6094988",
"0.60877",
"0.59931016",
"0.5970607",
"0.5962317",
"0.5954533",
"0.5915596",
"0.5906494",... | 0.58246714 | 22 |
Return 0 if DST is not in effect, or the DST offset (as timedelta positive eastward) if DST is in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no need to consult dst() unless you're interested in displaying the DST info. | def dst(self):
if self._tzinfo is None:
return None
offset = self._tzinfo.dst(self._realized_if_concrete_tzinfo())
_check_utc_offset("dst", offset)
return offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dst(self):\n if self._tzinfo is None:\n return None\n offset = self._tzinfo.dst(None)\n _check_utc_offset(\"dst\", offset)\n return offset",
"def _local_time_offset():\n if time.localtime().tm_isdst and time.daylight:\n return -time.altzone\n else:\n ... | [
"0.7982787",
"0.6852501",
"0.6627189",
"0.6487176",
"0.6445749",
"0.62509197",
"0.6102271",
"0.59712857",
"0.5833469",
"0.58159745",
"0.580037",
"0.5784196",
"0.57792485",
"0.5762912",
"0.5729294",
"0.5607387",
"0.5595929",
"0.559285",
"0.55924326",
"0.5586443",
"0.5575912",
... | 0.79034424 | 1 |
Plot of the FDataGrid samples by clusters. The clusters are calculated with the estimator passed as a parameter. If the estimator is not fitted, the fit method is called. Once each sample is assigned a label the plotting can be done. Each group is assigned a color described in a leglend. | def plot_clusters(estimator, X, chart=None, fig=None, axes=None,
n_rows=None, n_cols=None,
sample_labels=None, cluster_colors=None,
cluster_labels=None, center_colors=None,
center_labels=None,
center_width=3,
col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_clusters(estimator, fdata, *, chart=None, fig=None, axes=None,\n n_rows=None, n_cols=None,\n labels, sample_labels, cluster_colors, cluster_labels,\n center_colors, center_labels, center_width, colormap):\n fig, axes = _get_figure_and_axes(chart, f... | [
"0.7227393",
"0.7193735",
"0.71616477",
"0.70715195",
"0.7061236",
"0.69927675",
"0.6837134",
"0.67753047",
"0.6768641",
"0.67516124",
"0.6643371",
"0.6615665",
"0.6493218",
"0.64516",
"0.645055",
"0.64125025",
"0.636499",
"0.6300699",
"0.62987894",
"0.62667155",
"0.6257936",... | 0.7258416 | 0 |
Returns a random pair of leggings. | def randomLeggings():
return random.choice(LEGGINGS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_pair(self):\n\t\treturn random.sample(self.pictures.keys(), 2)",
"def _generate_random_agent(self):\n\n new_random_agent = list(self._all_waypoints)\n random.shuffle(new_random_agent)\n return tuple(new_random_agent)",
"def randomHelmet():\n return random.choice(HELMETS)"... | [
"0.67189395",
"0.6582839",
"0.61662394",
"0.61259276",
"0.6118828",
"0.6111193",
"0.609139",
"0.6082798",
"0.6071782",
"0.606003",
"0.60313797",
"0.60286945",
"0.5967144",
"0.59549415",
"0.59342325",
"0.59293985",
"0.5926842",
"0.59146374",
"0.5899798",
"0.5891182",
"0.588721... | 0.80405426 | 0 |
Check if valid stock item(s) have been provided. | def get(self, request, *args, **kwargs):
items = self.get_items()
if len(items) == 0:
# No valid items provided, return an error message
data = {
'error': _('Must provide valid StockItem(s)'),
}
return Response(data, status=400)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_inputs(self, item_data):\n if not item_data[0] in self.data['pizza']:\n print('Error: ' + item_data[0] + ' pizza does not exist.')\n return False\n\n if not item_data[1] in self.data['pizza'][item_data[0]]:\n print('Error: ' + item_data[1] + ' size does not ... | [
"0.69188875",
"0.67410445",
"0.67389095",
"0.6624274",
"0.65152407",
"0.63841784",
"0.63737553",
"0.6335458",
"0.62852734",
"0.6227092",
"0.61819965",
"0.6163342",
"0.6136819",
"0.61161315",
"0.60862064",
"0.60234684",
"0.6001421",
"0.5985206",
"0.5957052",
"0.5911877",
"0.59... | 0.0 | -1 |
Creates a classification model. | def create_model(is_predicting, input_ids, input_mask, segment_ids, vocab, vocab_size, bert_config, use_one_hot_embeddings):
# bert_module = hub.Module(
# BERT_MODEL_HUB,
# trainable=True)
# bert_inputs = dict(
# input_ids=input_ids,
# input_mask=input_mask,
# segme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model(self):\n self.classifier = DecisionTreeClassifier(max_depth=1)",
"def create_model(self, C : float =1):\n self.classifier = RandomForestClassifier(max_depth=5)",
"def create_model():\n\n # Create a sequential model (a simple NN is created) adding a softmax activation at the en... | [
"0.7451048",
"0.716728",
"0.70753753",
"0.69427526",
"0.69337225",
"0.69306064",
"0.6929345",
"0.68631464",
"0.68004555",
"0.6769279",
"0.6737084",
"0.66838384",
"0.66709864",
"0.660953",
"0.65912193",
"0.6564333",
"0.6534873",
"0.6526978",
"0.6525293",
"0.6521778",
"0.651739... | 0.0 | -1 |
Calculate how much penguins has the close enemies icebergs. | def __calc_penguins_of_close_iceberg_and_max_distance(self, iceberg):
ours_avg_distance, enemy_avg_distance = self.__simulation_data.get_avg_distance_from_players(iceberg)
if ours_avg_distance <= 0:
max_distance_to_check = MIN_DISTANCE_TO_CHECK
else:
max_distance_to_check... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __calc_penguins_to_send_for_support(self, source_iceberg):\n if type(source_iceberg) == Iceberg:\n penguins_per_turn = source_iceberg.penguins_per_turn\n penguin_amount_to_send = source_iceberg.penguin_amount\n else:\n penguins_per_turn = 0\n penguin_am... | [
"0.6231481",
"0.614905",
"0.6140536",
"0.59368527",
"0.58718663",
"0.580957",
"0.57884294",
"0.5750335",
"0.5749767",
"0.5741155",
"0.5721059",
"0.57177645",
"0.57042515",
"0.57033217",
"0.5639478",
"0.5622435",
"0.55887794",
"0.55817956",
"0.5577311",
"0.55672836",
"0.555027... | 0.7253487 | 0 |
Gets coordinates of the device location. Returns None if not provided or not accessible. | def get_address_coordinates_from_geolocation(mycity_request) -> dict:
user_address = None
if mycity_request.device_has_geolocation:
if mycity_request.geolocation_permission:
user_address = location_services_utils.convert_mycity_coordinates_to_arcgis(mycity_request)
return user_address | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_coordinates(self):\n try:\n return self.__data['coordinates']['Guest Entrance']['gps']\n except:\n return None",
"def get_location(self) -> tuple:\r\n if self.data is None:\r\n return (None, None)\r\n \r\n lat = self.data['GPSInfo']['GPS... | [
"0.7508627",
"0.6993387",
"0.69858235",
"0.69332206",
"0.6818274",
"0.67915535",
"0.6666421",
"0.6622221",
"0.6619786",
"0.6588545",
"0.6551099",
"0.64797306",
"0.6463064",
"0.63817817",
"0.6357216",
"0.63539475",
"0.63466513",
"0.63341695",
"0.6323071",
"0.63205975",
"0.6317... | 0.0 | -1 |
Copy the key/value pairs from another dictionary into this dictionary, overwriting any conflicting keys in this dictionary. | def update(self, other_dict=None, **f):
changed = False
if other_dict:
for (key, value) in other_dict.items() if hasattr(other_dict, 'items') else other_dict:
self.__setitem__(key, value, bulk_change=True)
changed = True
if f:
for (key, val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _merge(self, other: dict):\n self._storage = dict_merge(self._storage, other)",
"def override_dict_values(d1, d2):\n new = d1.copy()\n for k, v in d2.items():\n if isinstance(v, dict):\n new[k] = override_dict_values(new[k], d2[k])\n else:\n new[k] = v\n\n ... | [
"0.7387048",
"0.725533",
"0.7231954",
"0.7143269",
"0.68870693",
"0.6875816",
"0.6836898",
"0.6824049",
"0.6775912",
"0.6767146",
"0.67609125",
"0.6621395",
"0.65873575",
"0.65868723",
"0.65814626",
"0.6577281",
"0.6561855",
"0.6552224",
"0.65510833",
"0.6537261",
"0.65338963... | 0.0 | -1 |
Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x). | def insert(self, index, value):
if self._can_insert(index, value):
list.insert(self, index, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, index, item):\n if index > len(self):\n raise IndexError\n elif index == 0:\n self.insert_first(item)\n else:\n self._rest.insert(index-1, item)",
"def insert(self, index, item):\n # type: (int, Any) -> None\n return list.insert... | [
"0.73122674",
"0.7141766",
"0.70961785",
"0.69323033",
"0.6796972",
"0.6772682",
"0.67552716",
"0.6693691",
"0.66368234",
"0.6631376",
"0.66176337",
"0.6608958",
"0.6574597",
"0.6526233",
"0.65096164",
"0.6490155",
"0.64883775",
"0.64796865",
"0.6478901",
"0.64654714",
"0.645... | 0.68982285 | 4 |
Convert object to list. It is already list returns self | def to_list(obj, list_cls=list):
if obj is None:
return list_cls()
if isinstance(obj, list_cls):
return obj
if isinstance(obj, (unicode, str)):
return list_cls((obj,))
if isinstance(obj, (list, tuple, set, frozenset)) or hasattr(obj, '__iter__'):
return list_cls(obj)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_list(obj):\n if not isinstance(obj, list):\n return [obj]\n else:\n return obj",
"def as_list(obj):\n return obj if isinstance(obj, list) else [obj]",
"def coerce_to_list(obj) -> list:\n if obj is None:\n return []\n elif isinstance(obj, list):\n return obj\n ... | [
"0.83325016",
"0.774703",
"0.7554239",
"0.7535699",
"0.741788",
"0.7379035",
"0.7334636",
"0.7334633",
"0.7331051",
"0.72984946",
"0.72504807",
"0.72303146",
"0.7209674",
"0.7114596",
"0.7088114",
"0.7071589",
"0.7036857",
"0.6952685",
"0.694317",
"0.6926797",
"0.69040835",
... | 0.7347454 | 6 |
Checks if string s has valid syntax for horizontal tree. | def syntaxValid(s):
if not s or type(s) != str or s[0] != '[':
return False
#using stack to check for matching brackets
#push '[' and pop for ']'
bracketStack = []
for i in range(len(s)):
currentChar = s[i]
if currentChar == '[':
#check for there is a delimiter before open bracket or trying to double nes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printAsHorizontalTree(s):\n\tERROR_MSG = \"Invalid!\"\n\tif syntaxValid(s):\n\t\tprint(getHorizontalTreeString(s))\n\telse:\n\t\tprint(ERROR_MSG)",
"def isValid(self, s: str) -> bool:\n stack = []\n \n mapping = {\n \")\":\"(\",\n \"}\":\"{\",\n \"]\":\"[\"\n }\n \n for... | [
"0.7046031",
"0.68810767",
"0.6779586",
"0.6649023",
"0.63603646",
"0.63461107",
"0.62871104",
"0.6232321",
"0.60503346",
"0.5967644",
"0.596626",
"0.5931016",
"0.59306395",
"0.5847726",
"0.5763241",
"0.5696815",
"0.56707615",
"0.563801",
"0.5547333",
"0.5531735",
"0.5531246"... | 0.6466785 | 4 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(self, output, target):
with torch.no_grad():
# maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(k=1, dim=1, largest=True, sorted=True) # sorted:返回的结果按照顺序返回
# 指明是得到前k个数据以及其index; 指定在dim个维度上排序, 默认是最后一个维度;
# largest:如果为Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.8331214",
"0.8284662",
"0.82381004",
"0.8229767",
"0.82202226",
"0.81864446",
"0.81847763",
"0.8175173",
"0.8171541",
"0.81699467",
"0.81664646",
"0.81645083",
"0.81637454",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"... | 0.0 | -1 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(self, optimizer, epoch, args):
lr = args.learning_rate * (0.1 ** (epoch // 30))
# print(lr)
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.7911784",
"0.79050946",
"0.78485286",
"0.77735764",
"0.7732469",
"0.7730158",
"0.77215046",
"0.7720291",
"0.7707188",
"0.76916134",
"0.7672935",
"0.7663783",
"0.7663783",
"0.7663783",
"0.7653085",
"0.76401496",
"0.7637848",
"0.76358664",
"0.7624403",
"0.76229596",
"0.76195... | 0.77176815 | 8 |
Return the percentage of similitude between results and reality. | def cross_validation_results(results, reality):
length = len(results)
if length != len(reality):
return 0
sim = 0
for i in range(length):
if results[i] == reality[i]:
sim += 1
return 100*sim/length | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_real_percent(self):\n if not (self.votes and self.score):\n return 0\n return 100 * (self.get_real_rating() / self.field.range)",
"def information_ratio(returns, factor_returns):\n active_return = returns - factor_returns\n tracking_error = np.std(active_return, ddof=1)\n ... | [
"0.6748519",
"0.6599777",
"0.6563543",
"0.6536272",
"0.6477461",
"0.64762145",
"0.64625",
"0.6444886",
"0.643034",
"0.64172226",
"0.6355888",
"0.6320645",
"0.6307949",
"0.6297327",
"0.6256581",
"0.6222313",
"0.6211672",
"0.61806935",
"0.6169909",
"0.61523825",
"0.6140885",
... | 0.69330865 | 0 |
Give the first following peak after a point on one signal. | def get_following_peak(ind_spike, sig, sign):
sig1 = sig[:-2]
sig2 = sig[1:-1]
sig3 = sig[2:]
if sign == '+':
all_peaks, = np.where(numexpr.evaluate( '(sig1<=sig2) & ( sig2>sig3)'))
elif sign == '-':
all_peaks, = np.where(numexpr.evaluate( '(sig1>=sig2) & ( sig2<sig3)'))
ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak(self):\n pass",
"def peak(self) -> Point:\n return self.most_intense_point()",
"def first_peak_detect(beam, start_point):\n logging.debug('running first_peak_detect function')\n for i in range(start_point, len(beam)):\n logging.debug('current value of i is %d', i)\n i... | [
"0.71856356",
"0.7005908",
"0.69553566",
"0.690424",
"0.6754664",
"0.6728453",
"0.66947204",
"0.6598065",
"0.6530342",
"0.65045017",
"0.6425302",
"0.6304055",
"0.6237729",
"0.62373376",
"0.6197878",
"0.61924434",
"0.61449325",
"0.6085978",
"0.60394716",
"0.60376275",
"0.60313... | 0.65125316 | 9 |
Create the filename for the image | def generate_image_filename():
now = datetime.now().strftime('%a-%w-%b-%H:%M:%S')
return 'CCTV_{0}.jpg'.format(now) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file_name(self):\n # create a unique id for the file name\n index = self.helpers.alpha_uuid()\n\n filename = self.form['FieldStorage'][self.image_cid].filename\n extension = guess_extension(guess_type(filename)[0])\n return ( # concatenates the following data\n ... | [
"0.8076618",
"0.76982325",
"0.76669437",
"0.7609989",
"0.75951207",
"0.7572182",
"0.75527716",
"0.750989",
"0.7491719",
"0.74731326",
"0.7446953",
"0.74074036",
"0.7378294",
"0.7242009",
"0.72108406",
"0.70437557",
"0.7012552",
"0.69422007",
"0.69396174",
"0.69069815",
"0.690... | 0.8175233 | 0 |
Return length of the dataset. | def __len__(self) -> int:
return len(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return self._dataset.size(dirs=self._dirs)",
"def length(self) -> int:\n return len(self.data)",
"def __len__(self):\n return len(self.dataset)",
"def length(self):\n return len(self.data)",
"def length(self):\n return len(self.data)",
"def length(s... | [
"0.8409464",
"0.83180475",
"0.82663137",
"0.824963",
"0.824963",
"0.824963",
"0.8217461",
"0.8198147",
"0.8185409",
"0.8185409",
"0.8185409",
"0.8185409",
"0.81721336",
"0.8160378",
"0.8118708",
"0.8085709",
"0.80830795",
"0.8074432",
"0.80703044",
"0.80674833",
"0.80621445",... | 0.8011856 | 24 |
Save articles into JSON files. | def save_articles(self, articles):
for article in articles:
with open(
f'{self.data_folder}/articles/{article.get("id")}.json',
'w'
) as f:
json.dump(article, f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_json_file(article_data, dir_path):\n current_date = str(datetime.now().date())\n output_path = os.path.join(dir_path, current_date)\n os.makedirs(output_path, exist_ok=True)\n filepath = os.path.join(output_path, article_data['source'] + '.json')\n if not os.path.isfile(filepath):\n ... | [
"0.7155873",
"0.68222743",
"0.6810558",
"0.6680842",
"0.66180253",
"0.65919954",
"0.6574795",
"0.64991677",
"0.64795566",
"0.64482945",
"0.64417255",
"0.64391255",
"0.643686",
"0.64252853",
"0.6394636",
"0.6382291",
"0.63592774",
"0.63583505",
"0.63538396",
"0.6322471",
"0.63... | 0.86986554 | 0 |
Get entity annotations from Monant platform and save them to JSON files. | def save_annotations(self):
r = requests.get(
f'{self.api_host}/v1/entity-annotations?'
f'annotation_type=Source reliability (binary)&size=100',
headers=self.get_request_headers()
)
entity_annotations = r.json().get('entity_annotations')
for annotati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_annotations(data_folder):\n annotations_files = os.listdir('data_annotations')\n\n annotations = {}\n for file_name in annotations_files:\n annotation = json.load(\n open(f'{data_folder}/annotations/{file_name}', 'r')\n )\n key = int(annotation['entity_id'])\n ... | [
"0.6310822",
"0.6286099",
"0.6221531",
"0.61979747",
"0.6150533",
"0.6126273",
"0.6080921",
"0.5874297",
"0.5868495",
"0.58176434",
"0.5812265",
"0.58055127",
"0.5801545",
"0.5789865",
"0.5761264",
"0.5742751",
"0.5688504",
"0.56479406",
"0.5638197",
"0.56217295",
"0.5555076"... | 0.7949725 | 0 |
Limit samples to greater than the sequence length and fewer than N frames. Also limit it to classes we want to use. | def clean_data(self):
data_clean = []
for item in self.data:
if int(item[2]) >= self.seq_length and int(item[2]) <= self.max_frames:# and item[1] in self.classes:
data_clean.append(item)
return data_clean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_samples(chain_length):\n return min(chain_length / 10, MAX_GEN_DISCARD)",
"def reduce_sample_size(data,classes,times=2):\n data=data[range(0,data.shape[0],times)]\n classes=classes[range(0,classes.shape[0],times)]\n return data,classes",
"def __init__(self, seq_length=80, class_limit=No... | [
"0.5833286",
"0.5667921",
"0.55643165",
"0.55641323",
"0.55286056",
"0.55219245",
"0.5458092",
"0.5436224",
"0.53909874",
"0.5367901",
"0.53218985",
"0.53218985",
"0.53218985",
"0.53218985",
"0.5288281",
"0.5247768",
"0.5238297",
"0.52160585",
"0.52108985",
"0.5150198",
"0.51... | 0.47116217 | 91 |
Given a list and a size, return a rescaled/samples list. For example, if we want a list of size 5 and we have a list of size 25, return a new list of size five which is every 5th element of the origina list. | def rescale_list(input_list, size):
assert len(input_list) >= size
# Get the number to skip between iterations.
skip = len(input_list) // size
# Build our new output.
output = [input_list[i] for i in range(0, len(input_list), skip)]
# Cut off the last one if needed.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shorten_list(original: np.ndarray, size: int) -> np.ndarray:\r\n # Compute the size of the window for the averaged elements\r\n window_size = math.ceil(len(original) / size)\r\n # Compute the trimmed length so that the list can be reshaped correctly\r\n rounded_len = window_size * math.floor(len(or... | [
"0.7207605",
"0.6805966",
"0.6706896",
"0.653218",
"0.6509618",
"0.64563954",
"0.63008064",
"0.6258255",
"0.6111745",
"0.6111509",
"0.6109494",
"0.61063105",
"0.6097677",
"0.608714",
"0.6029441",
"0.6018637",
"0.5989179",
"0.59677154",
"0.5945093",
"0.59402585",
"0.590469",
... | 0.80564153 | 0 |
Check to see if we created the 0001 frame of this file. | def check_already_extracted(video_parts):
train_or_test, filename_no_ext, _ = video_parts
return bool(os.path.exists(os.path.join('demo_frames',
filename_no_ext + '-0001.jpg'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_frame(self):\n first_byte_as_bits = bin(int(self.packet_body[self.reader], base=16))[2:].zfill(8)\n return first_byte_as_bits[0:3] == \"001\"",
"def check_encoder(self):\n file = Path(self.get_encoder_path() + \".data-00000-of-00001\")\n\n return file.exists()",
"def hasCurre... | [
"0.6845341",
"0.6385996",
"0.62448496",
"0.6057301",
"0.5787386",
"0.57349885",
"0.57237864",
"0.56976765",
"0.56358933",
"0.5621559",
"0.559981",
"0.55927694",
"0.5521344",
"0.550883",
"0.5489131",
"0.5481525",
"0.54558146",
"0.5454623",
"0.54435945",
"0.54361707",
"0.542268... | 0.58535653 | 4 |
Returns the Euclidean Distance between a pair of objects. Function is used during parallelization. | def l2_simple(objects_list, index_pair):
return numpy.sum((objects_list[index_pair[0]] - objects_list[index_pair[1]])**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(x, y):\n return sqrt(sum(pow(a - b, 2) for a, b in zip(x, y)))",
"def euclidDist(pair1,pair2):\n return ((pair1[0]-pair2[0])**2+(pair1[1]-pair2[1])**2)**0.5",
"def _object_distance(self, object1, object2):\n return np.linalg.norm(np.array(object1) - np.array(object2))",
"d... | [
"0.7447262",
"0.7350513",
"0.73296595",
"0.73179066",
"0.730077",
"0.7266704",
"0.7238701",
"0.7188232",
"0.71286017",
"0.7123436",
"0.7119737",
"0.71051663",
"0.70892656",
"0.7031163",
"0.7024691",
"0.7018128",
"0.70100087",
"0.70067424",
"0.69784427",
"0.6969641",
"0.696342... | 0.0 | -1 |
Returns the Earth Mover Distance between a pair of objects. Function is used during parallelization. | def emd_simple_1D(grid, objects_list, index_pair):
return wasserstein_distance(grid, grid, u_weights=objects_list[index_pair[0]], v_weights=objects_list[index_pair[1]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _object_distance(self, object1, object2):\n return np.linalg.norm(np.array(object1) - np.array(object2))",
"def obj_distance(obj1, obj2):\n distance = aversine(obj1.details['lon'], obj1.details['lat'], obj2.details['lon'], obj2.details['lat'])\n return distance",
"def _computeDistance(self, mo... | [
"0.6140589",
"0.6113229",
"0.59033144",
"0.59033144",
"0.5900714",
"0.5888907",
"0.5857976",
"0.5745408",
"0.57076067",
"0.56939185",
"0.567923",
"0.56577253",
"0.5649809",
"0.5632931",
"0.5630739",
"0.5612005",
"0.5595232",
"0.5572394",
"0.5571492",
"0.55671525",
"0.5566166"... | 0.5214664 | 96 |
Returns the Earth Mover Distance between a pair of objects. Function is used during parallelization. | def emd_simple_2D(grid, objects_list, index_pair):
obj_i = objects_list[index_pair[0]]
obj_j = objects_list[index_pair[1]]
X = numpy.column_stack(numpy.nonzero(obj_i))
Y = numpy.column_stack(numpy.nonzero(obj_j))
X_w = obj_i[numpy.nonzero(obj_i)]
Y_w = obj_j[numpy.nonzero(obj_j)]
return em... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _object_distance(self, object1, object2):\n return np.linalg.norm(np.array(object1) - np.array(object2))",
"def obj_distance(obj1, obj2):\n distance = aversine(obj1.details['lon'], obj1.details['lat'], obj2.details['lon'], obj2.details['lat'])\n return distance",
"def _computeDistance(self, mo... | [
"0.6140828",
"0.6114125",
"0.59009343",
"0.59009343",
"0.5899646",
"0.5887343",
"0.58584136",
"0.57448024",
"0.57067776",
"0.5693578",
"0.56800014",
"0.56561565",
"0.5649594",
"0.5632582",
"0.5628515",
"0.5611888",
"0.55951047",
"0.5572395",
"0.5571489",
"0.55674255",
"0.5565... | 0.0 | -1 |
Returns the Earth Mover Distance between a pair of objects. Function is used during parallelization. | def energy_simple_1D(grid, objects_list, index_pair):
return energy_distance(grid, grid, u_weights=objects_list[index_pair[0]], v_weights=objects_list[index_pair[1]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _object_distance(self, object1, object2):\n return np.linalg.norm(np.array(object1) - np.array(object2))",
"def obj_distance(obj1, obj2):\n distance = aversine(obj1.details['lon'], obj1.details['lat'], obj2.details['lon'], obj2.details['lat'])\n return distance",
"def _computeDistance(self, mo... | [
"0.6140828",
"0.6114125",
"0.59009343",
"0.59009343",
"0.5899646",
"0.5887343",
"0.58584136",
"0.57448024",
"0.57067776",
"0.5693578",
"0.56800014",
"0.56561565",
"0.5649594",
"0.5632582",
"0.5628515",
"0.5611888",
"0.55951047",
"0.5572395",
"0.5571489",
"0.55674255",
"0.5565... | 0.0 | -1 |
Returns the initialized dataframe Returns pandas Dataframe initialized dataframe | def get_df(self):
try:
return self.df_input
except Exception as e:
print(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_frame_creator(self):\n\n return pd.DataFrame()",
"def dataframe(self):\n\n if self._dataframe is None:\n try:\n import pandas as pd\n except ImportError:\n raise RuntimeError('To enable dataframe support, '\n ... | [
"0.8237481",
"0.7771796",
"0.76089174",
"0.7549396",
"0.7528971",
"0.75231546",
"0.7477045",
"0.7453425",
"0.7445679",
"0.7369251",
"0.7317071",
"0.7295593",
"0.72757655",
"0.7230049",
"0.72181886",
"0.7208909",
"0.7134565",
"0.71017146",
"0.70900786",
"0.70872957",
"0.707599... | 0.0 | -1 |
Returns the calculated intercept of the polynomial regression | def get_poly_intercept(self, independent, dependent):
try:
x = self.df_input[[independent]]
y = self.df_input[[dependent]]
poly = PolynomialFeatures(degree = 2)
x_poly = poly.fit_transform(x)
model = LinearRegression()
model.fit(x_pol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intercept_(self):\n return self.regression.intercept_",
"def get_poly_coeff(self, independent, dependent):\n\n try:\n x = self.df_input[[independent]]\n y = self.df_input[[dependent]]\n\n poly = PolynomialFeatures(degree = 2)\n x_poly = poly.fit_trans... | [
"0.7419375",
"0.7269656",
"0.700004",
"0.665531",
"0.66219336",
"0.6617497",
"0.65746427",
"0.6553796",
"0.65420437",
"0.6540526",
"0.65344995",
"0.65324485",
"0.65271163",
"0.65270245",
"0.6526316",
"0.6439887",
"0.643661",
"0.6433109",
"0.64183915",
"0.6406595",
"0.6376373"... | 0.80430543 | 0 |
Test the name property. | def testName(self):
path_spec = path_spec_factory.Factory.NewPathSpec(
definitions.TYPE_INDICATOR_CS, parent=self._gpt_path_spec,
volume_index=0)
file_entry = self._file_system.GetFileEntryByPathSpec(path_spec)
self.assertIsNotNone(file_entry)
self.assertEqual(file_entry.name, 'cs1') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name(self):\n self.assertTrue(type(x.name) == str)",
"def test_name_property(self):\n v1 = versions.Version(version='1.2.3', name='foo')\n expected = 'foo'\n\n self.assertEqual(v1.name, expected)",
"def testName(self):\n dis_meta = DiseaseMeta()\n\n self.util.... | [
"0.7994545",
"0.7621826",
"0.7574307",
"0.75134736",
"0.75109535",
"0.741161",
"0.7379381",
"0.7315784",
"0.7302214",
"0.7277098",
"0.72736675",
"0.7271381",
"0.7256727",
"0.7250427",
"0.72418636",
"0.7220323",
"0.7208508",
"0.7182417",
"0.7174923",
"0.7158955",
"0.7103506",
... | 0.0 | -1 |
Returns the name of the type of body this is. | def p(self):
return 'Plane' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_name(self):\n return self._type_name",
"def type_name(self) -> Optional[str]:\n return pulumi.get(self, \"type_name\")",
"def type_name(self):\n return self.TYPE_NAMES[self.type]",
"def name(self) -> str:\n return self.type_data.name",
"def type_name(self) -> pulumi.Output[... | [
"0.72072667",
"0.72031623",
"0.71060884",
"0.7103304",
"0.7073736",
"0.70535296",
"0.7043681",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",
"0.6824264",... | 0.0 | -1 |
Returns normal vector of body at given point. | def normal(self, point):
return self._normal.dup() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_at(self, world_point: Point) -> Vector:\n # Convert the world point and normal to shape space\n local_point = self.world_to_object(world_point)\n # Calculate the normal in shape space\n local_normal = self.local_normal_at(local_point)\n # Convert the local normal vecto... | [
"0.79505223",
"0.78277105",
"0.75717294",
"0.75153327",
"0.7366493",
"0.7349096",
"0.73231417",
"0.7306383",
"0.7291598",
"0.7282756",
"0.7231979",
"0.710991",
"0.70887834",
"0.70513093",
"0.701303",
"0.6995466",
"0.699226",
"0.6950905",
"0.68633443",
"0.6798702",
"0.6663207"... | 0.76340336 | 2 |
Returns positive distance to target (or negative if no hit). | def intersection(self, ray):
d_proj = self._normal.dot(ray.d)
if abs(d_proj) < bounds.too_small:
return -1.0
s_proj = (self._origin - ray.o).dot(self._normal)
if d_proj * s_proj < 0.0:
# ray going away from plane
return -1.0
else:
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to_target(self):\n\n return Vector.distance(self.position, self.target_position)",
"def GetDistanceFromTarget(self):\n return abs(int(self.position[0] - self.target_position[0])) + abs(int(self.position[1] - self.target_position[1]))",
"def distance_to(self, target_pos):\n v =... | [
"0.78525376",
"0.77088195",
"0.7459229",
"0.7453839",
"0.6987158",
"0.690894",
"0.68732536",
"0.6871685",
"0.6828911",
"0.67403746",
"0.6696794",
"0.6663096",
"0.64520615",
"0.64108807",
"0.6353254",
"0.63351756",
"0.62974954",
"0.6284827",
"0.62818664",
"0.6273209",
"0.62298... | 0.0 | -1 |
acq = QubicAcquisition(instrument, sampling, scene, d) | def __init__(self, instrument, sampling, scene, d):
block = d['block']
effective_duration = d['effective_duration']
photon_noise = d['photon_noise']
max_nbytes = d['max_nbytes']
nprocs_instrument = d['nprocs_instrument']
nprocs_sampling = d['nprocs_sampling']
comm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, multiinstrument, sampling, scene, d):\n\n weights = d['weights']\n\n self.warnings(d)\n\n if d['MultiBand'] and d['nf_sub']>1:\n self.subacqs = [QubicAcquisition(multiinstrument[i],\n sampling, scene, d)\n ... | [
"0.73421264",
"0.70766366",
"0.7023857",
"0.61177397",
"0.6046371",
"0.5981141",
"0.591843",
"0.5774393",
"0.5670127",
"0.5631059",
"0.56212586",
"0.5617507",
"0.56167495",
"0.55850184",
"0.557392",
"0.5543862",
"0.5516496",
"0.54935575",
"0.5493272",
"0.5492852",
"0.54911435... | 0.7179647 | 1 |
Return the operator for the bolometer responses. | def get_detector_response_operator(self):
return BlockDiagonalOperator(
[self.instrument.get_detector_response_operator(self.sampling[b])
for b in self.block], axisin=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operator(self) -> str:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> str:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> Optional[str]:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> Optional[str]:\n return pulumi.get(self... | [
"0.71995807",
"0.71995807",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
... | 0.5637549 | 56 |
Return the operator for the bolometer responses. | def get_hwp_operator(self):
return BlockDiagonalOperator(
[self.instrument.get_hwp_operator(self.sampling[b], self.scene)
for b in self.block], axisin=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operator(self) -> str:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> str:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> Optional[str]:\n return pulumi.get(self, \"operator\")",
"def operator(self) -> Optional[str]:\n return pulumi.get(self... | [
"0.71995807",
"0.71995807",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
"0.7093884",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.