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 |
|---|---|---|---|---|---|---|
Gets all free fragments in an IPv4 range. | def get_free_fragments(self, uri, count=-1, start=0):
uri = uri + "/free-fragments?start={0}&count={1}".format(start, count)
return self._helper.get_collection(uri) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fusion_api_get_ipv4_range_free_fragments(self, uri, api=None, headers=None):\n return self.ipv4range.get(uri=uri, api=api, headers=headers, param='/free-fragments')",
"def fusion_api_get_ipv4_range_allocated_fragments(self, uri, api=None, headers=None):\n return self.ipv4range.get(uri=u... | [
"0.81302583",
"0.73491853",
"0.69455755",
"0.6926897",
"0.69000274",
"0.65118515",
"0.650639",
"0.6497357",
"0.61151046",
"0.5804491",
"0.55678064",
"0.5475955",
"0.53490156",
"0.5342843",
"0.5243048",
"0.523589",
"0.5205499",
"0.51444036",
"0.51074594",
"0.50988686",
"0.5049... | 0.71309733 | 2 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print("\n" + "-" * 60 + "\n")
print("\nHello! Let's explore some US bikeshare data!\n")
# get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
city = ""
while city not in VALID_CITIES:
print("Please enter one of the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.5787447 | 63 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
input_file_name = CITY_DATA.get(city)
# Load the CSV file into a Pandas data frame
df = pd.read_csv(input_file_name)
# Convert the format of the existing date field to a python DateTime
df["Start Time"] = pd.to_datetime(df["Start Time"])
# Create new column... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.7889219",
"0.788254... | 0.8108889 | 1 |
Displays statistics on the most frequent times of travel. | def time_stats(df, city, month, day):
start_time = time.time()
print(f"\nCalculating the most frequent times of travel in {city}.\n")
# Determine the month number with the most rides
print("\nThe month with the largest number of rides...")
if month == "all":
month_index = df["month"].valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.0 | -1 |
Displays statistics on the most popular stations and trip. | def station_stats(df, city):
print(f"\nCalculating The Most Popular Stations and Trips in {city}.")
start_time = time.time()
# display most commonly used start station
start_index = df["Start Station"].value_counts().idxmax()
start_count = df["Start Station"].value_counts().max()
print(f"The m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815431",
"0.7661541",
"0.7553297",
"0.749107",
"0.7474493",
"0.7445922",
"0.7430571",
"0.7423423",
"0.741729",
"0.74000263",
"0.73870325",
"0.7385237",
"0.73645216",
"0.7358968",
"0.7356304",
"0.735434",
"0.7351656",
"0.73508406",
"0.7349957",
"0.7341757",
"0.7339878",
... | 0.6888729 | 86 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df, city):
# ---------------------------------------------------------------
print(f"\nCalculating Trip Durations in the city of {city}.")
start_time = time.time()
# display total travel time
df["Travel Time"] = pd.to_datetime(df["End Time"]) - pd.to_datetime(
df["... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(m)
p[1] = mass_func_at_z(x[0], x[1], self.params['const_phi'], bounds=[self.params[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(z)
p[0] = self.finterp_z_pdf(x[0])
# p(m)
p[1] = mass_func_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(zsol)
met_dist = priors.FastTruncatedNormal(a=self.params['z_mini'], b=self.params... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(zsol)
met_dist = priors.FastTruncatedNormal(a=self.params['z_mini'], b=self.params... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7392355",
"0.7262984",
"0.711466",
"0.6915701",
"0.6909401",
"0.68956167",
"0.68956167",
"0.6873251",
"0.6872273",
"0.68018425",
"0.67985773",
"0.6781376",
"0.67679113",
"0.6749953",
"0.6739176",
"0.6724467",
"0.6686326",
"0.66334456",
"0.66287744",
"0.6623655",
"0.6605578... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(m)
p[1] = mass_func_at_z(x[0], x[1], self.params['const_phi'], bounds=[self.params[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(m)
p[1] = mass_func_at_z(x[0], x[1], self.params['const_phi'], bounds=[self.params[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Compute the value of the probability density function at x and return the ln of that. | def __call__(self, x, **kwargs):
if len(kwargs) > 0:
self.update(**kwargs)
if x.ndim == 1:
# doing mcmc; x is [zred, logmass, logzsol]
p = np.zeros_like(x)
# p(z)
p[0] = self.finterp_z_pdf(x[0])
# p(m)
p[1] = mass_func_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lnprob(self, x):\n return self.lnprob(x, *self.lnprob_args)",
"def ln(x):\n return log(x, const.e)",
"def lnprobability(self):\n return",
"def log_likelihood(self, x):\n return self.log_likelihood_exp(x) + self.log_prior_nuisance_parameters(x)",
"def n_pdf(x):\n return 1/... | [
"0.7391907",
"0.72649086",
"0.711581",
"0.6915692",
"0.69079846",
"0.68963856",
"0.68963856",
"0.68732494",
"0.68725616",
"0.68021107",
"0.6800133",
"0.67799383",
"0.6767311",
"0.6751591",
"0.6738774",
"0.67229307",
"0.66853",
"0.6633173",
"0.6628195",
"0.6625208",
"0.6604692... | 0.0 | -1 |
Begin triggering I/O in all IOPump instances we have. We will keep periodically 'pumping' our IOPumps until `.stop()` is called. Call from `setUp()` for example. | def start(self):
if self._pumping:
return
self._pumping = True
self._global_reactor.callLater(0, self._pump_once) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n super().start()\n loop = IOLoop.current()\n # Collect and send all IOPub messages, for all time\n # TODO: Check errors from this loop and restart as needed (or shut down the kernel)\n loop.add_callback(self.relay_iopub_messages)",
"def run(self):\n log... | [
"0.6621984",
"0.6034529",
"0.60302204",
"0.59769005",
"0.5975594",
"0.58433235",
"0.5814245",
"0.5773968",
"0.57562876",
"0.5711771",
"0.57089007",
"0.5707175",
"0.5635992",
"0.5624777",
"0.5607396",
"0.55764365",
"0.5567893",
"0.55610627",
"0.5517415",
"0.55100995",
"0.55055... | 0.62304974 | 1 |
Raises a ValueError if item has macro parameters. | def assert_no_macros(item: Any):
if ismacro(item):
raise ValueError(f"Item {item} is a macro value.")
if isinstance(item, dict):
for it in item.values():
assert_no_macros(it)
if isinstance(item, (list, tuple)):
for it in item:
assert_no_macros(it) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_param_exceptions(self):\n # test with no params\n with self.failUnlessRaises(Exception):\n ItemSelector()\n\n with self.failUnlessRaises(Exception):\n ItemSelector(regex='aaa', items=[11, 1, 1])\n\n selector = ItemSelector(regex='a')\n with self.fai... | [
"0.5601419",
"0.55820376",
"0.5550769",
"0.553425",
"0.54735035",
"0.5456392",
"0.53218484",
"0.52337104",
"0.5197225",
"0.5179749",
"0.50958675",
"0.5095692",
"0.50747716",
"0.5052702",
"0.50440544",
"0.49825388",
"0.4978737",
"0.4973885",
"0.4972528",
"0.4960362",
"0.494519... | 0.67680526 | 0 |
Initialise the Network Model with given number of layes defined with given size. | def __init__(self, state_size, action_size, action_high=1.0, action_low=0.0, layer_sizes=(64, 64),
batch_norm_options=(True, True), dropout_options=(0, 0), learning_rate=0.0001, logger=None):
self.state_size = state_size
self.action_size = action_size
self.action_high = action_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, netSize):\n\t\t\n\t\t# TRY THIS FOR RANDOM!\n\t\t#\n\t\t#\n\t\t#\n\t\t\n\t\tself.biases = [self.randomArray(i, 1) for i in netSize[1:]] # Biases do not exist for the first layer ! Those are inputs.\n\t\tself.netSize = netSize\n\t\t#Initialize Weights\n\t\t#This initializes th... | [
"0.70965767",
"0.67168045",
"0.65341616",
"0.6479995",
"0.6451678",
"0.64447796",
"0.64236647",
"0.64174455",
"0.64169323",
"0.638521",
"0.637205",
"0.63692236",
"0.636796",
"0.6325807",
"0.6316577",
"0.62999916",
"0.62999916",
"0.62784815",
"0.6272944",
"0.6261775",
"0.62588... | 0.0 | -1 |
Build an actor (policy) network that maps states > actions. | def build_model(self):
# Define input layer (states)
states = K.layers.Input(shape=(self.state_size,), name='states')
net = states
# Add the hidden layers
for layer_count in range(len(self.layer_sizes)):
net = K.layers.Dense(units=self.layer_sizes[layer_count])(net)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_actor_network(states, num_controls, params, scope_name):\n scope_key = scope_name + '/'\n with tf.variable_scope(scope_name):\n hidden_1 = tf.layers.dense(states,\n units=params.actor_hidden_units[0],\n activation=None,\n ... | [
"0.69356495",
"0.636351",
"0.6270465",
"0.62087923",
"0.62009275",
"0.6187312",
"0.61473614",
"0.6146225",
"0.6128509",
"0.60179603",
"0.6002386",
"0.5976266",
"0.5959938",
"0.5952642",
"0.594925",
"0.59280884",
"0.5916518",
"0.5898108",
"0.58937097",
"0.5891148",
"0.5880467"... | 0.0 | -1 |
Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
tasks = []
for platform in KETRA_PLATFORMS:
tasks.append(hass.config_entries.async_forward_entry_unload(entry, platform))
await asyncio.gather(*tasks)
common_platform = hass.data[DOMAIN][entry.unique_id]["common_platf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.5864566 | 76 |
Return the N4 Hub object. | def hub(self) -> N4Hub:
return self.platform_common.hub | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hub(self):\n return self._application_handler.data_collection.hub",
"def getHubble(self):\n return self._hubble",
"def hub(self) -> str:\n return self._db_data.hub",
"def get_hub_class():\n hubtype = _threadlocal.Hub\n if hubtype is None:\n hubtype = _threadlocal... | [
"0.63841695",
"0.638218",
"0.6184551",
"0.61496705",
"0.6148809",
"0.61075497",
"0.58169466",
"0.56410563",
"0.5580651",
"0.53937566",
"0.53923714",
"0.53186435",
"0.5205844",
"0.5205844",
"0.51673466",
"0.51398873",
"0.5032994",
"0.5032392",
"0.4969027",
"0.49559247",
"0.495... | 0.82082766 | 0 |
Converts a class to a pandas series. | def class2df(cl):
attrs = vars(cl)
cl = {item[0]: item[1] for item in attrs.items()}
return pd.Series(cl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_series(self) -> \"pd.Series\":\n import pandas as pd\n\n data = {\"_row_id\": self.id, \"_row_num\": self.num, **self.as_dict()}\n series = pd.Series(data)\n return series",
"def to_real_series(self, data: pd.Series) -> pd.Series:\n ...",
"def to_series(self) -> pd.Ser... | [
"0.7379312",
"0.6793011",
"0.67093587",
"0.66472113",
"0.64698786",
"0.64162344",
"0.6405924",
"0.6398417",
"0.6350942",
"0.63316363",
"0.63167405",
"0.62308085",
"0.62182087",
"0.61225235",
"0.6041683",
"0.60315126",
"0.60091174",
"0.5980282",
"0.5975727",
"0.59655094",
"0.5... | 0.699151 | 1 |
Tests that error is raised on invalid input data. | def test_invalid_data_raises_error(self):
with self.assertRaises(ValueError):
PoincareModel([("a", "b", "c")])
with self.assertRaises(ValueError):
PoincareModel(["a", "b", "c"])
with self.assertRaises(ValueError):
PoincareModel("ab") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_with_invalid_input(self):\n for dataset_type in ['ruler', 'pencil', 'cheese']:\n with self.assertRaises(ValueError) as exc:\n check_dataset_type(dataset_type)\n self.assertEqual(\"Dataset type not 'regular' or 'raw' is %s\" % dataset_type,\n ... | [
"0.7769626",
"0.7604946",
"0.7528094",
"0.7501662",
"0.74802184",
"0.7394625",
"0.73569643",
"0.70715976",
"0.7044988",
"0.70400596",
"0.7008276",
"0.69919646",
"0.6935181",
"0.6933202",
"0.69115615",
"0.6892353",
"0.68677276",
"0.68636453",
"0.6862753",
"0.68464905",
"0.6845... | 0.7101966 | 7 |
Test closest_child returns expected value and returns None for lowest node in hierarchy. | def test_closest_child(self):
self.assertEqual(self.vectors.closest_child('dog.n.01'), 'terrier.n.01')
self.assertEqual(self.vectors.closest_child('harbor_porpoise.n.01'), None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_closest_val_bst(tree,target,closest):\n current_node = tree\n\n while current_node is not None:\n if current_node is None:\n return closest\n if abs(target-closest) > abs(target - current_node.data):\n closest = current_node.data\n if target < current_node.... | [
"0.6621943",
"0.6511974",
"0.6448948",
"0.6435108",
"0.6072948",
"0.60070854",
"0.5994254",
"0.5975263",
"0.590643",
"0.58828044",
"0.5826286",
"0.58065325",
"0.5786452",
"0.57709676",
"0.5764981",
"0.57392573",
"0.57327574",
"0.57245797",
"0.569909",
"0.5695313",
"0.56920666... | 0.73931843 | 0 |
Test closest_parent returns expected value and returns None for highest node in hierarchy. | def test_closest_parent(self):
self.assertEqual(self.vectors.closest_parent('dog.n.01'), 'canine.n.02')
self.assertEqual(self.vectors.closest_parent('mammal.n.01'), None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_next_parent_node(self, parent):\n grandparent = parent.parent\n if grandparent is None:\n # here, we work at yearly/linear level\n return None\n\n parent_siblings = list(grandparent.children)\n sorted_keys = sorted(parent_siblings)\n index = sorted_... | [
"0.7030396",
"0.64167935",
"0.6360162",
"0.6311969",
"0.62710154",
"0.6195982",
"0.6195844",
"0.6163151",
"0.6149812",
"0.61235267",
"0.61113405",
"0.6106762",
"0.6080639",
"0.6008101",
"0.5998256",
"0.5990547",
"0.59833914",
"0.5936111",
"0.5930727",
"0.59146893",
"0.58932",... | 0.71701837 | 0 |
Test that a none GET method returns the correct error | def test_input():
encoded_text = u'Post test/test/test HTTP/1.1'
response = echo_client(encoded_text)
assert '405' in response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_errors(self):\n rc = self.app.get('/this_should_not_exist', follow_redirects=True)\n assert b'404 error :(' in rc.data",
"def test_two_legged_get(self):\n resp, content = self._two_legged(\"GET\")\n self.assertEqual(int(resp['status']), 200)",
"def test_trucks_api_error(sel... | [
"0.7881011",
"0.7745228",
"0.7691827",
"0.767983",
"0.76355946",
"0.7603721",
"0.75919557",
"0.7557427",
"0.7523062",
"0.7497758",
"0.7462016",
"0.7446817",
"0.7439628",
"0.7419393",
"0.7377602",
"0.73459095",
"0.7263187",
"0.7245952",
"0.7238263",
"0.7237791",
"0.7236589",
... | 0.0 | -1 |
Test that a request for a faulty uri returns a 404 error | def test_error404():
response = echo_client("GET test/test HTTP/1.1")
assert '404' in response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_errors(self):\n rc = self.app.get('/this_should_not_exist', follow_redirects=True)\n assert b'404 error :(' in rc.data",
"def test_invalid_route_is_status_404(self):\n response = self.client.get(\"/bad\")\n self.assertTrue(response.status_code == 404)",
"def test_not_existi... | [
"0.83580095",
"0.81577903",
"0.8135164",
"0.8134995",
"0.81261075",
"0.8124627",
"0.8012696",
"0.799247",
"0.790721",
"0.7854061",
"0.7792239",
"0.77437794",
"0.77327967",
"0.7719252",
"0.77079165",
"0.76710457",
"0.7628644",
"0.75984675",
"0.75915873",
"0.75852746",
"0.75744... | 0.77093 | 14 |
String representation of Poscar file | def __str__(self):
# print(self.get_string())
return self.get_string() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n out = 'Content of Graph stored in file ' + self.filename + '\\n'\n out += 'Content of headers:' + '\\n'\n out += str(self.headers)\n out += '\\nNumber of Curves: '+str(self.length())\n return out",
"def __str__(self):\n final_str = [\"Binary File Hea... | [
"0.6604887",
"0.6364614",
"0.62646776",
"0.61377776",
"0.6058567",
"0.6006769",
"0.6003735",
"0.59679127",
"0.5963719",
"0.5962812",
"0.5958227",
"0.59240437",
"0.59113026",
"0.5886439",
"0.58863527",
"0.5880247",
"0.58753246",
"0.58740497",
"0.5851024",
"0.58244175",
"0.5823... | 0.0 | -1 |
Return the args to launch the subprocess. | def _argsForSubprocess(self) -> list[str]:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_start_cmd_args(self):\r\n return self.get_args(OSPL.start)",
"def args(self):\n return self.cmd_args",
"def getSpawnArgs(self):\r\n _args = [\r\n executable, # path to python executable e.g. /usr/bin/python\r\n ]\r\n if not self.options['loud']:\r\n ... | [
"0.7228847",
"0.70896095",
"0.7023654",
"0.6994444",
"0.6835092",
"0.6763384",
"0.67612195",
"0.67377526",
"0.6590636",
"0.65861905",
"0.65741533",
"0.6540631",
"0.6515971",
"0.64767396",
"0.64591837",
"0.6445384",
"0.6396823",
"0.6395334",
"0.6331719",
"0.63132083",
"0.63123... | 0.7921439 | 0 |
returns the minimum value in the list. Raises exception if empty | def min(l):
if l:
s_list = sorted(l)
return s_list[0]
else:
raise ValueError("list empty") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_minimum_value_from_list(self, list_):\r\n return min(list_)",
"def find_min(list):\n return find_value_at(list, -1)",
"def min():\n\n # check if collection passed to process() so far is empty\n assert len(inlist) > 0, \"process() has empty collection\"\n\n # assign tmp the first val ... | [
"0.8623766",
"0.8172379",
"0.79932207",
"0.76424927",
"0.763713",
"0.7582653",
"0.75733745",
"0.75529677",
"0.74900657",
"0.7408981",
"0.7408981",
"0.73957294",
"0.7389005",
"0.7364589",
"0.73627824",
"0.7331601",
"0.72606117",
"0.7224501",
"0.71979445",
"0.7180544",
"0.71742... | 0.8449457 | 1 |
returns the maximum value in the list. Raises exception if empty | def max(l):
if l:
s_list = sorted(l)
return s_list[-1]
else:
raise ValueError("list empty") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max(self):\r\n maxVal = self.items[1]\r\n if maxVal is None:\r\n return None\r\n \r\n for i in range(1,len(self.items)):\r\n if self.items[i] is not None:\r\n if self.items[i] > maxVal:\r\n maxVal = self.items[i]\r\n ... | [
"0.8416",
"0.81303465",
"0.8030511",
"0.79588395",
"0.79333514",
"0.76107645",
"0.75805676",
"0.7580427",
"0.7573161",
"0.7543689",
"0.75375026",
"0.75372905",
"0.75098765",
"0.7501834",
"0.7501478",
"0.7495224",
"0.74499786",
"0.74337286",
"0.7403942",
"0.7395598",
"0.736643... | 0.8028246 | 3 |
Returns True if a and b are members of the same set. | def joined(self, a, b):
mapping = self._mapping
try:
return mapping[a] is mapping[b]
except KeyError:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_equivalent(self, a, b):\n assert set(a) == set(b)\n for key in a:\n assert self.is_equal(a[key], b[key])",
"def assertEqualAsSets(self, a, b):\n self.assertSetEqual(set(a), set(b))",
"def is_same_set(self, item1, item2):\n res = False\n for s in self._dat... | [
"0.74042857",
"0.7364471",
"0.7069721",
"0.7015663",
"0.69931185",
"0.6977477",
"0.6916377",
"0.6892476",
"0.68793875",
"0.68454605",
"0.68276435",
"0.6826703",
"0.6826196",
"0.6805797",
"0.67718834",
"0.6713187",
"0.6701026",
"0.6689459",
"0.6627186",
"0.6601325",
"0.6569425... | 0.64110434 | 29 |
Returns a Api instance. | def __init__(self, config, timeout=None):
self.__set_credentials(config)
self.__set_timeout(timeout)
self._base_url = 'https://reverse.geocoder.api.here.com/6.2/reversegeocode.json' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api(self):\n if self._api is None:\n self._api = Api(self)\n return self._api",
"def get_api(self):\n return self.api",
"def get_instance(cls):\n global FW_MANAGER_API\n if not FW_MANAGER_API:\n FW_MANAGER_API = cls()\n return FW_MANAGER_API",... | [
"0.8340845",
"0.73435336",
"0.6944522",
"0.6869204",
"0.6869204",
"0.6869204",
"0.6869204",
"0.6853912",
"0.682609",
"0.6742675",
"0.6690572",
"0.66656816",
"0.66338885",
"0.6582636",
"0.6569288",
"0.6561423",
"0.65136266",
"0.6495872",
"0.64536554",
"0.64031",
"0.63779026",
... | 0.0 | -1 |
Test flat yaml files comparing. | def test_json_like_flat_yaml(
before_yaml_flat: str,
after_yaml_flat: str,
json_like_flat_res: str,
):
assert gendiff(
before_yaml_flat,
after_yaml_flat,
form=JSON_LIKE_FORMAT,
) == json_like_flat_res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_yaml(self):\n\n # Check yml file can be loaded correctly\n with open(\"{}/app_spec.yml\".format(self.APP_PATH), mode='r',\n encoding=\"utf-8\", errors='ignore') as stream:\n # Load yaml file\n try:\n yaml_obj = yaml.load(stream) or {}\n ... | [
"0.6678179",
"0.6583754",
"0.6404194",
"0.6367564",
"0.63440216",
"0.628161",
"0.6268249",
"0.6261658",
"0.6220767",
"0.6210929",
"0.6164536",
"0.61586",
"0.6133815",
"0.610405",
"0.6081547",
"0.5962536",
"0.5956524",
"0.5940887",
"0.5929892",
"0.591979",
"0.5903216",
"0.58... | 0.5881167 | 23 |
handle higher values in recursion with memoization. only operate if the val isn't in the dict. populate the dict with every result always pass a basic dict for 0 and 1 | def memofib1(n:int, fibs:dict={0:0,1:1})->dict:
if n not in fibs:
fib1, fib2 = memofib(n -1, fibs), memofib(n -2,fibs)
fibs[n] = fib1 + fib2
return fibs[n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def memoize(func):\n tbl = {}\n\n def helper(args):\n if args not in tbl:\n tbl[args] = func(args)\n return tbl[args]\n return helper",
"def makeValMap(self,value = 'readcount'):\n self.valMap = np.zeros(len(self))\n self.valMap = self.valMap-1\n myTmp = []\... | [
"0.60997504",
"0.59238",
"0.5785667",
"0.56968004",
"0.56554776",
"0.55555713",
"0.55106014",
"0.5491152",
"0.5491152",
"0.5474471",
"0.54649985",
"0.5464799",
"0.54640716",
"0.54357344",
"0.54324067",
"0.53808033",
"0.53230196",
"0.53200406",
"0.53192824",
"0.53192824",
"0.5... | 0.5270475 | 22 |
Given a model, load pretrained weight and fuse conv layers | def load_and_fuse_pretrained_weights(model: torch.nn.Module, opt: argparse.ArgumentParser) -> torch.nn.Module:
model.optimize_for_inference(fuse_all_layers=False)
fused_state_dict = load_weights(opt.weights)
fused_state_dict = map_key_names(fused_state_dict, model.state_dict())
model.load_state_dict(fus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(img_width,img_height, name):\n model,last_conv_layer = get_model(img_width,img_height)\n model.load_weights(name)\n return model,last_conv_layer",
"def load_pretrained_weights(model, model_name, load_fc=True):\n state_dict = torch.load(url_map[model_name])\n if load_fc:\n mod... | [
"0.735765",
"0.71768886",
"0.70577496",
"0.68616176",
"0.6738198",
"0.6699347",
"0.66891056",
"0.6637697",
"0.66203254",
"0.66169906",
"0.66069275",
"0.6599178",
"0.659753",
"0.6591255",
"0.6587027",
"0.6564953",
"0.6559705",
"0.65380985",
"0.6532118",
"0.6525125",
"0.6497530... | 0.7324815 | 1 |
Find the areas of intersection between the given boxes1 and boxes2 in xmin, ymin, xmax, ymax | def intersection(boxes1: np.array, boxes2: np.array) -> np.array:
inter_coords = np.clip(
np.minimum(boxes1[:, None, 2:], boxes2[:, 2:]) - np.maximum(boxes1[:, None, :2], boxes2[:, :2]),
a_min=0,
a_max=None
)
return np.prod(inter_coords, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersection(boxes1, boxes2):\n ymin1, xmin1, ymax1, xmax1 = np.split(boxes1, 4, axis=1)\n ymin2, xmin2, ymax2, xmax2 = np.split(boxes2, 4, axis=1)\n\n pairwise_min_ymax = np.minimum(ymax1, np.transpose(ymax2))\n pairwise_max_ymin = np.maximum(ymin1, np.transpose(ymin2))\n intersect_heights = np.maximum(\... | [
"0.87406045",
"0.8639629",
"0.85277444",
"0.8039987",
"0.7914294",
"0.78545207",
"0.7734795",
"0.7698025",
"0.76504254",
"0.7554159",
"0.74728376",
"0.7455414",
"0.7454213",
"0.7400588",
"0.736359",
"0.736359",
"0.736359",
"0.73495644",
"0.73441243",
"0.7325737",
"0.73257285"... | 0.8002669 | 4 |
Convert xmin, ymin, xmax, ymax to centerx, centery, width, height | def xyxy_to_xywh(boxes: np.array) -> np.array:
boxes[..., 2] = boxes[..., 2] - boxes[..., 0]
boxes[..., 3] = boxes[..., 3] - boxes[..., 1]
boxes[..., 0] = boxes[..., 0] + boxes[..., 2]/2
boxes[..., 1] = boxes[..., 1] + boxes[..., 3]/2
return boxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(self):\n xc = (self.x.max() + self.x.min())/2.\n yc = (self.y.max() + self.y.min())/2.\n return (xc, yc)",
"def center(width, height):\n return width/2, height/2",
"def center(self):\n x0, y0, width, height = self._rect_bbox\n return x0 + width / 2., y0 + he... | [
"0.7331263",
"0.7330635",
"0.7240829",
"0.6923499",
"0.68902475",
"0.68811375",
"0.6824832",
"0.67836565",
"0.6772967",
"0.6734213",
"0.6726162",
"0.67211455",
"0.67181253",
"0.6695281",
"0.66415566",
"0.66031015",
"0.6576102",
"0.6568119",
"0.6545627",
"0.6509597",
"0.649359... | 0.0 | -1 |
Compute the precisionrecall curve and the average precision | def ap_per_class(
tp: np.array, conf: np.array, pred_cls: np.array, target_cls: np.array
) -> Tuple[np.array, np.array, np.array, np.array, np.array]:
# Sort by confidence
sorted_indices = np.argsort(-conf)
tp, conf, pred_cls = tp[sorted_indices], conf[sorted_indices], pred_cls[sorted_indices]
# Fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pr_auc_score(precision: list, recall: list) -> float:\n return quadrature_calculator(recall, precision)",
"def precision_recall(y_true, y_prob, ARGS):\n average_precision = average_precision_score(y_true, y_prob)\n if ARGS.graphs:\n precision, recall, _ = precision_recall_curve(y_true, y_prob... | [
"0.7777468",
"0.77756685",
"0.7767011",
"0.7711008",
"0.77076",
"0.7673158",
"0.7673145",
"0.76661867",
"0.76661867",
"0.7622668",
"0.75526094",
"0.75037986",
"0.7440165",
"0.73650604",
"0.729343",
"0.72888017",
"0.7284746",
"0.7267327",
"0.72073525",
"0.7147267",
"0.7133386"... | 0.0 | -1 |
Compute the average precision, given the recall and precision curves | def compute_ap(recall: np.array, precision: np.array) -> np.array:
# Append sentinel values to beginning and end
mrec = np.concatenate(([0.], recall, [min(recall[-1] + 1E-3, 1.)]))
mpre = np.concatenate(([0.], precision, [0.]))
# Compute the precision envelope
mpre = np.flip(np.maximum.accumulate(n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ... | [
"0.83239913",
"0.8071688",
"0.77354884",
"0.77035093",
"0.7684726",
"0.7682824",
"0.7678788",
"0.7636026",
"0.7636026",
"0.76210535",
"0.75673103",
"0.74946827",
"0.74600375",
"0.7266628",
"0.7226185",
"0.7193613",
"0.71866876",
"0.7172593",
"0.7143039",
"0.7127368",
"0.71263... | 0.7257528 | 14 |
Clip boxes to image dimensions | def clip_coords(boxes: torch.Tensor, img_shape: torch.Tensor):
boxes[:, 0].clamp_(0, img_shape[0])
boxes[:, 1].clamp_(0, img_shape[1])
boxes[:, 2].clamp_(0, img_shape[0])
boxes[:, 3].clamp_(0, img_shape[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_boxes_to_image(boxes, height, width):\n\n boxes[:, [0, 2]] = np.minimum(width - 1., np.maximum(0., boxes[:, [0, 2]]))\n boxes[:, [1, 3]] = np.minimum(height - 1., np.maximum(0., boxes[:, [1, 3]]))\n return boxes",
"def clip_boxes(self, boxes, im_shape):\n if boxes.shape[0] == 0:\n ... | [
"0.8051326",
"0.7780122",
"0.77587897",
"0.77209914",
"0.77209914",
"0.77200115",
"0.7718982",
"0.7705344",
"0.7705344",
"0.7692738",
"0.7652997",
"0.7428496",
"0.7055988",
"0.7036455",
"0.69493806",
"0.6878645",
"0.68074095",
"0.6784786",
"0.6759062",
"0.6679851",
"0.6667771... | 0.7323405 | 12 |
Layout for the start/index page | def start_page(app: dash.Dash, data: GameData) -> html:
data.reset()
start_page = dbc.Container(
dbc.Jumbotron([
html.H1("Can you beat our AI?", className="display-3"),
html.P(
"Are you a car expert? You think you know cars better than our machine "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n return render_template('main/index.html')",
"def index():\n return render_template('pages/index.html', isNav=True)",
"def index(self):\n\t\treturn render_template('index.html')",
"def index():\n return render_template(\n 'main/index.html',\n title='Main page'\n ... | [
"0.72906965",
"0.7155225",
"0.70902795",
"0.69669795",
"0.6957398",
"0.6914073",
"0.69089013",
"0.68991387",
"0.6871783",
"0.68351793",
"0.6834431",
"0.6812019",
"0.68056417",
"0.6786792",
"0.67728996",
"0.67632765",
"0.6758933",
"0.672355",
"0.672355",
"0.6711979",
"0.671057... | 0.0 | -1 |
Takes file path as string; returns text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. | def open_and_read_file(file_path):
source_material = open(file_path).read()
return source_material | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_and_read_file(file_path):\n\n text_file = open(file_path)\n full_text = text_file.read()\n\n return full_text",
"def open_and_read_file(file_path):\n\n # your code goes here\n text_file = open(file_path)\n text_string= text_file.read()\n text_file.close()\n return text_string",
... | [
"0.8119262",
"0.80849",
"0.80729145",
"0.80683374",
"0.7955215",
"0.7940279",
"0.7888122",
"0.78128433",
"0.77138",
"0.7699266",
"0.76635927",
"0.7631807",
"0.7622674",
"0.7612502",
"0.75782925",
"0.75302607",
"0.7527177",
"0.7487932",
"0.7439546",
"0.74100906",
"0.7372579",
... | 0.0 | -1 |
Allows only super user, otherwise redirecting to root | def superuser_required(view_func):
return user_passes_test(lambda u: u.is_superuser, login_url='/', redirect_field_name=None)(view_func) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_superuser_permission_with_super_user(self):\n with self.settings(MAINTENANCE_MODE_PERMISSION_PROCESSORS=(\n 'maintenancemode.permission_processors.is_superuser',\n )):\n self.client.login(username='super_user', password='maintenance_pw')\n response = self.cli... | [
"0.71010584",
"0.69411874",
"0.6940683",
"0.68318915",
"0.6809491",
"0.67110705",
"0.66148925",
"0.655251",
"0.65456045",
"0.6500882",
"0.6500882",
"0.6486205",
"0.6477929",
"0.6475384",
"0.6449824",
"0.642106",
"0.6408767",
"0.6402535",
"0.6388843",
"0.63764244",
"0.63568515... | 0.728493 | 0 |
Test for updating a submission | def test_update_submission(self):
sub_response_register = register_ok_submission(self, self.token)
response_data = json.loads(sub_response_register.data.decode())
self.assertTrue(response_data['status']=='success')
sub = [sub for sub in Submission.query(hash_key=self.new_user.username, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_submission_service(self):\n pass",
"def test_update_submission(self):\n self.call_file_submission()\n # note: this is a quarterly test submission, so\n # updated dates must still reflect a quarter\n if CONFIG_BROKER[\"use_aws\"]:\n update_json = {\"ex... | [
"0.7764652",
"0.7288204",
"0.71831644",
"0.6994233",
"0.6914636",
"0.69082",
"0.69060683",
"0.6827972",
"0.6827972",
"0.6827972",
"0.67407084",
"0.6733642",
"0.6681749",
"0.6656005",
"0.6621568",
"0.6607056",
"0.6595279",
"0.65546256",
"0.65380657",
"0.6506674",
"0.649569",
... | 0.8276319 | 0 |
Returns the currently visible state of the world as a numpy array of doubles. | def getSensors(self):
sensors = array([])
sensors = r_[sensors, self._getTotalDemandSensor()]
# sensors = r_[sensors, self._getDemandSensor()]
# sensors = r_[sensors, self._getPriceSensor()]
# sensors = r_[sensors, self._getBusVoltageSensor()]
# sensors = r_[sensors, self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getState(game):\n pixels = pygame.surfarray.array3d(game.screen)[:]\n pixels = np.array([pixels], dtype=float)\n\n # Here we will preprocess the pixel data\n bitsize = game.screen.get_bitsize() / 4\n pixels *= 1 / 2**bitsize # Normalize to [0..1]\n\n return pixels",
"def _get_obs(self):\n ... | [
"0.6756344",
"0.67543894",
"0.66300714",
"0.6490821",
"0.6417404",
"0.63494956",
"0.63421303",
"0.63346756",
"0.6237947",
"0.619991",
"0.6155184",
"0.6154079",
"0.6137255",
"0.61195725",
"0.61074835",
"0.6099334",
"0.6099334",
"0.606061",
"0.6059707",
"0.60488176",
"0.6046823... | 0.0 | -1 |
Checks if a particular name is among the column names of a dataframe. Alternative names can be given, which when found will be changed to the desired name. The DataFrame will be changed in place. If no matching name is found an AttributeError is raised. | def ensure_column_exists(df, col_name, col_alt = False):
if col_name not in df.columns:
renamed = False
if col_alt:
for dta in col_alt:
if dta in df.columns:
df.rename(columns={dta:col_name}, inplace = True)
renamed = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_columns(df: pd.DataFrame, names: typing.Sequence[str]) -> None:\n for expected in names:\n if expected not in df.columns:\n raise ValueError(f\"'{expected}' column not found in input\")\n return",
"def check_df_col(df, column, name=None):\n if column is not None:\n\n ... | [
"0.7750524",
"0.678532",
"0.6727862",
"0.6284831",
"0.6151429",
"0.61467224",
"0.6092325",
"0.60884756",
"0.60327345",
"0.6018756",
"0.5969523",
"0.59683293",
"0.59470916",
"0.5898043",
"0.5894091",
"0.58661723",
"0.5829222",
"0.5816485",
"0.5791446",
"0.5782782",
"0.57619584... | 0.7210286 | 1 |
max of xdistance and ydistance from (x,y) to the line ((x1,y1),(x2,y2)). Return infinity if there's no way to do it without intersecting a wall | def xymaxw_to_line(point, edge, walls):
# if min(x1,x2) <= x <= max(x1,x2) and min(y1,y2) <= y <= max(y1,y2):
# return 0
(x,y) = point
((x1,y1),(x2,y2)) = edge
if x1 == x2:
ds = [max(abs(x1-x), abs(y3-y)) \
for y3 in range(min(y1,y2),max(y1,y2)+1) \
if not racetrack.crash(((x,y),(x1,y3)), walls)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(x1, y1, x2, y2):\n return math.sqrt((x1 - x2) ** 2 + (y1 * 2.38 - y2 * 2.38) ** 2)",
"def LineMaxDistanceTo(line, point_or_line):\n line = rhutil.coerceline(line, True)\n test = rhutil.coerceline(point_or_line)\n if test is None: test = rhutil.coerce3dpoint(point_or_line, True)\n ... | [
"0.6736371",
"0.6635562",
"0.65396225",
"0.6487691",
"0.64592004",
"0.64060557",
"0.63906133",
"0.63818824",
"0.63812417",
"0.63495886",
"0.63482386",
"0.63333476",
"0.6299885",
"0.62979287",
"0.6293609",
"0.6277988",
"0.62134504",
"0.620851",
"0.6193028",
"0.6107365",
"0.609... | 0.72153175 | 0 |
A view to show one product's details | def product_detail(request, product_id):
product = get_object_or_404(Product, pk=product_id)
review_form = ReviewForm()
reviews = Review.objects.filter(product_id=product_id).order_by('-created_at')
context = {
'product': product,
'review_form': review_form,
'reviews': revie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_view(request, product):\n product = Products.objects.get(product=product)\n\n context = {\n \"product\": product,\n }\n\n return render(request, \"products/product_detail.html\", context)",
"def product_detail(request, product_id):\n product = get_object_or_404(Product, pk=produ... | [
"0.84522843",
"0.82275134",
"0.8158492",
"0.8144128",
"0.81159216",
"0.79595757",
"0.7922133",
"0.79041237",
"0.7466099",
"0.7449137",
"0.74209493",
"0.7345423",
"0.73277515",
"0.72346437",
"0.7213193",
"0.7202805",
"0.7150423",
"0.71476156",
"0.69926614",
"0.6931573",
"0.692... | 0.77063096 | 8 |
Gets the target_instance of this SetOnlineMigrationTaskBody. | def target_instance(self):
return self._target_instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target(self):\n return self._task_target",
"def get_target(self):\n return self._target",
"def _target(self):\n return self.__target",
"def target(self):\n return self.__target",
"def target(self):\n return self.__target",
"def target(self):\n return self._ta... | [
"0.6035363",
"0.60200274",
"0.59009045",
"0.5866133",
"0.5866133",
"0.58338064",
"0.58338064",
"0.58338064",
"0.58338064",
"0.57978475",
"0.5767576",
"0.5731631",
"0.57288975",
"0.5648365",
"0.5633763",
"0.5631898",
"0.56086534",
"0.56086534",
"0.55688477",
"0.55387115",
"0.5... | 0.648672 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, SetOnlineMigrationTaskBody):
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 resource doesn't yet have an assigned 'href' property, False otherwise. | def _is_new_(self):
#we can't call get_href in here, otherwise we'll have an infinite loop:
return False if self._read_property_(self.HREF_PROP_NAME) else True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_url(self):\n return hasattr(self, \"_url\") and self._url is not None",
"def exists(self):\n return self.islink() or exists(self._path)",
"def has_target_href(self) -> bool:\n return self._target_href is not None",
"def check_href(href):\n if bool(pattern.match(href)):\n ... | [
"0.7146463",
"0.69893646",
"0.64848757",
"0.6470109",
"0.64633214",
"0.6322043",
"0.6301547",
"0.62578046",
"0.6248713",
"0.6223082",
"0.6211599",
"0.6187709",
"0.61719114",
"0.6147388",
"0.6106723",
"0.61055565",
"0.6058852",
"0.5954254",
"0.59420574",
"0.59223753",
"0.58954... | 0.7432243 | 0 |
Gets the status of the resource as a stormpath.resource.status.Enabled object or stormpath.resource.status.Disabled object. | def status(self):
return status_dict[self._get_property_(self.STATUS).upper()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStatus(self):\n return self.enabled",
"def get_status(self):\n # TODO retrieve from db if not set\n return self.status",
"def get_status(self):\n return self.status",
"def get_status(self):\n return self.status",
"def get_status(self):\n return self.status",... | [
"0.7169624",
"0.71150684",
"0.7043476",
"0.7043476",
"0.7043476",
"0.6954905",
"0.6922029",
"0.6905952",
"0.6900789",
"0.6873888",
"0.6870921",
"0.68608403",
"0.6858082",
"0.6835155",
"0.68195784",
"0.6793498",
"0.67758656",
"0.67511886",
"0.6729547",
"0.66634345",
"0.6646859... | 0.6775833 | 17 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(y_true, y_pred, classes,
normalize=False,
title=None,
cmap=plt.cm.Blues):
if not title:
if normalize:
title = 'Normalized confusion matrix'
else:
title = 'Confusion matrix,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194052",
"0.8095069",
"0.80293566",
"0.8018802",
"0.799371",
"0.7990971",
"0.7980545",
"0.7975993",
"0.79609",
"0.7957234",
"0.7937344",
"0.79343724",
"0.79341805",
"0.79310715",
"0.7926063",
"0.79241866",
"0.7923726",
"0.79229325",
"0.79226404",
"0.79218584",
"0.7917542"... | 0.0 | -1 |
Takes in a dataframe, a variable list and titles to generate a scatter plot showing the relationship between experimentally determined variables and our model's predicted values. | def plot_T(df, parameters_list, title, point_type):
slope, intercept, r, p, std_er = stats.linregress(df['T_exp'], df['T_prd'])
plot = sns.regplot(x='T_exp', y='T_prd', data=df, line_kws={'label':
"y={0:.3f}x+{1:.3f}".format(slope, intercept)})
plot.legend()
plot.set(xlabel="Exper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_actual_vs_predicted_by_equations(df, x_variable, y_variables, plot_title):\n #Plot results\n df.plot(x=x_variable, y=y_variables, title=plot_title)\n plt.show()",
"def plot_scatter(x_variable, y_variable, df, x_title, y_title):\n slope, intercept, r_value, p_value, std_err = stats.linregress... | [
"0.75945157",
"0.691685",
"0.6510804",
"0.6306151",
"0.618157",
"0.6128263",
"0.6120626",
"0.6111686",
"0.608828",
"0.604521",
"0.6039046",
"0.6023502",
"0.60209817",
"0.5988978",
"0.59819615",
"0.5981702",
"0.5973939",
"0.593144",
"0.5922708",
"0.5921088",
"0.5917437",
"0.... | 0.613562 | 5 |
Produce a str representation of a Point for Python. | def __repr__(self) -> str:
return f"Point({self.x}, {self.y})" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"Point at ({}, {})\".format(self.x, self.y)",
"def keypoint2str(keypoint):\n keypoint_str = []\n keypoint_str.append(float(keypoint.pt[0]))\n keypoint_str.append(float(keypoint.pt[1]))\n keypoint_str.append(float(keypoint.size))\n keypoint_str.append(float(keypo... | [
"0.73177147",
"0.7214059",
"0.71699363",
"0.71564734",
"0.7049956",
"0.7041911",
"0.7025215",
"0.6972682",
"0.6966807",
"0.6930676",
"0.69084203",
"0.68845785",
"0.68075144",
"0.67827904",
"0.677254",
"0.6737131",
"0.67344993",
"0.6625498",
"0.6625133",
"0.6614454",
"0.659251... | 0.72963095 | 1 |
Get the nodes that this node refers to. | def referenced_nodes(self):
return self._referenced_nodes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referencing_nodes(self):\n\n return self._referencing_nodes",
"def nodes (self):\n return self.__nodes",
"def nodes(self):\n return self.__nodes",
"def nodes(self):\n return self._nodes",
"def nodes(self):\n return self._nodes",
"def nodes(self):\n return... | [
"0.846349",
"0.8438534",
"0.84362996",
"0.8400802",
"0.8400802",
"0.8400802",
"0.82085794",
"0.82085794",
"0.8145438",
"0.8118465",
"0.8004822",
"0.79577255",
"0.7910746",
"0.7878562",
"0.77620155",
"0.7756159",
"0.7751784",
"0.7738992",
"0.77143425",
"0.7709506",
"0.7701738"... | 0.7934429 | 12 |
Get the nodes that refer to this node. | def referencing_nodes(self):
return self._referencing_nodes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referenced_nodes(self):\n return self._referenced_nodes",
"def nodes (self):\n return self.__nodes",
"def nodes(self):\n return self.__nodes",
"def nodes(self):\n return self._nodes",
"def nodes(self):\n return self._nodes",
"def nodes(self):\n return sel... | [
"0.8051833",
"0.784493",
"0.7841791",
"0.77916634",
"0.77916634",
"0.77916634",
"0.7594732",
"0.7549712",
"0.7489801",
"0.7489801",
"0.74630314",
"0.74159473",
"0.7348847",
"0.7338879",
"0.7333792",
"0.7330956",
"0.7286051",
"0.7283245",
"0.724415",
"0.722515",
"0.722515",
... | 0.868759 | 0 |
Mutates the child a set number of times, and returns the shortest found mutation | def mutate(self, prev_length, order):
mutate_attempt = order.copy()
mutate_length = prev_length
best_mutate_tour = order.copy()
best_mutate = prev_length
for i in range(60):
previous = mutate_attempt.copy()
previous_length = mutate_length
i = r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate(self, child):\n for i in range(0, self.chromosome_length):\n if random.randint(1, 100) <= self.mutation_chance:\n child[i] = self.random_gene()\n return child",
"def mutation(parent):\n rand = random.uniform(0, 1)\n if rand > PROB_MUTATION or (not parent.l... | [
"0.6695745",
"0.6396908",
"0.6346015",
"0.6339389",
"0.62983507",
"0.6280339",
"0.6066794",
"0.5892216",
"0.5885157",
"0.58312607",
"0.5725345",
"0.5725069",
"0.57108784",
"0.57089144",
"0.57049644",
"0.56894577",
"0.5654404",
"0.5648768",
"0.56198865",
"0.55614537",
"0.55435... | 0.5350117 | 32 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
print('-'*40)
# get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
while True:
try:
city = input('Which city do you like to analyze? Please choose a ci... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
# load data file into a dataframe
df = pd.read_csv(CITY_DATA[city])
# convert the Start Time column to datetime
df['Start Time'] = pd.to_datetime(df['Start Time'])
# extract month and day of week from Start Time to create new columns
df['month'] = df['Start Tim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.8131659",
"0.8108622",
"0.8045596",
"0.8042176",
"0.80088127",
"0.8007226",
"0.79990864",
"0.7998206",
"0.7988353",
"0.7979118",
"0.7973126",
"0.79608303",
"0.7955881",
"0.79469144",
"0.7945703",
"0.7907982",
"0.79077077",
"0.79041964",
"0.7900504",
"0.78928053",
"0.788891... | 0.7792847 | 35 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# display the most common month
if len(df['month'].unique()) > 1:
max_idx = df.groupby('month')['Start Time'].count().idxmax() - 1
print('The most popular month of travel is', mon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.8023522",
"0.802221",
"0.7914353",
"0.7826378",
"0.7821697",
"0.78140223",
"0.7765606",
"0.7739828",
"0.7735833",
"0.7733764",
"0.7686237",
"0.76675326",
"0.7651101",
"0.7644171",
"0.7639292",
"0.7636152",
"0.76248395",
"0.76227194",
"0.7611663",
"0.7599656",
"0.75825727",... | 0.7012081 | 94 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# display most commonly used start station
print('The most commonly used start station is', df['Start Station'].mode()[0])
# display most commonly used end station
print('The most co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815675",
"0.7662213",
"0.7553417",
"0.74914914",
"0.74748665",
"0.7446617",
"0.7428588",
"0.74237514",
"0.74177027",
"0.7400495",
"0.7387161",
"0.7385634",
"0.73647535",
"0.735934",
"0.73566747",
"0.73548365",
"0.7351854",
"0.7351274",
"0.735057",
"0.73421645",
"0.7340198... | 0.71310204 | 59 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# display total travel time
print('The total time people spent on the trip are', df['Trip Duration'].sum()/(3600*24),
'days')
# display mean travel time
print('The average time people spe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78686154",
"0.78664047",
"0.78637... | 0.78738385 | 18 |
Returns a list of all words from all headlines longer than the min_word_length, converted to lowercase | def all_words(self, min_word_length=0):
return [word for headline in self.headlines for word in
headline.words(min_word_length=min_word_length)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def words(self, min_word_length=0):\n\n word_tokenizer = nltk.RegexpTokenizer(r'\\b[^\\s]+\\b')\n headline_string = self.headline_string.lower().replace(\"’\", \"'\")\n return [word for word in word_tokenizer.tokenize(headline_string) if len(word) >= min_word_length]",
"def small_word_filter... | [
"0.80475503",
"0.7082706",
"0.65824187",
"0.6521871",
"0.6469052",
"0.63823545",
"0.637053",
"0.63642716",
"0.62999916",
"0.6291157",
"0.6288269",
"0.6258216",
"0.6231481",
"0.62154037",
"0.6199231",
"0.61675537",
"0.6164615",
"0.616131",
"0.6141927",
"0.61316144",
"0.6107650... | 0.83405167 | 0 |
Returns a HeadlineData object containing all headlines with unique headline strings, earlier headlines are prioritised | def unique_headlines(self):
all_headlines = sorted(self.headlines, key=lambda x: x.datetime, reverse=True)
unique_headlines = list(dict((headline.headline_string, headline)
for headline in all_headlines).values())
return HeadlineData(unique_headlines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_headlines(self):\r\n\t\tlist_vals = list(self.keyword_headlines().values())\r\n\t\tuniq_headlines = set()\r\n\t\tfor list_val in list_vals:\r\n\t\t\tfor headlineobj in list_val:\r\n\t\t\t\tuniq_headlines.add(headlineobj.headlineid.content)\r\n\r\n\t\treturn list(uniq_headlines)",
"def get_headline_da... | [
"0.6820705",
"0.6815593",
"0.6498385",
"0.64366025",
"0.624847",
"0.61253214",
"0.60052425",
"0.5996817",
"0.59815514",
"0.5980182",
"0.59105253",
"0.58502215",
"0.5844797",
"0.5818052",
"0.58074373",
"0.5667856",
"0.5662274",
"0.5652105",
"0.56487715",
"0.56465113",
"0.55723... | 0.8398993 | 0 |
Helper function to set matplotlib's fontsize | def set_matplotlib_font_size(SMALL_SIZE = 8, MEDIUM_SIZE = 10, BIGGER_SIZE = 12):
plt.rc('font', size=SMALL_SIZE) # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_font_size():\n SMALLER_SIZE = 10\n MED_SIZE = 12\n BIG_SIZE = 18\n\n # plt.rc('font', size=SMALL_SIZE) # controls default text sizes\n plt.rc('axes', titlesize=MED_SIZE) # fontsize of the axes title\n plt.rc('axes', labelsize=MED_SIZE) # fontsize of the x and y labels\n ... | [
"0.8269334",
"0.80497575",
"0.79228544",
"0.788619",
"0.758933",
"0.7321905",
"0.725531",
"0.7250982",
"0.7186205",
"0.7086215",
"0.70619494",
"0.698588",
"0.6977874",
"0.67436594",
"0.6682817",
"0.6660538",
"0.6604063",
"0.6553635",
"0.6547028",
"0.65100497",
"0.646776",
"... | 0.81820697 | 1 |
Return True if 'labels' key defined in self.mapper. Here, we ensure that the mapper object has the minimal structure required by Alert Manager. Returns | def _check_for_labels(self):
check = True
if 'labels' not in self.mapper:
check = False
return check | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def labels(self) -> bool:\n return self._labels",
"def need_labels(self) -> bool:\n return False",
"def need_labels(self) -> bool:\n return False",
"def need_labels(self) -> bool:\n return True",
"def has_label(self):\n return self.label is not None",
"def has_label(sel... | [
"0.71797335",
"0.7143389",
"0.7143389",
"0.71200943",
"0.6846532",
"0.6631556",
"0.6579304",
"0.64803785",
"0.64736927",
"0.64712334",
"0.6462979",
"0.6402856",
"0.6402856",
"0.6402856",
"0.6402856",
"0.6402856",
"0.6402856",
"0.6402856",
"0.6394421",
"0.6394421",
"0.63181996... | 0.84790576 | 0 |
Get all the tags that are not assigned to a section. | def get_unassigned_tags(**kwargs):
return Tags.get_unassigned_tags(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_tags(self) -> dict:\n\n return {t: self.tags[t] for t in (self.tags or {}) if t.startswith('~')} or None",
"def non_archived_tags(self):\n non_archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').objects.non_archived().filter(trait=self)\n return apps.get_model('tags', 'T... | [
"0.6573414",
"0.64816797",
"0.64758956",
"0.63697666",
"0.6319512",
"0.6265631",
"0.6138177",
"0.6078653",
"0.5988606",
"0.5988606",
"0.59855694",
"0.5939488",
"0.59225035",
"0.59121907",
"0.5897471",
"0.58619463",
"0.58394897",
"0.58229274",
"0.58196884",
"0.5789871",
"0.578... | 0.7073977 | 0 |
Updates a plant's current name. | def update_plant_name(plant_id, name):
Plants.query.filter_by(id=plant_id).update(dict(name=name))
db.session.commit()
return Plants.get_names() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_name(self,new_name):\n self.name = new_name",
"def update_name(self, new_name):\r\n self.__name = new_name",
"def update_name(self, new_name):\r\n self.__name = new_name",
"def updateName(self,name):\n self.name = name",
"def set_name(self, newname=\"\"):\n self.n... | [
"0.7064339",
"0.68576795",
"0.68576795",
"0.6740121",
"0.6716291",
"0.65299904",
"0.64439076",
"0.62124974",
"0.6133991",
"0.6129149",
"0.61110383",
"0.6107806",
"0.6102509",
"0.60745543",
"0.60745543",
"0.6057166",
"0.6035733",
"0.60302144",
"0.6029787",
"0.6026253",
"0.6000... | 0.7565764 | 0 |
Generate a bigaussian distributed distribution. | def bigaussian(
n_particles: int,
mean: Tuple[float, float, float, float, float],
geometric_emittance_h: float,
geometric_emittance_v: float,
sigma_p: float,
) -> np.array:
cov = np.diag(
(
geometric_emittance_h,
geometric_emittance_h,
geometric_emitta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n (x - mu) / sigma, 2) / 2)",
"def gaussian_gen(ngaussian, nd, batchSize, seed, random=True):\n torch.manual_seed(seed)\n np.ra... | [
"0.7409804",
"0.6982354",
"0.6864934",
"0.68245196",
"0.68166125",
"0.6594961",
"0.65641946",
"0.6520326",
"0.651355",
"0.650837",
"0.6494215",
"0.64442414",
"0.6380185",
"0.6379187",
"0.63638943",
"0.6359884",
"0.6359002",
"0.635799",
"0.6340922",
"0.63388795",
"0.63266563",... | 0.7133675 | 1 |
Returns configuration of the active application. | def get_settings():
return SettingCollection.build() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_config(self):\n return self._app_conf[\"aiscalator\"]",
"def config(self):\n return self[CONFIG_KEY]",
"def get_config():\n app = NbConvertApp()\n app.load_config_file()\n return app.config",
"def get_config(self):\n return self.config",
"def get_config():\n return ... | [
"0.8120649",
"0.77481765",
"0.77226025",
"0.7534413",
"0.7485806",
"0.73956347",
"0.7376371",
"0.7373471",
"0.73340064",
"0.73169494",
"0.7294478",
"0.72712535",
"0.72651696",
"0.7241151",
"0.72198135",
"0.7218865",
"0.7218865",
"0.7201695",
"0.71903515",
"0.71903515",
"0.719... | 0.0 | -1 |
Split the given pandas DataFrame into many slices. | def get_slices(all_texts_df: pd.DataFrame,
slice_length: int = 25,
overlap_percent: float = 0) -> pd.DataFrame:
if overlap_percent >= 1 or overlap_percent < 0:
raise ValueError("Invalid overlap amount")
step = max(1, int(slice_length * (1 - overlap_percent)))
all_sli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_df(df, n_chunks):\n chunk_size = int(np.ceil(df.shape[0] / n_chunks))\n assert n_chunks * chunk_size >= df.shape[0]\n chunks = []\n for i in range(0, df.shape[0], chunk_size):\n chunks.append(df[i:i + chunk_size])\n assert len(chunks) == n_chunks\n return chunks",
"def split_da... | [
"0.7289702",
"0.72259223",
"0.7043013",
"0.6822769",
"0.6709902",
"0.6528461",
"0.64883214",
"0.6439159",
"0.64081824",
"0.6368322",
"0.6325749",
"0.6322713",
"0.63148636",
"0.6225795",
"0.61837626",
"0.61451566",
"0.60846883",
"0.6082403",
"0.6077513",
"0.6049462",
"0.593251... | 0.61384183 | 16 |
Get environment variable with given key , to be used to fetch sensitive info in production | def get_env_variable(var_name):
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, key):\n return os.environ[key]",
"def _get_env(key: str) -> str:\n value = os.getenv(key)\n assert isinstance(value, str), (\n f\"the {key} environment variable must be set and a string, \" f\"{value=}\"\n )\n return value",
"def env(key: str)... | [
"0.8113683",
"0.80514836",
"0.7947072",
"0.79169846",
"0.7624897",
"0.75877976",
"0.7586971",
"0.7546626",
"0.75090164",
"0.7426233",
"0.7413084",
"0.7397708",
"0.73779255",
"0.7321046",
"0.72642237",
"0.72633374",
"0.72388786",
"0.72076213",
"0.7205993",
"0.7203992",
"0.7153... | 0.69079924 | 27 |
Turn a list into an array. | def to_array(module, array, like=None):
_import_modules()
if module in [np, ma]:
if like is not None:
return module.asarray(array, dtype=like.dtype)
else:
return module.asarray(array)
elif module == torch:
if isinstance(array, torch.Tensor):
if lik... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listoflistToarray(l):\n max_dim=max([len(c) for c in l])\n all_array=[np.pad(c,(0,max_dim-len(c)),\"constant\",constant_values=(0,0)) for c in l]\n return np.array(all_array)",
"def as_array(value):\n\tif not isinstance(value, list):\n\t\treturn [value]\n\treturn value",
"def list_to_array(llist, ... | [
"0.7568045",
"0.7353453",
"0.7335708",
"0.72167104",
"0.70836496",
"0.6871827",
"0.68697774",
"0.68385994",
"0.6707813",
"0.6702284",
"0.66716486",
"0.6649649",
"0.6583473",
"0.65395176",
"0.6517272",
"0.64678884",
"0.64570946",
"0.6454708",
"0.64414173",
"0.64281493",
"0.636... | 0.0 | -1 |
Create a tensor with random values sampled from a uniform distribution. | def sample_uniform(module, shape, like=None):
_import_modules()
if module in [np, ma]:
return module.random.rand(*shape)
elif module == torch:
return module.rand(shape)
elif module == jnp:
return jax.random.uniform(_JAX_KEY, shape)
elif module == tf:
return tf.random.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randn(self, *args, **kwargs):\n # TODO: Put this in torch.cuda.randn\n return torch.empty(*args, **kwargs).normal_()",
"def uniform(random_state, size=None, low=0.0, high=1.0, ndim=None, dtype=None):\r\n low = tensor.as_tensor_variable(low)\r\n high = tensor.as_tensor_variable(high)\r\n ... | [
"0.73157173",
"0.7293668",
"0.7119648",
"0.7000716",
"0.69744015",
"0.6965755",
"0.6911757",
"0.6808739",
"0.67789054",
"0.67575526",
"0.67224276",
"0.6707129",
"0.6707129",
"0.6693818",
"0.6667518",
"0.6664173",
"0.6632252",
"0.6632252",
"0.6597723",
"0.65870976",
"0.6555167... | 0.0 | -1 |
Create a tensor with random values sampled from a Gaussian distribution. | def sample_gaussian(module, shape):
_import_modules()
if module in [np, ma]:
return module.random.randn(*shape)
elif module == torch:
return module.randn(*shape)
elif module == jnp:
return jax.random.normal(_JAX_KEY, shape)
elif module == tf:
return tf.random.normal(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_gaussian(self, probabilities):\n return tf.add(probabilities, tf.random.normal(probabilities.shape, mean=0.0, stddev=1.0))",
"def sample_gaussian(self, batch_size):\n return Variable(t.randn([batch_size, self.params.latent_variable_size])) # Dimension [batch_size x latent_dim]",
"def gaus... | [
"0.77697587",
"0.70840394",
"0.68135744",
"0.68061113",
"0.67728174",
"0.6744757",
"0.6736662",
"0.67224836",
"0.67096627",
"0.6707476",
"0.6693505",
"0.6643424",
"0.66378814",
"0.6614606",
"0.6610248",
"0.66002697",
"0.6566297",
"0.65482116",
"0.6522835",
"0.6522204",
"0.638... | 0.63366437 | 26 |
Returns the number of elements in an array. | def numel(array):
_import_modules()
module_name = type(array).__module__.split(".")[0]
if module_name in ["numpy", "numpy.ma.core"]:
return array.size
elif module_name == "torch":
return array.numel()
elif module_name.split(".")[0] == "jax":
return array.size
elif module_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num(an_array):\n return an_array.size",
"def get_length(array):\n return len(list(array))",
"def length(self):\n length = 0\n a = self.array_form\n for i in xrange(len(a)):\n if a[i] != i:\n length += 1\n return length",
"def array_dimensions(ar... | [
"0.84802824",
"0.8457376",
"0.7341247",
"0.71588755",
"0.7057582",
"0.70408493",
"0.7011125",
"0.6966082",
"0.6823613",
"0.6822485",
"0.6813259",
"0.6798273",
"0.6778768",
"0.6766926",
"0.67549896",
"0.6753062",
"0.67360866",
"0.6699322",
"0.6688237",
"0.6651473",
"0.664583",... | 0.7889555 | 2 |
Expand tensor dimension along given axis. Inserts a dimension of length one at a given index of the dimension array. | def expand_dims(module, array, dimension):
_import_modules()
if module in [np, ma, jnp, tf]:
return module.expand_dims(array, dimension)
elif module == torch:
return module.unsqueeze(array, dimension)
raise UnknownModuleException(f"Module {module.__name__} not supported.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _expand(x, ndim, axis=0):\n while F.rank(x) < ndim:\n x = F.expand_dims(x, axis)\n return x",
"def _expand_dims(st, axis):\n if not isinstance(st, structured_tensor.StructuredTensor):\n return tf.expand_dims(st, axis)\n nn_axis = _expand_dims_nonnegative_axis(axis, st.rank)\n if st.rank ==... | [
"0.74598265",
"0.74379015",
"0.7166822",
"0.70967984",
"0.67555684",
"0.67080164",
"0.6513863",
"0.64670485",
"0.64477015",
"0.6404194",
"0.63297796",
"0.6265306",
"0.62519306",
"0.6250318",
"0.6177342",
"0.616622",
"0.6106818",
"0.6061636",
"0.6060349",
"0.6046901",
"0.59272... | 0.6497756 | 7 |
Pads array with 0s along given dimension. | def pad_zeros(module, array, n, dimension):
_import_modules()
if module in [np, ma, jnp, tf]:
n_dims = len(array.shape)
pad = [(0, 0)] * n_dims
pad[dimension] = (n, n)
return module.pad(array, pad, mode="constant", constant_values=0.0)
elif module == torch:
n_dims = l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padding(a, dim):\n\n return np.pad(a, (0, dim-len(a)), 'constant', constant_values=(0))",
"def zero_pad(X, padding_width, dims):\n dims = (dims) if isinstance(dims, int) else dims\n pad = [(0, 0) if idx not in dims else (padding_width, padding_width)\n for idx in range(len(X.shape))]\n ... | [
"0.77171546",
"0.75383717",
"0.73517257",
"0.7301475",
"0.7272162",
"0.72354615",
"0.71544397",
"0.7135919",
"0.7034382",
"0.68385416",
"0.67861307",
"0.67414916",
"0.6674774",
"0.6609157",
"0.65826964",
"0.6552636",
"0.65005267",
"0.6495112",
"0.6483736",
"0.64026564",
"0.63... | 0.6695748 | 12 |
Pads array with 0s along given dimension but only on left side. | def pad_zeros_left(module, array, n, dimension):
_import_modules()
if module in [np, ma, jnp, tf]:
n_dims = len(array.shape)
pad = [(0, 0)] * n_dims
pad[dimension] = (n, 0)
return module.pad(array, pad, mode="constant", constant_values=0.0)
elif module == torch:
n_dim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padding(a, dim):\n\n return np.pad(a, (0, dim-len(a)), 'constant', constant_values=(0))",
"def zero_pad(X, padding_width, dims):\n dims = (dims) if isinstance(dims, int) else dims\n pad = [(0, 0) if idx not in dims else (padding_width, padding_width)\n for idx in range(len(X.shape))]\n ... | [
"0.7484725",
"0.7463282",
"0.7010858",
"0.69778156",
"0.69318527",
"0.69208264",
"0.6914058",
"0.68918586",
"0.6864669",
"0.6853248",
"0.6691557",
"0.66712",
"0.665533",
"0.66295743",
"0.659338",
"0.6591771",
"0.6590679",
"0.65596616",
"0.65583354",
"0.650905",
"0.6469959",
... | 0.6935757 | 4 |
Reshape array into given shape. | def reshape(module, array, shape):
_import_modules()
if module in [np, ma, torch, jnp]:
return array.reshape(shape)
if module == tf:
return tf.reshape(array, shape)
raise UnknownModuleException(f"Module {module.__name__} not supported.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape(x, shape):\n return Reshape(shape)(x)",
"def numpyReshape(array):\n return np.array(array, dtype = float).reshape(1, len(array))",
"def reshape(self, *shape):\n return F.Reshape.apply(self, shape)",
"def reshape(x, shape):\n if x.shape == shape:\n return chainer.as_vari... | [
"0.81575006",
"0.81534636",
"0.7557553",
"0.7513411",
"0.73801166",
"0.69971496",
"0.6988502",
"0.6981128",
"0.69777185",
"0.6970711",
"0.69420993",
"0.6909219",
"0.68312854",
"0.6825613",
"0.66678077",
"0.6619174",
"0.6607484",
"0.65642637",
"0.6549527",
"0.6544459",
"0.6512... | 0.67253315 | 14 |
Cumulative sum along given axis. | def cumsum(module, y, dimension):
_import_modules()
if module in [np, ma, torch, jnp]:
return module.cumsum(y, axis=dimension)
elif module == tf:
return tf.math.cumsum(y, dimension) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumsum(x, axis=None):\r\n return CumsumOp(axis=axis)(x)",
"def cumsum(tensor, axis=None):\n raise NotImplementedError",
"def cumsumr(x, axis=0):\n cums = x.cumsum(axis=axis)\n return cums - np.maximum.accumulate(cums*(x == 0), axis=axis)",
"def exclusive_cumsum(x):\n return torch.cumsu... | [
"0.864678",
"0.82058203",
"0.77805966",
"0.70134944",
"0.7000461",
"0.69337815",
"0.69337815",
"0.69337815",
"0.68563426",
"0.67117774",
"0.67117774",
"0.67117774",
"0.6633112",
"0.658497",
"0.6572482",
"0.65386045",
"0.65087646",
"0.65045345",
"0.64843714",
"0.64836526",
"0.... | 0.6964593 | 5 |
Cumulative integral along given axis. The returned tensor has the same shape as the input tensor y and the values correspond to the numeric integral computed up to the corresponding value of the provided x vector assuming that the function described by y is 0 outside of the domain described by x. | def cumtrapz(module, y, x, dimension):
n = len(y.shape)
if len(x.shape) < n:
x_shape = [1] * n
x_shape[dimension] = -1
x = reshape(module, x, x_shape)
selection = [slice(0, None)] * n
selection_l = selection[:]
selection_l[dimension] = slice(0, -1)
selection_l = tuple(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumsum(x, axis=None):\r\n return CumsumOp(axis=axis)(x)",
"def cumsum(tensor, axis=None):\n raise NotImplementedError",
"def cumprod(x, axis=None):\r\n return CumprodOp(axis=axis)(x)",
"def integral (self):\n dx = self.xbins[1] - self.xbins[0]\n dy = self.ybins[1] - self.ybins[... | [
"0.66349554",
"0.64732975",
"0.61775166",
"0.6121769",
"0.5936893",
"0.5786177",
"0.57451797",
"0.56903416",
"0.56903416",
"0.55951786",
"0.55480087",
"0.55378985",
"0.5534657",
"0.55333686",
"0.55297697",
"0.5508116",
"0.5484488",
"0.54308665",
"0.53933036",
"0.53920734",
"0... | 0.65004003 | 1 |
Zero tensor of given shape. | def zeros(module, shape, like=None):
_import_modules()
if module in [np, ma]:
if like is not None:
return module.zeros(shape, dtype=like.dtype)
else:
return module.zeros(shape)
elif module == torch:
if like is not None:
return module.zeros(shape, d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros(*shape, **kwargs):\n return Tensor(np.zeros(shape), **kwargs)",
"def zeros(shape, dtype=np.float32, constant=False):\n return Tensor(np.zeros(shape, dtype), constant=constant)",
"def empty(*shape, **kwargs):\n return Tensor(np.empty(shape), **kwargs)",
"def zero_init(self, shape):\... | [
"0.86172",
"0.81691533",
"0.8076792",
"0.79162407",
"0.78029114",
"0.779051",
"0.7737803",
"0.7691821",
"0.7689271",
"0.74238396",
"0.7397194",
"0.7289919",
"0.7249829",
"0.71769655",
"0.71769655",
"0.7165198",
"0.71602905",
"0.713397",
"0.71316004",
"0.70045686",
"0.6989378"... | 0.65631366 | 41 |
Apply softmax to tensor. | def softmax(module, x, axis=None):
_import_modules()
if module in [np, ma]:
return sp.special.softmax(x, axis=axis)
elif module == torch:
return module.nn.functional.softmax(x, dim=axis)
elif module == jnp:
return jax.nn.softmax(x, axis=axis)
elif module == tf:
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(input, dim, inplace=False):\n return FunctionLib.apply(\n 'Softmax', input.device, [input],\n outputs=[input if inplace else None], axis=dim)",
"def softmax(x, name):\n with tf.name_scope(name):\n outputs = tf.nn.softmax (x)\n # Return layer's output\n ... | [
"0.82138926",
"0.7878136",
"0.7862258",
"0.7862258",
"0.778104",
"0.7779031",
"0.775454",
"0.7753965",
"0.7741438",
"0.7716395",
"0.76876825",
"0.76786315",
"0.7678608",
"0.76718044",
"0.76555455",
"0.7650781",
"0.7624002",
"0.7606311",
"0.7598807",
"0.75922066",
"0.7576398",... | 0.0 | -1 |
Apply elementwise sigmoid to tensor. | def sigmoid(module, x):
_import_modules()
if module in [np, ma]:
return sp.special.sigmoid(x)
elif module == torch:
return module.sigmoid(x)
elif module == jnp:
return jax.nn.sigmoid(x)
elif module == tf:
return module.nn.sigmoid(x)
raise UnknownModuleException(f"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tanh_sigmoid(tensor):\n return 2 * sigmoid(2 * tensor) - 1",
"def sigmoid(input, inplace=False):\n return FunctionLib.apply(\n 'Sigmoid', input.device, [input],\n outputs=[input if inplace else None])",
"def sigmoid(X,W,b):\n preActivation = np.dot(X, W) + b\n return (1.0)/(1.0 +... | [
"0.8145814",
"0.7797516",
"0.76440203",
"0.7602396",
"0.76020575",
"0.75872725",
"0.75862736",
"0.75862736",
"0.75862736",
"0.75862736",
"0.75862736",
"0.75862736",
"0.75843424",
"0.7574853",
"0.7566171",
"0.75537324",
"0.75532055",
"0.7541103",
"0.7519647",
"0.7500285",
"0.7... | 0.0 | -1 |
Calculate tensor product of two tensors. | def tensordot(module, x, y, axes):
_import_modules()
if module in [np, ma]:
return np.tensordot(x, y, axes)
elif module == torch:
return torch.tensordot(x, y, axes)
elif module == jnp:
return jnp.tensordot(x, y, axes)
elif module == tf:
return tf.tensordot(x, y, axes)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tensor_outer_product(tensor1, tensor2):\n shape_1 = tensor1.shape\n shape_2 = tensor2.shape\n s1 = len(shape_1)\n s2 = len(shape_2)\n \n shape_1 = shape_1 + (1, )*s2\n shape_2 = (1, )*s1 + shape_2\n return np.reshape(tensor1, shape_1) * np.reshape(tensor2, shape_2)",
"def dot_prod(t1:... | [
"0.76992655",
"0.73948306",
"0.7307781",
"0.7241054",
"0.7083914",
"0.70663244",
"0.6997964",
"0.69520754",
"0.6915371",
"0.6895068",
"0.68881345",
"0.68570966",
"0.6854352",
"0.6849153",
"0.682718",
"0.6788505",
"0.67755437",
"0.67665565",
"0.67539734",
"0.6716716",
"0.67145... | 0.0 | -1 |
Sparse addition of values in y to given indices in x. | def scatter_add(module, x, indices, y, axis):
if module in [np, ma, torch, tf]:
selection_out = [slice(0, None)] * x.ndim
selection_in = [slice(0, None)] * y.ndim
for i, ind in enumerate(indices):
if (ind >= 0) and (ind < x.shape[axis]):
selection_out[axis] = ind
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(x, y):\r\n\r\n if hasattr(x, 'getnnz'):\r\n x = as_sparse_variable(x)\r\n if hasattr(y, 'getnnz'):\r\n y = as_sparse_variable(y)\r\n if not isinstance(x, theano.Variable):\r\n x = theano.tensor.as_tensor_variable(x)\r\n if not isinstance(y, theano.Variable):\r\n y = ... | [
"0.6675319",
"0.6379162",
"0.6367725",
"0.6231337",
"0.61930513",
"0.60226834",
"0.5982063",
"0.5982063",
"0.5975119",
"0.594403",
"0.5930772",
"0.59142876",
"0.5898049",
"0.5886552",
"0.586769",
"0.58669007",
"0.5864347",
"0.58437395",
"0.58408755",
"0.5796749",
"0.57539004"... | 0.5604872 | 21 |
Create and save a User with the given email and password. | def _create_user(self, email, password, **extra_fields):
if not email:
raise ValueError('The given email must be set')
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user",
"def... | [
"0.85437864",
"0.8511318",
"0.85077024",
"0.8502027",
"0.85019606",
"0.84882575",
"0.84882575",
"0.84882575",
"0.84854496",
"0.84765774",
"0.84759104",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8474798",
"0.8456341",
"0.8456... | 0.84889764 | 5 |
Normalize the email address by lowercasing the domain part of it. | def normalize_email(cls, email):
email = email or ''
try:
email_name, domain_part = email.strip().rsplit('@', 1)
except ValueError:
pass
else:
email = email_name + '@' + domain_part.lower()
return email or None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normalize_email_address(email_address: str) -> str:\n normalized = email_address.strip().lower()\n\n if not normalized or (' ' in normalized) or ('@' not in normalized):\n raise ValueError(f\"Invalid email address: '{email_address}'\")\n\n return normalized",
"def clean_email(email: str):\n ... | [
"0.820583",
"0.7434962",
"0.73419076",
"0.7272315",
"0.72139174",
"0.71126217",
"0.7111194",
"0.70998865",
"0.6933385",
"0.68583465",
"0.6845081",
"0.6819853",
"0.6756933",
"0.6726061",
"0.664631",
"0.66195184",
"0.66144216",
"0.66091055",
"0.65857416",
"0.6583048",
"0.652391... | 0.7894862 | 1 |
Plots the grid of images generated from final model | def plot_final_grid(generated_images):
fig = plt.figure(figsize=(GRID_SIZE, GRID_SIZE))
fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.001, hspace=0.001)
for ind in range(GRID_IMGS):
ax = fig.add_subplot(GRID_SIZE, GRID_SIZE, ind + 1, xticks=[], yticks=[])
ax.im... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_final_grid(generated_images):\n\n fig = plt.figure(figsize=(8, 6))\n fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.001, hspace=0.001)\n\n for ind in range(GRID_IMGS):\n ax = fig.add_subplot(GRID_SIZE, GRID_SIZE, ind + 1, xticks=[], yticks=[])\n ax.imshow... | [
"0.7727987",
"0.76496446",
"0.75795865",
"0.74211293",
"0.72157186",
"0.7159313",
"0.7065887",
"0.7062384",
"0.70465016",
"0.7040103",
"0.7029202",
"0.70169634",
"0.6988956",
"0.6946804",
"0.69443965",
"0.6935759",
"0.6915634",
"0.69137424",
"0.6909667",
"0.6909667",
"0.69092... | 0.7852281 | 0 |
Plots the grid of images generated from final model | def plot_final_grid(generated_images):
fig = plt.figure(figsize=(8, 6))
fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.001, hspace=0.001)
for ind in range(GRID_IMGS):
ax = fig.add_subplot(GRID_SIZE, GRID_SIZE, ind + 1, xticks=[], yticks=[])
ax.imshow(np.uint8(((... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_final_grid(generated_images):\n\n fig = plt.figure(figsize=(GRID_SIZE, GRID_SIZE))\n fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.001, hspace=0.001)\n\n for ind in range(GRID_IMGS):\n ax = fig.add_subplot(GRID_SIZE, GRID_SIZE, ind + 1, xticks=[], yticks=[])\n ... | [
"0.7853607",
"0.7651442",
"0.75816244",
"0.742085",
"0.7215919",
"0.7160057",
"0.7066514",
"0.7060876",
"0.7049062",
"0.7042223",
"0.70302474",
"0.7017314",
"0.69905573",
"0.69450766",
"0.69448805",
"0.69372225",
"0.691533",
"0.6914608",
"0.69114715",
"0.69114715",
"0.6909743... | 0.77292514 | 1 |
Calculate the heuristic value of a game state from the point of view of the given player. | def open_positions_score(game, player):
moves = game.get_legal_moves()
side_coef = 1 if player == game.active_player else -1
if len(moves) == 0:
result = float("-inf")
else:
result = len(moves)
return float(result*side_coef) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def utility(self, state, player):\n if state.isWin() or state.isLose():\n return state.getScore()\n\n # In case of cycle.\n if player == PACMAN:\n return INFINITY\n else:\n return -INFINITY",
"def calculate_utility(state, player):\n thisPlayer = pla... | [
"0.7160031",
"0.7126443",
"0.6840133",
"0.6816918",
"0.67986786",
"0.65901345",
"0.6581988",
"0.6449993",
"0.64499426",
"0.6436957",
"0.6435461",
"0.6433362",
"0.6419876",
"0.64143103",
"0.6406242",
"0.6401132",
"0.63523954",
"0.63402605",
"0.6339346",
"0.6311418",
"0.6307777... | 0.5773131 | 79 |
Sort shuffled list of cards, sorted by rank. >>> sort_cards(['3', '9', 'A', '5', 'T', '8', '2', '4', 'Q', '7', 'J', '6', 'K']) ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'] | def sort_cards(cards):
cards = sorted(list(cards))
acount = cards.count('A')
tcount = cards.count('T')
jcount = cards.count('J')
qcount = cards.count('Q')
kcount = cards.count('K')
for numa in range(acount):
cards.remove('A')
for numa in range(acount):
cards.insert(0, 'A'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_cards(self):\n self.cards.sort(key=operator.attrgetter('persona', 'rank'))\n self.update_position()",
"def card_ranks(cards):\n ranks = [\"--23456789TJQKA\".index(r) for r,s in cards] # Each card contains a rank and a suit, hand/cards == [(11, 'Q'), (9, 'D')] \n # Using a \"Rank St... | [
"0.7058909",
"0.66526777",
"0.6629813",
"0.64443755",
"0.6418277",
"0.6418277",
"0.640872",
"0.6222718",
"0.6196182",
"0.60838675",
"0.6004446",
"0.5998435",
"0.59595394",
"0.59177536",
"0.5716157",
"0.5713705",
"0.5634322",
"0.55832237",
"0.55583453",
"0.548072",
"0.5448527"... | 0.6707716 | 1 |
Create a simple linked list. | def simple_ll():
ll = LinkedList()
ll.push(20)
ll.push(4)
ll.push(15)
ll.push(85)
return ll | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lined_list_create_with_non_iterable():\n from linked_list import Linked_List\n new_linked_list = Linked_List(-100)\n assert new_linked_list.head.value == -100",
"def __init__(self):\n node = ListNode(0) # dummy\n self.head = node\n self.tail = node\n self.len = 0",
... | [
"0.73371357",
"0.7330096",
"0.7170844",
"0.7111012",
"0.7081536",
"0.7005132",
"0.6987626",
"0.6952199",
"0.6951812",
"0.6905778",
"0.6889222",
"0.6811711",
"0.6745294",
"0.6720752",
"0.67197055",
"0.66435957",
"0.66435957",
"0.66435957",
"0.66435957",
"0.66435957",
"0.663845... | 0.7760551 | 0 |
Advance the iterator nsteps ahead. If n is None, consume entirely. | def consume(iterator, n=None):
# Use functions that consume iterators at C speed.
if n is None:
# feed the entire iterator into a zero-length deque
collections.deque(iterator, maxlen=0)
else:
# advance to the empty slice starting at position n
next(islice(iterator, n, n), Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance(self, n):\n return _elas.SwigPyIterator_advance(self, n)",
"def consume(iterator, n=None, next=next, islice=islice, deque=deque):\n if n is not None:\n next(islice(iterator, n, n), None)\n else:\n exhaust(iterator)",
"def skip(self, n=None):\n while n > 0:\n ... | [
"0.74568206",
"0.7361216",
"0.7142135",
"0.6947827",
"0.6866517",
"0.6795257",
"0.6785379",
"0.6707773",
"0.6626332",
"0.65798295",
"0.6541862",
"0.64764965",
"0.642196",
"0.6421762",
"0.63521117",
"0.63086236",
"0.63065034",
"0.6246783",
"0.6222006",
"0.62043965",
"0.6199799... | 0.69244874 | 4 |
Update loaders dict to allow for extensible loader functionality. Returns a class/function that performs transformation and loads graph. | def _init_loaders(self):
@self.loaders_wrapper("nx2nx")
def get_nx2nx_loader(extractor, stream, transformers, graph):
"""
:param tranformers: List of dicts.
:extractor: function.
:param graph: networkx.Graph
:returns: projx.nx_loader
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_loader(self, *args, **kwargs):\n def loader():\n return self.load(*args, **kwargs)\n return loader",
"def loader(self):\n return self.loader_class()",
"def load_later(klass, name, load_func, *a, **kw):\n m = klass(name)\n m._loaded = False\n m._lo... | [
"0.63111156",
"0.6309476",
"0.6234799",
"0.62327635",
"0.6141865",
"0.6137516",
"0.60131127",
"0.58616364",
"0.5855201",
"0.5843506",
"0.58341694",
"0.5794473",
"0.57540494",
"0.5754032",
"0.5711285",
"0.5701592",
"0.56229484",
"0.5612075",
"0.55899227",
"0.55874485",
"0.5583... | 0.7325456 | 0 |
Separate the data into train and test according to the proportion | def split_test_and_train_data(self, test_size=0.3, view=0):
X_train, X_test, y_train, y_test = train_test_split(self.data[view], self.class_data, test_size=test_size)
return X_train, X_test, y_train, y_test | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_dev_test_split(data, train_pct=0.7):\n train_len, dev_len, test_len = create_split_bounds(len(data), train_pct)\n\n # Train (70%)\n train = data[0:train_len]\n\n # Dev (15%)\n dev_ub = (train_len + dev_len)\n dev = data[train_len:dev_ub]\n\n # Test (15%)\n test = data[dev_ub:]\n\n... | [
"0.73670703",
"0.7257811",
"0.7230635",
"0.7175592",
"0.71174973",
"0.71080244",
"0.70670545",
"0.705822",
"0.70348203",
"0.70279163",
"0.7021876",
"0.7020428",
"0.7018304",
"0.7011291",
"0.7011139",
"0.7010701",
"0.700252",
"0.6996773",
"0.697722",
"0.6975688",
"0.6971831",
... | 0.6959464 | 22 |
Calculate apriori probability based on crisp partition provided to the class | def calculate_class_apriori_probability(self, class_name):
unique, counts = np.unique(self.class_data, return_counts=True)
frequency_dict = dict(zip(unique, counts))
return float(frequency_dict[class_name])/len(self.class_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_overall_probability(self, x, expected_class):\n class_probability = self.calculate_class_apriori_probability(expected_class)\n view1_probability = self.check_probability(x[0], self.best_neighbours[0], expected_class, self.mfeat_fac_classifier, 0)\n view2_probability = self.check_prob... | [
"0.6390953",
"0.61655647",
"0.6162406",
"0.61446303",
"0.61107683",
"0.6089254",
"0.6048693",
"0.603507",
"0.6027028",
"0.6022073",
"0.5978051",
"0.59746134",
"0.5903609",
"0.5885098",
"0.5882223",
"0.58703727",
"0.58620393",
"0.585604",
"0.58487207",
"0.57808757",
"0.577681"... | 0.687434 | 0 |
Retur the output tensor at the given index. | def get_output_tensor(self, index):
output_details = self.model.get_output_details()[index]
tensor = np.squeeze(self.model.get_tensor(output_details['index']))
return tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_output_tensor(index):\n output_details = interpreter.get_output_details()[index]\n tensor = np.squeeze(interpreter.get_tensor(output_details['index']))\n return tensor",
"def get_output_tensor(self, index):\n output_details = self.interpreter.get_output_details()[index]\n tensor = ... | [
"0.8085678",
"0.80498403",
"0.80234796",
"0.7798135",
"0.7762317",
"0.7762317",
"0.7762317",
"0.70501757",
"0.7009183",
"0.66079545",
"0.6346569",
"0.61886317",
"0.618703",
"0.6052512",
"0.6041594",
"0.60324305",
"0.6031598",
"0.602657",
"0.6019419",
"0.59992254",
"0.5987431"... | 0.8095785 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.