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 |
|---|---|---|---|---|---|---|
[not settable, onlineonly] Number of bytes used in the referenced file system. If the referenced file system is restricted or offline, a value of 0 is returned. | def fs_size_used(self):
return self._fs_size_used | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usedspace(self):\n self.log.info(\"freespace\")\n nbytes = 0\n keys = list(self.downloads.keys())\n keys.sort()\n for key in keys:\n download = self.downloads[key]\n nbytes += download['size']\n self.log.info(\"returning:\" + str(nbytes))\n ... | [
"0.7420827",
"0.72786707",
"0.72786707",
"0.7269325",
"0.71914876",
"0.71662307",
"0.7160162",
"0.7136105",
"0.7135419",
"0.70523435",
"0.7033959",
"0.7007181",
"0.6840923",
"0.68281364",
"0.6804137",
"0.67992747",
"0.6791028",
"0.67774755",
"0.6768768",
"0.6767286",
"0.67621... | 0.7629277 | 0 |
[not settable, onlineonly] Total cache size (in bytes) in a hybrid aggregate. If the referenced aggregate is restricted or offline, or if it is not a hybrid aggregate, a value of 0 is returned. | def fs_hybrid_cache_size_total(self):
return self._fs_hybrid_cache_size_total | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_size(self):\n return self.cachesize",
"def get_size(self):\n return len(self.cache)",
"def get_size(self) -> int:\n total_size = 0\n for entry in self.__entries:\n total_size += entry.get_size()\n return total_size",
"def cache_size(self):\n retu... | [
"0.6754768",
"0.671188",
"0.65282655",
"0.6520063",
"0.64089966",
"0.6407665",
"0.63737583",
"0.63638794",
"0.6302466",
"0.62790143",
"0.6275713",
"0.6260091",
"0.62569165",
"0.6254125",
"0.62438375",
"0.62292016",
"0.62211895",
"0.6212261",
"0.6185322",
"0.61822873",
"0.6172... | 0.79143655 | 0 |
[not settable, onlineonly] The percentage of disk space currently in use on the referenced file system. | def fs_percent_used_capacity(self):
return self._fs_percent_used_capacity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disk_usage(self):\n self.monitoring_object['disk_usage'] =\\\n psutil.disk_usage('/')",
"def disk_usage(path):\n st = os.statvfs(path)\n free = (st.f_bavail * st.f_frsize)\n total = (st.f_blocks * st.f_frsize)\n used = (st.f_blocks - st.f_bfree) * st.f_frsize\n try:\n ... | [
"0.7765354",
"0.77051103",
"0.7577086",
"0.750689",
"0.7416436",
"0.73467296",
"0.73366296",
"0.7290818",
"0.7214682",
"0.7189561",
"0.7112761",
"0.71106875",
"0.7087746",
"0.7049418",
"0.7022909",
"0.69850135",
"0.69742143",
"0.69612396",
"0.6953823",
"0.6924519",
"0.6905571... | 0.78090465 | 0 |
[not settable, onlineonly] Number of uservisible files (inodes) used in the referenced file system. If the referenced file system is restricted or offline, a value of 0 is returned. | def fs_files_used(self):
return self._fs_files_used | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fs_files_private_used(self):\n return self._fs_files_private_used",
"def fs_maxfiles_used(self):\n return self._fs_maxfiles_used",
"def n_total_files(self):\n return len(self.fileinfo)",
"def numberFiles(self):\n return self.n",
"def __number_of_files(self):\n self.__... | [
"0.7214981",
"0.7100775",
"0.6683742",
"0.6647139",
"0.6588653",
"0.6584798",
"0.65275645",
"0.6507867",
"0.6462393",
"0.6428048",
"0.6423025",
"0.6417021",
"0.6347864",
"0.63377476",
"0.6323211",
"0.6319013",
"0.63131106",
"0.62815505",
"0.6277341",
"0.6269649",
"0.62391883"... | 0.7142993 | 1 |
Downmix to 2 channels if multichannel audio | def downmixWAV(self, wavf: str) -> None:
# HACK: https://github.com/jiaaro/pydub/issues/129
# FIXME: a reliable method to get number of wav channels
multichannel = True
try:
w = wave.open(wavf, 'rb')
if w.getnchannels() < 3:
multichannel = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _augment_channelswap(audio):\n if audio.shape[0] == 2 and torch.FloatTensor(1).uniform_() < 0.5:\n return torch.flip(audio, [0])\n\n return audio",
"def split_into_channels(audio):\n\tif AUDIO_CHANNELS == 1:\n\t\treturn [audio]\n\tif AUDIO_CHANNELS == 2:\n\t\treturn [audioop.tomono(audio, AUDIO_... | [
"0.66251373",
"0.58017147",
"0.57132083",
"0.56815225",
"0.56815225",
"0.5676537",
"0.5673752",
"0.5620985",
"0.55017495",
"0.5484101",
"0.53784776",
"0.5284562",
"0.5257859",
"0.52494276",
"0.5246769",
"0.52426875",
"0.521309",
"0.5204684",
"0.5174859",
"0.5143285",
"0.51371... | 0.6062682 | 1 |
Entrypoint to encode a PCM WAV according to self.codec Calls the corresponding encoding flavour subroutine | def encode(self, wavf: str, dstf: str, cover: str, meta: TrackMeta) -> None:
if self.downmix:
self.downmixWAV(wavf)
if self.codec == 'opus':
self.encodeOpus(wavf, dstf, cover, meta)
elif self.codec == 'flac':
self.encodeFLAC(wavf, dstf, cover, meta)
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_audio(in_file, out_file):\r\n # construct the encoder\r\n autoencoder = keras.models.load_model(\"audio_autoencoder.model\")\r\n in_layer = keras.layers.Input(shape=(416, 1))\r\n encode = autoencoder.layers[1](in_layer)\r\n encode = autoencoder.layers[2](encode)\r\n encode = autoencode... | [
"0.65444165",
"0.616003",
"0.61182684",
"0.6044659",
"0.599945",
"0.5975797",
"0.59426254",
"0.5871932",
"0.584925",
"0.58197874",
"0.5721502",
"0.57136923",
"0.5708158",
"0.57024765",
"0.56833845",
"0.5681794",
"0.56796414",
"0.5656293",
"0.5639054",
"0.5635989",
"0.5626203"... | 0.708651 | 0 |
Encodes a PCM WAV file to FLAC format | def encodeFLAC(self, wavf: str, dstf: str, cover: str, meta: TrackMeta) -> None:
FNULL = open(os.devnull, 'w')
args = ['flac', '-f', '--totally-silent', '--best']
if cover:
args.append('--picture')
args.append(cover)
args.append('-o')
args.append(dstf)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_flac(track_metadata):\n\tprint(\"---- Encoding\", track_metadata.file_name, \"to FLAC...\")\n\tnew_file_name = track_metadata.file_name + \".flac\"\n\tffmpeg(\"-i\", track_metadata.file_name, \"-c:a\", \"flac\", \"-compression_level\", \"12\", \"-lpc_passes\", \"8\", \"-lpc_type\", \"3\", \"-threads\", ... | [
"0.72776765",
"0.6860318",
"0.6540664",
"0.6528014",
"0.6487192",
"0.6446292",
"0.6383675",
"0.6361182",
"0.6282809",
"0.6255544",
"0.6238018",
"0.6137223",
"0.61305374",
"0.6121943",
"0.60995096",
"0.609092",
"0.60784394",
"0.6054091",
"0.5974038",
"0.5963611",
"0.59626454",... | 0.7052307 | 1 |
Encodes a PCM WAV file to MPEG4 AAC format (using NeroAAC) | def encodeAAC(self, wavf: str, dstf: str, cover: str, meta: TrackMeta) -> None:
FNULL = open(os.devnull, 'w')
subprocess.call(['neroAacEnc', '-q', '0.5',
'-if', wavf, '-of', dstf], stdout=FNULL, stderr=FNULL)
FNULL.close()
# tag AAC
mm = TrackMeta(meta)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_audio(in_file, out_file):\r\n # construct the encoder\r\n autoencoder = keras.models.load_model(\"audio_autoencoder.model\")\r\n in_layer = keras.layers.Input(shape=(416, 1))\r\n encode = autoencoder.layers[1](in_layer)\r\n encode = autoencoder.layers[2](encode)\r\n encode = autoencode... | [
"0.7306032",
"0.62807316",
"0.6186692",
"0.6184887",
"0.61353177",
"0.6118008",
"0.60905915",
"0.60306704",
"0.6010781",
"0.59966815",
"0.5967336",
"0.5942693",
"0.59272087",
"0.59113586",
"0.5872926",
"0.58028793",
"0.57023853",
"0.56894857",
"0.5689196",
"0.5650187",
"0.562... | 0.7470973 | 0 |
Dynamically load the module property as defined by the search parameter. | def load_from_module(search_definition):
try:
module_name, property_name = search_definition.split(":")
except:
raise ValueError(
'Search definition "{}" is not valid.'.format(search_definition)
)
try:
module = importlib.import_module(module_name)
except Imp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_parameter(self):",
"def import_JobProperties(self,module_name):\n try:\n if(module_name.count('.')==0):\n module=__import__(module_name,globals(),locals())\n elif(module_name.count('.')>0):\n module=__import__(module_name,globals(),locals(),\\\... | [
"0.5654104",
"0.5592349",
"0.5528449",
"0.54257554",
"0.5403773",
"0.5367219",
"0.53629297",
"0.53102595",
"0.5158309",
"0.51294607",
"0.5115421",
"0.5083747",
"0.5082948",
"0.50689006",
"0.5064725",
"0.5059072",
"0.50013876",
"0.49670178",
"0.49537078",
"0.49127337",
"0.4895... | 0.6725258 | 0 |
This function computes the MAC of message using key. The MAC function is CBCMAC with AES and both single1 padding and length strengthening provided by the padding function. key must be convertible to bytes of length 16 messuge must be convertible to bytes type | def CBCMACbasedOnAES(message, key):
# Convert the message into bytes
message1 = bytes(message)
# Convert the key into bytes
key1 = bytes(key)
# Create the AES object
aes_obj = AES.new(key1, AES.MODE_CBC, iv)
# Encrypt the message
MAC = aes_obj.encrypt(message1)
# Return the MAC of ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cbc_mac(key, data):\n engine = AES.new(key, AES.MODE_CBC, get_zero_vector(16))\n return engine.encrypt(data)[-16:]",
"def make_hmac(message, key):\n h = HMAC.new(key)\n h.update(message)\n return h.hexdigest()",
"def get_cipher_key(key):\n k = (\n key[0] ^ key[4],\n ... | [
"0.7086036",
"0.611308",
"0.5901191",
"0.5669914",
"0.56285095",
"0.5557149",
"0.5410308",
"0.5361496",
"0.5354697",
"0.53063726",
"0.5291547",
"0.52718997",
"0.52700454",
"0.5262614",
"0.5262613",
"0.5235734",
"0.5188047",
"0.5168812",
"0.5162046",
"0.51358014",
"0.5132436",... | 0.80590457 | 0 |
Split the main histogram file into a number of files based on the xaxis of the histograms. You can put all met_0j histograms into a single file and all met_1j1b histograms into a single file. | def split4fit(infile, histogram_list=['met_0j','met_1pj']):
import ROOT
outpfx = infile.split('.root')[0]
if '/' in outpfx:
outpfx = outpfx.split('/')[-1]
infile = ROOT.TFile(infile,'read')
lok = [str(o.GetName()) for o in infile.GetListOfKeys()]
def make_a_file(hist_name):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_histograms(self, folder_name):\n histograms_folder_name = folder_name + '_histograms'\n\n try:\n print(\"Making dir \" + str(histograms_folder_name) + \" for histograms\")\n os.mkdir(histograms_folder_name)\n except OSError:\n print(\"Folder exists, hav... | [
"0.5699574",
"0.5582589",
"0.5546733",
"0.55327415",
"0.54630715",
"0.54044586",
"0.53796023",
"0.5354796",
"0.5354093",
"0.53540707",
"0.5308832",
"0.5264176",
"0.52597815",
"0.52456474",
"0.5224068",
"0.51899284",
"0.51747006",
"0.51713526",
"0.5169178",
"0.5167327",
"0.516... | 0.70357597 | 0 |
Function to print individual scores per category | def PrintCategoryScore(Cat):
print()
print("########## Individual Category Results ##########")
for i in range(len(Cat)): # prints out the results per category
print()
print(Cat[i])
print(CategoryScore(Cat[i]))
print()
return print("----- End of Individuals Categor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_scores(result_collector):\n # print(\"\\n# Metric: Cohen's kappa\")\n # result_collector.set_metric(['k_cohen', 'k'])\n # result_collector.print_all_results()\n print(\"\\n# Metric: Macro avg. F1\")\n result_collector.set_metric([\"macro_avg\", \"fscore\"])\n # result_collector.print_al... | [
"0.67260253",
"0.6665418",
"0.66344786",
"0.6530227",
"0.65061975",
"0.6398446",
"0.62773705",
"0.62684315",
"0.6259877",
"0.6157813",
"0.6103413",
"0.6028164",
"0.5972317",
"0.5953665",
"0.59463376",
"0.5870147",
"0.57962006",
"0.5781991",
"0.5767299",
"0.57437664",
"0.57170... | 0.82049257 | 0 |
Combines all scores from all categories, except compound categories, such that an experienced team can be created. | def Combined_Non_Compound_Results(level):
CombinedResults = pd.DataFrame({},columns=['Name','Club','Score',
'Golds', 'Hits'])
# Initial empty dataframe to append in to
for i in level:
CombinedResults = CombinedResults.append(CategoryScore(i))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_all_evaluation(self, tag_bundle_set):\n categories_list = []\n for num, category in enumerate(self.categories):\n (is_matching_category, op_result_meta_info) = category.apply(tag_bundle_set)\n if is_matching_category:\n categories_list.append(\n ... | [
"0.6232284",
"0.5805466",
"0.56819975",
"0.5554579",
"0.55330455",
"0.5505344",
"0.53095824",
"0.52563643",
"0.5238515",
"0.51255673",
"0.5124239",
"0.50875473",
"0.50687027",
"0.50635606",
"0.50389135",
"0.501613",
"0.50091064",
"0.49548933",
"0.49239996",
"0.4914003",
"0.49... | 0.5833497 | 1 |
TM_fluid returns the 2x2 Transfer Matrix of a fluid layer | def TM_fluid(layer, kx, om):
h = layer.d
rho = layer.medium.rho
K = layer.medium.K
k = om*np.sqrt(rho/K)
ky = np.sqrt(k**2-kx**2)
T = np.zeros((2, 2), dtype=complex)
T[0, 0] = np.cos(ky*h)
T[1, 0] = (om**2*rho/ky)*np.sin(ky*h)
T[0, 1] = -(ky/(om**2*rho))*np.sin(ky*h)
T[1, 1] = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fluid_func(self):\n residual = []\n for fluid, x in self.inl[0].fluid.val.items():\n res = x * self.inl[0].m.val_SI\n for o in self.outl:\n res -= o.fluid.val[fluid] * o.m.val_SI\n residual += [res]\n return residual",
"def fluid_func(self)... | [
"0.5768485",
"0.56176883",
"0.5443617",
"0.5435858",
"0.5388646",
"0.53567904",
"0.53567904",
"0.53390956",
"0.52819616",
"0.52702206",
"0.52634484",
"0.5213695",
"0.5176987",
"0.51402587",
"0.50595313",
"0.50586605",
"0.5050682",
"0.5046748",
"0.5044931",
"0.49993876",
"0.49... | 0.6433278 | 0 |
Generate a model filename depending on flags. | def generateModelFilename(args, type):
opt = []
if args.letters:
opt.append('l')
if args.symbols:
opt.append('s')
if args.digits:
opt.append('d')
opt.sort()
return "models/model_{0}_{1}.yml".format(type, ''.join(opt)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_filename_from_options(opt):\n fs = '{}_emb_{}_hid_{}_de_{}_dd_{}_n_lyrs_{}_lr_{}'.format(\n opt.rnn_cell,\n opt.embedding_size, opt.hidden_size,\n opt.dropout_p_encoder, opt.dropout_p_decoder,\n opt.n_layers, opt.lr)\n\n if opt.optim is not None:\n fs += '_{}'.... | [
"0.6673857",
"0.6638888",
"0.63141143",
"0.63017",
"0.62750924",
"0.6254374",
"0.6215407",
"0.6143703",
"0.6113542",
"0.6111861",
"0.60562485",
"0.60557556",
"0.6055665",
"0.60303986",
"0.60138685",
"0.59926826",
"0.5991642",
"0.596877",
"0.594533",
"0.5944135",
"0.59324217",... | 0.7817009 | 0 |
Generate a filename in folder. folder/prefixfolder.0.ext | def generateFilename(folder, prefix, ext):
filename = os.path.basename(os.path.normpath(folder))
if prefix:
filename = "{0}-{1}".format(prefix, filename)
path = getIncrementedFilename(os.path.join(folder, filename), ext)
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_filename(extension, with_path=True, base_folder=None):\n name = get_md5(str(uuid4()))\n # if not extension:\n # extension = get_file_extension()\n if base_folder is not None:\n base_folder = \"%s/\" % base_folder.rstrip(\"/\")\n else:\n base_folder = \"\"\n\n if with_pa... | [
"0.7385492",
"0.7333924",
"0.7312657",
"0.72930425",
"0.7238043",
"0.72070307",
"0.7178001",
"0.7148282",
"0.710962",
"0.70897174",
"0.7036363",
"0.69962245",
"0.6996097",
"0.69855136",
"0.69633824",
"0.6955315",
"0.69493705",
"0.6947302",
"0.6938939",
"0.69265604",
"0.692255... | 0.8751055 | 0 |
This function loads filters from the module's buffer | def load_filters(self):
buffer_dict = dict(self.named_buffers())
n = 0
for k in self.phi_f.keys():
if type(k) != str:
self.phi_f[k] = buffer_dict['tensor' + str(n)]
n += 1
for psi_f in self.psi1_f:
for sub_k in psi_f.keys():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_filter(self, *args, **kwargs):\n raise NotImplementedError",
"def load_all_filters(self, interp=True, lamb=None):\n raise NotImplementedError",
"def get_filters(self):",
"def load_all_filters(self, interp=True, lamb=None):\n with self as s:\n filters = [s._load_filte... | [
"0.6760127",
"0.66662526",
"0.65889287",
"0.6388731",
"0.6377088",
"0.6367973",
"0.6348672",
"0.6340092",
"0.63190585",
"0.6272265",
"0.62107223",
"0.61704546",
"0.6143195",
"0.6071618",
"0.60356534",
"0.5954291",
"0.59326255",
"0.5896352",
"0.5821316",
"0.5776325",
"0.573437... | 0.7129835 | 0 |
Extracts GPM_IMERG data from its HDF5 format. | def extract_GPM_IMERG(hdf_list, layer_indexs, outdir = None, resolution = "0.1"):
hdf_list = core.enf_filelist(hdf_list)
output_filelist = []
# load the GPM datatype from the library
datatype = datatype_library()["GPM_IMERG_{0}_GLOBAL".format(resolution)]
# for every hdf file in the input list
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_mock_bgs_mxxl_file_hdf5(filename):\n f = h5py.File(filename)\n ra = f[\"Data/ra\"][...].astype('f8') % 360.0\n dec = f[\"Data/dec\"][...].astype('f8')\n SDSSr_true = f[\"Data/app_mag\"][...].astype('f8')\n zred = f[\"Data/z_obs\"][...].astype('f8')\n f.close()\n\n return {'RA':r... | [
"0.5809921",
"0.5733813",
"0.5630111",
"0.56280625",
"0.54389006",
"0.5396725",
"0.53915787",
"0.538835",
"0.5332873",
"0.53064656",
"0.5283936",
"0.5279001",
"0.52393204",
"0.52156854",
"0.5193792",
"0.51659465",
"0.51659465",
"0.5145079",
"0.5095168",
"0.50883245",
"0.50419... | 0.6405701 | 0 |
Test the startdate helper function. | def test_startdate(self):
req = create_request(query_string={'dates': '7d'})
eq_(startdate(req), date.today() - timedelta(days=7))
req = create_request(query_string={'dates': 'today'})
eq_(startdate(req), date.today())
req = create_request(query_string={'day': '2012-05-24'})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sample_one_date(self):\r\n self.assertEqual(self.test_sample.date, datetime.datetime(2016, 2, 12, 7, 34, 26))",
"def test_sample_date(self):\r\n self.assertEqual(self.test_sample.date, '2018-08-02 22:32:23')",
"def test_date_field():",
"def test_2_default_start_date(self):\n dat... | [
"0.7418544",
"0.72079736",
"0.70811504",
"0.69365495",
"0.6818063",
"0.6744521",
"0.6690331",
"0.6622518",
"0.6553764",
"0.65366197",
"0.6513246",
"0.6510367",
"0.6502609",
"0.6445681",
"0.6438329",
"0.64213866",
"0.6361636",
"0.63540447",
"0.6352647",
"0.6343614",
"0.632949"... | 0.7412501 | 1 |
Test the enddate helper function | def test_enddate(self):
req = create_request(query_string={'day': '2012-05-24'})
eq_(enddate(req), datetime(2012, 5, 25))
req = create_request(query_string={'week': '2012-05-24'})
eq_(enddate(req), datetime(2012, 5, 27, 23, 59, 59))
req = create_request(query_string={'day': 'to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_end_date(self):\n self.assertEqual(self.active.end_date, self.active.start_date + timedelta(3))",
"def test_get_end_date(self):\n # Creating booking object\n book_time = datetime.utcnow()\n duration = 3\n booking = Booking(1, \"dummy\", book_time, duration)\n\n ... | [
"0.8099103",
"0.73868465",
"0.7336594",
"0.71555233",
"0.70647436",
"0.7038015",
"0.7003596",
"0.6972179",
"0.69413835",
"0.69184554",
"0.6905523",
"0.68968177",
"0.6835612",
"0.6827259",
"0.6807936",
"0.6802212",
"0.6802212",
"0.6792249",
"0.6782013",
"0.67711264",
"0.674704... | 0.80878216 | 1 |
Test the __repr__ function of the Status model. | def test_status_repr(self):
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', user=u, save=True)
eq_(repr(s), '<Status: testuser: my status update>') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self) -> str:\n return f\"<TestStatus {self.test_id}: {self.status}>\"",
"def test_repr_method(self):\n\n u = User(\n email=\"test@test.com\",\n username=\"testuser\",\n password=\"HASHED_PASSWORD\"\n )\n\n u.id = 9999\n\n db.sessio... | [
"0.74939585",
"0.6992701",
"0.6944632",
"0.6924971",
"0.68719125",
"0.6830909",
"0.6818189",
"0.6818189",
"0.6818189",
"0.6818189",
"0.6818189",
"0.68118507",
"0.6807135",
"0.6787736",
"0.67022115",
"0.6695331",
"0.6669228",
"0.6649944",
"0.664373",
"0.66423917",
"0.6630548",... | 0.8246034 | 0 |
Test the loading of replies for a status. | def test_status_replies(self):
with self.app.app_context():
p = project(save=True)
u = user(save=True)
s = status(project=p, user=u, save=True)
for i in range(30):
status(project=p, user=u, reply_to=s, save=True)
page = s.replies()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_status_reply_count(self):\n with self.app.app_context():\n u = user(save=True)\n s = status(user=u, project=None, save=True)\n for i in range(5):\n status(user=u, project=None, reply_to=s, save=True)\n\n eq_(s.reply_count, 5)",
"def test_... | [
"0.612048",
"0.601257",
"0.5980231",
"0.5976872",
"0.5916692",
"0.580269",
"0.5790228",
"0.5780758",
"0.5731992",
"0.5731364",
"0.5731364",
"0.5725933",
"0.5664359",
"0.5663646",
"0.5607137",
"0.5565588",
"0.5563875",
"0.5541946",
"0.5509027",
"0.55016154",
"0.55000496",
"0... | 0.71060956 | 0 |
Test the reply_count property of the Status model. | def test_status_reply_count(self):
with self.app.app_context():
u = user(save=True)
s = status(user=u, project=None, save=True)
for i in range(5):
status(user=u, project=None, reply_to=s, save=True)
eq_(s.reply_count, 5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_status_replies(self):\n with self.app.app_context():\n p = project(save=True)\n u = user(save=True)\n s = status(project=p, user=u, save=True)\n\n for i in range(30):\n status(project=p, user=u, reply_to=s, save=True)\n\n page = ... | [
"0.7165764",
"0.65260106",
"0.64591074",
"0.64202434",
"0.6334059",
"0.6179951",
"0.6167599",
"0.61667216",
"0.6138746",
"0.6063657",
"0.605946",
"0.60412294",
"0.6024089",
"0.5998621",
"0.5979235",
"0.5946217",
"0.59048754",
"0.5891214",
"0.5882784",
"0.5866248",
"0.57976913... | 0.86650324 | 0 |
Test the __repr__ function of the Project model. | def test_project_repr(self):
with self.app.app_context():
p = project(slug="project", name="Project", save=True)
eq_(repr(p), '<Project: [project] Project>') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repr(self):\n foo = Project(FilePath(\"bar\"))\n self.assertEqual(repr(foo), \"Project(%r)\" % (foo.directory))",
"def test_repr(self):\n foo = Project(FilePath('bar'))\n self.assertEqual(\n repr(foo), 'Project(%r)' % (foo.directory))",
"def test_repr():\n c =... | [
"0.79380965",
"0.7825642",
"0.7233653",
"0.7208413",
"0.7143264",
"0.68903",
"0.6815971",
"0.67883444",
"0.6762459",
"0.6707629",
"0.66418946",
"0.6614794",
"0.6576248",
"0.6576248",
"0.6576248",
"0.6576248",
"0.6576248",
"0.6570561",
"0.65669024",
"0.65509444",
"0.6509135",
... | 0.84027827 | 0 |
Test loading of recent statuses for a project. | def test_project_recent_statuses(self):
with self.app.app_context():
p = project(save=True)
u = user(save=True)
# Create 70 statuses
for i in range(70):
status(project=p, user=u, save=True)
s = status(project=p, user=u, save=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_status():\n logger.debug(\"Starting the check_status() routine.\")\n\n url = \"https://www.toggl.com/api/v8/time_entries/current\"\n token = os.environ[\"TOGGL_API_TOKEN\"]\n auth_token = base64.b64encode(f\"{token}:api_token\".encode()).decode()\n resp = requests.get(url, headers={\"Autho... | [
"0.6473298",
"0.635153",
"0.63074726",
"0.63074726",
"0.62822413",
"0.6234853",
"0.6201601",
"0.6116359",
"0.6101787",
"0.60247105",
"0.6018722",
"0.6009632",
"0.5984645",
"0.59713846",
"0.59026635",
"0.58660436",
"0.58178747",
"0.581399",
"0.5808873",
"0.5801979",
"0.5789115... | 0.75648475 | 0 |
Test that the WeekColumnClause generates the right thing. | def test_week_column_clause(self):
# Dummy object to have a "name" attribute
e = lambda: None
e.name = "test"
c = None
eq_(compile_week_column_sqlite(e, c), "strftime('%Y%W', test)")
eq_(compile_week_column_postgresql(e, c), "to_char(test, 'YYYYWW')")
eq_(compile_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weeks():\n assert_equal(datetime.timedelta(days=7), convert_delta(\"1w\"))",
"def test_weeks(self):\n d = datetime(2014, 1, 29)\n eq_(week_start(d), datetime(2014, 1, 27, 0, 0, 0))\n eq_(week_end(d), datetime(2014, 2, 2, 23, 59, 59))",
"def test_wednesday(self):\n date =... | [
"0.6432751",
"0.63473666",
"0.61770153",
"0.60826415",
"0.60353845",
"0.6013306",
"0.5977321",
"0.59392285",
"0.59301287",
"0.5923003",
"0.5915772",
"0.5915053",
"0.5880065",
"0.58589923",
"0.5838699",
"0.58327746",
"0.5722747",
"0.5686529",
"0.5684126",
"0.5675613",
"0.56345... | 0.8682297 | 0 |
Test the week_start function of the Status model. | def test_status_week_start(self):
d = datetime(2014, 5, 8, 17, 17, 51, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
d_actual = s.week_start.strftime("%Y-%m-%d")
eq_(d_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_status_weeks_at_year_start(self):\n d = datetime(2013, 12, 31, 12, 13, 45, 0)\n with self.app.app_context():\n u = user(username='testuser', save=True)\n s = status(content='my status update', created=d, user=u, save=True)\n eq_(s.week_start.strftime(\"%Y-%m-%d\"... | [
"0.83616626",
"0.69464576",
"0.6789109",
"0.65788275",
"0.6457048",
"0.6422893",
"0.64069396",
"0.6401101",
"0.6383727",
"0.6268315",
"0.6216089",
"0.6153314",
"0.6131804",
"0.6118409",
"0.6089668",
"0.60509104",
"0.59532243",
"0.58916193",
"0.5876618",
"0.58585644",
"0.57753... | 0.8738532 | 0 |
Test the week_end function of the Status model. | def test_status_week_end(self):
d = datetime(2014, 5, 8, 17, 17, 51, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
d_actual = s.week_end.strftime("%Y-%m-%d")
eq_(d_actu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_status_weeks_at_year_end(self):\n d = datetime(2014, 1, 1, 12, 13, 45, 0)\n with self.app.app_context():\n u = user(username='testuser', save=True)\n s = status(content='my status update', created=d, user=u, save=True)\n eq_(s.week_start.strftime(\"%Y-%m-%d\"), \... | [
"0.8233477",
"0.6845551",
"0.68036824",
"0.67204213",
"0.6662919",
"0.66568273",
"0.6647003",
"0.6631411",
"0.6620486",
"0.6614611",
"0.65919197",
"0.65521747",
"0.6544718",
"0.6541975",
"0.6520461",
"0.63687605",
"0.63436925",
"0.63127625",
"0.61663187",
"0.6138307",
"0.6131... | 0.8860835 | 0 |
Test the week_{start|end} function around the end of the year. | def test_status_weeks_at_year_end(self):
d = datetime(2014, 1, 1, 12, 13, 45, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
eq_(s.week_start.strftime("%Y-%m-%d"), "2013-12-30")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weeks(self):\n d = datetime(2014, 1, 29)\n eq_(week_start(d), datetime(2014, 1, 27, 0, 0, 0))\n eq_(week_end(d), datetime(2014, 2, 2, 23, 59, 59))",
"def test_wednesday(self):\n date = datetime.date(1988, 5, 4)\n self.assertEqual(date.isoweekday(), 3)\n start_da... | [
"0.72202384",
"0.6944205",
"0.6851087",
"0.68134177",
"0.671705",
"0.656679",
"0.6489247",
"0.6467046",
"0.6361605",
"0.63153404",
"0.6272321",
"0.6271848",
"0.62629914",
"0.6248644",
"0.6210934",
"0.6208731",
"0.616122",
"0.6093136",
"0.60783833",
"0.6053811",
"0.60115033",
... | 0.72202754 | 0 |
Test the week_{start|end} function around the start of the year. | def test_status_weeks_at_year_start(self):
d = datetime(2013, 12, 31, 12, 13, 45, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
eq_(s.week_start.strftime("%Y-%m-%d"), "2013-12-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weeks(self):\n d = datetime(2014, 1, 29)\n eq_(week_start(d), datetime(2014, 1, 27, 0, 0, 0))\n eq_(week_end(d), datetime(2014, 2, 2, 23, 59, 59))",
"def test_sunday(self):\n date = datetime.date(1980, 5, 4)\n self.assertEqual(date.isoweekday(), 7)\n start_date,... | [
"0.7470957",
"0.68341273",
"0.6726478",
"0.6707495",
"0.6693684",
"0.6622957",
"0.66202676",
"0.6535436",
"0.6477194",
"0.6451959",
"0.641651",
"0.6399002",
"0.6384759",
"0.63531256",
"0.6233793",
"0.6227825",
"0.6224333",
"0.61802244",
"0.6172713",
"0.6135849",
"0.60264415",... | 0.71730626 | 1 |
Test the `include_week` param of `dictify`. | def test_status_dictify_include_week(self):
d = datetime(2014, 5, 8, 17, 17, 51, 0)
with self.app.app_context():
s = status(content='my status update', created=d, save=True)
d1 = s.dictify(include_week=False)
eq_(d1.get("week_start", None), None)
eq_(d1.ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_weeks(self):\n d = datetime(2014, 1, 29)\n eq_(week_start(d), datetime(2014, 1, 27, 0, 0, 0))\n eq_(week_end(d), datetime(2014, 2, 2, 23, 59, 59))",
"def test_weekly_training_is_weekly(self):\n self.assertIsInstance(self.weekly_training.is_weekly, bool)\n self.assertTr... | [
"0.59799606",
"0.5628876",
"0.55689055",
"0.5502893",
"0.5496654",
"0.5488705",
"0.5447173",
"0.5436449",
"0.5319935",
"0.53015006",
"0.5293573",
"0.5238236",
"0.5212375",
"0.5199183",
"0.51928383",
"0.51906854",
"0.5107755",
"0.5097796",
"0.50974196",
"0.5042864",
"0.5034714... | 0.79879344 | 0 |
Make sure the index view works like it's supposed to. | def test_index_view(self):
response = self.client.get('/')
eq_(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index_view(self):\n response = self.client.get(url_for('main.index'))\n self.assertEqual(response.status_code, 200)",
"def test_index_view(self):\n response = self.client.get(reverse('index'))\n self.assertEquals(response.status_code, 200)",
"def index():\n pass",
"def... | [
"0.7291941",
"0.71232474",
"0.7037661",
"0.7029703",
"0.69959986",
"0.6897299",
"0.68384355",
"0.6778169",
"0.6765011",
"0.66536397",
"0.65870583",
"0.65506434",
"0.6536556",
"0.65247446",
"0.6522577",
"0.64995563",
"0.6498999",
"0.64752",
"0.64728224",
"0.64705855",
"0.64657... | 0.71265316 | 1 |
Make sure the project view works like it's supposed to. | def test_project_view(self):
with self.app.app_context():
p = project(save=True)
response = self.client.get('/project/%s' % p.slug)
eq_(response.status_code, 200)
response = self.client.get('/project/not-a-real-project')
eq_(response.status_code, 404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_project_view(self):\n response = self.client.get('/projects/')\n self.assertEqual(response.status_code, 200)",
"def user_project_view(cls, user, project):\r\n pass",
"def test_project_admin_views(self):\n \n self._check_project_admin_view(self.testproject,\"a... | [
"0.7107375",
"0.70435315",
"0.68293095",
"0.6828729",
"0.6634028",
"0.6627897",
"0.6423891",
"0.6423891",
"0.6373143",
"0.63483727",
"0.6324649",
"0.6324649",
"0.6324649",
"0.63243335",
"0.62829185",
"0.6280038",
"0.62500846",
"0.62067044",
"0.61663127",
"0.61609465",
"0.6160... | 0.7253505 | 0 |
Make sure the Atom feed works with no status updates. | def test_feeds_no_statuses(self):
rv = self.client.get('/statuses.xml')
eq_(rv.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_feed(app, status, warning):\n app.build()\n assert app.statuscode == 0\n\n feed_path = app.outdir / \"blog/atom.xml\"\n assert (feed_path).exists()\n\n with feed_path.open() as feed_opened:\n feed_tree = lxml.etree.parse(feed_opened)\n entries = feed_tree.findall(\"{http://www.w3.... | [
"0.6835991",
"0.64578855",
"0.6295441",
"0.625764",
"0.6122108",
"0.60887194",
"0.6051578",
"0.5944181",
"0.5819396",
"0.5798948",
"0.5683095",
"0.56825566",
"0.56687045",
"0.56673497",
"0.5664007",
"0.56639534",
"0.5616004",
"0.5591796",
"0.5588172",
"0.5587753",
"0.5587734"... | 0.66492504 | 1 |
Test feeds for non existant objects | def test_feeds_do_not_exist(self):
rv = self.client.get('/user/who.xml')
eq_(rv.status_code, 404)
rv = self.client.get('/project/fake.xml')
eq_(rv.status_code, 404)
rv = self.client.get('/team/not-real.xml')
eq_(rv.status_code, 404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_empty_feed(self, items, rest_of_world):\n if not items or (len(items) == 1 and items[0].get('shelf')):\n # Empty feed.\n if rest_of_world:\n return -1\n return 0\n return 1",
"def test_invalid_source_couchdb(self):\n with self.assert... | [
"0.63835967",
"0.62838155",
"0.6250704",
"0.62298465",
"0.62261206",
"0.621487",
"0.6144546",
"0.5962096",
"0.59538424",
"0.58879393",
"0.58648056",
"0.5765122",
"0.57643414",
"0.57216215",
"0.5687507",
"0.5675347",
"0.5660919",
"0.5654927",
"0.56497484",
"0.5635615",
"0.5635... | 0.71294767 | 0 |
Test posting a status with no message. | def test_status_no_message(self):
with self.app.app_context():
u = user(email='joe@example.com', save=True)
authenticate(self.client, u)
rv = self.client.post('/statusize/', data={'message': ''},
follow_redirects=True)
# This kicks up a 404, bu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_status_no_login(self):\n self.logout()\n post_json = {\"submission_id\": self.status_check_submission_id}\n response = self.app.post_json(\"/v1/check_status/\", post_json, expect_errors=True,\n headers={\"x-session-id\": self.session_id})\n ... | [
"0.7201963",
"0.6949421",
"0.6923064",
"0.69161886",
"0.6813586",
"0.66684335",
"0.6579005",
"0.6507071",
"0.64746195",
"0.6440355",
"0.6384444",
"0.6365908",
"0.63456374",
"0.6339759",
"0.6318823",
"0.6302569",
"0.6298929",
"0.6298929",
"0.62898874",
"0.627214",
"0.6268902",... | 0.8056997 | 0 |
Test posting a status with a project. | def test_status_with_project(self):
with self.app.app_context():
u = user(email='joe@example.com', save=True)
p = project(name='blackhole', slug='blackhole', save=True)
data = {'message': 'r1cky rocks!', 'project': p.id}
authenticate(self.client, u)
rv = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_projects_post(self):\n project = Project()\n response = self.client.open('/project-tracker/projects',\n method='POST',\n data=json.dumps(project),\n content_type='application/json')\n ... | [
"0.74586385",
"0.7216196",
"0.69448817",
"0.69277596",
"0.6804187",
"0.6725366",
"0.6686353",
"0.6686353",
"0.663884",
"0.6617445",
"0.65784293",
"0.6564429",
"0.65430015",
"0.6496777",
"0.6490737",
"0.64863753",
"0.643171",
"0.64247245",
"0.64239454",
"0.639966",
"0.6381403"... | 0.8201474 | 0 |
Decorate a function to ensure the first arg being submitted is either a Dataset or DataArray. | def is_xarray(func, *dec_args):
@wraps(func)
def wrapper(*args, **kwargs):
try:
ds_da_locs = dec_args[0]
if not isinstance(ds_da_locs, list):
ds_da_locs = [ds_da_locs]
for loc in ds_da_locs:
if isinstance(loc, int):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_inputs(function):\n def decorated(self, data, *args, **kwargs):\n if not (isinstance(data, np.ndarray) and len(data.shape) == 2 and data.shape[1] == 1):\n raise ValueError('The argument `data` must be a numpy.ndarray with shape (n, 1).')\n\n return function(self, data, *args, ... | [
"0.67674077",
"0.64274913",
"0.57832295",
"0.56677085",
"0.5607064",
"0.5605012",
"0.5602898",
"0.56021005",
"0.55504334",
"0.5547576",
"0.55301267",
"0.55263126",
"0.55132675",
"0.5495199",
"0.54852957",
"0.54453933",
"0.5425492",
"0.5423",
"0.53411466",
"0.5329185",
"0.5301... | 0.69493866 | 0 |
Checks that at the minimum, the object has provided dimensions. | def has_dims(xobj, dims, kind):
if isinstance(dims, str):
dims = [dims]
if not all(dim in xobj.dims for dim in dims):
raise DimensionError(
f'Your {kind} object must contain the '
f'following dimensions at the minimum: {dims}'
)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_dimensions(self) -> None:\n dims = (self.y_dim, self.x_dim)\n da = self._obj[self.vars[0]] if isinstance(self._obj, xr.Dataset) else self._obj\n extra_dims = [dim for dim in da.dims if dim not in dims]\n if len(extra_dims) == 1:\n dims = tuple(extra_dims) + dims\n ... | [
"0.71973795",
"0.66598827",
"0.6652556",
"0.6621302",
"0.6527767",
"0.6464313",
"0.64623004",
"0.64564466",
"0.64167625",
"0.63492084",
"0.63252366",
"0.6256437",
"0.6236625",
"0.61707157",
"0.6160307",
"0.6137123",
"0.6123389",
"0.60822576",
"0.60810775",
"0.60706764",
"0.60... | 0.7164908 | 1 |
Checks that the array is at least the specified length. | def has_min_len(arr, len_, kind):
arr_len = len(arr)
if arr_len < len_:
raise DimensionError(
f'Your {kind} array must be at least {len_}, '
f'but has only length {arr_len}!'
)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LengthTest(arr):\n\tif len(arr) == 8:\n\t\treturn True;\n\telif len(arr) == 7:\n\t\treturn IsMissingField('cid', arr)\n\telse:\n\t\treturn False",
"def has_definite_size(iterable):\n return hasattr(iterable, '__len__')",
"def check_consistent_length(arrays: Sequence[npt.ArrayLike]) -> None:\n lengths... | [
"0.7045086",
"0.69550073",
"0.66807944",
"0.66467315",
"0.65652573",
"0.6508588",
"0.649857",
"0.63973033",
"0.638944",
"0.6372922",
"0.63468534",
"0.6344845",
"0.6343781",
"0.6341784",
"0.63383394",
"0.6317262",
"0.62815475",
"0.62730503",
"0.62381244",
"0.62193894",
"0.6203... | 0.82707816 | 0 |
Checks that the reference dimensions match appropriate initialized dimensions. If uninitialized, ignore 'member'. Otherwise, ignore 'lead' and 'member'. | def match_initialized_dims(init, ref, uninitialized=False):
# since reference products won't have the initialization dimension,
# temporarily rename to time.
init = init.rename({'init': 'time'})
init_dims = list(init.dims)
if 'lead' in init_dims:
init_dims.remove('lead')
if ('member' in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_verify_reference_same_dims(perfectModelEnsemble_initialized_control):\n pm = perfectModelEnsemble_initialized_control.generate_uninitialized()\n pm = pm.isel(lead=[0, 1, 2], init=[0, 1, 2])\n metric = \"mse\"\n comparison = \"m2e\"\n dim = \"init\"\n actual_no_ref = pm.verify(\n m... | [
"0.63892365",
"0.5941461",
"0.5922711",
"0.5867122",
"0.58525753",
"0.5823122",
"0.55616474",
"0.55140597",
"0.54647905",
"0.5436583",
"0.54341036",
"0.5396807",
"0.53695035",
"0.53636837",
"0.53424156",
"0.5328619",
"0.5301063",
"0.52989846",
"0.5285114",
"0.5285059",
"0.525... | 0.6501884 | 0 |
Checks that a new reference (or control) dataset has at least one variable in common with the initialized dataset. This ensures that they can be compared pairwise. | def match_initialized_vars(init, ref):
init_vars = init.data_vars
ref_vars = ref.data_vars
# https://stackoverflow.com/questions/10668282/
# one-liner-to-check-if-at-least-one-item-in-list-exists-in-another-list
if set(init_vars).isdisjoint(ref_vars):
raise VariableError(
'Please... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_dataset_consistency(self):\n if not self.multi_dataset: \n raise MutantError(\"_check_dataset_consistency only makes sense for multi-datasets!\")\n def _check_sets_raise_error(set1, set2, set1_name, set2_name):\n if not set1==set2:\n raise MutantError(... | [
"0.6559695",
"0.64126575",
"0.6134037",
"0.60592747",
"0.59999657",
"0.5986645",
"0.587413",
"0.58625877",
"0.5837595",
"0.5830325",
"0.57788134",
"0.57457954",
"0.5678638",
"0.5620417",
"0.5592057",
"0.55767757",
"0.55720913",
"0.55549836",
"0.5544577",
"0.5535928",
"0.55305... | 0.7352274 | 0 |
Check whether an item is in a list; kind is just a string. | def is_in_list(item, list_, kind):
if item not in list_:
raise KeyError(f'Specify {kind} from {list_}: got {item}')
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isList(self, item):\n\t retval = False\n\t if type(item) in (ListType, TupleType) :\n\t retval = True",
"def _is_list(item):\n return isinstance(item, list)",
"def _is_in_list(l, valid_l):\n\n for elem in l:\n if Settings._is_primitive(elem):\n if not Settings._is_in... | [
"0.7021183",
"0.67562884",
"0.66337615",
"0.6577507",
"0.6478335",
"0.6457706",
"0.64438295",
"0.64166516",
"0.6394912",
"0.63919556",
"0.63097334",
"0.6309731",
"0.6302186",
"0.62983406",
"0.62785506",
"0.6268537",
"0.6239638",
"0.6180043",
"0.6126522",
"0.6114221",
"0.60942... | 0.84802943 | 0 |
to seperate by nbytes to different files | def Seperate(f_read, f_write_name):
lines = f_read.readlines()
line_s = [line.split() for line in lines]
for i in range(6, 13):
nbytes = pow(2,i)
f_write = f_write_name + str(nbytes) + "b.txt"
f = open(f_write, "w+")
for line in line_s:
if line[3] == str(nbytes)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splitFile(filename, n):\n in_file = open(filename)\n line = in_file.readline()\n count = 0\n while line <> \"\":\n if count < 10: num = \"0\"+str(count)\n else: num = str(count)\n f = open(\"output/\"+filename+\"-\"+num,\"w\")\n for i in range(n):\n if line ==... | [
"0.6571904",
"0.65097827",
"0.6118995",
"0.5988217",
"0.59850276",
"0.5945666",
"0.5910023",
"0.57907903",
"0.5722481",
"0.5643262",
"0.56297284",
"0.56196105",
"0.55893993",
"0.55658495",
"0.5523404",
"0.5513597",
"0.5506873",
"0.5497721",
"0.54768145",
"0.54430634",
"0.5441... | 0.66836053 | 0 |
Run the validation for the current data. MUST BE OVERRIDDEN BY THE USER By default, this returns ``NotImplementedError``. | def validate(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self):\n raise NotImplementedError(\"validate function needs to be implemented for validators\")",
"def validate(self):\n raise NotImplementedError('validate method not implemented.')",
"def validate(self):\n raise NotImplementedError()",
"def Validate(self):\n raise NotI... | [
"0.76561004",
"0.7616243",
"0.75926286",
"0.73546165",
"0.7302044",
"0.7253421",
"0.7202504",
"0.7191916",
"0.712734",
"0.712734",
"0.712734",
"0.712734",
"0.712734",
"0.712734",
"0.712734",
"0.712734",
"0.7049217",
"0.69627583",
"0.6961386",
"0.69554317",
"0.6953269",
"0.6... | 0.7663959 | 1 |
Add message error for a field. | def add_error(self, field, message):
add_list_value(self.errors, field, message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_message(self, error_field=None, **kwargs):\n\n if error_field:\n return \"Validation failed in Validator \\\"{}\\\" on field \\\"{}\\\"\".format(self.__class__.__name__, error_field)\n return \"Validation failed in Validator \\\"{}\\\"\".format(self.__class__.__name__)",
"def e... | [
"0.7599287",
"0.7313962",
"0.71314716",
"0.7058884",
"0.6715801",
"0.6687381",
"0.6651646",
"0.66483325",
"0.6566156",
"0.6498605",
"0.6266045",
"0.626373",
"0.62412614",
"0.6224567",
"0.6207376",
"0.6121861",
"0.6121136",
"0.6024853",
"0.5969752",
"0.5968636",
"0.5929933",
... | 0.82044226 | 0 |
Save current data for CallEvent. This function calls an async job to save the current data. | def save(self):
# send data to be saved by another job
save_callevent.delay(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def persistData(self):\n\n call_data = self.data\n\n call, created = Call.objects.update_or_create(\n call_id=call_data.get('call_id'),\n defaults=call_data\n )\n\n if not created:\n call.refresh_from_db()\n self.persisted_data = call\n ret... | [
"0.6577137",
"0.59424883",
"0.59046453",
"0.5822146",
"0.57159835",
"0.5595816",
"0.554675",
"0.5530205",
"0.5493683",
"0.5481861",
"0.5462773",
"0.54595935",
"0.54430693",
"0.54261476",
"0.5422521",
"0.5421429",
"0.54210997",
"0.5407424",
"0.5397306",
"0.5378384",
"0.5337597... | 0.7813169 | 0 |
Process Bill current data. | def handle(self):
self.validate()
if self.errors:
raise InvalidDataException(self.errors)
phone_number = self.data.get('phone_number')
month = self.data.get('month')
year = self.data.get('year')
# if a period was not informed, get the current last one
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bill_handler(data):\n return BillHandler(data)",
"def process_deal(self, data):\n for i in data:\n if i.status == OrderStatus.PARTIALLY_FILLED or i.status == OrderStatus.FILLED:\n symbol, exchange = convert_symbol_tiger2vt(str(i.contract))\n self.tradeid += ... | [
"0.64300424",
"0.5972971",
"0.5840716",
"0.57267725",
"0.5645599",
"0.5611629",
"0.5566578",
"0.5532405",
"0.5518817",
"0.550737",
"0.54749537",
"0.54644704",
"0.5458061",
"0.54263884",
"0.54090387",
"0.54090387",
"0.54090387",
"0.53795475",
"0.53674847",
"0.53633726",
"0.536... | 0.66551983 | 0 |
Convenient function to return CallEvent handler instance. | def callevent_handler(data):
return CallEventHandler(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_event(self, hclass, event, *args, **kwargs):\n signal = self.signals.get_signal((hclass, event))\n event = Event(signal.name, self)\n ret = signal.call(event, *args, **kwargs) # FIXME should be coroutine\n return (event, ret)",
"def create_event() -> abc.Event:\n return g... | [
"0.61877227",
"0.56290776",
"0.5514893",
"0.5472287",
"0.5423003",
"0.53900313",
"0.53869385",
"0.53429985",
"0.5308292",
"0.5287016",
"0.5287016",
"0.5192604",
"0.51753825",
"0.5169624",
"0.5154342",
"0.5150147",
"0.5145951",
"0.5132487",
"0.5116136",
"0.50812685",
"0.504729... | 0.7149864 | 0 |
Convenient function to return Bill handler instance. | def bill_handler(data):
return BillHandler(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_handler(cls):\n if cls.__instance is None:\n cls.__instance = AliceBlueApi()\n return cls.__instance",
"def get_bh_obj(self, dbName):\n bh_xml = self.get_batchHistorical_XML(dbName)\n return self.get_batchHistorical_obj(bh_xml)",
"def get_handler(self):\n r... | [
"0.5837129",
"0.5660788",
"0.53860235",
"0.5356632",
"0.52412736",
"0.51488864",
"0.5145289",
"0.5141486",
"0.51175463",
"0.50862247",
"0.50208473",
"0.5017006",
"0.501412",
"0.50135314",
"0.4983343",
"0.49492487",
"0.49440217",
"0.4903349",
"0.48964068",
"0.4875863",
"0.4866... | 0.7591026 | 0 |
Value of the node equal to total if there are no children otherwise equal othe sum of the value of children referenced by cardinal index in meta | def value(self):
if self.children == tuple():
return sum(self.meta)
total = 0
for meta in self.meta:
if 0 < meta <= len(self.children):
total += self.children[meta-1].value()
return total | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total(self):\n return sum(self.meta) + sum(child.total() for child in self.children)",
"def total_value(self):\n return self.parent.child_total_value[self.action]",
"def total(tree):\n if tree is None:\n return 0\n return total(tree.left) + total(tree.right) + tree.cargo",
"def... | [
"0.75193995",
"0.7090225",
"0.6833369",
"0.67395985",
"0.6575276",
"0.6499926",
"0.6339678",
"0.630775",
"0.62239635",
"0.60891306",
"0.60015976",
"0.598772",
"0.5975482",
"0.5940115",
"0.59390444",
"0.5911306",
"0.58939373",
"0.5876452",
"0.58716124",
"0.586836",
"0.58667994... | 0.79557794 | 0 |
Sum of meta plus the total of all child nodes | def total(self):
return sum(self.meta) + sum(child.total() for child in self.children) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n if self.children == tuple():\n return sum(self.meta)\n total = 0\n for meta in self.meta:\n if 0 < meta <= len(self.children):\n total += self.children[meta-1].value()\n return total",
"def compute_node_sums(nodes):\n for ... | [
"0.74751604",
"0.69016945",
"0.6744781",
"0.6410817",
"0.629062",
"0.61332744",
"0.61299336",
"0.6067545",
"0.5979318",
"0.59661347",
"0.59570414",
"0.59568745",
"0.59314394",
"0.5910669",
"0.58150107",
"0.5808881",
"0.58080286",
"0.5805435",
"0.5795782",
"0.57718265",
"0.575... | 0.8090835 | 0 |
Returns a tree and the number of items read from records | def build(cls, records):
children = []
i = 2
for _ in range(records[0]):
j, child = cls.build(records[i:])
i += j
children.append(child)
return (i + records[1]), cls(tuple(records[i:i+records[1]]), tuple(children)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def part1(records):\n _, root = Node.build(records)\n return root.total()",
"def gbRecordSizer(recordLines):\n from Bio import SeqIO\n record = SeqIO.read(recordLines,'genbank')\n return len(record)",
"def get_tree_size(cur):\n sql = \"\"\"\n SELECT\n COUNT(*)\n FROM\n ... | [
"0.66247857",
"0.5619292",
"0.55071753",
"0.55022055",
"0.5421426",
"0.54014426",
"0.5342836",
"0.53116477",
"0.5294181",
"0.527001",
"0.52267885",
"0.5213094",
"0.5200736",
"0.5200254",
"0.5183346",
"0.5159723",
"0.51134664",
"0.511233",
"0.50889426",
"0.5079547",
"0.5078990... | 0.5670042 | 1 |
Displays classified image with top predicted class as title and horizontal bar chart of predicted probabilities of predicted top classes | def display_prediction(image_path, probabilities, predictions):
top_class = predictions[0]
# Setup plot gird and title
fig = plt.figure(figsize=(4, 5.4))
ax1 = plt.subplot2grid((2, 1), (0, 0))
ax2 = plt.subplot2grid((2, 1), (1, 0))
fig.suptitle(top_class.capitalize(), x=0.6, y=1, fontsize=16)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_prediction(top_p, top_class, image_path, cat_to_name):\n # Create a Path object that defines where the image lives. This will help categorize the image by using the parent directory ID.\n path = Path(image_path)\n\n # Get the names of each class\n names = [cat_to_name[str(c)] for c in top_c... | [
"0.7790771",
"0.74688953",
"0.728419",
"0.7250048",
"0.7156965",
"0.70418864",
"0.7005864",
"0.68334913",
"0.67379767",
"0.6721212",
"0.6688149",
"0.6659827",
"0.66352",
"0.6618896",
"0.6612142",
"0.6602421",
"0.6587695",
"0.6572992",
"0.6572382",
"0.657004",
"0.6568309",
"... | 0.8097561 | 0 |
test deletion of a part | def test_delete_part():
content_parts = ContentPartRepository(DB)
test_part = ContentPart("001", 1, "front", "Content 001 front matter content v1")
content_parts.add_or_update_content_part(test_part)
part = content_parts.get_content_part(
test_part.content_id,
test_part.version,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deleting_a_segment(self):\n pass",
"def test_delete_run(self):\n pass",
"def test_delete_unknown_part():\n content_parts = ContentPartRepository(DB)\n test_part = ContentPart(\"998\", 1, \"front\", \"Content 001 front matter content v1\")\n\n content_parts.delete_content_part(\n... | [
"0.7695575",
"0.74451977",
"0.7388344",
"0.73298687",
"0.723345",
"0.721669",
"0.71612936",
"0.7058679",
"0.7038795",
"0.699258",
"0.69905293",
"0.6938634",
"0.689907",
"0.6876178",
"0.6847478",
"0.67984086",
"0.679399",
"0.6785987",
"0.676931",
"0.6755514",
"0.6753548",
"0... | 0.7932837 | 0 |
test deletion of an unknown part | def test_delete_unknown_part():
content_parts = ContentPartRepository(DB)
test_part = ContentPart("998", 1, "front", "Content 001 front matter content v1")
content_parts.delete_content_part(
test_part.content_id,
test_part.version,
test_part.part_name
)
# should succeed with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deleting_a_segment(self):\n pass",
"def test_delete_part():\n content_parts = ContentPartRepository(DB)\n test_part = ContentPart(\"001\", 1, \"front\", \"Content 001 front matter content v1\")\n content_parts.add_or_update_content_part(test_part)\n part = content_parts.get_content_pa... | [
"0.75592434",
"0.7469026",
"0.7082972",
"0.70620626",
"0.69433826",
"0.6927957",
"0.6918441",
"0.66657805",
"0.66232866",
"0.65941745",
"0.65907836",
"0.65786546",
"0.6574386",
"0.6556716",
"0.65324837",
"0.6516587",
"0.65045065",
"0.64942455",
"0.64762455",
"0.6460559",
"0.6... | 0.7612974 | 0 |
Test if check_estimator passes. | def test_check_estimator(estimator):
check_estimator(estimator) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_estimator_passed(estimator_class):\n estimator_instance = estimator_class.create_test_instance()\n\n result_class = check_estimator(estimator_class, verbose=False)\n assert all(x == \"PASSED\" for x in result_class.values())\n\n result_instance = check_estimator(estimator_instance, verbo... | [
"0.80959433",
"0.788",
"0.716171",
"0.7135777",
"0.69051164",
"0.68552",
"0.6739199",
"0.67147166",
"0.66096014",
"0.6544982",
"0.65300125",
"0.65168136",
"0.6454732",
"0.64471126",
"0.63448036",
"0.63052756",
"0.6285852",
"0.6276287",
"0.6228733",
"0.6198588",
"0.6192282",
... | 0.9097493 | 0 |
Handles requests to delete the feedback with the given feedback_id. | def feedback_delete(request, feedback_id):
store = SESSION.get_store(request.session)
# get the feedback from the messages_received_list in session cache
messages_received_list = SESSION.get_messages_received_list(\
request.session)
i_remove, feedback = 0, None
for ind, m in enumerate(m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_delete_feedback(request, id):\n\n close_old_connections()\n \n # Not marking it as served if it isn't even ready yet.\n if not request.user.is_authenticated:\n return HttpResponseForbidden(\"You're not authenticated.\")\n \n # Delete the feedback.\n Feedback.objects.get(id=id).d... | [
"0.8160355",
"0.78569925",
"0.78176135",
"0.7574826",
"0.73686093",
"0.6502442",
"0.62784785",
"0.61090565",
"0.60895765",
"0.6086703",
"0.6070523",
"0.6036125",
"0.5935712",
"0.59251213",
"0.5901508",
"0.587811",
"0.587575",
"0.58570015",
"0.5855246",
"0.5809003",
"0.5801402... | 0.81376773 | 1 |
Creates thread, which will await new client and tell the client current (if nonzero) state on connection. "daemon = True" means "die if all other threads are dead" !! Should be called only on main thread with have_client_to_speak_with set to False first. Otherwise can result in multiple threads, each one writing state ... | def init_client_seeker():
client_seeker = threading.Thread(target=seek_for_client)
client_seeker.daemon = True
client_seeker.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seek_for_client():\n global have_client_to_speak_with\n \n win32pipe.DisconnectNamedPipe(pipe) #in case there were connection to dead client\n log_threadsafe(obs.LOG_DEBUG, 'Waiting for a new client')\n win32pipe.ConnectNamedPipe(pipe, None) #seek for new client\n log_threadsafe(obs.LOG_DEBUG... | [
"0.6031676",
"0.59984016",
"0.59984016",
"0.58910114",
"0.58797324",
"0.58580804",
"0.58397484",
"0.58056575",
"0.5750222",
"0.5733554",
"0.5697208",
"0.56557536",
"0.56497175",
"0.56365186",
"0.562158",
"0.56081617",
"0.5605185",
"0.55930245",
"0.5590876",
"0.5588366",
"0.55... | 0.623583 | 0 |
Disconnects old (dead) client and wait for a new one. On connection sends curren (if nonzero) state to the new client. Calls pipe_send_state(), reads state and modyfies have_client_to_speak_with. That's why most of operations on that variables/function must be guarded with mutex_state_sending. See comments above for de... | def seek_for_client():
global have_client_to_speak_with
win32pipe.DisconnectNamedPipe(pipe) #in case there were connection to dead client
log_threadsafe(obs.LOG_DEBUG, 'Waiting for a new client')
win32pipe.ConnectNamedPipe(pipe, None) #seek for new client
log_threadsafe(obs.LOG_DEBUG, 'A client... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipe_send_state(should_seek_new_client_on_fail=True):\n global have_client_to_speak_with\n \n if have_client_to_speak_with:\n log_threadsafe(obs.LOG_DEBUG, 'Sending %d to pipe' % state)\n try:\n win32file.WriteFile(pipe, str(state).encode('utf-8'))\n except pywintypes.e... | [
"0.6485937",
"0.6325655",
"0.5730386",
"0.57117444",
"0.56294435",
"0.5588799",
"0.54520696",
"0.5417959",
"0.5390762",
"0.5348496",
"0.532897",
"0.5312628",
"0.5282257",
"0.52460295",
"0.5241522",
"0.52319646",
"0.52246296",
"0.5206628",
"0.52012765",
"0.51943886",
"0.519205... | 0.67902863 | 0 |
Extract data / files from the application `app`. A extractor should put these files at `result_path` and log any errors to `logger`. The return code should be `True` on success, `False` otherwise. | def extract_data(self, app : Bundle, result_path : str) -> bool:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_application_file(self, application):\n # 1. Get the path of the app_config directory\n app_conf_dir = self.sys_conf['configs']['env'][self.env]['app_config_url']\n\n # 2. Get the path for the given application configuration file\n app_conf_dir += '/{file}.yaml'.format(file... | [
"0.51713",
"0.51351815",
"0.5070502",
"0.5006909",
"0.49494296",
"0.48960212",
"0.48624113",
"0.48357296",
"0.4821892",
"0.47723943",
"0.4735612",
"0.47250524",
"0.4720484",
"0.4704852",
"0.46886972",
"0.46639046",
"0.46378937",
"0.46374047",
"0.4626576",
"0.4626012",
"0.4625... | 0.7481783 | 0 |
Returns a list of all extractor classes | def all_extractors():
import os.path
import importlib
import inspect
extractors = []
# Rudimentary parsing of the directory to find all python files
plugin_dir = os.path.dirname(__file__)
# Assuming the plugins are all stored in the extractors/ dir where also
# the base class is store... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_extractor_classes():\n from .extractors import _ALL_CLASSES\n\n return _ALL_CLASSES",
"def gen_extractors():\n return [klass() for klass in gen_extractor_classes()]",
"def get_classes(self):\n query = read_query('structure exploration/classes')\n response = self._submit_query(que... | [
"0.8139812",
"0.7888099",
"0.7181725",
"0.7095149",
"0.70722044",
"0.6925459",
"0.69171095",
"0.68636954",
"0.6830808",
"0.6830808",
"0.6830808",
"0.6830808",
"0.6830808",
"0.6830808",
"0.6829222",
"0.6816609",
"0.67426676",
"0.67400193",
"0.6680297",
"0.656685",
"0.6564237",... | 0.7946651 | 1 |
Parse a CHIRP security token. | def _parse_security_token(token):
if not token:
return None
if ':' not in token:
logging.warn('Malformed token: no signature separator')
return None
sig, body = token.split(':', 1)
if _DISABLE_CRYPTO:
plaintext = body
else:
key_storage = KeyStorage.get()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_token(self, response=None):\n token_url = 'https://tinychat.com/start?#signin'\n if response is None:\n response = util.web.http_get(url=token_url, referer=token_url, proxy=self._proxy)\n\n if response is not None and response['content'] is not None:\n soup = B... | [
"0.6144686",
"0.60707945",
"0.6040866",
"0.5988779",
"0.57434446",
"0.57302487",
"0.55320007",
"0.54820126",
"0.5480701",
"0.5480701",
"0.5480701",
"0.5467807",
"0.5436225",
"0.5368838",
"0.53524274",
"0.534094",
"0.5266281",
"0.52243197",
"0.5222019",
"0.51838434",
"0.517491... | 0.67126787 | 0 |
Attach a user's credentials to a response. | def attach_credentials(response, user):
response.set_cookie(_CHIRP_SECURITY_TOKEN_COOKIE,
_create_security_token(user)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_credentials():",
"def test_credentialsSetResponse(self):\n cred = imap4.PLAINCredentials()\n cred.setResponse(b'\\0testuser\\0secret')\n self.assertEqual(cred.username, b'testuser')\n self.assertEqual(cred.password, b'secret')",
"def get_user_details(self, response):\n ... | [
"0.62017906",
"0.61743724",
"0.5863988",
"0.5680074",
"0.5572465",
"0.55617046",
"0.55614007",
"0.5557779",
"0.5540854",
"0.55386317",
"0.5523414",
"0.5503794",
"0.5500769",
"0.54540765",
"0.5449879",
"0.5427805",
"0.54111546",
"0.54075456",
"0.53991103",
"0.5397431",
"0.5392... | 0.77924997 | 0 |
Returns the URL of a login page that redirects to 'path' on success. | def create_login_url(path):
return "/auth/hello?redirect=%s" % path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GET_login(self):\r\n\r\n # dest is the location to redirect to upon completion\r\n dest = request.get.get('dest','') or request.referer or '/'\r\n return LoginPage(dest = dest).render()",
"def login_page():\n text = '<a href=\"%s\">Authenticate with Okta</a>'\n return text % create... | [
"0.7192956",
"0.6800965",
"0.66827124",
"0.66450155",
"0.65036446",
"0.6477103",
"0.6422007",
"0.63984793",
"0.6378266",
"0.6354311",
"0.6330546",
"0.6328878",
"0.6328678",
"0.63281304",
"0.63243735",
"0.6307606",
"0.62386686",
"0.6232495",
"0.6208821",
"0.62072647",
"0.61902... | 0.79841524 | 0 |
Create an HTTP response that will log a user out. The redirect param can be a relative URL in which case the user will go back to the same page when logging in. This is useful for switching users like on the playlist tracker page. | def logout(redirect=None):
# If the user was signed in and has a cookie, clear it.
logout_url = _FINAL_LOGOUT_URL
if redirect:
logout_url = '%s?redirect=%s' % (logout_url, redirect)
response = http.HttpResponseRedirect(logout_url)
response.set_cookie(_CHIRP_SECURITY_TOKEN_COOKIE, '')
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect(self) -> WerkzeugResponse:\n\n _dict = self.unpack_redirect()\n return self.perform_logout(_dict, BINDING_HTTP_REDIRECT)",
"def logout_redirect(request):\n logout(request)\n\n # Build the URL\n login_url = furl(login_redirect_url(request, next_url=request.build_absolute_uri())... | [
"0.7326342",
"0.73198265",
"0.7284289",
"0.7238084",
"0.71671414",
"0.71593136",
"0.7151981",
"0.71129674",
"0.70879936",
"0.7079564",
"0.7043046",
"0.7023484",
"0.70197374",
"0.7015899",
"0.701423",
"0.7005902",
"0.69992566",
"0.69971395",
"0.69959456",
"0.69959456",
"0.6989... | 0.77370954 | 0 |
A URLsafe token that authenticates a user for a password reset. | def get_password_reset_token(user):
return base64.urlsafe_b64encode(_create_security_token(user)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_password_reset_token():\n j = request.get_json(force=True)\n user_requested = j['user'].lower()\n\n # Disabled user accounts can not request for a new password.\n target_user = User.query.filter_by(mail=user_requested).first()\n\n if target_user is None:\n return Errors.UNKNOWN_US... | [
"0.7068343",
"0.6979489",
"0.6916166",
"0.69147855",
"0.68065274",
"0.6756396",
"0.6722973",
"0.67225903",
"0.6698638",
"0.66768074",
"0.66731113",
"0.66554016",
"0.6653242",
"0.65514797",
"0.6548692",
"0.65352726",
"0.65276843",
"0.65198666",
"0.6503898",
"0.650001",
"0.6499... | 0.76141065 | 0 |
Extracts an email address from a valid password reset token. | def parse_password_reset_token(token):
try:
token = base64.urlsafe_b64decode(str(token))
except TypeError:
return None
cred = _parse_security_token(token)
return cred and cred.email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_password_reset_token(token: str) -> tp.Optional[str]:\n try:\n decoded_token = jwt.decode(token, config.SECRET_KEY,\n algorithms=[ALGORITHM])\n except InvalidTokenError:\n return None\n if decoded_token[\"sub\"] != PASSWORD_RESET_SUBJECT:\n ... | [
"0.7039985",
"0.68341273",
"0.68253404",
"0.679571",
"0.67610675",
"0.6760937",
"0.6741547",
"0.6654214",
"0.65531987",
"0.640023",
"0.62692463",
"0.6200448",
"0.61567795",
"0.6123652",
"0.60978174",
"0.60570717",
"0.6042387",
"0.60345566",
"0.60287344",
"0.6026899",
"0.60162... | 0.80168754 | 0 |
Display or save a line plot of the dataframe. | def line_plot(self, df, show_figure=True, filename=None, **kwargs):
if self._interactive and show_figure:
return line_plot(df=df, filename=None, **kwargs)
if not self._interactive and filename is not None:
return line_plot(df=df, filename=filename, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linePlot(self):\n clf()\n plot(self.x,self.averages)\n xlabel('X Label (units)')\n ylabel('Y Label (units)')\n savefig('line.png')",
"def graph(df):\n df.plot()\n plt.show()",
"def line_graph():\r\n #create the data in an array\r\n xval = np.arange(0,6,(np.pi*... | [
"0.7247399",
"0.7064947",
"0.7009128",
"0.68883586",
"0.6884624",
"0.6852269",
"0.66661745",
"0.6652541",
"0.66047895",
"0.6523031",
"0.6508674",
"0.6485286",
"0.6472643",
"0.6460924",
"0.6446598",
"0.6407095",
"0.63918054",
"0.6377627",
"0.63767356",
"0.6328446",
"0.628481",... | 0.7667313 | 0 |
Show the details of complement that was (or will be) performed for the records. | def show_complement(self, **kwargs):
self._data.switch_complement(whether=None, **kwargs)
return self._data.show_complement() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Complement(self):\n if (self.translated == False):\n for i in range(len(self.alignment)):\n self.alignment[i].seq = self.alignment[i].seq.complement()\n self.Show(self.displayedColumn)\n self.BackupAlignment\n else:\n self.AlertMessage(\"... | [
"0.5775242",
"0.5743464",
"0.55356264",
"0.5504451",
"0.5423902",
"0.5415966",
"0.53729266",
"0.536349",
"0.5347733",
"0.52742505",
"0.5256045",
"0.5240801",
"0.52383417",
"0.5233155",
"0.5202733",
"0.5180749",
"0.51699567",
"0.5141384",
"0.5086646",
"0.5080214",
"0.5080147",... | 0.72387177 | 0 |
Initialize dictionary of trackers. | def _init_trackers(self):
data = copy.deepcopy(self._data)
series = ParamTracker.create_series(
first_date=data.first_date, last_date=data.today, population=data.population)
tracker = ParamTracker(
record_df=self._data.records(extras=False), phase_series=series, area=self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, keys_to_track):\r\n self.keys_to_track = keys_to_track\r\n self.tracker = {}\r\n for key_to_track in self.keys_to_track:\r\n self.tracker[key_to_track] = {}",
"def __init__(self,max_age=100,min_hits=10):\n self.max_age = max_age\n self.min_hits = m... | [
"0.75012267",
"0.6427343",
"0.62639487",
"0.6080427",
"0.6077556",
"0.60689676",
"0.60171473",
"0.59739995",
"0.59257585",
"0.59130996",
"0.59109986",
"0.5875346",
"0.5845771",
"0.58061785",
"0.5783098",
"0.5781152",
"0.57698804",
"0.5769008",
"0.57673883",
"0.57673883",
"0.5... | 0.78069323 | 0 |
The phases will be disabled and removed from summary. | def disable(self, phases, name="Main"):
self[name] = self._tracker(name).disable(phases)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phase(self):\n pass",
"def phases(self):\n return self._phases",
"def unstudied_skills(self):\n undone = [task for task in self.skills if task not in self.done_skills]\n print(\"Hello \"+ str(self.user_name)+\" :)\\nHere are the skills that are still incomplete: \")\n for... | [
"0.56792605",
"0.56478065",
"0.5620661",
"0.55673957",
"0.5443464",
"0.54326624",
"0.53489864",
"0.5344841",
"0.5331238",
"0.5326407",
"0.5294865",
"0.52542996",
"0.52436554",
"0.52221566",
"0.52197176",
"0.51593006",
"0.51584166",
"0.50953543",
"0.5072874",
"0.5055029",
"0.5... | 0.65539813 | 0 |
Return the estimator of the phase. | def phase_estimator(self, phase, name="Main"):
estimator = self._tracker_dict[name].series.unit(phase).estimator
if estimator is None:
raise UnExecutedError(f'Scenario.estimate(model, phases=["{phase}"], name={name})')
return estimator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPhase(phase):",
"def get_estimation(self):\n self.calculate_variables()\n if self.validate_preconditions():\n return self.estimate()\n else:\n return None",
"def phase(self):\n return self.__phase",
"def m_phase(self):\n return self._m_phase",
... | [
"0.6492449",
"0.6396096",
"0.6245162",
"0.6211135",
"0.6155881",
"0.6117626",
"0.59259164",
"0.5919323",
"0.578341",
"0.5782382",
"0.5680286",
"0.5680286",
"0.5680286",
"0.5667647",
"0.5667647",
"0.5618406",
"0.5616461",
"0.55942184",
"0.5574",
"0.55632395",
"0.55238044",
"... | 0.7582759 | 0 |
Return the subset of summary dataframe to select the target of parameter history. | def _param_history(self, targets, name):
series = self._tracker_dict[name].series
model_set = {unit.model for unit in series}
model_set = model_set - set([None])
parameters = self.flatten([m.PARAMETERS for m in model_set])
day_params = self.flatten([m.DAY_PARAMETERS for m in mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_target(self, df, target_name: str):\n \n return self.df[target_name]",
"def get_targets(self, df):\n return df.iloc[:, self.target_col]",
"def get_feat_and_target(df, target):\n x = df.drop(target, axis = 1)\n y = df[target]\n return x, y",
"def _history(self, target, phases=... | [
"0.6120377",
"0.5767605",
"0.5637257",
"0.5635355",
"0.55291855",
"0.5380826",
"0.534724",
"0.5300844",
"0.52480835",
"0.52071494",
"0.51738966",
"0.51618147",
"0.51550215",
"0.51391673",
"0.49831647",
"0.49728945",
"0.49236575",
"0.49220812",
"0.4913259",
"0.49054223",
"0.49... | 0.66820365 | 0 |
Adjust the last end dates of the registered scenarios, if necessary. | def adjust_end(self):
# The current last end dates
current_dict = {
name: self._ensure_date(tracker.last_end_date())
for (name, tracker) in self._tracker_dict.items()}
# Adjusted end date
adjusted_str = max(current_dict.values()).strftime(self.DATE_FORMAT)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_list_to_end_date(self):\n if len(self.change_events):\n event_index = len(self.change_events) - 1\n while ((event_index > -1) and (self.change_events[event_index].date_ordinal >\n self.end_date_ordinal)):\n event = self.change_events[event_i... | [
"0.67244375",
"0.63298994",
"0.6279191",
"0.62078863",
"0.6186914",
"0.61678594",
"0.5923968",
"0.5894802",
"0.58839434",
"0.58004695",
"0.58004695",
"0.58004695",
"0.58004695",
"0.58004695",
"0.58004695",
"0.58004695",
"0.58004695",
"0.5626302",
"0.55569535",
"0.5550756",
"0... | 0.7241436 | 0 |
Show change rates of parameter values in one figure. We can find the parameters which increased/decreased significantly. | def history_rate(self, params=None, name="Main", **kwargs):
df = self._track_param(name=name)
model = self._tracker(name).last_model
cols = list(set(df.columns) & set(model.PARAMETERS))
if params is not None:
if not isinstance(params, (list, set)):
raise TypeE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_parameters(self, event, gamma='2.4',\n gain=\"scale_default_value\"):\n print(\"gamma={}, gain={}\".format(gamma, gain))\n sys.stdout.flush()\n self.update_draw(gamma, gain)",
"def show_parameters(self):\n with np.printoptions(precision=3, suppress=... | [
"0.63222736",
"0.60968167",
"0.602045",
"0.600945",
"0.5968336",
"0.5863816",
"0.5856223",
"0.58190936",
"0.57916284",
"0.5782523",
"0.5754305",
"0.5710678",
"0.5689282",
"0.5687477",
"0.56859684",
"0.5658603",
"0.56582314",
"0.5644833",
"0.5638262",
"0.56351125",
"0.56246054... | 0.64278245 | 0 |
Perform retrospective analysis. Compare the actual series of phases (control) and series of phases with specified parameters (target). | def retrospective(self, beginning_date, model, control="Main", target="Target", **kwargs):
param_dict = {k: v for (k, v) in kwargs.items() if k in model.PARAMETERS}
est_kwargs = dict(kwargs.items() - param_dict.items())
# Control
self.clear(name=control, include_past=True)
self.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyse_results(self, \n target_dir, \n param_file = \"TRAINED_PARAMS_END.model\",\n w_norm_file = \"W_NORMS.dat\",\n num_to_test = 100,\n get_means_from = {\n 'N... | [
"0.60408705",
"0.58758664",
"0.5644826",
"0.5543238",
"0.54795575",
"0.544844",
"0.5408462",
"0.5391602",
"0.53793794",
"0.5373309",
"0.53686464",
"0.53674304",
"0.5345663",
"0.5332743",
"0.53223336",
"0.5291442",
"0.5291442",
"0.52801085",
"0.52746636",
"0.5273039",
"0.52550... | 0.6092217 | 0 |
Estimate delay period [days], assuming the indicator impact on the target value with delay. The average of representative value (percentile) and will be returned. | def estimate_delay(self, oxcgrt_data=None, indicator="Stringency_index",
target="Confirmed", percentile=25, limits=(7, 30), **kwargs):
min_size, max_days = limits
# Register OxCGRT data
if oxcgrt_data is not None:
warnings.warn(
"Please use Scen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate(values, target):\n\n # next time\n # diff(values)\n\n\n return 1.",
"def get_delay(self):\n if self.msg_tn == self.last_msg_tn:\n return\n if not self.delays:\n return\n n = len(self.delays)\n\n mean = sum(self.delays) / n\n std_dev =... | [
"0.61240596",
"0.58249533",
"0.5736352",
"0.5720196",
"0.551994",
"0.5515488",
"0.5515488",
"0.5449673",
"0.5441243",
"0.5343859",
"0.52559906",
"0.52168494",
"0.5213883",
"0.5213228",
"0.5210776",
"0.5206571",
"0.5188828",
"0.51886564",
"0.5151351",
"0.514995",
"0.51415145",... | 0.6570062 | 0 |
Parse html tages in sentences | def parse_html_tag(sentences, html_tag_file):
tag_list = file2tuple_list(html_tag_file, ",")
for key, value in tag_list:
for index in range(len(sentences)):
try:
sentences[index] = re.sub(key, value, sentences[index])
except Exception, e:
logging.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __yahoo_parse_text(self, content):\n text = ''\n # Process all paragraphs.\n paragraphs = content.find_all('p')\n for par in paragraphs:\n text += '<p>' + par.getText(separator=' ') + '</p>'\n # Remove all extra whitespace (single space remains).\n text = ' ... | [
"0.65768903",
"0.6414939",
"0.6314085",
"0.6304649",
"0.6183976",
"0.61760587",
"0.61702543",
"0.6127106",
"0.6099596",
"0.60908455",
"0.60301",
"0.6008985",
"0.6008985",
"0.59992546",
"0.59763205",
"0.5959324",
"0.59592533",
"0.595774",
"0.59353596",
"0.59334815",
"0.5910679... | 0.644006 | 1 |
Write data to buffer with buffer protocol | def test_write_bufferprotocol(ctx):
data = array('f', [1, 2, 3, 4])
buff = ctx.buffer(data=data)
assert buff.read() == data.tobytes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, data):\n self.buffer.write(data)\n self.offset += len(data)",
"def write(self, data):\n\t\tself.outputbuffer.write(data)",
"def pack(self,buffer):\n buffer.append(self.data)",
"def write(self, data):\n self.buffer.append(data)\n while self.push():\n pass"... | [
"0.77599627",
"0.7405367",
"0.7294376",
"0.71941775",
"0.70991886",
"0.70991886",
"0.70752317",
"0.7066335",
"0.701389",
"0.6976252",
"0.6973175",
"0.6920095",
"0.68100977",
"0.67799836",
"0.6749012",
"0.670543",
"0.66522443",
"0.664747",
"0.66468465",
"0.6641118",
"0.6630188... | 0.77639097 | 0 |
If place has a nearby MBTA, returns the page with that info, else (or if any other errors), returns an error page | def nearest():
try:
text = find_stop_near(session["place"])
return render_template("place.html", text = text)
except:
return render_template('error.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_near_location():\n return render_template(\"location.html\", latitude=None, longitude=None,\n list_stops=None)",
"def scrapping():\r\n\r\n data_cust = {}\r\n #token, latitude, longitude, name, place_id, types_places, vicinity = [],[],[],[],[],[], []\r\n\r\n apik = '... | [
"0.5860572",
"0.5601886",
"0.556867",
"0.53483754",
"0.534454",
"0.5319231",
"0.5303751",
"0.5295789",
"0.52449685",
"0.5211668",
"0.51778597",
"0.51622933",
"0.51574767",
"0.51421475",
"0.51280147",
"0.5089487",
"0.50833637",
"0.5079039",
"0.5062072",
"0.50607216",
"0.502367... | 0.64868116 | 0 |
Open the editing student window. | def on_edit_students_select(self):
edit_window = Students()
edit_window.exec_() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mouseDoubleClickEvent(self, e):\n self.win = items.edit.Edit(self)\n self.win.setModal(True)\n self.win.show()",
"def edit():",
"def edit_user(self):\n from editWindow import EditPlayer\n self.edit = EditPlayer(self.lang, self.result_table.currentItem().text())\n s... | [
"0.6857695",
"0.675959",
"0.6755998",
"0.6650021",
"0.6358983",
"0.6331608",
"0.62601465",
"0.62351334",
"0.619309",
"0.6178386",
"0.6118476",
"0.61091745",
"0.60836834",
"0.60471237",
"0.6022824",
"0.6017019",
"0.5987004",
"0.5984732",
"0.59686553",
"0.5962103",
"0.5930994",... | 0.8309543 | 0 |
Update views when the date is changed. | def on_date_change(self):
self.date = self.ui.calendarWidget.selectedDate()
self.update_views() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dates_observer(self, state):\n # Update all dates\n self._update_dates_from_history()",
"def update_views(self):\n # Get correct date format\n self.date_string = self.date.toString(self.date_format)\n \n # Clear Models\n self.availModel.clear()\n self.... | [
"0.6494887",
"0.64303577",
"0.6425736",
"0.63661104",
"0.62049454",
"0.6182257",
"0.6125983",
"0.6066578",
"0.59537566",
"0.5901415",
"0.58907646",
"0.58669895",
"0.5823096",
"0.57737094",
"0.57707644",
"0.57694495",
"0.5768196",
"0.57058334",
"0.56830543",
"0.56830543",
"0.5... | 0.68725854 | 0 |
Refresh the students available and attending for the given date. | def update_views(self):
# Get correct date format
self.date_string = self.date.toString(self.date_format)
# Clear Models
self.availModel.clear()
self.attendModel.clear()
for student in self.db.get_attendance_for_date(self.date_string):
if stu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, date):\r\n self.date = date",
"def _load_student_record(self, student_key, students_attendance_data):\n student = SchoolDB.models.Student.get(db.Key(student_key))\n if (student):\n student.attendance.save_multiple_dates(\n self.dates, students_atten... | [
"0.5911469",
"0.55838823",
"0.5495462",
"0.5478598",
"0.54697925",
"0.5468061",
"0.529754",
"0.5211721",
"0.5158502",
"0.51371205",
"0.51294976",
"0.51294976",
"0.50868255",
"0.50607437",
"0.50580114",
"0.50310814",
"0.50108874",
"0.4964432",
"0.4947712",
"0.4947712",
"0.4945... | 0.65859437 | 0 |
Move student from attended to available list. | def on_remove_clicked(self):
selected_indexes = self.ui.attendListView.selectedIndexes()
for index in selected_indexes:
row = self.attendModel.itemFromIndex(index).row()
student = self.attendModel.item(row, 0).text()
sid = self.attendModel.item(row, 1).text()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_an_entry(self):\n target_list = self.find_student()\n\n if not len(target_list):\n print('There is no contents to show')\n else:\n print('You selected the list below.')\n self.print_dataframe(target_list)\n opt = self.input_options(['y', '... | [
"0.5481265",
"0.53063625",
"0.52547395",
"0.5241378",
"0.5201852",
"0.51910436",
"0.50918496",
"0.5090114",
"0.50880194",
"0.5077619",
"0.50550723",
"0.5022331",
"0.5001788",
"0.49973884",
"0.4996648",
"0.49769428",
"0.49731165",
"0.49215776",
"0.49120808",
"0.48781928",
"0.4... | 0.54175085 | 1 |
Report a time_t as an ISO8601 time format. Defaults to now. | def timet_iso(t=time.time()):
return datetime.datetime.now().isoformat()[0:19] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iso_date(self, t=None):\n if t is None:\n t = time.time()\n time_str = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(t))\n\n return time_str",
"def formatted_time() -> datetime.datetime:\r\n return datetime.datetime.now()",
"def isoformat(self, timespec=\"auto\"):\n... | [
"0.7398466",
"0.706633",
"0.69513315",
"0.68297285",
"0.6829152",
"0.67798644",
"0.67408025",
"0.6729839",
"0.66987705",
"0.6689164",
"0.6689164",
"0.66699064",
"0.6641522",
"0.65828717",
"0.65425014",
"0.6505604",
"0.64849293",
"0.64819497",
"0.6459066",
"0.644515",
"0.64373... | 0.7495122 | 0 |
Loads the bash environment variables specified by 'export NAME=VALUE' into a dictionary and returns it. Take whatever variables not in that file from the Linux environment. | def GetBashEnvFromFile(this, filename):
DB_RE = re.compile("export (.+)=(.+)")
ret = {}
if filename is not None:
with open( filename, "r" ) as f:
for line in f:
m = DB_RE.search(line.strip())
if m:
name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_env(env_files):\n env = {}\n for env_file in env_files:\n with open(env_file) as f:\n for line in f:\n if line and line[0] != \"#\":\n try:\n index = line.index(\"=\")\n env[line[:index].strip()] = line... | [
"0.6895845",
"0.6810905",
"0.6783951",
"0.6769671",
"0.67103505",
"0.6698789",
"0.6692306",
"0.66548026",
"0.6652638",
"0.6608575",
"0.65690833",
"0.6533156",
"0.65055305",
"0.6478919",
"0.6466052",
"0.64383376",
"0.6395389",
"0.6377702",
"0.6372465",
"0.63347304",
"0.6331138... | 0.78436303 | 0 |
Returns a DBMySQLAuth formed by reading MYSQL_USER, MYSQL_PASSWORD, MYSQL_HOST and MYSQL_DATABASE envrionemnt variables from a bash script. Caches by default | def FromBashEnvFile(this, filename, cache=True):
if cache and filename in this.auth_cache:
return this.auth_cache[filename]
env = DBMySQLAuth.GetBashEnvFromFile(filename)
try:
auth = DBMySQLAuth(host = env[MYSQL_HOST],
user = env[MYSQL_USER]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db() -> mysql.connector.connection.MySQLConnection:\n username = getenv('PERSONAL_DATA_DB_USERNAME')\n password = getenv('PERSONAL_DATA_DB_PASSWORD')\n host = getenv('PERSONAL_DATA_DB_HOST')\n db = getenv('PERSONAL_DATA_DB_NAME')\n\n conect = mysql.connector.connection.MySQLConnection(\n ... | [
"0.6515381",
"0.6305752",
"0.59653795",
"0.59097266",
"0.59001666",
"0.5899042",
"0.58714527",
"0.5821578",
"0.58064324",
"0.5776066",
"0.5764474",
"0.57294273",
"0.57264",
"0.56820935",
"0.5681678",
"0.5665837",
"0.5655249",
"0.5650574",
"0.56354046",
"0.5626327",
"0.5606605... | 0.68844616 | 0 |
Test the get_usermail function. | def test_get_usermail(m_check):
m_check.return_value = b"email\n"
assert get_usermail() == "email"
m_check.side_effect = subprocess.CalledProcessError(42, "test")
assert get_usermail() == "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_user_by_emailuser_email_get(self):\n pass",
"def test_email(self):\r\n \r\n self.assertEqual('maryc123@yahoo.com', self.user.email)",
"def test_get_email_address(self):\n email_addr = 'test_get_email_addr' + '@' + self.email_dom\n org = 'o=%s' % (self.org_name)\n... | [
"0.75392437",
"0.71519345",
"0.6814032",
"0.67871207",
"0.67836803",
"0.6677691",
"0.6670167",
"0.6616136",
"0.6537178",
"0.6473739",
"0.6472649",
"0.6373025",
"0.63564473",
"0.6334709",
"0.6324414",
"0.6312994",
"0.6308379",
"0.6306206",
"0.6303542",
"0.62552875",
"0.6248734... | 0.7211447 | 1 |
Test the clone_repository function. | def test_clone_repository(m_check):
m_check.return_value = 0
assert clone_repository("test", "test", "test") == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clone_repository(koan, assert_cloned_repo_exists):\n koan.shell('')",
"def test_clone_scenario(self):\n pass",
"def test_clone_system(self):\n pass",
"def _mock_git_clone(self, args: List[str]) -> None:\n cloned_repo_root = args[-1]\n\n # Create \"cloned\" directory an... | [
"0.82233465",
"0.77650654",
"0.7716605",
"0.7560499",
"0.747564",
"0.7309313",
"0.7285124",
"0.7100823",
"0.709299",
"0.70320797",
"0.69590735",
"0.6906271",
"0.6862664",
"0.6752656",
"0.6698426",
"0.66245997",
"0.6560457",
"0.6463911",
"0.6458351",
"0.64459914",
"0.641486",
... | 0.8714088 | 0 |
The embedding updater model that read and answer questions | def embedding_updater_model(variables, rank,
n_slots,
init_params=None,
n_ents=None,
init_noise=0.0,
loss=total_loss_logistic,
scoring=multilinear,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_extract_document_embedding(self):\n input_ids = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32, name=\"ids\")\n attention_mask = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32, name=\"att\")\n token = tf.keras.layers.Input(shape=(self.maxlen,), dtype=tf.int32,... | [
"0.6409485",
"0.6324289",
"0.6234172",
"0.6121499",
"0.6103584",
"0.6020987",
"0.59622705",
"0.5899578",
"0.5887283",
"0.5861236",
"0.5821322",
"0.5807525",
"0.57943153",
"0.57827747",
"0.5741384",
"0.57363474",
"0.5726444",
"0.5716351",
"0.56564707",
"0.5654258",
"0.5641596"... | 0.6931258 | 0 |
Create a local index on a list of tuples and updates the global vocabulary | def local_vocabulary(tuples, voc):
new_tuples = []
local_voc0 = Indexer()
for t, v in tuples:
new_t = tuple([local_voc0.string_to_int(w) for w in t])
new_tuples.append((new_t, v))
local_voc = []
for w in local_voc0.index_to_string:
local_voc.append(voc(w))
return new_tupl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n print(\"Indexing...\")\n # ------------------------------------------------------------------\n # TODO: Create an inverted, positional index.\n # Granted this may not be a linked list as in a proper\n # implementation.\n # This index sh... | [
"0.649561",
"0.634331",
"0.6276083",
"0.62530005",
"0.61110073",
"0.61029226",
"0.60869354",
"0.60246015",
"0.60092986",
"0.598",
"0.59775156",
"0.5958632",
"0.59370226",
"0.59205157",
"0.58659947",
"0.5796124",
"0.5771141",
"0.5762922",
"0.5750373",
"0.5747169",
"0.570973",
... | 0.737797 | 0 |
Generate a function which converts a z and step value to an RGB colour, based on three predefined ratios. | def get_colour(self, r1, r2, r3, b1, b2, b3):
def colour(z, i):
"""
Gets the colour of a z and step value.
:param complex z: the z value from the mandelbrot set
:param int i: the step value
:rtype: tuple
:return: the three RGB colours
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rgbcolor(h, f):\n # q = 1 - f\n # t = f\n if h == 0:\n return v, f, p\n elif h == 1:\n return 1 - f, v, p\n elif h == 2:\n return p, v, f\n elif h == 3:\n return p, 1 - f, v\n elif h == 4:\n return f, p, v\n elif h == 5:\n return v, p, 1 - f",
... | [
"0.6529024",
"0.6498187",
"0.6447665",
"0.6419169",
"0.63274384",
"0.6322723",
"0.6188783",
"0.60802084",
"0.6072802",
"0.5948455",
"0.5910232",
"0.5883263",
"0.5878698",
"0.5863626",
"0.5861718",
"0.58612084",
"0.583371",
"0.5806005",
"0.57980853",
"0.57717776",
"0.57256144"... | 0.6906919 | 0 |
Gets the colour of a z and step value. | def colour(z, i):
if abs(z) < self.threshold:
return 0, 0, 0
v = np.log2(i + self.threshold - np.log2(np.log2(abs(z)))) / self.threshold
if v < 1.0:
return v ** b1, v ** b2, v ** b3 # coloured tones
else:
v = max(0, 2 - v)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th... | [
"0.73403287",
"0.7172178",
"0.6895486",
"0.66384035",
"0.654349",
"0.65309036",
"0.64248663",
"0.62704283",
"0.6260564",
"0.62288976",
"0.622155",
"0.62071323",
"0.6176974",
"0.6173576",
"0.6155353",
"0.6155353",
"0.6155353",
"0.6155353",
"0.613839",
"0.61319745",
"0.6128805"... | 0.7208043 | 1 |
Colours the grid and returns the image. | def get_coloured_grid(self, r1, r2, r3, b1=4, b2=2.5, b3=1):
r, g, b = np.frompyfunc(self.get_colour(r1, r2, r3, b1, b2, b3), 2, 3)(self.end_z, self.end_step)
img_array = np.dstack((r, g, b))
return Image.fromarray(np.uint8(img_array * 255)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_grid(self):\n plt.imshow(py.array(\n map(lambda x: map(lambda y: mplc.colorConverter.to_rgb(colord[y]), x), self.create_grid(self.graph))),\n interpolation='nearest')\n plt.show()",
"def make_image(self, save=False):\n\n # image_grid = np.full((self.size_x, sel... | [
"0.6998966",
"0.65337056",
"0.6325635",
"0.6285329",
"0.6260909",
"0.62575686",
"0.6254772",
"0.62346655",
"0.618115",
"0.615539",
"0.61247164",
"0.6097528",
"0.6022386",
"0.60113466",
"0.6007067",
"0.59790057",
"0.59721226",
"0.5971848",
"0.59443724",
"0.5926389",
"0.5913297... | 0.72839564 | 0 |
Generates the mandelbrot set from the set parameters for a particular number of iterations. | def generate_mandelbrot(self, iterations):
if self.grid is None:
raise RuntimeError("Grid hasn't been setup - call set_grid first.")
# Define the tensorflow variables
c = tf.constant(self.grid.astype(np.complex64))
z = tf.Variable(c)
n = tf.Variable(tf.zeros_like(c, t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMandelbrotSet(self):\n\t\t\n\t\t(x_min, x_max, y_min, y_max) = [i for i in self.extent]\n\t\t(rows, columns) = (self.width*self.dpi, self.width*self.dpi)\n\t\tr_real = np.linspace(x_min, x_max, columns)\n\t\tr_imag = np.linspace(y_max, y_min, rows)\n\t\tresult = np.empty((rows, columns))\n\n\t\t# used for s... | [
"0.59489983",
"0.56008106",
"0.55951405",
"0.5593306",
"0.55607903",
"0.54957503",
"0.54919815",
"0.5482499",
"0.54726803",
"0.5471357",
"0.54386574",
"0.54066265",
"0.5402647",
"0.5369949",
"0.53577334",
"0.535206",
"0.53520525",
"0.5346284",
"0.5345355",
"0.53447723",
"0.52... | 0.6835279 | 0 |
Generates the julia set from the set parameters for a number of iterations and using a particular value of c. | def generate_julia(self, iterations, c):
if self.grid is None:
raise RuntimeError("Grid hasn't been setup - call set_grid first.")
# Define the tensorflow variables
c_val = tf.constant(np.full(shape=self.grid.shape, fill_value=c, dtype=self.grid.dtype))
z = tf.Variable(self.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genPowerSet(cvalues, incEmpty=False):\t\t\n\tps = list()\n\tfor cv in cvalues:\n\t\tpse = list()\n\t\tfor s in ps:\n\t\t\tsc = s.copy()\n\t\t\tsc.add(cv)\n\t\t\t#print(sc)\n\t\t\tpse.append(sc)\n\t\tps.extend(pse)\n\t\tes = set()\n\t\tes.add(cv)\n\t\tps.append(es)\n\t\t#print(es)\n\t\n\tif incEmpty:\n\t\tps.ap... | [
"0.6113237",
"0.585974",
"0.5496323",
"0.5448815",
"0.5381841",
"0.53499573",
"0.53280026",
"0.5263938",
"0.52438045",
"0.5203017",
"0.51715815",
"0.5160977",
"0.511507",
"0.5103073",
"0.50933886",
"0.5076919",
"0.5047488",
"0.5038411",
"0.5017469",
"0.5008726",
"0.5005838",
... | 0.6562868 | 0 |
Print tabseparated sequence of things to line in file | def tabout(things, file=sys.stdout):
print("\t".join([str(x) for x in things]), file=file)
file.flush() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tab(self):\n self._write('\\t')",
"def output_tab_delimited(s1, s2, i1, i2):\n _out.write(\"%s\\t%s\\t%d\\t%d\\n\" % (s1, s2, i1, i2))\n _out.write(\"%s\\t%s\\t%d\\t%d\\n\" % (s2, s1, i2, i1))",
"def print_tsv(data, filename):\n with open(filename, 'wt') as fout:\n writefile = partia... | [
"0.7131929",
"0.7020605",
"0.66624314",
"0.65175635",
"0.64840746",
"0.64395034",
"0.63917106",
"0.63775367",
"0.63412404",
"0.6289037",
"0.61846536",
"0.6176423",
"0.616765",
"0.61081123",
"0.6081998",
"0.6079226",
"0.60417503",
"0.59935766",
"0.5967714",
"0.59413093",
"0.59... | 0.81036395 | 0 |
Adds a source (as a string) corresponding to a filename in the cache. The filename can be a true file name, or a fake one, like | def add(self, filename, source):
self.cache[filename] = source
if os.path.isfile(filename):
self.ages[filename] = os.path.getmtime(filename) # modification time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddSource (self, name, source, filename):\n self.containments [name] = source, filename, False",
"def add_source_file(self, filename):\n self.sources.add(Source.create(filename))",
"def cache(self, file_name, content):\n self.files_loaded[file_name] = content",
"def put_source(file_p... | [
"0.733794",
"0.70201176",
"0.6331393",
"0.6280567",
"0.61927634",
"0.6123509",
"0.6102532",
"0.605147",
"0.6028744",
"0.601777",
"0.5983757",
"0.5921107",
"0.5879947",
"0.58499354",
"0.5762012",
"0.5749603",
"0.57389265",
"0.57361263",
"0.5717338",
"0.57040185",
"0.5688251",
... | 0.8042132 | 0 |
Gets a copy of the entire cache | def get_copy(self):
# This is used in avant-idle to pass the content of a cache in
# the main process to a second process where an exception has been
# raised.
return self.cache | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cache(self):\n return self.cache",
"def get(self):\n if path.exists(self.cachefile):\n self.invalidion()\n full_cache = self._get_all()\n return full_cache\n else:\n return []",
"def getCacheContents(self):\n return self._cache",
... | [
"0.745652",
"0.74172235",
"0.72680855",
"0.7232514",
"0.71606326",
"0.71606326",
"0.71606326",
"0.71606326",
"0.7018596",
"0.7012775",
"0.7010496",
"0.67941254",
"0.67534447",
"0.6705078",
"0.6684562",
"0.6615776",
"0.6590172",
"0.65279984",
"0.6523774",
"0.6464215",
"0.64473... | 0.7468072 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.