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 |
|---|---|---|---|---|---|---|
Particle Simulator class initializer. | def __init__(self, particles):
self.particles = particles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,particle):\n self.par = particle",
"def init_particles(self):\n \n # Each particle is a dimension-K vector. We generate each particle \n # uniformly at random from the space [0,1]^K. \n self.Particles = np.random.uniform(0, 1, (self.Npar, self.K))\n #pr... | [
"0.75888294",
"0.71007025",
"0.70766026",
"0.70633173",
"0.6970787",
"0.69264394",
"0.68790823",
"0.681414",
"0.6796707",
"0.6731174",
"0.67066044",
"0.6701006",
"0.66263753",
"0.6609181",
"0.6585009",
"0.6580443",
"0.65549845",
"0.6544572",
"0.6502128",
"0.6500652",
"0.64466... | 0.7820965 | 0 |
Custom initializer closure for visualizer function. | def _init():
line.set_data([], [])
return line, | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_visualization(self) -> None:\n pass",
"def _plot_init(self):\n pass",
"def _plot_init(self):\n pass",
"def __init__(self, calcGrad, calcCost, input, alpha = 0.01):\n \n\tVisualizer.__init__(self, calcGrad, calcCost, input)\n\n\tself.alpha = alpha",
"def __init__(s... | [
"0.702511",
"0.6954049",
"0.6954049",
"0.66605836",
"0.6644008",
"0.6615155",
"0.6610074",
"0.65134645",
"0.6408052",
"0.6371969",
"0.6239919",
"0.6182451",
"0.61585945",
"0.60655004",
"0.6060406",
"0.6023605",
"0.6008714",
"0.59871906",
"0.59633356",
"0.59622073",
"0.5938787... | 0.0 | -1 |
Compare two types If types are sorted they are sorted first by level and then by name. | def __cmp__(self, other):
if isinstance(other, BaseType):
return cmp(self.level, other.level) or cmp(self.name, other.name)
else:
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sort_by_type(self, x, y):\n\n x_key, x_value = x\n y_key, y_value = y\n\n # if both values are map or list, sort by their keys\n if ((isinstance(x_value, schema.Map) or\n isinstance(x_value, schema.List)) and\n (isinstance(y_value, schema.Map) or\n ... | [
"0.70591813",
"0.6644227",
"0.6600623",
"0.6123862",
"0.6116717",
"0.61091506",
"0.6001275",
"0.59808797",
"0.59322023",
"0.5888874",
"0.5815527",
"0.57383543",
"0.57324827",
"0.5702648",
"0.5655841",
"0.5655841",
"0.5607537",
"0.55173254",
"0.55121386",
"0.5468389",
"0.54185... | 0.76405925 | 0 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
account_id = dictionary.get('accountId')
conference_id = dictionary.get('conferenceId')
name = dictionary.get('name')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.0 | -1 |
Constructs user's full name. | def full_name(self) -> str:
name = f'{self.last_name} {self.first_name}'
if self.middle_name:
name += ' ' + self.middle_name
return name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(self):\n return \"{} {}\".format(self.user.first_name, self.user.last_name)",
"def get_user_name(self):\n full_name = f'{self.f_name} {self.l_name}'\n return full_name",
"def get_full_name(self):\n full_name = f'{self.first_name} {self.last_name}' if self.first_name an... | [
"0.84534734",
"0.83821994",
"0.83503187",
"0.8320419",
"0.8045144",
"0.80098945",
"0.7976398",
"0.7968557",
"0.78517073",
"0.7833827",
"0.7833827",
"0.7833827",
"0.7796572",
"0.7757046",
"0.7757046",
"0.77559483",
"0.77527565",
"0.77037877",
"0.7700808",
"0.7700808",
"0.76985... | 0.7604106 | 61 |
Constructs user's short name (without patronymic). | def short_name(self) -> str:
return f'{self.last_name} {self.first_name}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_short_name(self):\n return f\"{self.first_name} {self.last_name[:1]}\" if self.first_name else self.username",
"def full_name_short(self):\n return \"{}. {}\".format(str(self.user.first_name)[:1], self.user.last_name)",
"def get_short_name(self):\n return self.username",
"def get... | [
"0.8210496",
"0.80097234",
"0.76470584",
"0.76470584",
"0.76470584",
"0.7540555",
"0.74721557",
"0.7376342",
"0.73590374",
"0.7336084",
"0.7305123",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087",
"0.7291087... | 0.79778725 | 2 |
Get the amount due on the given billing cycle For regular recurring costs this is simply `fixed_amount`. For oneoff costs this is the portion of `fixed_amount` for the given billing_cycle. | def get_amount_normal(self, billing_cycle):
if self.is_one_off():
billing_cycle_number = self._get_billing_cycle_number(billing_cycle)
if billing_cycle_number > self.total_billing_cycles:
# A future billing cycle after this one has ended
return Decimal('0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fine_due(self):\n fine = 0\n ndays = (dt.datetime.now() - self._checkout_date).days\n ndays_over = ndays - self.loantime\n if ndays_over > 0:\n fine += (ndays_over * self.finerate)\n return fine",
"def get_fee(self):\n fee = round(self.order_payment.am... | [
"0.58929443",
"0.57817584",
"0.56708753",
"0.56132084",
"0.5561824",
"0.55495286",
"0.5514481",
"0.53966284",
"0.53872204",
"0.538525",
"0.53463763",
"0.53450346",
"0.53301275",
"0.5305127",
"0.5276047",
"0.5253233",
"0.5222744",
"0.5213835",
"0.5174006",
"0.5166616",
"0.5083... | 0.7624496 | 0 |
Get the total amount billed so far | def get_billed_amount(self):
return Leg.objects.filter(transaction__recurred_cost__recurring_cost=self, amount__gt=0).sum_to_balance() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_paid(self):\n return sum(self.paid)",
"def get_total_supply() -> int:\n return total_supply",
"def _total_d(self):\n debit = 0.0\n for l in self.data:\n debit += l['debit']\n self.t_credit += l['credit']\n self.t_balance += l['balance']\n ... | [
"0.7370375",
"0.7272581",
"0.7162921",
"0.70798266",
"0.7075365",
"0.7055413",
"0.7042702",
"0.69820285",
"0.69287443",
"0.6896828",
"0.6893169",
"0.68846095",
"0.68569374",
"0.68366766",
"0.6827002",
"0.6819471",
"0.6818823",
"0.6801697",
"0.6789565",
"0.678531",
"0.6781878"... | 0.78803813 | 0 |
Has this recurring cost already enacted transactions for given billing cycle? | def has_enacted(self, billing_cycle):
return RecurredCost.objects.filter(
recurring_cost=self,
billing_cycle=billing_cycle,
).exists() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enact(self, billing_cycle, disable_if_done=True):\n as_of = billing_cycle.date_range.lower\n if not self.is_enactable(as_of):\n raise CannotEnactUnenactableRecurringCostError(\n \"RecurringCost {} is unenactable.\".format(self.uuid)\n )\n\n if self.has_... | [
"0.62638986",
"0.6067549",
"0.5936081",
"0.590648",
"0.5876808",
"0.5854577",
"0.5853818",
"0.5850467",
"0.58426255",
"0.5818747",
"0.5761081",
"0.5725485",
"0.5713025",
"0.56949985",
"0.5693796",
"0.5662111",
"0.5642745",
"0.56197953",
"0.5599373",
"0.55939776",
"0.5590682",... | 0.85943073 | 0 |
Is the RecurringCost ready to be enacted as of the date `as_of` This determines if `as_of` precedes the start of `initial_billing_cycle`. If so, we should not be enacting this RecurringCost yet. | def _is_ready(self, as_of):
if self.is_one_off():
return self.initial_billing_cycle.date_range.lower <= as_of
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_finished(self, as_of):\n if self.is_one_off():\n last_billing_cycle = self.get_billing_cycles()[self.total_billing_cycles - 1]\n return last_billing_cycle.date_range.upper <= as_of\n else:\n return False",
"def is_enactable(self, as_of):\n return \\\n... | [
"0.7337855",
"0.672307",
"0.6038199",
"0.58594894",
"0.58151066",
"0.57894814",
"0.5738601",
"0.57383454",
"0.5730905",
"0.5650643",
"0.56272036",
"0.5619895",
"0.5544008",
"0.55327904",
"0.545116",
"0.5443598",
"0.5400708",
"0.53757477",
"0.53706473",
"0.52968764",
"0.525970... | 0.8089435 | 0 |
Get a list of subscriptions. | def list_subscriptions(
connection, project_id, fields=None, offset=0, limit=-1, error_msg=None
):
return connection.get(
url=f'{connection.base_url}/api/subscriptions',
params={'offset': offset, 'limit': limit, 'fields': fields},
headers={'X-MSTR-ProjectID': project_id},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(cls, **kwargs):\n response = Yola().list_subscriptions(**kwargs)\n return [cls(**sub) for sub in response['results']]",
"def get_subscriptions(self):\n url = '{}/v2/subscriptions'.format(self.url)\n r = requests.get(url, headers=self.headers_v2)\n return r.json()",
"... | [
"0.8456876",
"0.8378425",
"0.83175546",
"0.81658775",
"0.8012425",
"0.78989965",
"0.789842",
"0.7794796",
"0.777386",
"0.77041095",
"0.76440823",
"0.7617931",
"0.7599874",
"0.7570641",
"0.7552839",
"0.7477382",
"0.7438582",
"0.73941374",
"0.7349831",
"0.73373795",
"0.7332646"... | 0.76252115 | 11 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
city = handle_invalid_inputs(question_1, cities)
# get the user input of the filter_choosed (month, day, both, o... | {
"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.6671077",
"0.65363395",
"0.64597565",
"0.6374352",
"0.6349016",
"0.6310872",
"0.6287443",
"0.62599736",
"0.62324905",
"0.62140554",
"0.6205851",
"0.6182028",
"0.6172251",
"0.61696005",
"0.61590976",
"0.6159067",
"0.6153877",
"0.6145122",
"0.6132135",
"0.61053854",
"0.61032... | 0.0 | -1 |
Loads data for the specified city and filter_chooseds 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, day of week and hour from Start Time to create new columns
df['month'] = df['St... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n\n print(\"\\nWe are loading the information for the selected filters.\")\n start_time = time.time()\n\n # filter the data according to the selected city\n if isinstance(city, list):\n df = pd.concat(map(lambda city: pd.read_csv(CITY_DATA[city]), city),\n ... | [
"0.7835897",
"0.7778312",
"0.7736864",
"0.76643765",
"0.7651178",
"0.7630762",
"0.75672865",
"0.75457704",
"0.7517885",
"0.75130033",
"0.7508841",
"0.75048673",
"0.75047255",
"0.7492502",
"0.74908274",
"0.7489766",
"0.74863905",
"0.74766",
"0.7451038",
"0.74423254",
"0.743029... | 0.74686253 | 18 |
calculate statistics(popular entry of that column and his occurrence) on the most frequent times of travel. | def popular_counts_column(column):
popular_anything = column.mode()[0]
counts_anything = column.value_counts()[popular_anything]
return popular_anything, counts_anything | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nCalculating The Most Frequent Times of Travel...\\n')\n start_time = time.time()\n\n # TO DO: display the most common month\n pop_month = df['month'].mode()[0]\n print(\"\\nThe most popular month is: \", pop_month)\n\n # TO DO: display the most common day of ... | [
"0.73891497",
"0.7268939",
"0.7255764",
"0.72360146",
"0.7229715",
"0.722763",
"0.72122437",
"0.72108567",
"0.7209101",
"0.7192253",
"0.71706414",
"0.7165746",
"0.7158084",
"0.7136184",
"0.71185875",
"0.7116348",
"0.71153706",
"0.7110789",
"0.70996636",
"0.70900434",
"0.70880... | 0.0 | -1 |
Displays statistics on the most frequent times of travel. | def time_stats(df, filter_choosed):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# display the most common month and number of occurrence
popular_month, counts_month = popular_counts_column(df['month'])
print('The Most Popular month:{}, Counts:{},'.format(... | {
"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.80234134",
"0.80223715",
"0.7914983",
"0.78252095",
"0.7820841",
"0.7812996",
"0.77644646",
"0.7739144",
"0.7734762",
"0.77328056",
"0.7685236",
"0.7667557",
"0.76502746",
"0.7643304",
"0.76385033",
"0.7635647",
"0.7623848",
"0.7622241",
"0.7611794",
"0.75985956",
"0.75820... | 0.0 | -1 |
Displays statistics on the most popular stations and trip. | def station_stats(df, filter_choosed):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# display most commonly used start station
popular_start, counts_start = popular_counts_column(df['Start Station'])
print('Start Station:{}, Counts:{},'.format(popular_sta... | {
"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.68791133 | 89 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df, filter_choosed):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# display total travel time
total_travel_time = df['Trip Duration'].sum()
travel_number = df['Trip Duration'].size
print('Total Duration:{}, Count:{},'.format(total_travel_time, trav... | {
"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.8143788",
"0.8025597",
"0.8004826",
"0.7950089",
"0.7937902",
"0.79316837",
"0.7927231",
"0.7915687",
"0.7914976",
"0.79086065",
"0.79061425",
"0.79011726",
"0.7892046",
"0.7890013",
"0.7887204",
"0.7885618",
"0.7884607",
"0.78830457",
"0.7874646",
"0.78690827",
"0.7866999... | 0.0 | -1 |
breakdate takes a date as an argument in the format '1 Jan 2010' and returns a tuple of size 3 The tuple contains three integer values (day,month,year) | def breakdate(date):
match = re.search(r'(\d+)\s(\w+)\s(\d+)',date)
day = 0
month = ''
year = 0
if not match:
sys.stderr.write('\nError in reading date!!!\n')
sys.exit(1)
day = int(match.group(1))
month = match.group(2)
year = int(match.group(3))
month = month.lower()
if month[:3] == 'jan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_fr_date(date_str):\n day=date_str[:2]\n month=date_str[3:5]\n try:\n #date coded on 4 digits\n year=date_str[6:]\n except:\n #date coded on 2 digits\n year=date_str[4:]\n\n return year, month, day",
"def split_date(value):\n if not is_valid_date(value):\n ... | [
"0.6598065",
"0.6595321",
"0.64452714",
"0.638986",
"0.6296726",
"0.6093714",
"0.60713655",
"0.5917233",
"0.590479",
"0.58485025",
"0.5820212",
"0.5813509",
"0.5799982",
"0.57810134",
"0.57726705",
"0.57651657",
"0.5732589",
"0.5732589",
"0.5712787",
"0.57051766",
"0.5704207"... | 0.8310145 | 0 |
Return a list of slices given a window size. data twodimensional array to get slices from win_size tuple of (rows, columns) for the moving window | def make_slices(data, win_size):
rows = data.shape[0] - win_size[0] + 1
cols = data.shape[1] - win_size[1] + 1
slices = []
for i in range(win_size[0]):
for j in range(win_size[1]):
slices.append(data[i:rows+i, j:cols+j])
return slices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window_partition(x, window_size):\n B, D, H, W, C = x.shape\n x = x.view(B, D // window_size[0], window_size[0], H // window_size[1], window_size[1], W // window_size[2], window_size[2], C)\n windows = x.permute(0, 1, 3, 5, 2, 4, 6, 7).contiguous().view(-1, reduce(mul, window_size), C)\n return win... | [
"0.7538039",
"0.7155911",
"0.6879272",
"0.68104887",
"0.6692612",
"0.6602731",
"0.6598914",
"0.64973307",
"0.6451885",
"0.64080024",
"0.6405831",
"0.64051193",
"0.63839924",
"0.6376568",
"0.634974",
"0.634974",
"0.63450885",
"0.6285897",
"0.626279",
"0.6242383",
"0.62375164",... | 0.86977434 | 0 |
Assigns an xcoordinate to Statcast's strike zone numbers. Zones 11, 12, 13, and 14 are ignored for plotting simplicity. | def assign_x_coord(row):
# Left third of strike zone
if row.zone in [1, 4, 7]:
return 1
# Middle third of strike zone
if row.zone in [2, 5, 8]:
return 2
# Right third of strike zone
if row.zone in [3, 6, 9]:
return 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_xcoords():\n\n for i in range(0, Molecule.ground_species_count):\n tmp1 = (PlotParameter.species_line_spacing * i) + 0.25\n tmp2 = tmp1 + PlotParameter.species_line_length\n Molecule.left_endpt.append(tmp1)\n Molecule.right_endpt.append(tmp2)\n\n for i in range(0, Mol... | [
"0.61098456",
"0.56125766",
"0.5489498",
"0.5334161",
"0.5327206",
"0.5234576",
"0.5234576",
"0.52221256",
"0.5189216",
"0.5147536",
"0.51472515",
"0.5142789",
"0.51419747",
"0.51378345",
"0.5114462",
"0.5104202",
"0.50998604",
"0.5098071",
"0.5095633",
"0.5068346",
"0.505800... | 0.7372651 | 0 |
Assigns a ycoordinate to Statcast's strike zone numbers. Zones 11, 12, 13, and 14 are ignored for plotting simplicity. | def assign_y_coord(row):
# Upper third of strike zone
if row.zone in [1, 2, 3]:
return 3
# Middle third of strike zone
if row.zone in [4, 5, 6]:
return 2
# Lower third of strike zone
if row.zone in [7, 8, 9]:
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getYtile(ty, tz, options):\n if options.xyz:\n return (2**tz - 1) - ty # Convert from TMS to XYZ numbering system\n else:\n return ty",
"def setY(self, value):\n self.position[1] = value",
"def assign_x_coord(row):\n # Left third of strike zone\n if row.zon... | [
"0.58096725",
"0.5772599",
"0.5701568",
"0.5568827",
"0.55686414",
"0.5506698",
"0.5461601",
"0.54573405",
"0.54444265",
"0.5427887",
"0.5427887",
"0.54022944",
"0.54022944",
"0.53814405",
"0.53696835",
"0.5353724",
"0.532635",
"0.5302157",
"0.5269206",
"0.5259502",
"0.524527... | 0.730646 | 0 |
Return 1d `np.array` with int values representing each channel [R,G,B] or [R,G,B,a] if value for transparency is present. Inverse of `get_hexcode`. | def get_channels(hexcode):
assert len(hexcode) in (7, 9)
assert hexcode[0] == "#"
rgb = hexcode[1:3], hexcode[3:5], hexcode[5:7], hexcode[7:]
rgb = [int(x, 16) for x in rgb if x != ""]
return np.array(rgb, dtype=np.uint8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _colored_img_to_arr(image, verbose=False):\n height, width = image.size\n arr = np.array(image.getdata())\n arr = arr.reshape(3, height, width)\n r = arr[0]\n g = arr[1]\n b = arr[2]\n return r, g, b",
"def GetRGBArray(self, p_int):\n ...",
"def GetChannelColorRGBA(vDataSet,aInd... | [
"0.65155816",
"0.627164",
"0.6132771",
"0.60103065",
"0.6009339",
"0.6008121",
"0.59757084",
"0.59692705",
"0.5954736",
"0.5948692",
"0.5933557",
"0.59232914",
"0.5903705",
"0.5877484",
"0.58281714",
"0.5777235",
"0.57593626",
"0.57127875",
"0.57086354",
"0.56859374",
"0.5685... | 0.7070885 | 0 |
Return a list with `n` strings representing colors fading from `c1` to `c2`. | def fade_color(c1, c2, n):
assert n >= 2
# decompose RGB. ignore alpha if present.
rgb1 = get_channels(c1)
rgb2 = get_channels(c2)
# find distances by chanel.
step_by_channel = (rgb2 - rgb1) / (n - 1)
# build steps.
scale = [rgb1 + (i * step_by_channel) for i in range(n)]
scale = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_colors(n):\n color = cm.rainbow(np.linspace(0, 1, n))\n return color",
"def get_colors(n, cmap=\"viridis\", start=0.0, stop=1.0, alpha=1.0, return_hex=False):\n colors = [cm.get_cmap(cmap)(x) for x in np.linspace(start, stop, n)]\n colors = [(r, g, b, alpha) for r, g, b, _ in colors]\n if ... | [
"0.71665025",
"0.6935482",
"0.6800732",
"0.6751211",
"0.6691951",
"0.65840596",
"0.6572139",
"0.6556966",
"0.65493804",
"0.6527477",
"0.6502501",
"0.64952916",
"0.64733255",
"0.6463096",
"0.6453381",
"0.6437666",
"0.64353216",
"0.6388581",
"0.63629615",
"0.62906516",
"0.62581... | 0.7398861 | 0 |
move this item after next item | def move_down(self):
next_sibling = self.get_next_sibling()
if next_sibling!=None:
self.move_to(next_sibling,'right')
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertBack(self, item):\n self.sentinel.prev.insertAfter(item)\n self.N += 1",
"def moveNext(self):\n parentNode = self.parentNode\n index = parentNode.idevices.index(self)\n if index < len(parentNode.idevices) - 1:\n temp = parentNode.idevices[index + 1]\n ... | [
"0.7450999",
"0.7043517",
"0.69421583",
"0.6860957",
"0.6615124",
"0.65495783",
"0.6376902",
"0.6291534",
"0.6253185",
"0.6218525",
"0.620817",
"0.61353517",
"0.6125515",
"0.6123651",
"0.61197364",
"0.6103677",
"0.6091351",
"0.6061233",
"0.60575217",
"0.60545427",
"0.6047014"... | 0.64396894 | 6 |
A test for comp_place_piece() | def test_comp_place_piece():
board = Board(640, 640, 8)
black_piece = GamePiece(0, 0, BLACK, 0)
white_piece = GamePiece(0, 0, WHITE, 0)
board.start_game()
board.game_pieces[3][3] = None
board.game_pieces[3][4] = None
board.game_pieces[4][3] = None
board.game_pieces[4][4] = None
boar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_place_piece_helper():\n board = Board(640, 640, 8)\n board.start_game()\n board.place_piece_helper(0, 0, 0, 0)\n assert len(board.used_points) == 5 and board.current_color == WHITE\n board.place_piece_helper(1, 0, 1, 0)\n assert len(board.used_points) == 6 and board.current_color == BLAC... | [
"0.73258364",
"0.7318275",
"0.7045659",
"0.6381066",
"0.63451725",
"0.63388145",
"0.6309141",
"0.6254486",
"0.6159695",
"0.6143413",
"0.61164594",
"0.6076947",
"0.6012649",
"0.60118514",
"0.60051394",
"0.5989589",
"0.59660536",
"0.5957842",
"0.59540784",
"0.59512335",
"0.5949... | 0.79349536 | 0 |
Creates a new superuser | def create_superuser(self,email,password):
user = self.create_user(email,password)
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createsuperuser():\n\n email = prompt('User E-Mail')\n email_confirm = prompt('Confirm E-Mail')\n\n if not email == email_confirm:\n sys.exit('\\nCould not create user: E-Mail did not match')\n\n if not EMAIL_REGEX.match(email):\n sys.exit('\\nCould not create user: Invalid E-Mail add... | [
"0.80412585",
"0.7921864",
"0.7915325",
"0.77949375",
"0.77885205",
"0.77613276",
"0.77593327",
"0.7739667",
"0.7705691",
"0.7691871",
"0.76866704",
"0.76856697",
"0.7680962",
"0.7672732",
"0.766203",
"0.76611584",
"0.7630425",
"0.7620972",
"0.7617647",
"0.7606459",
"0.760321... | 0.7623007 | 17 |
Evaluates a policy by running it n times. | def evaluate_policy(env, policy, gamma = 1.0, n = 100):
scores = [
run_episode(env, policy, gamma = gamma, render = False)
for _ in range(n)]
return np.mean(scores) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterate(self, iteration_loops, print_every_n):\n current_policy_function = lambda state_input: random.randint(0,self.nA-1) # Initialize with random policy\n current_Q = None\n iterations_completed = 0\n list_of_Q_dicts = [] # Maintain Qs throughout for comparison later\n whil... | [
"0.6549632",
"0.6319645",
"0.61743444",
"0.6098564",
"0.60468954",
"0.6003093",
"0.5998977",
"0.59627587",
"0.5948558",
"0.59019685",
"0.5883518",
"0.5839623",
"0.5802677",
"0.5782988",
"0.57726455",
"0.57705754",
"0.5767968",
"0.575119",
"0.5732588",
"0.5706621",
"0.57058346... | 0.66757435 | 1 |
Validates that the username is alphanumeric and is not already in use. | def clean_username(self):
data = self.cleaned_data['username']
if '@' in data or '|' in data or ' ' in data or '+' in data:
raise forms.ValidationError(_(u'Usernames should not have special characters.'))
try:
user = User.objects.get(username__exact=self.cleaned_data['use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid_username(username):\n word_letters = re.sub('[^a-zA-Z-0-9]+', '', str(username))\n if any(item.isalpha() for item in word_letters):\n return False\n return True",
"def clean_username(self):\n if self.edit_user is None:\n # checks for alnum and that th... | [
"0.8270316",
"0.8199544",
"0.81310993",
"0.80024475",
"0.795555",
"0.78986335",
"0.7823771",
"0.7818745",
"0.7801063",
"0.7748251",
"0.76987255",
"0.7676185",
"0.7672371",
"0.7657442",
"0.7611312",
"0.760858",
"0.76070887",
"0.7568461",
"0.7557298",
"0.7526015",
"0.7515451",
... | 0.7859516 | 6 |
Validates that the two password inputs match. | def clean_password2(self):
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
if self.cleaned_data['password1'] == self.cleaned_data['password2']:
return self.cleaned_data['password2']
raise forms.ValidationError(_(u'You must type the same password ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_password(password1: str, password2: str) -> bool:\n if password1 == password2:\n return True\n else:\n raise ValueError('Пароли не совпадают')",
"def clean_password(self):\n password1 = self.cleaned_data.get('password1')\n password2 = self.cleaned_data.get('password2')... | [
"0.79399914",
"0.7775991",
"0.75286",
"0.751961",
"0.7506222",
"0.7504838",
"0.745747",
"0.745747",
"0.74129796",
"0.7394356",
"0.7387584",
"0.7368053",
"0.73406",
"0.73406",
"0.7324741",
"0.73213553",
"0.73095393",
"0.7277372",
"0.72607356",
"0.71904254",
"0.7186055",
"0.7... | 0.72343296 | 19 |
Validates that the supplied email address is unique for the site. | def clean_email(self):
try:
user = User.objects.get(email__exact=self.cleaned_data['email'])
except User.DoesNotExist:
return self.cleaned_data['email']
raise forms.ValidationError(_(u'This email address is already in use. Please supply a different email address.')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_unique_email(email):\n if AssociatedEmail.objects.filter(email=email.lower(), is_primary_email=False):\n raise ValidationError(_(\"User with this email already exists.\"),\n code='email_not_unique',)\n if User.objects.filter(email=email.lower()):\n rais... | [
"0.7811236",
"0.7681506",
"0.750802",
"0.74950993",
"0.744549",
"0.74189126",
"0.7365537",
"0.7317443",
"0.7265087",
"0.7264893",
"0.7253402",
"0.72412723",
"0.72003585",
"0.71835124",
"0.71748316",
"0.7165133",
"0.7128252",
"0.71042466",
"0.7101546",
"0.7101546",
"0.70892125... | 0.6881035 | 32 |
String representation of the class instance. | def __str__(self):
return 'Token({type}, {value})'.format(
type=self.type,
value=repr(self.value)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n class_dictionary = vars(self)\n out = self.__class__.__name__\n for k,v in class_dictionary.items():\n if v > 0:\n out += ' : ' + str(k) + ' = ' + str(v)\n return out",
"def __repr__(self):\n outl = 'class :'+self.__class__.__name_... | [
"0.81528825",
"0.810694",
"0.80485237",
"0.7923295",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921949",
"0.7921295",
"0.7910681",
"0.79043895",
"0.79043895",
"0.79043895",
"0.78848475",
"0.78608793",
"0.7854687",
"0.78356767",
"0.7828303",
"0.7778142",
"0.777691... | 0.0 | -1 |
Return the state attributes. | def extra_state_attributes(self):
return {STATE_ATTRIBUTE_ROOM_NAME: self._room_name} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.828... | 0.0 | -1 |
Update the current cover position from the data. | def _async_update_current_cover_position(self):
_LOGGER.debug("Raw data update: %s", self._shade.raw_data)
position_data = self._shade.raw_data.get(ATTR_POSITION_DATA, {})
if ATTR_POSITION1 in position_data:
self._current_cover_position = int(position_data[ATTR_POSITION1])
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_data(self) -> None:\n data: SwitcherShutter = self.coordinator.data\n self._attr_current_cover_position = data.position\n self._attr_is_closed = data.position == 0\n self._attr_is_closing = data.direction == ShutterDirection.SHUTTER_DOWN\n self._attr_is_opening = data... | [
"0.6577723",
"0.6549762",
"0.6549762",
"0.6417879",
"0.6384423",
"0.63720477",
"0.6230134",
"0.60781413",
"0.6068532",
"0.59936655",
"0.5953635",
"0.59317994",
"0.5929338",
"0.5913609",
"0.59069985",
"0.58734846",
"0.58532465",
"0.5821888",
"0.58196",
"0.58079296",
"0.5804696... | 0.79747903 | 0 |
Gets or sets a list of polarizations for the item. | def polarizations(self) -> List[Polarization]:
return get_required(
map_opt(
lambda values: [Polarization(v) for v in values],
self._get_property(POLARIZATIONS_PROP, List[str]),
),
self,
POLARIZATIONS_PROP,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polar(self):\n return self._polar[self._plotid] # KeyError is desired, as all plots must have this property",
"def polar(position):\n return list(polar(complex(position[0], position[1])))",
"def to_polar(self, physics=False):\n if self.__coordsys in (Cartesian, Cartesian_3):\n ... | [
"0.7044728",
"0.6144635",
"0.57872546",
"0.57407016",
"0.56462336",
"0.55786127",
"0.544226",
"0.5440425",
"0.536691",
"0.5278291",
"0.51506054",
"0.50748307",
"0.5015942",
"0.50013155",
"0.49736014",
"0.4951902",
"0.49411768",
"0.49392888",
"0.49343815",
"0.49263212",
"0.492... | 0.74483776 | 0 |
Gets or sets a product type string for the item. | def product_type(self) -> str:
return get_required(
self._get_property(PRODUCT_TYPE_PROP, str), self, PRODUCT_TYPE_PROP
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_type(self) -> str:\n return self.__item_type",
"def product_type_name() -> str:\n\t\treturn Product.ListProducts.COMBO.label",
"def get_type(self):\n types = dict(PRODUCT_TYPE_CHOICES)\n return types.get(self.type, \"N/A\")",
"def product_type(self):\n pass",
"def produ... | [
"0.7532554",
"0.7275904",
"0.7272676",
"0.7160566",
"0.69237196",
"0.68777585",
"0.6872657",
"0.68482417",
"0.6800864",
"0.6673255",
"0.66540104",
"0.6618789",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",
"0.6558501",... | 0.7949418 | 0 |
Gets or sets a pixel spacing range for the item. | def pixel_spacing_range(self) -> Optional[float]:
return self._get_property(PIXEL_SPACING_RANGE_PROP, float) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSpacing(self):\n\t\tif not self.spacing:\n\t\t\ta, b, c = self.getVoxelSize()\n\t\t\tself.spacing = [1, b / a, c / a]\n\t\treturn self.spacing",
"def GetSpacing(self):\r\n\r\n return self._spacing",
"def GetSpacing(self, p_int, p_float=..., p_float=..., p_float=...):\n ...",
"def get_um_... | [
"0.6494858",
"0.6474152",
"0.6129958",
"0.6034496",
"0.5945042",
"0.58175343",
"0.57581127",
"0.57546556",
"0.57478184",
"0.57478184",
"0.57478184",
"0.5734896",
"0.56938565",
"0.56034327",
"0.5595521",
"0.5552176",
"0.5549323",
"0.55432105",
"0.55432105",
"0.55423546",
"0.55... | 0.75598234 | 0 |
Globus API check goauth expiry Checks if GOAuth expiry is has less than 10 days left. | def _check_goauth_expiration(self, expiry):
now = int(time.time())
time_left = int(expiry) - now
# 10 days
min_time_left = 60*60*24*10
if time_left < min_time_left:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_exp(self, now, leeway):\n if 'exp' in self:\n exp = self['exp']\n if not _validate_numeric_time(exp):\n raise InvalidClaimError('exp')\n if exp < (now - leeway):\n raise ExpiredTokenError()",
"def is_access_expired(self) -> bool:\... | [
"0.6331188",
"0.62962884",
"0.61397076",
"0.61361545",
"0.6125111",
"0.6115926",
"0.6079119",
"0.60741943",
"0.60479945",
"0.6031532",
"0.6017389",
"0.6016921",
"0.60122216",
"0.60109806",
"0.59854984",
"0.5958425",
"0.59578955",
"0.5949111",
"0.5946824",
"0.5945705",
"0.5898... | 0.8403415 | 0 |
Verify that messages printed to 'stdout' are captured by pytestzigzag upon failure. | def test_capture_stdout():
sys.stdout.write('Print to stdout')
assert False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ignore_capture():\n\n sys.stdout.write('Print to stdout')\n sys.stderr.write('Print to stderr')\n\n assert True",
"def testStdoutAndStderr(self):\n with self.OutputCapturer():\n print('foo')\n print('bar', file=sys.stderr)\n self.AssertOutputContainsLine('foo')\n self.AssertO... | [
"0.6834287",
"0.682161",
"0.6757061",
"0.657359",
"0.6389287",
"0.6314278",
"0.63060474",
"0.62410367",
"0.6228253",
"0.62123746",
"0.62040836",
"0.6132212",
"0.61104774",
"0.6107233",
"0.6069894",
"0.60576624",
"0.6057225",
"0.6044284",
"0.60359544",
"0.60048556",
"0.5994355... | 0.6866211 | 0 |
Return content up to ``n`` length. | def read(self, n=None):
l = []
if n is None or n < 0:
while True:
m = self._read1()
if not m:
break
l.append(m)
else:
while n > 0:
m = self._read1(n)
if not m:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tail(self, n=10):\n nend = self.len()\n nstart = nend - n\n if nstart < 0:\n nstart = 0\n return self.contents(nstart, nend)",
"def chunks(self, n):\n return _([self._[i:i+n] for i in range(0, self.size()._, n)])",
"def read(self, n=1):\n return self.str... | [
"0.7835838",
"0.6790196",
"0.6785236",
"0.66772944",
"0.6671758",
"0.65724343",
"0.65487707",
"0.65344024",
"0.6502827",
"0.6502827",
"0.6493319",
"0.64182645",
"0.64169574",
"0.640168",
"0.640168",
"0.63606864",
"0.63578147",
"0.6336417",
"0.6324835",
"0.63181376",
"0.631173... | 0.6266805 | 25 |
Return content up to ``n`` length. | def read(self, n=None):
l = []
if n is None or n < 0:
while True:
m = self._read1()
if not m:
break
l.append(m)
else:
while n > 0:
m = self._read1(n)
if not m:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tail(self, n=10):\n nend = self.len()\n nstart = nend - n\n if nstart < 0:\n nstart = 0\n return self.contents(nstart, nend)",
"def chunks(self, n):\n return _([self._[i:i+n] for i in range(0, self.size()._, n)])",
"def read(self, n=1):\n return self.str... | [
"0.7835838",
"0.6790196",
"0.6785236",
"0.66772944",
"0.6671758",
"0.65724343",
"0.65487707",
"0.65344024",
"0.6502827",
"0.6502827",
"0.6493319",
"0.64182645",
"0.64169574",
"0.640168",
"0.640168",
"0.63606864",
"0.63578147",
"0.6336417",
"0.6324835",
"0.63181376",
"0.631173... | 0.6281023 | 22 |
Initialize a MajoranaOperator with a single term. | def __init__(self, term=None, coefficient=1.0):
self.terms = {}
if term is not None:
term, parity = _sort_majorana_term(term)
self.terms[term] = coefficient * (-1)**parity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(terms):\n op = MajoranaOperator()\n op.terms = terms\n return op",
"def fromTerm(cls, term, swipl):\n\n if isinstance(term, Term):\n term = term.handle\n elif not isinstance(term, (c_void_p, int)):\n raise ArgumentTypeError((str(Term), str(c_... | [
"0.7383972",
"0.61364233",
"0.5988654",
"0.5864725",
"0.5848132",
"0.5702616",
"0.5684114",
"0.5647186",
"0.5598309",
"0.5565401",
"0.5562132",
"0.5535482",
"0.55024076",
"0.54951656",
"0.5487507",
"0.54595995",
"0.54425293",
"0.5439411",
"0.5433199",
"0.53961784",
"0.5380824... | 0.7100039 | 1 |
r"""Change to a basis of new Majorana operators. The input to this method is a real orthogonal matrix $O$. It returns a new MajoranaOperator which is equivalent to the old one but rewritten in terms of a new basis of Majorana operators. Let the original Majorana operators be denoted by $\gamma_i$ and the new operators ... | def with_basis_rotated_by(self, transformation_matrix):
if not _is_real_orthogonal(transformation_matrix):
raise ValueError("Transformation matrix is not real orthogonal.")
rotated_op = MajoranaOperator()
for term, coeff in self.terms.items():
rotated_term = _rotate_basi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_basis(self, U_global):\n self.matrix = U_global @ self.matrix @ np.conj(U_global).T",
"def basischange(rho0, U):\n return U @ rho0 @ U.conj().T",
"def vector_to_operator(op):\n if not op.isoperket:\n raise TypeError(\"only defined for operator-kets\")\n if op.superrep != \"su... | [
"0.55767834",
"0.53462887",
"0.5331405",
"0.5295472",
"0.5285719",
"0.5192217",
"0.51443785",
"0.5132153",
"0.51173246",
"0.5083385",
"0.50375396",
"0.5014097",
"0.4997924",
"0.49957007",
"0.49936497",
"0.49906278",
"0.49768046",
"0.49672312",
"0.49646956",
"0.49557227",
"0.4... | 0.5118987 | 8 |
Create and return a `User` with an email, username and password. | def create_user(self, username, email, password=None):
if username is None:
raise TypeError('Users must have a username.')
if email is None:
raise TypeError('Users must have an email address.')
user = self.model(username=username, email=self.normalize_email(email))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email=None, password=None, **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, username=email, **extra_fields)\n user.set_password(password)\n u... | [
"0.871256",
"0.86927533",
"0.868441",
"0.86744446",
"0.8649317",
"0.8649317",
"0.8618906",
"0.8615675",
"0.8607496",
"0.8606581",
"0.8606581",
"0.8606581",
"0.8606581",
"0.8606581",
"0.8606581",
"0.8606581",
"0.8606581",
"0.85984576",
"0.859789",
"0.8597251",
"0.8594306",
"... | 0.84041405 | 59 |
Returns a string representation of this `User`. This string is used when a `User` is printed in the console. | def __str__(self):
return self.email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.user_id) + \": \" + \\\n str(self.user_name) + \": \" + str(self.user_email)",
"def __repr__(self):\n\n return '<User user_id={} email={} first_name={} last_name={}>'.format(self.user_id,\n ... | [
"0.8413597",
"0.83416843",
"0.82696235",
"0.82438594",
"0.822045",
"0.8204515",
"0.81018466",
"0.8099857",
"0.8097398",
"0.809523",
"0.8093098",
"0.80919737",
"0.80919737",
"0.80919737",
"0.80919737",
"0.80919737",
"0.80899847",
"0.8084857",
"0.808155",
"0.8060798",
"0.800683... | 0.0 | -1 |
Return the angular frequency for this potential for the given mass. | def omega(self, mass: float) -> float:
return np.sqrt(self.spring_constant / mass) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frequency(self, mass: float) -> float:\n return self.omega(mass) / u.twopi",
"def mass(self):\n\t\treturn self.volume*self.density",
"def plasma_ang_frequency(n_e, m=spc.m_p):\n return math.sqrt((n_e * spc.elementary_charge**2) / (spc.epsilon_0 * m))",
"def mass(self):\n return self._mas... | [
"0.8558507",
"0.6509668",
"0.64014196",
"0.6355256",
"0.6355256",
"0.6325714",
"0.6322453",
"0.62979895",
"0.62690926",
"0.62690926",
"0.619267",
"0.61567307",
"0.6145228",
"0.6136066",
"0.60856014",
"0.6084143",
"0.6047474",
"0.60108745",
"0.5983998",
"0.597555",
"0.5975147"... | 0.7268162 | 1 |
Return the fullwidth at halfmax of the potential. | def fwhm(self) -> float:
return 2 * np.sqrt(2 * np.log(2)) * self.width | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def width(self):\n xx = self.xx\n return max(xx) - min(xx)",
"def max_norm() -> float:\n return 1.0",
"def absolute_width(self):\r\n return round_up(self.width + self.horizontal_spacing * max(self.config['ratios']))",
"def width_h_invis(self):\n if m_higgs > 2.0 * self.mx:\n c... | [
"0.60424906",
"0.5918914",
"0.58390826",
"0.58276206",
"0.579982",
"0.57973003",
"0.57948667",
"0.5786066",
"0.57733774",
"0.57733774",
"0.57733774",
"0.57733774",
"0.57733774",
"0.57733774",
"0.5740682",
"0.5713979",
"0.57050145",
"0.56941414",
"0.56759274",
"0.5662834",
"0.... | 0.583586 | 3 |
Initialize the model by setting up the layers. | def __init__(self, input_size, output_size, hidden_dim, n_layers, bidirectional=True, drop_prob=0):
super(BiLSTM, self).__init__()
self.output_size = output_size
self.n_layers = n_layers
self.hidden_dim = hidden_dim
self.bidirectional = bidirectional
self.lstm = nn.LSTM... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_layers(self):\n self._init_predictor()\n if self.use_edge_fusion:\n self._init_edge_module()",
"def initialisation(self):\n self.create_variables()\n self.create_placeholders()\n self.build_model()\n self.reset_lr(None, True)\n self.build_loss... | [
"0.7877656",
"0.740135",
"0.73939556",
"0.73799825",
"0.72304994",
"0.72242755",
"0.7183698",
"0.7181406",
"0.7175707",
"0.71491647",
"0.70773673",
"0.70694804",
"0.7036073",
"0.70194495",
"0.7018242",
"0.69936645",
"0.6969751",
"0.6949472",
"0.69274527",
"0.6899944",
"0.6853... | 0.0 | -1 |
Test calculating bounding box's area. | def test_areas(self):
df = self.spark.createDataFrame(
[
(Box2d(1, 2, 1.0, 1.0),),
(Box2d(10, 12, 1.0, 5.0),),
],
["bbox"],
)
df = df.withColumn("area", area(col("bbox")))
self.assertCountEqual((1.0, 5.0), df.select("are... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rectangle_area(self):\n self.assertEqual(12, rectangle_area(\n self.values['base'], self.values['height']))",
"def boundingBoxArea(box):\n return (box[2] - box[0] + 1) * (box[3] - box[1] + 1)",
"def test_area(self):\r\n rect = Rectangle(30, 50, 130, 60)\r\n a... | [
"0.8065532",
"0.8037415",
"0.7948927",
"0.7830735",
"0.77955776",
"0.7500105",
"0.7443576",
"0.742373",
"0.7408322",
"0.73405117",
"0.73196113",
"0.7311976",
"0.72496635",
"0.7185762",
"0.7161532",
"0.71592045",
"0.70235264",
"0.69637954",
"0.6939459",
"0.6932197",
"0.6909909... | 0.70603794 | 16 |
Extract patches rom an image | def get_patches(image_mat, stride):
window_shape = (128, 128, 3)
windows = view_as_windows(image_mat, window_shape, step=stride)
patches = []
for m in range(windows.shape[0]):
for n in range(windows.shape[1]):
patches += [windows[m][n][0]]
return patches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_patches(img, patch_s):\n def np_extract_patches(img):\n orig = np.array(img.shape[:2])\n new = patch_s[0] * np.ceil(orig / patch_s[0]).astype(int)\n points = new - orig\n img = np.pad(img, [(0, points[0]), (0, points[1]), (0, 0)],\n ... | [
"0.752042",
"0.7405589",
"0.7383237",
"0.7218089",
"0.71736616",
"0.7031394",
"0.6964944",
"0.69237727",
"0.6889955",
"0.68696856",
"0.6828709",
"0.6797487",
"0.6776113",
"0.67393386",
"0.67282397",
"0.6677259",
"0.6650687",
"0.6630599",
"0.6598658",
"0.6565674",
"0.6555005",... | 0.6376204 | 26 |
Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even. For example, capitalize("abcdef") = ['AbCdEf', 'aBcDeF']. See test cases for more examples. The input will be a lowercase string with no spaces. Good luck! | def capitalize(s):
s = list(s)
capitalizeEvenArray = []
capitalizeOddArray = []
finalArray = []
for i in range(len(s)):
if i % 2 == 0:
capitalizeEvenArray.append(s[i].capitalize())
capitalizeOddArray.append(s[i])
else:
capitalizeEvenArray.append(s[i])
capitalizeOddArray.append(s[i].capitalize())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalize1(s):\n return s[:1].upper() + s[1:]",
"def capitalize(phrase):\n new_phrase = phrase[0].upper()\n \n # loop through the phrase starting from index 1\n # concat each letter from phrase to new_phrase\n for i in range(1, len(phrase)):\n new_phrase += phrase[i]\n\n return n... | [
"0.72522223",
"0.7004824",
"0.67990184",
"0.6785063",
"0.6768302",
"0.6745219",
"0.66949296",
"0.6629766",
"0.65753126",
"0.6549061",
"0.64965546",
"0.64816284",
"0.6469912",
"0.6451273",
"0.64363456",
"0.64363456",
"0.64178455",
"0.6406056",
"0.64053345",
"0.6401183",
"0.637... | 0.8053942 | 0 |
Return index if given number is found in the list. | def linear_search(arr: IntList, query: int) -> int:
arr_len: int = len(arr)
for idx in range(arr_len):
if arr[idx] == query:
return idx
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_search(self, num_lst, key):\r\n # Running time: O(n)\r\n for i in range(len(num_lst)):\r\n if num_lst[i] == key:\r\n return i\r\n \r\n return -1",
"def index(liste, value):\n\n for ii in range(len(liste)):\n if liste[ii] == value:\n ... | [
"0.75644296",
"0.7527579",
"0.7342308",
"0.73023516",
"0.7262485",
"0.72490627",
"0.72077674",
"0.72039735",
"0.7189785",
"0.716159",
"0.71311665",
"0.71184236",
"0.70855105",
"0.7074518",
"0.7072363",
"0.7027025",
"0.7008956",
"0.6887056",
"0.6869319",
"0.6769843",
"0.676485... | 0.65247744 | 37 |
Return index if given number is found in the list. It reduces one comparison in every iterations. In the original one we "loop & compare the forcond & param", on this one we only need to "compare the param (& incr). | def linear_search_sentinel(arr: IntList, query: int) -> int:
arr_len: int = len(arr) # e.g. [3, 5, 1, 9] => 4
last: int = arr[-1] # last=9
arr[-1] = query # e.g. search '1' -> arr[-1]=1
idx: int = 0
while arr[idx] != query: # arr[0,1,2,3] ?= 1
idx += 1 # search 1 => idx=2
arr[-1] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_search(self, num_lst, key):\r\n # Running time: O(n)\r\n for i in range(len(num_lst)):\r\n if num_lst[i] == key:\r\n return i\r\n \r\n return -1",
"def linear_search(lst, value):\n i = 0\n while i != len(lst) and lst[i] != value:\n ... | [
"0.7044698",
"0.6974586",
"0.6957792",
"0.6896653",
"0.68217874",
"0.67767775",
"0.66456515",
"0.66047734",
"0.6602837",
"0.65877736",
"0.65762985",
"0.6559269",
"0.65419406",
"0.6509697",
"0.6508344",
"0.64554805",
"0.645407",
"0.6453971",
"0.6402255",
"0.6388524",
"0.638281... | 0.5866487 | 64 |
Create a colormap for robot joints | def linkcolormap(self, linkcolors="viridis"):
if isinstance(linkcolors, list) and len(linkcolors) == self.n:
# provided a list of color names
return colors.ListedColormap(linkcolors)
else:
# assume it is a colormap name
return cm.get_cmap(linkcolors, 6) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_label_colormap():\n colormap = np.array([\n [128, 64, 128],\n [244, 35, 232],\n [ 70, 70, 70],\n [102, 102, 156],\n [190, 153, 153],\n [153, 153, 153],\n [250, 170, 30],\n [220, 220, 0],\n [107, 142, 35],\n [152, 251, 152],... | [
"0.68236434",
"0.65476716",
"0.6484247",
"0.6156376",
"0.61551416",
"0.61100024",
"0.60688406",
"0.60494787",
"0.59901047",
"0.5970671",
"0.59689003",
"0.59651875",
"0.59312844",
"0.59022063",
"0.587058",
"0.5836178",
"0.58328897",
"0.58183086",
"0.58183086",
"0.5814701",
"0.... | 0.54297245 | 50 |
Get/set robot name (Robot superclass) ``robot.name`` is the robot name | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self.robot.name + ' ' + SWITCH_TYPES[self.type][0]",
"def set_robot(self, robot):\n self.robot = robot",
"def get_robot_type(robot_name):\n attr = 'robotType'\n path = '{}.{}'.format(get_target_ctrl_path(robot_name), attr)\n return get_attribute_value(path)",
"... | [
"0.6452747",
"0.6167242",
"0.6055254",
"0.6042503",
"0.5917789",
"0.58874357",
"0.5874447",
"0.5860842",
"0.58605766",
"0.58605766",
"0.58605766",
"0.58191293",
"0.58191293",
"0.58191293",
"0.5786786",
"0.57778573",
"0.57778573",
"0.5772978",
"0.5770095",
"0.5766569",
"0.5765... | 0.0 | -1 |
Get/set robot manufacturer's name (Robot superclass) ``robot.manufacturer`` is the robot manufacturer's name | def manufacturer(self):
return self._manufacturer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manufacturer(self):\n return self._device.manufacturer",
"def manufacturer(self) -> str:\n return self.profile_device.manufacturer",
"def getManufacturer(self):\n return self.manufacturer",
"def get_drive_manufacturer(self, drive_model):\n\n\t\tdrive_model = drive_model.lower()\n\n\t... | [
"0.7519577",
"0.7362755",
"0.73484373",
"0.7201688",
"0.7069193",
"0.7007841",
"0.6888599",
"0.60468894",
"0.5962523",
"0.58395827",
"0.58304405",
"0.58224547",
"0.5815096",
"0.57975537",
"0.5751366",
"0.57211953",
"0.5533511",
"0.5505995",
"0.54804397",
"0.54248047",
"0.5420... | 0.73867214 | 1 |
Get/set robot joint acceleration (Robot superclass) ``robot.qdd`` is the robot joint acceleration | def qdd(self):
return self._qdd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _joint_angle_control(self):\n\n error = self.target_pos - self.robot_arm_pos\n return self._pd_control(error) + self.torque",
"def updateMARG(self, q: np.ndarray, gyr: np.ndarray, acc: np.ndarray, mag: np.ndarray, dt: float = None) -> np.ndarray:\n _assert_numerical_iterable(q, 'Quaterni... | [
"0.63749534",
"0.6044896",
"0.5947305",
"0.5932011",
"0.57884717",
"0.57407933",
"0.56916785",
"0.5687669",
"0.56656045",
"0.56028676",
"0.55788934",
"0.55512613",
"0.5521995",
"0.5521059",
"0.5514926",
"0.54816747",
"0.5477208",
"0.54666066",
"0.5388541",
"0.5362684",
"0.535... | 0.0 | -1 |
Creates an instance of `ActorRnnNetwork`. | def __init__(
self,
input_tensor_spec,
output_tensor_spec,
conv_layer_params=None,
input_fc_layer_params=(200, 100),
lstm_size=(40,),
output_fc_layer_params=(200, 100),
activation_fn=tf.keras.activations.relu,
name='ActorRnnNetwork',
):
if len(tf.nest.flatten(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_network(self):\n\n print ('Creating network, changing data will have no effect beyond this point.')\n n = IMNN.IMNN(parameters=self.parameters)\n\n if self.load_network:\n n.restore_network()\n else:\n n.setup(network = self.network, load_data = self.dat... | [
"0.67001796",
"0.62896705",
"0.6281561",
"0.61653763",
"0.61375254",
"0.5852676",
"0.5843381",
"0.5778502",
"0.5772604",
"0.57688445",
"0.5726827",
"0.5725136",
"0.5676937",
"0.5645411",
"0.5645028",
"0.56429565",
"0.5632609",
"0.5626175",
"0.5543503",
"0.55420905",
"0.554208... | 0.5934057 | 5 |
Return the maximum indices from the input based on the mask values. | def get_max_indices(self, input):
min_element = torch.min(torch.abs(input.contiguous().view(-1)))
input_temp = input + min_element + self.epsilon
masked_input_temp = input_temp * self.mask
values, indices = torch.sort(masked_input_temp, dim=1, descending=True)
return in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_maximum(data, mask):\r\n\r\n flag = (torch.sum(mask, dim = 1, keepdim = True) == 1).float()\r\n only_nonzero = torch.max(mask, dim = 1, keepdim = True)[1]\r\n\r\n minimum = torch.min(data, dim = 1, keepdim = True)[0]\r\n masked_maximum, masked_maximum_id = torch.max((data - minimum) * mask, ... | [
"0.7233552",
"0.7122363",
"0.68888634",
"0.68044424",
"0.6763603",
"0.67334",
"0.6616053",
"0.65992135",
"0.6405563",
"0.6393752",
"0.6393752",
"0.6393752",
"0.6301888",
"0.6298719",
"0.62982213",
"0.6277624",
"0.6219846",
"0.6150456",
"0.6126163",
"0.61140656",
"0.61120814",... | 0.771752 | 0 |
Returns a deep copy of this accumulator. | def copy(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_copy(self):\n return self.__class__(self.inputs, self.outputs, self.middle)",
"def deepcopy(self):\n return self.copy()",
"def deepcopy(self):\n return copy.deepcopy(self)",
"def copy(self):\n \n return deepcopy(self)",
"def deepcopy(self):\n return copymo... | [
"0.68696034",
"0.68196577",
"0.66156954",
"0.6609806",
"0.6567306",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6552565",
"0.6520686",
... | 0.0 | -1 |
Returns a copy of this accumulator with the contents rightmultiplied by the specified object. Typically this operator will be used to chain backprop gradients, ie. do_dx = do_dy dy_dx, where the accumulator stores do_dy. | def __mul__(self, A):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iadd__(self, obj):\n # calls __add__\n tmp = self + obj\n self.data = tmp.data\n return self",
"def __add__(self, obj):\n return self ^ obj",
"def __mul__(self, obj):\n return self & obj",
"def __imul__(self, obj):\n # calls __mul__\n tmp = self *... | [
"0.590042",
"0.58840644",
"0.5749573",
"0.5681582",
"0.56071913",
"0.5605998",
"0.5557515",
"0.5528245",
"0.55110997",
"0.5393863",
"0.53195864",
"0.53055394",
"0.53037316",
"0.530091",
"0.5299481",
"0.5293384",
"0.52927715",
"0.52476996",
"0.52457047",
"0.52109677",
"0.51889... | 0.0 | -1 |
Return a list of weak references to the keys. The references are not guaranteed to be 'live' at the time they are used, so the result of calling the references needs to be checked before being used. This can be used to avoid creating references that will cause the garbage collector to keep the keys around longer than n... | def keyrefs(self):
return list(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keyrefs(self):\n return [ref(key) for key in self.iterkeys()]",
"def keyrefs(self):\r\n return self.data.keys()",
"def keyrefs(self):\r\n return self.data.keys()",
"def iterkeyrefs(self):\n for key in self.iterkeys():\n yield ref(key)",
"def list_ref_keys(self):\n... | [
"0.82074225",
"0.7239157",
"0.7239157",
"0.7028191",
"0.6850422",
"0.65938056",
"0.65938056",
"0.6564662",
"0.6491547",
"0.64053553",
"0.6279825",
"0.6259065",
"0.6250254",
"0.6239333",
"0.61376363",
"0.6136784",
"0.6128882",
"0.6128882",
"0.609659",
"0.60938567",
"0.6087779"... | 0.7305308 | 1 |
Set self.name to a randomly generated (w/ weights!) nickname | def __init__(self):
# there's always a 1/40 chance of Bob Johnson!
self.name = weighted_choice(
[(self.make_name(), 39), (self.bob, 1), (self.beef, 1)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_name(self,new_name):\n self.name = new_name",
"def set_name(self, newname=\"\"):\n self.name = newname",
"def reset(self):\n import string\n # import random\n from random import SystemRandom\n old_name = self.name\n\n while old_name == self.name:\n ... | [
"0.72103363",
"0.7203026",
"0.71570575",
"0.7083047",
"0.7069082",
"0.69720286",
"0.69692993",
"0.69543684",
"0.6920626",
"0.6920626",
"0.68515587",
"0.6850224",
"0.6850224",
"0.68295616",
"0.6815698",
"0.6808106",
"0.6802845",
"0.6788818",
"0.67887366",
"0.67838293",
"0.6765... | 0.64276636 | 84 |
Return the instance's name | def get_name(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getname(self):\n if self.instance is not None:\n return '%s_%s' % (self.name,self.instance)\n else:\n return self.name",
"def name(self):\n return self._client.project_name + '/instances/' + self.instance_id",
"def get_name(self):\n\t\treturn self.__name",
"def ... | [
"0.8780096",
"0.83843404",
"0.8188377",
"0.813625",
"0.80755264",
"0.80714804",
"0.80714804",
"0.80714804",
"0.80620867",
"0.80620867",
"0.80620867",
"0.80620867",
"0.80581266",
"0.802426",
"0.80163795",
"0.79936075",
"0.7993189",
"0.7993189",
"0.7993189",
"0.7975848",
"0.797... | 0.0 | -1 |
Generate a first name | def get_first(self):
return "%s%s" % (
weighted_choice([("", 39), ("We put our faith in ", 1)]),
choice(self.first_chunks).title()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateUsername(self):\n retval= \"{0}.{1}\".format( self.first_name.split()[0].lower(),\n self.last_name.split()[-1].lower() )\n \n return toAscii(retval)",
"def get_first_name(self) -> str:\n return self.first_name",
... | [
"0.7938248",
"0.77602273",
"0.7621453",
"0.75850064",
"0.7529725",
"0.75006044",
"0.7488171",
"0.74808437",
"0.74504983",
"0.74376416",
"0.7406537",
"0.7385905",
"0.73541754",
"0.7321227",
"0.73053443",
"0.7299395",
"0.7291553",
"0.7285527",
"0.7259067",
"0.7250136",
"0.72501... | 0.0 | -1 |
Change the name of an existing attribute. | def setName(self, attributeIndex, newName) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attribute_name(self, attribute_name):\n\n self._attribute_name = attribute_name",
"def attribute_name(name: str) -> str:\n return text.snake_case(utils.safe_snake(name))",
"def set_attribute(self, name, value):\n\n pass",
"def renameAttr(*args, **kwargs)->AnyStr:\n pass",
"def new_n... | [
"0.769654",
"0.7592607",
"0.74921066",
"0.7343999",
"0.7326134",
"0.7285174",
"0.7285174",
"0.7269998",
"0.72308606",
"0.72252005",
"0.7183459",
"0.7161339",
"0.6953541",
"0.69324696",
"0.69324696",
"0.684895",
"0.68437946",
"0.6837461",
"0.6832023",
"0.68090236",
"0.6806226"... | 0.80927634 | 0 |
Get the number of keys for the skewX attribute. The view parameter is optional. | def getNumberOfSkewXKeys(self, view) -> int:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSkewXKeyTimes(self, view) -> list[float]:\n ...",
"def getNumberOfTransformKeys(self, view) -> int:\n ...",
"def getNumberOfScaleKeys(self, view) -> int:\n ...",
"def getNumberOfRotationKeys(self, view) -> int:\n ...",
"def getNumberOfKeys(self, attr, view) -> int:\n ... | [
"0.7319535",
"0.7204794",
"0.7149547",
"0.71381664",
"0.7128321",
"0.69738686",
"0.67407584",
"0.67082655",
"0.61614305",
"0.5690349",
"0.56343406",
"0.5535973",
"0.5533726",
"0.5444282",
"0.54256725",
"0.5407733",
"0.53724974",
"0.5370755",
"0.5344329",
"0.5333305",
"0.53196... | 0.9129364 | 0 |
Get the number of keys for all attributes of this transform. The view parameter is optional. | def getNumberOfTransformKeys(self, view) -> int:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumberOfKeys(self, attr, view) -> int:\n ...",
"def getNumberOfScaleKeys(self, view) -> int:\n ...",
"def getNumberOfTranslationKeys(self, view) -> int:\n ...",
"def getNumberOfRotationKeys(self, view) -> int:\n ...",
"def getNumberOfSkewXKeys(self, view) -> int:\n ... | [
"0.8405167",
"0.75059074",
"0.74644214",
"0.7448493",
"0.7274628",
"0.7077828",
"0.6883859",
"0.6447866",
"0.6422313",
"0.631336",
"0.631336",
"0.63107264",
"0.60906625",
"0.60181314",
"0.5899048",
"0.5883699",
"0.58664364",
"0.5858172",
"0.58445215",
"0.58445215",
"0.580362"... | 0.8118101 | 1 |
Set the anim curve for the rotation attribute of this transform. The index parameter should be 0 for the x values, 1 for the y values. The view parameter is optional. | def setRotationAnimCurve(self, index, animCurve, view) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setTranslationAnimCurve(self, index, animCurve, view) -> None:\n ...",
"def setPositionAnimCurve(self, index, animCurve, view) -> None:\n ...",
"def setPivotPointAnimCurve(self, index, animCurve, view) -> None:\n ...",
"def setSkewXAnimCurve(self, index, animCurve, view) -> None:\n ... | [
"0.7323325",
"0.72483635",
"0.6869143",
"0.6817336",
"0.66532713",
"0.6598991",
"0.6543107",
"0.63113564",
"0.59990704",
"0.5867983",
"0.5773243",
"0.5703239",
"0.56291264",
"0.5480719",
"0.54592454",
"0.54382986",
"0.54352987",
"0.53866434",
"0.53450215",
"0.53049517",
"0.52... | 0.86197585 | 0 |
Check whether this curve has been modified away from its default values. | def isDefault(self) -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_modified(self):\n if self.any_parent_as_widget:\n return self._is_modified or self.defaults_not_set\n\n if self._is_modified or self.defaults_not_set:\n return True\n\n if self.is_overidable:\n return self.was_overriden != self.is_overriden\n else... | [
"0.6547326",
"0.63797295",
"0.62450814",
"0.62450814",
"0.6101802",
"0.60560596",
"0.604923",
"0.60092044",
"0.5900057",
"0.58781374",
"0.5836954",
"0.57791185",
"0.5750626",
"0.571046",
"0.5690318",
"0.5684944",
"0.56829584",
"0.56686825",
"0.56680304",
"0.5666855",
"0.56543... | 0.0 | -1 |
Postmultiply this matrix by a scale transformation. The y and z parameters may be left out; if so the scale is uniform along all three axes. | def scale(self, x, y, z) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(self, scale):\n \n scale_matrix = wf.scaleMatrix(scale, self.width/2, self.height/2, 0)\n self.transform(scale_matrix)",
"def Scale(*args, **kwargs):\n return _gdi_.GraphicsMatrix_Scale(*args, **kwargs)",
"def scale3d(p, a=1, b=1, c=1):\n translation_mat = np.matrix([\n... | [
"0.6576966",
"0.65492755",
"0.6306448",
"0.6301948",
"0.6251686",
"0.61309683",
"0.6070604",
"0.6001046",
"0.59448457",
"0.593658",
"0.5875388",
"0.58635914",
"0.5845655",
"0.5800007",
"0.57828707",
"0.5762446",
"0.57486653",
"0.5743575",
"0.5728276",
"0.5702517",
"0.56567025... | 0.6515715 | 2 |
Postmultiply this matrix with a skew transformation. The y and z parameters may be left out; if so, the skew is in the X direction only. | def skew(self, x, y, z) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skew(self):\n \n v = self.v; w = self.w;\n \n # the following matrix is at odds with H&Z pg. 72\n return np.array([\n [ 0, v[2], -v[1], w[0]],\n [-v[2], 0 , v[0], w[1]],\n [ v[1], -v[0], 0, w[2]],\n [-w[0... | [
"0.674893",
"0.61231506",
"0.6083809",
"0.60219413",
"0.5870477",
"0.5850717",
"0.56683666",
"0.56683666",
"0.56683666",
"0.56683666",
"0.5636025",
"0.56122017",
"0.55229884",
"0.5379817",
"0.5210464",
"0.5087206",
"0.5014046",
"0.49173725",
"0.48539457",
"0.47405082",
"0.472... | 0.66605175 | 1 |
Set this matrix to be a translation matrix, replacing any existing values. This is different from other methods in this class as it replaces, rather than multiplying by, the existing values in the matrix. | def translation(self, x, y, z) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix(self):\n return self._translation",
"def _transform(self, matrix):\n for x in list(self.keys()):\n ar = self[x]\n if len(ar.shape) == 2 and ar.shape[1] == 3:\n self[x] = np.dot(matrix, ar.transpose()).transpose()",
"def translate(self, x=0, y=0, z=0... | [
"0.6885663",
"0.66732776",
"0.6645825",
"0.6421659",
"0.6166122",
"0.6065455",
"0.606052",
"0.5972051",
"0.59345686",
"0.5833458",
"0.57894486",
"0.5770156",
"0.57565403",
"0.5745422",
"0.5739375",
"0.5732846",
"0.57183987",
"0.5716183",
"0.5713978",
"0.5685722",
"0.56761926"... | 0.52555287 | 80 |
Returns True if this transform matches the default settings, False if not. | def isDefault(self) -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_defaults(self) -> pulumi.Output[Optional[bool]]:\n return pulumi.get(self, \"use_defaults\")",
"def use_defaults(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"use_defaults\")",
"def use_defaults(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \... | [
"0.6298078",
"0.62840414",
"0.62840414",
"0.6268125",
"0.61701113",
"0.60805655",
"0.60344934",
"0.6000641",
"0.59880275",
"0.59543455",
"0.5952754",
"0.5945263",
"0.5880526",
"0.58679044",
"0.5862624",
"0.5861585",
"0.583916",
"0.58366555",
"0.5818389",
"0.57946056",
"0.5759... | 0.61273813 | 6 |
Return this transform to its default settings. | def reset(self) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_transform(self, *args, transform=None, **kwargs):\n # Apply default transform\n # TODO: Do some cartopy methods reset backgroundpatch or outlinepatch?\n # Deleted comment reported this issue\n method = kwargs.pop('_method')\n if transform is None:\n transform = PlateCarree()\n ... | [
"0.6143181",
"0.6138567",
"0.60939837",
"0.6062362",
"0.6050486",
"0.60184455",
"0.590092",
"0.5881013",
"0.5852312",
"0.58440506",
"0.58381414",
"0.58221316",
"0.5815106",
"0.5782928",
"0.5765118",
"0.5758224",
"0.57505065",
"0.57505065",
"0.573958",
"0.57122284",
"0.5676541... | 0.0 | -1 |
Initialize the soundingEnvironment object. See class documentation. | def __init__(self,
launchSiteLat,
launchSiteLon,
launchSiteElev,
dateAndTime,
soundingFile,
timeFromSounding,
distanceFromSounding,
inflationTemperature=0.0,
UTC_offse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n setup_logging()\n if platform.system() == \"Windows\":\n torchaudio.USE_SOUNDFILE_LEGACY_INTERFACE = False\n torchaudio.set_audio_backend(\"soundfile\")\n else:\n torchaudio.set_audio_backend(\"sox_io\")\n\n torch.manual_seed(0)\n random.seed(0)\n np.random.seed... | [
"0.654832",
"0.6542081",
"0.65346956",
"0.64869595",
"0.59081393",
"0.5888667",
"0.5888667",
"0.5865568",
"0.580509",
"0.5800644",
"0.5756435",
"0.5748782",
"0.57444435",
"0.56872886",
"0.56696457",
"0.5643041",
"0.55588436",
"0.5462768",
"0.5427535",
"0.54250544",
"0.5410461... | 0.6761782 | 0 |
Constructor function responsible for applying perturbations to wind profiles and returning closure functions. | def make_perturbedWind(self, iDevTime, iDevSpace, randomChance, resultType=None):
# Interpolate the deviations
timeDeviationU = UnivariateSpline(wind_time_perturbation.AltitudesM[:31],
wind_time_perturbation.M_U_Kts[iDevTime], s=5)
timeD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **observation_functions):\n self.observation_functions = observation_functions",
"def __init__(self, *observation_functions):\n self.observation_functions = observation_functions",
"def __init__(self, *args, **kwargs):\n try:\n geometry = kwargs['geometry']\n ... | [
"0.57617277",
"0.57545006",
"0.56610876",
"0.56411827",
"0.56189775",
"0.5596865",
"0.55687106",
"0.54733866",
"0.5429545",
"0.54240674",
"0.5421355",
"0.5342612",
"0.5336828",
"0.5332356",
"0.53233254",
"0.5318489",
"0.52870184",
"0.5277305",
"0.5269967",
"0.5261108",
"0.526... | 0.0 | -1 |
Initialize a 1D linear interpolation class. | def __init__(self, x, y, kind='linear', axis=-1,
copy=True, bounds_error=True, fill_value=np.nan):
_Interpolator1D.__init__(self, x, y, axis=axis)
self.copy = copy
self.bounds_error = bounds_error
self.fill_value = fill_value
if kind in ['zero', 'slinear', 'qua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_1d_linear_interpolation_basic(self):\n\n # Define pixel centers along each direction\n x = [1.0, 2.0, 4.0]\n\n # Define array with corresponding values\n A = numpy.zeros((len(x)))\n\n # Define values for each xas a linear function\n for i in range(len(x)):\n ... | [
"0.6662798",
"0.64082444",
"0.62980455",
"0.61222905",
"0.60928935",
"0.6003189",
"0.5990886",
"0.5990886",
"0.598326",
"0.5962284",
"0.5906751",
"0.589192",
"0.5887509",
"0.5864227",
"0.5863058",
"0.5859278",
"0.58498627",
"0.5846102",
"0.58292145",
"0.5828141",
"0.5788423",... | 0.7018905 | 0 |
Return the path of the creme data directory. | def get_data_home(data_home=None):
if data_home is None:
data_home = os.environ.get('CREME_DATA', os.path.join('~', 'creme_data'))
data_home = os.path.expanduser(data_home)
if not os.path.exists(data_home):
os.makedirs(data_home)
return data_home | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def data_dir():\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
"def data_dir(self) -> Path:\n return self._data_dir",
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def data_dir():\n ... | [
"0.82566875",
"0.8075111",
"0.8062139",
"0.80395365",
"0.7988162",
"0.7978554",
"0.79116637",
"0.7893909",
"0.7882033",
"0.7861019",
"0.78586584",
"0.78586584",
"0.7857231",
"0.7816852",
"0.77922225",
"0.7702507",
"0.7698726",
"0.76870507",
"0.76775813",
"0.7674349",
"0.76168... | 0.69737244 | 56 |
Compress the given data (assumed to be bytes) and return a bytearray containing the compressed data (including gzip header and footer). Also returns offsets for the end of each separate stream. | def compress_inmem(data, concat):
f = io.BytesIO()
if concat: chunksize = len(data) // 10
else: chunksize = len(data)
offsets = []
compressed = 0
print('Generating compressed data {}, concat: {})'.format(
len(data), concat))
while compressed < len(data):
start = len... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gzip_compress(data):\n s = BytesIO()\n g = gzip.GzipFile(fileobj=s, mode='wb')\n g.write(data)\n g.close()\n return s.getvalue()",
"def data_zip(self, data):\n stringio = StringIO.StringIO()\n gzip_file = gzip.GzipFile(fileobj=stringio, mode='wb')\n gzip_file.write(data)\n... | [
"0.70542353",
"0.666646",
"0.6556566",
"0.64006585",
"0.6137972",
"0.6015027",
"0.59958714",
"0.59958714",
"0.59419537",
"0.5889193",
"0.588133",
"0.58588576",
"0.5744829",
"0.5673796",
"0.56064403",
"0.5575992",
"0.5520173",
"0.54564345",
"0.5424424",
"0.5421693",
"0.5377742... | 0.65692574 | 2 |
finds an empty space in the board | def find_empty(bo):
for i in range(len(bo)):
for j in range(len(bo[0])):
if bo[i][j] == 0:
return (i, j)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_empty_space(board, position1):\n return board[position1] == \" \"",
"def find_empty_space(board: list) -> tuple:\n board_length = len(board)\n for i in range(board_length):\n for j in range(board_length):\n if board[i][j] == 0:\n return (i,j)",
"def find_empt... | [
"0.7841911",
"0.76906204",
"0.75697964",
"0.7427892",
"0.7348643",
"0.7342331",
"0.7284005",
"0.7277991",
"0.7223856",
"0.71628565",
"0.7157783",
"0.7124829",
"0.71075344",
"0.71034384",
"0.70795405",
"0.7076924",
"0.70670384",
"0.7040869",
"0.70359844",
"0.7022655",
"0.69981... | 0.60761356 | 99 |
Check object permission explicitly | def check_object_permission(permission, request, view, obj):
if not permission().has_object_permission(request, view, obj):
view.permission_denied(
request, message=getattr(permission, 'message', None)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self , request , view , obj):\n if request.method in permissions.SAFE_METHODS:\n return True\n \n return obj.id == request.user.id",
"def has_object_permission(self, request,view,obj):\n\n if request.method in permissions.SAFE_METHODS:\n ... | [
"0.8233219",
"0.81073236",
"0.8062163",
"0.80545795",
"0.80545795",
"0.7992148",
"0.7978788",
"0.7948386",
"0.7944094",
"0.7928957",
"0.79191506",
"0.79100275",
"0.7898929",
"0.7892742",
"0.7887395",
"0.7880892",
"0.786043",
"0.7853925",
"0.7828313",
"0.78021914",
"0.7801279"... | 0.7935371 | 9 |
Logic to check IsAdmin | def has_permission(self, request, view):
return request.user.group == 'admin' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin(self):\r\n return self.admin",
"def is_admin(self):\n return False",
"def is_admin(self):\n return self.admin",
"def is_admin(self):\n if self.type == 1:\n return True\n else:\n return False",
"def is_admin(self):\n return self._i... | [
"0.8365019",
"0.82752836",
"0.8188533",
"0.81780964",
"0.80866367",
"0.80866367",
"0.80189764",
"0.80126745",
"0.80063874",
"0.7969319",
"0.79527736",
"0.79527736",
"0.7943225",
"0.79196393",
"0.7906165",
"0.7893259",
"0.78324926",
"0.782546",
"0.7793185",
"0.7772955",
"0.775... | 0.70080054 | 78 |
Detect if a string is unicode and encode as utf8 if necessary | def _unicode_encode(self, s):
if isinstance(s, unicode):
return s.encode('utf-8')
else:
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_if_unicode(string, encoding):\n if isinstance(string, compat.unicode_type):\n return string.encode(encoding)\n else:\n return string",
"def encode_utf8(string):\n if isinstance(string, unicode):\n try: \n return string.encode(\"utf-8\")\n except:\n ... | [
"0.8235775",
"0.7682714",
"0.761567",
"0.757977",
"0.7336079",
"0.7318566",
"0.72909296",
"0.72722745",
"0.7269364",
"0.7258999",
"0.72548974",
"0.72349155",
"0.7132942",
"0.7106343",
"0.70799017",
"0.70676583",
"0.7016419",
"0.6975712",
"0.69728166",
"0.6971774",
"0.69609606... | 0.7614967 | 3 |
Get dataset directory path | def get_dataset_dir(dataset_name, data_dir=None, folder=None, create_dir=True):
if not data_dir:
data_dir = os.getenv("DAGBLDR_DATA", os.path.join(
os.path.expanduser("~"), "dagbldr_data"))
if folder is None:
data_dir = os.path.join(data_dir, dataset_name)
else:
data_dir ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_dir(self):\n return self._dataset_dir",
"def dataset_path(cls):\n basepath = os.path.dirname(__file__)\n filepath = os.path.abspath(\n os.path.join(basepath, \"..\", \"datasets\", get_env('DATA_FILENAME')))\n return filepath",
"def dataset_path(dataset, work_d... | [
"0.86802703",
"0.84927994",
"0.833197",
"0.8127515",
"0.795427",
"0.79035944",
"0.7859111",
"0.7820627",
"0.7797325",
"0.7766699",
"0.77482384",
"0.77009135",
"0.7679224",
"0.764534",
"0.7640673",
"0.7640673",
"0.7578858",
"0.7549296",
"0.7542878",
"0.75077206",
"0.7500093",
... | 0.69216084 | 62 |
returns True if prob(`n` is prime) <= 2(`target`) | def rabin_miller(n, target=128):
###############
## Start your code here
return True
## End of your code
############### | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def es_primo(n):\n \n for i in range(2, n):\n if n % i == 0:\n return False\n return True",
"def good_prime(p):\n return p % 4 == 3 and probablyPrime(p, accuracy=100)",
"def is_prime(n):\... | [
"0.65185803",
"0.6411449",
"0.6252246",
"0.6240773",
"0.61441463",
"0.612877",
"0.61243665",
"0.6093008",
"0.6086957",
"0.60837",
"0.6072287",
"0.60722363",
"0.6065737",
"0.6044747",
"0.6018856",
"0.6015212",
"0.5995672",
"0.5987627",
"0.5983543",
"0.59587085",
"0.5928701",
... | 0.0 | -1 |
Queries whether the coordinates in a given array lie within the rectangular sector. If no coordinate is inside, the nearest one to the rectangle center | def contains ( self, pos ):
# make sure xmin is minimum etc
xmin = min(self.x_min,self.x_max)
xmax = max(self.x_min,self.x_max)
ymin = min(self.y_min,self.y_max)
ymax = max(self.y_min,self.y_max)
abs_tol = self.abs_tol
# get pos indices inside rectangle (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_rect(a, b, c, x, y=None):\n x_in = a.x < x.x < b.x and a.y < x.y < c.y\n return x_in if y is None else x_in and a.x < y.x < b.x and a.y < y.y < c.y",
"def isInside(point_x, point_y, area_left, area_top, area_width, area_height):\n return (area_left <= point_x < area_left + area_width) and (area_t... | [
"0.6389873",
"0.6386841",
"0.6366608",
"0.6340976",
"0.6286869",
"0.6264496",
"0.6238886",
"0.62013626",
"0.6182754",
"0.61706823",
"0.61654305",
"0.61147875",
"0.609145",
"0.60809505",
"0.60798424",
"0.6070196",
"0.6062104",
"0.605309",
"0.6029966",
"0.6010486",
"0.6004462",... | 0.61862457 | 8 |
Return x with the kth bit unset. | def unset_bit(x, k):
return x & ~(1 << k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_unset_bit_index(x, k):\n\n if (x == -1):\n return -1\n\n return (x << k) // get_lowest_unset_bit(x)",
"def shift_lowest_set_bit_index(x, k):\n\n return shift_trailing_zeros(x) << k",
"def toggle_bit(x, k):\n\n return x ^ (1 << k)",
"def get_bit(x, k):\n\n return (x >> k... | [
"0.785679",
"0.672574",
"0.6647436",
"0.661932",
"0.6595134",
"0.6560402",
"0.6560175",
"0.6538527",
"0.6374372",
"0.6225628",
"0.60957354",
"0.5836835",
"0.5782423",
"0.56798875",
"0.56410295",
"0.5630133",
"0.5604995",
"0.5586543",
"0.5531352",
"0.5527269",
"0.5489902",
"... | 0.8371103 | 0 |
Return x with the lowest unset bit set to 1. | def drop_lowest_unset_bit(x):
return x | (x + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)",
"def get_lowest_set_bit(x):\n\n return x & -x",
"def drop_lowest_set_bit(x):\n\n return x & (x - 1)",
"def get_lowest_one_mask(x):\n return x & (~(x-1))",
"def replace_lowest_one_with_zero(x):\n return x & (x-1)",
"def shift_lowest_unset_b... | [
"0.86741453",
"0.8289608",
"0.828684",
"0.8127598",
"0.7477113",
"0.7472726",
"0.73668766",
"0.709176",
"0.6992917",
"0.6984007",
"0.6536291",
"0.64560443",
"0.6389169",
"0.6286382",
"0.6286382",
"0.6244122",
"0.61941826",
"0.6119925",
"0.60861117",
"0.6072724",
"0.6052655",
... | 0.8139838 | 3 |
Return x with the lowest set bit extended to the right. | def right_extend_lowest_set_bit(x):
return x | (x - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_set_bit(x):\n\n return x & -x",
"def right_extend_lowest_unset_bit(x):\n\n return x & (x + 1)",
"def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)",
"def drop_lowest_set_bit(x):\n\n return x & (x - 1)",
"def get_lowest_one_mask(x):\n return x & (~(x-1))",
"def drop_lowest_u... | [
"0.8246262",
"0.80287576",
"0.7680289",
"0.758844",
"0.72759986",
"0.7122231",
"0.7062122",
"0.6962807",
"0.69216734",
"0.6797617",
"0.6734647",
"0.67007136",
"0.6609793",
"0.6515218",
"0.649581",
"0.6489792",
"0.64044863",
"0.6327192",
"0.6242736",
"0.6075741",
"0.60599774",... | 0.8558883 | 0 |
Return a number with only the lowest set bit of x set high. | def get_lowest_set_bit(x):
return x & -x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)",
"def drop_lowest_set_bit(x):\n\n return x & (x - 1)",
"def get_lowest_one_mask(x):\n return x & (~(x-1))",
"def drop_lowest_unset_bit(x):\n\n return x | (x + 1)",
"def right_extend_lowest_set_bit(x):\n\n return x | (x - 1)",
"def right_e... | [
"0.83368045",
"0.8178622",
"0.7791736",
"0.7705958",
"0.76094395",
"0.7425341",
"0.7420755",
"0.7139553",
"0.7130183",
"0.7092812",
"0.689913",
"0.6897876",
"0.6850305",
"0.64095664",
"0.64000577",
"0.6246631",
"0.62212706",
"0.62212706",
"0.6080144",
"0.60384214",
"0.600134"... | 0.87011707 | 0 |
Return a number with only the lowest unset bit of x set high. | def get_lowest_unset_bit(x):
return ~x & (x + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_lowest_unset_bit(x):\n\n return x | (x + 1)",
"def drop_lowest_set_bit(x):\n\n return x & (x - 1)",
"def get_lowest_set_bit(x):\n\n return x & -x",
"def get_lowest_one_mask(x):\n return x & (~(x-1))",
"def right_extend_lowest_unset_bit(x):\n\n return x & (x + 1)",
"def shift_lowest_... | [
"0.84037507",
"0.83467925",
"0.81635994",
"0.77223295",
"0.7654197",
"0.7427513",
"0.7378457",
"0.72598803",
"0.72150075",
"0.64417297",
"0.64139",
"0.6370859",
"0.63298297",
"0.6295853",
"0.6222663",
"0.6191402",
"0.6161103",
"0.6161103",
"0.61456406",
"0.60763246",
"0.59350... | 0.87053716 | 0 |
Return True if the kth bit of x is set. | def is_set(x, k):
return get_bit(x, k) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bit(x, k):\n\n return (x >> k) & 1",
"def set_bit(x, k):\n\n return x | (1 << k)",
"def get_bit_position(x, k):\n\n return x & (1 << k)",
"def toggle_bit(x, k):\n\n return x ^ (1 << k)",
"def contains(self, x):\n for i in range(self.k):\n if self.bits[mmh3.hash(x,i) % ... | [
"0.7360053",
"0.7071993",
"0.7017226",
"0.67987436",
"0.6559385",
"0.64691454",
"0.63955414",
"0.62079245",
"0.6098993",
"0.60845166",
"0.60655105",
"0.59974104",
"0.5901778",
"0.58625376",
"0.5828601",
"0.57815087",
"0.57742256",
"0.57185435",
"0.5714837",
"0.5713286",
"0.57... | 0.8555022 | 0 |
Return True if x is odd. | def is_odd(x):
return (x & 1) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd(self, x):\n return x%2",
"def is_odd(x):\n if (x%2==1):\n return True\n else:\n return False",
"def is_odd(x):\n return x % 2 != 0",
"def is_even(self, x):\n return x%2 == 0",
"def is_odd(number):\r\n return number % 2 != 0",
"def is_odd(number: int) -> ... | [
"0.92417246",
"0.90397656",
"0.89947265",
"0.86413765",
"0.82064384",
"0.8120293",
"0.81164205",
"0.8112446",
"0.80544883",
"0.80518025",
"0.7995396",
"0.76766104",
"0.7660533",
"0.75783783",
"0.75357056",
"0.7442092",
"0.74060404",
"0.73995054",
"0.7397562",
"0.73860157",
"0... | 0.85491544 | 4 |
Return True if x is a power of two meaning x only has one bit set high. | def is_power_two(x):
return (x != 0) and (drop_lowest_set_bit(x) == 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_power_of_2(x):\n return x == get_lowest_one_mask(x)",
"def isPower2(num):\n\treturn ((num & (num - 1)) == 0) and num > 0",
"def isPower2(num):\n\treturn ((num & (num - 1)) == 0) and num > 0",
"def isPowerOfTwo(self, n: int) -> bool:\n if n <= 0:\n return False\n return bin(n)... | [
"0.84522396",
"0.76572716",
"0.76572716",
"0.7444844",
"0.74082875",
"0.73730993",
"0.72849196",
"0.7276963",
"0.7218001",
"0.6895004",
"0.670227",
"0.6657333",
"0.64511126",
"0.6438028",
"0.6429878",
"0.6368955",
"0.63538283",
"0.61974114",
"0.61510456",
"0.6137991",
"0.6086... | 0.89744943 | 0 |
Return the n least significant bits of x. | def get_least_significant_bits(x, n):
return x & ones(n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lowest_set_bit(x):\n\n return x & -x",
"def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)",
"def bitget(x, n):\n return (x >> n) & 1",
"def count_significant_bits(input_x: int) -> int:\n x = input_x\n for i in range(x.bit_length()):\n if x & (1 << i) > 0:\n return ... | [
"0.75937796",
"0.7344321",
"0.7224334",
"0.7020355",
"0.7008437",
"0.6986647",
"0.69712573",
"0.6967072",
"0.69609517",
"0.6890778",
"0.68332714",
"0.6801609",
"0.67847633",
"0.67075855",
"0.66670066",
"0.6633309",
"0.6616294",
"0.6567858",
"0.6560542",
"0.65295297",
"0.65019... | 0.8861537 | 0 |
Return x with bits swapped according to bit_array. If bit_array has two bits set high, these two bits indicate the two bits that you want to swap. If bit_array only has one bit set high, the second bit defaults to the first bit index + 1. If bit_array has no bits set high, nothing is swapped. | def swap_bits_bit_array(x, bit_array):
if (is_power_two(bit_array)):
bit_array |= bit_array << 1
if (is_power_two(x & bit_array)):
x ^= bit_array
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_bits_bit_array(x, bit_array):\n\n mask = bit_array - 1\n\n lower = x & mask\n upper = x & ~mask\n\n return lower, upper",
"def shift_lowest_unset_bit_bit_array(x, bit_array):\n\n if (x == -1):\n return -1\n\n return (x * bit_array) // get_lowest_unset_bit(x)",
"def shift_lowe... | [
"0.7058473",
"0.6840852",
"0.67505944",
"0.6483858",
"0.6273972",
"0.6252496",
"0.60304403",
"0.58818495",
"0.58431095",
"0.5740533",
"0.5719198",
"0.55437213",
"0.552858",
"0.5495178",
"0.5482866",
"0.54474443",
"0.53210145",
"0.5308464",
"0.52962476",
"0.5262038",
"0.525798... | 0.8700425 | 0 |
Return x logically right shifted by k. k can be negative, which would mean a logical left shift. | def shift_bits(x, k):
if (k >= 0):
return x << k
else:
return x >> -k | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_unset_bit_index(x, k):\n\n if (x == -1):\n return -1\n\n return (x << k) // get_lowest_unset_bit(x)",
"def shift_lowest_set_bit_index(x, k):\n\n return shift_trailing_zeros(x) << k",
"def get_bit(x, k):\n\n return (x >> k) & 1",
"def get_bit_position(x, k):\n\n return x... | [
"0.73530054",
"0.7301117",
"0.6804961",
"0.6659019",
"0.653539",
"0.64145637",
"0.6338609",
"0.63025296",
"0.624316",
"0.62376416",
"0.6236587",
"0.62338376",
"0.6064034",
"0.6064034",
"0.6008495",
"0.59854186",
"0.5864433",
"0.5854073",
"0.5837134",
"0.5777427",
"0.57766527"... | 0.8206654 | 0 |
Return x with the trailing 1's shifted out (to the right). You can also think of it as shifting the lowest unset bit to the 0th bit. If there are no 0's, return 1. | def shift_trailing_ones(x):
if (x == -1):
return -1
return x // get_lowest_unset_bit(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_trailing_zeros(x):\n\n if (x == 0):\n return 0\n\n return x // get_lowest_set_bit(x)",
"def drop_lowest_unset_bit(x):\n\n return x | (x + 1)",
"def get_lowest_unset_bit(x):\n\n return ~x & (x + 1)",
"def right_extend_lowest_unset_bit(x):\n\n return x & (x + 1)",
"def replace... | [
"0.84050584",
"0.760099",
"0.75577164",
"0.7538504",
"0.73925316",
"0.733938",
"0.72805756",
"0.72624636",
"0.72570235",
"0.70080304",
"0.6960269",
"0.6888363",
"0.6810049",
"0.65769964",
"0.6575856",
"0.6529422",
"0.6500505",
"0.6482913",
"0.6428625",
"0.6344328",
"0.6210393... | 0.86418754 | 0 |
Return x with the lowest set bit shifted to the kth bit. If there are no 1's, return 0. This can use shift_trailing_zeros() on x first because the lost 0's will be shifted back in. | def shift_lowest_set_bit_index(x, k):
return shift_trailing_zeros(x) << k | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_unset_bit_index(x, k):\n\n if (x == -1):\n return -1\n\n return (x << k) // get_lowest_unset_bit(x)",
"def shift_bits(x, k):\n if (k >= 0):\n return x << k\n else:\n return x >> -k",
"def get_bits(x, k, size, offset=0):\n\n answer = x >> offset\n answer >... | [
"0.848231",
"0.79114425",
"0.75010514",
"0.74990636",
"0.73637533",
"0.6855699",
"0.67306244",
"0.6711019",
"0.66867274",
"0.6631109",
"0.65762556",
"0.6496599",
"0.64825374",
"0.63554454",
"0.63347757",
"0.63296217",
"0.625746",
"0.62024456",
"0.61418575",
"0.61057866",
"0.6... | 0.89036864 | 0 |
Return x with the lowest unset bit shifted to the kth bit. If there are no 0's, return 1. This can't use shift_trailing_ones() on x first because the ones will be lost. | def shift_lowest_unset_bit_index(x, k):
if (x == -1):
return -1
return (x << k) // get_lowest_unset_bit(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_lowest_set_bit_index(x, k):\n\n return shift_trailing_zeros(x) << k",
"def shift_bits(x, k):\n if (k >= 0):\n return x << k\n else:\n return x >> -k",
"def get_bit_position(x, k):\n\n return x & (1 << k)",
"def get_bit(x, k):\n\n return (x >> k) & 1",
"def get_lowest_... | [
"0.85546774",
"0.74955034",
"0.72534764",
"0.7177372",
"0.7127356",
"0.7074932",
"0.6874598",
"0.6869122",
"0.67564464",
"0.6744918",
"0.66561425",
"0.6588411",
"0.65520877",
"0.6499034",
"0.64703053",
"0.63558346",
"0.6336695",
"0.63219285",
"0.6312908",
"0.6254256",
"0.6200... | 0.8622787 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.