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 |
|---|---|---|---|---|---|---|
Plot the scores obtained by a list of methods on a list of graphs. | def plot_scoring(
graphs: list,
ref_partitions: object,
graph_names: list,
methods: list,
scoring: Callable[
[object, object], object
] = cdlib.evaluation.adjusted_mutual_information,
nbRuns: int = 5,
) -> object:
forDF = []
for i, g in enumerate(graphs):
for m in met... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_graph(self) -> None:",
"def plot_time_advances(self, path: str = None, methods: list = None, title=None):\n df = self.get_results(methods)\n ax = plt.axes()\n sns.lineplot(x='epoch', y='value', data=df, hue='statistics', style='method', ax=ax)\n plt.ylim(-31, 11)\n plt... | [
"0.612018",
"0.60104775",
"0.59162647",
"0.58902407",
"0.5849361",
"0.5841088",
"0.5839306",
"0.5805346",
"0.5803431",
"0.57910824",
"0.57711995",
"0.5769438",
"0.57638323",
"0.57449424",
"0.57376575",
"0.5734237",
"0.5729009",
"0.5682087",
"0.5679241",
"0.5673704",
"0.567118... | 0.7017071 | 0 |
This function returns the elevation based on tif files located in the ./data/elevation/.tif folder using rasterio library. | def get_elevation_data(lat, lon):
logging.info("Getting elevation data for the coordinate ({}, {}).".format(lat, lon))
# Initialising function variables
grid_lat = None
grid_lon = None
coord = (lon, lat)
config_data = get_config()["gis"]
elev_file_name = config_data["input_file_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elevation(x, y):\n file = os.path.abspath(\"..\") + \"\\Shape\\Shape.vrt\"\n layer = gdal.Open(file)\n gt = layer.GetGeoTransform()\n rasterx = int((x - gt[0]) / gt[1])\n rastery = int((y - gt[3]) / gt[5])\n print('elevation =', layer.GetRasterBand(1).ReadAsArray(rasterx, rastery, 1, 1)[0][0]... | [
"0.71581376",
"0.7124947",
"0.64889693",
"0.640733",
"0.6338503",
"0.6217897",
"0.6069941",
"0.6061986",
"0.6008313",
"0.5963957",
"0.5874497",
"0.5836849",
"0.5830222",
"0.572488",
"0.570814",
"0.57011336",
"0.5688908",
"0.564884",
"0.56215036",
"0.5600793",
"0.55930495",
... | 0.7472302 | 0 |
This function retrieves the baseline historical weather data supplied in 'location key' of config.yaml. It uses Dark Sky API to retrieve historical weather data such as temperature, humidity and pressure. | def get_gis_historical_data():
logging.info("Generating baseline reference and historical weather data.")
# Initialising function variables
fake = Faker()
geolocator = Nominatim()
config_data = get_config()
locations = config_data["location"]
# Check if there are no duplicate locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weather_data(weather_station):\n now = datetime.datetime.now()\n then = now - datetime.timedelta(days=7)\n\n query_date_start = (\"%d%02d%02d\" % (then.year, then.month, then.day))\n query_date_end = (\"%d%02d%02d\" % (now.year, now.month, now.day))\n\n api_key = '/api/%s' % WUNDERGROUND_KEY... | [
"0.65205216",
"0.63677955",
"0.6169985",
"0.5902983",
"0.58921283",
"0.58830535",
"0.5816516",
"0.5792356",
"0.577339",
"0.57286644",
"0.57247823",
"0.572364",
"0.56794244",
"0.5657562",
"0.5617185",
"0.55872756",
"0.55848914",
"0.55707026",
"0.5563872",
"0.5557767",
"0.55350... | 0.6846133 | 0 |
This function aggregates baseline historical data by location and month | def aggregate_gis_historical_data():
logging.info("Processing historical weather data aggregation.")
# Initialising function variables
config_data = get_config()
# Initialise pandas dataframe column name for baseline reference
# and historical data.
hist_file_path = get_file_path(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gis_historical_data():\n logging.info(\"Generating baseline reference and historical weather data.\")\n \n # Initialising function variables\n fake = Faker()\n geolocator = Nominatim()\n config_data = get_config()\n locations = config_data[\"location\"]\n \n # Check if there are ... | [
"0.58381313",
"0.5734232",
"0.56948924",
"0.5653308",
"0.5646137",
"0.554423",
"0.5541146",
"0.5489446",
"0.5416555",
"0.5412332",
"0.5408023",
"0.536637",
"0.53220284",
"0.52999943",
"0.5291678",
"0.5265832",
"0.52515584",
"0.52434707",
"0.523636",
"0.52346766",
"0.5223585",... | 0.6543381 | 0 |
Constructs a densenet201 model. | def densenet201(pretrained=False, **kwargs):
model = ResNetFeatures(BasicBlock, [3, 4, 6, 3], **kwargs)
if pretrained:
_load_pretrained(model, model_zoo.load_url(model_urls['densenet201']))
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_model(self):\n if self.model_type=='densenet_121':\n model = self.make_densenet_121(self.weights)\n\n\n return model",
"def create_model():\r\n parser = argparse.ArgumentParser()\r\n parser.add_argument('--DISC_LR', type=float, default=1e-4)\r\n parser.add_argument('--GEN_LR'... | [
"0.74119705",
"0.66543114",
"0.66498333",
"0.6570754",
"0.64200634",
"0.63234144",
"0.62984204",
"0.6281156",
"0.6251362",
"0.6214036",
"0.617731",
"0.61620563",
"0.6139047",
"0.6125915",
"0.6096478",
"0.6096478",
"0.6068243",
"0.60617614",
"0.6011719",
"0.6006324",
"0.599229... | 0.7408212 | 1 |
This method is called whenever data is received from a client. The only message that a client sends to the server is a RPC Request message. If the RPC Request message is valid, then the method is called in a thread | def dataReceived(self, data):
if self.__buffer:
# We have some data from the last dataReceived() so lets prepend it
data = self.__buffer + data
self.__buffer = None
while data:
dobj = zlib.decompressobj()
try:
request = rencode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dispatch_from_client_request(self):\n # Listen for client connection\n self._from_client_request.listen()\n\n while not self._exit_request:\n readable, _, _ = select([self._from_client_request], [], [self._from_client_request], 0.1)\n\n if readable:\n ... | [
"0.68748134",
"0.6768327",
"0.6757667",
"0.67148477",
"0.6711134",
"0.66720986",
"0.66720986",
"0.66050917",
"0.6565084",
"0.65585506",
"0.6556971",
"0.6539188",
"0.6431191",
"0.64153564",
"0.6412267",
"0.638672",
"0.6384882",
"0.6378129",
"0.6362476",
"0.6343157",
"0.6317066... | 0.70811373 | 0 |
Load data from disk. If ``kind`` is `gwosc` assumes input is an strain HDF5 file downloaded | def read(cls, path, kind=None, **kws):
kind = (kind or '').lower()
if not kind:
# attempt to guess filetype
ext = os.path.splitext(path)[1].lower().strip('.')
if ext in ['h5', 'hdf5', 'hdf']:
kind = 'hdf'
elif ext in ['txt', 'gz', 'dat', 'c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def training_data(kind, depth = 5):\n\n if kind == 'unigram':\n return UnigramTrainingData.load(UNIGRAM_DIR + str(depth))\n\n if kind == 'rnn':\n return RNNTrainingData.load(RNN_DIR + str(depth))",
"def load_mnist(path, kind='train'):\n labels_path = os.path.join(path,'%s-labels-idx1-ubyte... | [
"0.5953198",
"0.5252723",
"0.5231705",
"0.50929207",
"0.50844127",
"0.50709325",
"0.506653",
"0.5061513",
"0.50486684",
"0.5040646",
"0.5024534",
"0.5007193",
"0.5007193",
"0.50033534",
"0.49804032",
"0.4952549",
"0.4922163",
"0.49177516",
"0.4917272",
"0.49139136",
"0.491180... | 0.60233635 | 0 |
Return cyclic ACF corresponding to PSD obtained by inverse Fourier transforming. Returns | def to_acf(self):
rho = 0.5*np.fft.irfft(self) / self.delta_t
return AutoCovariance(rho, delta_t=self.delta_t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PSD_to_ACF(freq, psd, lags):\n freq_sym = np.append(-freq[::-1], freq) \n psd_sym = np.append(psd[::-1], psd)\n\n steps = freq_sym[1:] - freq_sym[:-1]\n height = psd_sym[1:]\n\n # nd = np.tile(freq_sym[1:], (len(lags), 1)).T\n nd = np.tile(freq_sym, (len(lags), 1)).T\n\n # acf = np.cos(-2*... | [
"0.66626525",
"0.6300266",
"0.6267516",
"0.6267516",
"0.626026",
"0.61031294",
"0.6091076",
"0.59904426",
"0.5905221",
"0.5882946",
"0.58500314",
"0.5722968",
"0.571717",
"0.57079524",
"0.57078564",
"0.56853944",
"0.56747645",
"0.56401896",
"0.5640028",
"0.56299365",
"0.55929... | 0.640065 | 1 |
Get an output/input variable. | def __getitem__(self, name):
if self.outputs is not None:
try:
return self.outputs[name]
except KeyError:
if name in self._auto_ivc_map:
return self.inputs[self._auto_ivc_map[name]]
if self.inputs is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_output(self, **kwargs):\n with tf.variable_scope(self.layer_scope):\n return self.out",
"def get_variable(self, name):\n if self._scalamagic:\n intp = self.scala_interpreter\n intp.interpret(name)\n return intp.last_result()",
"def inputValue(se... | [
"0.6752224",
"0.6591138",
"0.6557258",
"0.6555575",
"0.6506442",
"0.63788795",
"0.63788795",
"0.63788795",
"0.63788795",
"0.63788795",
"0.63788795",
"0.6339062",
"0.63368",
"0.632077",
"0.6307426",
"0.6247665",
"0.62285554",
"0.619877",
"0.619877",
"0.619877",
"0.619877",
"... | 0.6600384 | 1 |
Get the units for a variable name. | def _get_units(self, name):
meta = self._abs2meta
if name in meta:
return meta[name]['units']
proms = self._prom2abs
if name in proms['output']:
abs_name = proms['output'][name][0]
return meta[abs_name]['units']
elif name in proms['input']:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_units(self, variable):\n try:\n units = self.dataset[variable].units\n return units\n except:\n return None",
"def getResRatioVarUnit( self, name ):\n\n if not self.resNames:\n self.updateAdb( )\n... | [
"0.74081725",
"0.7261851",
"0.71404684",
"0.71044797",
"0.7081885",
"0.7070995",
"0.69846416",
"0.6925272",
"0.6917649",
"0.6912531",
"0.69123954",
"0.6894977",
"0.6651058",
"0.659811",
"0.65960217",
"0.65913147",
"0.6581691",
"0.6579393",
"0.6524793",
"0.6490647",
"0.6450717... | 0.8026463 | 0 |
Get the values of the design variables, as seen by the driver, for this case. | def get_design_vars(self, scaled=True, use_indices=True):
return self._get_variables_of_type('desvar', scaled, use_indices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printDesignVariables(self):\n print(\"-\" * 85)\n print(\"{:>30}{:>20}{:>20}\".format(\"CSM Design Parameter\", \"Name\", \"Value\"))\n print(\"-\" * 85)\n for dvName in self.DVs:\n DV = self.DVs[dvName]\n print(f\"{DV.csmDesPmtr:>30}{DV.name:>20}{DV.value:>20}... | [
"0.68563646",
"0.6626772",
"0.6534895",
"0.6532961",
"0.651272",
"0.6484132",
"0.64549094",
"0.6451239",
"0.6384466",
"0.633503",
"0.6333191",
"0.63260627",
"0.6310112",
"0.6295249",
"0.628637",
"0.62795824",
"0.62777877",
"0.6180956",
"0.6172419",
"0.61514163",
"0.61485827",... | 0.7145759 | 0 |
Write table of variable names, values, residuals, and metadata to out_stream. | def _write_table(self, var_type, var_data, hierarchical, print_arrays, out_stream):
if out_stream is None:
return
# Make a dict of variables. Makes it easier to work with in this method
var_dict = OrderedDict()
for name, vals in var_data:
var_dict[name] = vals
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_table_vehicles(io_stream, vnumber, vcapacity):\n io_stream.write('table vehicle\\n')\n io_stream.write('id;volume;weight;fixed_cost;variable_cost\\n')\n for i in range(0, vnumber):\n row = [i, vcapacity, vcapacity, 0.0, 1.0]\n row = [str(e) for e in row]\n io_stream.write(';... | [
"0.6095418",
"0.6072536",
"0.5994893",
"0.5944242",
"0.59246516",
"0.5886715",
"0.5735065",
"0.5709688",
"0.5703924",
"0.56810933",
"0.56685746",
"0.5661571",
"0.56249696",
"0.5596444",
"0.5583554",
"0.5554277",
"0.55315995",
"0.55291486",
"0.54729015",
"0.5462207",
"0.545514... | 0.66337454 | 0 |
Get the absolute and promoted name versions of the provided derivative key. | def _deriv_keys(self, key):
prom2abs = self._prom2abs
abs2prom = self._abs2prom
DERIV_KEY_SEP = self._DERIV_KEY_SEP
# derivative could be tuple or string, using absolute or promoted names
if isinstance(key, tuple):
of, wrt = key
else:
of, wrt = k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolute_names(self):\n DERIV_KEY_SEP = self._DERIV_KEY_SEP\n\n for key in self._keys:\n if DERIV_KEY_SEP in key:\n # return derivative keys as tuples instead of strings\n of, wrt = key.split(DERIV_KEY_SEP)\n yield (of, wrt)\n els... | [
"0.62433356",
"0.5751408",
"0.56088847",
"0.52073133",
"0.50863856",
"0.49969488",
"0.49366152",
"0.49324927",
"0.4900794",
"0.48926795",
"0.4873144",
"0.48243654",
"0.4822273",
"0.47954556",
"0.47884956",
"0.47645155",
"0.47629976",
"0.47306743",
"0.46946052",
"0.46438673",
... | 0.740441 | 0 |
Yield absolute names for variables contained in this dictionary. Similar to keys() but with absolute variable names instead of promoted names. Yields str absolute names for variables contained in this dictionary. | def absolute_names(self):
DERIV_KEY_SEP = self._DERIV_KEY_SEP
for key in self._keys:
if DERIV_KEY_SEP in key:
# return derivative keys as tuples instead of strings
of, wrt = key.split(DERIV_KEY_SEP)
yield (of, wrt)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vars(cls):\n for key in dir(cls):\n if key.startswith('var_'):\n yield key[4:]",
"def _var_name_generator():\n count = itertools.count()\n while True:\n yield '_var_' + str(count.next())",
"def items(self, deep=False):\n for var in self.vars(deep):\n ... | [
"0.6477693",
"0.6199682",
"0.6083263",
"0.6010082",
"0.5916821",
"0.58778125",
"0.5876126",
"0.586796",
"0.5736524",
"0.57143927",
"0.56993145",
"0.5647373",
"0.5647242",
"0.5587756",
"0.5552013",
"0.553918",
"0.55298007",
"0.5525652",
"0.5451237",
"0.5448552",
"0.542522",
... | 0.67446005 | 0 |
Get audit logs, sort by time in in reverse chronological order. This API returns the first 10,000 results only. Please use filter in the API for more relevant results. MSP Customer Would see logs of MSP's and tenants as well. | def get_traillogs(self, conn, limit=100, offset=0, username=None, start_time=None,
end_time=None, description=None, target=None, classification=None,
customer_name=None, ip_address=None, app_id=None):
path = urls.TRAIL_LOG["GET_ALL"]
params = {
"li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetLogs(self):\n utcnow = datetime.datetime.utcnow()\n lower_filter = self.log_position.GetFilterLowerBound()\n upper_filter = self.log_position.GetFilterUpperBound(utcnow)\n new_filter = self.base_filters + [lower_filter, upper_filter]\n entries = logging_common.FetchLogs(\n log_filter='... | [
"0.7129476",
"0.6680837",
"0.66445136",
"0.6628818",
"0.6558355",
"0.6427984",
"0.6388969",
"0.63801205",
"0.6173607",
"0.6146164",
"0.6146164",
"0.6137496",
"0.6091237",
"0.6076141",
"0.60328996",
"0.60099995",
"0.59999657",
"0.5991797",
"0.59658474",
"0.5960705",
"0.5949625... | 0.67995703 | 1 |
Get audit events for all groups, sort by time in in reverse chronological order.This API returns the first 10,000 results only. Please use filter in the API for more relevant results. | def get_eventlogs(self, conn, limit=100, offset=0, group_name=None, device_id=None,
classification=None, start_time=None, end_time=None):
path = urls.EVENT_LOG["GET_ALL"]
params = {
"limit": limit,
"offset": offset
}
if group_name:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_log_events(client, log_group):\n\n\tresp = client.filter_log_events(logGroupName=log_group, limit=10000)\n\treturn resp['events']",
"def list_events(\n self,\n project_name,\n group_id,\n service_filter=None,\n time_range=None,\n page_size=None,\n retry=go... | [
"0.70322144",
"0.61524975",
"0.604581",
"0.5978046",
"0.5915792",
"0.5767054",
"0.5700942",
"0.5694042",
"0.5663286",
"0.5598019",
"0.55365473",
"0.55105114",
"0.54919237",
"0.54886174",
"0.54715794",
"0.5468754",
"0.5455551",
"0.54503524",
"0.5448905",
"0.5447147",
"0.540073... | 0.65729 | 1 |
Get details of an audit event/log | def get_eventlogs_detail(self, conn, id):
path = urlJoin(urls.EVENT_LOG["GET"], id)
resp = conn.command(apiMethod="GET", apiPath=path)
return resp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def async_describe_logbook_event(event): # type: ignore\n data = event.data\n message = \"has been triggered\"\n if ATTR_SOURCE in data:\n message = f\"{message} by {data[ATTR_SOURCE]}\"\n return {\n \"name\": data.get(ATTR_NAME),\n \"message\": message... | [
"0.6821845",
"0.6652355",
"0.6543476",
"0.6522972",
"0.64650506",
"0.6413855",
"0.6246624",
"0.62311846",
"0.62180877",
"0.6201794",
"0.61936474",
"0.6179406",
"0.617823",
"0.61002064",
"0.60831964",
"0.60831964",
"0.6037114",
"0.60080445",
"0.5976022",
"0.59753305",
"0.59753... | 0.7285483 | 0 |
Checking with Microsoft Font Validator. | def com_google_fonts_check_fontvalidator(font):
# In some cases we want to override the severity level of
# certain checks in FontValidator:
downgrade_to_warn = [
# There are reports that this fontval check has an out-of-date
# understanding of valid bits in fsSelection.
# More info... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_opentype_familyname(self):\n font = Font.get_ttfont(self.operator.path)\n self.assertEqual(font.ot_family_name, font.familyname)",
"def test_check_opentype_stylename(self):\n stylename_mapping = {\n 'Regular': ['Thin', 'Light', 'Extra Light', 'Regular',\n ... | [
"0.66999376",
"0.6561339",
"0.6518208",
"0.6518208",
"0.6447985",
"0.64417946",
"0.64289904",
"0.6428117",
"0.64090306",
"0.64015275",
"0.63722837",
"0.63663197",
"0.63632476",
"0.63315845",
"0.6312507",
"0.6307867",
"0.6289573",
"0.6289573",
"0.6258024",
"0.62548333",
"0.622... | 0.7043042 | 0 |
Instantiate the class with a database instance and also an SMTP instance which is responsible for sending confirmation emails. Also set available timeslots that people can book for. | def __init__(self, database_manager=DataBaseManager(), emailer=EmailSender()):
self.database_manager = database_manager
self.emailer = emailer
# Set available timeslots
self.initial_time_slots = ['09:00:00',
'10:00:00',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, user, password, _recipients, templatedir='templates'):\n\n self.user = user\n self.password = password\n self.recipient = _recipients if type (_recipients) is list else [_recipients]\n self.server = 'smtp.gmail.com'\n self.port = 587\n\n if os.path.isdir... | [
"0.593538",
"0.57756203",
"0.5749966",
"0.5713733",
"0.57021195",
"0.5693684",
"0.56859493",
"0.56799823",
"0.566929",
"0.56081414",
"0.55958164",
"0.5573325",
"0.55702955",
"0.55215466",
"0.54456973",
"0.5395605",
"0.5392591",
"0.53879774",
"0.5381332",
"0.5368475",
"0.53641... | 0.7780047 | 0 |
Getting the date of 7 days later from current day. | def next_seven_day(self):
today = datetime.date.today()
week_next = today + datetime.timedelta(days=7)
return week_next.strftime('%Y-%m-%d') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_week_date():\n return timezone.now()+timezone.timedelta(days=6)",
"def get_prev_weekday(x: Optional[Date] = None) -> Date:\n ## Get the day:\n x = x or get_today()\n\n ## Define the offset:\n offset = max(1, (x.weekday() + 6) % 7 - 3)\n\n ## Compute the day and return:\n return x - T... | [
"0.69482285",
"0.67034215",
"0.6692377",
"0.66036826",
"0.6488771",
"0.6337313",
"0.63113797",
"0.6233774",
"0.61356586",
"0.61312723",
"0.6130495",
"0.6126569",
"0.6113718",
"0.60930926",
"0.6027795",
"0.5993995",
"0.5991983",
"0.5979135",
"0.59749365",
"0.59516615",
"0.5949... | 0.7539515 | 0 |
Convert a date into weekday string form | def get_the_weekday(self,date):
date_convert = date.split('-')
week_days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
date_list = [int(i) for i in date_convert]
day = datetime.date(date_list[0], date_list[1], date_list[2])
# convert weekday int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_of_week(date: datetime) -> str:\n weekday = date.weekday()\n return calendar.day_name[weekday]",
"def date_to_day_of_week(date):\n return date.weekday()",
"def get_weekday_number(date):\n return date.strftime('%w')",
"def date_day_of_week(date):\n day_of_week = date.strftime('%A')\n ... | [
"0.78104866",
"0.76651293",
"0.7552025",
"0.7451308",
"0.7268718",
"0.71907043",
"0.7140627",
"0.7097642",
"0.7082069",
"0.70273197",
"0.7010225",
"0.69217354",
"0.6881678",
"0.6690514",
"0.6657678",
"0.6657678",
"0.66044676",
"0.6601838",
"0.6588213",
"0.6588213",
"0.6588213... | 0.79862875 | 0 |
Check if a given date is a weekday and if not, we tell user they cannot book that day. Also check if the booking day is inside our allowed range which is one week. | def check_weekday(self, date):
week_next = self.next_seven_day()
today = datetime.date.today().strftime('%Y-%m-%d')
if not date or date > week_next or date < today: # check the date is within one week
return False, "Sorry you can only booking consultation up to next one week. Your b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_weekday_of_date(self, date):\n return date.isoweekday() % 7",
"def sleep_in(weekday, vacation):\r\n if not weekday or vacation:\r\n return True\r\n return False",
"def sleep_in(weekday, vacation):\r\n if not weekday or vacation:\r\n return True\r\n else:\r\n re... | [
"0.7051321",
"0.6796055",
"0.67910826",
"0.6701195",
"0.65922606",
"0.6474264",
"0.6421613",
"0.6387774",
"0.63600135",
"0.6227869",
"0.61653614",
"0.6164587",
"0.61135364",
"0.60949105",
"0.60126436",
"0.5992501",
"0.5977553",
"0.59321845",
"0.5889374",
"0.58726126",
"0.5809... | 0.7207394 | 0 |
Get list of available times that are booked for a given date and course | def get_time_slots(self, cid, date):
query = "SELECT time from consultation where cid = %s and date = %s"
inputs = (cid, date)
array_book = self.database_manager.execute_query(query, inputs)
array_book = [e[0] for e in array_book]
booked = array_book if array_book else []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_avail_time_slots(self, cid, date):\n booked = self.get_time_slots(cid, date)\n avail_time_slots = []\n for time in self.initial_time_slots:\n if time not in booked:\n avail_time_slots.append(time)\n return avail_time_slots",
"def consultation_booking_... | [
"0.73901004",
"0.6602472",
"0.6398043",
"0.63878804",
"0.6345009",
"0.6186943",
"0.61377203",
"0.605541",
"0.5960356",
"0.5856391",
"0.57217366",
"0.56533283",
"0.5651054",
"0.5642533",
"0.56393796",
"0.5614545",
"0.5546214",
"0.5517886",
"0.5516936",
"0.5475233",
"0.54484606... | 0.7257012 | 1 |
Given a course id and a date, get the list of not booked time on that date for that course | def get_avail_time_slots(self, cid, date):
booked = self.get_time_slots(cid, date)
avail_time_slots = []
for time in self.initial_time_slots:
if time not in booked:
avail_time_slots.append(time)
return avail_time_slots | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time_slots(self, cid, date):\n query = \"SELECT time from consultation where cid = %s and date = %s\"\n inputs = (cid, date)\n array_book = self.database_manager.execute_query(query, inputs)\n array_book = [e[0] for e in array_book]\n booked = array_book if array_book els... | [
"0.6475281",
"0.5428682",
"0.5371842",
"0.5371842",
"0.51741886",
"0.51081544",
"0.5009312",
"0.49967223",
"0.49914086",
"0.49795753",
"0.4913998",
"0.49124762",
"0.48989335",
"0.48970482",
"0.48623538",
"0.4860842",
"0.48081848",
"0.47892904",
"0.47883248",
"0.47678515",
"0.... | 0.6290072 | 1 |
Main function for handling consultation booking query. Use the other helper function in this class to perform checks. First check the date and time to book is valid and then check if that time slot is free for booking. If successful, send the confirmation email to user | def consultation_booking_query(self, cid, sid, time, date):
if not self.check_course_exist(cid):
return ConsultationError.INVALID_COURSE.value
is_weekday, feedback = self.check_weekday(date)
time = self.round_time(time)
if is_weekday:
try:
avail_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_a_booking(self):\n date = datetime(2030, 3, 1, 11)\n\n response = self.client.post(reverse('bookings', kwargs={'facility': 'g'}), {\n 'book': str(date.timestamp())})\n\n context = response.context\n bookings = context[\"bookings\"]\n\n ... | [
"0.6285904",
"0.6248594",
"0.60556376",
"0.59616846",
"0.58689266",
"0.5847724",
"0.5803472",
"0.5801589",
"0.5801299",
"0.5799272",
"0.57964927",
"0.57900834",
"0.57629204",
"0.5760087",
"0.5751662",
"0.57443297",
"0.57376814",
"0.5724082",
"0.570967",
"0.56869584",
"0.56727... | 0.76142645 | 0 |
Time rounding function to convert time to nearest hour | def round_time(self, time):
hour, mins, _ = time.split(":")
return '{:02d}:00:00'.format(int(hour)+1 ) if int(mins) >= 30 else '{:02d}:00:00'.format(int(hour)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_hours(time):\n return int(time / 3600)",
"def minute_and_hour_to_time(minute, hour):\n return hour * 60 + minute",
"def round_time(time):\n t_min = time.minute % 5\n t_sec = time.second\n t_mic = time.microsecond\n time = time - timedelta(minutes=t_min, seconds=t_sec, microsecon... | [
"0.6894247",
"0.6868417",
"0.6807988",
"0.67942107",
"0.6661185",
"0.6559892",
"0.65049607",
"0.6504825",
"0.64477766",
"0.63714486",
"0.6369177",
"0.63213694",
"0.63099164",
"0.6292212",
"0.6286086",
"0.6229638",
"0.6191705",
"0.61642456",
"0.6159741",
"0.61480266",
"0.61301... | 0.75865996 | 0 |
Prepares the HttpResponse that will be used to contain the CSV data | def initialize_response(self, filename):
key = 'Content-Disposition'
self.response = HttpResponse(content_type='text/csv')
self.response[key] = f'attachment; filename="{filename}"'
self.writer = UnicodeCsvWriter(self.response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_response(filename, header, rows):\r\n response = HttpResponse(mimetype='text/csv')\r\n response['Content-Disposition'] = 'attachment; filename={0}'.format(filename)\r\n writer = csv.writer(response, dialect='excel', quotechar='\"', quoting=csv.QUOTE_ALL)\r\n # In practice, there... | [
"0.63558805",
"0.6211693",
"0.61712754",
"0.61518145",
"0.6062035",
"0.6041702",
"0.6011072",
"0.5961391",
"0.5917385",
"0.59064513",
"0.5903959",
"0.588618",
"0.58850384",
"0.57541096",
"0.575156",
"0.5745402",
"0.5737436",
"0.5736874",
"0.57214737",
"0.5717868",
"0.57091135... | 0.6857063 | 0 |
Convolve two Ndimensional arrays using FFT. See convolve. | def fftconvolve(in1, in2, mode='same'):
s1 = array(in1.shape)
s2 = array(in2.shape)
complex_result = (np.issubdtype(in1.dtype, np.complex) or
np.issubdtype(in2.dtype, np.complex))
size = s1 + s2 - 1
# Always use 2**n-sized FFT
fsize = (2 ** np.ceil(np.log2(size))).astype('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fftconvolve(array, kernel):\n x = numpy.fft.fftshift(numpy.fft.fftn(image))\n y = numpy.fft.fftshift(numpy.fft.fftn(kernel))\n\n return numpy.real(numpynp.fft.fftshift(\n numpy.fft.ifftn(numpy.fft.ifftshift(x * y))))",
"def weightedfftconvolve(in1, in2, mode=\"full\", weighting=\"none\", disp... | [
"0.7239143",
"0.71845514",
"0.7157312",
"0.70784557",
"0.7055453",
"0.6915631",
"0.6884482",
"0.67564625",
"0.66061014",
"0.66050863",
"0.6434134",
"0.63963294",
"0.6372463",
"0.63168097",
"0.62808156",
"0.61976945",
"0.61933094",
"0.61032593",
"0.60985255",
"0.6070625",
"0.6... | 0.7394281 | 0 |
Sends each order transaction to the database | def send_to_db(ck_transactions):
db = DDDB()
db.add_orders(ck_transactions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_order(self, p_order, p_in_out, count):\n pass",
"def add_orders_on(user, order_date, items):\n for item in items:\n order = BreadOrder(\n user=user,\n date=order_date,\n type=item\n )\n db.session.add(order)\n db.session.commit()",
"de... | [
"0.6368061",
"0.6128186",
"0.6065711",
"0.6017387",
"0.59723914",
"0.58429277",
"0.5839083",
"0.5839083",
"0.58321863",
"0.5796558",
"0.5778104",
"0.57750577",
"0.5752862",
"0.57170993",
"0.56874627",
"0.5681104",
"0.56760603",
"0.5659921",
"0.5651157",
"0.5630337",
"0.562386... | 0.78310764 | 0 |
Converts a char into the appropriate Position, if any exists. | def convert_to_position(char: str) -> Position:
if char == 'PG':
return Position.PG
elif char == 'SG':
return Position.SG
elif char == 'SF':
return Position.SF
elif char == 'PF':
return Position.PF
elif char == 'C':
return Position.C
else:
raise Ru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _charToIndex(self,ch): \n return self.char_dict[ch]",
"def alphabet_position(char):\n if type(char) != type(''):\n return -1\n if len(char) != 1:\n return -1\n if char.isalpha():\n return lowerLetters.find(char.lower())\n return -1",
"def _get_char(self):\r\... | [
"0.6826631",
"0.68057626",
"0.66368306",
"0.6616373",
"0.649323",
"0.6439652",
"0.64255637",
"0.6351111",
"0.62918675",
"0.62909377",
"0.6249595",
"0.6187012",
"0.6185425",
"0.61581844",
"0.61502945",
"0.6104441",
"0.6099312",
"0.6068768",
"0.6057841",
"0.6031381",
"0.6031381... | 0.7934982 | 0 |
Test opening cache files in a subprocess (with a clean environment). | def test_reopen_cache():
env = os.environ.copy()
# Get the path to current directory
path = os.path.dirname(os.path.realpath(__file__))
# Set the COVERAGE_PROCESS_START env. variable.
# Allows to cover files run in a subprocess
# http://nedbatchelder.com/code/coverage/s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_use_cache_missing_file():\n # Generate cached files\n cmd_list = [NETMIKO_GREP] + ['interface', 'all']\n _, full_dir = find_netmiko_dir()\n remove_file = 'bad_device.txt'\n remove_file_full = \"{}/{}\".format(full_dir, remove_file)\n if os.path.exists(remove_file_full) and os.path.isfile... | [
"0.69525003",
"0.6447687",
"0.636721",
"0.6286523",
"0.62074196",
"0.61756605",
"0.6045512",
"0.600041",
"0.58595663",
"0.5831782",
"0.5773257",
"0.5741478",
"0.5648182",
"0.5604841",
"0.55939627",
"0.5588715",
"0.55886006",
"0.5573728",
"0.5554118",
"0.55458426",
"0.5485352"... | 0.7429855 | 0 |
run encounter from start; introduce NPCs, present interaction choices, and start social/combat encounter based on choices | def begin_encounter(self):
#introduce NPCs - run all introduce methods, unless the NPCs have the same name
for i in range(len(self.npc_names)):
for _npc in self.npc_list:
if _npc.name == self.npc_names[i]:
_npc.introduce(self.npc_quantities[i], self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parley(self):\n wait_times = constants.TUTORIAL_WAIT_TIMES\n self.introduce_chat_interface()\n self.wait_for_response(\n message='Please type a greeting message to continue.',\n delay_time=wait_times['chat-interface'],\n )\n self.introduce_knowledgeable_... | [
"0.6173418",
"0.6145519",
"0.599449",
"0.59839225",
"0.59169596",
"0.58977705",
"0.5870836",
"0.5825354",
"0.57647556",
"0.5661851",
"0.5659896",
"0.5659896",
"0.56488043",
"0.5643661",
"0.5642012",
"0.56370825",
"0.5635088",
"0.5627784",
"0.56082624",
"0.5599039",
"0.5566845... | 0.8137266 | 0 |
quick description of npcs in current location | def display_npcs(self):
if self.location == world.LocationType.INDOORS:
print("In the room before you, you see:")
for i in range(len(self.npc_list)):
print("A " + self.npc_list[i].name + " (Distance: " + str(self.npc_distances[i]) + "ft.)") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_npc(loc_npc):\r\n func.clear_screen()\r\n print('В текущей локации находятся:')\r\n for i in loc_npc:\r\n print('NPC ', i)\r\n print(npc[i].about())\r\n print('Настроение:', npc[i].mood, '\\n')\r\n input(\"Нажми enter для продолжения...\")",
"def look_at(self):\n ... | [
"0.67704767",
"0.6305048",
"0.6275345",
"0.6239086",
"0.62250483",
"0.61454546",
"0.6121275",
"0.60830915",
"0.606883",
"0.6023328",
"0.5991017",
"0.5978248",
"0.59666777",
"0.5941092",
"0.5914425",
"0.5826963",
"0.5782244",
"0.57809716",
"0.57723576",
"0.57674545",
"0.576181... | 0.72753835 | 0 |
A method to find all saved scores from the database. | def find_all(self):
cursor = self._connection.cursor()
cursor.execute('SELECT * FROM scores ORDER BY level')
all_scores = cursor.fetchall()
return all_scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_saved():\n return saved.find()",
"def getScores(self,query):\n pass",
"def find_all_by_level(self, level):\n cursor = self._connection.cursor()\n command = 'SELECT * FROM scores WHERE level=? ORDER BY score'\n cursor.execute(command, [level])\n all_scores_by_le... | [
"0.6841076",
"0.6711554",
"0.6601322",
"0.657444",
"0.65719324",
"0.65098506",
"0.6496116",
"0.6478606",
"0.6399739",
"0.6348333",
"0.62986887",
"0.62947536",
"0.61703575",
"0.6157236",
"0.6095744",
"0.6060185",
"0.6047248",
"0.60408145",
"0.5990906",
"0.58930206",
"0.5884905... | 0.81065226 | 0 |
A method to find all saved scores on a specific level. | def find_all_by_level(self, level):
cursor = self._connection.cursor()
command = 'SELECT * FROM scores WHERE level=? ORDER BY score'
cursor.execute(command, [level])
all_scores_by_level = cursor.fetchall()
return all_scores_by_level | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all(self):\n cursor = self._connection.cursor()\n cursor.execute('SELECT * FROM scores ORDER BY level')\n all_scores = cursor.fetchall()\n return all_scores",
"def find_all_by_player(self, player):\n cursor = self._connection.cursor()\n command = 'SELECT * FROM ... | [
"0.7215508",
"0.6560095",
"0.6534747",
"0.6025395",
"0.58823144",
"0.5759367",
"0.57350314",
"0.5605739",
"0.55363613",
"0.5535136",
"0.5493144",
"0.54914767",
"0.54653996",
"0.5458332",
"0.537102",
"0.5313048",
"0.5254255",
"0.5236667",
"0.5226593",
"0.52190083",
"0.5205779"... | 0.8105305 | 0 |
A method to find all scores by a specific player. | def find_all_by_player(self, player):
cursor = self._connection.cursor()
command = 'SELECT * FROM scores WHERE player=? ORDER BY level'
cursor.execute(command, [player])
return cursor.fetchall() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score(self, player):\n if player in self.player_scores:\n return self.player_scores[player]\n else:\n raise Exception(\"Player not in score list\")",
"def calculate_scores(players):\n scores = {}\n for player in players.tuple_:\n scores[player.id_] = playe... | [
"0.7240055",
"0.69891363",
"0.67218506",
"0.6526238",
"0.64880234",
"0.6344628",
"0.6267268",
"0.6236462",
"0.62285614",
"0.6221099",
"0.6183751",
"0.6143489",
"0.6104288",
"0.6069036",
"0.6060385",
"0.6030242",
"0.6006022",
"0.5981791",
"0.59692144",
"0.5958714",
"0.5953676"... | 0.84626925 | 0 |
A method to add new scores to the database. A new score is added after every game played. | def add_score(self, player, level, score):
cursor = self._connection.cursor()
command = 'INSERT INTO scores (player, level, score) VALUES (?, ?, ?)'
cursor.execute(command, [player, level, score])
self._connection.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_score(self, data):\n # sql_score_add = \"\"\"update $s SET\n for team_id, score in data.items():\n if int(score) in range(0, 14):\n column = \"score_\" + (score)\n sql_cmd = (\"UPDATE %s SET %s=1 WHERE team_id=%s\" % (self.dbtable, column, team_id))\n ... | [
"0.7908688",
"0.68989253",
"0.68800557",
"0.67670214",
"0.66604817",
"0.6655626",
"0.6654588",
"0.6644192",
"0.664415",
"0.6584629",
"0.6540392",
"0.65298015",
"0.6486854",
"0.64767516",
"0.64708185",
"0.64389807",
"0.6434606",
"0.64264286",
"0.642309",
"0.63963497",
"0.63225... | 0.7622393 | 1 |
Simple helper function to get the page url/ | def get_url(self, page):
return self.server_url + page | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self) -> str:\n\n return self.__page_url",
"def url(self):\r\n return self.urlparts.geturl()",
"def get_absolute_url(self):\r\n return \"{0}page1/\".format(self.get_short_url())",
"def url(self):\n url = os.environ.get('PATH_INFO')\\\n or os.environ.get('REQ... | [
"0.76338345",
"0.7173302",
"0.7136625",
"0.71100295",
"0.70039535",
"0.6974125",
"0.6918383",
"0.6789336",
"0.67570287",
"0.6727007",
"0.6721156",
"0.6717571",
"0.6681439",
"0.6677521",
"0.6657421",
"0.66332924",
"0.6630717",
"0.6630717",
"0.6628256",
"0.66132647",
"0.6607386... | 0.78212947 | 0 |
Get plant details for specified timespan. | def plant_detail(self, plant_id, timespan, date):
assert timespan in Timespan
if timespan == Timespan.day:
date_str = date.strftime('%Y-%m-%d')
elif timespan == Timespan.month:
date_str = date.strftime('%Y-%m')
response = self.session.get(self.get_url('PlantDetai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timespan(self, timespan=None, timezone=None):\r\n url = '{0}/{1}'.format(self.get_pull_url(), 'timespan')\r\n params = base.get_params(('timespan', 'timezone'), locals())\r\n\r\n return http.Request('GET', url, params), parsers.parse_json",
"def get_hours_per_unit_snap(now):\n print(\... | [
"0.6048593",
"0.5318801",
"0.5122391",
"0.50630397",
"0.49727464",
"0.4930676",
"0.4928082",
"0.48587734",
"0.48452678",
"0.48042193",
"0.47776973",
"0.47688463",
"0.46948302",
"0.46917686",
"0.4672459",
"0.46535444",
"0.46435475",
"0.46115947",
"0.45913598",
"0.45773146",
"0... | 0.74597615 | 0 |
Get inverter data for specified date or today. | def inverter_data(self, inverter_id, date):
if date is None:
date = datetime.date.today()
date_str = date.strftime('%Y-%m-%d')
response = self.session.get(self.get_url('newInverterAPI.do'), params={
'op': 'getInverterData',
'id': inverter_id,
'type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_date(self, date):\n data = {}\n for stock in self.stocks:\n data[stock] = self.stock_data[stock].to_stock_dataframe_day(date)\n return data",
"def get_price_data(ticker, days_befoure):\r\n #config_file=raw_input('config file: ')\r\n config_file=\"d:/tmp/moex.jso... | [
"0.59639776",
"0.5859418",
"0.57783407",
"0.56881666",
"0.5599386",
"0.5589904",
"0.55563724",
"0.55145603",
"0.55125386",
"0.54645395",
"0.53165585",
"0.53057396",
"0.5285592",
"0.5245948",
"0.5234474",
"0.5232715",
"0.519923",
"0.51930124",
"0.5186436",
"0.5179437",
"0.5169... | 0.7362004 | 0 |
Use device_list, it's more descriptive since the list contains more than inverters. | def inverter_list(self, plant_id):
warnings.warn("This function may be deprecated in the future because naming is not correct, use device_list instead", DeprecationWarning)
return self.device_list(plant_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_device_list(self, device_list):\n self.device_list = device_list\n\n self.device_combo.clear()\n\n if not device_list:\n return\n\n self.device_combo.addItem(\"\")\n\n active_entry = None\n\n for dev in device_list:\n\n action_string = \"{m... | [
"0.64911735",
"0.6443062",
"0.6252887",
"0.62276167",
"0.62269986",
"0.6201142",
"0.61817676",
"0.6126628",
"0.6034526",
"0.60178775",
"0.6007457",
"0.6002648",
"0.59752244",
"0.5935301",
"0.59268457",
"0.5907353",
"0.58914775",
"0.5880226",
"0.5864928",
"0.58647996",
"0.5846... | 0.69720715 | 0 |
Get basic plant information with device list. | def plant_info(self, plant_id):
response = self.session.get(self.get_url('newTwoPlantAPI.do'), params={
'op': 'getAllDeviceList',
'plantId': plant_id,
'pageNum': 1,
'pageSize': 1
})
data = json.loads(response.content.decode('utf-8'))
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_list(self, plant_id):\n return self.plant_info(plant_id)['deviceList']",
"def get_devices():\n names = devices.list()\n if request.args.get('full') is not None:\n data = {d: devices.show(d) for d in names}\n else:\n data = names\n return jsonify({'devices': data})",
... | [
"0.75556433",
"0.70134014",
"0.68364483",
"0.68065023",
"0.67908365",
"0.6746467",
"0.6720276",
"0.6682221",
"0.66305697",
"0.6543957",
"0.6543498",
"0.6494734",
"0.6484901",
"0.6465679",
"0.6437325",
"0.6409516",
"0.6389772",
"0.63704956",
"0.6364575",
"0.6355703",
"0.635533... | 0.765959 | 0 |
Return the device class of the sensor. | def device_class(self):
return SENSOR_TYPES[self.sensor][3].get("device_class") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return self._sensor_type",
"def device_class(self):\r\n return self._sensor_cfg[3]",
"def device_class(self):\r\n return self._sensor_cfg[3]",
"def device_class(self) -> str | None:\n ... | [
"0.93628424",
"0.9240069",
"0.9161452",
"0.9161452",
"0.9156968",
"0.90412056",
"0.90412056",
"0.8956785",
"0.89529496",
"0.8950599",
"0.8919914",
"0.871994",
"0.8717259",
"0.87069035",
"0.8660478",
"0.8652474",
"0.83961546",
"0.83828783",
"0.8380708",
"0.8380708",
"0.8380708... | 0.92430294 | 1 |
Initializes an instance from number of times to try, and lower and upper bounds to sleep (in seconds). | def __init__ (self, times, lower, upper):
self.times = times
self.lower = lower
self.upper = upper
self.counter = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, timeout, tries):\r\n self._timeout = timeout\r\n self._tries = tries",
"def __init__(self, tries, exceptions=None, delay=1):\r\n self.tries = tries\r\n if exceptions is None:\r\n exceptions = retry.default_exceptions\r\n self.exceptions = exceptions\r\n ... | [
"0.6777629",
"0.6550155",
"0.6473606",
"0.608336",
"0.6008538",
"0.5947795",
"0.5889047",
"0.58258945",
"0.582502",
"0.57822096",
"0.57511",
"0.5726218",
"0.5697493",
"0.5653644",
"0.5648945",
"0.56483763",
"0.5644084",
"0.5633479",
"0.5630757",
"0.56092227",
"0.5588159",
"... | 0.690081 | 0 |
Get the ids of the registered engines. This method always blocks. | def remote_get_ids(self):
return self.smultiengine.get_ids() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIDs(self):\n return self.multiengine.getIDs()",
"def engineList(self, targets):\n if isinstance(targets, int):\n if targets not in self.engines.keys():\n log.msg(\"Engine with id %i is not registered\" % targets)\n raise error.InvalidEngineID(\"Engine... | [
"0.69110274",
"0.63427883",
"0.6191196",
"0.6022198",
"0.5954033",
"0.59250677",
"0.58777815",
"0.58292615",
"0.5824796",
"0.5804927",
"0.57669634",
"0.57343227",
"0.5724957",
"0.5702801",
"0.57008684",
"0.57008624",
"0.56766325",
"0.56736207",
"0.56694365",
"0.5666263",
"0.5... | 0.6516591 | 1 |
Turn a list of deferred_ids into a final result or failure. | def process_did_list(did_list):
new_d_list = [self.get_pending_deferred(did, True) for did in did_list]
final_d = gatherBoth(new_d_list,
fireOnOneErrback=0,
consumeErrors=1,
log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_results( # type: ignore[misc]\n deferredList: Tuple[\"defer.Deferred[T1]\", ...],\n consumeErrors: bool = False,\n) -> \"defer.Deferred[Tuple[T1, ...]]\":\n # The `type: ignore[misc]` above suppresses\n # \"Overloaded function implementation cannot produce return type of signature 1/2/3\"\n... | [
"0.6013431",
"0.5807183",
"0.57902557",
"0.57902557",
"0.5497678",
"0.54742616",
"0.53362757",
"0.5127025",
"0.51104206",
"0.5088483",
"0.5002355",
"0.49978006",
"0.49900883",
"0.48699865",
"0.48649788",
"0.4819112",
"0.47713944",
"0.4770748",
"0.47648305",
"0.47619805",
"0.4... | 0.5984314 | 1 |
A parallelized version of Python's builtin map. This has a slightly different syntax than the builtin `map`. This is needed because we need to have keyword arguments and thus can't use args to capture all the sequences. Instead, they must be passed in a list or tuple. raw_map(func, seqs) > map(func, seqs[0], seqs[1], .... | def raw_map(self, func, sequences, dist='b', targets='all', block=True):
if not isinstance(sequences, (list, tuple)):
raise TypeError('sequences must be a list or tuple')
max_len = max(len(s) for s in sequences)
for s in sequences:
if len(s)!=max_len:
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map(iteratee, *seqs):\n return _map(fnc.iteratee(iteratee), *seqs)",
"def map(self, func, *sequences):\n return self.mapper().map(func, *sequences)",
"def map(func, iterable, chunksize=None, ncpu=0, limit=True, progress=False):\n if (ncpu == 0):\n if (not progress):\n return ... | [
"0.71589917",
"0.69364524",
"0.69016457",
"0.6803368",
"0.67787397",
"0.6751321",
"0.67485857",
"0.6698962",
"0.66840696",
"0.6644073",
"0.6631258",
"0.66112894",
"0.6594355",
"0.657014",
"0.6553259",
"0.65476775",
"0.6470776",
"0.6453482",
"0.6449276",
"0.6433381",
"0.634615... | 0.71248853 | 1 |
A parallel version of Python's builtin `map` function. This method applies a function to sequences of arguments. It follows the same syntax as the builtin `map`. This method creates a mapper objects by calling `self.mapper` with no arguments and then uses that mapper to do the mapping. See the documentation of `mapper`... | def map(self, func, *sequences):
return self.mapper().map(func, *sequences) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _doMap(self, func, iterable):\n name = \"Mapper\"\n sys.stderr.write(\"Master[%s phase]: starting\\n\" % name)\n pipes = [mp.Pipe() for _ in range(self.num_workers)]\n proc = [mp.Process(target=spawn_mapper(func), name=name, args=(q,)) for q in pipes]\n for p in proc:\n ... | [
"0.72321373",
"0.7169596",
"0.7142879",
"0.71094584",
"0.6858198",
"0.6813721",
"0.68108535",
"0.6759652",
"0.67054784",
"0.66790706",
"0.6635265",
"0.6604754",
"0.66029197",
"0.6593076",
"0.65843767",
"0.65499353",
"0.65375745",
"0.650316",
"0.64501595",
"0.6427934",
"0.6421... | 0.7605146 | 0 |
Demonstrates using the pager. | def pager():
lines = []
for x in range(200):
lines.append('%s. Hello World!' % click.style(str(x), fg='green'))
click.echo_via_pager('\n'.join(lines)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pager(self, start_page=1):\n return Pager(start_page)",
"def print_paging_menu():\n print(\"\\n~ Enter 'n' to view next page of tickets\")\n print(\"~ Enter 'p' to view previous page of tickets\")\n print(\"~ Enter 'q' to quit viewing list of tickets\")",
"def show_more(text,filename=None,w... | [
"0.6193642",
"0.6142706",
"0.59355986",
"0.5923058",
"0.58354825",
"0.58264136",
"0.5783766",
"0.56706333",
"0.5645084",
"0.55829614",
"0.5568693",
"0.5560625",
"0.5547341",
"0.5534162",
"0.55162716",
"0.5515672",
"0.5388088",
"0.5358382",
"0.5328274",
"0.5272116",
"0.5266672... | 0.761011 | 0 |
Read data (document / collection) from Firestore recursively and save to local file system | def read(cred, output, depth, type, exclude, path):
click.echo('Reading from firetore, credential file: %s' % (cred))
cred = os.path.abspath(cred)
output = os.path.abspath(output)
click.echo('Document path: %s' % path)
click.echo('Output path: %s' % output)
if depth<0:
depth = 1000000
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(cred, folder, depth, path):\n click.echo('Writing to Firetore, credential file: %s' % (cred))\n cred = os.path.abspath(cred)\n data_folder = os.path.abspath(folder)\n click.echo('Document path: %s' % path)\n click.echo('Data folder path: %s' % data_folder)\n\n if depth < 0:\n dep... | [
"0.6884818",
"0.6076309",
"0.5875299",
"0.58504695",
"0.5354211",
"0.5283906",
"0.5241763",
"0.5212156",
"0.5192171",
"0.5189327",
"0.5181385",
"0.5175433",
"0.5147129",
"0.5092648",
"0.5061182",
"0.5056619",
"0.504086",
"0.50271386",
"0.5024991",
"0.5018954",
"0.5016102",
... | 0.6566067 | 1 |
Read data (document / collection) from local folder and write to Firestore recursively \b | def write(cred, folder, depth, path):
click.echo('Writing to Firetore, credential file: %s' % (cred))
cred = os.path.abspath(cred)
data_folder = os.path.abspath(folder)
click.echo('Document path: %s' % path)
click.echo('Data folder path: %s' % data_folder)
if depth < 0:
depth = 1000000
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(cred, output, depth, type, exclude, path):\n click.echo('Reading from firetore, credential file: %s' % (cred))\n cred = os.path.abspath(cred)\n output = os.path.abspath(output)\n click.echo('Document path: %s' % path)\n click.echo('Output path: %s' % output)\n\n if depth<0:\n dept... | [
"0.60830563",
"0.5607789",
"0.55427426",
"0.5538369",
"0.55160624",
"0.5408159",
"0.5377633",
"0.5359673",
"0.5350318",
"0.5331554",
"0.53252536",
"0.5292329",
"0.5278777",
"0.52338994",
"0.51846474",
"0.5164863",
"0.51599556",
"0.51181865",
"0.50957966",
"0.5087054",
"0.5023... | 0.71699053 | 0 |
Create config file with OXE connection parameters | def oxe_configure(host, login, password, proxies):
config = ConfigParser()
full_path = join(gettempdir(), 'pyoxeconf.ini')
if exists(full_path):
config.read(full_path)
if config.has_section('default') is False:
config.add_section('default')
if config.has_section(str(host)) is Fal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_config(self) -> None:\n if self.is_config_exist() is False:\n file = open(file=self.connection_string, mode=\"w+\")\n file.close()",
"def create_config(self) -> None:\n pass",
"def create_config(self) -> None:\n pass",
"def create_configfile():\n confi... | [
"0.71747446",
"0.67635787",
"0.67635787",
"0.6734129",
"0.6716206",
"0.66022563",
"0.65181285",
"0.6445137",
"0.6434882",
"0.6411332",
"0.6348044",
"0.6332934",
"0.61990017",
"0.6172318",
"0.6123248",
"0.61203516",
"0.6118633",
"0.6114111",
"0.6108447",
"0.60713667",
"0.60442... | 0.6787651 | 1 |
Builder for requests headers depending on request method | def oxe_set_headers(token, method=None):
# basic method GET
headers = {
'Authorization': 'Bearer ' + token,
'accept': 'application/json'
}
# addition for POST & PUT
if method in ('POST', 'PUT'):
headers.update({'Content-Type': 'application/json'})
# addition for DELETE
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _headers(self, **kwargs):\n headers = BASE_HEADERS.copy()\n if self.headers:\n headers.update(self.headers)\n headers.update(kwargs)\n return headers",
"def _build_headers(self):\n headers = {\n 'Authorization': 'Bearer {api_key}'.format(api_key=self._... | [
"0.67952037",
"0.67826074",
"0.67234015",
"0.67234015",
"0.6566839",
"0.6520469",
"0.6506166",
"0.64933366",
"0.64751816",
"0.6439939",
"0.6395954",
"0.6390138",
"0.6371061",
"0.635928",
"0.63532174",
"0.63498604",
"0.63317686",
"0.633148",
"0.6325686",
"0.6300463",
"0.629868... | 0.69006896 | 0 |
Assert that actual_list and expected_list are almost equal. ie. assertAlmostEqual(actual_elem, expected_elem) in each list. | def assertListAlmostEqual(self, actual_list, expected_list):
self.assertTrue(len(actual_list) == len(expected_list))
for i in xrange(len(actual_list)):
self.assertAlmostEqual(actual_list[i], expected_list[i]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertListAlmostEqual(self, list1, list2):\n for i, j in zip(list1, list2):\n rounded_i, rounded_j = self.round_values(i, j)\n self.assertAlmostEqual(rounded_i, rounded_j)",
"def assertTuplesAlmostEqual(self, actual, expected):\n try:\n for a, e in exactZip(actual, expe... | [
"0.83103",
"0.81242037",
"0.7785256",
"0.73372203",
"0.732838",
"0.72245044",
"0.7105452",
"0.70458096",
"0.69843453",
"0.6927921",
"0.68653214",
"0.68061745",
"0.6747581",
"0.6736418",
"0.67044675",
"0.66939676",
"0.66726786",
"0.6670484",
"0.6584054",
"0.657256",
"0.6550882... | 0.936699 | 0 |
Sample n_samples from the model. Sample from prior and create ldj. Then invert the flow and invert the logit_normalize. | def sample(self, n_samples):
z = sample_prior((n_samples,) + self.flow.z_shape)
ldj = torch.zeros(z.size(0))
z, ldj = self.flow (z, ldj, reverse=True)
z, ldj = self.logit_normalize(z, ldj, reverse=True)
return z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_from_prior(self, n_samples):\n\n p0 = self.rng.lognormal(mean=self.mean, sigma=self.sigma, size=n_samples)\n return p0[:, np.newaxis]",
"def sample_from_prior(self, n_samples):\n\n lamda = np.abs(self.rng.standard_cauchy(size=n_samples))\n\n p0 = np.log(np.abs(self.rng.rand... | [
"0.6363827",
"0.6241979",
"0.59031504",
"0.5891487",
"0.5890565",
"0.58652526",
"0.58364046",
"0.5712361",
"0.5668051",
"0.56108147",
"0.55263615",
"0.55153114",
"0.54841155",
"0.54841155",
"0.54841155",
"0.54841155",
"0.54841155",
"0.5463291",
"0.5456113",
"0.5456113",
"0.54... | 0.73537606 | 0 |
Run a train and validation epoch and return average bpd for each. | def run_epoch(model, data, optimizer, epoch):
traindata, valdata = data
model.train()
train_bpd = epoch_iter(model, traindata, optimizer, epoch)
model.eval()
val_bpd = epoch_iter(model, valdata, optimizer, epoch)
return train_bpd, val_bpd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_epoch(self, dataloader, train=True):\n losses = []\n accs = []\n for imgs, targets in dataloader:\n imgs, targets = imgs.to(self.device), targets.to(self.device)\n\n # calc. the losses\n output = self.resnet(imgs)\n loss = self.criterion(outp... | [
"0.72259",
"0.7162968",
"0.70626986",
"0.70128274",
"0.693935",
"0.6934751",
"0.6930591",
"0.6924467",
"0.6924467",
"0.6878245",
"0.68370175",
"0.6802234",
"0.6745276",
"0.6732712",
"0.6711104",
"0.66833466",
"0.65563345",
"0.6547786",
"0.65361917",
"0.6494339",
"0.6479519",
... | 0.75531656 | 0 |
Given an adjacency matrix and starting node, traverse the graph | def dfsIterative(m, start):
s = [start] # list, use as stack
visited = {start} # set
out = []
while len(s) > 0:
cur = s.pop()
pr('cur')
out.append(cur)
for vertex, connected in enumerate(m[cur]):
# vertex is column in matrix (i)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viterbi(adj_matrix, label_sequence, starting_vertex):\n\n assert adj_matrix, \"adj_matrix is None or empty.\"\n n = len(adj_matrix) # vertex count.\n for row in adj_matrix:\n assert len(row) == n, \"adj_matrix is not square.\"\n\n assert 0 <= starting_vertex <= n - 1, \"starting_vertex out ... | [
"0.63261956",
"0.6208576",
"0.61341274",
"0.6112829",
"0.60796154",
"0.60773766",
"0.6034537",
"0.6020517",
"0.60101736",
"0.60092723",
"0.597108",
"0.5929371",
"0.5928171",
"0.59148794",
"0.59029406",
"0.58984756",
"0.5895746",
"0.5883026",
"0.5869071",
"0.5836068",
"0.58274... | 0.6316166 | 1 |
Create an image upload_job and return an UploadJob instance | def create_job(self, image_name, image_checksum, project, cloud_account_names=None):
self._log.debug("Project {}: Create image upload job for image {} to {}".
format(project, image_name, cloud_account_names))
create_job_msg = RwImageMgmtYang.YangInput_RwImageMgmt_CreateUploadJob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_create_and_upload(self, upload=True, **kwargs):\n if 'name' not in kwargs:\n name = data_utils.rand_name(self.__name__ + \"-image\")\n kwargs['name'] = name\n\n params = dict(kwargs)\n image = self.create_image(**params)\n self.assertEqual('queued', image... | [
"0.7061483",
"0.64601487",
"0.59854835",
"0.5850496",
"0.58365744",
"0.5815387",
"0.57524824",
"0.56940156",
"0.5630146",
"0.5604861",
"0.5588327",
"0.5575735",
"0.5562993",
"0.5536786",
"0.55213976",
"0.551275",
"0.55043775",
"0.54979646",
"0.54731596",
"0.5472851",
"0.54714... | 0.7056711 | 1 |
Wait until the upload job reaches a terminal state | def wait_until_complete(self):
self._log.debug("waiting for upload job %s to complete", self._job_id)
xpath = ManoProject.prefix_project("D,/rw-image-mgmt:upload-jobs/" +
"rw-image-mgmt:job[rw-image-mgmt:id={}]".
forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_until_job_completes(self):\n while True:\n jobflow = self.conn.describe_jobflow(self.jobid)\n if self.verbose_mode:\n print jobflow.state\n if (jobflow.state == 'COMPLETED' or jobflow.state == 'TERMINATED'\n or jobflow.state == 'FAILED'... | [
"0.7011266",
"0.69578224",
"0.69578224",
"0.69578224",
"0.69578224",
"0.6860455",
"0.68326867",
"0.6693386",
"0.6693386",
"0.6650743",
"0.6615907",
"0.6586633",
"0.6496838",
"0.6451071",
"0.64483374",
"0.63990617",
"0.6358756",
"0.6353165",
"0.62730867",
"0.626102",
"0.622848... | 0.74622226 | 0 |
A simpler version of exit_based_on_results(); this function causes the script to exit normally with return value of zero if and only if all tests within the script passed and had no errors. Otherwise it returns the number of failures plus the number of errors | def simple_exit(results):
if results.wasSuccessful():
_exit(0)
else:
nfail = len(results.errors)+len(results.failures)
_exit(nfail) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit_based_on_results(results):\n NotImpErrors = 0\n for error in results.errors:\n for errormsg in error:\n if type(errormsg) is str:\n if 'NotImplemented' in errormsg:\n NotImpErrors +=1\n break\n if results.wasSuccessful():\n ... | [
"0.76364",
"0.7418066",
"0.6828983",
"0.66794246",
"0.65226054",
"0.64622444",
"0.6386139",
"0.63859236",
"0.63789564",
"0.63374364",
"0.6336109",
"0.6326882",
"0.6310747",
"0.630126",
"0.62832946",
"0.6256901",
"0.61972606",
"0.6194782",
"0.6180795",
"0.6180723",
"0.61695355... | 0.7812444 | 0 |
A probablyobsolete function to exit from a unit testscript with a status that depends on whether or not the only errors or failures were NotImplemented errors. Specifically, | def exit_based_on_results(results):
NotImpErrors = 0
for error in results.errors:
for errormsg in error:
if type(errormsg) is str:
if 'NotImplemented' in errormsg:
NotImpErrors +=1
break
if results.wasSuccessful():
_exit(0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_exit_code(results):\n assert results[\"metrics\"][\"Exit code\"] == 0",
"def simple_exit(results):\n if results.wasSuccessful():\n _exit(0)\n else:\n nfail = len(results.errors)+len(results.failures)\n _exit(nfail)",
"def test_xfailed_but_passed():\n pass",
"def tes... | [
"0.71618015",
"0.6987518",
"0.68979514",
"0.68465614",
"0.6811039",
"0.6778233",
"0.66374123",
"0.6611588",
"0.6609739",
"0.65894103",
"0.6573683",
"0.6560653",
"0.65252155",
"0.6486731",
"0.6451126",
"0.6423018",
"0.6410285",
"0.63805205",
"0.6364145",
"0.63522345",
"0.63445... | 0.74607766 | 0 |
helper function to respond json with the given status code and the given data | def respond(code, data):
return {
'statusCode': code,
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps(data)
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_json_response(data, status=True, code=200):\n\n to_serialize = {}\n if status:\n to_serialize['status'] = True\n if data is not None:\n to_serialize['result'] = data\n else:\n to_serialize['status'] = False\n to_serialize['error'] = data\n response = app.... | [
"0.82891816",
"0.8202379",
"0.7970874",
"0.7904336",
"0.789215",
"0.77233076",
"0.7712879",
"0.76846516",
"0.76841486",
"0.75793076",
"0.73921037",
"0.7388529",
"0.7360723",
"0.7353334",
"0.731192",
"0.7300626",
"0.7272777",
"0.7260774",
"0.72089255",
"0.72054183",
"0.720473"... | 0.83790994 | 0 |
Loads a series of known mnemonics and their generated addresses on account 0, index 0. | def mnemonics(tdd):
return load_data(tdd, "mnemonics.json") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_lemma_pos_offset_map():\n lemma_pos_offset_map = defaultdict(dict)\n ##pos_lemma_offset_map = defaultdict(dict)\n for suffix in _FILEMAP.values():\n # parse each line of the file (ignoring comment lines)\n with open(wordnet_dir+'index.%s' % suffix) as fin:\n for i, line i... | [
"0.5462835",
"0.5123565",
"0.5044636",
"0.49631006",
"0.494597",
"0.49274454",
"0.49178877",
"0.49134806",
"0.4877699",
"0.48551586",
"0.48249665",
"0.4812821",
"0.48062235",
"0.47993273",
"0.47603127",
"0.47496802",
"0.47460192",
"0.47357395",
"0.47238162",
"0.47097886",
"0.... | 0.58986574 | 0 |
Mocks the Terra instance before a request is made. | def mock_terra():
terra = Terra("soju-0013", "")
terra.lcd.request_middlewares.append(lcd_request_test_middleware)
return terra | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_setup(self, mocker):\n # pylama: ignore=W0201\n session_cls = mocker.patch.object(requests, 'Session')\n self.session = mocker.MagicMock()\n self.session.__enter__.return_value = self.session\n session_cls.return_value = self.session\n\n self.response = mocker.... | [
"0.6782043",
"0.6592813",
"0.6565687",
"0.6544803",
"0.65013963",
"0.64377755",
"0.63736105",
"0.6317969",
"0.62460375",
"0.6238057",
"0.6181688",
"0.61687994",
"0.61482024",
"0.6130161",
"0.6127421",
"0.6127421",
"0.6127421",
"0.6083885",
"0.60798734",
"0.60511017",
"0.60322... | 0.7425829 | 0 |
Return a screenshot of all screens. | def grab_screens() -> QPixmap:
# grab all screens
screens = QtWidgets.QApplication.screens()
pixmaps = []
w = 0
h = 0
for screen in screens:
pix = screen.grabWindow(0)
w += pix.width()
h = max(h, pix.height())
pixmaps.append(pix)
# merge all pixmaps
final... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getScreenList(self, verbose = False):\n return execCmd(\"%s -list\" % self._screenPath, verbose)",
"def create_screens(self):\n\n for name in State.game['screens']:\n self.create_screen(name)",
"def get_screen_image(dir=\"screenshots\"):\n screenshot_name = dir + \"/screensh... | [
"0.669737",
"0.6682343",
"0.66719764",
"0.6635923",
"0.6561212",
"0.63937396",
"0.63591784",
"0.6343912",
"0.6330666",
"0.63194615",
"0.6269219",
"0.62050754",
"0.61970925",
"0.61793834",
"0.6173518",
"0.6172579",
"0.61499625",
"0.60498494",
"0.6041306",
"0.60394",
"0.6023680... | 0.76967037 | 0 |
Return only unique elements of a list of names. | def unique_names(names):
return sorted(set(names)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uniq(listinput):\n\t\"\"\" This will be provided for the student. \"\"\"\n\toutput = []\n\tfor x in listinput:\n\t\tif x not in output:\n\t\t\toutput.append(x)\n\treturn output",
"def uniq(elements):\n us = set()\n ret = []\n for e in elements:\n if e not in us:\n ret.append(e)\n ... | [
"0.6976379",
"0.6941287",
"0.69210607",
"0.69099766",
"0.6850234",
"0.68281347",
"0.6813528",
"0.67876744",
"0.66393167",
"0.6612804",
"0.6556339",
"0.6508535",
"0.65020144",
"0.64769304",
"0.64689285",
"0.6465169",
"0.6462953",
"0.64619017",
"0.6438553",
"0.6429687",
"0.6411... | 0.829594 | 0 |
Counts the element/attribute usage based on the information found in fileinfos. | def count_items(fileinfos, type, name=""):
names = []
if is_filename(name):
# count all elements/attributes for one text
for nodeName in fileinfos[name]["usage_" + type].keys():
names.append(nodeName)
elif name == "":
# count all elements/attributes for all texts
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_all(fileinfos, args):\n # create overall figure\n count_and_draw(fileinfos,args)\n # create figures for all the files\n for key in fileinfos:\n count_and_draw(fileinfos,args,key)\n # create figures for all the elements\n els_processed = []\n for key in fileinfos:\n fo... | [
"0.6886276",
"0.6738042",
"0.6660266",
"0.6429914",
"0.64092374",
"0.62989074",
"0.628416",
"0.6216311",
"0.5990448",
"0.5982315",
"0.588425",
"0.58645785",
"0.5762811",
"0.56903577",
"0.5662114",
"0.5643657",
"0.56194276",
"0.5618649",
"0.5595091",
"0.55841815",
"0.557454",
... | 0.7681641 | 0 |
Dump the fileinfos to a JSON file. | def dump_to_json(fileinfos, out):
jsonarray = json.dumps(fileinfos)
json_filename = "all_elements_used.json"
text_file = open(os.path.join(out,out_dir_name,json_filename), "w")
text_file.write(jsonarray)
text_file.close()
stdout.write("... "+json_filename+" created\n") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SaveJSON(self, filename):\n data = {\n 'files': self._files,\n 'ebuilds': self._ebuilds,\n }\n json.dump(data, open(filename, 'w'))",
"def _dumpJson(self, data, file):\n name, ext = os.path.splitext(file)\n tempFile = \"{0}.tmp\".format(name)\n with open(tempFile, ... | [
"0.69172674",
"0.66837215",
"0.66653365",
"0.66187596",
"0.65824217",
"0.6502465",
"0.6499544",
"0.64916843",
"0.64843327",
"0.64843327",
"0.6442699",
"0.6432443",
"0.6427955",
"0.64231676",
"0.6397462",
"0.6368988",
"0.63653654",
"0.6357841",
"0.63443846",
"0.6318794",
"0.63... | 0.7570784 | 0 |
Dump the fileinfos to a CSV file. | def dump_to_csv(fileinfos, out, all_el_names, all_att_names):
uni_el_names = unique_names(all_el_names)
uni_att_names = unique_names(all_att_names)
att_names_prefixed = ["@%s" % item for item in uni_att_names]
csv_filename = "all_elements_used.csv"
# transform information from dictionary to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_csv(self, filename): # DONE\n self.data.to_csv(filename)",
"def write_to_csv_backup(api_info):\n\n rows = build_csv_write(api_info)\n\n with open(\"DbDynamicInfoBackUp.csv\", \"a\") as csv_file:\n writer = csv.writer(csv_file)\n for i in rows:\n writer.writerow(i)",... | [
"0.6587749",
"0.6567262",
"0.6516401",
"0.64488095",
"0.6329177",
"0.6303232",
"0.62775934",
"0.6203434",
"0.6203434",
"0.62002873",
"0.6188982",
"0.6188288",
"0.6174277",
"0.6162279",
"0.61549187",
"0.6153997",
"0.6153394",
"0.6148572",
"0.6131395",
"0.6130641",
"0.611053",
... | 0.67741257 | 0 |
Checks whether the collection and XML files can be found. | def check_paths(coll_path, out):
pathpattern = os.path.join(coll_path,"*.xml")
try:
if not os.path.exists(coll_path):
raise ValueError("Error: The collection could not be found.")
except ValueError as err:
print(err)
exit(1)
try:
if not os.path.exists(out):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_integrity(self):\n root = self.root\n for scene_name in self.scene_list:\n if not(os.path.isdir(os.path.join(root,scene_name)) and \n os.path.isdir(os.path.join(root,scene_name, images_dir)) and\n os.path.isfile(os.path.join(root,scene_nam... | [
"0.6503214",
"0.6503214",
"0.6393145",
"0.63877565",
"0.6369802",
"0.63557065",
"0.6311064",
"0.6305909",
"0.62576085",
"0.6249468",
"0.6203111",
"0.61695117",
"0.6166657",
"0.61103743",
"0.60590494",
"0.6058801",
"0.6057483",
"0.6051951",
"0.6050533",
"0.6041272",
"0.6041272... | 0.66739774 | 0 |
Tests if the input string is an XML filename | def is_filename(name):
test = re.search("[A-Za-z0-9_-]+\.xml$", name)
if test:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkFilename(path):\n ret = libxml2mod.xmlCheckFilename(path)\n return ret",
"def isValidTagName(s):\n if s.lower().startswith(\"xml\"):\n return False\n return re.match(\"[^\\W\\d][\\w\\-_.]*\", s)",
"def isXML(content):\n\n testStr = '<?xml'\n\n # File case.\n if hasattr(cont... | [
"0.68024284",
"0.6641543",
"0.65921056",
"0.6479503",
"0.63526535",
"0.63460016",
"0.627532",
"0.62090844",
"0.6194135",
"0.6066573",
"0.6058418",
"0.60285604",
"0.59887815",
"0.59805787",
"0.5978015",
"0.5959385",
"0.59314483",
"0.59218484",
"0.58941853",
"0.5881844",
"0.588... | 0.80211204 | 0 |
Adds subplots to the figure. | def add_subplots(fig, els_counted, atts_counted, chart_info, name="", log=False):
if name != "":
if is_filename(name):
# overview of element/attribute usage for a single text
draw_chart(els_counted, fig, chart_info["elements_used_text"], log)
draw_chart(atts_counted, fig,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_subplot(gridRows, gridCols, plotNo):\n pl.subplot(gridRows, gridCols, plotNo)",
"def create_four_subplots():\n pass",
"def plot_subplots(self, fig_num: int, title: str, raw: np.ndarray, smoothed: np.ndarray,\n axes_lbl_entries: Sequence[str]) -> matplotlib.figure.Figure:\n ... | [
"0.7376317",
"0.72689253",
"0.70899445",
"0.70780927",
"0.6994428",
"0.6944281",
"0.6904434",
"0.6834838",
"0.678537",
"0.673969",
"0.6703993",
"0.661437",
"0.65972716",
"0.6589826",
"0.65496194",
"0.65350604",
"0.6439696",
"0.6395684",
"0.6373495",
"0.6358416",
"0.63542396",... | 0.7276523 | 1 |
Count elements and attributes and draw figure | def count_and_draw(fileinfos, args, name=""):
els_counted = count_items(fileinfos,"el",name)
atts_counted = count_items(fileinfos,"att",name)
draw_figure(els_counted, atts_counted, args, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_all(fileinfos, args):\n # create overall figure\n count_and_draw(fileinfos,args)\n # create figures for all the files\n for key in fileinfos:\n count_and_draw(fileinfos,args,key)\n # create figures for all the elements\n els_processed = []\n for key in fileinfos:\n fo... | [
"0.59811217",
"0.58999234",
"0.5895706",
"0.58333105",
"0.5640615",
"0.5606671",
"0.5598163",
"0.55730134",
"0.55256116",
"0.5464455",
"0.54509664",
"0.5447591",
"0.5437948",
"0.5432597",
"0.54283845",
"0.5419368",
"0.54186237",
"0.5411935",
"0.54011625",
"0.5399584",
"0.5393... | 0.7792259 | 0 |
Reduce the size of an image to the indicated maximum dimensions This function takes a PIL.Image object and integer values for the maximum allowed width and height (a zero value means no maximum constraint), calculates the size that meets those constraints and resizes the image. The resize is done in place, changing the... | def downsize_img(img: Image.Image,
max_width: int,
max_height: int) -> Tuple[Image.Image, bool]:
width, height = img.size
# Assume 0 as current size
if not max_width:
max_width = width
if not max_height:
max_height = height
if (max_width, max_height... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resizeImage(image, maxW, maxH):\n\timageW, imageH = image.size\n\tif imageW == maxW and imageH == maxH:\n\t\treturn image\n\t# find which axis requires the biggest zoom (smallest relative max dimension)\n\tzoomW = float(imageW) / float(maxW)\n\tzoomH = float(imageH) / float(maxH)\n\tzoom = max(zoomW, zoomH)\n\... | [
"0.7313931",
"0.6797074",
"0.66853905",
"0.6638203",
"0.6576893",
"0.64611125",
"0.6412122",
"0.6409634",
"0.63759714",
"0.6345033",
"0.62863255",
"0.62354404",
"0.62176794",
"0.62083846",
"0.6204622",
"0.61793035",
"0.615424",
"0.612027",
"0.61074275",
"0.6103727",
"0.609519... | 0.7365748 | 0 |
Reduce the number of colors of an Image object It takes a PIL image object and tries to reduce the total number of colors, converting it to an indexed color (mode P) image. If the input image is in mode 1, it cannot be further reduced, so it's returned back with no changes. | def do_reduce_colors(img: Image.Image,
max_colors: int) -> Tuple[Image.Image, int, int]:
orig_mode = img.mode
if orig_mode == "1":
return img, 2, 2
colors = img.getcolors()
if colors:
orig_colors = len(colors)
else:
orig_colors = 0
# Intermediate c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_color(image):\n\n # http://stackoverflow.com/questions/5906693/how-to-reduce-the-number-of-colors-in-an-image-with-opencv-in-python\n w, h, _ = image.shape\n for row in xrange(h-1):\n for col in xrange(w-1):\n #pi = row * w * 3 + col * 3\n pixel = image[col][row]\n ... | [
"0.7646288",
"0.6199736",
"0.6088131",
"0.6087488",
"0.60827786",
"0.6039727",
"0.58463526",
"0.58313364",
"0.5830371",
"0.5783675",
"0.5783629",
"0.57750285",
"0.57423425",
"0.5721086",
"0.5709663",
"0.57042706",
"0.56973356",
"0.5687904",
"0.56869465",
"0.56319326",
"0.5605... | 0.71109265 | 1 |
Create and return a sample quizz | def sample_quizz(**params):
defaults = {
'title': 'Boomer WW II Quizz',
'description': 'Are You A World War II Whiz?'
}
defaults.update(params)
return Quizz.objects.create(**defaults) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_quizes(self):\n driver = self.driver\n wait = self.wait\n\n create_quizz_name(driver, wait, quiz_name)\n\n create_textual_question(driver, wait, textual_question_1)\n create_textual_question(driver, wait, textual_question_2)\n create_textual_question(driver... | [
"0.6743306",
"0.62160754",
"0.62013143",
"0.6199276",
"0.6093944",
"0.5910831",
"0.58823454",
"0.58408946",
"0.5759428",
"0.5724299",
"0.566125",
"0.56514454",
"0.5644561",
"0.5635653",
"0.56318986",
"0.562786",
"0.56228137",
"0.5605605",
"0.558572",
"0.5567439",
"0.5556626",... | 0.7778706 | 0 |
Retrieves specific league matchday fixtures from API | async def _get_league_fixtures_matchday(self, server_id: str, league_id: str, matchday: str):
params = {'matchday': matchday}
url = self.api_url + 'competitions/{}/fixtures'.format(league_id)
return await self._make_request(url, params, server_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _matchdayfixtures(self, ctx: commands.Context, league_id: str, matchday: str='1'):\n headers = ['ID', 'Home', ' ', ' ', 'Away']\n data = await self._get_league_fixtures_matchday(ctx.message.server.id, league_id, matchday)\n\n await self.bot.say('```diff\\n+ Matchday ' + matchday + ' ... | [
"0.7193875",
"0.67219526",
"0.6705892",
"0.643531",
"0.62030923",
"0.61631644",
"0.6108169",
"0.5966481",
"0.5817939",
"0.5803004",
"0.57856566",
"0.57549417",
"0.57185924",
"0.5710034",
"0.5686895",
"0.5681784",
"0.5653688",
"0.5642157",
"0.56397754",
"0.5622974",
"0.5606544... | 0.7777739 | 0 |
Retrieves specific league leaderboard from API | async def _get_league_leaderboard(self, server_id: str, league_id: str, matchday: str):
if matchday is None:
matchday = ''
params = {'matchday': matchday}
url = self.api_url + 'competitions/{}/leagueTable'.format(league_id)
return await self._make_request(url, params, server... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaderboard(self):\n\n url = API_PATH[\"leaderboard\"].format(region_url=self.region_url)\n\n response = requests.get(url, headers=self.headers)\n\n return response.json()",
"def get_leaderboard(request):\n\n includedUsers = User.objects.filter(hide_leaderboard=False, is_staff=False)\... | [
"0.68470746",
"0.6579917",
"0.65558994",
"0.6431325",
"0.6389054",
"0.6388643",
"0.6316726",
"0.6310277",
"0.6274791",
"0.61995524",
"0.61978364",
"0.61695975",
"0.6142409",
"0.61303324",
"0.60644513",
"0.6037634",
"0.60006803",
"0.5971666",
"0.5949463",
"0.59340775",
"0.5922... | 0.6942586 | 0 |
Retrieves specific team info | async def _get_team_info(self, server_id: str, team_id: str):
params = {}
url = self.api_url + 'teams/{}'.format(team_id)
return await self._make_request(url, params, server_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_team_info(self, id):\n params = {'key': self.key, 'start_at_team_id': id,\n 'teams_requested': 1}\n r = requests.get(self.TEAM_URL, params=params)\n return TeamResponse(r.json()['result']['teams'][0])",
"def get_team(self):\n try:\n team_id = self.r... | [
"0.7538589",
"0.73244494",
"0.7296382",
"0.7267556",
"0.71839696",
"0.71808416",
"0.70882523",
"0.7044311",
"0.70201695",
"0.70070887",
"0.6972436",
"0.6941021",
"0.6889169",
"0.6869604",
"0.6866879",
"0.6845668",
"0.68446237",
"0.6834434",
"0.6823779",
"0.6790941",
"0.679071... | 0.7572377 | 0 |
Sets token for footballdata.org API | async def _tokenset(self, ctx: commands.Context, token: str):
self.config[ctx.message.server.id] = token
dataIO.save_json('data/football/config.json', self.config)
await self.bot.say('football-data API token set') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_token(self, token):\n # type: (Token) -> None\n self.token = token\n self._token_header = \"Bearer \" + token[\"access_token\"]",
"def api_token(self, api_token):\n\n self._api_token = api_token",
"def api_token(self, api_token):\n\n self._api_token = api_token",
"d... | [
"0.72034425",
"0.6961557",
"0.6961557",
"0.6853091",
"0.6750332",
"0.6673931",
"0.66676825",
"0.6644839",
"0.66060215",
"0.65552807",
"0.652376",
"0.6491826",
"0.6440416",
"0.63904065",
"0.6361036",
"0.6346903",
"0.63006663",
"0.6299534",
"0.6299534",
"0.62760955",
"0.6268818... | 0.752868 | 0 |
Gets last matchday fixtures | async def _lastfixtures(self, ctx: commands.Context, league_id: str):
headers = ['ID', 'Home', 'G', ' ', 'G', 'Away']
data = await self._get_league_fixtures_timeframe(ctx.message.server.id, league_id, 'p7')
await self.bot.say('```diff\n+ Last fixtures```')
pretty_data = []
for f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_league_fixtures_matchday(self, server_id: str, league_id: str, matchday: str):\n params = {'matchday': matchday}\n url = self.api_url + 'competitions/{}/fixtures'.format(league_id)\n\n return await self._make_request(url, params, server_id)",
"async def _matchdayfixtures(self,... | [
"0.664862",
"0.61880636",
"0.61498684",
"0.57026047",
"0.55819744",
"0.5568221",
"0.55650574",
"0.55338144",
"0.5467822",
"0.543978",
"0.54388535",
"0.5433871",
"0.53994286",
"0.53809017",
"0.53425187",
"0.533992",
"0.533346",
"0.5309541",
"0.52856404",
"0.5279819",
"0.527941... | 0.6616225 | 1 |
Gets specific matchday fixtures Defaults to matchday 1 | async def _matchdayfixtures(self, ctx: commands.Context, league_id: str, matchday: str='1'):
headers = ['ID', 'Home', ' ', ' ', 'Away']
data = await self._get_league_fixtures_matchday(ctx.message.server.id, league_id, matchday)
await self.bot.say('```diff\n+ Matchday ' + matchday + ' fixtures``... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _get_league_fixtures_matchday(self, server_id: str, league_id: str, matchday: str):\n params = {'matchday': matchday}\n url = self.api_url + 'competitions/{}/fixtures'.format(league_id)\n\n return await self._make_request(url, params, server_id)",
"def test_single_match(self):\n ... | [
"0.75872165",
"0.6141927",
"0.5587973",
"0.5584712",
"0.55028814",
"0.5417704",
"0.5377775",
"0.5377625",
"0.53597903",
"0.53553355",
"0.533468",
"0.52482533",
"0.524783",
"0.5247689",
"0.5236725",
"0.51911557",
"0.5182286",
"0.5163468",
"0.51237655",
"0.50984573",
"0.5065957... | 0.7391474 | 1 |
Generator for each file and directory | def files_and_folders(self):
yield from self._root.files_and_folders(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filelist_generator(self):\n for filename in self.filenames:\n yield filename",
"def directory_walker(start_dir):\n\n for root, dirs, files in os.walk(os.path.expanduser(start_dir)):\n for f in files:\n filename = os.path.join(root, f)\n # Only process if its ... | [
"0.7190483",
"0.7147999",
"0.70710903",
"0.70637256",
"0.7036718",
"0.70238703",
"0.70016503",
"0.6983245",
"0.6972447",
"0.6955986",
"0.6939163",
"0.693766",
"0.6891783",
"0.6865853",
"0.6865214",
"0.6835685",
"0.6812363",
"0.68081945",
"0.6771897",
"0.6769362",
"0.6762657",... | 0.7265181 | 0 |
Read and parse RARC from buffer. | def read(buffer) -> RARC:
# TODO: Add error checking
header = struct.unpack('>IIIIIIII', buffer[:32])
info = struct.unpack('>IIIIIIHHI', buffer[32:][:32])
rarc = RARC(*header, *info)
data = buffer[32:]
file_data = data[rarc.file_offset:][:rarc.file_length]
read_string_table(rarc, data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_from_bytes(self, raw_buffer):\n\n try:\n (cpu_svn,\n self.misc_select,\n _,\n attributes,\n mr_enclave,\n _,\n mr_signer,\n _,\n self.isv_prod_id,\n self.isv_svn,\n _,... | [
"0.5503501",
"0.54348403",
"0.5418983",
"0.5363614",
"0.53104985",
"0.5271902",
"0.5271709",
"0.5269464",
"0.52663326",
"0.52595025",
"0.5241821",
"0.52365834",
"0.51867217",
"0.51867217",
"0.5183559",
"0.5170246",
"0.51675284",
"0.5160428",
"0.5148865",
"0.5136454",
"0.51353... | 0.81372935 | 0 |
Compute the Longest Proper Prefix which is also a Suffix (LPS) array. | def compute_lsp(pattern, patt_len, lps):
pointer = 0
lps[0] = 0
i = 1
while i < patt_len:
if pattern[i] == pattern[pointer]:
pointer += 1
lps[i] = pointer
i += 1
else:
if pointer != 0:
pointer = lps[pointer - 1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lcp(s,sa):\n lcp = list()\n lcp.append(0)\n for i in range(1,len(sa)):\n lcp.append( longest_prefix_length(s, sa[i], sa[i-1]) )\n return lcp",
"def longest_increasing_subsequence(X):\r\n N = len(X)\r\n P = [0] * N\r\n M = [0] * (N+1) \r\n L = 0\r\n for i in range(N):\r\n... | [
"0.6896043",
"0.58654726",
"0.5859839",
"0.58537763",
"0.56931084",
"0.56799144",
"0.56313735",
"0.5626806",
"0.55893284",
"0.55066836",
"0.54774266",
"0.53755206",
"0.53678685",
"0.5318928",
"0.5314617",
"0.5309503",
"0.52898115",
"0.5269063",
"0.52025235",
"0.5197834",
"0.5... | 0.60028046 | 1 |
Test adding a credential to MongoDB credential store. | def test_mdb_add_credential(self):
cred = vccs_auth.credential.from_dict(self.cred_data, None)
id_ = self.mdb.add_credential(cred)
print("Added credential -> id : {!r}".format(id_))
cred2 = self.mdb.get_credential(self.cred_data['credential_id'])
print("Fetched credential :\n{}"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_store_existing_cred(self):\n self.new_cred.save_cred()\n self.assertEqual(len(Credentials.cred_list), 1)",
"def test_save_creds(self):\n self.new_credentials.save_creds()\n self.assertEqual(len(Credentials.credential_list),1)",
"def test_credential_create(self):\n se... | [
"0.73998183",
"0.7286204",
"0.7213283",
"0.71673906",
"0.7066448",
"0.69625634",
"0.68952906",
"0.6859978",
"0.68306863",
"0.6701606",
"0.6699401",
"0.6476767",
"0.64438003",
"0.6415699",
"0.6410146",
"0.63984615",
"0.63497376",
"0.63493955",
"0.62973535",
"0.62595546",
"0.62... | 0.7739804 | 0 |
Test adding a duplicate credential to MongoDB credential store. | def test_mdb_add_duplicate_credential(self):
this_id = 9797
data = self.cred_data
data['credential_id'] = this_id
cred = vccs_auth.credential.from_dict(data, None)
self.mdb.add_credential(cred)
cred.derived_key(new='bb' * (512 / 8))
print cred.to_dict()
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_duplicate(self):\n self.new_credential.credential_create()\n test_credentials = Credentials(\"MySpace\", \"Ghostke99\", \"daimaMkenya001\")\n test_credentials.credential_create()\n search_duplicate = Credentials.search_duplicate(\"MySpace\")\n self.assertTrue(sear... | [
"0.78255934",
"0.7580541",
"0.71481156",
"0.71136874",
"0.7055291",
"0.7006554",
"0.6912832",
"0.6901657",
"0.6888127",
"0.6855711",
"0.67945147",
"0.6759346",
"0.6653814",
"0.66450834",
"0.66354036",
"0.64718235",
"0.64647275",
"0.6450949",
"0.64090073",
"0.6342286",
"0.6331... | 0.7705258 | 1 |
Test fetching unknown credential. | def test_mdb_get_unknown_credential(self):
res = self.mdb.get_credential(1234567890)
self.assertEqual(res, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_creds_not_found():\n assert_equal(find_credentials({'foo': 'bar'}), (None, None))",
"def test_getcredentials_failed_netrc(netrc):\n netrc.side_effect = FileNotFoundError(\"\")\n server = KasServer()\n assert not server._username\n assert not server._password",
"def test_... | [
"0.68713856",
"0.6636915",
"0.64731884",
"0.63755894",
"0.63538057",
"0.63538057",
"0.63509166",
"0.63429207",
"0.6336358",
"0.63246906",
"0.6319021",
"0.6315944",
"0.6310986",
"0.62921965",
"0.6276207",
"0.627014",
"0.6215178",
"0.6157719",
"0.61278623",
"0.61278623",
"0.610... | 0.77316827 | 0 |
Test revoking a credential. | def test_mdb_revoking_credential(self):
this_id = 9898
data = self.cred_data
data['credential_id'] = this_id
cred = vccs_auth.credential.from_dict(data, None)
self.mdb.add_credential(cred)
# assert no exception
cred2 = self.mdb.get_credential(this_id)
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_revoked(self):\n self.assertEqual(self.project.is_revoked(), False)",
"def test_revoked_cert(self):\n\n # Initially should be able to to operations like open a session\n self._open_session()\n HttpAgentRpc().remove_host(self.host.fqdn)\n\n # After revokation any acc... | [
"0.6389961",
"0.6314945",
"0.62947994",
"0.6172954",
"0.6162046",
"0.6151327",
"0.6143952",
"0.6141443",
"0.6120828",
"0.6111874",
"0.60948175",
"0.60479844",
"0.6022124",
"0.6012169",
"0.5950155",
"0.5893915",
"0.5893513",
"0.58884704",
"0.5770536",
"0.5764254",
"0.575241",
... | 0.8346957 | 0 |
Test the __repr__ method of a credential. | def test_mdb_credential_repr(self):
cred = vccs_auth.credential.from_dict(self.cred_data, None)
res = repr(cred)
print "Credential : {!r}".format(res)
self.assertTrue(hex(self.cred_data['key_handle']) in res)
self.assertTrue(self.cred_data['type'] in res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repr(self):\n dummy = DummyCryptographicObject()\n repr(dummy)",
"def test_repr(self):\n self.assertEqual(\n repr(userbase.Preauthenticated('foo@bar')),\n '<Preauthenticated: foo@bar>')",
"def test_display_cred(self):\n self.assertEqual(Credentials.dis... | [
"0.74393976",
"0.70600057",
"0.70516384",
"0.69921756",
"0.68154055",
"0.65346986",
"0.6510147",
"0.64923185",
"0.648255",
"0.6446318",
"0.64374864",
"0.6412424",
"0.63760316",
"0.6320829",
"0.62903655",
"0.6257066",
"0.6190755",
"0.5962807",
"0.59566957",
"0.5948195",
"0.593... | 0.78560376 | 0 |
This snippet to decided what type of task is given for evaluation. This is really experiment specific and needs to be updated if things change. The only use for the task types is to make the evaluation on the classes with more than 100 samples at training for the epic evaluation. If actions are trained explicitly then ... | def get_task_type_epic(action_classes, verb_classes, noun_classes):
task_types = []
if action_classes > 0:
task_types.append("EpicActions")
if verb_classes > 0:
task_types.append("EpicVerbs")
if noun_classes > 0:
task_types.append("EpicNouns")
return task_types | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_task_specific_eval(task):\n if task == 'vrp':\n from evaluation.eval_VRP import eval_google_or,eval_Clarke_Wright\n\n return [(eval_google_or.EvalGoogleOR,'or_tools'), (eval_Clarke_Wright.EvalClarkeWright,'Clarke_Wright')]\n\n elif task == 'vrptw':\n from evaluation.eval_VRPTW i... | [
"0.6503214",
"0.6361112",
"0.6304494",
"0.6277422",
"0.6171994",
"0.616361",
"0.6150416",
"0.606043",
"0.59382284",
"0.5891429",
"0.58487225",
"0.58432925",
"0.58132005",
"0.5798007",
"0.577507",
"0.57504714",
"0.5745241",
"0.57363325",
"0.57022166",
"0.5690334",
"0.5669375",... | 0.6772187 | 0 |
Splits a model state dictionary in subcheckpoints so that the final size of each subcheckpoint does not exceed a given size. The subcheckpoints are determined by iterating through the `state_dict` in the order of its keys, so there is no optimization made to make each subcheckpoint as close as possible to the maximum s... | def flax_shard_checkpoint(params, max_shard_size="10GB"):
max_shard_size = convert_file_size_to_int(max_shard_size)
sharded_state_dicts = []
current_block = {}
current_block_size = 0
total_size = 0
# flatten the weights to chunk
weights = flatten_dict(params, sep="/")
for item in weigh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_partition_on_target_size_vertex_than_has_to_be_split(self):\n self.setup()\n large_vertex = TestVertex(1000, \"Large vertex\")\n large_vertex.add_constraint(PartitionerMaximumSizeConstraint(10))\n self.graph = ApplicationGraph(\n \"Graph with large vertex\", [large_v... | [
"0.5447984",
"0.5420202",
"0.5262327",
"0.5197391",
"0.518604",
"0.5176101",
"0.5175833",
"0.5174734",
"0.5156535",
"0.5135529",
"0.51065505",
"0.5106479",
"0.5078083",
"0.5054104",
"0.50533545",
"0.5044372",
"0.50167805",
"0.4993698",
"0.49864617",
"0.49733406",
"0.4969168",... | 0.6677971 | 0 |
r""" Cast the floatingpoint `params` to `jax.numpy.bfloat16`. This returns a new `params` tree and does not cast the `params` in place. This method can be used on TPU to explicitly convert the model parameters to bfloat16 precision to do full halfprecision training or to save weights in bfloat16 for inference in order ... | def to_bf16(self, params: Union[Dict, FrozenDict], mask: Any = None):
return self._cast_floating_to(params, jnp.bfloat16, mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_fp16(self, params: Union[Dict, FrozenDict], mask: Any = None):\n return self._cast_floating_to(params, jnp.float16, mask)",
"def cast_parameters_to_bf16(place, program, scope=None, to_bf16_var_names=None):\n all_parameters = []\n for block in program.blocks:\n all_parameters.extend(blo... | [
"0.7070078",
"0.69352823",
"0.65822524",
"0.5615649",
"0.5578388",
"0.5462372",
"0.53054917",
"0.530453",
"0.52218384",
"0.51704764",
"0.5153915",
"0.51356757",
"0.51211435",
"0.50357515",
"0.5008127",
"0.4879392",
"0.485458",
"0.48361912",
"0.48303774",
"0.47836018",
"0.4773... | 0.75039154 | 0 |
r""" Cast the floatingpoint `parmas` to `jax.numpy.float32`. This method can be used to explicitly convert the model parameters to fp32 precision. This returns a new `params` tree and does not cast the `params` in place. | def to_fp32(self, params: Union[Dict, FrozenDict], mask: Any = None):
return self._cast_floating_to(params, jnp.float32, mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cast_floating_to(self, params: Union[Dict, FrozenDict], dtype: jnp.dtype, mask: Any = None) -> Any:\n\n # taken from https://github.com/deepmind/jmp/blob/3a8318abc3292be38582794dbf7b094e6583b192/jmp/_src/policy.py#L27\n def conditional_cast(param):\n if isinstance(param, jnp.ndarray) ... | [
"0.5991893",
"0.597532",
"0.58963186",
"0.5659163",
"0.5620524",
"0.55966693",
"0.55932355",
"0.54186344",
"0.53701866",
"0.53546476",
"0.53410137",
"0.531362",
"0.52842003",
"0.527955",
"0.5197702",
"0.5188624",
"0.51253825",
"0.51162386",
"0.5039107",
"0.50123215",
"0.49999... | 0.73091394 | 0 |
r""" Cast the floatingpoint `parmas` to `jax.numpy.float16`. This returns a new `params` tree and does not cast the `params` in place. This method can be used on GPU to explicitly convert the model parameters to float16 precision to do full halfprecision training or to save weights in float16 for inference in order to ... | def to_fp16(self, params: Union[Dict, FrozenDict], mask: Any = None):
return self._cast_floating_to(params, jnp.float16, mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bf16(self, params: Union[Dict, FrozenDict], mask: Any = None):\n return self._cast_floating_to(params, jnp.bfloat16, mask)",
"def cast_parameters_to_bf16(place, program, scope=None, to_bf16_var_names=None):\n all_parameters = []\n for block in program.blocks:\n all_parameters.extend(bl... | [
"0.64355737",
"0.62667245",
"0.56928766",
"0.5585037",
"0.5519305",
"0.5508482",
"0.54957175",
"0.5233368",
"0.5187701",
"0.5149924",
"0.50876534",
"0.5062732",
"0.5032946",
"0.49982625",
"0.49486592",
"0.49486592",
"0.49486592",
"0.49480826",
"0.49480826",
"0.49480826",
"0.4... | 0.71142125 | 0 |
Register this class with a given auto class. This should only be used for custom models as the ones in the library are already mapped with an auto class. This API is experimental and may have some slight breaking changes in the next releases. | def register_for_auto_class(cls, auto_class="FlaxAutoModel"):
if not isinstance(auto_class, str):
auto_class = auto_class.__name__
import transformers.models.auto as auto_module
if not hasattr(auto_module, auto_class):
raise ValueError(f"{auto_class} is not a valid auto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_class(cls):\n if cls is RegisteredType:\n raise \"Please do _not_ register RegisteredType!\"\n \n cid = RegisteredType._reg[autoid]\n RegisteredType._reg['classes'][cls] = cid\n RegisteredType._reg['classids'][cid] = cls\n RegisteredType._reg['a... | [
"0.6776159",
"0.6657153",
"0.66237974",
"0.63050866",
"0.62078553",
"0.6145712",
"0.61293656",
"0.60562444",
"0.6045435",
"0.60446596",
"0.5937903",
"0.58827955",
"0.58161414",
"0.57446134",
"0.5714061",
"0.567607",
"0.5643422",
"0.5598895",
"0.5584236",
"0.55817175",
"0.5572... | 0.8423522 | 0 |
values as a dictionary is not hashable and hence cannot be used directly in the explored/visited set. This function changes values dict into a unique hashable string which can be used in the explored set. You may or may not use this | def convertStateToHash(values):
l = list(sorted(values.items()))
modl = [a+b for (a, b) in l]
return ''.join(modl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def HashValue(self) -> _n_0_t_3[_n_0_t_9]:",
"def __hash__(self):\n return hash(self.value)",
"def eliminate(values):\n solved_values = [box for box in values.keys() if len(values[box]) == 1]\n for box in solved_values:\n digit = values[box]\n for peer in peers[box]:\n # v... | [
"0.5454918",
"0.54015154",
"0.5385653",
"0.53502357",
"0.53502357",
"0.53162235",
"0.52739483",
"0.52719384",
"0.52631074",
"0.5217652",
"0.5215425",
"0.51902264",
"0.51642615",
"0.51546514",
"0.51301754",
"0.5089109",
"0.5087942",
"0.5077861",
"0.50689274",
"0.5043173",
"0.5... | 0.6645296 | 1 |
This function is used by '/book/search/' it can check whether the inputs are keyword of a book or isbn | def is_isbn_or_keyword(inputs):
isbn_or_keyword='keyword'
if len(inputs)==13 and inputs.isdigit():
isbn_or_keyword='isbn'
short_inputs=inputs.strip('-')
if '-' in inputs and short_inputs.isdigit() and len(short_inputs)==10:
isbn_or_keyword='isbn'
return isbn_or_keyword | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_isbn(val):\n if is_isbn10(val) or is_isbn13(val):\n if val[0:3] in [\"978\", \"979\"] or not is_ean13(val):\n return True\n return False",
"def book_search(library: list) -> None:\n options = ['Author', 'Title', 'Publisher', 'Shelf', 'Category', 'Subject']\n prompt = '\\nWhat... | [
"0.65093267",
"0.63722867",
"0.6290724",
"0.625288",
"0.61700827",
"0.6067454",
"0.6060485",
"0.6046413",
"0.5957303",
"0.5878592",
"0.58614373",
"0.58510476",
"0.58190084",
"0.5804851",
"0.5802345",
"0.57644963",
"0.57568294",
"0.5722268",
"0.57160085",
"0.56934005",
"0.5646... | 0.75670373 | 0 |
Removes rows where 'DESC' == 'RECOVR AUD' (not 'REGULAR'). These caused duplicate entries when grouping by turnstile & datetime. Removes DESC column. Fixes EXITS column name. | def clean_data(df_turnstiles):
# sort values in a such a way that the duplicate values sit directly below the originals, so they will be removed.
df_turnstiles.sort_values(
["C/A", "UNIT", "SCP", "STATION", "DATE_TIME"],
inplace=True,
ascending=False,
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_unique_ticker(state: State):\n if state.events.extract_company_list + state.events.load_company_list == 200:\n try:\n state.files.combined_exchanges.columns = map(str.lower, state.files.combined_exchanges.columns)\n\n # Following line is dropping duplicates but there's no... | [
"0.56350195",
"0.54732513",
"0.52934396",
"0.5236066",
"0.5183868",
"0.5166554",
"0.5122519",
"0.50612414",
"0.50369066",
"0.4998789",
"0.49871984",
"0.49319714",
"0.49076754",
"0.4899998",
"0.4882397",
"0.48713702",
"0.48684317",
"0.48679164",
"0.48649603",
"0.48645777",
"0.... | 0.6617085 | 0 |
Adds 'AMPM' and 'DAY_NAME' columns to the dataFrame. | def add_dt_cols(df_turnstiles):
df_turnstiles["AMPM"] = (
pd.DatetimeIndex(df_turnstiles["TIME"]).strftime("%r").str[-2:]
)
df_turnstiles["DAY_NAME"] = pd.to_datetime(df_turnstiles["DATE"]).dt.day_name()
return df_turnstiles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __append_columns(self, new_dataframe):\n self.dataframe = pd.merge(self.dataframe, new_dataframe)",
"def augment_dataframe(self, df: pd.DataFrame) -> pd.DataFrame:",
"def add_columns(self, **columns):\n return self.as_dataframe(self.data.assign(**columns))",
"def add_cols_to_cleaned_df(df):... | [
"0.5433198",
"0.54121774",
"0.5236415",
"0.52023053",
"0.5188201",
"0.50159407",
"0.5009321",
"0.4990669",
"0.49770692",
"0.49355897",
"0.49140552",
"0.4908264",
"0.48580837",
"0.48296228",
"0.48267817",
"0.4824319",
"0.48108315",
"0.47799486",
"0.47572893",
"0.47559062",
"0.... | 0.6033092 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.