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 |
|---|---|---|---|---|---|---|
Returns the string representation of the SubmitJob object. | def __str__(self):
return str(self.first_name) + ' ' + str(self.email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n outstr = \"Job:{name}<{mode}:{qtype}\".format(\n name=self.name, mode=self.kind, qtype=self.qtype)\n if self.submitted:\n outstr += ':{}'.format(self.id)\n outstr += \"(command:{cmnd})\".format(cmnd=self.command)\n if self.submitted or self.do... | [
"0.732466",
"0.7000577",
"0.67367667",
"0.6686486",
"0.66070056",
"0.6513324",
"0.6513324",
"0.65035015",
"0.6179166",
"0.6101141",
"0.60501635",
"0.59821576",
"0.5960051",
"0.59253055",
"0.5875672",
"0.5825303",
"0.58114165",
"0.57846075",
"0.57683605",
"0.57655585",
"0.5719... | 0.0 | -1 |
Slices a Tensor along the given axis. | def _slice_along_axis(x, start=0, stop=None, step=1, axis=0):
axis_ = tf.get_static_value(axis)
if axis_ is None: # Non-static axis: use `gather`.
axis_len = ps.shape(x)[axis]
start = 0 if start is None else start if start >= 0 else start + axis_len
stop = axis_len if stop is None else stop if stop >= ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getslice(arr: tf.Tensor, slice: tf.Tensor, axis: int) -> tf.Tensor:\n if arr is None:\n return None\n return tf.boolean_mask(arr, slice, axis=axis)",
"def _slice_at_axis(sl, axis):\n return (slice(None),) * axis + (sl,) + (...,)",
"def _slice(tensor, size, i):\n return tensor[:, i * size... | [
"0.66464174",
"0.65555227",
"0.6490316",
"0.6236306",
"0.61960506",
"0.61859226",
"0.61508197",
"0.6118521",
"0.5986936",
"0.58949655",
"0.5869262",
"0.5865358",
"0.58602685",
"0.5847187",
"0.5833424",
"0.57768404",
"0.5725104",
"0.57173896",
"0.57031536",
"0.5576784",
"0.555... | 0.74212134 | 0 |
Retrieve, update or delete a posts. | def post_detail(request, pk):
try:
posts = Post.objects.get(pk=pk)
except Post.DoesNotExist:
return HttpResponse(status=404)
if request.method == 'GET':
serializer = PostSerializer(posts)
return JSONResponse(serializer.data)
elif request.method == 'PUT':
data = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_posts(self): #return list of posts that are associated with this blog_id\n return Post.find_posts_for_blog_id(self.blog_id) #this will return a list of posts objects",
"def get(self, post_id=None):\n\n if post_id:\n post = Post.query.filter_by(id=post_id).first()\n if ... | [
"0.6505801",
"0.64528555",
"0.6423532",
"0.6373631",
"0.63427925",
"0.6274615",
"0.6225649",
"0.6193003",
"0.6176566",
"0.61616415",
"0.61007327",
"0.60968506",
"0.6080469",
"0.6043778",
"0.6037077",
"0.6010792",
"0.60076684",
"0.5992963",
"0.5914296",
"0.59106",
"0.5901715",... | 0.6171181 | 9 |
When the 'tab' key is pressed with only whitespace character before the cursor, do autocompletion. Otherwise, insert indentation. | def autocomplete_or_indent(event):
b = event.app.current_buffer
if editor.expand_tab:
b.insert_text(' ')
else:
b.insert_text('\t') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tab_insert_indent():\n before_cursor = get_app().current_buffer.document.current_line_before_cursor\n\n return bool(before_cursor.isspace())",
"def indent(self):\n cursor = self.parent.textCursor()\n # Check if something is selected\n if cursor.hasSelection():\n # get th... | [
"0.7409058",
"0.6785718",
"0.6439355",
"0.6325192",
"0.6276583",
"0.6078577",
"0.607181",
"0.6044039",
"0.60010666",
"0.59886366",
"0.59711945",
"0.58322",
"0.57286376",
"0.56684005",
"0.5649768",
"0.56064373",
"0.56026214",
"0.559056",
"0.55718994",
"0.555576",
"0.5532935",
... | 0.85131466 | 0 |
Test updating an incident with a missing incidents_ids | def test_incident_missing_incident_id(self):
resp = self.client.post(
reverse('incidents', kwargs={'team_id': '7de98e0c-8bf9-414c-b397-05acb136935e'}),
)
self.assertEqual(resp.status_code, 400)
self.assertEqual(resp.json(), {'error': 'incident_ids is a required argument'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_incident_updating_none_existent_incident(self):\n resp = self.client.post(\n reverse('incidents', kwargs={'team_id': '7de98e0c-8bf9-414c-b397-05acb136935e'}),\n {'incident_ids': '76e3d488-52b8-4b86-906e-8bc5b3b7504e', 'annotation': 'Rebooted server'}\n )\n\n self... | [
"0.81305057",
"0.74679",
"0.72949487",
"0.6610341",
"0.65915537",
"0.64035577",
"0.6397764",
"0.63928056",
"0.63899857",
"0.63855296",
"0.62303734",
"0.6209178",
"0.6127048",
"0.60682535",
"0.604549",
"0.60442185",
"0.6022475",
"0.59770966",
"0.59713066",
"0.59646034",
"0.594... | 0.69273186 | 3 |
Test updating an incident that does not exist | def test_incident_updating_none_existent_incident(self):
resp = self.client.post(
reverse('incidents', kwargs={'team_id': '7de98e0c-8bf9-414c-b397-05acb136935e'}),
{'incident_ids': '76e3d488-52b8-4b86-906e-8bc5b3b7504e', 'annotation': 'Rebooted server'}
)
self.assertEqua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_incident_update_none_existent_team(self):\n resp = self.client.post(\n reverse('incidents', kwargs={'team_id': '8de98e0c-8bf9-414c-b397-05acb136956e'}),\n {'incident_ids': '76e3d488-52b8-4b86-906e-8bc5b3b7504e', 'actionable': True}\n )\n\n self.assertEqual(resp.s... | [
"0.75527954",
"0.7263033",
"0.71938485",
"0.6947797",
"0.68797266",
"0.6852765",
"0.67820483",
"0.6717752",
"0.664864",
"0.6608671",
"0.65943825",
"0.6592367",
"0.6580305",
"0.6576265",
"0.6547913",
"0.6532791",
"0.65235233",
"0.6514574",
"0.64946425",
"0.6493697",
"0.6482193... | 0.8191759 | 0 |
Test updating an incident for a team that does not exist | def test_incident_update_none_existent_team(self):
resp = self.client.post(
reverse('incidents', kwargs={'team_id': '8de98e0c-8bf9-414c-b397-05acb136956e'}),
{'incident_ids': '76e3d488-52b8-4b86-906e-8bc5b3b7504e', 'actionable': True}
)
self.assertEqual(resp.status_code,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_incident_updating_none_existent_incident(self):\n resp = self.client.post(\n reverse('incidents', kwargs={'team_id': '7de98e0c-8bf9-414c-b397-05acb136935e'}),\n {'incident_ids': '76e3d488-52b8-4b86-906e-8bc5b3b7504e', 'annotation': 'Rebooted server'}\n )\n\n self... | [
"0.7703553",
"0.72567016",
"0.6904991",
"0.6682763",
"0.66215116",
"0.6607036",
"0.6511893",
"0.64988476",
"0.64765954",
"0.6448938",
"0.6431168",
"0.6369534",
"0.6328983",
"0.63267136",
"0.6322361",
"0.63013417",
"0.6295472",
"0.62949175",
"0.6219397",
"0.6140698",
"0.610082... | 0.85430807 | 0 |
Check if user is authorized to set stage for post | def _authorize_stage_change(user: User, post: Post, new_stage_id: int) -> bool:
legit_stages = (post.stage.prev_stage_id, post.stage.next_stage_id)
if new_stage_id in legit_stages and post.assignee == user:
return True
if user.has_perm("magplan.edit_extended_post_attrs"):
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onchange_restrict_access(self, stage_id):\n print('----------',self.env.uid)\n # if self.env.uid != 1 :\n raise exceptions.Warning('You are not allowed to change the stages, Please contact the Administrator')\n return True\n return {}",
"def can_view_post(user):\n #onl... | [
"0.70157516",
"0.66664",
"0.6640315",
"0.63519424",
"0.63519424",
"0.63496745",
"0.6348047",
"0.6348047",
"0.6348047",
"0.6328234",
"0.6316238",
"0.6265314",
"0.62418246",
"0.6222624",
"0.6092303",
"0.60652214",
"0.59974426",
"0.59974426",
"0.59974426",
"0.59631175",
"0.59505... | 0.756467 | 0 |
GetSettingsForOperation(operation) > list_of_FSettingEntry Implements FApplication.GetSettingsForOperation() | def GetSettingsForOperation(self, operation):
if (operation == IMPORT):
options = []
for entry in FXsi.__IMPORT_OPTIONS:
options.append(FSettingEntry(*entry))
return options
elif (operation == EXPORT):
options = []
for e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings_f(self):\n\n return self._get_list_field(\"settings\", lambda x: _build_setting(self.settings(), x))",
"def get_setting_keys(self):\n return self.do_rpc(\"get_setting_keys\")",
"def get_settings():\n return SettingCollection.build()",
"def GetAllSettings(appname, section):\n ... | [
"0.64357954",
"0.6301887",
"0.6129466",
"0.5944746",
"0.5810554",
"0.5794425",
"0.57932436",
"0.5714147",
"0.5705955",
"0.5686104",
"0.5686104",
"0.56702167",
"0.56081367",
"0.56060934",
"0.5603054",
"0.5527702",
"0.55034333",
"0.5482175",
"0.5455909",
"0.5444749",
"0.5436023... | 0.83759177 | 0 |
Get the width (xdimension) of the area. | def width(self):
return abs(self.end[0] - self.start[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getWidth(self):\n area = self.getArea()\n length = self.getLength()\n return area / length",
"def getWidth(self):\n return _libsbml.Dimensions_getWidth(self)",
"def width(self):\n return _libsbml.Dimensions_width(self)",
"def width(self) -> int:\n return self._ob... | [
"0.81667393",
"0.7926992",
"0.7908447",
"0.77495134",
"0.7737006",
"0.77228993",
"0.7720189",
"0.7643378",
"0.7558893",
"0.75532365",
"0.7540826",
"0.75351435",
"0.75351435",
"0.75289947",
"0.752155",
"0.752155",
"0.752155",
"0.75207937",
"0.75207937",
"0.75207937",
"0.752079... | 0.0 | -1 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
# TO DO: get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
while True:
try:
city = input('Input city name (chicago, new york city, washington): ').lower()
... | {
"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.6671714",
"0.65376973",
"0.64612824",
"0.6376945",
"0.63504905",
"0.6311004",
"0.6288045",
"0.6260879",
"0.62342596",
"0.6215191",
"0.6207211",
"0.61830604",
"0.6174147",
"0.61701334",
"0.6160666",
"0.6159556",
"0.61552376",
"0.61457616",
"0.61299276",
"0.61062425",
"0.610... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
# load data file into a dataframe
df = pd.read_csv(CITY_DATA[city])
# convert the Start Time column to datetime
df['Start Time'] = pd.to_datetime(df['Start Time'])
# extract month and day of week from Start Time to create new columns
df['month'] = df['Start... | {
"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.81314564",
"0.81085265",
"0.8045849",
"0.8042005",
"0.800918",
"0.80069226",
"0.7999247",
"0.79979444",
"0.79886496",
"0.7978921",
"0.79736865",
"0.79605865",
"0.7956074",
"0.79472643",
"0.7945933",
"0.7908438",
"0.7908127",
"0.7904659",
"0.790041",
"0.7892886",
"0.7889158... | 0.76704395 | 68 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# TO DO: display the most common month
months = ['january', 'february', 'march', 'april', 'may', 'june']
popular_month = df['month'].mode()[0]
popular_month = months[popular_month - 1]
... | {
"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.80229414",
"0.8021659",
"0.79154044",
"0.78253615",
"0.7820659",
"0.7812822",
"0.77646637",
"0.77399075",
"0.7735228",
"0.7733135",
"0.76855505",
"0.7668204",
"0.76504695",
"0.7643491",
"0.7638798",
"0.7635826",
"0.7624526",
"0.76222384",
"0.76126415",
"0.7598943",
"0.7582... | 0.7200223 | 70 |
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()
# TO DO: display most commonly used start station
max_used_st = df['Start Station'].value_counts().idxmax()
print('\nMost commonly used start station: {}'.format(max_used_st))
# TO ... | {
"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.69312876 | 80 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time
total_travel_time = np.sum(pd.to_datetime(df['End Time']) - pd.to_datetime(df['Start Time']))
totalDays = str(total_travel_time).split()[0]
clock = str(total_trav... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.8143977",
"0.80268085",
"0.8005599",
"0.79511017",
"0.7938921",
"0.79326934",
"0.792851",
"0.7916632",
"0.7915868",
"0.79095894",
"0.79071254",
"0.79020894",
"0.789307",
"0.78909105",
"0.78881186",
"0.7886607",
"0.78857124",
"0.78838766",
"0.7875441",
"0.7870104",
"0.78680... | 0.0 | -1 |
Return the textual representation of this object. | def __repr__(self):
return "FletcherDType({})".format(str(self.arrow_dtype)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_string(self):\n return self.__repr__()",
"def __repr__(self):\n return self.text",
"def __repr__(self):\n return self.text",
"def __repr__(self):\n return self.textual_representation().encode(\"utf-8\")",
"def toString(self) -> str:\n raise NotImplementedError",
... | [
"0.82824975",
"0.81832796",
"0.81832796",
"0.8106402",
"0.804333",
"0.80323106",
"0.7971726",
"0.795831",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
"0.7956761",
... | 0.0 | -1 |
Check whether 'other' is equal to self. By default, 'other' is considered equal if it's a string matching 'self.name'. it's an instance of this type. | def __eq__(self, other):
if isinstance(other, six.string_types):
return other == self.name
elif isinstance(other, type(self)):
return self.arrow_dtype == other.arrow_dtype
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n\n return (self.name) == (other.name)",
"def __eq__(self, other):\n return self.name == other.name",
"def __eq__(self, other):\n return self.getName() == other.getName()",
"def __eq__(self, other):\n if type(self) != type(other):\n return False... | [
"0.8427487",
"0.82797825",
"0.8245928",
"0.79671884",
"0.7958928",
"0.7958928",
"0.79459715",
"0.7842671",
"0.7805731",
"0.7805731",
"0.7789016",
"0.77139634",
"0.7612859",
"0.7591556",
"0.7586084",
"0.7574574",
"0.7574574",
"0.756764",
"0.75585437",
"0.7537009",
"0.7536081",... | 0.7491013 | 22 |
Return a string identifying the data type. Will be used for display in, e.g. ``Series.dtype`` | def name(self):
# type: () -> str
return str(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_type_str(self):\n return data_ref_type_str(self.data_type)",
"def typecast(dtype: Any) -> str:\n if dtype is int:\n return \"Int64\"\n elif dtype is float:\n return \"Float64\"\n elif dtype is bool:\n return \"bool\"\n return \"string\"... | [
"0.801212",
"0.79151255",
"0.77638954",
"0.73846257",
"0.7357647",
"0.7327617",
"0.7268015",
"0.72639215",
"0.7257583",
"0.7236656",
"0.7236656",
"0.7236656",
"0.7211246",
"0.7110817",
"0.7102447",
"0.7078003",
"0.6999487",
"0.696393",
"0.6935519",
"0.69146574",
"0.6912892",
... | 0.0 | -1 |
Return the number of elements in this array. Returns | def size(self):
return len(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n return len(self.arr)",
"def _N(self):\n return len(self._array)",
"def count(self):\r\n return self.data_array.size",
"def __len__(self):\n return len(self.array)",
"def __len__(self):\n return len(self.array)",
"def __len__(self):\n return np.s... | [
"0.8487639",
"0.83301806",
"0.82580143",
"0.8198649",
"0.8198649",
"0.81034327",
"0.810022",
"0.80992085",
"0.8074043",
"0.8049342",
"0.8004364",
"0.7999203",
"0.79522777",
"0.78951585",
"0.7878925",
"0.7858691",
"0.7830864",
"0.7817386",
"0.77742654",
"0.77610457",
"0.775488... | 0.7141683 | 85 |
Length of this array. Returns | def __len__(self):
# type: () -> int
return self.shape[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self.array)",
"def __len__(self):\n return len(self.array)",
"def getArrayLength(self):\r\n return self.arraySize",
"def size(self):\n return len(self.arr)",
"def __len__(self):\n return self._arr.shape[1]",
"def length(self) -> int:\n ... | [
"0.8905154",
"0.8905154",
"0.8805126",
"0.8673622",
"0.85563564",
"0.8456202",
"0.8424837",
"0.8424837",
"0.8424837",
"0.8410581",
"0.8409163",
"0.8409163",
"0.8401203",
"0.83924747",
"0.83924747",
"0.83667403",
"0.83565646",
"0.83565646",
"0.83565646",
"0.8353474",
"0.834347... | 0.0 | -1 |
Boolean NumPy array indicating if each value is missing. This should return a 1D array the same length as 'self'. | def isna(self):
# type: () -> np.ndarray
return extract_isnull_bytemap(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isna(self):\n size = len(self.data)\n isnull_byte_map = np.zeros(size, dtype=bool)\n for i in range(size):\n if self.data[i] is None:\n isnull_byte_map[i] = 1\n\n return isnull_byte_map",
"def data_missing():\n return RaggedArray([[], [-1, 0, 1]], dtyp... | [
"0.6848798",
"0.67537147",
"0.65689963",
"0.65461826",
"0.64909106",
"0.64457023",
"0.644562",
"0.6431257",
"0.6421081",
"0.637616",
"0.636206",
"0.6334424",
"0.6312067",
"0.6282745",
"0.6282333",
"0.6247037",
"0.62356174",
"0.62020016",
"0.6196756",
"0.61658096",
"0.6140825"... | 0.74002665 | 1 |
Cast to a NumPy array with 'dtype'. | def astype(self, dtype, copy=True):
if self.dtype == dtype:
return self
if isinstance(dtype, FletcherDtype):
dtype = dtype.arrow_dtype.to_pandas_dtype()
arrow_type = dtype.arrow_dtype
elif isinstance(dtype, pa.DataType):
dtype = dtype.to_pandas_dt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asarray(val, dtype=np.float64):\n # val is a list, tuple etc\n if not np.isscalar(val) and np.ndim(val) > 0:\n np_val = np.asarray(val, dtype=dtype)\n else:\n # val is a scalar number\n np_val = np.asarray([val], dtype=dtype)\n\n return np_val",
"def _to_numpy_ndarray(cls, da... | [
"0.7329888",
"0.70835435",
"0.7066227",
"0.70650464",
"0.6984045",
"0.6961744",
"0.6949394",
"0.6946292",
"0.69244313",
"0.6881979",
"0.68546593",
"0.683145",
"0.68048763",
"0.67890763",
"0.67437947",
"0.6719441",
"0.66922414",
"0.6659825",
"0.6624919",
"0.6620474",
"0.661164... | 0.6200731 | 58 |
Construct a new ExtensionArray from a sequence of scalars. | def _from_sequence(cls, scalars, dtype=None, copy=None):
if isinstance(scalars, FletcherArray):
return scalars
if dtype and isinstance(dtype, FletcherDtype):
dtype = dtype.arrow_dtype
return cls(pa.array(scalars, type=dtype, from_pandas=True)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from_sequence(cls, scalars):\n return cls(xnd.xnd(list(scalars)))",
"def _from_sequence(cls, scalars):\n return cls(pa.array(scalars))",
"def literal_array(cls, elems):\n tys = [el.type for el in elems]\n if len(tys) == 0:\n raise ValueError(\"need at least one eleme... | [
"0.74398285",
"0.73513067",
"0.5925144",
"0.5783047",
"0.5611878",
"0.55738205",
"0.553745",
"0.54946977",
"0.5494618",
"0.54936904",
"0.54608756",
"0.54314053",
"0.53493595",
"0.52803767",
"0.5263886",
"0.5165147",
"0.51559293",
"0.515543",
"0.51491386",
"0.5140238",
"0.5140... | 0.7183158 | 2 |
Add info about test case start time. | def pytest_runtest_setup(self, item):
if not item.config.option.tc_duration:
self.detailed_duration[item.nodeid] = dict()
self.detailed_duration[item.nodeid]['setup'] = time.time()
if self._buildname is not None:
self._send_post_request(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def track_start_time(self, test_class, test_name, start_time):\n if test_class is None or test_name is None:\n return\n\n test_key = \"{}.{}\".format(test_class, test_name)\n self.start_time_by_test[test_key] = start_time",
"def start_time(self):\n pass",
"def start_time(... | [
"0.7758343",
"0.7414121",
"0.7353284",
"0.726137",
"0.71158445",
"0.6933612",
"0.68328947",
"0.68328947",
"0.6829134",
"0.6816494",
"0.6752416",
"0.67141324",
"0.67065495",
"0.6681601",
"0.666478",
"0.6653868",
"0.6649986",
"0.66262716",
"0.66251177",
"0.66251177",
"0.6625117... | 0.6450213 | 36 |
Regex test to make sure URL is in valid format | def is_web_url(text):
return re.match(r'(http://|https://|www.)(www\.)?([a-zA-Z0-9-_.]+)(\.[a-zA-Z0-9]{2,4})(\S+)', text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsValidURL(s):\n return RE_COMPLEX_URL.match(s)",
"def validaURL(url: AnyStr) -> bool:\n\n return re.compile(patternURL).search(url) != None # Linea 1",
"def validateURL(url):\n pattern = re.compile(\"^https*:\\/\\/\\w+(\\.\\w+){2}[\\/A-Za-z\\d\\?\\=]*$\")\n match = pattern.match(url)\n\n retu... | [
"0.8192488",
"0.818914",
"0.7880767",
"0.7789709",
"0.7744466",
"0.7740075",
"0.7546739",
"0.74793637",
"0.7473631",
"0.74197984",
"0.7410157",
"0.74091166",
"0.7378311",
"0.7335737",
"0.73335934",
"0.73326313",
"0.73068017",
"0.7292581",
"0.72582245",
"0.72484934",
"0.724745... | 0.67165256 | 74 |
Return the number of operations (transactions) begun since the last reset. | def getOperationCount():
return _operationCount | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n return len(self.transactions)",
"def count(self):\n nreq, nres = 0, 0\n for entry in self.__history:\n if entry.oreq is not None:\n ... | [
"0.70103854",
"0.70103854",
"0.6931038",
"0.64327085",
"0.63480765",
"0.63309973",
"0.63017976",
"0.6285706",
"0.62184405",
"0.62102354",
"0.62073493",
"0.6190978",
"0.6185479",
"0.6138618",
"0.61078095",
"0.6105683",
"0.6089241",
"0.60472864",
"0.601587",
"0.5982805",
"0.597... | 0.6497977 | 3 |
Builds a closing HTML tag for Simply Logical exercises. | def depart_exercise_node(self, node):
self.body.append('</div>\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_close():\n return(\"\"\"\n\n </section>\n\n </div>\n\n</main>\n</body>\n</html>\"\"\")",
"def _close(self, tag, newline=False):\n if tag in _self_closing_tags or (tag in _auto_closing_tags and not self.no_magic):\n # This tag was already closed\n tagstr = ''\n ... | [
"0.71677715",
"0.60572696",
"0.5934129",
"0.5905471",
"0.5822575",
"0.57317966",
"0.554099",
"0.5469522",
"0.54219437",
"0.54158413",
"0.53987205",
"0.53940177",
"0.5388376",
"0.538431",
"0.53592163",
"0.5327956",
"0.5327668",
"0.53134155",
"0.53085786",
"0.5295258",
"0.52808... | 0.6349158 | 1 |
Get the step task whose index matches the specified index. | def get_task_by_index(self, task_index):
num_of_existing_tasks = len(self.tasks)
if num_of_existing_tasks < task_index + 1:
raise ValueError("A task with an index of '{}' can not be found, highest index is '{}'.".format(task_index,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_step_by_index(self, step_index):\n logger.debug(\"Ticket steps IDs are '%s', getting ticket step with index '%s'\", self.steps, step_index)\n # Check that index is not larger than the amount of steps that exist.\n step_ids = [step.id for step in self.steps]\n logger.debug(\"Sort... | [
"0.7365229",
"0.683713",
"0.661489",
"0.6430592",
"0.63948697",
"0.63535756",
"0.6347322",
"0.62424296",
"0.62418467",
"0.62099606",
"0.60862464",
"0.5987762",
"0.5956976",
"0.5856196",
"0.5837229",
"0.5805889",
"0.57942104",
"0.5717616",
"0.56787604",
"0.5661014",
"0.563606"... | 0.72159934 | 1 |
Save configuration to a JSON file. If filename is not an absolute path, it will be prefixed with ~/.pines/ | def save(config, filename=None):
filename = add_directory(filename or 'configure.json')
directory = os.path.dirname(filename)
if not os.path.exists(directory):
os.makedirs(directory, 0o700)
with open(filename, "w") as f:
json.dump(config, f, indent=2, sort_keys=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_config(self, filename: str=None):\n if not filename:\n filename = self.config_file\n with open(filename, \"w\") as file_object:\n json.dump(self.config, file_object, indent=4, sort_keys=True)",
"def save_config_to_json(config, filename):\n with open(filename, 'w+')... | [
"0.7773879",
"0.7696323",
"0.76123863",
"0.7535027",
"0.7462439",
"0.73880017",
"0.73783",
"0.7343196",
"0.7339879",
"0.7306615",
"0.723454",
"0.72333753",
"0.72182196",
"0.71830004",
"0.7182543",
"0.71661973",
"0.7121449",
"0.7116388",
"0.710098",
"0.7064238",
"0.70376384",
... | 0.78251755 | 0 |
Get all the tags that this building has associated with it | def get_building_tags(building):
tags = Building._get_collection().find({'name': building}, {'tags.name': 1, 'tags.value': 1, '_id': 0})[0]['tags']
res = {}
for tag in tags:
if tag['name'] in res:
res[tag['name']]['values'].append(tag['value'])
else:
tagtype_dict = {}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tags(self):\n return self.tags",
"def get_tags(self):\n\n return self.tags",
"def getTags(self,):\n\t\treturn self.tags;",
"def tags(self):\n return self.__tags[:]",
"def tags(self):\n return self._tags",
"def tags(self):\n return self._tags",
"def tags(self):... | [
"0.77014303",
"0.767499",
"0.7594935",
"0.7487854",
"0.7476978",
"0.7476978",
"0.7476978",
"0.7476978",
"0.7476978",
"0.7476978",
"0.7476978",
"0.7476978",
"0.74462694",
"0.7344525",
"0.7293671",
"0.71916926",
"0.71767354",
"0.7157296",
"0.70833606",
"0.70833606",
"0.705332",... | 0.6870817 | 48 |
Return if there are positive number in a list. | def has_positive(l):
return any([p > 0 for p in l]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonzero(list_):\n for a in list_:\n if a!=0:\n return True\n return False",
"def onlyonepositive(a):\n nbr = 0\n for e in a:\n if e >= 0: \n nbr += 1\n if nbr>1: return False\n return nbr==1",
"def check_sum(num_list: list) -> bool:\r\n num_l... | [
"0.77211535",
"0.7292462",
"0.67892927",
"0.6733688",
"0.67298824",
"0.65459853",
"0.64620036",
"0.64514464",
"0.6429815",
"0.6399997",
"0.6359512",
"0.6352985",
"0.63303584",
"0.6264943",
"0.624274",
"0.6240415",
"0.6221899",
"0.6161041",
"0.61327326",
"0.61004806",
"0.60866... | 0.8231804 | 0 |
update the comment, returns the updated comment object | def put(self, data):
if 'content' in data:
self.context.content = data['content']
self.context.mtime = datetime.datetime.now()
self.db.flush()
return self.context.as_dict(self.user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_comment():\n # Implement me!\n\n logger.info(\"vars: %r\" % request.vars)\n logger.info(\"vars_comment_text: %r\" % request.vars.comment_text)\n logger.info(\"vars id: %r\" % request.vars.comment_id)\n logger.info(\"comment_text: %r\" % db(db.Comments.id == request.vars.comment_id))\n\n ... | [
"0.7505439",
"0.7020776",
"0.70142674",
"0.70094633",
"0.69599533",
"0.694627",
"0.69388866",
"0.6909832",
"0.68660694",
"0.6837548",
"0.6788977",
"0.67880875",
"0.67880875",
"0.6757419",
"0.671422",
"0.66595525",
"0.66256803",
"0.65920687",
"0.65920687",
"0.6591285",
"0.6497... | 0.0 | -1 |
Test case for get_offers | def test_get_offers(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_offers_show_every(self):\n result = self.client.get('/offers_show_every')\n self.assertEqual(result.status, '200 OK')\n self.assertIn(b'Offers', result.data)",
"def test_offers_new(self):\n result = self.client.get('/offers_new')\n self.assertEqual(result.status, '200 ... | [
"0.76182306",
"0.701146",
"0.6992594",
"0.6685116",
"0.6681483",
"0.6667998",
"0.65268654",
"0.6498977",
"0.6476835",
"0.63730186",
"0.636235",
"0.63345194",
"0.6300536",
"0.6272169",
"0.6201638",
"0.61964214",
"0.61756366",
"0.6163078",
"0.61200154",
"0.6075485",
"0.6071051"... | 0.9226012 | 0 |
Test case for post_query_reply_offers | def test_post_query_reply_offers(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_brands_reply(self):\n # 1. Setup service channel / dispatch channel\n # 2. send a post to brand\n # 3. Reply with custom response\n # 4. Route a reply\n # 5. check there is no extra responses created\n # 6. create a matchable and repeat 1-5\n brand = 'brand... | [
"0.6047266",
"0.5921384",
"0.58601",
"0.58514297",
"0.5829743",
"0.57101303",
"0.57101303",
"0.569029",
"0.5685805",
"0.5659997",
"0.56575954",
"0.5650776",
"0.56448174",
"0.55697227",
"0.55605835",
"0.55522627",
"0.5547608",
"0.5543996",
"0.55412924",
"0.55405164",
"0.551622... | 0.9376161 | 0 |
Get valid subject name from the validation list. | def get_valid_subject_name(self, position):
"""
Arguments:
position: position of the name in the list
Returns:
valid subject's name
"""
assert position < self.n_valid,\
"The total number of validation samples is: %d" % self.n_va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval_subject_name(self, position):\n \"\"\"\n Arguments:\n position: position of the name in the list\n Returns:\n eval subject's name\n \"\"\"\n assert position < self.n_eval,\\\n \"The total number of evaluation samples i... | [
"0.63036346",
"0.62889",
"0.62056816",
"0.5997642",
"0.5895169",
"0.56481797",
"0.562876",
"0.56247073",
"0.5564403",
"0.55145323",
"0.5496684",
"0.54586786",
"0.542141",
"0.5390427",
"0.5390427",
"0.5357935",
"0.5350442",
"0.533212",
"0.52949905",
"0.528305",
"0.5232104",
... | 0.8160653 | 0 |
Represent data for this node and its successors as a string. >>> l1 = Node(3) >>> l1.as_rev_string() '3' >>> l1 = Node(3, Node(2, Node(1))) >>> l1.as_rev_string() '123' | def as_rev_string(self):
out = []
n = self
while n:
out.append(str(n.data))
n = n.next
return "".join(reversed(out)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n string = \"\"\n cur_node = self.head\n while cur_node is not None:\n string += cur_node.data.__str__()\n cur_node = cur_node.next\n return string",
"def __str__(self):\n s = \"\"\n current = self.__head\n while current:\n... | [
"0.7004908",
"0.69331115",
"0.6837348",
"0.683472",
"0.67163855",
"0.66946685",
"0.6660352",
"0.6619991",
"0.6599775",
"0.6560227",
"0.6525102",
"0.65225345",
"0.6480557",
"0.64620215",
"0.645294",
"0.64494914",
"0.6422252",
"0.6411429",
"0.6402353",
"0.6381566",
"0.6358572",... | 0.77878225 | 0 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(AidHUI, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.health is None:
self.health = 0
if self.utcA0 is None:
self.utcA0 = 0.
if self.utcA1 is None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.7794938",
"0.77218187",
"0.77218187",
"0.76881015",
"0.7627416",
"0.75650686",
"0.7441556",
"0.7418871",
"0.7351959",
"0.7308522",
"0.7280604",
"0.72376406",
"0.7227385",
"0.72258365",
"0.72258365",
"0.72192574",
"0.7213339",
"0.7213339",
"0.7213339",
"0.7213339",
"0.72133... | 0.0 | -1 |
Returns a dictionary with all sub_blocks that have sub_height >= peak sub_height blocks_n, as well as the peak header hash. | async def get_sub_blocks_from_peak(self, blocks_n: int) -> Tuple[Dict[bytes32, SubBlockRecord], Optional[bytes32]]:
res = await self.db.execute("SELECT * from sub_block_records WHERE is_peak = 1")
row = await res.fetchone()
await res.close()
if row is None:
return {}, None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_sub_block_dicts(self) -> Tuple[Dict[uint32, bytes32], Dict[uint32, SubEpochSummary]]:\n\n res = await self.db.execute(\"SELECT * from sub_block_records WHERE is_peak = 1\")\n row = await res.fetchone()\n await res.close()\n if row is None:\n return {}, {}\n\n ... | [
"0.6718056",
"0.6645126",
"0.5870701",
"0.5596961",
"0.5568936",
"0.5459704",
"0.54170156",
"0.53998464",
"0.53407425",
"0.52779704",
"0.5269007",
"0.52453315",
"0.5236605",
"0.5227864",
"0.5219503",
"0.5175411",
"0.5145804",
"0.5138298",
"0.5124882",
"0.51037955",
"0.5071132... | 0.73399156 | 0 |
Initializes the URA using characteristics of the xr.DataArray. | def __init__(self, data_array, cui2name):
assert isinstance(data_array, xr.DataArray), 'Constructor requires xr.DataArray.'
self.data_array = data_array
self.data = self.data_array.values
self.sources = self.data_array.source.values
self.targets = self.data_array.target.values
self.metrics = self.data_arra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, xarray_obj):\n super(RasterDataArray, self).__init__(xarray_obj)",
"def __init__(self, xarray_obj):\n super(XRasterBase, self).__init__(xarray_obj)",
"def __init__(self, data_array):\n self._data_array = data_array\n self._units = self._data_array.attrs.get('units... | [
"0.65598696",
"0.6009049",
"0.58663225",
"0.5743766",
"0.57187927",
"0.5697086",
"0.56335866",
"0.56290436",
"0.5593048",
"0.5565473",
"0.5539854",
"0.551571",
"0.5500209",
"0.54929787",
"0.54854995",
"0.5459809",
"0.5453355",
"0.5448729",
"0.539661",
"0.53937316",
"0.5392156... | 0.6366975 | 1 |
Normalizes along dimension `axis` using an L2 norm. This specialized function exists for numerical stability reasons. | def _l2_normalize(x, axis=None, eps=1e-12):
return x * jax.lax.rsqrt((x * x).sum(axis=axis, keepdims=True) + eps) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def L2_norm(x, axis=-1):\n return keras.backend.l2_normalize(x, axis=axis)",
"def l2_normalize(data, axis=-1, eps=1e-6):\n ret = data / (np.linalg.norm(data, axis=axis, keepdims=True) + eps)\n return ret",
"def l2_normalize(data, eps, axis=None):\n return cpp.nn.l2_normalize(data, eps, axis)",
"d... | [
"0.81979185",
"0.81201303",
"0.76465195",
"0.74191755",
"0.72494805",
"0.72071797",
"0.71965885",
"0.7150768",
"0.70740837",
"0.7066513",
"0.6917897",
"0.6877026",
"0.67952",
"0.67790395",
"0.6737739",
"0.6715988",
"0.67142457",
"0.66988385",
"0.66967857",
"0.66967857",
"0.66... | 0.79119027 | 2 |
Initializes an SpectralNorm module. | def __init__(
self,
eps: float = 1e-4,
n_steps: int = 1,
name: Optional[str] = None,
):
super().__init__(name=name)
self.eps = eps
self.n_steps = n_steps | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setup_sensor ( self ):\n self.spectral = Spectral ( np.array([450, 520, 630, 770., 1550, 2090.] ),\n np.array([ 520, 600, 690, 900., 1750., 2350.] ) )",
"def _setup_sensor ( self ):\n self.spectral = Spectral ( np.array([500, 610, 780, 1580.] ),\n ... | [
"0.654872",
"0.65115786",
"0.62402457",
"0.61430484",
"0.6098814",
"0.59957963",
"0.5941377",
"0.5891013",
"0.58713466",
"0.5870207",
"0.58647656",
"0.5858942",
"0.5794146",
"0.5755449",
"0.5742214",
"0.5719434",
"0.5693104",
"0.5669909",
"0.563323",
"0.56286854",
"0.55559146... | 0.0 | -1 |
must transform seq_ys to onehot, IF USE TF FOR CORRECTION LABELLING | def sequence_predict(self,sess,seq_xs,dropout,seqlen,seq_ys = []):
if len(seq_ys) > 0:
# since we have 1 sequence
seq_ys = seq_ys[0,0:seqlen[0]]
y = np.zeros([seqlen[0],2])
y[np.arange(0,seqlen[0]),np.array(seq_ys,dtype=np.int32)] = 1
"""cut spare entries... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(seq):\n prot_seq = seq\n BASES = 'ARNDCQEGHILKMFPSTWYV'\n bases = np.array([base for base in BASES])\n feat = np.concatenate(\n [[(bases == base.upper()).astype(int)] if str(base).upper() in BASES else np.array([[-1] * len(BASES)]) for base\n in prot_seq])\n return feat",
... | [
"0.7347744",
"0.7000622",
"0.69049084",
"0.68621737",
"0.68258244",
"0.67841196",
"0.6725663",
"0.6703079",
"0.6665239",
"0.66638666",
"0.66544235",
"0.66123766",
"0.66001654",
"0.6570477",
"0.65520424",
"0.65492046",
"0.6534541",
"0.6518564",
"0.6512032",
"0.6511438",
"0.650... | 0.0 | -1 |
must transform seq_ys to onehot, IF USE TF FOR CORRECTION LABELLING | def CNN_sequence_predict(cnn,sess,seq_xs,dropout,seqlen,seq_ys = []):
if len(seq_ys) > 0:
y = np.zeros([seqlen[0],2])
y[np.arange(0,seqlen[0]),np.array(seq_ys,dtype=np.int32)] = 1
cost = -1
if len(seq_ys) > 0:
llogits, predictions,cost = sess.run( [cnn.logit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(seq):\n prot_seq = seq\n BASES = 'ARNDCQEGHILKMFPSTWYV'\n bases = np.array([base for base in BASES])\n feat = np.concatenate(\n [[(bases == base.upper()).astype(int)] if str(base).upper() in BASES else np.array([[-1] * len(BASES)]) for base\n in prot_seq])\n return feat",
... | [
"0.73477733",
"0.70013154",
"0.6906219",
"0.68627095",
"0.68260723",
"0.6786618",
"0.6727752",
"0.67029953",
"0.6664745",
"0.66645926",
"0.66569376",
"0.66124994",
"0.66026324",
"0.65727997",
"0.65531856",
"0.65509117",
"0.6535372",
"0.6518666",
"0.65134346",
"0.6513381",
"0.... | 0.0 | -1 |
Reset cooldown for a spell that has been casted. | def resetCooldown(player, spellid, seed):
if player:
if player.spellsCasted.has_key(spellid):
# seed is to ensure cooldown is removing for the correct casting as
# the caster could have died and recasted the spell
if player.spellsCasted[spellid] is seed:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_fedcm_cooldown(self):\n pass",
"async def _reset_cooldowns(self, ctx):\n if await self.casino_is_global():\n for player in await self.db.all_users():\n try:\n user = await ctx.bot.fetch_user(player)\n except AttributeError:\n ... | [
"0.64685977",
"0.58603543",
"0.56642014",
"0.5626359",
"0.55059505",
"0.54801047",
"0.5420794",
"0.539609",
"0.5290534",
"0.51710445",
"0.5133951",
"0.5108581",
"0.5085112",
"0.5042354",
"0.50306606",
"0.50131863",
"0.4998343",
"0.4996965",
"0.49597856",
"0.49414253",
"0.4922... | 0.7984658 | 0 |
def default(self) set the link_words list to a default list of some english link_words. | def default(self):
self.link_words = ['accordingly', 'actually', 'and', 'also', 'although', 'as', 'because', 'besides', 'but', 'consequently', 'conversely', 'eventually', 'firstly', 'furthermore', 'how', 'hence', 'however', 'if', 'meanwhile', 'moreover', 'namely', 'nevertheless', 'next', 'nonetheless', 'once', 'other... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\t\tself.link_words = []",
"def __init__(self, sNLP, link_words=None, list_punct_simple = [';',':','(',')'], list_punct_cmplx = [\"--\"]):\n\t\tif link_words == None:\n\t\t\tself.link_words = LinksWords()\n\t\t\tself.link_words.default()\n\t\tself.list_punct_simple = list_punct_simple\n\t\ts... | [
"0.69457674",
"0.62121487",
"0.6066871",
"0.5894917",
"0.58607024",
"0.5614325",
"0.56142855",
"0.55854076",
"0.5510025",
"0.5502078",
"0.5497211",
"0.5496076",
"0.5484538",
"0.54762065",
"0.5474935",
"0.5438736",
"0.5367142",
"0.5367142",
"0.53523207",
"0.5275611",
"0.526559... | 0.8329805 | 0 |
Creates an Actor instance with an empty context. | def actor():
return Actor() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, concurrency = 1):\n warnings.warn(\"We're phasing out the Actor class, so as to get rid of\"\n \"the coros module. If you use Actor, please speak up on \"\n \"eventletdev@lists.secondlife.com, and we'll come up with a \"\n \"transitio... | [
"0.6023027",
"0.5766297",
"0.5761367",
"0.54024166",
"0.5383121",
"0.5198913",
"0.51878303",
"0.5173661",
"0.51520634",
"0.51336956",
"0.50445735",
"0.49691996",
"0.49674845",
"0.49629658",
"0.4960038",
"0.49351895",
"0.4923349",
"0.48964354",
"0.48842847",
"0.48767823",
"0.4... | 0.63404906 | 0 |
Take the softmax of `logits` over given dimension, and set entries to 0 wherever `mask` is 0. | def masked_softmax(logits, mask, dim=-1, log_softmax=False):
mask = mask.type(torch.float32)
masked_logits = mask * logits + (1 - mask) * -1e30
softmax_fn = F.log_softmax if log_softmax else F.softmax
probs = softmax_fn(masked_logits, dim)
return probs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masked_softmax(logits, mask, dim):\n exp_mask = (1 - tf.cast(mask, 'float')) * (-1e30) # -large where there's padding, 0 elsewhere\n masked_logits = tf.add(logits, exp_mask) # where there's padding, set logits to -large\n prob_dist = tf.nn.softmax(masked_logits, dim)\n return masked_logits, prob_di... | [
"0.78365254",
"0.78365254",
"0.71126115",
"0.69034487",
"0.68940914",
"0.68670464",
"0.6841659",
"0.6840338",
"0.6839226",
"0.6816966",
"0.6647428",
"0.66378504",
"0.657287",
"0.6564672",
"0.6538492",
"0.65051174",
"0.64922285",
"0.6484271",
"0.64635235",
"0.6428213",
"0.6365... | 0.7660106 | 2 |
Render website's home page. | def home():
return render_template('home.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n return render_template('homepage.html')",
"def home():\n\n return render_template('home_page.html')",
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"... | [
"0.8724249",
"0.85791856",
"0.850329",
"0.84860355",
"0.84612614",
"0.84362435",
"0.8429879",
"0.8419578",
"0.8396612",
"0.8396612",
"0.8374868",
"0.8356488",
"0.8350785",
"0.8340763",
"0.8340763",
"0.8336323",
"0.8330013",
"0.8329599",
"0.8325031",
"0.8317146",
"0.8293699",
... | 0.83374727 | 19 |
Render the website's about page. | def about():
return render_template('about.html', name="Mary Jane") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about():\n\n\treturn render_template(\"about.html\")",
"def about():\n return render_template(\n 'about.html',\n title='About',\n ... | [
"0.87910306",
"0.8698105",
"0.86404276",
"0.86124563",
"0.8490408",
"0.84784615",
"0.8467779",
"0.84352976",
"0.84289914",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242",
"0.8424242... | 0.7684119 | 77 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.822279",
"0.8221949",
"0.8221949",
"0.8221949",
"0.8221949",
"0.81952757",
"0.8112146",
"0.80862916",
"0.79723567",
"0.7865226",
"0.7660734",
"0.72365665",
"0.71592164",
"0.71522385",
"0.71522385",
"0.7149995",
"0.7149995",
"0.7141148",
"0.7136335",
"0.7127464",
"0.7127464... | 0.8162726 | 14 |
Test to ensure the LVS Real Server in specified service is absent. | def test_absent():
name = "lvsrs"
ret = {"name": name, "result": None, "comment": "", "changes": {}}
mock_check = MagicMock(side_effect=[True, True, True, False])
mock_delete = MagicMock(side_effect=[True, False])
with patch.dict(
lvs_server.__salt__,
{"lvs.check_server": mock_chec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dontStartPrivilegedService(self):\n ports = self._privilegedStartService(self.highPortNumber)\n self.assertEqual(ports, [])",
"def check_NonExistingTestService(test_case, override_service_name=null):\n # type: (AnyMagpieTestCaseType, Optional[Str]) -> None\n services_info = T... | [
"0.6525983",
"0.6507412",
"0.631911",
"0.6117195",
"0.60492325",
"0.5902874",
"0.5886381",
"0.5863452",
"0.5845744",
"0.5841201",
"0.5830439",
"0.57938516",
"0.5792845",
"0.5787666",
"0.57874554",
"0.5760502",
"0.5752704",
"0.5696341",
"0.56909937",
"0.56698793",
"0.5659",
... | 0.6117459 | 3 |
Initalize an instance of the User class. Arguments | def __init__(self, skills_oh, places_oh, domains_oh, schools_dictionnary, skills = [], age = 0, place = "", company = "",
schools = [], _id = 0):
self._id = _id
self.skills = skills
self.age = age
self.place = place
self.company ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, user: User):\n self.user = user",
"def __init__(self, user=None):\n self.user = user",
"def __init__(self, user):\n\n if isinstance(user, dict):\n # Every user must have these values\n self.id = user['id']\n self.name = user['first_name']... | [
"0.74823457",
"0.7415884",
"0.73180866",
"0.7309201",
"0.7178027",
"0.715587",
"0.7069644",
"0.70147485",
"0.70091045",
"0.69978553",
"0.69715595",
"0.69171906",
"0.69170386",
"0.6907267",
"0.68760073",
"0.6828032",
"0.67903686",
"0.6790274",
"0.67850065",
"0.6779088",
"0.676... | 0.0 | -1 |
Input n>=6, Returns a array of primes, 2 <= p < n | def primesfrom2to(n):
sieve = numpy.ones(n/3 + (n%6==2), dtype=numpy.bool)
for i in xrange(1,int(n**0.5)/3+1):
if sieve[i]:
k=3*i+1|1
sieve[ k*k/3 ::2*k] = False
sieve[k*(k-2*(i&1)+4)/3::2*k] = False
return numpy.r_[2,3,((3*numpy.nonzero(sieve)[0][1:]+1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probable_prime(n: int) -> [int]:\n return [6*n-1, 6*n+1]",
"def get_primes(n):\n\n return list(primes_sieve(n))",
"def prime_array(number_of_primes) -> array:\n p = array('i',list(primes(number_of_primes)))\n return p",
"def make_primes(n):\n out_list = []\n for i in range(2, n):\n ... | [
"0.78810406",
"0.78444964",
"0.77933097",
"0.7650548",
"0.7626844",
"0.75202084",
"0.75010294",
"0.7486007",
"0.74678427",
"0.74572444",
"0.7429019",
"0.74092805",
"0.73962444",
"0.73798555",
"0.7366298",
"0.7364451",
"0.7356198",
"0.7351732",
"0.73305947",
"0.7302029",
"0.72... | 0.7035659 | 44 |
socli.fix_google_url() adds `https` protocol if not existent yet | def test_fix_google_url():
url = _search.fix_google_url("www.example.com/questions/1234")
assert url == "https://www.example.com/questions/1234" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_url(url):\n\n if not url.startswith('http'):\n url = 'http://' + url\n\n return url",
"def url_prepare(url):\n if 'http://' in url or 'https://' in url:\n return url\n try:\n if requests.get('https://' + url):\n return 'https://' + url\n except Exception as... | [
"0.7377884",
"0.7000733",
"0.68584746",
"0.6825751",
"0.66962713",
"0.6465938",
"0.64518553",
"0.6405671",
"0.6373408",
"0.6217376",
"0.6148668",
"0.61436564",
"0.6108983",
"0.60816705",
"0.6059763",
"0.60215217",
"0.5997181",
"0.5968289",
"0.5962476",
"0.5947451",
"0.5923557... | 0.7352019 | 1 |
Get filepaths to be moved | def get_filepaths_to_remove(scratch_dir, target_dir):
target_fns = [fp.name for fp in target_dir.glob("*/*") if fp.name[-3:] == ".nc"]
return [fp for fp in scratch_dir.glob("*/*") if fp.name in target_fns] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_files_paths(self):\n return self.__files_paths",
"def filepaths(self):\n pass",
"def get_paths(self):\n return (self.world_fpath, self.subj_fpath, self.peds_fpath)",
"def _path_files(self):\n\n if not os.path.exists(self.path):\n return None\n\n directory... | [
"0.7319363",
"0.70674855",
"0.6997715",
"0.6931481",
"0.6925145",
"0.6792038",
"0.67801195",
"0.6773894",
"0.67400765",
"0.6699727",
"0.66884786",
"0.66734654",
"0.6645538",
"0.66137016",
"0.6579142",
"0.65772176",
"0.65765697",
"0.65658504",
"0.65658504",
"0.65296656",
"0.65... | 0.0 | -1 |
Read pd.dataframe from txt file Take first row as header | def read_sectionKLD_df(txtpath, dfname=False):
df = pd.read_csv(txtpath, header=0)
if not dfname:
df.name = re.search(r'(\w+)_kld.txt',basename(txtpath)).group(1)
else:
df.name = dfname
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(txt_path: str = RAW_TXT) -> pd.DataFrame:\n df = pd.read_csv(txt_path)[INDICES]\n return df",
"def _parse_textfile(self):\n\n field_names = list(self.FIELD_NAME_TO_INDEX.keys())\n field_indices = list(self.FIELD_NAME_TO_INDEX.values())\n frame = pd.read_csv(\n ... | [
"0.72828764",
"0.72581106",
"0.7040358",
"0.6893565",
"0.67912793",
"0.66897494",
"0.6671475",
"0.6629908",
"0.65933967",
"0.6588113",
"0.6584307",
"0.6516371",
"0.65063375",
"0.64825845",
"0.6474374",
"0.6464861",
"0.6455139",
"0.64547133",
"0.64447194",
"0.64441633",
"0.644... | 0.6273738 | 28 |
Returns whether this variable is binary variable. | def is_binary(self):
return self._vtype is self.BINARY | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DataIsBinaryData(self):\n return self.data_type == definitions.REG_BINARY",
"def _is_binary(name):\n\n return name in unidata.unicode_binary or name in unidata.unicode_alias['binary']",
"def isbinary(f):\n return f.dtype == bool",
"def is_binary_payload(cls) -> bool:\n return True",
"de... | [
"0.7074085",
"0.6940666",
"0.6861149",
"0.6839288",
"0.65833735",
"0.6501432",
"0.6459711",
"0.6421068",
"0.6354459",
"0.63503325",
"0.6347556",
"0.62427443",
"0.6240889",
"0.6217807",
"0.62014985",
"0.6156533",
"0.6073995",
"0.60325956",
"0.5972762",
"0.59642637",
"0.5908629... | 0.7812761 | 0 |
Returns the variable upper bound value. | def get_upper_bound(self):
return self._upper_bound | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_bound(self) -> float:\n ...",
"def upper_bound(height):\n tan_72 = math.tan(math.radians(72))\n upper_boundary = 250 + height / tan_72\n return upper_boundary",
"def upper_global(self):\n return self.get_dim_attribute('upper')",
"def getUpperBound(self) -> int:\n retur... | [
"0.7648803",
"0.6916557",
"0.68514436",
"0.67856795",
"0.67529786",
"0.6705144",
"0.6573983",
"0.65643513",
"0.65576863",
"0.6537298",
"0.63787186",
"0.6277389",
"0.6272858",
"0.6266706",
"0.6126394",
"0.6102305",
"0.60279924",
"0.60163176",
"0.5994444",
"0.59753996",
"0.5960... | 0.76406366 | 1 |
Initialization of Army object contains 2 squads with different strength values | def setUp(self):
self.army = army.Army(0, "random_squad")
self.army.squads[0].get_damage(0.6)
self.army.squads[1].get_damage(0.9) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, strength, **kwargs):\n\n # Store strength, add a repr-addition.\n self._strength = strength\n self._repr_add = f\"{self.strength:,.1f} A;\"\n\n super().__init__(**kwargs)",
"def __init__(self, denoiser_strength): \n self._strength = denoiser_strength",
"def... | [
"0.64462787",
"0.6437603",
"0.6424373",
"0.6131473",
"0.60784245",
"0.6050375",
"0.593263",
"0.5899531",
"0.5878803",
"0.5878803",
"0.5878803",
"0.57708246",
"0.57265824",
"0.57153946",
"0.56940794",
"0.568678",
"0.568678",
"0.5662015",
"0.5660123",
"0.56527823",
"0.56504446"... | 0.5958986 | 6 |
Creates and saves a User with the given username, email and password. | def create_user(self, username, email, password=None):
now = timezone.now()
if not username:
raise ValueError('The given username must be set')
if not email:
raise ValueError('Users must have an email address')
user = self.model(username=username,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.86018604",
"0.8470518",
"0.84632266",
"0.8417567",
"0.84143835",
"0.83928436",
"0.834656",
"0.83461845",
"0.8314962",
"0.8306497",
"0.8289392",
"0.82770276",
"0.8271251",
"0.8258233",
"0.8213149",
"0.81979084",
"0.81759745",
"0.81719893",
"0.81636846",
"0.8163305",
"0.8137... | 0.80850977 | 23 |
Creates and saves a superuser with the given username, email and password. | def create_superuser(self, username, email, password):
user = self.create_user(username, email,
password=password
)
user.is_admin = True
user.is_active = True
user.is_superuser = True
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_superuser(username, email, password):\n if username and email and password:\n user, created = User.objects.get_or_create(pk=defaults.USERWARE_SUPERUSER_ID)\n if user:\n user.username = username\n user.email = email\n user.set_password(password)\n ... | [
"0.83959347",
"0.8277215",
"0.8262071",
"0.8183218",
"0.8175094",
"0.81698024",
"0.8132562",
"0.8121137",
"0.811828",
"0.8118269",
"0.8114283",
"0.8107188",
"0.8097342",
"0.80830115",
"0.8036451",
"0.8026299",
"0.8006595",
"0.79756224",
"0.7972572",
"0.79663754",
"0.7954823",... | 0.8055361 | 14 |
Given an input vector x, run it through the neural network and return the output vector. | def predict(self, x):
assert isinstance(x, np.ndarray)
output = x
for layer in self._layers:
output = layer.feed_forward(output)
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_network(self, x):\n # We have the input vector x, this is the first layer in our nn\n a = x\n\n # So we need to run the neural network now. We are going to make\n # things extra explicit by having the z term. Clearly super\n # inefficient\n for w, b in zip(self.w... | [
"0.7754827",
"0.73055935",
"0.7172319",
"0.7074188",
"0.6984514",
"0.697744",
"0.6861625",
"0.6861625",
"0.68406343",
"0.673689",
"0.67055863",
"0.6662573",
"0.6625359",
"0.65345633",
"0.64994085",
"0.64842737",
"0.6483687",
"0.6463754",
"0.64379656",
"0.64277136",
"0.6427080... | 0.0 | -1 |
x is a scalar or a numpy array. Returns the output y, the result of applying the function to input x. | def activate(x):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, _x: np.ndarray) -> np.ndarray:\n return self.function(_x)",
"def __call__(self, x):\n z = np.asarray(x)\n return (self._evaluate(z.flatten())).reshape(z.shape)",
"def fn(x):\n if x.ndim == 1:\n return np.sum(x**2)\n else:\n return np.sum(x**2, axis=1)... | [
"0.7265205",
"0.7036451",
"0.6938741",
"0.6828958",
"0.67526007",
"0.67203313",
"0.6713422",
"0.6701469",
"0.66541934",
"0.6647517",
"0.66442484",
"0.66442484",
"0.66442484",
"0.66442484",
"0.6640261",
"0.6622106",
"0.65752697",
"0.65249795",
"0.6516136",
"0.650396",
"0.64652... | 0.0 | -1 |
y is a scalar or a numpy array. Returns the derivative d(f)/dx given the activation value y. | def derivative_given_y(self, y):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_given_y(self, y):\n\n return np.dot(y, np.subtract(1.0, y))",
"def derivative_given_y(self, y):\n return 1",
"def derivativeY(self, x, y):\n xa = np.asarray(x)\n ya = np.asarray(y)\n return (self._derY(xa.flatten(), ya.flatten())).reshape(xa.shape)",
"def der... | [
"0.8281769",
"0.7971777",
"0.7282453",
"0.7278014",
"0.7158988",
"0.7157939",
"0.71467376",
"0.7113143",
"0.6956741",
"0.6943898",
"0.69056106",
"0.6891197",
"0.6891197",
"0.6891197",
"0.6891197",
"0.688776",
"0.6866506",
"0.6794079",
"0.6761467",
"0.6738223",
"0.66712993",
... | 0.78804624 | 2 |
x is a scalar or a numpy array. Returns the output y, the result of applying the function to input x. | def activate(self, x):
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, _x: np.ndarray) -> np.ndarray:\n return self.function(_x)",
"def __call__(self, x):\n z = np.asarray(x)\n return (self._evaluate(z.flatten())).reshape(z.shape)",
"def fn(x):\n if x.ndim == 1:\n return np.sum(x**2)\n else:\n return np.sum(x**2, axis=1)... | [
"0.7263772",
"0.7037865",
"0.69381595",
"0.68272054",
"0.6752792",
"0.67196923",
"0.6712783",
"0.6702161",
"0.66542125",
"0.664771",
"0.664145",
"0.664145",
"0.664145",
"0.664145",
"0.6636937",
"0.6619112",
"0.6572321",
"0.65235347",
"0.65154076",
"0.6504698",
"0.6462373",
... | 0.0 | -1 |
y is a scalar or a numpy array. Returns the derivative d(f)/dx given the activation value y. | def derivative_given_y(self, y):
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_given_y(self, y):\n\n return np.dot(y, np.subtract(1.0, y))",
"def derivative_given_y(self, y):\n raise NotImplementedError()",
"def derivativeY(self, x, y):\n xa = np.asarray(x)\n ya = np.asarray(y)\n return (self._derY(xa.flatten(), ya.flatten())).reshape(xa.... | [
"0.82820845",
"0.7881551",
"0.72829795",
"0.72786236",
"0.71590436",
"0.7158745",
"0.7147602",
"0.711359",
"0.6956152",
"0.69446176",
"0.69049567",
"0.68905175",
"0.68905175",
"0.68905175",
"0.68905175",
"0.6887191",
"0.68659693",
"0.679469",
"0.6761929",
"0.6738578",
"0.6672... | 0.797249 | 1 |
x is a scalar or a numpy array. Returns the output y, the result of applying the function to input x. | def activate(self, x):
return 1.0 / (1 + np.exp(-x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, _x: np.ndarray) -> np.ndarray:\n return self.function(_x)",
"def __call__(self, x):\n z = np.asarray(x)\n return (self._evaluate(z.flatten())).reshape(z.shape)",
"def fn(x):\n if x.ndim == 1:\n return np.sum(x**2)\n else:\n return np.sum(x**2, axis=1)... | [
"0.7265205",
"0.7036451",
"0.6938741",
"0.6828958",
"0.67526007",
"0.67203313",
"0.6713422",
"0.6701469",
"0.66541934",
"0.6647517",
"0.66442484",
"0.66442484",
"0.66442484",
"0.66442484",
"0.6640261",
"0.6622106",
"0.65752697",
"0.65249795",
"0.6516136",
"0.650396",
"0.64652... | 0.0 | -1 |
y is a scalar or a numpy array. Returns the derivative d(f)/dx given the activation value y. | def derivative_given_y(self, y):
return np.dot(y, np.subtract(1.0, y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_given_y(self, y):\n return 1",
"def derivative_given_y(self, y):\n raise NotImplementedError()",
"def derivativeY(self, x, y):\n xa = np.asarray(x)\n ya = np.asarray(y)\n return (self._derY(xa.flatten(), ya.flatten())).reshape(xa.shape)",
"def derivativeY(sel... | [
"0.7971777",
"0.78804624",
"0.7282453",
"0.7278014",
"0.7158988",
"0.7157939",
"0.71467376",
"0.7113143",
"0.6956741",
"0.6943898",
"0.69056106",
"0.6891197",
"0.6891197",
"0.6891197",
"0.6891197",
"0.688776",
"0.6866506",
"0.6794079",
"0.6761467",
"0.6738223",
"0.66712993",
... | 0.8281769 | 0 |
Number of nodes in this layer. | def size(self):
if type(self._shape).__name__ == 'tuple':
return self._shape[-1]
else:
return self._shape | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_nodes(self):\n return int(self._data['number_of_nodes'])",
"def number_of_nodes(self) -> int:\n return self.graph.number_of_nodes()",
"def num_nodes(self):\n return len(self.nodes)",
"def NodesCount(self):\n return len(self.nodes)",
"def Nnodes(self):\n retu... | [
"0.884108",
"0.8839241",
"0.88105243",
"0.87139344",
"0.8681243",
"0.86454386",
"0.86454386",
"0.8633927",
"0.86019003",
"0.8587419",
"0.8584337",
"0.85082716",
"0.8491084",
"0.84907573",
"0.8444417",
"0.8343219",
"0.8335802",
"0.8335682",
"0.8314132",
"0.82749814",
"0.820933... | 0.0 | -1 |
Retuns the return between the first and last value of the DataFrame. | def total_return_from_returns(returns):
return (returns + 1).prod() - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pasrse_data_start_end(self, data):\n first = data['obs_time'].iloc[0]\n last = data['obs_time'].iloc[-1]\n\n return (first, last)",
"def ends(df, x=5):\n return df.head(x).append(df.tail(x))",
"def end(self) -> datetime:\n return self.df.index[-1].to_pydatetime()",
"def ta... | [
"0.62884945",
"0.6218539",
"0.6029459",
"0.59238476",
"0.5906566",
"0.5862075",
"0.56956667",
"0.5684081",
"0.5657445",
"0.5637002",
"0.5610714",
"0.55805355",
"0.55770147",
"0.5563085",
"0.55573285",
"0.5502801",
"0.5501828",
"0.5491376",
"0.5477382",
"0.5439566",
"0.541723"... | 0.0 | -1 |
Airtable returns ISO 8601 date string eg. "20140905 | def to_internal_value(self, value: str) -> date:
return utils.date_from_iso_str(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_to_str(obj: \"date\") -> str:\n return obj.isoformat()",
"def toisostring(dt):\n return dt.format(ISOFORMAT) + 'Z'",
"def format_datestr(v):\n return v.isoformat() + 'Z'",
"def isoformat(self):\n return \"%04d-%02d-%02d\" % (self._year, self._month, self._day)",
"def format_date_is... | [
"0.7274548",
"0.723659",
"0.710448",
"0.6892617",
"0.68477327",
"0.67942494",
"0.6793317",
"0.6766327",
"0.67001003",
"0.66711015",
"0.6663165",
"0.6637688",
"0.6629122",
"0.6582647",
"0.6572089",
"0.6553097",
"0.6550876",
"0.6538845",
"0.648271",
"0.64795166",
"0.64693916",
... | 0.0 | -1 |
Find a satisfying assignment for a given CNF formula. Returns that assignment if one exists, or None otherwise. >>> satisfying_assignment([]) {} >>> x = satisfying_assignment([[('a', True), ('b', False), ('c', True)]]) >>> x.get('a', None) is True or x.get('b', None) is False or x.get('c', None) is True True >>> satisf... | def satisfying_assignment(formula):
if len(formula) == 0:
return {}
solution = find_solution(formula)
if solution != {}:
return solution
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def satisfying_assignment(formula):\n # convert the formula to a list of sets.\n formula = [set(i) for i in formula]\n\n # call the helper starting with the givne formula and an empty assignments\n # dictionary.\n result = sat_helper(formula, {})\n if result[0]:\n return result[1] # resul... | [
"0.819847",
"0.7084346",
"0.62437457",
"0.5711736",
"0.5696458",
"0.5462854",
"0.5451768",
"0.54476345",
"0.5438681",
"0.5257444",
"0.52328926",
"0.52178246",
"0.51854515",
"0.5175418",
"0.5156013",
"0.5109788",
"0.5089812",
"0.5082111",
"0.507183",
"0.50628316",
"0.49926516"... | 0.76016676 | 1 |
Finds and parses all integers in the string x | def ints_in(x: str) -> list[int]:
ex = r'(?:(?<!\d)-)?\d+'
return ints(re.findall(ex, x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strToListInt(x):\n if type(x)==str:\n return [int(i) for i in x[1:-1].split(\", \")]",
"def parse_input(string):\n return [int(vote) for vote in string.split()]",
"def find_numbers(text):\n result = []\n for word in text.split():\n if word.isdigit():\n result.ap... | [
"0.6700874",
"0.6699546",
"0.6608552",
"0.65675336",
"0.64741063",
"0.6469193",
"0.645327",
"0.6372926",
"0.6344449",
"0.63079387",
"0.6279571",
"0.62669784",
"0.62510616",
"0.62431026",
"0.6222961",
"0.621731",
"0.6215568",
"0.6213727",
"0.6211594",
"0.62020713",
"0.6173085"... | 0.76216453 | 0 |
Save PyTorch model parameter to NPY file Requirements import numpy as np | def save_param_to_npy(model, param_name, path):
for name, param in model.named_parameters():
if name == param_name + '.weight':
weights = param.data.cpu().numpy()
param_file = path + '-' + param_name
np.save(param_file, weights)
print("Saved ", param_name, " t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_npz(save_dict={}, name='model.npz'):\n rename_dict = {}\n for k, value in enumerate(save_dict):\n rename_dict.update({'param'+str(k) : value.eval()})\n np.savez(name, **rename_dict)\n print('Model is saved to: %s' % name)",
"def write_model_data(model, filename):\n data = lasagne.l... | [
"0.6429143",
"0.6404704",
"0.63632673",
"0.62855244",
"0.62813056",
"0.626273",
"0.61921954",
"0.6184623",
"0.61819017",
"0.6157497",
"0.6152439",
"0.6134694",
"0.61051977",
"0.61004263",
"0.60838217",
"0.60781217",
"0.6074281",
"0.6062155",
"0.60577714",
"0.6029765",
"0.6021... | 0.7250374 | 0 |
Selects the face contour depending on the reletive position of the head | def _find_dynamic_lmk_idx_and_bcoords(self, pose, dynamic_lmk_faces_idx, dynamic_lmk_b_coords, neck_kin_chain, dtype=torch.float32):
batch_size = pose.shape[0]
aa_pose = torch.index_select(pose.view(batch_size, -1, 3), 1, neck_kin_chain)
rot_mats = batch_rodrigues(aa_pose.view(-1, 3), dtype=dtyp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_face_landmarks(data):\n head = extract_head(data);\n landmarks = data['position_data']['face_landmarks'][data['i']];\n face_box = data['position_data']['face_box'][data['i']];\n if face_box is not None:\n for p in landmarks:\n cv2.circle(head,p,3,(255,0,0));\n else:\n ... | [
"0.60513896",
"0.5932689",
"0.58093935",
"0.5794264",
"0.5766186",
"0.5747199",
"0.56914675",
"0.56844455",
"0.5642587",
"0.56204265",
"0.5604524",
"0.5601304",
"0.55593044",
"0.55521274",
"0.55410874",
"0.55376166",
"0.5506842",
"0.54978096",
"0.545237",
"0.54374015",
"0.543... | 0.0 | -1 |
Transform a keypoint into gaussian like representation | def kp2gaussian(kp, spatial_size, kp_variance):
mean = kp['value']
coordinate_grid = make_coordinate_grid(spatial_size, mean.type())
number_of_leading_dimensions = len(mean.shape) - 1
shape = (1,) * number_of_leading_dimensions + coordinate_grid.shape
coordinate_grid = coordinate_grid.view(*shape)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(centre, k, intensity, xpos):\r\n\treturn intensity * np.exp(- np.power(k * (xpos - centre), 2))",
"def gaussian(mu, wid, x):\n return np.exp(-((x - mu) / (0.6005612 * wid))**2)",
"def gaussian_k(x0, y0, sigma, height, width):\n y = np.arange(0, width, 1, float)\n x = np.arange(0, height, ... | [
"0.6592707",
"0.6404964",
"0.62782484",
"0.62487584",
"0.6217355",
"0.6187855",
"0.6172046",
"0.61688614",
"0.6123739",
"0.6010845",
"0.59409523",
"0.59193027",
"0.5917914",
"0.5880607",
"0.5863034",
"0.585642",
"0.5829372",
"0.58065814",
"0.58054405",
"0.5803235",
"0.5793031... | 0.6513649 | 1 |
Contextual attention layer implementation. | def forward(self, f, b, mask):
raw_int_fs = list(f.size())
raw_int_bs = list(b.size())
kernel = 2 * self.rate
raw_w = extract_image_patches(b, ksizes=[kernel, kernel], strides=[self.rate * self.stride, self.rate * self.stride], rates=[1, 1], padding='same')
raw_w = raw_w.view(raw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, encoder_state, context, context_lens):\n attn = self.attention(context, encoder_state.squeeze(0), context_lens)\n return attn",
"def _Attention(self, name, is_causal=True):\n p = self.params\n tr_atten_p = TransformerAttentionLayer.Params().Set(\n name='transformer_at... | [
"0.7302596",
"0.70033437",
"0.6519189",
"0.65044045",
"0.6473802",
"0.6447233",
"0.6391859",
"0.63718355",
"0.62860805",
"0.6249749",
"0.62475526",
"0.6188868",
"0.6185548",
"0.61709875",
"0.61514854",
"0.61309737",
"0.6128917",
"0.60853946",
"0.60835904",
"0.6078229",
"0.604... | 0.0 | -1 |
Read image from the giving path. Default value is grayscale, and image is read by YCbCr format as the paper. | def imread(path, is_grayscale=True):
if is_grayscale:
return imageio.imread(path, as_gray=True, pilmode='YCbCr').astype(np.float32)
else:
return imageio.imread(path, pilmode='YCbCr').astype(np.float32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imread(path, is_grayscale=True):\n if is_grayscale:\n #flatten=True 以灰度图的形式读取 \n return scipy.misc.imread(path, flatten=True, mode='YCbCr').astype(np.float)\n else:\n return scipy.misc.imread(path, mode='YCbCr').astype(np.float)",
"def imread(path, is_grayscale=True):\n if is_grayscale:\n retu... | [
"0.759326",
"0.7581001",
"0.75307614",
"0.74117774",
"0.7376011",
"0.73754233",
"0.7256798",
"0.7143725",
"0.7053511",
"0.70276254",
"0.7025315",
"0.69861597",
"0.6949372",
"0.68321115",
"0.68203723",
"0.68118256",
"0.68032616",
"0.6803125",
"0.6729134",
"0.6723671",
"0.66796... | 0.7459921 | 3 |
This function comments on the most recent post in the bot's feed. Returns the comment's ID on success or False on failure or if is not a string | def comment_on_last_post(comment):
if type(comment) != str:
logger.error(LOG_INVALID_VARIABLES_STR)
return False
comment_id = graph.put_comment(object_id=get_last_post()["id"], message=comment)["id"]
logger.info(LOG_COMMENT_SUCCESS.format(comment_id))
return comment_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment_on_post_id(comment, obj_id):\n\n if type(comment) != str or type(obj_id) != str:\n logger.error(LOG_INVALID_VARIABLES_STR)\n return False\n\n # Success! Log and return the post id\n comment_id = graph.put_comment(object_id=obj_id, message=comment)[\"id\"]\n logging.info(LOG_CO... | [
"0.6326516",
"0.5962932",
"0.58834267",
"0.5823242",
"0.5802593",
"0.5778034",
"0.5733312",
"0.5721383",
"0.56242657",
"0.5614177",
"0.5587503",
"0.5584368",
"0.5573611",
"0.55722773",
"0.5546959",
"0.55101776",
"0.5504145",
"0.5498484",
"0.5489353",
"0.5469229",
"0.54594797"... | 0.75101966 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
print('Confusion matrix, without normalization')
print(cm)
plt.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.7893862 | 30 |
Convert pydantic object to pandas dataframe with 1 row. | def to_df(self):
return pd.DataFrame([dict(self)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_df(self):\r\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n from ..df import DataFrame\n\n return DataFrame(self)",
"def pandas_convert(self):\n data = {}\n\n for names in self.data[0]:\n col_values = []\n\n if names in objects:\n ... | [
"0.7579772",
"0.7208269",
"0.7193753",
"0.71868104",
"0.7147646",
"0.71019787",
"0.70991975",
"0.70454514",
"0.6980722",
"0.69795847",
"0.69795847",
"0.6948011",
"0.69058794",
"0.6863359",
"0.6824685",
"0.6816394",
"0.6778083",
"0.67714864",
"0.67522967",
"0.6737739",
"0.6724... | 0.7535765 | 2 |
Returns a dict of what bags go in each bag. | def get_rules(data: List[str]) -> Dict[str, Dict[str, int]]:
contains_split = re.compile(r"bags?.?$")
bags = {}
for line in data:
color, contains = line.split(" bags contain ")
if not contains == "no other bags.":
contains = [contains_split.sub("", item).strip() for item in cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sub_bags(self) -> List[Bag]:\n return [Bag(name, amount) for name, amount in self.rules[self.name].items()]",
"def get_bag_count(self):\n # b.get_bag_count() + 1 because get_bag_count does not count itself\n # A bag does not contain itself for our purposes.\n return sum([(b.get_b... | [
"0.67890984",
"0.6678691",
"0.6371466",
"0.63347965",
"0.63120705",
"0.6058451",
"0.6048966",
"0.5971175",
"0.5963874",
"0.59519297",
"0.586754",
"0.5815801",
"0.57934326",
"0.575948",
"0.5739669",
"0.5729089",
"0.5720046",
"0.5672005",
"0.5638437",
"0.56010246",
"0.5598568",... | 0.61894256 | 5 |
Checks if the bag contains a certain color. | def contains_color(self, target: str = "shiny gold") -> bool:
for bag in self.bags:
if bag.name == target or bag.contains_color(target):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasColor(self, color):\n if type(color) is not int:\n raise TypeError( \"Color must be of type int.\" )\n else:\n return color in self.__colordict__",
"def isColor(self,color):\n return self.color==color",
"def validColor(color):\n if color not in (RED, GREEN, ... | [
"0.73525834",
"0.7234019",
"0.6699411",
"0.65781164",
"0.6562159",
"0.6510248",
"0.6482259",
"0.646352",
"0.6445873",
"0.64203286",
"0.63757193",
"0.6364761",
"0.63629025",
"0.63452584",
"0.633092",
"0.6325876",
"0.6309591",
"0.62997097",
"0.6285915",
"0.6266769",
"0.625346",... | 0.77066606 | 0 |
Returns onehot encoded Variable | def to_categorical(y, num_columns):
y_cat = torch.zeros((y.shape[0], num_columns))
y_cat[range(y.shape[0]), y] = 1.0
y_cat = y_cat.view(y.shape[0], num_columns, 1, 1)
y_cat = y_cat.to(device)
return y_cat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output",
"def one_hot_encode(x, n_classes):\n return np.eye(n_classes)[x]",
"def one_hot(y_):\n y_ = y_.reshape(len(y_))\n ... | [
"0.8121293",
"0.80437994",
"0.80373216",
"0.79746693",
"0.79646856",
"0.79440534",
"0.79381895",
"0.79274017",
"0.78687656",
"0.78521234",
"0.78004986",
"0.77972883",
"0.778436",
"0.77638763",
"0.77571285",
"0.7745554",
"0.7730836",
"0.77264756",
"0.77055925",
"0.77040774",
"... | 0.0 | -1 |
Returns a boolean indication to say if the referenced name/bucket is associated with the control panel app. They either start with the name "alphaapp" or they have a tag of "buckettype" with the value "datawarehouse". | def is_control_panel_bucket(name, bucket):
is_valid = name.startswith("alpha-app-")
if name.startswith("dev-"):
# Ignore this since it's a bucket associated with the dev instance.
is_valid = False
elif not is_valid:
try:
tags = bucket.Tagging()
tags.load()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_app_applied(dbapi, app_name):\n try:\n return dbapi.kube_app_get(app_name).active\n except exception.KubeAppNotFound:\n return False",
"def _check_study_app_request(context):\n # NOTE: This assumes 'scopes' was overwritten by get_context_data.\n scopes = [x[0] for x in co... | [
"0.64779985",
"0.599591",
"0.5898966",
"0.5505324",
"0.5389059",
"0.5259245",
"0.5259243",
"0.52116805",
"0.52116454",
"0.51701826",
"0.516845",
"0.51443183",
"0.5138428",
"0.5127226",
"0.51114357",
"0.5110896",
"0.50997066",
"0.50929403",
"0.5088065",
"0.507274",
"0.5061695"... | 0.73639214 | 0 |
Takes in a table name and checks if that table exists in BigQuery. | def does_table_exist(table_name):
result = call_bq(
['show', table_name], project='khan-academy', raise_exception=False)
if "Not found: Table" in result:
return False
else:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _TableExists(dataset_id, table_id, project_id):\n client = GetApiClient()\n service = client.tables\n get_request_type = GetApiMessage('BigqueryTablesGetRequest')\n get_request = get_request_type(datasetId=dataset_id, tableId=table_id,\n projectId=project_id)\n try:\n se... | [
"0.77273595",
"0.75567347",
"0.7483804",
"0.735529",
"0.735026",
"0.7322221",
"0.73100245",
"0.73099047",
"0.7270977",
"0.72513354",
"0.72427255",
"0.7219763",
"0.71754146",
"0.7160873",
"0.7156353",
"0.7117777",
"0.710644",
"0.70882595",
"0.7084261",
"0.70666826",
"0.7015083... | 0.84100085 | 0 |
Pad list of sentence according to the longest sentence in the batch. | def pad_sents(sents, pad_token):
MAX_LEN = max([len(sent) for sent in sents])
sents_padded = [sent[:] for sent in sents]
for sent in sents_padded:
if len(sent) < MAX_LEN:
sent += [pad_token]*(MAX_LEN - len(sent))
return sents_padded | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_sentence_batch(sentence_batch):\n max_sentence = max([len(sentence) for sentence in sentence_batch])\n return [sentence + [CODES['<PAD>']] * (max_sentence - len(sentence))\n for sentence in sentence_batch]",
"def pad_sentence_batch(sentence_batch):\r\n max_sentence = max([len(sentence... | [
"0.82801026",
"0.8021309",
"0.774206",
"0.77089113",
"0.7647809",
"0.75435805",
"0.74933594",
"0.7448544",
"0.7407473",
"0.74066424",
"0.73821384",
"0.73703057",
"0.72982824",
"0.7255713",
"0.7246784",
"0.7176892",
"0.7124899",
"0.7070855",
"0.6977589",
"0.69090223",
"0.68699... | 0.67936486 | 22 |
Normalize the vector x in the L2 norm | def normalize_l2(x):
return x / (npla.norm(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def L2_normalize(xx):\r\n\tZx = compute_L2_normalization(xx)\r\n\treturn xx / np.sqrt(Zx[:, np.newaxis])",
"def L2_norm(x, axis=-1):\n return keras.backend.l2_normalize(x, axis=axis)",
"def _l2_normalize(x, axis=None, eps=1e-12):\n return x * jax.lax.rsqrt((x * x).sum(axis=axis, keepdims=True) + eps)",
"... | [
"0.8213796",
"0.8163298",
"0.80987704",
"0.80160016",
"0.7960478",
"0.77546084",
"0.7745933",
"0.7716235",
"0.7662777",
"0.7647724",
"0.7625953",
"0.7582813",
"0.7543614",
"0.75356215",
"0.7526656",
"0.75264484",
"0.7518853",
"0.75015867",
"0.74921685",
"0.747322",
"0.7470747... | 0.8975376 | 0 |
Compute the elementwise softmax of two vectors | def softmax(a,c):
assert(np.shape(a) == np.shape(c))
return np.multiply(np.sign(a) , np.maximum(np.absolute(a) - c, np.zeros(np.shape(a)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(x):\r\n e_x = np.exp(x - np.max(x))\r\n return e_x / e_x.sum(axis=0) # only difference\r",
"def softmax(x):\r\n e_x = np.exp(x - np.expand_dims(np.max(x, axis=-1), axis=-1))\r\n return e_x / np.expand_dims(e_x.sum(axis=-1), axis=-1) # only difference\r",
"def softmax(x):\n e_x = np.e... | [
"0.73953474",
"0.73872066",
"0.7354362",
"0.7354362",
"0.7354362",
"0.7354362",
"0.73020005",
"0.7268082",
"0.725536",
"0.72447383",
"0.72356087",
"0.7209264",
"0.71982235",
"0.7163661",
"0.7157907",
"0.71534014",
"0.71534014",
"0.71534014",
"0.71534014",
"0.71534014",
"0.715... | 0.6896534 | 94 |
Compute the penalized matrix fact_inporization of X. Finds set of U vectors and V vectors such that || X duv.t ||_F is minimized ||u||2 <= 1, ||v||2 <= 1 ||u||1 <= c1, ||v||1 <= c2 In other words, subject to some sparsity and norm constraints, we should have that the sum over i of (d_i u_i v_i.T) is close to X. | def compute_pmf(X_inp, rank, c1, c2):
X_arr = []
u_arr = []
v_arr = []
d_arr = []
X = deepcopy(X_inp)
v_init = np.ones((np.shape(X)[1],1))
for i in range(rank):
X_arr.append(X)
(d,u,v) = compute_factor(X, v_init, c1, c2)
assert abs(npla.norm(u) - 1 ) < 1e-3
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_cov_x(infodic,p):\n\n fjac = infodic['fjac']\n ipvt = infodic['ipvt']\n n = len(p)\n\n # adapted from leastsq function in scipy/optimize/minpack.py\n perm = np.take(np.eye(n),ipvt-1,0)\n r = np.triu(np.transpose(fjac)[:n,:])\n R = np.dot(r,perm)\n try:\n cov_x = np.linalg.in... | [
"0.5395546",
"0.52047133",
"0.5168139",
"0.5142269",
"0.50308293",
"0.5029573",
"0.5020289",
"0.5012972",
"0.49773479",
"0.49512708",
"0.4937035",
"0.49365556",
"0.49303326",
"0.49189627",
"0.49149948",
"0.48658383",
"0.48615623",
"0.485038",
"0.48483074",
"0.48355833",
"0.48... | 0.4621216 | 53 |
Takes image and mask as input and returns image with mask contours | def Predict_Image_Contours(img, mask_full, feature_dict, filename = None, path = ''):
for ii in range(len(feature_dict)):
Type = feature_dict[str(ii)] ## So first key is 1
if Type=='modern_build':
color_rgb = (255,0,0)
elif Type=='trad_build':
color_rgb = (0,0,255)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_mask_to_image(img, mask):\n img_size = img.shape[0]\n mask = cv2.resize(mask, dsize=(img_size, img_size))\n\n # Find contour of the mask\n imgray = mask\n ret,thresh = cv2.threshold(imgray, 127, 255, 0)\n contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIM... | [
"0.75970256",
"0.74997854",
"0.7430567",
"0.7351365",
"0.6825531",
"0.68030775",
"0.6727694",
"0.668699",
"0.6645335",
"0.66421235",
"0.6562039",
"0.6497408",
"0.6496671",
"0.64471096",
"0.6376893",
"0.63608044",
"0.6341518",
"0.6332149",
"0.6313721",
"0.63050985",
"0.6305063... | 0.5729307 | 70 |
Initialise a GMail notifier object. Prompt the user to authenticate and provide mailing permissions if required. | def __init__(self, address):
self.address = address
self.creds = None
# if there's an access token from previous authentication, load it
if os.path.exists(ACCESS_TOKEN_PATH):
with open(ACCESS_TOKEN_PATH, 'rb') as tokenfile:
self.creds = pickle.load(tokenfile)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_startup():\n imap = imaplib.IMAP4_SSL('imap.gmail.com')\n # authenticate\n imap.login(email_credentials.email_user, email_credentials.email_pass)\n return imap",
"def __init__(self, user, password, _recipients, templatedir='templates'):\n\n self.user = user\n self.password = p... | [
"0.71742123",
"0.63861555",
"0.6319666",
"0.6195784",
"0.6136228",
"0.61343366",
"0.602035",
"0.5795834",
"0.5761681",
"0.5761283",
"0.57289636",
"0.56912637",
"0.56397784",
"0.5634498",
"0.5626155",
"0.5565247",
"0.55646455",
"0.5561519",
"0.5540531",
"0.5538235",
"0.5505637... | 0.5880532 | 7 |
Given kwargs of sequences, enumerate_kwarg_dict generates every combination of the kwargs values provided, yielding a dict of the kwargs as keys. | def enumerate_kwarg_dict(**kwargs):
keys = []
lens = []
for key in kwargs:
keys.append(key)
lens.append(len(kwargs[key]))
for ndind in np.ndindex(*lens):
nowdict = dict()
for ind, key in zip(ndind, keys):
nowdict[key] = kwargs[key][ind]
yield nowdict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dicts_product(**kwargs):\n keys = kwargs.keys()\n vals = kwargs.values()\n for instance in itertools.product(*vals):\n yield dict(zip(keys, instance))",
"def product_dict(**kwargs):\n keys = kwargs.keys()\n vals = kwargs.values()\n\n product = []\n for item in itertools.product(*v... | [
"0.66215783",
"0.65075207",
"0.62692845",
"0.62031484",
"0.60535663",
"0.60165465",
"0.59008527",
"0.5836615",
"0.57660544",
"0.5740573",
"0.5639123",
"0.56280446",
"0.5624082",
"0.5586988",
"0.5542501",
"0.5535488",
"0.5508857",
"0.5505142",
"0.54689133",
"0.5418922",
"0.541... | 0.8559462 | 0 |
Splitting the X ndarray into the X_train and X_test data | def test_train_split(model, X, y, test_size=.1, random_state=42, metric=None):
random.seed(random_state)
rows = random.sample(range(len(X)), int(test_size * len(X)))
X_train, y_train = X[[row for row in range(len(X)) if not (row in rows)], :], y[[row for row in range(len(y)) if
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_data(self):\n X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=7)\n\n return X_train, X_test, y_train, y_test",
"def split_data(X:np.ndarray, y:np.ndarray) -> (np.ndarray, np.ndarray, np.ndarray, np.ndarray):\n \n X_train, X_val, y_train, y_val = train_test_spl... | [
"0.8028402",
"0.7793232",
"0.760009",
"0.7510908",
"0.74605054",
"0.7359983",
"0.7322339",
"0.73036546",
"0.7303015",
"0.7259285",
"0.7255058",
"0.71327686",
"0.7132494",
"0.71225715",
"0.7121363",
"0.7090068",
"0.70635617",
"0.70362186",
"0.70244145",
"0.7022647",
"0.6954202... | 0.0 | -1 |
Load the network weights and biases | def load_networks(self, dir_weights, idx_load):
path_p = dir_weights + 'p_{}.ckpt'
path_D = dir_weights + 'D_{}.ckpt'
path_U = dir_weights + 'U_{}.ckpt'
self.net_p.load_weights(path_p.format(idx_load))
self.net_D.load_weights(path_D.format(idx_load))
self.net_U.load_wei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()",
"def load_nn(self, filename):\n self.weights_and_biases = (np.load(filename, allow_pickle=... | [
"0.81352437",
"0.77744836",
"0.7531094",
"0.74200773",
"0.7331382",
"0.7321973",
"0.713008",
"0.7061271",
"0.70502347",
"0.7045512",
"0.7014477",
"0.7014477",
"0.69948256",
"0.69532",
"0.69512",
"0.6946497",
"0.69441706",
"0.6937924",
"0.6899497",
"0.689469",
"0.6844235",
"... | 0.7623774 | 2 |
Securely hash a password using a provided salt | def hash_password(password, salt):
password = str(password).encode('utf-8')
salt = str(salt).encode('utf-8')
return hashlib.sha512(password + salt).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_pass(password, salt):\n return hashlib.pbkdf2_hmac('sha512', password.encode(), salt, 100000)",
"def encrypt_password(password, salt):\n\n if isinstance(password, str):\n password_bytes = password.encode(\"UTF-8\")\n else:\n password_bytes = password\n\n hashed_password = sha25... | [
"0.7692427",
"0.74144167",
"0.7296053",
"0.72924256",
"0.72908473",
"0.7286055",
"0.72522134",
"0.7242838",
"0.72303313",
"0.7101504",
"0.70916915",
"0.7064012",
"0.7042825",
"0.7042825",
"0.7042825",
"0.70355195",
"0.7021024",
"0.6947296",
"0.6919233",
"0.691473",
"0.6912665... | 0.7817522 | 0 |
Provide helpful representation when printing. | def __repr__(self):
return f'<Human human_id={self.human_id} email={self.email}>' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def __str__(self):\n return self.printable()",
"def __repr__(self):\n s = ''\n for attr in self.__dict__:\n val = pformat(self.__dict__[attr])[:1500]\n if len(val)>70:\n s+=f'\\n{at... | [
"0.76575935",
"0.7606807",
"0.74774486",
"0.7351439",
"0.734988",
"0.7327919",
"0.73275",
"0.73121685",
"0.73121685",
"0.7305257",
"0.7292606",
"0.7273153",
"0.7269981",
"0.7268578",
"0.7256028",
"0.72502035",
"0.72048515",
"0.7179483",
"0.71617794",
"0.71582687",
"0.7155405"... | 0.0 | -1 |
Provide helpful representation when printing. | def __repr__(self):
# Sometimes, to avoid messy concatenation, it's ok to have your string
# go past the 80-charcter line limit
return f'<Animal animal_id={self.animal_id} name={self.name}> animal_species={self.animal_species}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def __str__(self):\n return self.printable()",
"def __repr__(self):\n s = ''\n for attr in self.__dict__:\n val = pformat(self.__dict__[attr])[:1500]\n if len(val)>70:\n s+=f'\\n{at... | [
"0.7658144",
"0.7607513",
"0.7478154",
"0.7352044",
"0.73506075",
"0.7328598",
"0.73283577",
"0.73120356",
"0.73120356",
"0.7306207",
"0.7292816",
"0.72734815",
"0.72702235",
"0.7269387",
"0.7256873",
"0.7250844",
"0.72050035",
"0.7179941",
"0.71619093",
"0.7158537",
"0.71563... | 0.0 | -1 |
Test the `llvm_strip` property of the | def test_llvm_strip(self):
self.assertEqual(
self.ndk.llvm_strip,
f"/opt/android/android-ndk/toolchains/llvm/prebuilt/{self.ndk.host_tag}/bin/llvm-strip",
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lstrip(self) -> String:\n pass",
"def rstrip(self) -> String:\n pass",
"def test_llvm_readelf(self):\n self.assertEqual(\n self.ndk.llvm_readelf,\n f\"/opt/android/android-ndk/toolchains/llvm/prebuilt/{self.ndk.host_tag}/bin/llvm-readelf\",\n )",
"def test_strip_... | [
"0.5925448",
"0.56708527",
"0.5625955",
"0.54900813",
"0.5342901",
"0.51844054",
"0.51297843",
"0.512715",
"0.51190764",
"0.5106026",
"0.50734746",
"0.5065017",
"0.50459456",
"0.50071377",
"0.49844846",
"0.49797246",
"0.49778157",
"0.4964041",
"0.49617007",
"0.4943957",
"0.49... | 0.80540067 | 0 |
Validate string for URL | def check_url(url):
regex = re.compile(
r'^https?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsValidURL(s):\n return RE_COMPLEX_URL.match(s)",
"def _validate_url(url):\n if not url or url.count('/') != 1 or url[0] != '@':\n return False\n return True",
"def validate_url(self):\n pass",
"def check_url(value):\n\n valid = validators.url(value)\n if valid != T... | [
"0.81274974",
"0.8093377",
"0.8030946",
"0.79925084",
"0.7951957",
"0.77946264",
"0.77573943",
"0.7750517",
"0.7745736",
"0.76155764",
"0.75947946",
"0.75857884",
"0.7584491",
"0.75569296",
"0.7550756",
"0.7550357",
"0.75485814",
"0.7540168",
"0.75382155",
"0.74994075",
"0.74... | 0.7379112 | 26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.