query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Called when a connection is made. Sets attributes ``_transport``, ``_when_connected``, ``_last_received``, ``reader`` and ``writer``. Ensure ``super().connection_made(transport)`` is called when derived. | def connection_made(self, transport):
self._transport = transport
self._when_connected = datetime.datetime.now()
self._last_received = datetime.datetime.now()
reader_factory = self._reader_factory
writer_factory = self._writer_factory
reader_kwds = {}
writer_kwds... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection_made(self, transport: BaseTransport) -> None:\n self.transport = transport",
"def connection_made(self, transport):\n print('Connection Made')\n self.transport = transport",
"def connection_made(self, transport):\n self.transport = transport\n self.on_connected... | [
"0.7746852",
"0.77213734",
"0.76538384",
"0.7543223",
"0.7519254",
"0.71371055",
"0.7102876",
"0.71006286",
"0.69904965",
"0.6950871",
"0.69351697",
"0.690995",
"0.66259885",
"0.66192645",
"0.65338343",
"0.6512166",
"0.6494174",
"0.644675",
"0.6437705",
"0.60995424",
"0.60450... | 0.8196434 | 0 |
Time elapsed since client connected, in seconds as float. | def duration(self):
return (datetime.datetime.now() - self._when_connected).total_seconds() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed_time_in_seconds(self):\n return self._elapsed_time_in_seconds",
"def duration(self):\n if self._connected:\n return (datetime.datetime.now() - self._connected).total_seconds()\n return float('inf')",
"def duration(self) -> float:\n return time.time() - self.co... | [
"0.7489594",
"0.74188197",
"0.7321411",
"0.7258974",
"0.7157413",
"0.7114975",
"0.7096659",
"0.7065171",
"0.70002097",
"0.69881487",
"0.6917328",
"0.6911001",
"0.69096434",
"0.6845181",
"0.6840852",
"0.68355215",
"0.6788002",
"0.67572224",
"0.67431957",
"0.6735307",
"0.673407... | 0.75461715 | 0 |
Begin advanced negotiation. Callback method further requests advanced telnet options. Called once on receipt of any ``DO`` or ``WILL`` acknowledgments received, indicating that the remote end is capable of negotiating further. | def begin_advanced_negotiation(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def begin_negotiation(self):\n if self._closing:\n self.waiter_connected.cancel()\n return\n\n self._loop.call_soon(self.check_negotiation)",
"def negotiation_should_advance(self):\n # Generally, this separates a bare TCP connect() from a True\n # RFC-compliant t... | [
"0.59198445",
"0.57896835",
"0.5568085",
"0.55480313",
"0.5160394",
"0.503215",
"0.4938892",
"0.48619843",
"0.47623533",
"0.4716586",
"0.47029376",
"0.46880955",
"0.46534738",
"0.46363252",
"0.4619564",
"0.46188635",
"0.46145657",
"0.45824525",
"0.45603034",
"0.455962",
"0.45... | 0.67340714 | 0 |
Encoding that should be used for the direction indicated. The base implementation always returns the encoding given to class initializer, or, when unset (None), ``USASCII``. | def encoding(self, outgoing=False, incoming=False):
# pylint: disable=unused-argument
return self.default_encoding or "US-ASCII" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encoding(self, outgoing=False, incoming=False):\n assert outgoing or incoming\n return (self.env.get('CHARSET', self._default_encoding)\n if (outgoing and not incoming and self.outbinary) or (\n not outgoing and incoming and self.inbinary) or (\n ... | [
"0.6991464",
"0.69778",
"0.6884511",
"0.6861322",
"0.6802753",
"0.6802753",
"0.6802753",
"0.6802753",
"0.6790363",
"0.6737713",
"0.6689147",
"0.6489467",
"0.6467056",
"0.6440495",
"0.6418696",
"0.6411266",
"0.63548106",
"0.6142244",
"0.61268723",
"0.6124121",
"0.60555106",
... | 0.7481137 | 0 |
Whether advanced negotiation should commence. | def negotiation_should_advance(self):
# Generally, this separates a bare TCP connect() from a True
# RFC-compliant telnet client with responding IAC interpreter.
server_do = sum(enabled for _, enabled in self.writer.remote_option.items())
client_will = sum(enabled for _, enabled in self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_negotiation(self, final=False):\n if not self._advanced and self.negotiation_should_advance():\n self._advanced = True\n logger.debug(\"begin advanced negotiation\")\n asyncio.get_event_loop().call_soon(self.begin_advanced_negotiation)\n\n # negotiation is c... | [
"0.69260913",
"0.67120564",
"0.58638775",
"0.5733265",
"0.5602215",
"0.5586874",
"0.55329067",
"0.55127007",
"0.54190314",
"0.5394952",
"0.53668785",
"0.5343635",
"0.52741605",
"0.52627194",
"0.5261908",
"0.5255557",
"0.5226124",
"0.52245325",
"0.5219944",
"0.51779395",
"0.51... | 0.72975564 | 0 |
Callback, return whether negotiation is complete. | def check_negotiation(self, final=False):
if not self._advanced and self.negotiation_should_advance():
self._advanced = True
logger.debug("begin advanced negotiation")
asyncio.get_event_loop().call_soon(self.begin_advanced_negotiation)
# negotiation is complete (retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_negotiation(self):\n if self._closing:\n self.waiter_connected.cancel()\n return\n pots = self.stream.pending_option\n if not any(pots.values()):\n if self.duration > self.CONNECT_MINWAIT:\n # the number of seconds since connection has ... | [
"0.6801442",
"0.6568575",
"0.61798817",
"0.60798776",
"0.60071146",
"0.59360796",
"0.56638616",
"0.5614649",
"0.5547745",
"0.5415259",
"0.54142064",
"0.54036856",
"0.53632724",
"0.535246",
"0.5343512",
"0.53294545",
"0.5275654",
"0.52629775",
"0.52530646",
"0.522893",
"0.5228... | 0.69614357 | 0 |
Creates a new database from scratch loading the info from datalog.csv and extracts info from the each session's .tdms file If a preexisting database is passed it will add the sessions not already present | def create_database(excelpath, database=None):
def generate_database_from_metadatas(metadata_dict, stimulus_dict):
"""
Given a dictionary of session objects with their metadata creates a new database
with all the sessions in the database and the associated metadata
"""
# Cre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_db_setup() -> None:\n db_filename = \"twdft.db\"\n db_path = os.path.join(TWDFT_DATA_DIR, db_filename)\n csv_filename = \"sites.csv\"\n csv_path = os.path.join(TWDFT_DATA_DIR, csv_filename)\n db_is_new = not os.path.exists(db_path)\n sites_csv = os.path.join(TWDFT_DATA_DIR, csv_filena... | [
"0.623949",
"0.6126668",
"0.6094227",
"0.6067609",
"0.6060192",
"0.6055851",
"0.6054817",
"0.6004642",
"0.5970945",
"0.5953632",
"0.5857623",
"0.58563125",
"0.58413136",
"0.5826197",
"0.57636046",
"0.5752786",
"0.5735318",
"0.5718436",
"0.5713309",
"0.57069284",
"0.5704334",
... | 0.6542749 | 0 |
Given a dictionary of session objects with their metadata creates a new database with all the sessions in the database and the associated metadata | def generate_database_from_metadatas(metadata_dict, stimulus_dict):
# Create empty database from template class
indexes = sorted(metadata_dict.keys())
database = pd.DataFrame(index=indexes, columns=['Number', 'Metadata', 'Tracking', 'Registration', 'Stimuli'])
# Fill in metadata from th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database_session_wide(app) -> SQLAlchemy:\n if os.path.exists(get_test_database_path()):\n os.unlink(get_test_database_path())\n\n from pipwatch_api.datastore.models import DATABASE\n DATABASE.init_app(app=app)\n DATABASE.create_all()\n yield DATABASE\n\n DATABASE.drop_all()\n DATAB... | [
"0.6652588",
"0.6618158",
"0.6533384",
"0.6390175",
"0.6344271",
"0.63380307",
"0.6321619",
"0.6237914",
"0.6227624",
"0.62212944",
"0.62153596",
"0.6207867",
"0.61359006",
"0.6103177",
"0.61003464",
"0.60975677",
"0.6092535",
"0.60867435",
"0.6059832",
"0.5968431",
"0.596832... | 0.6749462 | 0 |
loops over a list of dictionary with the info for each session and gets all the stimulus onset times | def get_stim_onset_times(sessions, metadata_dict):
if not isinstance(sessions, list):
sessions = list(sessions)
for line in sessions:
session_id = line['Sess.ID']
if session_id: # we loaded a line with session info
session_name = '{}_{}'.format(line[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTimes():",
"def getTimes():",
"def getTimes():",
"def get_times_from_sessions(sorting_man, sessions,\n sign='pos', skip_artifacts=True):\n return get_data_from_sessions(sorting_man, sessions,\n sign, ['times'], skip_artifacts)",
"def sta... | [
"0.65231055",
"0.65231055",
"0.65231055",
"0.6393931",
"0.6184825",
"0.6122553",
"0.59389263",
"0.59258145",
"0.5923464",
"0.5921139",
"0.5858588",
"0.58490074",
"0.5847726",
"0.58407706",
"0.578101",
"0.57597786",
"0.57564735",
"0.57446367",
"0.57149935",
"0.5639643",
"0.561... | 0.7422578 | 0 |
loops over a list of dictionary with the info for each session and gets all the metadata | def get_metadata(sessions):
if not isinstance(sessions, list):
sessions = list(sessions)
for line in sessions:
session_id = line['Sess.ID']
if session_id: # we loaded a line with session info
session_name = '{}_{}'.format(line['Experiment'], line['Se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metadata(session, url, filelist):\n metadata = {}\n # Loop over the Clowder dataset image ID list\n for clowder_img in filelist.json():\n # Get metadata for the image from Clowder\n response = clowder_file_metadata(session, url, clowder_img['id'])\n # Metadata from multiple ex... | [
"0.6214154",
"0.5921212",
"0.5755976",
"0.57426655",
"0.5742081",
"0.57078063",
"0.56998515",
"0.5668264",
"0.5618146",
"0.55938953",
"0.5592542",
"0.55439705",
"0.5542058",
"0.55399126",
"0.5531447",
"0.55264294",
"0.5500047",
"0.5478684",
"0.54766417",
"0.5467299",
"0.54621... | 0.743502 | 0 |
Change from date to month | def date_to_month(date):
return re.sub(r'(\d{4}-\d{2})-\d{2}', r'\1', date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_month(date):\n return date.month",
"def MONTH(date):\n return _make_datetime(date).month",
"def setMonth(self, *args):\n return _libsbml.Date_setMonth(self, *args)",
"def get_month(self, indate):\n return indate.strftime(\"%B\") + \"-\" + indate.strftime(\"%Y\")",
"def decrement_... | [
"0.77243966",
"0.735111",
"0.71769124",
"0.71729517",
"0.6849947",
"0.6843161",
"0.6707294",
"0.66655874",
"0.6617973",
"0.661158",
"0.6599854",
"0.6599854",
"0.65967923",
"0.6558509",
"0.65565616",
"0.65458804",
"0.6489243",
"0.64884037",
"0.63371634",
"0.63212645",
"0.63069... | 0.7433812 | 1 |
Get the function from Nearest interpolation for the oceanic age field | def _get_age_func(self) :
age_nc_Arr = self['age_nc_Arr'].value
age_lon_Vec = self['age_lon_Vec'].value
age_lat_Vec = self['age_lat_Vec'].value
xx, yy = np.meshgrid(age_lon_Vec, age_lat_Vec) # xx for longitude, yy for latitude
xx = xx.reshape(xx.size) #nearest
yy = yy.reshape(yy.size)
x = np.column_stack(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate_model(self, age):\n\n # easy exit:\n if (age < self.models[0].glb[iage]): return None\n if (age > self.models[-1].glb[iage]): return None\n\n istart = 0\n istop = len(self.models)-1\n while (istop > istart+1):\n itemp = (istop+istart)//2\n ... | [
"0.574289",
"0.56960344",
"0.5642655",
"0.54970354",
"0.5492774",
"0.54384196",
"0.5385632",
"0.5368975",
"0.53457355",
"0.53434247",
"0.53386706",
"0.5294346",
"0.5285072",
"0.52787054",
"0.52730745",
"0.5235761",
"0.5208889",
"0.52074367",
"0.5201311",
"0.51824677",
"0.5178... | 0.7788994 | 0 |
Calculate the age gradient vector on original age grid points | def _cal_age_grad(self):
age_nc_Arr = self['age_nc_Arr'].value
age_nc_Arr_msk = age_nc_Arr > 180.
age_lon_Vec = self['age_lon_Vec'].value
age_lat_Vec = self['age_lat_Vec'].value
deriv_lat, deriv_lon = np.gradient(age_nc_Arr, age_lat_Vec, age_lon_Vec)
msk_left = np.zeros(age_nc_Arr_msk.shape)
msk_right = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_age_grad(self,renew=False):\n\t\ttry:\n\t\t\tdriv_lat = self['deriv_lat'].value\n\t\t\tdriv_lon = self['deriv_lon'].value\n\t\t\tdriv_msk = self['deriv_msk'].value\n\t\texcept:\n\t\t\tself._cal_age_grad()\n\t\tderiv_lat = self['deriv_lat'].value\n\t\tderiv_lon = self['deriv_lon'].value\n\t\tderiv_msk = sel... | [
"0.691785",
"0.6275828",
"0.6222302",
"0.6183185",
"0.61593217",
"0.6157958",
"0.60830003",
"0.6068481",
"0.6031056",
"0.6023609",
"0.60083145",
"0.59959316",
"0.5975593",
"0.59573",
"0.5943804",
"0.5932758",
"0.5924193",
"0.58491886",
"0.58460766",
"0.5843713",
"0.58372456",... | 0.78362966 | 0 |
get the age gradient at each grid point | def get_age_grad(self,renew=False):
try:
driv_lat = self['deriv_lat'].value
driv_lon = self['deriv_lon'].value
driv_msk = self['deriv_msk'].value
except:
self._cal_age_grad()
deriv_lat = self['deriv_lat'].value
deriv_lon = self['deriv_lon'].value
deriv_msk = self['deriv_msk'].value
age_lon_Vec =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cal_age_grad(self):\n\t\tage_nc_Arr = self['age_nc_Arr'].value\n\t\tage_nc_Arr_msk = age_nc_Arr > 180.\n\t\tage_lon_Vec = self['age_lon_Vec'].value\n\t\tage_lat_Vec = self['age_lat_Vec'].value\n\t\tderiv_lat, deriv_lon = np.gradient(age_nc_Arr, age_lat_Vec, age_lon_Vec)\n\t\tmsk_left = np.zeros(age_nc_Arr_msk... | [
"0.7373884",
"0.6562875",
"0.6507039",
"0.6486442",
"0.64006454",
"0.6399949",
"0.6344714",
"0.6339418",
"0.6229573",
"0.62217957",
"0.6203564",
"0.62013716",
"0.6187462",
"0.6156918",
"0.61553365",
"0.6141594",
"0.6131156",
"0.60966295",
"0.60867345",
"0.6073759",
"0.6059024... | 0.6642174 | 1 |
Find the grid point on the result lat&lon grid that's closest to the given coordinates | def _find_nearest_grid(self,lon,lat,period):
group = self['%g_sec'%( period )]
lonArr = group['lonArr'].value
latArr = group['latArr'].value
diff_Arr = np.dstack((lonArr, latArr)) - np.array([lon, lat]) # 3-d array ( , ,2)
diff_Arr[:,:,0] = diff_Arr[:,:,0] * np.cos(lat/180.*np.pi)
dist_sq = np.sum(diff_Arr*... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_closest_pt(ref_lon, ref_lat, tlon, tlat):\n\n # compute great circle distance from location to model grid points\n dist = gc_dist(ref_lon, ref_lat, tlon, tlat)\n\n # find j index of closest grid point\n work = N.take(dist,N.argmin(dist,0),0).diagonal()\n jj = N.argsort(work)[0]\n\n # f... | [
"0.7869433",
"0.7670987",
"0.7409804",
"0.73985344",
"0.7375369",
"0.73174095",
"0.72477806",
"0.69265217",
"0.67355555",
"0.6684142",
"0.6669667",
"0.6652987",
"0.66368204",
"0.6624449",
"0.6617213",
"0.6610935",
"0.6608017",
"0.65666974",
"0.65532094",
"0.6545663",
"0.65198... | 0.76830816 | 1 |
Read Ye's agedependent phase velocity curve from his 2013 paper, Fig 3 | def read_curve_Ye(self, fname='./Curve_Ye.lst'):
try:
self.create_group(name='Curve_Ye')
except:
pass
group = self['Curve_Ye']
f = open(fname, 'r')
lines = f.readlines()
for line in lines:
try:
age, vel = line.strip().split()
arr = np.append(arr, np.array([[float(age.replace(',','')), float... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xycurves_read_y(self) -> float:\n return float(self.dss_obj.XYCurvesF(ctypes.c_int32(2), ctypes.c_double(0)))",
"def getETA():",
"def getETA():",
"def iv_curve(voc):\n \n set_mode(mode_cv) # set operation mode to CC\n time.sleep(.1)\n volt_step = voc\n while volt_step > 0.5:\n ... | [
"0.5792761",
"0.5689362",
"0.5689362",
"0.5598587",
"0.55810696",
"0.54435396",
"0.54211086",
"0.5395927",
"0.5359138",
"0.53488517",
"0.53426903",
"0.53074145",
"0.5297593",
"0.52945036",
"0.52914715",
"0.52900124",
"0.5276078",
"0.52596027",
"0.5259379",
"0.5245957",
"0.524... | 0.656235 | 0 |
Get basemap for plotting results | def _get_basemap(self, projection='lambert', geopolygons=None, resolution='i', bound=True, hillshade=False):
# fig=plt.figure(num=None, figsize=(12, 12), dpi=80, facecolor='w', edgecolor='k')
minlat = self.attrs['minlat']
maxlat = self.attrs['maxlat']
minlon = self.attrs['minlon']
maxlon = self.attrs['maxlon'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_basemap(self, projection='lambert', geopolygons=None, resolution='i'):\n # fig=plt.figure(num=None, figsize=(12, 12), dpi=80, facecolor='w', edgecolor='k')\n lat_centre = (self.maxlat+self.minlat)/2.0\n lon_centre = (self.maxlon+self.minlon)/2.0\n if projection=='merc':\n ... | [
"0.768583",
"0.67051417",
"0.66305643",
"0.66269356",
"0.6420326",
"0.63739675",
"0.6318919",
"0.6219537",
"0.6179917",
"0.6173425",
"0.61360645",
"0.6124757",
"0.6112975",
"0.6102493",
"0.60988593",
"0.60919696",
"0.6082849",
"0.6076129",
"0.6058652",
"0.6038709",
"0.6025106... | 0.75758696 | 1 |
Plot sedimentary thickness map | def plot_sed(self,period=6.,projection='lambert',geopolygons=None, showfig=True, vmin=0, vmax=None, hillshade=False):
if hillshade:
alpha = 0.5
else:
alpha =1.
m = self._get_basemap(projection=projection, geopolygons=geopolygons,hillshade=hillshade)
group = self['%g_sec'%( period )]
x, y = m(group['lonA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(sigma, strikes, dips):\n values, vectors = principal(sigma)\n sigma1, sigma2, sigma3 = vectors\n\n fig = plt.figure()\n ax = fig.add_subplot(111, projection='stereonet')\n plt.hold(True)\n ax.density_contourf(strikes, dips)\n #ax.pole(strikes, dips, 'b.')\n ax.line(sigma1[0],sigma1... | [
"0.63369995",
"0.61236846",
"0.6114349",
"0.6095849",
"0.60944027",
"0.6065564",
"0.60634726",
"0.5903474",
"0.5871973",
"0.58385426",
"0.5830472",
"0.58245665",
"0.581662",
"0.5804532",
"0.5801797",
"0.5794579",
"0.57639295",
"0.5746792",
"0.5691547",
"0.56898904",
"0.568783... | 0.6411703 | 0 |
Plot agedependent velocity map | def plot_age_vel(self, period=6., projection='lambert',geopolygons=None, showfig=True, vmin=None, vmax=None, sta=True, hillshade=False):
if hillshade:
alpha = 0.5
else:
alpha =1.
m = self._get_basemap(projection=projection, geopolygons=geopolygons,hillshade=hillshade)
group = self['%g_sec'%( period )]
x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_velocity(self):\n \n plt.figure(figsize=[2,6])\n plt.plot(self.velocity_model['vp'],self.velocity_model['depth'],'r',label='vp')\n plt.plot(self.velocity_model['vs'],self.velocity_model['depth'],'b',label='vs')\n\n plt.ylim(np.max(self.velocity_model['depth']),np.min(sel... | [
"0.70021725",
"0.65644425",
"0.654601",
"0.6497373",
"0.6178289",
"0.61547524",
"0.61532503",
"0.6071668",
"0.6066135",
"0.5938079",
"0.5922543",
"0.5911259",
"0.5875194",
"0.5851111",
"0.58128566",
"0.5808326",
"0.5806869",
"0.5797526",
"0.57773346",
"0.57172334",
"0.5687899... | 0.72254646 | 0 |
Plot the difference between tomography result and agedependent velocity map | def plot_diff(self, period=6., projection='lambert',geopolygons=None, showfig=True, vmin=None, vmax=None, sta=True, hillshade=False, pct=True):
group = self['%g_sec'%( period )]
age_vel = group['age_vel'].value
age_vel_msk = group['age_vel_msk'].value
tomo_data = group['tomo_data'].value
tomo_data_msk = group... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def velocity_map(self, output='test'):\n self.figure = figure(figsize=(10,3))\n self.axes = self.figure.gca() \n xWindowLim = (self.analyst.windowSize[0], self.analyst.windowSize[1])\n yWindowLim = (self.analyst.windowSize[2], self.analyst.windowSize[3])\n \n # Generate ... | [
"0.65208423",
"0.647963",
"0.6475825",
"0.6369093",
"0.63263804",
"0.6205774",
"0.6198295",
"0.61233115",
"0.6067947",
"0.6054253",
"0.6020657",
"0.60199803",
"0.60023",
"0.5966201",
"0.5963947",
"0.5959262",
"0.5952182",
"0.5901261",
"0.5888683",
"0.588114",
"0.58783644",
... | 0.6540563 | 0 |
Plot age derivative as vectors on the map vec_s the size of the vectors drawn on the map (length of plot width) sparse how sparse for drawing the vectors lon longitude of starting point on stream line, only works when streamline == True lat latitude of starting point on stream line, only works when streamline == True | def plot_age_deriv(self, period=6., vec_s=0.05, sparse=10, lon=232., lat=46., streamline=False, projection='lambert',geopolygons=None, showfig=True, vmin=None, vmax=None, sta=True, hillshade=False):
if hillshade:
alpha = 0.5
else:
alpha = 1.
group = self['%g_sec'%( period )]
deriv_lat_Arr = group['age_der... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_age_traj(self, period=6., lon=232., lat=46., N=30, streamline=False, vec=False, projection='lambert',geopolygons=None, showfig=True, vmin=None, vmax=None, sta=True, hillshade=False):\n\t\tif hillshade:\n\t\t\talpha = 0.5\n\t\telse:\n\t\t\talpha = 1.\n\t\tgroup = self['%g_sec'%( period )]\n\t\tage_Arr = gr... | [
"0.5908049",
"0.5506614",
"0.5383747",
"0.5346564",
"0.5323745",
"0.52370286",
"0.51830995",
"0.5181756",
"0.5127858",
"0.5122104",
"0.5091455",
"0.5085826",
"0.5079753",
"0.5042886",
"0.50355995",
"0.50293756",
"0.5007741",
"0.49756533",
"0.49617273",
"0.49609876",
"0.495422... | 0.7200851 | 0 |
Plot a trajectory of varying age based on a starting point lon, lat longitude & latitude of the starting point | def plot_age_traj(self, period=6., lon=232., lat=46., N=30, streamline=False, vec=False, projection='lambert',geopolygons=None, showfig=True, vmin=None, vmax=None, sta=True, hillshade=False):
if hillshade:
alpha = 0.5
else:
alpha = 1.
group = self['%g_sec'%( period )]
age_Arr = group['age_Arr'].value
ag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_single_trajectory(self):\n\n plt.plot(self.trip_centroids['lon'], self.trip_centroids['lat'], '-o')",
"def plot_trajectories_XYZ(t_start,t_stop):\n \n time, ankle_l_trajectory, ankle_r_trajectory,foot_l_contact,foot_r_contact,muscle_lh_activations, muscle_rh_activations,muscle_lh_forces,mus... | [
"0.67130643",
"0.65517485",
"0.6224497",
"0.6078203",
"0.6022338",
"0.59993726",
"0.5980043",
"0.5936171",
"0.5933869",
"0.5921403",
"0.5905096",
"0.58895224",
"0.5805531",
"0.57912093",
"0.5780577",
"0.57152444",
"0.56844264",
"0.56327474",
"0.5602548",
"0.55992043",
"0.5591... | 0.65716076 | 1 |
Sends status report to Slack for given operation. `done` is the count of successfully scraped/aggregated symbols `failed` is a list of symbol names that could not be scraped/aggregated | def send_report(done, failed, scraper, op="scrape"):
if done > 0:
msg_success = "👍 Successfully {}d {}".format(op, _symbol_str(done))
else:
msg_success = "No symbols where successfully scraped 😭"
if len(failed) > 0:
msg_fail = "⚠️️ Failed to {} {}: {}".format(op,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status():\n _request('worklog/status/')",
"def status(args):\n print('Yields HPC fleet \"{}\" status'.format(args))",
"def do_status(self, args):\n status = self._leet.job_status\n\n for job in self.finished_jobs:\n status.append({\"id\" : job.id,\n ... | [
"0.58444166",
"0.57056075",
"0.56257963",
"0.56198466",
"0.5551347",
"0.5489644",
"0.5458203",
"0.54325044",
"0.54281545",
"0.5385839",
"0.5376189",
"0.5369204",
"0.53362334",
"0.53180194",
"0.5302695",
"0.52896714",
"0.5284125",
"0.52820325",
"0.5270204",
"0.5268695",
"0.525... | 0.7662954 | 0 |
Count words in all files under INPUTS_PATH | def word_count():
word_counter = Counter()
# read files and count words
for file_path in Path(INPUTS_PATH).rglob("*"):
if file_path.is_file():
print(f"Processing input file: {file_path.as_posix()}")
word_counter += Counter(file_path.read_text().split())
# write the resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_words(filename):",
"def count_all_words(file_name):\n\n return len(separate_words(file_name))",
"def load_input(path):\n counts = defaultdict(int)\n if not os.path.exists(mode+'indices.p'):\n root = '/'.join(path.split('/')[0:-1])\n all_paths = [root+'/'+x for x in os.listdir(root)... | [
"0.8194428",
"0.77317137",
"0.741911",
"0.74173814",
"0.7133204",
"0.70941913",
"0.7048425",
"0.6957227",
"0.6880276",
"0.6853278",
"0.6809252",
"0.6798499",
"0.67847085",
"0.67829734",
"0.67795736",
"0.6779509",
"0.6753361",
"0.6688868",
"0.66835743",
"0.6672029",
"0.6659063... | 0.8237946 | 0 |
Ensure a member can leave a community | def test_leave_community(self):
url = '/api/v1/communities/3/leave_community/'
response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user3'))
self.assertEquals(status.HTTP_204_NO_CONTENT, response.status_code)
self.assertEqual(14, Member.objects.all().count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_leave_community_banned(self):\n url = '/api/v1/communities/5/leave_community/'\n\n response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user3'))\n self.assertEquals(status.HTTP_401_UNAUTHORIZED, response.status_code)\n\n self.assertEqual(15, Member.objects.all().count... | [
"0.755527",
"0.6848541",
"0.68042284",
"0.6512431",
"0.6444627",
"0.6382766",
"0.6282716",
"0.62807584",
"0.626154",
"0.61867917",
"0.6175655",
"0.6155387",
"0.6050245",
"0.6015117",
"0.6000263",
"0.59927756",
"0.5978494",
"0.597619",
"0.5971745",
"0.59683484",
"0.5955255",
... | 0.7604314 | 0 |
Ensure a banned member cannot leave a community | def test_leave_community_banned(self):
url = '/api/v1/communities/5/leave_community/'
response = self.client.post(url, HTTP_AUTHORIZATION=self.auth('user3'))
self.assertEquals(status.HTTP_401_UNAUTHORIZED, response.status_code)
self.assertEqual(15, Member.objects.all().count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cant_ban_user_from_community_if_member(self):\n user = make_user()\n headers = make_authentication_headers_for_user(user)\n\n other_user = make_user()\n community = make_community(creator=other_user, type='P')\n community_name = community.name\n\n user.join_commun... | [
"0.7482391",
"0.73174125",
"0.71301365",
"0.70725477",
"0.7006769",
"0.6890567",
"0.6749513",
"0.6619335",
"0.6447031",
"0.6412974",
"0.6375203",
"0.63603395",
"0.6315346",
"0.62225026",
"0.60823",
"0.60503536",
"0.59814376",
"0.5931603",
"0.5899643",
"0.58481574",
"0.5830799... | 0.74711186 | 1 |
Ensure an unauthenticated user cannot list memberships | def test_list_my_memberships_without_auth(self):
url = '/api/v1/communities/0/list_my_memberships/'
response = self.client.get(url)
self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_members_with_mod_rights_not_accepted(self):\n url = '/api/v1/communities/3/retrieve_members/'\n\n # Test before acceptation\n response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user2'))\n self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code)",
"... | [
"0.67897993",
"0.65733534",
"0.6546578",
"0.6515001",
"0.6474156",
"0.6451716",
"0.6421053",
"0.6411042",
"0.6399281",
"0.6391644",
"0.6373416",
"0.6317749",
"0.6316283",
"0.6315243",
"0.6303196",
"0.62909466",
"0.6274377",
"0.62658304",
"0.6185835",
"0.61791426",
"0.6175023"... | 0.67098165 | 1 |
Ensure a nonmember authenticated user cannot list community members | def test_list_members_without_member_rights(self):
url = '/api/v1/communities/3/retrieve_members/'
response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user4'))
self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_members_with_mod_rights_not_accepted(self):\n url = '/api/v1/communities/3/retrieve_members/'\n\n # Test before acceptation\n response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user2'))\n self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code)",
"... | [
"0.74336517",
"0.71425796",
"0.71181476",
"0.711704",
"0.69755274",
"0.6971609",
"0.6896055",
"0.6858473",
"0.6735097",
"0.67309946",
"0.64784896",
"0.6459869",
"0.6459869",
"0.64299446",
"0.6417699",
"0.6399707",
"0.6287258",
"0.6272853",
"0.6266458",
"0.62664276",
"0.625872... | 0.7155631 | 1 |
Ensure a moderator can list community members | def test_list_members_with_mod_rights_not_accepted(self):
url = '/api/v1/communities/3/retrieve_members/'
# Test before acceptation
response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user2'))
self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_my_memberships_moderator(self):\n url = '/api/v1/communities/0/list_my_memberships/'\n\n response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user2'))\n self.assertEqual(status.HTTP_200_OK, response.status_code)\n\n data = response.data\n self.assertEqual(2... | [
"0.7051194",
"0.6711181",
"0.64728236",
"0.64343464",
"0.6335402",
"0.6332418",
"0.6322088",
"0.6300939",
"0.62266105",
"0.62061685",
"0.6186931",
"0.6154109",
"0.6133125",
"0.6089142",
"0.6066312",
"0.60557896",
"0.60480255",
"0.60186434",
"0.5995337",
"0.598136",
"0.5977626... | 0.6736305 | 1 |
Ensure an owner can list community members | def test_list_members_with_owner_rights(self):
url = '/api/v1/communities/4/retrieve_members/'
response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user1'))
self.assertEqual(status.HTTP_200_OK, response.status_code)
data = response.data
self.assertEqual(3, data['count'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_my_memberships_owner(self):\n url = '/api/v1/communities/0/list_my_memberships/'\n\n response = self.client.get(url, HTTP_AUTHORIZATION=self.auth('user1'))\n self.assertEqual(status.HTTP_200_OK, response.status_code)\n\n data = response.data\n self.assertEqual(10, d... | [
"0.6850305",
"0.6369545",
"0.6356356",
"0.63156796",
"0.6232381",
"0.62307173",
"0.6166239",
"0.6013789",
"0.5975188",
"0.59524864",
"0.5949585",
"0.5914357",
"0.5889505",
"0.58360505",
"0.5826356",
"0.58094084",
"0.5800246",
"0.5785122",
"0.5776153",
"0.57705945",
"0.5761523... | 0.73415005 | 0 |
Ensure an owner can accept members | def test_accept_member_with_owner(self):
url = '/api/v1/communities/3/accept_member/'
data = {
'id': 5
}
response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user1'), format='json')
self.assertEqual(status.HTTP_200_OK, response.status_code)
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_accept_member_with_owner_bad_request(self):\n url = '/api/v1/communities/3/accept_member/'\n data = {\n 'lol': 5\n }\n\n response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user1'), format='json')\n self.assertEqual(status.HTTP_400_BAD_REQUEST... | [
"0.6731412",
"0.65779585",
"0.63750887",
"0.6366519",
"0.6354966",
"0.62834394",
"0.6279583",
"0.6198843",
"0.6170857",
"0.61704665",
"0.61604524",
"0.6086872",
"0.60775965",
"0.6073261",
"0.60595465",
"0.6056707",
"0.59992194",
"0.5991158",
"0.5943764",
"0.59232306",
"0.5914... | 0.6751411 | 0 |
Ensure accept_member request data format | def test_accept_member_with_owner_bad_request(self):
url = '/api/v1/communities/3/accept_member/'
data = {
'lol': 5
}
response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user1'), format='json')
self.assertEqual(status.HTTP_400_BAD_REQUEST, response.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_accept_member_with_simple_member(self):\n url = '/api/v1/communities/3/accept_member/'\n data = {\n 'id': 5\n }\n\n response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user4'), format='json')\n self.assertEqual(status.HTTP_401_UNAUTHORIZED, re... | [
"0.6623991",
"0.6439201",
"0.6344205",
"0.60939497",
"0.6076833",
"0.5939714",
"0.57749414",
"0.57017714",
"0.56973577",
"0.56565666",
"0.55855423",
"0.54607755",
"0.54509866",
"0.5416845",
"0.54042083",
"0.5377248",
"0.5291782",
"0.52428794",
"0.52106965",
"0.52024275",
"0.5... | 0.6553939 | 1 |
Ensure an non accepted moderator cannot accept members | def test_accept_member_with_not_accepted_moderator(self):
url = '/api/v1/communities/3/accept_member/'
data = {
'id': 5
}
response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user2'), format='json')
self.assertEqual(status.HTTP_401_UNAUTHORIZED, respo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_regular_member_cannot_target_another_member(self, constants):\n constants.MODERATION_ROLES = [self.moderator_role.id]\n ctx = helpers.MockContext(author=self.author)\n\n await self.cog.user_info(self.cog, ctx, self.target)\n\n ctx.send.assert_called_once_with(\"You may no... | [
"0.6785598",
"0.64873403",
"0.64873403",
"0.64451265",
"0.6402304",
"0.63861674",
"0.638381",
"0.63739187",
"0.6372048",
"0.63524115",
"0.631415",
"0.63072675",
"0.6279124",
"0.62184",
"0.6168928",
"0.616577",
"0.6144473",
"0.61243993",
"0.60957074",
"0.6082967",
"0.6080854",... | 0.72607374 | 0 |
Ensure an moderator can accept members | def test_accept_member_with_moderator(self):
mod = Member.objects.get(id=4)
mod.status = '1'
mod.save()
url = '/api/v1/communities/3/accept_member/'
data = {
'id': 5
}
response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user2'), form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_accept_member_with_not_accepted_moderator(self):\n url = '/api/v1/communities/3/accept_member/'\n data = {\n 'id': 5\n }\n\n response = self.client.post(url, data, HTTP_AUTHORIZATION=self.auth('user2'), format='json')\n self.assertEqual(status.HTTP_401_UNAUTHO... | [
"0.6981334",
"0.65625805",
"0.65563244",
"0.6527023",
"0.64415276",
"0.6407077",
"0.6333332",
"0.6292483",
"0.62635446",
"0.621534",
"0.6205803",
"0.61909056",
"0.6183474",
"0.6173419",
"0.6173419",
"0.6162516",
"0.6156852",
"0.613148",
"0.6097213",
"0.60312736",
"0.6019743",... | 0.71248305 | 0 |
Install eggs for a particular configuration | def __install_eggs(self, config):
egg_carton = (
self.directory.install_directory(self.feature_name),
"requirements.txt",
)
eggs = self.__gather_eggs(config)
self.logger.debug("Installing eggs %s..." % eggs)
self.__load_carton(egg_carton, eggs)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install(self, egg, dir_path):",
"def install():\n deploy()\n configure()",
"def _install(self):\n\n pass",
"def install_egg(self, egg_name):\n if not os.path.exists(self.egg_directory):\n os.makedirs(self.egg_directory)\n self.requirement_set.add_requirement(\n ... | [
"0.6983456",
"0.66896045",
"0.6177954",
"0.60125315",
"0.6004646",
"0.59920675",
"0.5969057",
"0.590986",
"0.5858302",
"0.58255863",
"0.58191156",
"0.5809163",
"0.58055943",
"0.57812357",
"0.5772991",
"0.5771122",
"0.5763537",
"0.57495356",
"0.57216597",
"0.57147646",
"0.5714... | 0.8199708 | 0 |
Divide the data into trips and give each trip a unique number "trip_no" The data is saved to a parquet file. | def save_numbered_trips(df, output_path:str, max_skip=3):
current_trip_no = 0
parquet_schema = None
if os.path.exists(output_path):
os.remove(output_path)
skips=0
for i,partition in enumerate(df.partitions):
try:
df_raw = partition.compute()
except Val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_microtrips(self):\n for data in self.microtrip_data:\n file_name = \"../data/microtrips/\" + data.file.name + \"_m\" + \".csv\"\n data.save_csv(file_name)",
"def export_trip_information(trip_id,first_arrive,first_depart,\n trip_length,trip_duration,to... | [
"0.60607815",
"0.5905817",
"0.5816707",
"0.54936224",
"0.53999996",
"0.53608507",
"0.5337857",
"0.53275985",
"0.5279713",
"0.5245389",
"0.52331084",
"0.52224356",
"0.51837873",
"0.5180322",
"0.5174375",
"0.51288676",
"0.5123644",
"0.510983",
"0.51059484",
"0.5104036",
"0.5098... | 0.67602295 | 0 |
bags the data for the specified participants by sessions. The starting index of each session is defined in session_start and the corresponding labels are defined in session_labels. (X,Y) is the entire dataset. | def single_instances_to_sessions(X, Y, session_labels, session_start, participant_indices):
bags = []
labels = []
single_instance_labels = []
for k in participant_indices:
for j in range(len(session_labels[k])):
if j < len(session_labels[k])-1:
end = session_start[k][j+1]
else:
end = len(X[k])
ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regroup_dataset(labels):\r\n batch_y = labels.copy()\r\n for i, label in enumerate(labels):\r\n if label in [0, 15, 19]:\r\n batch_y[i]=0\r\n if label in [1, 2, 3, 4, 5,]:\r\n batch_y[i]=1\r\n if label in [... | [
"0.5448921",
"0.53773844",
"0.5312974",
"0.5291654",
"0.52719367",
"0.52677006",
"0.52605337",
"0.5203306",
"0.51902205",
"0.51698947",
"0.5103194",
"0.50545406",
"0.5038974",
"0.5037716",
"0.50168985",
"0.5003415",
"0.50015026",
"0.4984332",
"0.49801752",
"0.4976352",
"0.494... | 0.6738862 | 0 |
Read a list of synapse admin events and report changes to user power levels. | def report_admin_events(events):
levels = {} # keeps track of user -> level mapping over time
show_mutes = False
for event in events:
(timestamp, sender, event_type, content) = event
print(f"\n{timestamp}\t{sender}")
# report on users where the prior known level is gone
us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _e_list(self, ctx):\n event_list = self.database.get_guild_events(ctx.guild.id)\n if len(event_list) == 0:\n await ctx.send(\"This server has no custom events\")\n return\n out = \"```\\nServer Events:\\n\"\n for event in event_list:\n out += f... | [
"0.595979",
"0.5520849",
"0.5495647",
"0.5478341",
"0.53156155",
"0.53067887",
"0.52975523",
"0.5295242",
"0.5291212",
"0.52869153",
"0.5238782",
"0.5236966",
"0.52195317",
"0.5198999",
"0.5172369",
"0.51485234",
"0.51476765",
"0.51330614",
"0.51263815",
"0.5109358",
"0.51061... | 0.66740656 | 0 |
Calculates the time difference abs(date1 date2) between two dates in months. Day is neglected. | def month_diff(date1, date2):
# First make sure, that date2 > date1
if date1.daysTo(date2) < 0:
date_tmp = date1
date1 = date2
date2 = date_tmp
years = date2.year() - date1.year()
months = date2.month() - date1.month()
if months < 0:
years -= 1
months += 12
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff_month(d1, d2):\n return ceil(abs((d1.year - d2.year) * 12 + d1.month - d2.month))",
"def compute_duration(date1, date2):\n duration = 0\n if date1 and date2:\n delta = abs(date1 - date2)\n duration = delta.days * 86400 + delta.seconds\n return duration",
"def date_diff_months... | [
"0.6941323",
"0.6818145",
"0.679008",
"0.67421985",
"0.6620554",
"0.64680517",
"0.64635617",
"0.64242184",
"0.6399711",
"0.6364292",
"0.60353655",
"0.59266156",
"0.582229",
"0.5665558",
"0.5641006",
"0.5557162",
"0.5533768",
"0.55188507",
"0.55112755",
"0.5487111",
"0.5483864... | 0.7048405 | 0 |
arrival_time = frequency of the exponential distribution related to the arrival time in 1/seconds service_time = deterministic service time in 1/seconds max_time = time of simulation in hour to be converted in seconds in the program | def M_D_1(arrival_time,max_time,service_time=1/90):
#conversion in seconds
max_seconds = max_time*60*60
sim_time = 0.0 # simulation time
t_1 = 0.0 # time for next event (arrival)
t_2 = max_seconds # time for next event (departure)
t_n = 0.0 #last event time--> tempo dell'ultimo avvenimento gener... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approximate_delivery_time(self):\n # this is set to seconds just of demonstration\n approx_delivery_time = random.randrange(300, 600)\n approx_time_to_main_station = approx_delivery_time / 2\n\n return {\n \"delivery_time\": approx_delivery_time,\n \"time_to_st... | [
"0.623899",
"0.62073016",
"0.57325894",
"0.56798995",
"0.5615627",
"0.5612654",
"0.55865824",
"0.5578292",
"0.55203074",
"0.5509975",
"0.5509975",
"0.54552954",
"0.543938",
"0.5385902",
"0.53795916",
"0.534916",
"0.5277093",
"0.52733487",
"0.5250447",
"0.52468187",
"0.5239847... | 0.69476897 | 0 |
This function/filter reads the host_var information provided by Ansible aruba_config module to extract "changed lines" | def aruba_diff(self, host_var):
output_list = []
for item in host_var:
if type(host_var[item]) is dict:
if 'updates' in host_var[item]:
if host_var[item]['changed']:
update = host_var[item]['updates']
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __analyze_config(self):\n result = {}\n with open(self.file) as f:\n data = f.readlines()\n temp_key = ''\n for line in data:\n if line[0] == '\t' or line[0] == ';':\n result[temp_key].append(line.strip())\n else:\n temp... | [
"0.5730209",
"0.56443113",
"0.5615085",
"0.5516753",
"0.54714805",
"0.5436443",
"0.54273635",
"0.53481036",
"0.5313529",
"0.5283646",
"0.52792495",
"0.5246545",
"0.5220793",
"0.5219981",
"0.52106386",
"0.5179972",
"0.51748455",
"0.51602554",
"0.5153993",
"0.5145902",
"0.51281... | 0.66426724 | 0 |
Gets the current head | def head(self):
return self._head | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\r\n return self.__head",
"def first(self):\n return self.__head",
"def currenthead(self):\n return self.repo.head.object",
"def peek(self):\n return self.list.head",
"def head(self) -> object:\n if not self._head:\n raise EmptyListException(\"T... | [
"0.80130213",
"0.7923789",
"0.7821768",
"0.75414413",
"0.73890346",
"0.73000383",
"0.7205366",
"0.7202247",
"0.72009563",
"0.71663415",
"0.71562153",
"0.71256787",
"0.710123",
"0.7087479",
"0.7047039",
"0.7027316",
"0.7017254",
"0.69998443",
"0.69862455",
"0.69797623",
"0.697... | 0.85257405 | 1 |
Gets the current tail | def tail(self):
return self._tail | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tail(self):\n return self._readahead.getvalue()",
"def get_tail(self):\n pointer = self.head\n while pointer.next_node:\n pointer = pointer.next_node\n return pointer",
"def peek_last(self):\n if self.is_empty(): raise RuntimeError(\"Empty list\")\n ... | [
"0.7987476",
"0.75084555",
"0.7217858",
"0.7078854",
"0.70251787",
"0.6993961",
"0.69410443",
"0.6919684",
"0.6894651",
"0.68824685",
"0.6878774",
"0.6853597",
"0.68393075",
"0.67811173",
"0.6733288",
"0.6732261",
"0.6592453",
"0.65848786",
"0.65684897",
"0.6545789",
"0.65059... | 0.864701 | 1 |
Adds a node to the front of the list | def addFront(self, data):
new_list = _Node(data)
temp = self._head
if self._head is None:
self._head = new_list
self._tail = new_list
else:
new_list.next = temp
new_list.next.prev = new_list
self._head = new_list
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_front(self, item):\n new_node = Node(item)\n # if the list is empty, make it head\n if self.head is None:\n self.head = new_node\n # else, \n else:\n new_node.next = self.head # new node points to current head\n self.head = new_node # c... | [
"0.82249105",
"0.7810608",
"0.7768546",
"0.7768546",
"0.7755671",
"0.7738799",
"0.77328646",
"0.7720509",
"0.7625948",
"0.7588103",
"0.75430006",
"0.752145",
"0.7492182",
"0.746664",
"0.745477",
"0.7394027",
"0.7339842",
"0.73390335",
"0.73347354",
"0.728799",
"0.7265528",
... | 0.7907306 | 1 |
Return name of serializer for a model. | def get_serializer_name_by_model(_model):
return '{}Serializer'.format(_model.__name__) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_name(self) -> str:\n return self._get_string(openvr.Prop_RenderModelName_String)",
"def name(self) -> str: # pragma: no cover\n return self.model.__name__",
"def get_model_name(self) -> str:\n raise NotImplementedError",
"def model_name(self) -> str:\n return self._... | [
"0.6780367",
"0.6774362",
"0.66296005",
"0.6629534",
"0.657652",
"0.6532302",
"0.65118784",
"0.6496903",
"0.64815027",
"0.639073",
"0.63782823",
"0.63662857",
"0.62982553",
"0.6294734",
"0.6262839",
"0.6249802",
"0.6196127",
"0.6195564",
"0.6152502",
"0.6151185",
"0.6149466",... | 0.9127496 | 0 |
Test Azure EventHub origin parses Binary in a variety of data types. | def test_data_format_binary(sdc_builder, sdc_executor, azure):
container_name = get_random_string(string.ascii_lowercase, 10)
event_hub_name = get_random_string(string.ascii_lowercase, 10)
MESSAGES = [b'message 1', b'message 2']
EXPECTED_OUTPUT = "[b'message 1', b'message 2']"
builder = sdc_builde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_bytes(self, ???):",
"def test_bin_data_type(self):\n\n with pytest.raises(TypeError) as verr:\n avg.median2D(self.testInst, ['1', 'a', '23', '10'], 'longitude',\n ['0', 'd', '24', 'c'], 'mlt',\n ['dummy1', 'dummy2', 'dummy3'], auto_bin=Fa... | [
"0.6008974",
"0.59854835",
"0.5940457",
"0.5918118",
"0.5896898",
"0.5895602",
"0.5882247",
"0.58684736",
"0.58602846",
"0.58145744",
"0.5814127",
"0.57945067",
"0.5786584",
"0.57704145",
"0.57686555",
"0.57686555",
"0.57686555",
"0.57686555",
"0.57686555",
"0.57686555",
"0.5... | 0.6982023 | 0 |
Create and return a Azure EventHub origin stage depending on execution mode for the pipeline. | def _get_azure_eventhub_consumer_stage(builder, container_name, event_hub_name, data_format):
azure_iot_event_hub_consumer = builder.add_stage(name=AZURE_IOT_EVENT_HUB_STAGE_NAME).set_attributes(
container_name=container_name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_event(trigger, event):\n\n if trigger == \"eval\":\n print(\"Triggered by Invoke\")\n\n # event is the pipeline, provide consistent pipeline defaults\n pipeline = default_pipeline(event)\n\n return pipeline\n\n elif trigger == \"S3\":\n print(\"Triggered from S3\"... | [
"0.52332556",
"0.5193338",
"0.5114489",
"0.50379026",
"0.4959821",
"0.48886234",
"0.4858949",
"0.48461798",
"0.4842308",
"0.4800151",
"0.4778661",
"0.47242874",
"0.47108313",
"0.4688939",
"0.4656326",
"0.46418527",
"0.46377864",
"0.45985177",
"0.45866713",
"0.45585388",
"0.45... | 0.62307066 | 0 |
Test whether we can add a landing page to campaign. | def testAddLandingPageToCampaign(self):
if self.__class__.campaign1 is None:
self.testSaveCampaign()
landing_page = {
'id': '-1',
'url': 'http://www.example.com',
'name': 'Landing page #%s' % Utils.GetUniqueName()
}
self.assert_(isinstance(self.__class__.service.AddLandingP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available(self):\n existing_url = self.context.get_personal_fundraising_campaign_url()\n same = existing_url == self.context.absolute_url()\n creating = 'create-personal-campaign-page' in self.request.URL\n return not same and not creating",
"def testGetLandingPagesForCampaign(sel... | [
"0.7193204",
"0.6475577",
"0.63865",
"0.6113079",
"0.5993139",
"0.5958102",
"0.58199036",
"0.5775793",
"0.57187057",
"0.56757647",
"0.56338835",
"0.5573666",
"0.5542688",
"0.55141956",
"0.5502747",
"0.5437384",
"0.5427393",
"0.5408094",
"0.5405026",
"0.539166",
"0.5384252",
... | 0.6654128 | 1 |
Test whether we can copy campaigns. | def testCopyCampaigns(self):
if self.__class__.campaign1 is None:
self.testSaveCampaign()
requests = [{
'campaignId': self.__class__.campaign1['id']
}]
self.assert_(isinstance(self.__class__.service.CopyCampaigns(requests),
tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canShare(self):\n return False",
"def CanCopy(self):\n return self.HasSelection()",
"def can_be_collected(self):\n return True",
"def canCreateCaddyManip(*args, **kwargs)->bool:\n pass",
"def _copyDataSetsForExperiment(self):\n\n # Copy all tubes - if they could not be co... | [
"0.60453284",
"0.5922676",
"0.5760109",
"0.5710391",
"0.5692238",
"0.5674369",
"0.56590486",
"0.553042",
"0.54061353",
"0.5337865",
"0.5293677",
"0.5285584",
"0.5263262",
"0.52472526",
"0.52441347",
"0.52295303",
"0.52201074",
"0.5219359",
"0.52088076",
"0.520511",
"0.5189243... | 0.7094511 | 0 |
Test whether we can fetch campaigns by criteria. | def testGetCampaignsByCriteria(self):
criteria = {
'archiveFilter': {
'inactiveOnly': 'true'
}
}
self.assert_(isinstance(self.__class__.service.GetCampaignsByCriteria(
criteria), tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_existent_campaigns_returns_campaigns_list(self):\n test_campaign = return_canned_campaign()\n test_campaign.create()\n response = self.client.get(self.endpoint_url)\n response_body = response.get_json()\n self.assertEqual(response.status_code, 200)\n self.asse... | [
"0.6126352",
"0.60831",
"0.5854207",
"0.5814784",
"0.5765778",
"0.5627458",
"0.5505774",
"0.54764736",
"0.5463633",
"0.53875184",
"0.5286463",
"0.5152078",
"0.51443475",
"0.51261663",
"0.509484",
"0.50877887",
"0.5074913",
"0.50539947",
"0.50416815",
"0.50400865",
"0.5023619"... | 0.6735202 | 0 |
Test whether we can fetch landing pages for a campaign. | def testGetLandingPagesForCampaign(self):
if self.__class__.campaign1 is None:
self.testSaveCampaign()
self.assert_(isinstance(self.__class__.service.GetLandingPagesForCampaign(
self.__class__.campaign1['id']), tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available(self):\n existing_url = self.context.get_personal_fundraising_campaign_url()\n same = existing_url == self.context.absolute_url()\n creating = 'create-personal-campaign-page' in self.request.URL\n return not same and not creating",
"def test_contact_landing_success(self)... | [
"0.67742693",
"0.6306628",
"0.62808394",
"0.6120006",
"0.59452415",
"0.57627016",
"0.5738992",
"0.5561723",
"0.5556827",
"0.55112934",
"0.54937756",
"0.54576766",
"0.5449263",
"0.542853",
"0.54040414",
"0.53753954",
"0.53047925",
"0.53038776",
"0.5275955",
"0.5274629",
"0.526... | 0.67377996 | 1 |
To render admin dashboard | def admin_dashboard():
if current_user.is_admin:
return render_template("home/admin_dashboard.html", title="Admin Dashboard")
abort(403) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dashboard():\n return render_template(\"admin/dashboard.html\", title=\"Dashboard\")",
"def show_admin():\n return render_admin_page(\"admin.html\")",
"def admin():\n return Response(render_template('admin.html'))",
"def dashboard():",
"def index(self):\n return self.render(\"admin/inde... | [
"0.8648089",
"0.8191513",
"0.80940354",
"0.7911078",
"0.7859473",
"0.7806951",
"0.77863497",
"0.7742015",
"0.7731237",
"0.75979704",
"0.7586668",
"0.75291425",
"0.7436194",
"0.7365606",
"0.7362157",
"0.73533463",
"0.7312894",
"0.725193",
"0.7224566",
"0.7199894",
"0.7161485",... | 0.82224727 | 1 |
DNS Server IP array of the DNS Zone. | def dns_server_ips(self) -> Optional[Sequence[str]]:
return pulumi.get(self, "dns_server_ips") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip_addresses(self):\n try:\n return socket.gethostbyaddr(self.fqdn)[-1]\n except socket.error as _:\n return ['127.0.0.1']",
"def get_server_ip(self, server_id):\n interface_list = self.get_server_ip_mac(server_id)\n if not isinstance(interface_list, list):\n... | [
"0.6982518",
"0.6663064",
"0.6639232",
"0.6582995",
"0.65587693",
"0.64883596",
"0.64526194",
"0.6438488",
"0.6390472",
"0.6310422",
"0.6257167",
"0.6109224",
"0.60959417",
"0.60855275",
"0.6008593",
"0.5972465",
"0.5970295",
"0.59657687",
"0.59450984",
"0.5930674",
"0.59133"... | 0.7367935 | 0 |
Number of DNS Services using the DNS zone. | def dns_services(self) -> Optional[float]:
return pulumi.get(self, "dns_services") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_servos(self) -> int:\n return self._num_servos",
"def service_count(self) -> str:\n return pulumi.get(self, \"service_count\")",
"def get_new_service_num(route53_zone, service_name):\n\n # Match records belonging to the service for particular service and\n # environment.\n match_... | [
"0.6881554",
"0.65291023",
"0.6471647",
"0.63960993",
"0.62855804",
"0.6134902",
"0.61287624",
"0.60777795",
"0.600986",
"0.60090524",
"0.6004223",
"0.5980317",
"0.5954924",
"0.5919003",
"0.58260965",
"0.581609",
"0.58124703",
"0.5804332",
"0.579322",
"0.5773976",
"0.5755711"... | 0.6778599 | 1 |
Source IP of the DNS Zone. | def source_ip(self) -> Optional[str]:
return pulumi.get(self, "source_ip") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSourceIp(self):\n return self.__sourceIp",
"def getOriginIp(self):\n return self.originIp",
"def public_ip_source(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"public_ip_source\")",
"def address(self):\n \n return self.__ip",
"def ip_address(self) ... | [
"0.73396534",
"0.6806294",
"0.6775697",
"0.6729144",
"0.669053",
"0.66422296",
"0.66422296",
"0.66401964",
"0.6604399",
"0.6597317",
"0.65907013",
"0.6536555",
"0.6487871",
"0.6486956",
"0.64785546",
"0.64755166",
"0.64685756",
"0.6462598",
"0.6390518",
"0.6390518",
"0.638882... | 0.752894 | 0 |
As a general rule you should ensure there's an appropriate index for the field provided in ordering. allow_count (default False) indicates whether or not to allow count queries that can be extremely expensive on large and fast changing datasets. allow_empty_first_page and orphans are currently ignored and only exist to... | def __init__(
self,
queryset,
per_page=25,
ordering="pk",
allow_count=False,
allow_empty_first_page=True,
orphans=0,
):
self.queryset = queryset
self.per_page = int(per_page)
self.ordering = ordering
self.allow_count = allow_cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_paginate(operation_name=None):\n pass",
"def can_paginate(operation_name=None):\n pass",
"def can_paginate(operation_name=None):\n pass",
"def can_paginate(operation_name=None):\n pass",
"def can_paginate(operation_name=None):\n pass",
"def can_paginate(operation_name=None):\n p... | [
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.5470511",
"0.54211426",
"0.52824336",
"0.52025956",
"0.52025956",... | 0.6878338 | 0 |
Attempt to fetch usage data from Xfinity. | def get_usage_data(username, password):
usage_req = XfinityUsage(username, password, browser_name="firefox-headless")
return usage_req.run() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsageInfo(self):\n return self.jsonRequest(\"/api/v1/usage\", { \"apiKey\": self._apiKey })",
"def _fetch_data(self):\n pass",
"def test_mock_datasource_usages(self):\n account1 = self.test_data.accounts[0]\n meter = account1.meters[0]\n usage = meter.usages[0]\n ... | [
"0.65825534",
"0.6223947",
"0.6160463",
"0.6084775",
"0.6011586",
"0.5991422",
"0.5960606",
"0.5794058",
"0.5778082",
"0.57704514",
"0.57532215",
"0.5739064",
"0.5734715",
"0.5715392",
"0.56156725",
"0.5563081",
"0.55498004",
"0.5534532",
"0.5509536",
"0.55004823",
"0.5500482... | 0.68384093 | 0 |
Parses usage data from `get_usage_data` into a simplified dictionary. | def parse_usage_data(usage_data):
try:
used = float(usage_data["used"])
total = float(usage_data["total"])
units = usage_data["units"]
except KeyError:
raise RuntimeError("Missing usage field")
except ValueError:
raise RuntimeError("Invalid float for usage")
try:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_usage_data(self):\n with self._lock:\n data_copy = self._data.copy()\n return data_copy",
"def getUsageInfo(self):\n return self.jsonRequest(\"/api/v1/usage\", { \"apiKey\": self._apiKey })",
"def _usage_report_dict(self, root):\n details = {}\n selector = ... | [
"0.595714",
"0.5901919",
"0.5696059",
"0.56513846",
"0.5559412",
"0.55006486",
"0.5456827",
"0.5399195",
"0.53736734",
"0.53501415",
"0.5313205",
"0.53006226",
"0.52940077",
"0.5287321",
"0.52843976",
"0.5270543",
"0.52501863",
"0.5234447",
"0.5186706",
"0.51861036",
"0.51832... | 0.7904441 | 0 |
Converts from an array of vertex indices to a bitwise representation | def verts_to_bits(vs):
return sum(2**v for v in vs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertex_group_ids_to_bitmask(vertex):\n list = [x.group for x in vertex.groups]\n masked = 0\n for group in list:\n masked |= 1 << group\n return masked",
"def flip_labels_with_indices(arr, indices):\n\n assert arr.ndim == 1, 'arr is not 1d!'\n assert np.all(np.unique(arr) == np.array... | [
"0.6393874",
"0.61002445",
"0.6074662",
"0.6046116",
"0.6043752",
"0.5958655",
"0.5898454",
"0.58136505",
"0.57977664",
"0.57674116",
"0.5753882",
"0.573017",
"0.57096016",
"0.56567574",
"0.5620509",
"0.5576903",
"0.5572747",
"0.5552426",
"0.5549938",
"0.5513818",
"0.54547226... | 0.69435185 | 0 |
Applies a vertex permutation to a list of faces, optionally flipping the faces | def faces_apply(op, faces, flip):
return [face_apply(op, face, flip) for face in faces] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def face_apply(op, face, flip):\n edges = [edge_apply(op, edge) for edge in face]\n if flip: edges = list(reversed(edges))\n return edges",
"def permutations(cube):\r\n yield from rotations24(cube)\r\n yield from rotations24(np.flip(cube, 0))\r\n yield from rotations24(np.flip(cube, 1))\r\n ... | [
"0.6295819",
"0.57063204",
"0.56514055",
"0.5288726",
"0.5246789",
"0.5239562",
"0.51833093",
"0.517691",
"0.51233995",
"0.5112797",
"0.5077392",
"0.50435096",
"0.5018579",
"0.50046337",
"0.5001015",
"0.49998033",
"0.49979767",
"0.49799728",
"0.49551815",
"0.49465147",
"0.494... | 0.6877623 | 0 |
Returns the midpoint of the edge, scaled by 2 | def d_midpoint(edge):
v0, v1 = EDGES[edge]
v0_pos = VERTICES[v0]
v1_pos = VERTICES[v1]
return ((x+y) for (x,y) in zip(v0_pos, v1_pos)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMidPoint(self):\n return p.Point((self.start.normalVector + self.end.normalVector)/2.0)",
"def midpoint(self) -> Tuple[int, int]:\n minx, miny, maxx, maxy = self.substrates.bounds\n return ((minx + maxx) // 2, (miny + maxy) // 2)",
"def midpoints(self):\n return self.bins[:, ... | [
"0.71897864",
"0.71782583",
"0.69667315",
"0.68740594",
"0.6849831",
"0.6820582",
"0.68040663",
"0.6604313",
"0.655959",
"0.6443173",
"0.64284766",
"0.6420485",
"0.64110684",
"0.64069355",
"0.6338997",
"0.6332368",
"0.6320957",
"0.6279374",
"0.6177305",
"0.60413665",
"0.60012... | 0.72003573 | 0 |
Returns the square of the length of two positions | def length_sq(pos1, pos2):
return sum((x-y)**2 for (x,y) in zip(pos1, pos2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(a, b):\n return sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]))",
"def two_point_length(tuple1, tuple2):\n tot_sum = 0\n tot_sum += pow(tuple1[0]-tuple2[0], 2)\n tot_sum += pow(tuple1[1]-tuple2[1], 2)\n tot_sum += pow(tuple1[2]-tuple2[2], 2)\n final_len = pow(tot_... | [
"0.77668077",
"0.7397608",
"0.7298026",
"0.7286897",
"0.7151986",
"0.69440967",
"0.68845505",
"0.6838329",
"0.68282306",
"0.66732067",
"0.663228",
"0.6612591",
"0.6606926",
"0.65746224",
"0.65694505",
"0.6530553",
"0.65292597",
"0.64804214",
"0.6469597",
"0.64584744",
"0.6403... | 0.840613 | 0 |
Searches the CSV for the user provided criteria, then calls the display_search_results function once it is found | def search_csv(search_criteria):
results_list = []
with open('work_log.csv', 'r') as file:
for row in file:
if search_criteria in row:
results_list.append(row)
results_sort(results_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proceed(results_sort):\n result_index = 0\n good = True\n with open('work_log.csv', 'r') as file:\n while good:\n proceed_prompt = input('Would you like to see the next '\n 'match (Y/N)? \\n>').upper()\n if proceed_prompt == 'Y':\n ... | [
"0.66718364",
"0.66616684",
"0.64814675",
"0.6412671",
"0.6390805",
"0.6351803",
"0.6337164",
"0.63014495",
"0.6237988",
"0.62156785",
"0.61356044",
"0.6060477",
"0.60499936",
"0.60499936",
"0.60210896",
"0.6012082",
"0.6007237",
"0.59896463",
"0.59748703",
"0.5954872",
"0.59... | 0.7490647 | 0 |
Searches the csv file for the time spent on the task | def search_time(time_spent):
results_list = []
with open('work_log.csv', 'r') as file:
for row in file:
if time_spent in row:
results_list.append(row)
time_sort(time_spent, results_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self,time):\n \n fname = []\n tind =[]\n for t in time:\n flag=1\n for f in self.timelookup.keys():\n\n if t >= self.timelookup[f][0] and t<=self.timelookup[f][-1]:\n# print 'Found tstep %s'%datetime.strptime(t,'%Y-%m-... | [
"0.62988394",
"0.6165839",
"0.6142794",
"0.613546",
"0.61039007",
"0.6103374",
"0.59048325",
"0.5850628",
"0.58097833",
"0.5788802",
"0.57876265",
"0.57777923",
"0.5762286",
"0.5760471",
"0.57439256",
"0.57371503",
"0.5698138",
"0.5673036",
"0.5657542",
"0.56012",
"0.560112",... | 0.70304364 | 0 |
Uses a regex pattern to search the CSV for the users specified criteria | def reg_csv_search(arg):
results_list = []
with open('work_log.csv', 'r') as file:
for row in file:
if re.search(arg, str(row)):
results_list.append(row)
results_sort(results_list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_csv(search_criteria):\n results_list = []\n with open('work_log.csv', 'r') as file:\n for row in file:\n if search_criteria in row:\n results_list.append(row)\n results_sort(results_list)",
"def match_name(pattern, rows):\n matching = []\n for row in... | [
"0.67888",
"0.6470334",
"0.6396413",
"0.6255691",
"0.5961034",
"0.5894265",
"0.5788759",
"0.57324696",
"0.56589437",
"0.5637524",
"0.56029505",
"0.5554282",
"0.55365884",
"0.55257493",
"0.5497352",
"0.54574275",
"0.5443628",
"0.5270864",
"0.52509785",
"0.5232844",
"0.522245",... | 0.73986834 | 0 |
Displays the time criteria in a user friendly format | def display_time(time_spent, results):
time_list = results.split(',')
if time_list[2] == time_spent:
print('Date : {}'.format(time_list[0]))
print('Title : {}'.format(time_list[1]))
print('Time Spent : {}'.format(time_list[2]))
print('Notes : {}'.format(time_list[3]))
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_time(self):\n hour = str(datetime.datetime.now().strftime(\"%H\"))\n minute = str(datetime.datetime.now().strftime(\"%M\"))\n\n hour1 = int(hour[0])\n hour2 = int(hour[1])\n minute1 = int(minute[0])\n minute2 = int(minute[1])\n\n self.light_number(self.numb... | [
"0.662041",
"0.6618704",
"0.65189946",
"0.6502401",
"0.63292795",
"0.6303609",
"0.62661237",
"0.6211137",
"0.61990756",
"0.6094369",
"0.6071117",
"0.6003552",
"0.60004944",
"0.59723264",
"0.59697723",
"0.59694594",
"0.59597594",
"0.59349036",
"0.59229594",
"0.5916387",
"0.591... | 0.6771459 | 0 |
Tries to perform an urlopen(url).read(), with workarounds for broken certificate stores. On many Python installations, urllib has problems using the system certificate stores; this seems to be particularly true on macOS, it is so in a twisted way on Win32 and can be a problem on some Linux distros (where in general the... | def workaround_url_read(url):
from urllib.request import urlopen
from urllib.error import URLError
try:
return urlopen(url).read()
except URLError as ex:
import ssl
if len(ex.args) and isinstance(ex.args[0], ssl.SSLError):
logger.warn("SSL error reading catalog file %... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getfilehttps(self, url):\n ctx = ssl.create_default_context()\n ctx.check_hostname = False\n ctx.verify_mode = ssl.CERT_NONE\n response = urllib.request.urlopen(url, context=ctx)\n result = response.read()\n return result",
"def _fetch(url, ssl_verify = True):\n r... | [
"0.76082635",
"0.71762764",
"0.662815",
"0.66156995",
"0.65748215",
"0.6362366",
"0.631332",
"0.6236358",
"0.62360704",
"0.62359977",
"0.62280315",
"0.60872215",
"0.60525805",
"0.60064995",
"0.59848493",
"0.5960688",
"0.5955748",
"0.59550893",
"0.59434485",
"0.5941267",
"0.59... | 0.7631621 | 0 |
Ensure we have an alias to import is_affirmative as _is_affirmative for backward compatibility with Agent 5.x | def test_alias():
assert getattr(config, "_is_affirmative", None) is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_affordable(self, tx_message: TransactionMessage) -> bool:\n is_affordable = True\n if self.context.ownership_state.is_initialized:\n is_affordable = self.context.ownership_state.is_affordable_transaction(\n tx_message\n )\n if self.context.ledger_st... | [
"0.58096945",
"0.56020963",
"0.5278895",
"0.5237023",
"0.52046263",
"0.5125001",
"0.5096052",
"0.50864345",
"0.50788856",
"0.49949625",
"0.49739137",
"0.49159327",
"0.48837402",
"0.48781067",
"0.48724884",
"0.48707488",
"0.48390678",
"0.4833998",
"0.47909078",
"0.478799",
"0.... | 0.64019364 | 0 |
simulate simple BRDF BRDF is not random so we enforce a certain structure onto the BRDF First the SZA is modelled as a simple sin across the year One approach is a climatology from the MODIS data? For this i think sin waves of diff freq will give some characteristic covering can vary max and min angles to sensors | def angular1(brdf_settings):
# const
scaleconst = 2*np.pi/366
locals().update(brdf_settings)
def scale(x, a=5, b=10, xmin=-1, xmax=1):
"""
rescale the sin
a new min
b = new max
xmin = min of x
xmax = max of x
"""
return (b - a)*(x - xmin)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sim_any_sinmode(gls_obj, in_freq, times):\n k = np.where(np.round(gls_obj.freq, 5) == in_freq)[0]\n if len(k) > 1:\n k = k[0]\n amp = np.sqrt(gls_obj._a[k]**2 + gls_obj._b[k]**2)\n ph = np.arctan2(gls_obj._a[k], gls_obj._b[k]) / (2. * np.pi)\n T0 = times.min() - ph / in_freq\n offset =... | [
"0.6582506",
"0.6425722",
"0.6123549",
"0.6094703",
"0.6085024",
"0.6063853",
"0.6045906",
"0.6019445",
"0.6018563",
"0.60164666",
"0.60149175",
"0.60096467",
"0.597433",
"0.5969006",
"0.59594935",
"0.5911588",
"0.58930105",
"0.58714265",
"0.58433384",
"0.58316123",
"0.582491... | 0.68870825 | 0 |
rescale the sin a new min b = new max xmin = min of x xmax = max of x | def scale(x, a=5, b=10, xmin=-1, xmax=1):
return (b - a)*(x - xmin)/(xmax - xmin) + a | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rescale(self, xmin, xmax):\n\n # Normalise\n self.normalise()\n\n \n # Rescale\n range = xmax-xmin\n for seg in self.segments:\n seg.lower_bound = seg.lower_bound*range + xmin\n seg.upper_bound = seg.upper_bound*range + xmin",
"def sin_inplace(a... | [
"0.634048",
"0.6331223",
"0.605195",
"0.6003298",
"0.5982807",
"0.5972186",
"0.5926084",
"0.5825354",
"0.57681715",
"0.5748232",
"0.5718174",
"0.5701674",
"0.56905395",
"0.5674951",
"0.5660613",
"0.5647292",
"0.5632954",
"0.55880105",
"0.55765074",
"0.55494636",
"0.5454097",
... | 0.67776537 | 0 |
finds the respond tenant id that matches the external tenant id provided, if exists and accessible | def get_internal_tenant_from_mapping_with_external(tenant_mappings, external_tenant_id):
for curr_internal_tid, curr_external_tid in tenant_mappings.items():
if external_tenant_id == curr_external_tid:
return curr_internal_tid
raise Exception(
'no respond tenant matches external tena... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tenant_id(self, tenant_name):\n _url = \"http://\" + self.host_ip + \":35357/v2.0/tenants\"\n _headers = {'x-auth-token': self.cloud_admin_info['token_project']}\n _body = None\n\n response = self.request(\"GET\", _url, _headers, _body)\n if response is None:\n ... | [
"0.6791298",
"0.66685784",
"0.66443527",
"0.6412366",
"0.6134844",
"0.5966822",
"0.59410775",
"0.5836731",
"0.58017755",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.57861495",
"0.56586814",
"... | 0.7206188 | 0 |
given an email address and a list of Respond users, find the user id of the user with the provided email, and raise an exception if no user is found | def get_user_id_from_email(email, users):
# find the user id that matches the email provided in user_to_add field
for user in users:
if user.get('email') == email:
return user.get('userId')
raise Exception('no user found with email ' + email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user_id(email: str):\n user_id = sdk.search_users(email=email)\n \n \"\"\" Customized logic block to check if an email address is associated with a Looker user\"\"\"\n if len(user_id) == 0: \n return 'There is no user associated with this email' \n else:\n return user_id[0]['id']",
"def get_u... | [
"0.78303033",
"0.7438993",
"0.71716756",
"0.7155806",
"0.69510233",
"0.6937138",
"0.6776626",
"0.6728193",
"0.66594094",
"0.66438246",
"0.6626024",
"0.6621654",
"0.6596364",
"0.6587094",
"0.65866435",
"0.6575921",
"0.6572273",
"0.6489863",
"0.64741397",
"0.64670396",
"0.64641... | 0.7865365 | 0 |
Get latest backup files using Frappe utils, push them to S3 and remove local copy | def push_backup(args: Arguments) -> None:
files = get_files_from_previous_backup(args.site)
bucket = get_bucket(args)
for path in files:
upload_file(
path=path,
site_name=args.site,
bucket=bucket,
bucket_directory=args.bucket_directory,
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_artifacts(ctx: Context, salt_version: str, artifacts_path: pathlib.Path):\n ctx.info(\"Preparing upload ...\")\n s3 = boto3.client(\"s3\")\n to_delete_paths: list[dict[str, str]] = []\n remote_path = f\"release-artifacts/{salt_version}\"\n try:\n ret = s3.list_objects(\n ... | [
"0.6482276",
"0.6345482",
"0.6258528",
"0.6255586",
"0.6162054",
"0.6135203",
"0.61243594",
"0.609647",
"0.60642684",
"0.6008225",
"0.59802324",
"0.597014",
"0.59692574",
"0.59250724",
"0.590495",
"0.5896386",
"0.58930147",
"0.58853287",
"0.5872126",
"0.58527386",
"0.58522874... | 0.7075595 | 0 |
Prefix the ContentType objects of content items, to make them recognizable. Runs automatically at syncdb, and initial south model creation. | def _on_post_syncdb(app, verbosity=2, db=DEFAULT_DB_ALIAS, **kwargs):
app_models = [m for m in get_models(app) if issubclass(m, ContentItem)]
for model in app_models:
update_model_prefix(model, verbosity=verbosity, db=db) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_contenttypes(sender, verbosity=2, db=DEFAULT_DB_ALIAS, **kwargs):\n from django.contrib.contenttypes.models import ContentType\n \n if verbosity >= 2:\n print(\"Running Djangae version of update_contenttypes on {}\".format(sender))\n\n try:\n apps.get_model('contenttypes', 'Con... | [
"0.61386204",
"0.594458",
"0.5770157",
"0.5747259",
"0.56587195",
"0.555685",
"0.5482608",
"0.5481097",
"0.53574556",
"0.53456044",
"0.52986324",
"0.5290497",
"0.52506703",
"0.51700705",
"0.5093248",
"0.5090371",
"0.5065744",
"0.5023431",
"0.50153744",
"0.50094336",
"0.500867... | 0.6385645 | 0 |
Returns the calculated entropy (according to information theory) of the input message | def entropy(message):
n = len(message)
message = letter_freq(message)
h = 0
for n_i in message.values():
p_i = n_i/n
h += -p_i*(log2(p_i))
return h | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entropy(message):\n message = letter_freq(message)\n n = sum(message.values())\n h = 0\n for n_i in message.values():\n p_i = n_i / n\n h += -p_i * log2(p_i)\n return h",
"def entropy(message):\n # Should the import be here or should it be at the top of the page?\n freq_dic... | [
"0.8179265",
"0.7819709",
"0.7344961",
"0.7160971",
"0.7141463",
"0.71327984",
"0.7111015",
"0.7095652",
"0.706582",
"0.70250344",
"0.7019725",
"0.700042",
"0.69589937",
"0.690922",
"0.68974507",
"0.68952984",
"0.68520355",
"0.6753812",
"0.6741173",
"0.67280805",
"0.671165",
... | 0.8245352 | 0 |
Gets the class_ref of this ExtraLink. | def class_ref(self):
return self._class_ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class(self):\n\t\treturn self.CLASS",
"def class_id(self):\n return self._class_id",
"def get_class_attribute(self):\n return self.class_attr",
"def _class(self):\n return self.__class",
"def class_id(self) -> str:\n return self._class_id",
"def class_id(self) -> str:\... | [
"0.65787274",
"0.6499837",
"0.6441003",
"0.633477",
"0.6297404",
"0.6297404",
"0.60447276",
"0.6017914",
"0.5997474",
"0.5912678",
"0.59080553",
"0.5890727",
"0.586411",
"0.5799989",
"0.5785895",
"0.57600605",
"0.57169163",
"0.56916183",
"0.5678962",
"0.5666141",
"0.56647825"... | 0.81063294 | 0 |
Sets the class_ref of this ExtraLink. | def class_ref(self, class_ref):
self._class_ref = class_ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_id(self, class_id):\n\n self._class_id = class_id",
"def _class(self, _class):\n\n self.__class = _class",
"def _class(self, _class):\n\n self.__class = _class",
"def set_ref(self, new_ref):\n self.__ref = new_ref",
"def class_ref(self):\n return self._class_ref... | [
"0.66160256",
"0.6506323",
"0.6506323",
"0.61303324",
"0.5789517",
"0.5653708",
"0.5653708",
"0.5644072",
"0.56309736",
"0.55408466",
"0.55408466",
"0.5468603",
"0.54295385",
"0.5406994",
"0.53981334",
"0.5388326",
"0.5387655",
"0.5356944",
"0.5233787",
"0.52302057",
"0.51907... | 0.8206257 | 0 |
Merge sentences to one array | def merge_sentences(sentences):
full_sentences = []
for sentence in sentences:
for arr_word in sentence:
full_sentences.append(arr_word)
return full_sentences | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentences(a, b):\n\n # TODO\n return []",
"def sentences(self) -> List[str]:\n\t\treturn [self.text[start:end] for start, end in self.tokenizations]",
"def sentences(self) -> List[str]:\n\t\treturn [self.text[start:end] for start, end in self.tokenizations]",
"def sentences(self) -> List[str]:\n\t\... | [
"0.69770706",
"0.6601281",
"0.6601281",
"0.64054155",
"0.63674307",
"0.636191",
"0.62882817",
"0.6285933",
"0.6236928",
"0.62270564",
"0.6223481",
"0.6192691",
"0.61609006",
"0.61104393",
"0.6108619",
"0.6108619",
"0.6104886",
"0.610436",
"0.6091728",
"0.60737956",
"0.6059608... | 0.7643958 | 0 |
Do pre processing data, tokenization, remove stop words, and stemming | def preprocessing(data):
#tokenizer = RegexpTokenizer(r'\w+') # allow charachter only
#words = tokenizer.tokenize(data) # tokenize : convert to words
words = word_tokenize(data)
# remove stop words & stemming
new_words = []
for word in words:
if word not in stop_words:
new_wo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _preprocess(self):\n self.data['sentences'] = self.data['text'].apply(self._tokenize_sent)\n self.data['nouns'] = self.data['sentences'].apply(self._get_nouns)\n # self._get_frequent_features()\n # self._compactness_pruning()\n # self._redundancy_pruning()\n # self._ge... | [
"0.770828",
"0.73175377",
"0.71628886",
"0.69962186",
"0.69881225",
"0.6972407",
"0.69602007",
"0.6924144",
"0.6921391",
"0.6892576",
"0.6868782",
"0.6824503",
"0.6817865",
"0.6762162",
"0.67592436",
"0.6708688",
"0.6693218",
"0.6692617",
"0.66874915",
"0.66873366",
"0.668497... | 0.82242334 | 0 |
Find activities that are registered multiple times. You should find the query even if you get zero results. | def query_five(self, table_name_activities):
query = (
"SELECT user_id, transportation_mode, start_date_time, end_date_time, COUNT(*) AS NumDuplicates "
"FROM %s "
"GROUP BY user_id, transportation_mode, start_date_time, end_date_time "
"HAVING NumDuplicates >1 "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_activity_occurrences(self):\n pass",
"def get_activities(self, user_id=None, group_id=None, app_id=None,\n activity_id=None, start_index=0, count=0):\n raise NotImplementedError()",
"def activities(self):\n return self._activities",
"def __ui_find_activities... | [
"0.63341004",
"0.57011014",
"0.5677445",
"0.56412303",
"0.5640431",
"0.5504351",
"0.546893",
"0.5462067",
"0.5432692",
"0.54266936",
"0.5410815",
"0.53793097",
"0.53693116",
"0.5323399",
"0.5299379",
"0.5280299",
"0.5255576",
"0.52236176",
"0.52144575",
"0.52102506",
"0.52045... | 0.5983168 | 1 |
Find the number of users which have been close to each other in time and space (Covid19 tracking). Close is defined as the same minute (60 seconds) and space (100 meters). | def query_six(self, table_name_activities, table_name_trackpoints):
query = (
"SELECT t1.user_id, t1.lat, t1.lon, t2.user_id, t2.lat, t2.lon "
"FROM (SELECT user_id, lat, lon, date_time FROM %s inner join %s on Activity.id=TrackPoint.activity_id) as t1, "
"(SELECT user_id, l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearby_openness(game, player):\n radius = 4\n nearby_legal_move_count = 0\n\n current_location = game.get_player_location(player)\n\n min_row = current_location[0] - radius\n max_row = current_location[0] + radius + 1\n min_col = current_location[1] - radius\n max_col = current_location[1]... | [
"0.5593727",
"0.54564375",
"0.5203057",
"0.5095816",
"0.50687665",
"0.50595754",
"0.5052626",
"0.5024759",
"0.5016105",
"0.4969579",
"0.4965821",
"0.49551564",
"0.49421763",
"0.49245408",
"0.4910931",
"0.4900106",
"0.48929957",
"0.48916903",
"0.48914006",
"0.48905036",
"0.488... | 0.5606755 | 0 |
Find all types of transportation modes and count how many distinct users that have used the different transportation modes. Do not count the rows where the transportation mode is null. | def query_eight(self, table_name):
query = (
"SELECT transportation_mode as TransportationMode, COUNT(DISTINCT user_id) as NumDistinctUsers "
"FROM %s "
"WHERE transportation_mode <> 'None' "
"GROUP BY transportation_mode"
)
self.cursor.execute(qu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_type_counts(self):\n names = self.visible()\n return {\n 'total': names.count(),\n 'personal': len([n for n in names if n.is_personal()]),\n 'organization': len([n for n in names if n.is_organization()]),\n 'event': len([n for n in names if n.is_... | [
"0.61126447",
"0.5563086",
"0.55279905",
"0.5462258",
"0.5416903",
"0.52652234",
"0.5176184",
"0.51421887",
"0.5133025",
"0.5132203",
"0.5088221",
"0.5081676",
"0.50632614",
"0.50608855",
"0.502527",
"0.49960738",
"0.498637",
"0.49753973",
"0.49554306",
"0.49297845",
"0.49210... | 0.57151276 | 1 |
b) Which user had the most activities this year and month, and how many recorded hours do they have? Do they have more hours recorded than the user with the second most activities? | def query_nine_b(self, table_name_activities):
query = (
"SELECT user_id, COUNT(*) AS ActivityCount"
", SUM(TIMESTAMPDIFF(HOUR, start_date_time, end_date_time)) as HoursActive "
"FROM %s "
"WHERE YEAR(start_date_time) = '2008' AND MONTH(start_date_time) = '11' "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nCalculating The Most Frequent Times of Travel...\\n')\n start_time = time.time()\n\n # TO DO: display the most common month\n if len(df['Month'].unique()) != 1:\n a = df['Month'].mode()[0]\n print('The most popular month: ', a)\n\n # TO DO: display th... | [
"0.6475652",
"0.64616454",
"0.64578974",
"0.64363235",
"0.64292324",
"0.6413384",
"0.6412211",
"0.640618",
"0.6394706",
"0.6383782",
"0.63697183",
"0.6365011",
"0.63590086",
"0.63465524",
"0.6344959",
"0.6342446",
"0.6331201",
"0.6329994",
"0.63283557",
"0.6324795",
"0.632194... | 0.6653954 | 0 |
For a given transfer sent to echo node, get the corresponding echoed transfer | def get_echoed_transfer(sent_transfer):
app = address_to_app[sent_transfer.initiator]
events = RaidenAPI(app.raiden).get_raiden_events_payment_history(
token_address=token_address,
)
def is_valid(event):
return (
type(event) == EventPaymentReceive... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transfer(self):\n return self._transfer",
"def get_transfer_output_and_socket(ftp):\n try:\n transfer_type = transfer_menu()\n if transfer_type == \"1\":\n output, sock = ftp.port_cmd()\n elif transfer_type == \"2\":\n output, sock = ftp.pasv_cmd()\n ... | [
"0.5897282",
"0.5155022",
"0.5014647",
"0.48934287",
"0.48728555",
"0.48627025",
"0.48430175",
"0.48427844",
"0.4825058",
"0.48053637",
"0.47954482",
"0.47850862",
"0.47134098",
"0.47083998",
"0.4707706",
"0.46917704",
"0.4689539",
"0.46554816",
"0.46517766",
"0.46489337",
"0... | 0.7087603 | 0 |
Get the latest refresh datetime of a cohort. Returns current time formatted as a string if the field is not found. | def get_cohort_refresh_datetime(utm_id):
# @TODO MOVE DB REFS INTO QUERY MODULE
conn = dl.Connector(instance=settings.__cohort_data_instance__)
query = """ SELECT utm_touched FROM usertags_meta WHERE utm_id = %s """
conn._cur_.execute(query, int(utm_id))
utm_touched = None
try:
utm_tou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_last_meas_time(self):\n\n #if flag for whole data regeneration is set\n if self._process_type == 'full_gen':\n return datetime.datetime(1900, 1, 1, 0, 0, 0)\n \n \n res = self._db.Query(\"\"\"SELECT last_measurement_time\n FROM last... | [
"0.62165296",
"0.616487",
"0.6088386",
"0.60617465",
"0.6045005",
"0.5971621",
"0.5926703",
"0.5917341",
"0.59016716",
"0.58545",
"0.5838771",
"0.5812011",
"0.57949024",
"0.5793899",
"0.57753074",
"0.57753074",
"0.5775221",
"0.5765011",
"0.5749749",
"0.5748395",
"0.5720312",
... | 0.7260143 | 0 |
Extract data from the global hash given a request object. If an item is successfully recovered data is returned | def get_data(request_meta, hash_result=True):
hash_table_ref = read_pickle_data()
# Traverse the hash key structure to find data
# @TODO rather than iterate through REQUEST_META_BASE &
# REQUEST_META_QUERY_STR look only at existing attributes
logging.debug(__name__ + " - Attempting to pull data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_request(self, request):\n adapter = self.url_map.bind_to_environ(request.environ)\n endpoint, values = adapter.match()\n\n request_data = request.get_data(as_text=True)\n param = json.loads(request_data) if request_data else {}\n\n context_data = request.headers.get('X-S... | [
"0.56379586",
"0.5580467",
"0.54474115",
"0.54155",
"0.5414851",
"0.53585744",
"0.5352306",
"0.53308815",
"0.531813",
"0.5292978",
"0.5292057",
"0.5272722",
"0.5263837",
"0.5239827",
"0.52351373",
"0.5232972",
"0.5226501",
"0.5200576",
"0.5200576",
"0.5200576",
"0.51960737",
... | 0.60611254 | 0 |
Given request metadata and a dataset create a key path in the global hash to store the data | def set_data(data, request_meta, hash_result=True):
hash_table_ref = read_pickle_data()
key_sig = build_key_signature(request_meta, hash_result=hash_result)
logging.debug(__name__ + " :: Adding data to hash @ key signature = {0}".
format(str(key_sig)))
if hash_result:
key_sig_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_external_key(self, data):\n return data['key']",
"def upload():\n \n if request.method == 'GET':\n return jsonify({'status': 'Error!', 'message': 'Please use POST request'})\n else:\n data = session['data']\n arg1 = data['arg1'].lower()\n rel = data['rel'].low... | [
"0.57468635",
"0.54577863",
"0.5405114",
"0.5376858",
"0.53746635",
"0.5367215",
"0.5360612",
"0.53402084",
"0.5338125",
"0.53335136",
"0.53268045",
"0.5267196",
"0.5259356",
"0.52559704",
"0.5184614",
"0.51756406",
"0.5161057",
"0.5160552",
"0.5157643",
"0.5156853",
"0.51519... | 0.617912 | 0 |
Given a RequestMeta object contruct a hashkey. | def build_key_signature(request_meta, hash_result=False):
key_sig = list()
# Build the key signature -- These keys must exist
for key_name in REQUEST_META_BASE:
key = getattr(request_meta, key_name)
if key:
key_sig.append(key_name + HASH_KEY_DELIMETER + key)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_key(\n request: PreparedRequest,\n ignored_params: Iterable[str] = None,\n include_get_headers: bool = False,\n **kwargs,\n) -> str:\n key = hashlib.sha256()\n key.update(encode((request.method or '').upper()))\n url = remove_ignored_url_params(request, ignored_params)\n url = ur... | [
"0.6666289",
"0.6348019",
"0.61674154",
"0.6050588",
"0.5945049",
"0.5932106",
"0.5922866",
"0.5905479",
"0.5856865",
"0.5832915",
"0.581081",
"0.580476",
"0.5729224",
"0.571339",
"0.5685138",
"0.5685138",
"0.56837296",
"0.56794053",
"0.5674972",
"0.56635183",
"0.56480783",
... | 0.68788236 | 0 |
Compose a url from a set of keys | def get_url_from_keys(keys, path_root):
query_str = ''
for key in keys:
parts = key.split(HASH_KEY_DELIMETER)
if parts[0] in REQUEST_META_BASE:
path_root += parts[1] + '/'
elif parts[0] in REQUEST_META_QUERY_STR:
query_str += parts[0] + '=' + parts[1] + '&'
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_url(api_key, url, args=None):\n if args is None:\n args = []\n argsep = '&'\n if '?' not in url:\n argsep = '?'\n if '?apiKey=' not in url and '&apiKey=' not in url:\n args.insert(0, ('apiKey', api_key))\n return url + argsep + '&'.join(['='.join(t) for t in args])",
... | [
"0.6878986",
"0.65894485",
"0.649509",
"0.6402911",
"0.6257756",
"0.60850906",
"0.60804915",
"0.6013498",
"0.5980712",
"0.5920877",
"0.58935153",
"0.58797026",
"0.5854093",
"0.58360004",
"0.57937574",
"0.5785422",
"0.57762593",
"0.57590055",
"0.5758113",
"0.5753998",
"0.57346... | 0.7288405 | 0 |
To determine whether a coor in inside or on the fringe of a rectangular coor is a tuple of two numbers. rec is represented with a list of 4 coor of the 4 corner | def isIn(self, coor, rec):
x, y = coor[0], coor[1]
top, bottom, left, right = rec[1][1], rec[0][1], rec[0][0], rec[1][0]
# print(top, bottom, left, right)
if left <= x <= right and bottom <= y <= top:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corners((u,v)):\r\n return ((u+1,v+1), (u+1,v), (u,v), (u,v+1))",
"def overlap_rect(rec1, rec2):\n # true if rec2 is left of rec1\n a = rec2[2] <= rec1[0]\n \n # true if rec2 is right of rec1\n b = rec1[2] <= rec2[0]\n\n # true if rec2 is below rec1\n c = rec2[3] <= rec1[1]\n\n # t... | [
"0.59030926",
"0.58912385",
"0.58596796",
"0.5801079",
"0.57638234",
"0.5733983",
"0.57246816",
"0.57164705",
"0.5706039",
"0.5702762",
"0.5688784",
"0.5657079",
"0.564293",
"0.5626091",
"0.56171894",
"0.5584251",
"0.5580394",
"0.5574595",
"0.55681694",
"0.55593956",
"0.55397... | 0.7361468 | 0 |
Convert idx to state array structured according to dims_state_grid | def state_from_id(index, dims_state_grid):
entries = [index] * len(dims_state_grid)
for i in range(1, len(dims_state_grid)):
value = 1
for j in range(i, len(dims_state_grid)):
value *= dims_state_grid[j]
for k in range(i - 1, len(dims_state_grid)):
if k == i - 1:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_state(state):\n grid = state.grid\n pos = state.pos\n reshaped_grid = np.reshape(grid,(1, grid_size*grid_size)) # Only use squared for square matrices\n reshaped_grid = reshaped_grid[0]\n processed_state = np.concatenate((pos, reshaped_grid))\n processed_state = np.array([processed_st... | [
"0.65787387",
"0.6121556",
"0.58805615",
"0.5752284",
"0.5732881",
"0.5709797",
"0.55998015",
"0.55990964",
"0.556733",
"0.55428475",
"0.5519896",
"0.55152744",
"0.5499255",
"0.54791164",
"0.54601943",
"0.54572254",
"0.5454298",
"0.5431956",
"0.5429013",
"0.5424711",
"0.54229... | 0.7723534 | 0 |
Calculate mean squared error. If ``x1`` and ``x2`` have different shapes, then they need to broadcast. This uses | def mse(x1, x2, axis=0):
x1 = np.asanyarray(x1)
x2 = np.asanyarray(x2)
return np.mean((x1 - x2) ** 2, axis=axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_squared_error(x0, x1):\n return MeanSquaredError()(x0, x1)",
"def msre(x1, x2, axis=0):\n x1 = np.asanyarray(x1)\n x2 = np.asanyarray(x2)\n return np.mean((((x1 - x2) ** 2) / x1), axis=axis)",
"def _mean_squared_error(img1, img2):\n err = np.sum((img1.astype(\"float\") - img2.astype(\"f... | [
"0.8226302",
"0.7394932",
"0.70136625",
"0.70063365",
"0.68697226",
"0.67129135",
"0.659804",
"0.65663034",
"0.65424967",
"0.64867127",
"0.64791524",
"0.6449142",
"0.64091104",
"0.63836336",
"0.62251514",
"0.6153482",
"0.6134623",
"0.6100003",
"0.60949916",
"0.59974325",
"0.5... | 0.7577179 | 1 |
Show rows cols random samples from a batch (without labels). | def show_random_samples(batch, rows=5, cols=5, width=None, height=None, shuffle=True):
if width is None: width = 1.5*cols
if height is None: height = 1.5*rows
if rows * cols == 1:
axes = [plt.subplots(rows, cols, figsize=(width, height))[1]]
else:
axes = plt.subplots(rows, cols, figsize... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_samples(model, dataset, epoch, logs, X_dev_batch, y_dev_batch):\n\n for _ in range(10):\n ind = random_randint(0, len(X_dev_batch))\n row_X, row_y = X_dev_batch[np.array([ind])], y_dev_batch[np.array([ind])]\n preds = model.predict_classes(row_X, verbose=0)\n q = dataset.cha... | [
"0.64462656",
"0.6371136",
"0.63103604",
"0.6304433",
"0.622922",
"0.6163216",
"0.6106708",
"0.59904164",
"0.5981648",
"0.59786355",
"0.5977816",
"0.5953265",
"0.58819944",
"0.5839658",
"0.5830676",
"0.5830318",
"0.58296937",
"0.5824432",
"0.5812563",
"0.58024067",
"0.5784958... | 0.79881436 | 0 |
Adds schema copying to the end of a pipeline. When the pipeline already has a final node, then the all except the last command are run before the copying, and the last command after. | def add_schema_copying_to_pipeline(pipeline: Pipeline, schema_name,
source_db_alias: str, target_db_alias: str,
max_number_of_parallel_tasks: int = 4):
task_id = "copy_schema"
description = f"Copies the {schema_name} schema to the {target_db_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, pipeline):\n for stage in pipeline.pipe:\n self._pipe.append(stage)\n return self",
"def _copy_chunk(self, last_pk):\n self.execute(self.commands.copy_chunk(\n self.name,\n self._join_cols(self.intersection.dest_columns),\n self._q... | [
"0.5802347",
"0.5191208",
"0.51351225",
"0.51165193",
"0.50928503",
"0.5007843",
"0.4984623",
"0.4981267",
"0.49188995",
"0.4882613",
"0.48803213",
"0.4875119",
"0.48523596",
"0.48431078",
"0.48389772",
"0.48251715",
"0.4806743",
"0.47955215",
"0.47856268",
"0.47797322",
"0.4... | 0.6730207 | 0 |
Return the periods of thetrajectory of neuron i | def get_periods(indexes, step):
period = np.array([indexes[j+1] - indexes[j] for j in range(len(indexes) -1)])*step
return period | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_periods(a,t):\n ex = get_extrema(a,t)[1]\n \n l = ipol(ex,0)\n \n diff = np.diff(l)\n \n return diff",
"def period(self) -> int:",
"def get_periods():\n return [\n relativedelta(),\n relativedelta(days=6),\n relativedelta(months=1),\n relativedelta(mo... | [
"0.6936276",
"0.61068726",
"0.6073322",
"0.59679854",
"0.58855665",
"0.58448124",
"0.56923974",
"0.5629729",
"0.5613269",
"0.55943346",
"0.5572579",
"0.55323595",
"0.5529906",
"0.55260295",
"0.5525814",
"0.5524414",
"0.5517219",
"0.55161285",
"0.54997855",
"0.54787534",
"0.54... | 0.6372389 | 1 |
Attempt to turn data into a token with key info that's too short. Make sure we get a C{ValueError}. | def testKeyInfoTooShort(self):
key = 5
self.assertRaises(ValueError, dataToToken, key, data='x', keyInfo='xx') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testKeyInfoTooLong(self):\n key = 5\n self.assertRaises(ValueError, dataToToken, key, data='hey',\n keyInfo='xxxxx')",
"def testBadDataToToken(self):\n key = createKey()\n self.assertRaises(ValueError, dataToToken, key, data=self)",
"def testTokenToDataW... | [
"0.70762175",
"0.607703",
"0.60147566",
"0.58342063",
"0.55614984",
"0.5477406",
"0.53772527",
"0.52765024",
"0.5223486",
"0.5218025",
"0.5209739",
"0.52083516",
"0.51871884",
"0.5180023",
"0.5137369",
"0.5118065",
"0.5095644",
"0.50949544",
"0.50814134",
"0.5077386",
"0.5026... | 0.7599055 | 0 |
Attempt to turn data into a token with key info that's too long. Make sure we get a C{ValueError}. | def testKeyInfoTooLong(self):
key = 5
self.assertRaises(ValueError, dataToToken, key, data='hey',
keyInfo='xxxxx') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testKeyInfoTooShort(self):\n key = 5\n self.assertRaises(ValueError, dataToToken, key, data='x', keyInfo='xx')",
"def testBadDataToToken(self):\n key = createKey()\n self.assertRaises(ValueError, dataToToken, key, data=self)",
"def testTokenToDataWithBadKey(self):\n key =... | [
"0.7316048",
"0.6184192",
"0.60824144",
"0.5804973",
"0.57880867",
"0.5631557",
"0.55719686",
"0.5516091",
"0.5458997",
"0.53713936",
"0.5358326",
"0.53580767",
"0.5306614",
"0.52973235",
"0.52792686",
"0.52790624",
"0.52631515",
"0.52393305",
"0.5231974",
"0.52234995",
"0.52... | 0.7421354 | 0 |
Attempt to turn a token into valid data using an invalid key. Make sure we get a C{ValueError}. | def testTokenToDataWithBadKey(self):
key = createKey()
data = {u'user': u'aliafshar'}
token = dataToToken(key, data)
self.assertRaises(ValueError, tokenToData, createKey(), token=token) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testBadDataToToken(self):\n key = createKey()\n self.assertRaises(ValueError, dataToToken, key, data=self)",
"def testBadKeyToToken(self):\n key = 5\n self.assertRaises(ValueError, dataToToken, key, data='hey')",
"def testKeyInfoTooShort(self):\n key = 5\n self.ass... | [
"0.7641556",
"0.7378524",
"0.6560763",
"0.6310796",
"0.62208354",
"0.6214384",
"0.61293644",
"0.595883",
"0.5911464",
"0.5843664",
"0.5817309",
"0.57752836",
"0.5773261",
"0.5734485",
"0.56548244",
"0.5645461",
"0.56449616",
"0.56429386",
"0.5612306",
"0.560686",
"0.55679715"... | 0.80681634 | 0 |
Test that we can roundtrip encrypt / decrypt after forking without error. | def testRoundtripAfterFork(self):
if fork() == 0:
key = createKey()
data = {u'user': u'aliafshar', u'id': u'91821212'}
token = dataToToken(key, data)
self.assertEqual(data, tokenToData(key, token))
# This is horrible, but necessary: Turn the child into... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_encrypt_creates_and_restores_backup(\n self,\n mock_os,\n mock_shutil,\n mock_subprocess,\n ):\n mock_subprocess.run.return_value.returncode = 1\n\n with self.assertRaises(RuntimeError):\n self.mikla.encrypt('Chunky Hunky', 'plain', 'enc')\n\n ... | [
"0.6426856",
"0.6424985",
"0.63377774",
"0.627262",
"0.6084893",
"0.60583663",
"0.5969925",
"0.59437805",
"0.59314126",
"0.58886117",
"0.58823997",
"0.5869974",
"0.5838037",
"0.5835891",
"0.5832072",
"0.58096397",
"0.57812876",
"0.5772174",
"0.5755509",
"0.57499325",
"0.57485... | 0.71512514 | 0 |
Generalises the numerical differentiation function deriv to calculate the partial derivative of a 2D array representing a twovariable function with respect to x or y given by dim | def pderiv2D(field, xld, dim = 0):
n_x, n_y = field.shape
dfield = np.zeros_like(field)
if (dim not in [0, 1]):
raise ValueError("2-D function, enter dim = 0 (df/dx) or dim = 1 (df/dy)")
if (dim == 0):
# check if len(x) equals M
if len(xld) != n_x :
raise ValueError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diffuse_2d(t,y,D,shape):\n m,n = shape\n Fliq0 = np.reshape(np.ascontiguousarray(y),(m,n))\n dy = np.zeros((m,n))\n\n # Calculate derivatives in the interior\n dy[1:-1, 1:-1] = (\n D * (Fliq0[:-2, 1:-1] - 2 * Fliq0[1:-1, 1:-1] + Fliq0[2:, 1:-1])\n + D * (Fliq0[1:-1, :-2] - 2 * Fliq... | [
"0.71400756",
"0.7021378",
"0.70070183",
"0.6926722",
"0.6923472",
"0.6883543",
"0.68410754",
"0.6825765",
"0.6825765",
"0.6823402",
"0.6761243",
"0.6683259",
"0.66645986",
"0.6662775",
"0.6586452",
"0.6581192",
"0.65791905",
"0.6511668",
"0.6491774",
"0.6467675",
"0.6455269"... | 0.73236173 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.