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 |
|---|---|---|---|---|---|---|
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
text_OK = False
city_conf_text = 'Chosen city is {}? Enter "y" to confirm. '
while True:
city = input('\n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, week_day):
# name for day variable changed from "day_name" into week_day to take into account new pandas method ".day_name()"
# read in file form selected city
df = pd.read_csv(CITY_DATA[city])
# create additional columns for months, days, start/ end times, hours and station combina... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.8131557",
"0.8108646",
"0.80456805",
"0.8041907",
"0.8008996",
"0.80066293",
"0.799892",
"0.79980177",
"0.79883647",
"0.79786384",
"0.7973428",
"0.79604656",
"0.7955707",
"0.7946914",
"0.79457873",
"0.7907952",
"0.79078037",
"0.79041624",
"0.7900135",
"0.7892769",
"0.78888... | 0.0 | -1 |
Displays statistics on the most frequent times of travel. | def time_stats(df, month, week_day):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# display the most common month
if month == 7:
pop_month_start_num = df['month_start'].mode()[0]
pop_month_start = months[pop_month_start_num - 1].title()
p... | {
"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.80235124",
"0.80223495",
"0.7914819",
"0.78260994",
"0.7821642",
"0.78139323",
"0.77653635",
"0.7739615",
"0.77358055",
"0.7733576",
"0.7686211",
"0.7667902",
"0.76510555",
"0.76440334",
"0.76391727",
"0.7636328",
"0.7624661",
"0.7622607",
"0.76119757",
"0.7599401",
"0.758... | 0.0 | -1 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# display most commonly used start station
pop_start_station = df['Start Station'].mode()[0]
print('The most popular START STATION for renting a bike is {}. '.format(pop_start_station))
... | {
"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.0 | -1 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# display total travel time
tot_sum = (df['End Time'] - df['Start Time']).sum()
print('The total travel time for all trips within the selected data set is {} (hh:mm:ss).'.format(tot_sum))
# display m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.7584329 | 93 |
I rebalance the tree. | def rebalance(self, node):
# perform rebalance until root
while node != None:
# compute node height
node.updateHeight()
# store node's parent
parent = node.parent
# node balance factor is 2: rotate it properly
if node.balanceFact... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rebalance(self):\n prev_height = self._height # Save current height for comparison later\n self._height = self.height() # Update the height of the node\n if self._unbalanced():\n if self.full():\n if self._leftchild._height > self._rightchild._height:\n ... | [
"0.7963739",
"0.7918383",
"0.78662556",
"0.75338566",
"0.73955345",
"0.7141099",
"0.7101765",
"0.68558115",
"0.67163277",
"0.66535354",
"0.65619683",
"0.6451634",
"0.63025844",
"0.62915564",
"0.6283278",
"0.626441",
"0.6260662",
"0.6244254",
"0.62398833",
"0.62159663",
"0.621... | 0.75646424 | 3 |
A utility function to test if two atoms are the same regardless of their IDs. | def __eq__(self, other):
if type(self) != type(other):
return False
else:
return ((self.name == other.name) and (self.value == other.value)
and (self.time == other.time)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isIsosceles(self):\n\t\treturn self.a == self.b or self.a == self.c or self.b == self.c",
"def is_equal(self, a, b):\n return a is b",
"def _are_assumed_equal(a, b, assumed_equivs):\n\n # Are we just assuming that the two are equal?\n equiv = (id(a), id(b))\n if equiv in assumed_equivs:\n retu... | [
"0.6669723",
"0.6570769",
"0.6536498",
"0.65263814",
"0.64910364",
"0.648458",
"0.64796185",
"0.64715624",
"0.6441356",
"0.6433267",
"0.6431419",
"0.64223903",
"0.63988644",
"0.6378566",
"0.63738555",
"0.6373344",
"0.636345",
"0.6360412",
"0.6356157",
"0.6347841",
"0.63342994... | 0.0 | -1 |
Get time zone offset. | def get_timzone_offset(self, timezone):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tzoffset(self):\n return _tzoffset(self._tz, self._t)",
"def _local_time_offset():\n if time.localtime().tm_isdst and time.daylight:\n return -time.altzone\n else:\n return -time.timezone",
"def get_utc_offset():\n timedelta = datetime.datetime.now() - datetime.datetime.utcnow... | [
"0.8114098",
"0.7687836",
"0.76663375",
"0.763602",
"0.7618972",
"0.75373244",
"0.75334746",
"0.7246631",
"0.72184235",
"0.720433",
"0.7117189",
"0.7107194",
"0.70973885",
"0.7074649",
"0.7069205",
"0.7056303",
"0.7024507",
"0.7002665",
"0.6923286",
"0.6848891",
"0.6834723",
... | 0.7916148 | 1 |
Reset the encoder values to zero | def ReInitialize_Encoders(self):
for i in range(3):
self.fd_channel[i].write(b'\x00\x00\x00')
# Write zeros to 24 bit PR register
fcntl.ioctl(self.fd_channel[i], self.LOAD_CMD_REG, self.TRAN_PR_CNTR)
# Transfers the PR register to the counter
self.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.enc_len = None\n self.precomputed_enc_h = None\n self.mask = None",
"def reset(self):\n self.enc_len = None\n self.precomputed_enc_h = None\n self.mask = None\n self.prev_attn = None",
"def reset(self):\n self.values = None\n ... | [
"0.7715912",
"0.7498753",
"0.7079342",
"0.69441664",
"0.69384253",
"0.6871477",
"0.68487144",
"0.68310565",
"0.6801526",
"0.6756597",
"0.6753875",
"0.6745159",
"0.6740667",
"0.6717318",
"0.67017263",
"0.6696437",
"0.668092",
"0.6667224",
"0.66662085",
"0.6658621",
"0.6647675"... | 0.6548937 | 33 |
Stage position frame in the Tk GUI. Defines buttons and their location | def Define_Frame(self):
self.frame=Frame(self.master, relief=GROOVE, bd=4)
self.frame.grid(row=0,column=1,rowspan=2,columnspan=2)
frame_title = Label(self.frame,text="Stage Control",relief=RAISED,bd=2,width=24, bg="light yellow",font=("Times", 16))
frame_title.grid(row=0, column=1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_button_gui(self):\n cont = self.container\n\n # This container is used for centering.\n but_cont = ttk.Frame(cont)\n but_cont.grid(row=10, column=0, sticky='ew')\n tku.prepare_centering(but_cont)\n\n # This container actually holds the buttons.\n but_cont2 = ttk.Frame(but_cont)\n ... | [
"0.6765841",
"0.6737861",
"0.6707397",
"0.6681542",
"0.6503716",
"0.65012497",
"0.6474421",
"0.6459724",
"0.6450532",
"0.64097995",
"0.6407992",
"0.640231",
"0.63891834",
"0.6373193",
"0.63693386",
"0.6295125",
"0.6282915",
"0.62717146",
"0.62624186",
"0.6261977",
"0.622761",... | 0.6772856 | 0 |
Add a job title with system defined category and program id, the program id , category and job title makes a unique set. | def post(self, request):
settings.LOGGER.info(
"JobTitleView >> post >> request: {}".format(request.POST))
try:
serializer = JobTitleSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
settings.LOGGER.info(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_job_title(self):\n inv_search = 'title:engineer not title:programmer'\n spi_search = 'find job engineer not position programmer'\n self._compare_searches(inv_search, spi_search)",
"def create_job(project, description):\n randomnames = open(os.path.join(\"Anemone\", \"... | [
"0.5473698",
"0.54642886",
"0.5456923",
"0.54051816",
"0.53663737",
"0.5351387",
"0.5318119",
"0.52990985",
"0.5296978",
"0.5265019",
"0.5242906",
"0.5203784",
"0.51732147",
"0.51128894",
"0.5091719",
"0.50734794",
"0.5058318",
"0.50224304",
"0.50088704",
"0.4998208",
"0.4989... | 0.0 | -1 |
Gets the displayed name of this AI. | def getName(self):
return "Antiyoy AI" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"display_name\")",
"def display_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"display_name\")",
"def displ... | [
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84242225",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223",
"0.84184223"... | 0.0 | -1 |
Retrieve the EFO term label. | def label(efo):
url = 'https://www.ebi.ac.uk/ols/api/ontologies/efo/terms?iri=http://www.ebi.ac.uk/efo/'+efo
try:
response = requests.get(url).json()
except:
return ""
if 'error' in response.keys():
return ""
return response['_embedded']['terms'][0]['label'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_label(urs):\n return assign_term(urs)[1]",
"def entity_label(self, eid):\n entities = self._load_entities()\n return entities[eid][\"label\"]",
"def _get_label(self):\n return self.label",
"def get_label(self, ):\n return self.attrs.get(self.AttributeNames.LABEL, None)"... | [
"0.6996399",
"0.679516",
"0.6789283",
"0.669412",
"0.6662217",
"0.66592497",
"0.66592497",
"0.66592497",
"0.66592497",
"0.66532314",
"0.6617111",
"0.6614944",
"0.6613897",
"0.6613897",
"0.6613897",
"0.6601244",
"0.6580295",
"0.6564287",
"0.6562638",
"0.6562638",
"0.6562638",
... | 0.79824245 | 0 |
Fetch the cluster configuration details. | def get_cluster_config(cohesity_client):
config = cohesity_client.cluster.get_cluster()
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster_config(self, cluster_name: str) -> dict:\n\n try:\n response = self.session.get(\n url=f'{self.url}/{cluster_name}',\n headers=self._get_request_header(),\n timeout=self._timeout_config\n )\n except RequestsConnectionE... | [
"0.736589",
"0.7346189",
"0.71583754",
"0.6833823",
"0.67531306",
"0.65792304",
"0.6477731",
"0.64691406",
"0.64297867",
"0.6385467",
"0.63468",
"0.6320102",
"0.63129514",
"0.6277506",
"0.6277506",
"0.6247529",
"0.62389594",
"0.6229865",
"0.6214853",
"0.62041736",
"0.614486",... | 0.72812015 | 2 |
Get default parameters and setting. These setting are predefined for common analysis. For an alternate setup, generate \"RNAseq_pipeline_defaults.txt\" under home folder and/or run path. Predefined parameters are superseded by \"RNAseq_pipeline_defaults.txt\" file under home path and that, in turn, is superseded by the... | def get_defaults():
# get package defaults
with open(os.path.join(iLoop_RNAseq_pipeline.__path__[0], 'defaults', 'RNAseq_pipeline_defaults.txt')) as rpd:
defaults = {}
for line in rpd.readlines():
if line.strip():
defaults[line.split(',')[0].strip()] = line.split(','... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_params():\n\n with IOTools.open_file(os.path.join(os.path.dirname(__file__),\n \"defaults.yml\")) as inf:\n result = yaml.load(inf, Loader=RoundTripLoader)\n return result",
"def get_default_params_file() -> Path:\n return get_path_to_pyflow(... | [
"0.70365804",
"0.66658",
"0.6646884",
"0.66009355",
"0.6429898",
"0.6395395",
"0.63865936",
"0.6361334",
"0.6339925",
"0.630356",
"0.62843144",
"0.6280962",
"0.62805986",
"0.6258651",
"0.62187433",
"0.62183136",
"0.6203209",
"0.6195272",
"0.61935234",
"0.6158887",
"0.61224854... | 0.74645346 | 0 |
>>> p = {2, 3, 5, 7, 11, 13, 17, 19} >>> tests = (prime(n) == (n in p) ... for n in range(2, 21) ... ) >>> all(tests) True >>> prime(9973) True >>> prime(9997) False | def prime(n: int) -> bool:
factors = find_first(lambda i: n % i == 0, range(2, int(math.sqrt(n) + 1)))
return len(list(factors)) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n\n prime_set = primes(n + 1)\n return n in prime_set",
"def is_prime(n):\n test_vals = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n if n in test_vals:\n return True\n d = n - 1\n s = 0\n while not d & 1:\n d = d >> 1\n s += 1\n for a in test_vals:\n for r in range(0, s... | [
"0.7799041",
"0.74937814",
"0.7493588",
"0.7408851",
"0.73645663",
"0.7317609",
"0.73126787",
"0.7255527",
"0.723234",
"0.7148987",
"0.7141445",
"0.7141022",
"0.71347225",
"0.71173453",
"0.70990604",
"0.7090064",
"0.70712626",
"0.70701075",
"0.7060674",
"0.7060552",
"0.705128... | 0.68508613 | 56 |
>>> p = {2, 3, 5, 7, 11, 13, 17, 19} >>> tests = (prime_t(n) == (n in p) ... for n in range(2, 21) ... ) >>> all(tests) True >>> prime_t(9973) True >>> prime_t(9997) False | def prime_t(n: int) -> bool:
tests = set(range(2, int(math.sqrt(n) + 1)))
non_factors = set(takewhile(lambda i: n % i != 0, tests))
return tests == non_factors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n\n prime_set = primes(n + 1)\n return n in prime_set",
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def is_prime(n):\n test_vals = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n if n in test_vals:\n return True\n d = n - 1\n s = 0... | [
"0.7313725",
"0.72568756",
"0.72117835",
"0.70340055",
"0.69727284",
"0.69264084",
"0.69167405",
"0.6908247",
"0.68976057",
"0.68683493",
"0.6834534",
"0.68313044",
"0.6809433",
"0.6806866",
"0.67972153",
"0.6794178",
"0.67930144",
"0.6732481",
"0.6723465",
"0.67158353",
"0.6... | 0.70916456 | 4 |
>>> p = {2, 3, 5, 7, 11, 13, 17, 19} >>> tests = (prime_any(n) == (n in p) ... for n in range(2, 21) ... ) >>> all(tests) True >>> prime_any(9973) True >>> prime_any(9997) False | def prime_any(n: int) -> bool:
tests = range(2, int(math.sqrt(n) + 1))
has_factors = any(n % t == 0 for t in tests)
return not has_factors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n\n prime_set = primes(n + 1)\n return n in prime_set",
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def is_prime(n):\n test_vals = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n if n in test_vals:\n return True\n d = n - 1\n s = 0... | [
"0.7181846",
"0.6898149",
"0.68793786",
"0.68543464",
"0.67247844",
"0.668284",
"0.6675213",
"0.666668",
"0.6655934",
"0.6623585",
"0.6618737",
"0.6592692",
"0.65831786",
"0.65795034",
"0.65768504",
"0.65621936",
"0.65424985",
"0.6538722",
"0.6531022",
"0.65181994",
"0.648928... | 0.7146152 | 1 |
>>> list(primeset(range(2, 21))) [2, 3, 5, 7, 11, 13, 17, 19] | def primeset(source: Iterable[int]) -> Iterator[int]:
for i in source:
if prime(i):
yield i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_set_prime_numbers(number):\n prime_numbers = set()\n\n for i in range(2, number + 1):\n for j in prime_numbers:\n if i % j == 0:\n break\n else:\n prime_numbers.add(i)\n\n return prime_numbers",
"def gen_primes(limit=10000):\n\n candidates = ... | [
"0.8338889",
"0.7561285",
"0.75049454",
"0.748565",
"0.7357091",
"0.73143554",
"0.72272825",
"0.713704",
"0.7135844",
"0.7130501",
"0.7106237",
"0.7105116",
"0.71001226",
"0.7083318",
"0.7052981",
"0.7044474",
"0.69936013",
"0.69803995",
"0.6978609",
"0.6977743",
"0.6919769",... | 0.7484329 | 4 |
Return an ordering of the nbit integers by increasing bit count. | def orderByIncreasingBitCount(n):
res = [0] # freebie
biggest = 2**n - 1
for i in range(1, n):
for j in range(1, biggest):
if hamming_weight(j) == i:
res.append(j)
res.append(biggest) # another freebie
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bits(n):\n\n # Create a list of the first 1,000 binary numbers\n binary_list = reverse_binary_list()\n\n # Start by calculating number of 1's for n\n n_ones = num_of_ones(n, binary_list)\n\n # Calculate number of 1's for next value\n next_ones = 0\n while n_ones != next_ones:\n n = ... | [
"0.6160015",
"0.6099676",
"0.5974707",
"0.59488124",
"0.5914475",
"0.58844227",
"0.58460546",
"0.5804653",
"0.5740673",
"0.57353914",
"0.57286286",
"0.568372",
"0.56732494",
"0.5668087",
"0.5661544",
"0.5660755",
"0.5653851",
"0.56387144",
"0.56386966",
"0.5618264",
"0.561682... | 0.7632072 | 0 |
Takes file path as string; returns text as string. Takes a string that is a file path, opens the file, and Turns the file's contents as one string of text. | def open_and_read_file(file_path):
# Read the file, return text as a string titled "contents"
contents = open(file_path).read()
# Return contents of your file as one long string
return contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_and_read_file(file_path):\n\n text_file = open(file_path)\n full_text = text_file.read()\n\n return full_text",
"def open_and_read_file(file_path):\n\n # your code goes here\n text_file = open(file_path)\n text_string= text_file.read()\n text_file.close()\n return text_string",
... | [
"0.83131844",
"0.8230455",
"0.8229315",
"0.81497365",
"0.81140405",
"0.80929667",
"0.8035107",
"0.79442555",
"0.7939859",
"0.7872458",
"0.7834842",
"0.7826561",
"0.7807666",
"0.78003234",
"0.7738249",
"0.7610164",
"0.75931025",
"0.7563546",
"0.75231177",
"0.74875945",
"0.7438... | 0.77900875 | 14 |
Get cached cairo surface. | def get_surface(**kwargs):
icon = _IconBuffer()
for key, value in kwargs.items():
icon.__setattr__(key, value)
return icon.get_surface() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cairo_surface(filename, width, height):\n surface = cairo.PDFSurface(filename, width, height)\n return surface",
"def get_context(self):\n return cairo.Context(self._s)",
"def cairo_context(surface):\n context = cairo.Context(surface)\n context.scale(mm_to_pt(1), mm_to_pt(1))\n return... | [
"0.6860621",
"0.642825",
"0.6160079",
"0.6106446",
"0.6083988",
"0.60276634",
"0.59859467",
"0.5962177",
"0.584543",
"0.5700429",
"0.55785954",
"0.5509315",
"0.5405318",
"0.5405318",
"0.5399263",
"0.53562206",
"0.5313273",
"0.5228028",
"0.52064884",
"0.5190411",
"0.5182306",
... | 0.58941996 | 8 |
Calculate the Hamming distance between two bit strings | def hamming_distance(s1, s2):
return sum(c1 != c2 for c1, c2 in zip(s1, s2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hamming_distance(input1, input2):\n if len(input1) != len(input2):\n raise ValueError('Length of input1 and input2 are not equal.')\n input1 = hex_decode(hex_encode(input1))\n input2 = hex_decode(hex_encode(input2))\n # the general strategy here is to xor the two strings together\n # and ... | [
"0.86581886",
"0.8609805",
"0.83848983",
"0.8360063",
"0.83254594",
"0.8282518",
"0.81959116",
"0.815917",
"0.8092042",
"0.8089088",
"0.80491406",
"0.8043047",
"0.8019958",
"0.8018021",
"0.8009184",
"0.7942804",
"0.7872873",
"0.782325",
"0.77714366",
"0.77687335",
"0.7726213"... | 0.8044223 | 11 |
Returns the value to which the specified key is mapped, or 1 if this map contains no mapping for the key | def get(self, key):
index = key % self.size
cur = self.bucket[index]
while cur:
if cur.key == key:
return cur.val
cur = cur.next
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key: int) -> int:\n if key not in self.map:\n return -1\n return self.map[key]",
"def get(self, key: int) -> int:\n if key in self.hashmap.keys():return self.hashmap[key]\n else:return -1",
"def get(self, key: int) -> int:\n sh = key % 37\n if ... | [
"0.8003586",
"0.79090834",
"0.762897",
"0.7564004",
"0.7556298",
"0.7529827",
"0.7525957",
"0.74929136",
"0.73735875",
"0.7294219",
"0.7293118",
"0.72221535",
"0.7215888",
"0.7180873",
"0.7177207",
"0.7161431",
"0.69811606",
"0.6928305",
"0.6784603",
"0.6756287",
"0.6732945",... | 0.6393806 | 31 |
Turn byte string or unicode string into a unicode string (PRIVATE). | def _as_unicode(s):
if isinstance(s, str):
return s
# Assume it is a bytes string
# Note ISO-8859-1 aka Latin-1 preserves first 256 chars
return codecs.latin_1_decode(s)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asunicode(s):\n if isinstance(s, bytes):\n return s.decode('utf-8', 'replace')\n else:\n return s",
"def as_unicode(string):\n return same_string_type_as(\"\", string)",
"def make_unicode(string):\n if sys.version < '3' and isinstance(string, str):\n return unicode(string.d... | [
"0.79828906",
"0.7899803",
"0.78666604",
"0.7707591",
"0.7692861",
"0.76289684",
"0.7614199",
"0.75872463",
"0.756025",
"0.7552921",
"0.7516569",
"0.74821585",
"0.747283",
"0.7453585",
"0.7435766",
"0.74259853",
"0.74032134",
"0.73785543",
"0.73785543",
"0.73448074",
"0.73062... | 0.74650633 | 13 |
Checks if a product is in stock | def is_in_stock(res_obj):
selector = '#app > div.page-content > div.page-section > div > div > div.row-side > div.product-buy-box > div.product-flag > div > div > span'
stock = res_obj.html.find(selector, first=True)
if stock == None:
return True
if stock.text == 'OUT OF STOCK':
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def is_in_stock(cls, product: Product, session: ClientSession) -> bool:\n if not cls.is_expected_fqdn(product.fqdn):\n raise UnexpectedFQDN\n resp = await session.request(\n method=\"GET\", url=product.url, raise_for_status=True\n )\n try:\n return... | [
"0.8031233",
"0.7914503",
"0.7534334",
"0.7272875",
"0.7244365",
"0.72259575",
"0.7126557",
"0.69856846",
"0.6984308",
"0.68941766",
"0.6754919",
"0.6637641",
"0.66218525",
"0.6571009",
"0.6522367",
"0.6493364",
"0.64595187",
"0.64439434",
"0.6424697",
"0.62896127",
"0.627917... | 0.7837728 | 2 |
Special initialization of certain model weights. | def _reset_parameters(self):
if self.cfg.initial_forget_bias is not None:
self.hindcast_lstm.bias_hh_l0.data[self.cfg.hidden_size:2 * self.cfg.hidden_size] = self.cfg.initial_forget_bias | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(model):\n ...",
"def init_weights_(self):\n raise NotImplementedError",
"def _initialize_weights(self):\n pass",
"def initialize_weights(self):\n weights_initializer.WeightsInitializer.initialize_layer_or_model(\n self._batch)",
"def setWeightInitializer(self... | [
"0.8807841",
"0.8478919",
"0.8317759",
"0.8259904",
"0.81699884",
"0.8132161",
"0.8086595",
"0.8037357",
"0.8011198",
"0.7983077",
"0.79621196",
"0.79621196",
"0.7953538",
"0.7951533",
"0.79456466",
"0.7940514",
"0.782644",
"0.77934897",
"0.7766713",
"0.7761337",
"0.77286774"... | 0.0 | -1 |
Perform a forward pass on the MultiheadForecastLSTM model. | def forward(self, data: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]:
# possibly pass dynamic and static inputs through embedding layers, then concatenate them
x_h = self.hindcast_embedding_net(data)
x_f = self.forecast_embedding_net(data)
# run hindcast part of the lstm
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x):\n # Set initial states\n h0_variable = torch.zeros(self.num_layers * 2, x.size(0), self.hidden_size).to(self.device)\n c0_variable = torch.zeros(self.num_layers * 2, x.size(0), self.hidden_size).to(self.device)\n\n # Forward propagate LSTM\n out, _ = self.ls... | [
"0.6934581",
"0.6786432",
"0.67352366",
"0.6726805",
"0.66073835",
"0.65423995",
"0.64748937",
"0.64720213",
"0.64686567",
"0.64573485",
"0.64095575",
"0.63642955",
"0.636062",
"0.636062",
"0.6357213",
"0.63501835",
"0.63420254",
"0.6290306",
"0.62771",
"0.6203052",
"0.619438... | 0.5738834 | 81 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, IncidentInfoV2):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Given an input directed graph, returns its reverse. | def reverse_test_graph(graph):
flatten = lambda l: [item for sublist in l for item in sublist] # flattens a list of lists
nodes = set(graph.keys()).union(set(flatten(graph.values())))
reversed_graph = {node: [] for node in nodes}
for row in graph:
outgoing_edges = graph[row]
for edge in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reversed_graph(directed_graph):\n\n reversed = directed_graph.__class__()\n for i in directed_graph.get_vertices().keys():\n reversed.add_vertex(i)\n\n for i in directed_graph.get_vertices().keys():\n vertex = directed_graph.get_vertex(i)\n for j in vertex.get_heads():\n ... | [
"0.79482424",
"0.7650989",
"0.69474876",
"0.6856863",
"0.66126597",
"0.6611828",
"0.6580383",
"0.64982295",
"0.64140075",
"0.63691974",
"0.6364908",
"0.6309494",
"0.62161905",
"0.62152755",
"0.61902934",
"0.6189799",
"0.6161129",
"0.6149108",
"0.6112712",
"0.608629",
"0.60351... | 0.7047143 | 2 |
Must always have at least one user with the Admin role (and anon doesn't count). | def test_cannot_remove_all_admins(self):
r = self.app.get('/admin/groups/')
admin_holder = r.html.find(
'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
admin_id = admin_holder['data-group']
users = admin_holder.find('ul', {'class': 'users'}).findAll(
'li', {'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_admin():\r\n if not current_user.is_admin:\r\n abort(403)",
"def check_admin():\n if not current_user.is_admin:\n abort(403)",
"def check_admin():\n if not current_user.is_admin:\n abort(403)",
"def check_admin():\n\tif not current_user.is_admin:\n\t\tabort(403)",
"d... | [
"0.67763656",
"0.67606527",
"0.67606527",
"0.66570437",
"0.66285825",
"0.6553558",
"0.65198165",
"0.6474044",
"0.6470885",
"0.64612126",
"0.6449902",
"0.64238375",
"0.6338849",
"0.6288632",
"0.6272081",
"0.62683195",
"0.62599576",
"0.62138915",
"0.61945766",
"0.6191175",
"0.6... | 0.5927007 | 60 |
Indicates if Reeborg is facing North (top of the screen) or not. | def is_facing_north(): #py:is_facing_north
return RUR._is_facing_north_() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_facing_north(self): #py:UR.is_facing_north\n return RUR._UR.is_facing_north_(self.body)",
"def is_origin(self) -> bool:\n return self.x == 0 and self.y == 0",
"def is_center(self):\n if self.pupils_located:\n return self.is_right() is not True and self.is_left() is not T... | [
"0.7919203",
"0.6518342",
"0.62704915",
"0.61221063",
"0.605618",
"0.6022997",
"0.59548485",
"0.586084",
"0.5789783",
"0.5760996",
"0.56978303",
"0.5693609",
"0.5672032",
"0.5656589",
"0.5638894",
"0.55956614",
"0.5560494",
"0.5521336",
"0.547523",
"0.54616797",
"0.5453688",
... | 0.77814716 | 1 |
Indicates if Reeborg is facing North (top of the screen) or not. | def is_facing_north(self): #py:UR.is_facing_north
return RUR._UR.is_facing_north_(self.body) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_facing_north(): #py:is_facing_north\n return RUR._is_facing_north_()",
"def is_origin(self) -> bool:\n return self.x == 0 and self.y == 0",
"def is_center(self):\n if self.pupils_located:\n return self.is_right() is not True and self.is_left() is not True",
"def check_top(... | [
"0.77814716",
"0.6518342",
"0.62704915",
"0.61221063",
"0.605618",
"0.6022997",
"0.59548485",
"0.586084",
"0.5789783",
"0.5760996",
"0.56978303",
"0.5693609",
"0.5672032",
"0.5656589",
"0.5638894",
"0.55956614",
"0.5560494",
"0.5521336",
"0.547523",
"0.54616797",
"0.5453688",... | 0.7919203 | 0 |
Implement the linear part of a layer's backward propagation dW[l] = (dZ[l]A[l1].T)/m db[l] = (np.sum(dZ, axis=1, keepdims=True))/m dA[l1] = W[l].T dZ[l] | def linear_backward(dZ: np.array, cache: Tuple) -> Tuple:
A_prev, W, b = cache
m = A_prev.shape[1] # number of examples
dW = (np.dot(dZ, A_prev.T))/m
db = (np.sum(dZ, axis=1, keepdims=True))/m
dA_prev = np.dot(W.T, dZ)
return dA_prev, dW, db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_backward_calculation(dZ, internal_params):\n\n A_prev, W, b = internal_params\n nb = A_prev.shape[1]\n\n ### START CODE HERE ### (≈ 3 lines of code)\n dW =np.multiply((np.dot(dZ, A_prev.T)),1/nb)\n db = np.multiply ((np.sum(dZ, axis=1, keepdims=True),1/nb))\n dA_prev = np.dot(W.T, dZ)\... | [
"0.7908602",
"0.76593405",
"0.7646032",
"0.7582416",
"0.752185",
"0.74883837",
"0.7454244",
"0.7352305",
"0.7216037",
"0.712672",
"0.71181947",
"0.69684166",
"0.69647133",
"0.6905091",
"0.6904065",
"0.6897094",
"0.6870892",
"0.68291605",
"0.68221414",
"0.67836654",
"0.6755764... | 0.7314945 | 8 |
Determine if the species has look for functional group attachments that could cause molecule instabilities | def instability_product_zmas(zma, stereo=True):
ich = automol.geom.inchi(automol.zmat.geometry(zma))
instab_ichs = instability_product_inchis(ich, stereo=stereo)
if instab_ichs is not None:
instab_zmas = tuple(automol.inchi.zmatrix(ich)
for ich in instab_ichs)
else:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_calib_groups(self):\n is_science = self.find_frames('science')\n for i in range(len(self)):\n if not is_science[i]:\n continue\n if len(self.calib_bitmask.flagged_bits(self['calibbit'][i])) > 1:\n msgs.error('Science frames can only be as... | [
"0.58665705",
"0.5796943",
"0.5576857",
"0.55763674",
"0.5548222",
"0.550208",
"0.5486317",
"0.5394382",
"0.537463",
"0.53571206",
"0.5311446",
"0.5302816",
"0.5292797",
"0.52856207",
"0.52853626",
"0.52630234",
"0.52620894",
"0.5251455",
"0.52503026",
"0.5244021",
"0.5230866... | 0.0 | -1 |
Determine if the species has look for functional group attachments that could cause molecule instabilities | def instability_product_graphs(gra, stereo=True):
# Build graphs for the detection scheme
rad_grp_dct = radical_group_dct(gra)
# Check for instability causing functional groups
prd_gras = ()
for atm, grps in rad_grp_dct.items():
if atm in instab_fgrps.DCT:
fgrps_dct = instab_fg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_calib_groups(self):\n is_science = self.find_frames('science')\n for i in range(len(self)):\n if not is_science[i]:\n continue\n if len(self.calib_bitmask.flagged_bits(self['calibbit'][i])) > 1:\n msgs.error('Science frames can only be as... | [
"0.58681464",
"0.5795681",
"0.55763006",
"0.5575406",
"0.55502933",
"0.55019075",
"0.5485602",
"0.5396502",
"0.53750575",
"0.5358191",
"0.53118396",
"0.53025126",
"0.52932537",
"0.52866656",
"0.5286499",
"0.52617234",
"0.526155",
"0.52516264",
"0.5251058",
"0.52441525",
"0.52... | 0.0 | -1 |
get the original position of the axes. | def get_original_position(self, axes, renderer):
if self._locator is None:
bbox = axes.get_position(original=True)
else:
bbox = self._locator(axes, renderer)
return bbox | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_machinekit_position():\n return settings.controller.axes_position()",
"def origin(self):\r\n\r\n return self.ox, self.oy, self.oz",
"def position(self):\n return self._position.copy()",
"def get_pos(self) -> tuple:\n return self.rect.center",
"def adjust_position(self):\n\n ... | [
"0.73908794",
"0.66588074",
"0.6495541",
"0.64886403",
"0.64827746",
"0.6476158",
"0.6462129",
"0.6457132",
"0.6457132",
"0.64547294",
"0.64399457",
"0.64179224",
"0.64134413",
"0.6401671",
"0.6401671",
"0.6386918",
"0.63582605",
"0.63582605",
"0.6358202",
"0.63515997",
"0.63... | 0.7750258 | 0 |
Remove any entries in the assets table that are not used at all. By not used we mean to look at all foreign key relations and find assets that have None. | def _remove_unused_assets(write_cursor: 'DBCursor') -> None:
log.debug('Deleting unused asset ids')
write_cursor.execute("""
WITH unique_assets AS (SELECT DISTINCT asset FROM(
SELECT currency AS asset FROM timed_balances UNION
SELECT asset1 AS asset FROM aave_events UNION
SELECT asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reset_unlinked_constituencies():\n UnlinkedConstituency.objects.all().delete()",
"def delete_unused_tags( self, owner ):\n self.filter(\n owner = owner,\n documents__isnull = True).delete()",
"def cleanup(self):\n for table in filter(lambda x: self.cmd.exists(x, sile... | [
"0.5879156",
"0.5840521",
"0.57857317",
"0.5750976",
"0.56536585",
"0.56527066",
"0.56154335",
"0.557533",
"0.5513993",
"0.5511471",
"0.5506803",
"0.55001974",
"0.5465322",
"0.5454954",
"0.5443343",
"0.5395343",
"0.53822976",
"0.53752315",
"0.5337691",
"0.53269213",
"0.531330... | 0.70332074 | 0 |
Check whether the last two received numbers are nonconsecutive. | def check_non_consecutive(agent):
return agent.received[-1] - agent.received[-2] != 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_consecutive(s):\n for (x, y) in pairwise(sorted(s)):\n if y - x != 1:\n return False\n return True",
"def is_consecutive(a_list):\n current_value = a_list[0]-1\n for number in a_list:\n current_value +=1\n if current_value != number:\n return False\n... | [
"0.67791176",
"0.66806567",
"0.6586815",
"0.64163715",
"0.62057024",
"0.6157683",
"0.6146303",
"0.5973882",
"0.59391135",
"0.5878017",
"0.5726122",
"0.56979746",
"0.5680733",
"0.5675066",
"0.56688035",
"0.566431",
"0.5597228",
"0.558718",
"0.55736417",
"0.5534394",
"0.5510732... | 0.8001332 | 0 |
Return the value of this CorrelationId object. The return value | def value(self):
valueType = self.type()
if valueType == CorrelationId.INT_TYPE \
or valueType == CorrelationId.AUTOGEN_TYPE:
return self.__asInteger()
elif valueType == CorrelationId.OBJECT_TYPE:
return self.__asObject()
else:
return N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correlation_id(self):\n return self._correlation_id",
"def get_company_id_value(self):\n return self.company_id_value",
"def type(self):\n return _internals.CorrelationId_type(self)",
"def cen_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cen_id\")",
"def id(se... | [
"0.78683627",
"0.7146154",
"0.7000599",
"0.68124014",
"0.6782479",
"0.6676294",
"0.664208",
"0.664208",
"0.6460984",
"0.6459618",
"0.6458681",
"0.6434835",
"0.6426785",
"0.6373151",
"0.6354108",
"0.6348844",
"0.6345221",
"0.63205653",
"0.6289468",
"0.62798357",
"0.62758815",
... | 0.79887307 | 0 |
Check if user is authenticated. If not, display login form. | def authenticate(self, msg=""):
if self.request.user:
return True
else:
templating = self.server.templating # save current templating settings
templating_path = self.server.templating_path
self.server.set_templating("pystache")
self.server.set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ShowLogin():\n current_user = helpers.get_current_user()\n if current_user is None:\n return render_template('login.html')\n else:\n return redirect('/')",
"def index(self):\n\n # try and pull the user's data\n user = get_active_user_data()\n\n ... | [
"0.78474724",
"0.7216996",
"0.7205118",
"0.7175319",
"0.71743643",
"0.71643996",
"0.71580863",
"0.71243757",
"0.71041775",
"0.7068835",
"0.7056636",
"0.7045808",
"0.70366496",
"0.70366496",
"0.70366496",
"0.70366496",
"0.70366496",
"0.70366496",
"0.70366496",
"0.7023175",
"0.... | 0.6866582 | 34 |
Reads file into list (should be new line delimited text) If no file supplied then reads from stdin | def read_files_into_list(files):
contents = []
try:
contents = [line.strip() for line in fileinput.input(
files=files if files else ('-',))]
except IOError as error:
print('Operation failed: %s' % error)
return contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r(lines=1, prompt=None):\n lista = []\n for i in range(lines):\n l = sys.stdin.readline()\n if l:\n lista.append(l)\n else:\n exit()\n return lista",
"def contentsOfFileSpecifiedIn(argv):\n for argument in argv:\n try:\n with open(argum... | [
"0.65973467",
"0.6563652",
"0.65068",
"0.64773744",
"0.64717317",
"0.645057",
"0.6346151",
"0.63253254",
"0.6301627",
"0.62897915",
"0.6281566",
"0.62520397",
"0.6250286",
"0.6248348",
"0.6237774",
"0.61758024",
"0.6172925",
"0.61711705",
"0.6145559",
"0.61320275",
"0.6106155... | 0.7058677 | 0 |
Return all of the variables list | def get_client_vars(self):
with self.graph.as_default():
client_vars = self.sess.run(tf.trainable_variables())
return client_vars | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_variables(self):\n return []",
"def get_all_variables(self):\n return [self.item]",
"def get_all_variables(self):\n out = []\n for i in self.items:\n out += i.get_all_variables()\n return out",
"def get_all_variables(self):\n out = []\n ... | [
"0.86639255",
"0.8356203",
"0.827432",
"0.827432",
"0.827432",
"0.8121574",
"0.8021741",
"0.79662204",
"0.7918375",
"0.7914313",
"0.78248435",
"0.78092563",
"0.77733177",
"0.77483755",
"0.77109617",
"0.7668621",
"0.765079",
"0.76274604",
"0.7603272",
"0.75680745",
"0.7535275"... | 0.0 | -1 |
Residual unit with 2 sub layers with preactivation, plan A shortcut. | def _residual_v2_build(self,
x,
kernel_size,
in_filter,
out_filter,
stride):
layers = []
with tf.name_scope('residual_v2') as name_scope:
if self._activate_before_residual:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TruncatedResidual(r,alpha_base,reuse=False):\n with tf.variable_scope('TrResidual') as scope: \n if reuse:\n scope.reuse_variables()\n \n alpha = alpha_variable(\"alpha\",[dOutput]) \n alpha_final = tf.multiply(alpha,alpha_base)\n \n if istrainAlpha:\n ... | [
"0.62530804",
"0.6176443",
"0.60826874",
"0.60223293",
"0.5935545",
"0.586518",
"0.58475554",
"0.58371454",
"0.5743737",
"0.57398796",
"0.56810236",
"0.5650603",
"0.5631074",
"0.55462927",
"0.55322427",
"0.5505697",
"0.54484993",
"0.5438758",
"0.5437032",
"0.5410188",
"0.5379... | 0.50384545 | 49 |
A logged in user can post a comment | def test_post(self):
self.assertEqual(self.response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n post_id = int(self.request.get('post_id'))\n post = Posts.get_by_id(post_id)\n comment = self.request.get('comment')\n submitter_id = self.get_active_user().key().id()\n\n if submitter_id:\n comment = Comments(post_id=post_id, content=comment,\n ... | [
"0.72726786",
"0.7083539",
"0.7056021",
"0.6976553",
"0.6960496",
"0.6815414",
"0.6794364",
"0.67624235",
"0.6759909",
"0.67432654",
"0.66097116",
"0.66097116",
"0.66097116",
"0.65501034",
"0.65484995",
"0.65457463",
"0.65126354",
"0.64925885",
"0.64914393",
"0.64914393",
"0.... | 0.0 | -1 |
Call to clean up this socket after it's closed. | def cleanup(self):
if hasattr(self, "reply_channel"):
del self.factory.reply_protocols[self.reply_channel] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self):\n try:\n self.socket.close()\n except:\n pass # ignore errors when attempting to close socket\n self.socket = None\n self.current_host_and_port = None",
"def cleanup(self):\n self.sock.close()",
"def cleanup(self):\n self._sock... | [
"0.86428857",
"0.858198",
"0.83295333",
"0.8249067",
"0.8102506",
"0.8058096",
"0.80420256",
"0.80420256",
"0.8002572",
"0.8002572",
"0.8002572",
"0.8002572",
"0.8002572",
"0.8002572",
"0.79910225",
"0.7935088",
"0.79158396",
"0.7868217",
"0.78605616",
"0.7852479",
"0.7843671... | 0.0 | -1 |
Tokenizer function that removes stopwords, lowers case, tags part of speech, and lemmatizes. Takes a text string. Returns fully tokenized and normalized words. | def tokenize(text):
tokens = word_tokenize(text)
words = [token for token in tokens if re.match("[a-zA-Z0-9]", token)]
no_stopwords = [word for word in words if word not in stopwords.words("english")]
lowercase_words = [word.lower() for word in no_stopwords]
pos_tagged_words = pos_tag(lowercase_word... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n \n tokens = word_tokenize(text)\n \n STOPWORDS = list(set(stopwords.words('english')))\n # remove short words\n tokens = [token for token in tokens if len(token) > 2]\n # remove stopwords\n tokens = [token for token in tokens if token not in STOPWORDS]\n \n lemma... | [
"0.8144719",
"0.80365914",
"0.80356145",
"0.80100876",
"0.7982211",
"0.797575",
"0.79722714",
"0.79560703",
"0.7953729",
"0.79098463",
"0.7899802",
"0.78523004",
"0.7843829",
"0.7843829",
"0.7812445",
"0.7779404",
"0.77729505",
"0.7721257",
"0.77035236",
"0.7671604",
"0.75994... | 0.7798043 | 15 |
Aggregate a list of payloads | def aggregate(
user_model: Any,
request: Union[prediction_pb2.SeldonMessageList, List, Dict],
seldon_metrics: SeldonMetrics,
) -> Union[prediction_pb2.SeldonMessage, List, Dict]:
def merge_meta(meta_list):
tags = {}
requestPath = {}
for meta in meta_list:
if meta:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate(self, xs: List[Tensor]):\n if self.aggr == \"concat\":\n return torch.cat(xs, dim=-1)\n\n x = torch.stack(xs, dim=-1)\n if self.aggr == \"add\":\n return x.sum(dim=-1)\n elif self.aggr == \"mean\":\n return x.mean(dim=-1)\n elif self... | [
"0.62345374",
"0.6157526",
"0.5969577",
"0.59140444",
"0.58655035",
"0.5787762",
"0.5783028",
"0.57733506",
"0.57340163",
"0.5613827",
"0.5600419",
"0.55803525",
"0.5571247",
"0.5553955",
"0.553424",
"0.55071336",
"0.5486156",
"0.5481604",
"0.547303",
"0.54587793",
"0.5439284... | 0.5167526 | 40 |
Returns True if the file containing the memoized function has not been updated since the cache was last saved. | def is_safe_cache(self):
if self.get_last_update() > self.timestamp:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_update(self, cache_key):\r\n return self._read_sha(cache_key) != cache_key.hash",
"def is_cached(self):\n return False",
"def _check_cache(self):\n return os.path.exists(self._cache_key)",
"def is_cache_valid(self):\n if os.path.isfile(self.cache_filename):\n mod_... | [
"0.7081418",
"0.70619285",
"0.6996564",
"0.69775736",
"0.6964032",
"0.693055",
"0.6901986",
"0.68997246",
"0.68702114",
"0.682337",
"0.6818252",
"0.676197",
"0.66992855",
"0.6692315",
"0.6649667",
"0.66095525",
"0.6605537",
"0.65723443",
"0.6541651",
"0.6532446",
"0.6496958",... | 0.6844574 | 9 |
Initialize name and cuisine attributes. | def __init__(self, name, cuisine):
self.name = name
self.cuisine = cuisine | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, restaurant_name, cuisine_type):\r\n\t\tself.restaurant_name = restaurant_name\r\n\t\tself.cuisine_type = cuisine_type",
"def __init__(self, restaurant_name, cuisine_type):\n\t\tself.name = restaurant_name\n\t\tself.type = cuisine_type",
"def __init__(self, restaurant_name, cuisine_type):\n\t... | [
"0.66150117",
"0.65564877",
"0.6555645",
"0.6543713",
"0.6510778",
"0.64852613",
"0.64852613",
"0.64852613",
"0.6406553",
"0.63760173",
"0.6343019",
"0.63210416",
"0.63017946",
"0.63017946",
"0.6272533",
"0.6252154",
"0.6252154",
"0.62420285",
"0.6219914",
"0.6219914",
"0.620... | 0.7851757 | 1 |
Compute the least common multiple of a and b | def lcm(a, b):
if a == b == 0:
return 0
return (a * b) // gcd(a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)",
"def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)",
"def lcm(a, b):\n\treturn a * b // gcm(a, b)",
"def lcm(a, b):\r\n return a * b // gcd(a, b)",
... | [
"0.80964017",
"0.74694085",
"0.7422334",
"0.73100525",
"0.72879106",
"0.7285635",
"0.7285635",
"0.7279704",
"0.7249829",
"0.72487193",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72239035",
"0.72151035",
"... | 0.72382534 | 10 |
TIME_ZONE = 'Asia/Shanghai' TIME_ZONE = 'UTC' Return the default time zone as a tzinfo instance. This is the time zone defined by settings.TIME_ZONE. | def get_timezone(time_zone=''):
return pytz.timezone(time_zone) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timezone():\n\n return time.timezone",
"def _get_tz():\n return 'UTC'",
"def get_timezone():\n localTimezone = request.args.get('timezone')\n if localTimezone in pytz.all_timezones:\n return localTimezone\n else:\n raise pytz.exceptions.UnknownTimeZoneError\n userId = reques... | [
"0.74292964",
"0.7415964",
"0.73699343",
"0.72567254",
"0.69658935",
"0.69086796",
"0.6902996",
"0.6864516",
"0.68626535",
"0.6834895",
"0.67096496",
"0.66948265",
"0.6691175",
"0.6656783",
"0.66406924",
"0.66121846",
"0.65706974",
"0.6557447",
"0.6552792",
"0.6551581",
"0.65... | 0.71925354 | 4 |
Helper function that reads in an image as a | def read_image(path):
image = cv2.imread(path)
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_image(path):\n img = misc.imread(path)\n return img",
"def read_image(img_path):\n img = imageio.imread(uri=img_path)\n return img",
"def read_image(path: str):\n return Image.open(path, mode=\"r\")",
"def imread(path):\n with open(path, 'rb') as f:\n with PIL.Image.open(f) ... | [
"0.7616772",
"0.75648016",
"0.7546724",
"0.75342935",
"0.7479038",
"0.74596316",
"0.74519426",
"0.7415104",
"0.74105406",
"0.7398279",
"0.7366668",
"0.7277692",
"0.7252496",
"0.72470164",
"0.72344834",
"0.7201172",
"0.7190662",
"0.71878093",
"0.71499544",
"0.71432304",
"0.714... | 0.70335525 | 31 |
Returns a list of Enums to be generated | def _create_enums(properties):
enums = {}
for property_ in properties:
# Only generate enums for keyword properties that do not require includes.
if property_['field_template'] in ('keyword', 'multi_keyword') and len(property_['include_paths']) == 0:
enum = Enum(property_['type_name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enums(self):\n return self._enums",
"def list_available_enum(enum_type: Type[Enum]) -> List[str]:\n return [f\"{i}: {v}\" for (i, v) in enumerate(enum_type)] # type: ignore[var-annotated]",
"def enum_names(self):\n return [enum.name for enum in self]",
"def _build_all_enums(self):\n ... | [
"0.7330478",
"0.72526973",
"0.7199668",
"0.71159345",
"0.6931589",
"0.69005865",
"0.6823371",
"0.6605916",
"0.6593142",
"0.6567007",
"0.65318644",
"0.64688665",
"0.64278346",
"0.64026964",
"0.6381322",
"0.63707",
"0.6286862",
"0.62492687",
"0.62078077",
"0.61956257",
"0.61344... | 0.57811064 | 44 |
Create the field used for an inheritance fast path from an independent CSS property, and return the Field object. | def _create_inherited_flag_field(property_):
name_for_methods = join_names(property_['name_for_methods'], 'is', 'inherited')
return Field(
'inherited_flag',
name_for_methods,
property_name=property_['name'],
type_name='bool',
wrapper_pointer_name=None,
field_templ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_property_field(property_, alias_dictionary):\n name_for_methods = property_['name_for_methods']\n\n assert property_['default_value'] is not None, \\\n ('MakeComputedStyleBase requires an default value for all fields, none specified '\n 'for property ' + property_['name'])\n\n i... | [
"0.61445683",
"0.6040924",
"0.5959548",
"0.58931154",
"0.56643975",
"0.5626869",
"0.5624341",
"0.5596164",
"0.557545",
"0.5547095",
"0.5470982",
"0.5463084",
"0.5443062",
"0.532899",
"0.5317446",
"0.5310176",
"0.53058094",
"0.530033",
"0.5281374",
"0.5281374",
"0.5279827",
... | 0.57364804 | 4 |
Extract word features for a string x. Words are delimited by whitespace characters only. | def extractWordFeatures(x):
# BEGIN_YOUR_CODE (around 5 lines of code expected)
temp = x.split(',')
return temp[1]
# END_YOUR_CODE
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractWordFeatures(x):\n # BEGIN_YOUR_CODE (around 5 lines of code expected)\n a = Counter(x.split())\n return dict(a)\n # END_YOUR_CODE",
"def get_text_features(text, word_features):\n words = word_tokenize(text)\n features = {}\n for w in word_features:\n features[w] = (w in wo... | [
"0.70785135",
"0.65954065",
"0.6439349",
"0.6315796",
"0.6276663",
"0.61085737",
"0.60919505",
"0.6076143",
"0.60335547",
"0.6032559",
"0.60224724",
"0.6022351",
"0.6007156",
"0.6004211",
"0.5999093",
"0.5999053",
"0.59722906",
"0.5948896",
"0.5948854",
"0.59055066",
"0.58796... | 0.7816759 | 0 |
Generate a dataframe with a fixed ratio of positives to negatives by requiring all new edges in label_graph to appear in the dataframe. | def make_pairs_with_edges(self, label_graph, target_positive_ratio=.5, enforce_non_edge=True, enforce_has_embeddings=False):
pairs = []
pairs_dict = defaultdict(bool)
edges = 0
if target_positive_ratio == 0:
# We want all the pairs from label_graph
# todo: do we... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_labels(self, labels=None):\n encoded_labels = pandas.DataFrame([], columns=['low', 'medium', 'high'])\n encoded_labels.loc[:, 'low'] = 1.0 * (labels['damage_grade'].values == 1)\n encoded_labels.loc[:, 'medium'] = 1.0 * (labels['damage_grade'].values == 2)\n encoded_labels... | [
"0.5935969",
"0.5926544",
"0.5922692",
"0.5867431",
"0.58212125",
"0.5566528",
"0.55638695",
"0.55370736",
"0.54879844",
"0.5443996",
"0.5403039",
"0.5362388",
"0.5328311",
"0.53151023",
"0.5299417",
"0.5291811",
"0.5288095",
"0.52510726",
"0.52311814",
"0.52310884",
"0.52198... | 0.4872858 | 63 |
Initialize by grabbing annotated attributes from `dictionary`. | def __init__(self, dictionary: dict[str, t.Any]) -> None:
missing_keys = self.__annotations__.keys() - dictionary.keys()
if missing_keys:
raise KeyError(f"Fetched object lacks expected keys: {missing_keys}")
for annotation in self.__annotations__:
setattr(self, annotation... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attributes_from_dictionary(self, dict):\n for key in dict:\n self.__dict[key] = dict[key]\n self.__nonzero = True",
"def set_attr_from_dict(self, dictionary):\n for key in dictionary:\n self.__setattr__(key, dictionary.get(key))",
"def __init__(self, **attribu... | [
"0.7230297",
"0.6992777",
"0.69840556",
"0.6982737",
"0.6823576",
"0.67974263",
"0.6732983",
"0.6731098",
"0.6689794",
"0.6618808",
"0.6609053",
"0.6603291",
"0.65694875",
"0.6496791",
"0.6468408",
"0.6468408",
"0.64332145",
"0.6413084",
"0.63765424",
"0.6340011",
"0.632222",... | 0.78623635 | 0 |
Return string representing encripted message. | def encrypt(self, message):
return self._transform(message, self._encoder) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(self, message):\n return str.translate(message, self._encoder)",
"def encode(self, message):\n return message.encode()",
"def serialize_message(self) -> bytes:\n return self.compile_message().serialize()",
"def encrypt_message(self, message):\n\t\tf = Fernet(self.key)\n\t\tre... | [
"0.7271884",
"0.7218929",
"0.6881216",
"0.68299156",
"0.6805144",
"0.67404187",
"0.67016965",
"0.666928",
"0.6644596",
"0.6619317",
"0.6617966",
"0.65562344",
"0.64658695",
"0.6451686",
"0.64401907",
"0.6422529",
"0.64206177",
"0.63834715",
"0.6368615",
"0.6338247",
"0.633662... | 0.61440647 | 33 |
Gets the BillingAccountId from config | def get_billing_info():
# Get the credential
if os.path.exists(os.getenv("GOOGLE_APPLICATION_CREDENTIALS")):
location = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
with open(location) as f:
location = json.load(f)
billing_account_id = location['Config'][0]['Authentication']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_id(self):\n return self.config.account_id",
"def _get_billing_account_id():\n org_client = boto3.client(\"organizations\")\n response = org_client.describe_organization()\n return response[\"Organization\"][\"MasterAccountId\"]",
"def billing_account(self) -> Optional[pulumi.Input[s... | [
"0.71688056",
"0.71417135",
"0.64892083",
"0.64892083",
"0.6446725",
"0.6446725",
"0.6446725",
"0.6439616",
"0.6439616",
"0.6409565",
"0.6387285",
"0.6362755",
"0.6362755",
"0.6362755",
"0.6362755",
"0.6362755",
"0.6362755",
"0.6362755",
"0.6362755",
"0.63025385",
"0.63025385... | 0.6538082 | 2 |
Sends a 401 response that enables basic auth | def authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8093693",
"0.8092711",
"0.79585856",
"0.7851594",
"0.7842797",
"0.78244835",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
"0.78108114",
... | 0.77476996 | 32 |
Ensure that two different PQGram Profile are actually the same. Used in later tests to compare dynamically created Profiles against preset Profiles. | def checkProfileEquality(self, profile1, profile2):
if len(profile1) != len(profile2) or len(profile1[0]) != len(profile2[0]):
return False
for gram1 in profile1:
contains = False
for gram2 in profile2:
if gram1 == gram2:
con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkProfileEquality(self, profile1, profile2):\n if len(profile1) != len(profile2) or len(profile1[0]) != len(profile2[0]):\n return False\n for gram1 in profile1:\n contains = False\n for gram2 in profile2:\n if gram1 == gram2:\n ... | [
"0.7173993",
"0.6805735",
"0.67792714",
"0.6097838",
"0.58692485",
"0.5791827",
"0.5638295",
"0.5503221",
"0.54368395",
"0.54029185",
"0.536762",
"0.53675735",
"0.535671",
"0.53444594",
"0.5341146",
"0.53021646",
"0.5295202",
"0.5286622",
"0.5228899",
"0.5227843",
"0.52238405... | 0.7128818 | 1 |
Initializes an Oracle to be used for the given sentence. Minimally, it initializes a member variable `actions`, a list that will be updated every time `__call__` is called and a new action is generated. | def __init__(self, deps: Sequence[Dep]):
#Initialize the requried variables
self.actions=[]
self.features_list=[]
#Maintain assigned dependencies
self.connected_childs = set()
#Maintain all dependents
self.dependencies=defaultdict(set)
#Assign all dependen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n execute(query=_query['cr_tweet'])\n execute(query=_query['cr_sentiment'])",
"def __init__(self, searchPhrase='', intent_actions=None):\n self.id = ''\n self.searchPhrase = searchPhrase\n self.intent_actions = intent_actions\n self.es = es()",
"def __init__(self, ... | [
"0.58447737",
"0.5824861",
"0.5448768",
"0.54443306",
"0.53099823",
"0.5280382",
"0.526281",
"0.524834",
"0.5238433",
"0.5182305",
"0.5171382",
"0.5166722",
"0.51649356",
"0.5087058",
"0.50843054",
"0.5075466",
"0.50646484",
"0.5017349",
"0.49746752",
"0.49718636",
"0.4955755... | 0.0 | -1 |
Draw an ellipse with a given position and covariance | def draw_ellipse(position, covariance, ax=None, **kwargs):
ax = ax or plt.gca()
# Convert covariance to principal axes
if covariance.shape == (2, 2):
U, s, Vt = np.linalg.svd(covariance)
angle = np.degrees(np.arctan2(U[1, 0], U[0, 0]))
width, height = 2 * np.sqrt(s)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_ellipse(position, covariance, ax=None, **kwargs):\r\n # Convert covariance to principal axes\r\n if covariance.shape == (2, 2):\r\n U, s, Vt = np.linalg.svd(covariance)\r\n angle = np.degrees(np.arctan2(U[1, 0], U[0, 0]))\r\n width, height = 2 * np.sqrt(s)\r\n else:\r\n ... | [
"0.840408",
"0.83872885",
"0.83385664",
"0.8117954",
"0.7819908",
"0.7780715",
"0.7749703",
"0.7740195",
"0.77339417",
"0.7724917",
"0.771405",
"0.7710944",
"0.7593914",
"0.7255161",
"0.7168584",
"0.71576935",
"0.7078389",
"0.6957663",
"0.69198805",
"0.69095415",
"0.69095415"... | 0.8376353 | 2 |
Compute my distance from the origin | def distance_from_origin(self):
return ((self.x ** 2) + (self.y ** 2)) ** 0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) **0.5",
"def distance_to_origin(self):\n return np.sqrt(self.x ** 2 + self.y ** 2)",
"def distance_from_origin(self) -> float:\n return self._distance_from_origin",
"def distanceFromOrigin(self):\n return ((sel... | [
"0.8565058",
"0.84973544",
"0.8323514",
"0.8296796",
"0.8215572",
"0.7732662",
"0.74226093",
"0.7381035",
"0.7292783",
"0.7264896",
"0.72594285",
"0.7255858",
"0.72473836",
"0.7230952",
"0.7207537",
"0.7149636",
"0.7141725",
"0.71386373",
"0.7136102",
"0.7132502",
"0.71323717... | 0.85663384 | 5 |
Tokenize each row using spaCy and lemmatize all tokens | def spacy_tokenizer(string: str) -> str:
doc = nlp(string)
new_string = " ".join([token.lemma_ for token in doc if not token.is_stop])
return new_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize_records(records):\r\n contents = map(lambda record: record[constants.TEXT], records)\r\n tokenized_records = [word_tokenize(record.lower()) for record in contents]\r\n lemmatized_records = lemmatize_words(tokenized_records)\r\n lemmatized_words = list()\r\n for lemmatized_record in lemm... | [
"0.701306",
"0.6986097",
"0.6865209",
"0.68044204",
"0.67631567",
"0.674077",
"0.6737134",
"0.6729966",
"0.67211527",
"0.67189413",
"0.67109805",
"0.6655042",
"0.6649198",
"0.6634464",
"0.6613286",
"0.6567289",
"0.65643615",
"0.6542479",
"0.6536254",
"0.6516325",
"0.6516325",... | 0.0 | -1 |
read data into pandas dataframe | def read_data(dir_path):
files_list = list(dir_path.iterdir())
for filename in files_list:
review = pd.read_csv(str(filename),sep='\t',encoding="utf-8")
df = pd.DataFrame(review)
df.columns = ["label", "text"]
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataframe():\r\n\r\n df = pd.read_csv('data/data.csv', header=0)\r\n return df",
"def read_data(self) -> pd.DataFrame:\n data = pd.read_csv(self.data_path)\n assert isinstance(data, pd.DataFrame)\n return data",
"def read_data(self) -> pd.DataFrame:\n data = pd.read... | [
"0.7317912",
"0.7204458",
"0.7204458",
"0.7179978",
"0.7019588",
"0.7015765",
"0.69683903",
"0.69651395",
"0.6956185",
"0.6956185",
"0.6956185",
"0.69033307",
"0.68813056",
"0.6867566",
"0.68612397",
"0.68612397",
"0.68385285",
"0.6784176",
"0.6747188",
"0.67383355",
"0.67313... | 0.6361832 | 65 |
Get mailbox config from SSM paramater store | def _setup(self):
self.log_object.write_log(
"MESH0001", None, {"mailbox": self.mailbox, "environment": self.environment}
)
common_params = MeshCommon.get_ssm_params(f"/{self.environment}/mesh")
mailbox_params = MeshCommon.get_ssm_params(
f"/{self.environment}/me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parameter_store_config(config):\n parameter_store = config\n ps_keys = list(parameter_store.keys())\n ssm = boto3.client('ssm')\n LOGGER.info(f\"Loading configurations from Parameter Store for {config}\")\n for ps_key in ps_keys:\n ps_name = parameter_store[ps_key]\n result = s... | [
"0.6167825",
"0.59346735",
"0.59311837",
"0.59073704",
"0.58579004",
"0.58362454",
"0.5784848",
"0.57751316",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396",
"0.5709396... | 0.0 | -1 |
Generate MESH Authorization header for mailboxid. | def _build_mesh_authorization_header(
self,
nonce: str = None,
noncecount: int = 0,
):
if not nonce:
nonce = str(uuid.uuid4())
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M")
# e.g. NHSMESH AMP01HC001:bd0e2bd5-218e-41d0-83a9-73fdec414803:0:2020... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildHeader(self):\n if self.key:\n userString = self.user+b\":\"+self.key\n else:\n userString = self.user+b\":\"\n \n encodedUserString = b64encode(userString)\n decodedUserString = encodedUserString.decode(\"ascii\")\n self.basicAuthHeader ... | [
"0.67031866",
"0.66252786",
"0.6533902",
"0.6345725",
"0.6195944",
"0.6177111",
"0.61637753",
"0.61637753",
"0.60105246",
"0.5996904",
"0.5980559",
"0.59759873",
"0.5972992",
"0.5958031",
"0.59421545",
"0.59193486",
"0.58982885",
"0.5879134",
"0.58532155",
"0.5847732",
"0.579... | 0.7292366 | 0 |
Returns lists of length batch_size. This can be used on any iterator, for example to batch up SeqRecord objects from Bio.SeqIO.parse(...), or to batch Alignment objects from Bio.AlignIO.parse(...), or simply lines from a file handle. This is a generator function, and it returns lists of the entries from the supplied it... | def batch_iterator(iterator, batch_size):
entry = True # Make sure we loop once
while entry:
batch = []
while len(batch) < batch_size:
try:
entry = next(iterator) ##had to change this for python3
except StopIteration:
entry = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_iterator(iterator, batch_size):\n entry = True # Make sure we loop once\n while entry:\n batch = []\n while len(batch) < batch_size:\n try:\n entry = iterator.__next__()\n except StopIteration:\n entry = None\n if entry i... | [
"0.7465705",
"0.74528027",
"0.67078733",
"0.66925323",
"0.66754067",
"0.65960926",
"0.6524206",
"0.6478166",
"0.6445739",
"0.6421101",
"0.6420285",
"0.6330645",
"0.62611824",
"0.61926645",
"0.6163195",
"0.6143574",
"0.6098119",
"0.6073899",
"0.6062207",
"0.6034692",
"0.603204... | 0.7410526 | 2 |
Return [timestamp] as [format_time] GMT string. If [timestamp] is None then use current time. | def gmtime_string(timestamp: int = None, format_time: str = HTTP_DATE_FORMAT):
return time.strftime(format_time, time.gmtime(timestamp)) # == datetime.datetime.utcfromtimestamp(timestamp).strftime(HTTP_DATE_FORMAT) & datetime.datetime.utcnow().strftime(HTTP_DATE_FORMAT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_time(timestamp=None, format=r\"%Y%m%d-%H%M%S\"):\n time_str = time.strftime(format, time.localtime(timestamp if timestamp else time.time()))\n return time_str",
"def _format_ts(cls, timestamp):\n return localtime(timestamp).strftime('%Y-%m-%d %H:%M:%S')",
"def formatTimestamp(self, time... | [
"0.77732444",
"0.73521465",
"0.7316761",
"0.7313386",
"0.7092045",
"0.70525587",
"0.7049738",
"0.7035316",
"0.6904726",
"0.68232393",
"0.68192536",
"0.67859054",
"0.67232364",
"0.6686349",
"0.6661031",
"0.6648096",
"0.6648096",
"0.6620401",
"0.66183484",
"0.66183484",
"0.6618... | 0.7519722 | 1 |
Returns the embedding of a grid graph. | def _grid(m, dtype=np.float32):
M = m**2
x = np.linspace(0, 1, m, dtype=dtype)
y = np.linspace(0, 1, m, dtype=dtype)
xx, yy = np.meshgrid(x, y)
z = np.empty((M, 2), dtype)
z[:, 0] = xx.reshape(M)
z[:, 1] = yy.reshape(M)
return z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_embedding(self, model):\n embedding = []\n for node in range(len(self.graph.nodes())):\n embedding.append(list(model[str(node)]))\n embedding = np.array(embedding)\n return embedding",
"def _get_embedding(self, data):\n # Tensor(n, c)\n cat = data['cat... | [
"0.62898034",
"0.62191874",
"0.60477537",
"0.5886965",
"0.58596414",
"0.577232",
"0.5757991",
"0.57542133",
"0.5753683",
"0.57471174",
"0.57323354",
"0.56826603",
"0.5663495",
"0.5634725",
"0.56186706",
"0.54839605",
"0.5480838",
"0.5466624",
"0.5463585",
"0.54391503",
"0.543... | 0.0 | -1 |
If a batch has been loaded, returns a Spark Dataframe containing the data within the loaded batch | def dataframe(self) -> pyspark.DataFrame:
if self.batch_manager.active_batch_data is None:
raise ValueError(
"Batch has not been loaded - please run load_batch() to load a batch."
)
return cast(SparkDFBatchData, self.batch_manager.active_batch_data).dataframe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_training_data(db_conn):\n return pd.read_sql('''select * from churn_model.churn_data;''', db_conn)",
"def load_stream(self, stream):\n batches = super(ArrowStreamPandasSerializer, self).load_stream(stream)\n import pyarrow as pa\n\n for batch in batches:\n yield [self.a... | [
"0.61941147",
"0.6190219",
"0.6132202",
"0.6109516",
"0.60395706",
"0.5971409",
"0.5963812",
"0.5911073",
"0.5855866",
"0.58475465",
"0.5794236",
"0.5790668",
"0.5781664",
"0.57514507",
"0.57109165",
"0.5697456",
"0.5695474",
"0.56728345",
"0.5665782",
"0.56521374",
"0.564270... | 0.72456676 | 0 |
Uses a DataFrame and Domain kwargs (which include a row condition and a condition parser) to obtain and/or query a Batch of data. Returns in the format of a Spark DataFrame along with Domain arguments required for computing. If the Domain \ is a single column, this is added to 'accessor Domain kwargs' and used for late... | def get_compute_domain(
self,
domain_kwargs: dict,
domain_type: Union[str, MetricDomainTypes],
accessor_keys: Optional[Iterable[str]] = None,
) -> Tuple["pyspark.DataFrame", dict, dict]: # noqa F821
"""
# TODO: <Alex>Docusaurus run fails, unless "pyspark.DataFrame" t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_domain_records( # noqa: C901, PLR0912, PLR0915\n self,\n domain_kwargs: dict,\n ) -> \"pyspark.DataFrame\": # noqa F821\n \"\"\"\n # TODO: <Alex>Docusaurus run fails, unless \"pyspark.DataFrame\" type hint above is enclosed in quotes.\n This may be caused by it becom... | [
"0.8120844",
"0.6048707",
"0.5950215",
"0.59367865",
"0.5845206",
"0.57713306",
"0.5685307",
"0.5671637",
"0.5649757",
"0.564466",
"0.56275374",
"0.55908084",
"0.5550703",
"0.55055475",
"0.54911",
"0.5481735",
"0.547521",
"0.54710567",
"0.54465115",
"0.54464406",
"0.5393636",... | 0.586721 | 4 |
Construct an Account object for the given owner, given number, and initial balance, in US Dollars (defaults to $0.00). | def __init__(self, owner, initial_balance=0.0):
Account.count += 1
self.owner = owner
self.account_number = '%sXY-%s-%08d' % (Account.division,
Account.branch, Account.count)
self.balance = initial_balance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_rao(amount: int):\n return Balance(amount)",
"def __init__(self, account_number: str, bank_name: str,\n starting_balance: float):\n super().__init__(account_number)\n self.bank_name = bank_name\n self.starting_balance = starting_balance\n self.current_b... | [
"0.65885645",
"0.6419395",
"0.63592315",
"0.63263553",
"0.6301358",
"0.6292732",
"0.6246223",
"0.6176988",
"0.60891277",
"0.60864514",
"0.6052209",
"0.60520595",
"0.5938293",
"0.59314173",
"0.59303683",
"0.5909801",
"0.58845013",
"0.58335406",
"0.582221",
"0.5797057",
"0.5773... | 0.7403893 | 0 |
To format the expiry ``datetime`` object at your convenience. | def format_expiry_datetime(expiry):
datetime_format = durin_settings.EXPIRY_DATETIME_FORMAT
return DateTimeField(format=datetime_format).to_representation(expiry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expiration_date(self) -> str:\n return pulumi.get(self, \"expiration_date\")",
"def format_datetime(self, datetime):\n return datetime.isoformat()",
"def formatted_time() -> datetime.datetime:\r\n return datetime.datetime.now()",
"def get_expiration_date(self):\n return self.expir... | [
"0.6517516",
"0.6467586",
"0.623119",
"0.62275183",
"0.62108237",
"0.61739767",
"0.604218",
"0.6036547",
"0.6026883",
"0.6015831",
"0.6007692",
"0.5996553",
"0.59707093",
"0.5965397",
"0.5957163",
"0.59537226",
"0.5951729",
"0.5924716",
"0.5923562",
"0.59153813",
"0.590324",
... | 0.8084522 | 1 |
To format the expiry ``datetime`` object at your convenience. | def format_expiry_datetime(expiry):
datetime_format = durin_settings.EXPIRY_DATETIME_FORMAT
return DateTimeField(format=datetime_format).to_representation(expiry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expiration_date(self) -> str:\n return pulumi.get(self, \"expiration_date\")",
"def format_datetime(self, datetime):\n return datetime.isoformat()",
"def formatted_time() -> datetime.datetime:\r\n return datetime.datetime.now()",
"def get_expiration_date(self):\n return self.expir... | [
"0.6516496",
"0.6465693",
"0.6231666",
"0.6226281",
"0.62099564",
"0.6174253",
"0.6043273",
"0.60352904",
"0.6026429",
"0.6016754",
"0.60084593",
"0.5995285",
"0.59714377",
"0.5962992",
"0.5957824",
"0.5952545",
"0.59524095",
"0.592313",
"0.5922375",
"0.5915873",
"0.5903521",... | 0.8083992 | 0 |
Converts an array of position indices to onehot representation. | def EncodePositionsToOneHotArray(
positions: numpy.ndarray,
one_hot_array_size: int,
) -> numpy.ndarray:
num_positions = len(positions)
result = numpy.zeros((num_positions, one_hot_array_size))
result[numpy.arange(num_positions), positions] = 1
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indices_to_one_hot(data, nb_classes):\n\ttargets = np.array(data).reshape(-1)\n\treturn np.eye(nb_classes)[targets]",
"def indices_one_hot(labels_indices, num_classes=10):\n\n num_labels = labels_indices.shape[0]\n index_offset = np.arange(num_labels) * num_classes\n labels_one_hot = np.zeros((num_l... | [
"0.79452485",
"0.7939188",
"0.7938422",
"0.7938422",
"0.7938422",
"0.7938422",
"0.79127043",
"0.785616",
"0.7756704",
"0.7512997",
"0.74612385",
"0.7460429",
"0.7460429",
"0.74508077",
"0.7430489",
"0.7349784",
"0.7300275",
"0.7295092",
"0.7292091",
"0.72907954",
"0.72596645"... | 0.7977776 | 0 |
Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has an additional getter parameter. Custom getters can be passed as the `custom_getter` parameter of tf.variable_scope. Then, tf.get_variable ... | def _custom_dtype_getter(self, getter, name, shape=None,
*args, **kwargs):
if self.dtype in CASTABLE_TYPES:
var = getter(name, shape, tf.float32, *args, **kwargs)
return tf.cast(var, dtype=self.dtype, name=name + '_cast')
else:
return get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float32_variable_storage_getter(getter, name, shape=None, dtype=None,\n initializer=None, regularizer=None,\n trainable=True,\n *args, **kwargs):\n storage_dtype = tf.float32 if trainable else dtype\n ... | [
"0.77795357",
"0.67778546",
"0.67778546",
"0.6704484",
"0.61997455",
"0.60959065",
"0.5969402",
"0.5952168",
"0.59272265",
"0.5917217",
"0.5720231",
"0.5573573",
"0.5573573",
"0.5479989",
"0.5459602",
"0.54420453",
"0.5352729",
"0.5308366",
"0.5292199",
"0.52698094",
"0.52146... | 0.67645115 | 3 |
Initialize weights and bias | def initialize(self, weight_type="none"):
# should have better implementation for convnet weights
fan_in = self.num_channels*np.prod(self.filter_size);
fan_out = self.num_filters*np.prod(self.filter_size);
filter_bound=np.sqrt(6./(fan_in + fan_out));
fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self) -> None:\n self.fc.bias.data.fill_(0)\n self.fc.weight.data.uniform_(-0.1, 0.1)",
"def initialize_weights(self, weights_initializer, bias_initializer):\n wshapes = [\n [self.input_size, self.hidden_size[0]],\n [self.hidden_size[0], self.hidden_siz... | [
"0.84367526",
"0.8411315",
"0.83398384",
"0.83388233",
"0.83295226",
"0.82616276",
"0.82555413",
"0.8243034",
"0.8234309",
"0.8220086",
"0.8220086",
"0.8220086",
"0.8199937",
"0.8199937",
"0.8188938",
"0.81879956",
"0.81849605",
"0.8162607",
"0.8162607",
"0.8162607",
"0.81495... | 0.0 | -1 |
Apply argmax on 4D tensor | def apply(self, X):
return T.cast(T.ge(X,
self.relex_level*T.max(X,
axis=(1),
keepdims=True)),
dtype="float32"); | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argmax(tensor):\n raise NotImplementedError",
"def max(tensor, axis=None):\n raise NotImplementedError",
"def softmax4(x):\n ndim = K.ndim(x)\n if ndim == 2:\n return K.softmax(x)\n elif ndim == 3:\n e = K.exp(x - K.max(x, axis=-1, keepdims=True))\n s = K.sum(e, ... | [
"0.80028886",
"0.72310567",
"0.6891589",
"0.68120944",
"0.6809317",
"0.67051727",
"0.6588987",
"0.6587543",
"0.6571777",
"0.64923203",
"0.64859015",
"0.64535475",
"0.6448377",
"0.6428148",
"0.64255667",
"0.6404201",
"0.6389808",
"0.638407",
"0.6340535",
"0.6340378",
"0.631562... | 0.0 | -1 |
Testing the Product class' object | def test_Product(self):
self.assertEquals(self.prod_1.pk, 1)
self.assertEquals(self.prod_1.ean, '3350033118072')
self.assertEquals(self.prod_1.name, 'test 1')
self.assertEquals(self.prod_1.nutriscore, 'u')
self.assertEquals(self.prod_1.category, 'cat 1') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_product(self):\n self.assertEqual(self.test_product.name, self.test_product_name)\n self.assertEqual(self.test_product.price, self.test_product_price)",
"def test_new_product(self):\n prod = Product(name='New Product', price=100, weight=60,\n flammability=0.9)\... | [
"0.83845466",
"0.8000843",
"0.75062335",
"0.74242795",
"0.7416258",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7412037",
"0.7408712",
"0.7372206",
"0.7230011",
"0.7210395",
"0.71079427",... | 0.83841574 | 1 |
Check if there are tiles that are sliding. | def sliding(self):
for i in range(self.tiles_len):
x, y = self.tilepos[i] # current pos
X, Y = self.tilePOS[self.tiles[i]] # target pos
if x != X or y != Y:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def board_tiles_availability(self):\n for row in range(GameData.rows):\n for col in range(GameData.columns):\n if self.board[row][col] == 0:\n return False\n # Game is draw, no more moves left!\n return True",
"def isSolvable(self):\n tiles... | [
"0.65930706",
"0.638862",
"0.62965345",
"0.61245984",
"0.6120127",
"0.607347",
"0.6063839",
"0.60553825",
"0.60170245",
"0.6007903",
"0.5990519",
"0.5931457",
"0.59222656",
"0.58895385",
"0.58627856",
"0.58527035",
"0.58461946",
"0.5832893",
"0.58315253",
"0.58312386",
"0.582... | 0.8055036 | 0 |
Concatenates all the observable sequences. 1 res = Observable.concat(xs, ys, zs) 2 res = Observable.concat([xs, ys, zs]) Returns an observable sequence that contains the elements of each given sequence, in sequential order. | def concat(*args: Union[ObservableBase, Iterable[ObservableBase]]) -> ObservableBase:
from ..operators.observable.concat import concat
return concat(*args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat(*seqs):\n return itertools.chain.from_iterable(seqs)",
"def concat(seqs):\n return itertools.chain.from_iterable(seqs)",
"def __concat(self, *args):\n \n if isinstance(args[0], list):\n items = args[0]\n else:\n items = list(args)\n\n items.ins... | [
"0.7238332",
"0.7167098",
"0.7099569",
"0.7039833",
"0.68583626",
"0.6615508",
"0.63579917",
"0.6185098",
"0.6071459",
"0.6019094",
"0.60180134",
"0.6014045",
"0.6009036",
"0.58560336",
"0.58487153",
"0.5834083",
"0.5810778",
"0.58014554",
"0.57798594",
"0.57755494",
"0.57755... | 0.776197 | 0 |
Convert a marble diagram string to an observable sequence, using an optional scheduler to enumerate the events. | def from_marbles(string: str) -> ObservableBase:
from ..testing.marbles import from_marbles
return from_marbles(string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_diagram(wiring_diagram: str) -> List[Move]:\n return [\n Move(direction=shift[0], dist=int(shift[1:])) for shift in wiring_diagram.split(\",\")\n ]",
"def from_string(representation):\r\n auto = Automaton()\r\n lines = [line.strip() for line in representation.spl... | [
"0.5569698",
"0.531187",
"0.50459725",
"0.48425665",
"0.48415402",
"0.48367253",
"0.4784225",
"0.4708554",
"0.46952093",
"0.46904787",
"0.4686589",
"0.46717924",
"0.4660843",
"0.4582461",
"0.457833",
"0.45755085",
"0.45656914",
"0.45643985",
"0.45558202",
"0.45454064",
"0.453... | 0.5335665 | 1 |
Returns a nonterminating observable sequence. Such a sequence can be used to denote an infinite duration (e.g. when using reactive joins). Returns an observable sequence whose observers will never get called. | def never() -> ObservableBase:
from ..operators.observable.never import never
return never() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dematerialize(self) -> ObservableBase:\n\n source = self\n\n def subscribe(observer, scheduler=None):\n def on_next(value):\n return value.accept(observer)\n\n return source.subscribe_(on_next, observer.on_error, observer.on_completed, scheduler)\n return AnonymousObservable(s... | [
"0.54305434",
"0.5403069",
"0.5254239",
"0.52189046",
"0.5106923",
"0.5026279",
"0.4979283",
"0.4974927",
"0.4895316",
"0.48185128",
"0.47756532",
"0.4716944",
"0.4610369",
"0.45916033",
"0.45808548",
"0.45804575",
"0.45765635",
"0.45746127",
"0.45565483",
"0.4554189",
"0.454... | 0.5548675 | 0 |
Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. | def using(resource_factory, observable_factory) -> ObservableBase:
from ..operators.observable.using import using
return using(resource_factory, observable_factory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resourcemanager(acquire, release):\n @contextmanager\n def manager(*args):\n resource = acquire(*args)\n try:\n yield resource\n finally:\n release(resource)\n return manager",
"def defer(observable_factory: Callable[[Any], ObservableBase]) -> ObservableBas... | [
"0.55955094",
"0.5593514",
"0.51814985",
"0.51694787",
"0.5079011",
"0.5000184",
"0.49541306",
"0.4931269",
"0.48444688",
"0.4838977",
"0.47772145",
"0.4764979",
"0.47647765",
"0.47512844",
"0.4751263",
"0.47417977",
"0.47372416",
"0.4735242",
"0.4718308",
"0.47150412",
"0.46... | 0.656926 | 0 |
Calculates the Euclidean distance between two points. | def euclidean_distance(x1, y1, x2, y2):
distance = math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
return distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))",
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-point_two)",
"def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array... | [
"0.8550962",
"0.84894866",
"0.842017",
"0.83857816",
"0.836532",
"0.83231467",
"0.8293594",
"0.8259977",
"0.8207562",
"0.8182812",
"0.8158064",
"0.8147019",
"0.8116608",
"0.8050444",
"0.8009833",
"0.7977984",
"0.79753816",
"0.7974776",
"0.7961696",
"0.7955595",
"0.79395825",
... | 0.8295445 | 6 |
Converts the given path into a list of PoseStamped. | def path_to_poses(mapdata, path):
p_array = []
rospy.loginfo("Converting path to poses.")
last_ori = quaternion_from_euler(0, 0, 0)
last_ori = Quaternion(last_ori[0], last_ori[1],last_ori[2],last_ori[3])
for i in range(len(path) - 1):
msg = PoseStamped()
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_to_list(path):\n fd = open(path)\n t = list()\n for line in fd:\n t += process_line(line)\n\n return t",
"def path2list(thePath):\r\n theItems = thePath.split( os.pathsep )\r\n theResult = '\\n'.join( theItems )\r\n return theResult",
"def load_timestamps(data_path):\n ... | [
"0.61401564",
"0.5921927",
"0.5751967",
"0.56722283",
"0.5638672",
"0.55092335",
"0.5509118",
"0.5502879",
"0.5502604",
"0.54711443",
"0.54691726",
"0.54654634",
"0.54320896",
"0.54027",
"0.5391929",
"0.5376734",
"0.5361043",
"0.53476495",
"0.53406185",
"0.52886033",
"0.52816... | 0.6523746 | 0 |
Get a string by an user input, if the str is a valid number, return it in num type. | def get_number():
while True:
user_number_str = input('Digite um número para saber o seu fatorial: ').strip()
if user_number_str.isnumeric():
return int(user_number_str)
else:
print('Valor inválido.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num(s: str):\n try: return int(s)\n except ValueError: return float(s)",
"def get_number_input(msg=\"Provide a number: \", num_type=int):\n while True:\n try:\n num = num_type(input(msg))\n except ValueError:\n print(f\"Whoops!! Please enter a correct number of {n... | [
"0.72740763",
"0.7191368",
"0.6927254",
"0.68119746",
"0.6803667",
"0.6755699",
"0.6736005",
"0.6728184",
"0.6666828",
"0.6636448",
"0.6605236",
"0.65901506",
"0.65672904",
"0.6513722",
"0.65135723",
"0.64867276",
"0.643773",
"0.6418368",
"0.6395508",
"0.6381024",
"0.63436806... | 0.72914976 | 0 |
Computes a log likelihood ratio testing whether the bins to the left of a position x and to the right of x are drawn from the same poisson distribution. Note, there is no filtering of outliers. And this includes GC correction. | def llscore6(y, xi, read_threshold=200, MIN_LOOK = 5,
log_func=sys.stdout.write):
## how far to look in each direction
MAX_LOOK = max_look(y)
mean_reads = y.mean( )
look = int(np.round(read_threshold/mean_reads)) if mean_reads > 0 else (MAX_LOOK + 1)
if look > MAX_LOOK:
sys.stderr.write... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_likelihood_poisson(self, df, dfo, n_bins=10):\n cond = df[\"selected_jig\"].values == 1\n range = parameter_ranges['uae'], parameter_ranges['rec']\n\n uae_obs = dfo[\"mueff_av\"].values\n rec_obs = dfo[\"rec_arcsec\"].values\n obs, xedges, yedges = np.histogram2d(uae_obs... | [
"0.6233618",
"0.59912854",
"0.5950113",
"0.58592075",
"0.58513784",
"0.5808643",
"0.5651975",
"0.56376",
"0.55860555",
"0.5582757",
"0.55753636",
"0.55621666",
"0.5521014",
"0.5520791",
"0.55127317",
"0.5488472",
"0.5455218",
"0.5441517",
"0.54263043",
"0.5417107",
"0.5406383... | 0.0 | -1 |
Return the specified commit as a symbolic link to commitsbyhash | def _format_to_link(self, commit):
return os.path.join(self.mount, "commits-by-hash", self._hash_updir(commit), commit) + "/" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expand_short_commit_digest(refenv: lmdb.Environment, commit_hash: str) -> str:\n reftxn = TxnRegister().begin_reader_txn(refenv)\n commitParentStart = commit_parent_db_key_from_raw_key(commit_hash)\n with reftxn.cursor() as cursor:\n shortHashExists = cursor.set_range(commitParentStart)\n ... | [
"0.6456598",
"0.6315783",
"0.62166786",
"0.61285615",
"0.6127595",
"0.60412914",
"0.6023898",
"0.59878755",
"0.59829354",
"0.5933174",
"0.5929886",
"0.5911038",
"0.5872372",
"0.58675146",
"0.58482885",
"0.5842916",
"0.5753739",
"0.5649349",
"0.5647317",
"0.55816686",
"0.55813... | 0.7983223 | 0 |
Creates a matrix of zeroes. | def zeroes(height, width):
g = [[0.0 for _ in range(width)] for __ in range(height)]
return Matrix(g) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeroes(height, width):\n g = [[0.0 for _ in range(width)] for __ in range(height)]\n return Matrix(g)",
"def init_zero_matrix(self,rows,cols):\n\t\ttmpMatrix = []\n\t\tfor i in range(rows):\n\t\t\ttmp = [0 for j in range(cols)]\n\t\t\ttmpMatrix.append(tmp)\n\t\treturn tmpMatrix",
"def zeros_matrix(se... | [
"0.816446",
"0.8115332",
"0.8112645",
"0.8058636",
"0.7998705",
"0.7998705",
"0.7991481",
"0.7961953",
"0.7903478",
"0.7851954",
"0.7753049",
"0.77253217",
"0.76235515",
"0.75657403",
"0.75162",
"0.7456788",
"0.74495494",
"0.73435724",
"0.73126847",
"0.72773176",
"0.7277003",... | 0.8253079 | 0 |
Take the name of a product and return an object containing the specifications of this product | def extract_product(product):
product = "%" + product + "%"
cursor.execute("USE openfoodfacts;")
cursor.execute("""SELECT Food.id, Food.name, categories_id, nutri_score, url, stores \
FROM Food \
INNER JOIN Categories ON Food.categories_id LIKE Categories.name\
WHERE Food.name LIKE %s;"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, product, production_volume):\n self.name = name\n self.product = product\n self.production_volume = production_volume\n self.suppliers = []\n self.costumers = []\n self.production_drop = 0\n self.market_shrinkage = 0\n self.sale_drop ... | [
"0.62322193",
"0.6150904",
"0.61288106",
"0.6059199",
"0.59283185",
"0.59100634",
"0.58770084",
"0.58761024",
"0.5846379",
"0.5839438",
"0.5831475",
"0.5829391",
"0.57825124",
"0.57489556",
"0.5742759",
"0.57335204",
"0.5722515",
"0.5627878",
"0.562765",
"0.5610689",
"0.56016... | 0.5812697 | 12 |
Examples >>> round_run_time("59s") '59.0 s' >>> round_run_time("60s") '1.0 m' >>> round_run_time("3599s") '60.0 m' >>> round_run_time("3600s") '1.0 h' | def round_run_time(run_time_str):
run_time = float(run_time_str[:-1])
if run_time < 60:
return f"{run_time} s"
elif run_time >= 60 and run_time < 3600:
return f"{round(run_time / 60, 1)} m"
else:
return f"{round(run_time / 3600, 1)} h" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_elapsed(sec):\n if sec < 60:\n return str(sec) + \" sec\"\n elif sec < (60 * 60):\n return str(sec / 60) + \" min\"\n else:\n return str(sec / (60 * 60)) + \" hr\"",
"def round_time(time):\n t_min = time.minute % 5\n t_sec = time.second\n t_mic = time.microsecond\n... | [
"0.63636315",
"0.632777",
"0.62821156",
"0.6234266",
"0.6174446",
"0.60945106",
"0.60767066",
"0.60504675",
"0.603428",
"0.6029421",
"0.6019505",
"0.5986841",
"0.59820724",
"0.59751606",
"0.5960361",
"0.5955153",
"0.59423447",
"0.5929967",
"0.5892549",
"0.5845084",
"0.5804397... | 0.8500661 | 0 |
Gets a collection of `InputExample`s for the train set. | def get_train_examples(self, data_dir):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_inputs(self, example):\n return example",
"def get_train_examples(self):\n raise NotImplementedError()",
"def get_train_examples(self, input_file):\r\n raise NotImplementedError()",
"def _create_examples(self, data, set_type):\n examples = []\n for (i, elem) in en... | [
"0.73499966",
"0.7173421",
"0.7126833",
"0.65602446",
"0.64204013",
"0.64052176",
"0.63422555",
"0.6290186",
"0.6282746",
"0.625262",
"0.62499267",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0.62466323",
"0... | 0.6067737 | 69 |
Gets a collection of `InputExample`s for the dev set. | def get_dev_examples(self, data_dir):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dev_examples(self, input_file):\r\n raise NotImplementedError()",
"def get_train_inputs(self, example):\n return example",
"def get_examples(self, env):\n return self.fam.c_get_examples(self, env)",
"def get_dev_examples(self):\n raise NotImplementedError()",
"def _create_ex... | [
"0.68112403",
"0.6588688",
"0.655683",
"0.6552607",
"0.64272827",
"0.63816285",
"0.6255956",
"0.61930686",
"0.61160946",
"0.6094262",
"0.6054992",
"0.6051947",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",
"0.5994604",... | 0.58509433 | 40 |
Converts an ``InputExample`` to token ids and segment ids. twofold inputs 1. [CLS] para [SEP] q [SEP] a 0 0 0 1 1 1 2. [CLS] evidence [SEP] 0 0 0 | def example_to_token_ids_segment_ids_label_ids(
ex_index,
example,
max_seq_length,
max_evid_length,
tokenizer):
if ex_index < 5:
print('*** Example {} ***'.format(ex_index))
print('qid: {}'.format(example.qid))
qid = example.qid
# evidence
ante_evidence = example.evidence # list o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example_to_token_ids_segment_ids_label_ids(\n ex_index,\n example,\n max_seq_length,\n max_evid_length,\n tokenizer):\n if ex_index < 5:\n print('*** Example {} ***'.format(ex_index))\n print('qid: {}'.format(example.qid))\n\n qid = example.qid\n\n # ante evidence\n ante_evidence = exa... | [
"0.70893425",
"0.6897168",
"0.68141216",
"0.6357156",
"0.63081753",
"0.63081753",
"0.6199592",
"0.6127808",
"0.61205286",
"0.60528535",
"0.6020083",
"0.60095656",
"0.5896903",
"0.5857811",
"0.5852545",
"0.58286536",
"0.58014333",
"0.58014333",
"0.57913035",
"0.5787212",
"0.57... | 0.7179579 | 0 |
Create a TransferRequestFinisher component. config A dictionary of required configuration values. logger The object the transfer_request_finisher should use for logging. | def __init__(self, config: Dict[str, str], logger: Logger) -> None:
super(TransferRequestFinisher, self).__init__("transfer_request_finisher", config, logger)
self.work_retries = int(config["WORK_RETRIES"])
self.work_timeout_seconds = float(config["WORK_TIMEOUT_SECONDS"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, config: Dict[str, str], logger: Logger) -> None:\n super(Bundler, self).__init__(\"bundler\", config, logger)\n self.file_catalog_client_id = config[\"FILE_CATALOG_CLIENT_ID\"]\n self.file_catalog_client_secret = config[\"FILE_CATALOG_CLIENT_SECRET\"]\n self.file_cata... | [
"0.5395955",
"0.5386604",
"0.5328198",
"0.52133393",
"0.518532",
"0.51649624",
"0.5073543",
"0.50508004",
"0.5049396",
"0.5035001",
"0.50187546",
"0.5010802",
"0.4950966",
"0.49137738",
"0.49060217",
"0.48976278",
"0.48858225",
"0.48811722",
"0.48586753",
"0.48498413",
"0.482... | 0.7259807 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.