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 |
|---|---|---|---|---|---|---|
Get the 'raw_transaction' content from the message. | def raw_transaction(self) -> CustomRawTransaction:
enforce(self.is_set("raw_transaction"), "'raw_transaction' content is not set.")
return cast(CustomRawTransaction, self.get("raw_transaction")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_message(self) -> RawMessage:\n return self.__raw_message",
"def raw_message(self) -> CustomRawMessage:\n enforce(self.is_set(\"raw_message\"), \"'raw_message' content is not set.\")\n return cast(CustomRawMessage, self.get(\"raw_message\"))",
"def body(self):\n return self.m... | [
"0.7058746",
"0.6511272",
"0.6372274",
"0.636641",
"0.6239525",
"0.62357557",
"0.6073031",
"0.605961",
"0.5931054",
"0.5921001",
"0.5912746",
"0.586043",
"0.58279073",
"0.5768041",
"0.5755944",
"0.56872374",
"0.56653523",
"0.56653523",
"0.5663256",
"0.56579155",
"0.56517065",... | 0.7030105 | 1 |
Get the 'signed_message' content from the message. | def signed_message(self) -> CustomSignedMessage:
enforce(self.is_set("signed_message"), "'signed_message' content is not set.")
return cast(CustomSignedMessage, self.get("signed_message")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_message_content(message): # pylint: disable=too-many-return-statements\n if message.content_type == \"photo\":\n return message.photo[0].file_id\n if message.content_type == \"text\":\n return message.text\n if message.content_type == \"audio\":\n return message.audio.file_id... | [
"0.70703405",
"0.67033327",
"0.6590439",
"0.64318043",
"0.63649565",
"0.63360643",
"0.63123226",
"0.6301378",
"0.62859064",
"0.62551785",
"0.62300676",
"0.619354",
"0.61811334",
"0.61743134",
"0.6125781",
"0.60881484",
"0.60881484",
"0.6079197",
"0.60646284",
"0.60646284",
"0... | 0.77742064 | 0 |
Get the 'signed_transaction' content from the message. | def signed_transaction(self) -> CustomSignedTransaction:
enforce(
self.is_set("signed_transaction"),
"'signed_transaction' content is not set.",
)
return cast(CustomSignedTransaction, self.get("signed_transaction")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_message(self) -> CustomSignedMessage:\n enforce(self.is_set(\"signed_message\"), \"'signed_message' content is not set.\")\n return cast(CustomSignedMessage, self.get(\"signed_message\"))",
"def sign_transaction(self):\n private_key=RSA.importKey(binascii.unhexlify(self.sender_pri... | [
"0.69285035",
"0.62230104",
"0.6093691",
"0.59609264",
"0.59465414",
"0.59208524",
"0.5844866",
"0.58439267",
"0.58288693",
"0.57923603",
"0.57424635",
"0.5558498",
"0.5551264",
"0.55027443",
"0.547574",
"0.54751813",
"0.54367286",
"0.54205626",
"0.5406815",
"0.5375192",
"0.5... | 0.7213274 | 0 |
sets up config items for delta class, prepares input files, instantiates delta class and runs comparison removes temporary files | def delta_runner(nconfig,
dialect: csvhelper.Dialect) -> gdelta.FileDelta:
adj_temp_dir = nconfig.temp_dir or dirname(nconfig.infiles[1])
adj_out_dir = nconfig.out_dir or dirname(nconfig.infiles[1])
#--- handle all key, compare and ignore logic --------------
def convert_cols(col_titl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n self.files_to_remove = []\r\n self.dirs_to_remove = []\r\n\r\n # Create temp directory to hold input and output.\r\n self.test_dir = mkdtemp(dir=get_qiime_temp_dir(),\r\n prefix='qiime_compare_categories_tests_')\r\n self.dirs_t... | [
"0.6164049",
"0.58214206",
"0.57856697",
"0.5782001",
"0.5734466",
"0.5731442",
"0.57106066",
"0.5695239",
"0.5674864",
"0.56572884",
"0.56088245",
"0.5601859",
"0.5561754",
"0.5520933",
"0.5473283",
"0.5472652",
"0.54674006",
"0.546737",
"0.5457336",
"0.54556006",
"0.5455474... | 0.60849 | 1 |
Return assignment config section after converting col names to offsets. | def get_assign_with_offsets_for_names(col_names: List[str],
assign_config: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
new_assign_config: List[Dict[str, Any]] = copy.deepcopy(assign_config)
for asgn in new_assign_config:
if asgn.get("src_field", None) is not None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _config_column(self):\n return self.totals_column",
"def get_section(self,name):\n if self.__config.has_section(name):\n data={}\n for opt,val in self.__config.items(name):\n data[opt]=val\n return data\n else:\n raise Exception(... | [
"0.5456801",
"0.51627904",
"0.51525956",
"0.51099646",
"0.5065017",
"0.5042853",
"0.5021782",
"0.4957951",
"0.4902568",
"0.48941445",
"0.48564792",
"0.48513383",
"0.4816087",
"0.48056573",
"0.4785528",
"0.47788706",
"0.4774979",
"0.47260636",
"0.47121105",
"0.47066826",
"0.46... | 0.61098427 | 0 |
Defines the user config or metadata. Does not get the user input. | def define_user_config(self) -> None:
self.add_standard_metadata('infiles')
self.add_custom_metadata(name='key_cols',
short_name='k',
required=True,
default=[],
nargs='*',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_config():\n global udata\n udata = UserConfig()",
"def config():",
"def config():",
"def configuration():",
"def config( **kwargs ):",
"def main():\n logger = logging.getLogger(__name__)\n logger.info('making final data set from raw data')\n get_user_config()",
"def user_config(... | [
"0.6611121",
"0.6499463",
"0.6499463",
"0.6472938",
"0.64045906",
"0.63433033",
"0.633927",
"0.6333297",
"0.6333297",
"0.63055027",
"0.6282369",
"0.60847986",
"0.6083332",
"0.608091",
"0.60744405",
"0.60674465",
"0.6055751",
"0.59834033",
"0.59704685",
"0.5963652",
"0.5954494... | 0.77484155 | 0 |
Adds file into the exisiting compiled freq dist should input an existing freq dist file | def update_freq_dist(filename):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file_char_freqs(file_name, char_freqs):\n with open(file_name, 'r') as f:\n for line in f:\n add_string_char_freqs(line, char_freqs)",
"def perform_register(path, file_name):\n subprocess.call(\n [sys.executable, 'setup.py', 'sdist', 'bdist_wheel'], cwd=path)\n subprocess.call(['twi... | [
"0.5544207",
"0.53773427",
"0.5278644",
"0.5275859",
"0.52109265",
"0.51934636",
"0.5189407",
"0.5168266",
"0.51434845",
"0.5105723",
"0.51044667",
"0.5085891",
"0.5066389",
"0.5041279",
"0.5029795",
"0.5019524",
"0.5016518",
"0.49983114",
"0.498523",
"0.4964506",
"0.49512455... | 0.78899646 | 0 |
this function opens the target word and checks if the word to be added is already in there. If it isn't, the word will get added in | def chk_append_in_out(target_word, word_to_add, data):
# insert syntax to write to temp file
import shutil
filename = filepath1(data)
dict_tmpfile = filepath1(data + ' tmp')
with open(filename, 'r',
encoding='utf8') as dict_file:
dict_reader = csv.reader(dict_file, d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_word(self, word):\n\n if word in self.wordlist:\n return \"Already in word list\"\n\n file_name = self.config_folder + self.wordlist_file\n word_list = open(file_name,'a+')\n word_list.write(word + \"\\n\")\n word_list.close()\n return None",
"def test... | [
"0.71003145",
"0.66599035",
"0.6446007",
"0.6352773",
"0.6343785",
"0.62655973",
"0.6239579",
"0.61663043",
"0.61641014",
"0.6160714",
"0.6103694",
"0.6097981",
"0.60290027",
"0.6027761",
"0.60161966",
"0.5995897",
"0.5943689",
"0.5924485",
"0.5922836",
"0.59157676",
"0.58998... | 0.678876 | 1 |
Method used here is to write a file for all the targets The file will contain all the Predecessors and Successors, including repeats (chk_append_in_out1) The next step is to open evey word file, enter the entire file into working memory do a set, and then write the file. Prefer to do the read/write with temp to prevent... | def update_in_out1(filename):
import shutil
with open(filepath(filename, 'Edges'), 'r',
encoding='utf8') as edge_file:
edge_reader = csv.reader(edge_file, delimiter='\t',
quoting=csv.QUOTE_MINIMAL)
# edges = [l for l in edge_reader] # Lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def targeted_set_write(out_file_name, num_set_writes, which_set,\n\tvalue_offset, num_address_bits, num_sets, line_size, num_data_bits):\n\twith open(out_file_name, 'w') as out_file:\n\t\tout_file.write('v2.0 raw\\n')\n\t\tnum_line_bits = int(log(line_size,2))\n\t\tnum_set_bits = int(log(line_size,2))\n\t\tread = ... | [
"0.60186255",
"0.5852953",
"0.5814185",
"0.5787644",
"0.5782379",
"0.57397735",
"0.56404793",
"0.55990887",
"0.5586535",
"0.551966",
"0.5496019",
"0.5495671",
"0.5484422",
"0.5469437",
"0.54581624",
"0.545783",
"0.5454956",
"0.5451633",
"0.5432979",
"0.5415584",
"0.54153407",... | 0.7180383 | 0 |
Use this to quickly plot the hubness of a text, after running hubness | def plothub(filename):
with open(filepath(filename, 'Hubness'),
'r', encoding='utf8') as hubness_file:
hub_reader = csv.reader(hubness_file, delimiter='\t',
quoting=csv.QUOTE_MINIMAL)
data = []
frequency = []
out_hubness = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_Hubble():\n pickle_in = open(\"MICE_SN_data.pickle\", \"rb\")\n SN_data = pickle.load(pickle_in)\n z = SN_data[\"SNZ\"]\n mu = SN_data['SNMU']\n mu_err = SN_data['SNMU_ERR']\n z_array = np.linspace(0.0, 1.5 + 0.01, 1001)\n mu_cosm = 5 * np.log10((1 + z_array) * Convergence.comoving(z_... | [
"0.5925228",
"0.5808202",
"0.58062714",
"0.5628367",
"0.5522299",
"0.5359839",
"0.53364545",
"0.53199846",
"0.5239548",
"0.5233426",
"0.5204231",
"0.51950955",
"0.51807016",
"0.5170372",
"0.51426303",
"0.51354647",
"0.51220435",
"0.51134527",
"0.5103181",
"0.51025635",
"0.510... | 0.6313495 | 0 |
Create a random square matrix of dimension mn, but rank k Replace last nk columns with linear combinations of the first k | def _randomnk(m, n, k):
a = np.random.random((m, n))
for i in range(k, n):
pars = np.random.random(k)
a[:, i] = a[:, :k] @ pars
return a | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_random_matrix(n):\n return [[random.randint(1, 50) for i in range(n)] for j in range(n)]",
"def random_cluster_matrix(shape):\n N, k = shape\n A = np.zeros((N, k))\n for row in A: \n row[randint(0, k - 1)] = 1\n\n return A",
"def matrix_generate(n):\n a = np.eye(n)\n ma... | [
"0.7058815",
"0.6905523",
"0.65846723",
"0.6442867",
"0.6430646",
"0.6377194",
"0.63462657",
"0.63337016",
"0.6314663",
"0.6305563",
"0.6303248",
"0.62964904",
"0.62718517",
"0.624942",
"0.623986",
"0.61731344",
"0.6158133",
"0.60874325",
"0.6083504",
"0.60694724",
"0.6003654... | 0.7738931 | 0 |
Creates CIDR block from reverse zone name. | def ReverseZoneToCIDRBlock(self):
if( self.origin.endswith('in-addr.arpa.') ):
ip_parts = self.origin.split('.in-')[0].split('.')
ip_parts.reverse()
for ip_part in ip_parts:
if( not ip_part.isdigit() ):
raise Error('%s is not a reverse zone.' % self.zone_name)
cidr_block =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_subnet ( vpc_conn,\n ec2_conn,\n vpc_id,\n subnet_cidr,\n zone_name,\n subnet_basename ) :\n subnet = vpc_conn.create_subnet( vpc_id, subnet_cidr, zone_name )\n aws_cmd( ec2_conn.create_tags, [ subnet.id,\... | [
"0.5535262",
"0.54961246",
"0.5362842",
"0.53434074",
"0.5324529",
"0.5305466",
"0.53013504",
"0.52917355",
"0.52762777",
"0.522872",
"0.5221217",
"0.52068883",
"0.51941127",
"0.51882166",
"0.5182296",
"0.51517445",
"0.51500666",
"0.5107974",
"0.50915426",
"0.5076636",
"0.507... | 0.7640928 | 0 |
Makes records in the database from dns.zone class. | def MakeRecordsFromZone(self):
return self.core_helper_instance.AddFormattedRecords(
self.zone_name, self.zone_file_string, self.view) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_dns(self):\n if self.ptr:\n which_zone = None\n zones = dns.models.Zone.objects.all()\n for zone in zones:\n if self.ptr.endswith(zone.name) or self.ptr.endswith(zone.name + '.'):\n which_zone = zone\n break\n\n... | [
"0.7278506",
"0.6787656",
"0.65429133",
"0.64670986",
"0.644392",
"0.6279423",
"0.6111223",
"0.6069045",
"0.60088825",
"0.59943026",
"0.5969688",
"0.59328884",
"0.59145474",
"0.5877854",
"0.58749115",
"0.5860105",
"0.583984",
"0.5791179",
"0.5722849",
"0.569231",
"0.5681088",... | 0.69980377 | 1 |
Removes the cache file | def clear_cache():
os.remove(CACHE_FILE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_cache(self, filename=None):\n os.remove(self._cache_filename(filename))",
"def purge_cache():\n from voiceplay.config import Config\n logger.debug('Purging cache...')\n cache_dir = Config.cfg_data().get('cache_dir', '')\n if os.path.exists(cache_dir) and os.path.isdir(... | [
"0.78681904",
"0.7865937",
"0.77217686",
"0.7681812",
"0.7541766",
"0.74766535",
"0.74674535",
"0.7463867",
"0.7456172",
"0.7440165",
"0.7420707",
"0.7402965",
"0.73867005",
"0.7371262",
"0.7354825",
"0.7337829",
"0.7337749",
"0.72497946",
"0.7184994",
"0.7159605",
"0.7099601... | 0.7989166 | 0 |
(string) > (List of 3 Strings) Takes a word and returns 3 rhyming words in a list. Can edit para_dict["max"] = "3" to another number to produce more results > get_rhymes("funny") > ['money', 'honey', 'sunny'] | def get_rhymes(word):
baseurl = "https://api.datamuse.com/words"
para_dict = {}
para_dict['rel_rhy'] = word
para_dict["max"] = '3'#Get a max of 3 results, change for more
resp = requests.get(baseurl, params=para_dict)
word_ds = resp.json()
return [d['word']for d in word_ds]
return resp.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_rhyme_words(sentence: str, n_rhymes: int, language:str=\"english\") -> List[str]:\n last_word = find_last_word(sentence)\n if language == \"english\":\n return query_datamuse_api(last_word, n_rhymes)\n elif language == \"dutch\":\n return mick_rijmwoordenboek(last_word, n_rhymes)\n ... | [
"0.69366336",
"0.65123796",
"0.6491043",
"0.64400357",
"0.62415045",
"0.6063567",
"0.6017016",
"0.5952609",
"0.5884212",
"0.57756734",
"0.5767852",
"0.57128626",
"0.5701876",
"0.563756",
"0.55809224",
"0.5575984",
"0.55699545",
"0.55596",
"0.5542515",
"0.541976",
"0.53728986"... | 0.76137656 | 0 |
Converts span indicies into spacy entity labels. | def spans_to_ents(doc, spans, label):
started = False
left, right, ents = 0, 0, []
for x in doc:
if x.pos_ == 'SPACE':
continue
if spans.intersection(set(range(x.idx, x.idx + len(x.text)))):
if not started:
left, started = x.idx, True
right = x.idx + len(x.text)
elif started:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annotate_span(self, labels):\n \t\tfor key in labels:\n \t\t\tspan = \"-[%s-%s]\" % (key[0], key[1])\n \t\t\tnew_label = labels[key] + span\n \t\t\tlabels[key] = new_label\n \t\treturn labels",
"def to_spans(l_ids, voc):\n spans = {}\n current_lbl = None\n current_start = None\n for i, l_id in en... | [
"0.6947499",
"0.6358475",
"0.5968742",
"0.5902321",
"0.5859916",
"0.57923925",
"0.57918185",
"0.57451344",
"0.5620688",
"0.56022626",
"0.5562303",
"0.5558138",
"0.553478",
"0.55312395",
"0.55130225",
"0.55030227",
"0.5488316",
"0.5483918",
"0.54623985",
"0.5414684",
"0.541399... | 0.66366553 | 1 |
Reads csv file with python span list and text. | def read_datafile(filename):
data = []
with open(filename) as csvfile:
reader = csv.DictReader(csvfile)
count = 0
for row in reader:
fixed = fix_spans.fix_spans(
ast.literal_eval(row['spans']), row['text'])
data.append((fixed, row['text']))
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_csv():",
"def readcsv(path, delimiter= ','):\n my_data = genfromtxt(path, delimiter= delimiter)\n return my_data",
"def loadCSV(input_file):",
"def _read_csv(self, input_file, quotechar=None):\n with codecs.open(input_file, \"r\", encoding=\"UTF-8\") as f:\n reader = csv.read... | [
"0.70463127",
"0.65343654",
"0.64720374",
"0.64523727",
"0.63862234",
"0.6382505",
"0.6368334",
"0.632806",
"0.632088",
"0.6239257",
"0.6183946",
"0.61252445",
"0.61162686",
"0.61012506",
"0.6097735",
"0.6097735",
"0.60601383",
"0.6037592",
"0.6027081",
"0.6003599",
"0.599042... | 0.6753282 | 1 |
Adds "|Music on voice!" to the nickname | async def on(self, ctx, *, nickname=""):
nickname = nickname.strip()
mention_here = True
mention_everyone = True
if nickname == "":
nickname = "Dank Bot |Music on voice!"
try:
await self.bot.change_nickname(ctx.message.server.me, nickname)
awai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voice(self,nick):\n self.logger.debug(\"voicing %s\" % nick)\n self.connection.mode(self.config[\"IRC/channel\"],\"+v \"+nick)",
"def add_nickname(self, nickname):\n if 'Nicknames' not in self.properties:\n self.properties['Nicknames'] = []\n if (len(self.properties['Ni... | [
"0.6569396",
"0.6313596",
"0.621216",
"0.6108642",
"0.60116947",
"0.5816694",
"0.5812705",
"0.5786665",
"0.57645404",
"0.5713363",
"0.57022995",
"0.5637566",
"0.56236994",
"0.5614517",
"0.56139743",
"0.5605845",
"0.5605322",
"0.5583918",
"0.5568492",
"0.5565607",
"0.55596346"... | 0.7346703 | 0 |
Removes "|Music on voice!" from the nickname | async def off(self, ctx, *, nickname=""):
nickname = nickname.strip()
if nickname == "":
nickname = None
try:
await self.bot.change_nickname(ctx.message.server.me, nickname)
await self.bot.delete_message(ctx.message)
await self.bot.say("RIP music l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def on(self, ctx, *, nickname=\"\"):\n nickname = nickname.strip()\n mention_here = True\n mention_everyone = True\n if nickname == \"\":\n nickname = \"Dank Bot |Music on voice!\"\n try:\n await self.bot.change_nickname(ctx.message.server.me, nickname... | [
"0.64960885",
"0.62356037",
"0.5948419",
"0.5863114",
"0.5785885",
"0.5784235",
"0.57336915",
"0.5673621",
"0.5665342",
"0.5648003",
"0.5634752",
"0.55836535",
"0.5575552",
"0.5567717",
"0.5564841",
"0.5560091",
"0.5523668",
"0.55103797",
"0.5496949",
"0.54440194",
"0.5437352... | 0.6796304 | 0 |
Lambda function which is supposed to turn on EC2 and RDS instances during working hours and stop them during nonworking hours. | def lambda_handler(event, context):
ec2 = boto3.resource('ec2')
filters = [
{
'Name': 'tag:time',
'Values': ['*']
}
]
print('**************** CHECKING EC2 INSTANCES ****************')
for instance in ec2.instances.filter(Filters=filters):
print('====... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda_handler(event, context):\n Stop_Instances()",
"def lambda_handler(event, context):\n try:\n day = datetime.datetime.now().weekday()\n\n fetcher = assume_role()\n config = fetch_config_from_s3(fetcher)\n print config\n\n if is_weekday(day, config['schedule']['ha... | [
"0.7346162",
"0.6831002",
"0.6431433",
"0.6177326",
"0.61037785",
"0.5985038",
"0.59797364",
"0.5953911",
"0.5907059",
"0.5870279",
"0.5856792",
"0.5852862",
"0.5816772",
"0.5725218",
"0.5691569",
"0.5688513",
"0.56642574",
"0.56627375",
"0.56511104",
"0.5620447",
"0.5619792"... | 0.7279179 | 1 |
Calculates drift between baseline and sample datasets according to a predefined metric (jensenshannon distance or KS) or a userdefined metric. | def calculate_drift(
self,
pre_defined_metric=None,
user_defined_metric=None
):
if pre_defined_metric and user_defined_metric:
print("One of pre_defined_metric or user_defined_metric must be None.")
elif pre_defined_metric:
# Remove capitalizati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_concept_drift(\n self, \n pre_defined_metric=None,\n user_defined_metric=None):\n\n if (pre_defined_metric is not None) and (user_defined_metric is not None):\n raise ValueError(\n 'One of pre_defined_metric or user_defined_metric must be None.'\n... | [
"0.6770538",
"0.5381941",
"0.526073",
"0.5175363",
"0.5107576",
"0.5066699",
"0.50264215",
"0.50174767",
"0.50110817",
"0.49905413",
"0.4970395",
"0.49415106",
"0.49399406",
"0.49198732",
"0.49193394",
"0.49020305",
"0.4882319",
"0.4879518",
"0.48557532",
"0.48357955",
"0.483... | 0.720477 | 0 |
Calculates concept drift between target columns of baseline and sample datasets according to a predefined metric (jensenshannon distance or KS) or a userdefined metric. | def calculate_concept_drift(
self,
pre_defined_metric=None,
user_defined_metric=None):
if (pre_defined_metric is not None) and (user_defined_metric is not None):
raise ValueError(
'One of pre_defined_metric or user_defined_metric must be None.'
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_drift(\n self, \n pre_defined_metric=None,\n user_defined_metric=None\n ):\n\n if pre_defined_metric and user_defined_metric:\n print(\"One of pre_defined_metric or user_defined_metric must be None.\")\n\n elif pre_defined_metric:\n # Re... | [
"0.65799433",
"0.5086956",
"0.50817716",
"0.5058224",
"0.5035665",
"0.5031872",
"0.4981543",
"0.49669003",
"0.49491736",
"0.49223495",
"0.49129647",
"0.48953718",
"0.48806772",
"0.48792365",
"0.4862095",
"0.48564133",
"0.4822283",
"0.48191035",
"0.48054305",
"0.47748592",
"0.... | 0.699062 | 0 |
A method to compare model performance on baseline and sample datasets. Will call _eval_classifier or _eval_regressor depending on label_type. | def compare_performance(self):
if self.label_type == "categorical":
self._eval_classifier()
elif self.label_type == "numerical":
self._eval_regressor()
return self.performance_comparison | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _eval_classifier(self):\n\n y_pred_baseline = self.df_baseline[self.score_column]\n y_pred_sample = self.df_sample[self.score_column]\n\n y_label_baseline = self.df_baseline[self.label_column]\n y_label_sample = self.df_sample[self.label_column]\n\n precision_baseline = preci... | [
"0.7196866",
"0.6902271",
"0.64734215",
"0.64661807",
"0.6423611",
"0.6399491",
"0.63337004",
"0.6251186",
"0.6218847",
"0.6186226",
"0.6151527",
"0.6150512",
"0.6083028",
"0.60501564",
"0.6049572",
"0.602045",
"0.601726",
"0.60159814",
"0.6010698",
"0.59799844",
"0.5974786",... | 0.7807284 | 0 |
A function to compute accuracy, precision, recall, F1 score, and AUC on baseline and sample datasets. | def _eval_classifier(self):
y_pred_baseline = self.df_baseline[self.score_column]
y_pred_sample = self.df_sample[self.score_column]
y_label_baseline = self.df_baseline[self.label_column]
y_label_sample = self.df_sample[self.label_column]
precision_baseline = precision_score(y_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(predictions, test_labels):\n return f1_score(test_labels, predictions, average='micro') * 100",
"def run_analyses(y_predict_train, y_train, y_predict, y_test):\n # calculate metrics\n _, training_error = output_error(y_predict_train, y_train)\n (precision, recall, f1, _),... | [
"0.73754245",
"0.723671",
"0.71870387",
"0.7103964",
"0.7055236",
"0.70394593",
"0.6993133",
"0.6923043",
"0.69128865",
"0.68919206",
"0.68692416",
"0.6863576",
"0.6817139",
"0.6813245",
"0.6804683",
"0.6797919",
"0.67572665",
"0.6747165",
"0.6717102",
"0.6716808",
"0.6678665... | 0.7435086 | 0 |
A function to compute the jensenshannon distances between columns of similar DataFrames. For categorical columns, the probability of each category will be computed separately for `df_baseline` and `df_sample`, and the Jensen Shannon distance between the 2 probability arrays will be computed. For numerical columns, the ... | def js_metric(df_1, df_2, numerical_columns, categorical_columns):
res = {}
STEPS = 100
for col in categorical_columns:
# to ensure similar order, concat before computing probability
col_baseline = df_1[col].to_frame()
col_sample = df_2[col].to_frame()
col_baseline["source"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_js_divergence(df_1, df_2, n_bins=30):\n a = np.concatenate((df_1, df_2), axis=0)\n e, p = prob_mass_fun(df_1, n = n_bins, range = (a.min(), a.max()))\n _, q = prob_mass_fun(df_2, n = e, range = (a.min(), a.max()))\n\n return scipy.spatial.distance.jensenshannon(p, q)",
"def calculateDista... | [
"0.64014757",
"0.61950874",
"0.59821224",
"0.5697888",
"0.54592794",
"0.5174234",
"0.5137397",
"0.5131423",
"0.5122167",
"0.511841",
"0.51071995",
"0.5100075",
"0.5094216",
"0.50908756",
"0.5061743",
"0.50580746",
"0.5043095",
"0.50322914",
"0.50091624",
"0.49507222",
"0.4939... | 0.72510445 | 0 |
caculate the weight of every letter and store it in dict. the weight will be higher of the letter in the front of the str. | def calc_weight(str,dict):
for i,c in enumerate(str):
dict[c] += 10**(len(str)-(i+1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letter_freq( text ):\n\tchars = string.ascii_uppercase\n\ttext = text.upper()\n\tresult = get_letter_dict()\n\ttotal = 0\n\tfor char in chars:\n\t\tcount = text.count(char)\n\t\tresult[char] = count\n\t\ttotal += count\n\tif total != 0:\n\t\tfor char in chars:\n\t\t\tresult[char] = (result[char]*10000 / total)... | [
"0.6980124",
"0.66394264",
"0.6570559",
"0.64728016",
"0.6415543",
"0.63915235",
"0.63693476",
"0.6336936",
"0.62094826",
"0.6142864",
"0.60898614",
"0.6065776",
"0.5998639",
"0.5994172",
"0.5974454",
"0.5951927",
"0.5886264",
"0.5864922",
"0.58455706",
"0.5832374",
"0.581352... | 0.7911035 | 0 |
Construct a mock feed entry for testing purposes. | def _generate_mock_feed_entry(
external_id,
title,
distance_to_home,
coordinates,
category=None,
attribution=None,
published=None,
updated=None,
status=None,
):
feed_entry = MagicMock()
feed_entry.external_id = external_id
feed_entry.title = title
feed_entry.distance_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_mock_feed_entry(\n external_id, title, distance_to_home, coordinates, category\n ):\n feed_entry = MagicMock()\n feed_entry.external_id = external_id\n feed_entry.title = title\n feed_entry.distance_to_home = distance_to_home\n feed_entry.coordinates = coo... | [
"0.83168864",
"0.6930864",
"0.6871718",
"0.67939675",
"0.672434",
"0.6586626",
"0.6480374",
"0.6390978",
"0.62527645",
"0.62234247",
"0.6203504",
"0.6159744",
"0.6154554",
"0.6029947",
"0.5981847",
"0.5948124",
"0.59268343",
"0.5897245",
"0.5870529",
"0.58508486",
"0.5843938"... | 0.8014367 | 1 |
Set the web service up. Prepare to start the server, load base templates. | async def setup(self):
load_base_templates()
uris = URI.gather()
for uri, resource in uris.items():
methods = resource.methods
if "get" not in methods:
methods["get"] = None
for method in methods.keys():
self.app.add_routes([
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_server():\n cherrypy.config.update('server.conf')\n cherrypy.tree.mount(StringGeneratorWebService(), '/', 'server.conf')",
"def setup_server():\n\n require('environment', provided_by=env.environments)\n upgrade_packages()\n # Install required system packages for deployment, plus ... | [
"0.7408571",
"0.68233854",
"0.65421337",
"0.6487205",
"0.64843947",
"0.64820206",
"0.64214313",
"0.63946795",
"0.63638616",
"0.63557905",
"0.63319635",
"0.63204724",
"0.62664366",
"0.6252772",
"0.62226355",
"0.6215619",
"0.62104434",
"0.61679184",
"0.6167284",
"0.6160783",
"0... | 0.7317173 | 1 |
Compute the posterior from prior, data, and beta | def computePosterior(self):
# in their log form, posterior = prior + beta * datalikelihood
# make a copy of prior at first
self.posterior.copy(self.prior)
# add the data likelihood
altar.blas.daxpy(self.beta, self.data, self.posterior)
# all done
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_posterior(prior, likelihood, y):\n\n # -------------------------------------------------------------------------\n # ERROR CHECKS -- DO NOT MODIFY\n #\n\n # check that prior probabilities sum to 1\n if np.abs(1 - np.sum(prior)) > 1e-06:\n exit('In compute_posterior: The prior prob... | [
"0.6960007",
"0.6903496",
"0.6892312",
"0.6858051",
"0.6833745",
"0.6672229",
"0.664316",
"0.6620881",
"0.6616256",
"0.6613969",
"0.64222795",
"0.6411957",
"0.6320511",
"0.63114715",
"0.6309484",
"0.6231747",
"0.62173533",
"0.61869395",
"0.6168176",
"0.6164074",
"0.61630934",... | 0.7864245 | 0 |
Conversion from Topocentric Frame to parent frame | def _to_parent_frame(self, *args, **kwargs):
lat, lon, _ = self.latlonalt
m = rot3(-lon) @ rot2(lat - np.pi / 2.0) @ rot3(self.heading)
offset = np.zeros(6)
offset[:3] = self.coordinates
return self._convert(m, m), offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _switch_to_parent_frame(self):\n pass",
"def frame(self):\n sc = self.table\n components = tuple(getattr(sc.data, comp) for comp in sc.data.components)\n ref_frame = sc.frame.replicate_without_data()\n units = list(c.unit for c in components)\n\n # TODO: Currently th... | [
"0.638682",
"0.597424",
"0.59039867",
"0.5756185",
"0.5738526",
"0.5661447",
"0.55860686",
"0.5582718",
"0.5569664",
"0.55645853",
"0.55555004",
"0.55261123",
"0.5493971",
"0.54788893",
"0.54199463",
"0.54108435",
"0.5404521",
"0.5352165",
"0.5322155",
"0.5319915",
"0.5318639... | 0.6750881 | 0 |
Column that adds primary key foreign key reference. | def ReferenceCol(tablename, nullable=False, pk_name='id', **kwargs):
return db.Column(
db.ForeignKey("{0}.{1}".format(tablename, pk_name)),
nullable=nullable, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reference_col(tablename, nullable=True, pk_name='id', **kwargs):\n return db.Column(\n db.ForeignKey('{0}.{1}'.format(tablename, pk_name)),\n nullable=nullable, **kwargs)",
"def reference_col(tablename: str, nullable: bool = False, pk_name: str = 'id',\n onupdate: str = None... | [
"0.73920554",
"0.7201066",
"0.70771027",
"0.64817816",
"0.6393585",
"0.62086946",
"0.61619574",
"0.60691184",
"0.58412683",
"0.5764522",
"0.5702417",
"0.56470424",
"0.5642272",
"0.5633937",
"0.5618169",
"0.5618169",
"0.5618169",
"0.5618169",
"0.56098497",
"0.55792147",
"0.553... | 0.7489892 | 0 |
Plots Correlation matrix using Seaborn's heatmap() | def plot_correlation_mat(corr_matrix):
fig, ax = plt.subplots(figsize=(15, 10))
ax = sns.heatmap(corr_matrix, annot=True, linewidths=0.5, fmt=".2f", cmap="YlGnBu")
return fig, ax | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_heatmap():\n\n # retrieve data\n df = pd.read_csv('./housing.csv')\n df = df.dropna()\n\n # plot heatmap\n plt.figure(figsize=(10, 6))\n sns.heatmap(cbar=False, annot=True, data=df.corr(), cmap='coolwarm')\n plt.title('Correlation Matrix')\n\n plt.show()\n\n return None",
"d... | [
"0.80930406",
"0.79764396",
"0.78559196",
"0.77818274",
"0.7761641",
"0.75360155",
"0.7531052",
"0.75234735",
"0.73209655",
"0.72859406",
"0.72267157",
"0.7199242",
"0.7039838",
"0.7024438",
"0.70156866",
"0.6992622",
"0.69044554",
"0.68655294",
"0.685408",
"0.6838858",
"0.68... | 0.82679826 | 0 |
Takes an NumPy objects and calculate mean rounded up to 2 decimal places. Uses NumPy. | def mean_and_round(np_arr):
return np.around(np.mean(np_arr), 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(arr) -> float:\n return sum(arr) / len(arr)",
"def numpy_mean(arr):\n return arr.mean()",
"def mean_average_precision(rs):\n return np.mean([average_precision(r) for r in rs])",
"def mean_average_precision(rs):\n return np.mean([average_precision(r) for r in rs])",
"def mean_average_pre... | [
"0.7604948",
"0.73098946",
"0.7100601",
"0.7074791",
"0.7074791",
"0.70042104",
"0.69043773",
"0.68142015",
"0.68140984",
"0.6793933",
"0.6768673",
"0.6746572",
"0.67322683",
"0.67287934",
"0.67109233",
"0.6702194",
"0.6691489",
"0.669076",
"0.6683232",
"0.6679802",
"0.667202... | 0.78207487 | 0 |
Restores the value range of `x` from `scaled_quantization`. | def inverse_scaled_quantization(x, scale):
return x / tf.cast(scale, x.dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_scale(self) -> None:\n self._scale.set(self._start_val)",
"def setScaleX(self,startx,endx):\r\n if startx == endx:\r\n endx += 1\r\n self.scaleLock.acquire()\r\n self.scalex = [startx,endx]\r\n self.scaleLock.release()",
"def _unscale(self, x_scaled,\n ... | [
"0.65934366",
"0.63605946",
"0.6346162",
"0.61942303",
"0.6165913",
"0.60597116",
"0.60339946",
"0.6022547",
"0.594257",
"0.59286416",
"0.59124124",
"0.59093827",
"0.58548886",
"0.58281666",
"0.57701653",
"0.57419604",
"0.57379663",
"0.57320064",
"0.5703202",
"0.5676941",
"0.... | 0.65853035 | 1 |
Flattens each tensor in the structure and concats them as a vector. Each tensor within the structure should have rank >= 1 (i.e. no scalars). | def flatten_concat(structure):
flattened_as_list = []
for x in tf.nest.flatten(structure):
with tf.control_dependencies([tf.debugging.assert_rank_at_least(x, 1)]):
flattened_as_list.append(tf.reshape(x, [-1]))
return tf.concat(flattened_as_list, axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_flatten_concat(flat_vector, original_structure):\n location, split_tensors = 0, []\n for orig_t in tf.nest.flatten(original_structure):\n length = tf.size(orig_t)\n split_vector = tf.slice(flat_vector, [location], [length])\n split_tensors.append(tf.reshape(split_vector, orig_t.shape))\n ... | [
"0.6934443",
"0.6432345",
"0.63398564",
"0.63115364",
"0.6305452",
"0.61996335",
"0.6199364",
"0.6127758",
"0.61093885",
"0.6085986",
"0.60410327",
"0.60410327",
"0.60204536",
"0.59982544",
"0.59907216",
"0.5918523",
"0.5900797",
"0.5900797",
"0.59003973",
"0.58820534",
"0.58... | 0.67263645 | 1 |
Applies the inverse of `flatten_concat` given the original structure. | def inverse_flatten_concat(flat_vector, original_structure):
location, split_tensors = 0, []
for orig_t in tf.nest.flatten(original_structure):
length = tf.size(orig_t)
split_vector = tf.slice(flat_vector, [location], [length])
split_tensors.append(tf.reshape(split_vector, orig_t.shape))
location +=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten():",
"def unflatten(self, flat, unused_shaped_like):\n return next(flat)",
"def _unflatten(updates, flat):\n updates_flat, treedef = tree_flatten(updates)\n offsets = []\n for update in updates_flat:\n size = np.prod(update.shape)\n if offsets:\n offsets.append(size + o... | [
"0.6606743",
"0.6201",
"0.61660093",
"0.6140371",
"0.6018699",
"0.5994332",
"0.59197783",
"0.5779552",
"0.5744646",
"0.5611224",
"0.55886036",
"0.55516064",
"0.5547768",
"0.55092406",
"0.54934996",
"0.5468161",
"0.54661274",
"0.54348326",
"0.5426601",
"0.54238355",
"0.5408686... | 0.67896277 | 0 |
Sample uniform random +1/1 values with specified shape/dtype/seed_pair. | def sample_rademacher(shape, dtype, seed_pair):
rand_uniform = tf.random.stateless_uniform(shape=shape, seed=seed_pair)
return tf.cast(tf.sign(rand_uniform - 0.5), dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_init(self, shape):\n return np.random.randn(shape[0],shape[1])*0.01",
"def random_grid_generator(self, *input_shape):\n rnd = np.random.RandomState(1)\n rnd.rand(input_shape)",
"def __call__(self, shape):\n return np.random.uniform(low=self.minval, high=self.maxval, size=... | [
"0.6607744",
"0.65160346",
"0.6449938",
"0.63840264",
"0.6271769",
"0.62677956",
"0.62615526",
"0.6230718",
"0.6225875",
"0.6215122",
"0.6215122",
"0.62109816",
"0.6197962",
"0.6188556",
"0.6188556",
"0.6150676",
"0.6146104",
"0.6144197",
"0.61030155",
"0.60764605",
"0.607155... | 0.70864815 | 0 |
Applies randomized Hadamard transform to a vector with the given seed. | def randomized_hadamard_transform(x, seed_pair, repeat=1):
def apply_transform(repeat_index, x):
# All sources of randomness depend on the input seed.
cur_seed = seed_pair + repeat_index
# Randomly flip signs.
signs = sample_rademacher(tf.shape(x), dtype=x.dtype, seed_pair=cur_seed)
rademacher_x ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Randomize(self, seed):\n return _hypre.HypreParVector_Randomize(self, seed)",
"def Randomize(seed=None):\n random.seed()",
"def random():\n np.random.seed(1939)",
"def random_seed(seed):\n state = RandomState()\n random.seed(seed) # alter state\n np.random.seed(seed)\n torch.man... | [
"0.72160476",
"0.6252012",
"0.61264646",
"0.6104204",
"0.6027406",
"0.59588945",
"0.5843953",
"0.5826915",
"0.5806609",
"0.5764964",
"0.57520556",
"0.56425035",
"0.5587424",
"0.5571807",
"0.5561682",
"0.5561682",
"0.5544209",
"0.5542532",
"0.55329883",
"0.5522111",
"0.5521139... | 0.65680003 | 1 |
Applies inverse of `randomized_hadamard_transform` with the given seed. | def inverse_randomized_hadamard_transform(x, original_dim, seed_pair, repeat=1):
def inverse_transform(repeat_index, x):
# All sources of randomness depend on the input seed.
cur_seed = seed_pair + repeat_index
# Apply Hadamard.
unrotated_x = fast_walsh_hadamard_transform(tf.expand_dims(x, axis=0))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Randomize(self, seed):\n return _hypre.HypreParVector_Randomize(self, seed)",
"def randomized_hadamard_transform(x, seed_pair, repeat=1):\n\n def apply_transform(repeat_index, x):\n # All sources of randomness depend on the input seed.\n cur_seed = seed_pair + repeat_index\n # Randomly flip ... | [
"0.63035",
"0.5997",
"0.59833217",
"0.5879817",
"0.5676773",
"0.56577283",
"0.5605971",
"0.56022614",
"0.5587602",
"0.5516984",
"0.5442309",
"0.5429797",
"0.5382201",
"0.5339735",
"0.53354836",
"0.53172106",
"0.53168136",
"0.531431",
"0.531122",
"0.531122",
"0.53079414",
"0... | 0.67484003 | 0 |
Applies the fast WalshHadamard transform to a set of vectors. This method uses a composition of existing TensorFlow operations to implement the transform. | def fast_walsh_hadamard_transform(x):
with tf.compat.v1.name_scope(None, 'fast_walsh_hadamard_transform'):
# Validate input.
x = tf.convert_to_tensor(x)
if x.shape.ndims != 2:
raise ValueError('Number of dimensions of x must be 2. Shape of x: %s' %
x.shape)
original_x_sha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, words_as_ids):\n embeddings = []\n pvals = []\n\n for i in range(self.num_hash_functions):\n hashes = torch.take(self.hash_table[:, i], words_as_ids)\n embeddings.append(\n self.W[hashes, :]*self.P[words_as_ids, :][:, :, i].unsqueeze(-1))\... | [
"0.5522231",
"0.53372025",
"0.527949",
"0.52573943",
"0.5253499",
"0.52511674",
"0.5237799",
"0.52341264",
"0.5219605",
"0.52143556",
"0.5199507",
"0.51990074",
"0.519376",
"0.5169124",
"0.5154596",
"0.51501334",
"0.5148931",
"0.5145936",
"0.51418734",
"0.51379865",
"0.511156... | 0.5690857 | 0 |
Search for a language change event This event have to call retranslateUi to change interface language on the fly. | def changeEvent(self, event):
if event.type() == QEvent.LanguageChange:
self.retranslateUi(self)
self.translation()
else:
QWidget.changeEvent(self, event) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changeEvent(self, event):\n QtGui.QWidget.changeEvent(self, event)\n if event.type() == QtCore.QEvent.LanguageChange:\n self.ui.retranslateUi(self)",
"def on_language_changed(self, locale_code: str):\n self.localisationsettings.formats.on_language_changed(locale_code) # XXX: ... | [
"0.7505738",
"0.67875266",
"0.63437736",
"0.60278124",
"0.60113406",
"0.5933175",
"0.5888969",
"0.5872382",
"0.57965034",
"0.57594067",
"0.57474285",
"0.5727051",
"0.57047117",
"0.5654096",
"0.5597392",
"0.5592813",
"0.557915",
"0.5546464",
"0.5508444",
"0.55025834",
"0.54920... | 0.7507987 | 0 |
Position galaxies in haloes and give them random velocities. Centrals are positioned at the centre of the halo, satellites are positioned randomly following a NFW profile. Adds position, velocity and cosmological redshift to the catalogue. | def position_galaxies(self):
# random distance to halo centre
distance = self._get_distances()
# position around halo centre
pos = self._get_positions(distance)
# random velocity vector
vel = self._get_velocities()
# add properties to catalogue
self.add... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate(centres, masses, halomodel=None, profile=None, hodmod=None, edges=None):\r\n if halomodel is not None:\r\n profile = halomodel.halo_profile\r\n hodmod = halomodel.hod\r\n\r\n masses = np.array(masses)\r\n\r\n # Define which halos have central galaxies.\r\n cgal = np.random.bi... | [
"0.6275231",
"0.60089487",
"0.5885311",
"0.5736741",
"0.5690794",
"0.5661221",
"0.5655317",
"0.5602407",
"0.5582321",
"0.5573209",
"0.55618227",
"0.55206233",
"0.5515065",
"0.5512598",
"0.5505847",
"0.55015934",
"0.5452092",
"0.54224503",
"0.5379042",
"0.53735346",
"0.5357367... | 0.75214773 | 0 |
Add colours to the galaxy catalogue. | def add_colours(self, colour):
col = np.zeros(self.size)
is_cen = self.get("is_cen")
is_sat = self.get("is_sat")
abs_mag = self.get("abs_mag")
z = self.get("zcos")
col[is_cen] = colour.get_central_colour(abs_mag[is_cen], z[is_cen])
col[is_sat] = colour.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onAdd(self, event):\n dialog = wx.ColourDialog(self)\n\n if dialog.ShowModal() == wx.ID_OK:\n tup = _colorDataToTuple(dialog.GetColourData())\n self.graphColors.append(tup)\n self._tupleListToStrings()\n self._updateButtons(None)",
"def position_galaxies... | [
"0.6054459",
"0.58969396",
"0.5857854",
"0.5799438",
"0.5699093",
"0.56044793",
"0.55963576",
"0.55643207",
"0.55396104",
"0.54653233",
"0.54333127",
"0.5426593",
"0.54035664",
"0.5399104",
"0.5398703",
"0.53953093",
"0.5394801",
"0.53748614",
"0.5368808",
"0.5305265",
"0.528... | 0.6687702 | 0 |
Add apparent magnitude to catalogue, using a colourdependent kcorrection | def add_apparent_magnitude(self, k_correction):
app_mag = k_correction.apparent_magnitude(self.get("abs_mag"),
self.get("zcos"), self.get("col"))
self.add("app_mag", app_mag) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_absorption_correction(qz, scale):\n global t\n global mu\n global wavelength\n for i in xrange(len(scale)):\n #a = wavelength * qz[i] / 4 / math.pi\n a = 1.18 * qz[i] / 4 / math.pi\n theta = math.asin(a)\n g = 2 / math.sin(theta)\n Ac = t * g / mu / (1-math.... | [
"0.61943704",
"0.5803293",
"0.55368394",
"0.5523082",
"0.54558635",
"0.54471475",
"0.5332194",
"0.53284",
"0.5315003",
"0.5293777",
"0.52740526",
"0.52639467",
"0.524778",
"0.52342796",
"0.52268916",
"0.5213369",
"0.52128583",
"0.52124137",
"0.52076995",
"0.5202614",
"0.51987... | 0.74488336 | 0 |
Returns True if the group is considered 'active' i.e. downloading, postprocessing, running a script, etc, but NOT 'PAUSED'. | def nzbget_group_is_active(group):
return group['Status'] != 'PAUSED' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_active(self):\n return not self.pending",
"def is_active(self):\n return True",
"def is_active(self):\n return True",
"def is_active(self):\n return True",
"def is_active(self):\n return True",
"def is_active(self):\n return True",
"def is_active(self):\... | [
"0.7447838",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",
"0.70882857",... | 0.8493866 | 0 |
Returns the total size (in MB) of the groups that are considered active. | def nzbget_groups_total_active_size_mb(groups, ignore_group_id=None):
total_size_mb = 0
for group in groups:
group_id = group['NZBID']
if group_id != ignore_group_id and nzbget_group_is_active(group):
total_size_mb += group['FileSizeMB']
return total_size_mb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_size(self):\n return self._gsize",
"def queue_size(self):\n return len(self.groups)",
"def group_sizes(self):\n return self.g_sizes",
"def get_space_used():\n files = jobtracker.query(\"SELECT * FROM files \" \\\n \"WHERE status IN ('added', 'down... | [
"0.7319546",
"0.71736133",
"0.70472366",
"0.6881431",
"0.6765999",
"0.6727976",
"0.64822716",
"0.64482194",
"0.644731",
"0.6442343",
"0.64213836",
"0.6419984",
"0.63973016",
"0.63911587",
"0.6385464",
"0.6370308",
"0.6364254",
"0.6332993",
"0.6329032",
"0.6260791",
"0.6259489... | 0.80626035 | 0 |
Generator func that yields nzbs (groups) from the list of groups in the order of priority. | def nzbget_groups_iter_nzbs_by_priority(groups):
yielded_groups = 0
# the current priority being yielded
# On each iteration, this will be set to the next lowest priority until all
# groups are exhausted
current_priority = 999999
while len(groups) != yielded_groups:
# discover current ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def itergroups(groups, num=3):\n sortedgroups = sorted(groups, key=santamin)\n\n for c in sortedgroups:\n if num == 1:\n yield (c,)\n else:\n others = (\n t for t in sortedgroups\n if not set.intersection(t, c)\n )\n for ... | [
"0.65269375",
"0.6517903",
"0.57685906",
"0.57568085",
"0.5715821",
"0.5638671",
"0.5618139",
"0.56120896",
"0.55910784",
"0.5561625",
"0.55534804",
"0.5542105",
"0.55349934",
"0.5506357",
"0.54974157",
"0.5447159",
"0.5420551",
"0.53884554",
"0.53871655",
"0.53659403",
"0.53... | 0.83164 | 0 |
Assess BUSCO completeness on the most prevalent members of the metatranscriptome at each taxonomic level. | def manageBuscoQuery(output_dir, individual_or_summary, samples,
mets_or_mags, pep_ext, nt_ext,
sample_dir, organisms, organisms_taxonomy,
tax_tab, busco_threshold, perc_mem):
max_jobs = calc_max_jobs(len(samples), perc_mem = perc_mem)
samples_compl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_topo_current_occupants_positive():\n instance = topo.Topography()\n assert instance.current_occupants()[\"Herbivores\"] >= 0\\\n and instance.current_occupants()[\"Carnivores\"] >= 0",
"def test_get_utilizationPerc(self):\n for app_num, servo_type in app_nr.items():\n try:... | [
"0.54937917",
"0.5383217",
"0.5354205",
"0.52984875",
"0.523739",
"0.5234398",
"0.52048343",
"0.51565915",
"0.51536274",
"0.5137586",
"0.5136333",
"0.5101773",
"0.5067415",
"0.50583863",
"0.5044711",
"0.50408775",
"0.503162",
"0.50287145",
"0.50269985",
"0.50220853",
"0.50141... | 0.5942879 | 0 |
Update the exploration rate and target network if needed. This method is called in ``collect_rollouts()`` after each step in the environment. | def _on_step(self) -> None:
self._n_calls += 1
# Account for multiple environments
# each call to step() corresponds to n_envs transitions
if self._n_calls % max(self.target_update_interval // self.n_envs, 1) == 0:
polyak_update(self.q_net.parameters(), self.q_net_target.para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n with torch.no_grad():\n self.preprocess_rollout()\n \n # DEEP-RL TUTORIALS: КОСТЫЛЬ\n #self.advantages = self.returns[:-1] - self.values[:-1]\n #self.advantages = (self.advantages - self.advantages.mean()) / (self.advantages.std() + 1e-5)\n \... | [
"0.6818274",
"0.65078664",
"0.62273747",
"0.6226086",
"0.61098075",
"0.60934013",
"0.60540247",
"0.5974521",
"0.5917893",
"0.591169",
"0.58738273",
"0.5862635",
"0.5862635",
"0.5857583",
"0.5852532",
"0.5837221",
"0.5826191",
"0.5824564",
"0.57933074",
"0.57570016",
"0.573884... | 0.6896352 | 0 |
Simple helper function that groups a list into pairs. For example, [1,2,3,4,5] would return [1,2],[3,4] | def pairs(lst):
for i in range(1, len(lst), 2):
yield lst[i-1], lst[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_to_pairs(l):\n return {(l[2*i], l[2*i+1]) for i in range(len(l)/2)}",
"def get_pairs(my_list):\n return [(current, my_list[idx + 1] if - 1 else None) for idx, current in enumerate(my_list) if idx < len(my_list) - 1]",
"def group(lst, n):\n return zip(*[lst[i::n] for i in range(n)])",
"def... | [
"0.7544938",
"0.7045488",
"0.7019172",
"0.6966148",
"0.69476837",
"0.680975",
"0.6743494",
"0.6712265",
"0.6687029",
"0.66334724",
"0.6593827",
"0.6549743",
"0.65470976",
"0.6513818",
"0.64491403",
"0.6429426",
"0.63867474",
"0.63702846",
"0.6325235",
"0.62996686",
"0.6261211... | 0.7495571 | 1 |
This looks at what games everyone has won and sets their currentRank field. The current algorithm is very simple just award ranks based on number of games won. You should replace this with your own ranking logic. | def setRanks_ByNumWinsOnly(tourney_id):
logging.info('in setRanks()')
#Load all finished games
finishedGames = games.Game.all().filter("winner !=", None).filter("tourney_id =", tourney_id)#.run(batch_size=1000)
#logging.info("finishedGames:")
#logging.info(finishedGames)
players_id_name_dict = getPlayersIDNam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignRanks(self):\r\n\t\trank = 0\r\n\t\tscores = list(self._playerScores)\r\n\t\tscores.reverse()\r\n\t\tfor playerScore in scores:\r\n\t\t\tif not playerScore.has(NOT_MET) or not playerScore.value(NOT_MET):\r\n\t\t\t\trank += 1\r\n\t\t\t\tplayerScore.set(RANK, smallText(BugUtil.colorText(u\"%d\" % rank, Sco... | [
"0.7701785",
"0.67771345",
"0.67622954",
"0.6706499",
"0.66493636",
"0.6544014",
"0.6438019",
"0.63874644",
"0.6338628",
"0.6337832",
"0.62946194",
"0.6282804",
"0.6261159",
"0.62240756",
"0.6211711",
"0.6198657",
"0.61769044",
"0.6132075",
"0.6129363",
"0.61088383",
"0.60784... | 0.71486187 | 1 |
Basic test of parse_seat() take 1 | def test_parse_basic_seat1():
assert parse_seat("BFFFBBFRRR") == {"row": 70, "column": 7, "seat_id": 567} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_basic_seat2():\n assert parse_seat(\"FFFBBBFRRR\") == {\"row\": 14, \"column\": 7, \"seat_id\": 119}",
"def test_parse_basic_seat3():\n assert parse_seat(\"BBFFBBFRLL\") == {\"row\": 102, \"column\": 4, \"seat_id\": 820}",
"def test_end_to_end_max_seat_id():\n assert process_max_seat_id... | [
"0.8575361",
"0.8526021",
"0.586431",
"0.58630556",
"0.5824849",
"0.5770204",
"0.57489043",
"0.56829906",
"0.55174303",
"0.54567784",
"0.54225427",
"0.5383719",
"0.5380807",
"0.53624284",
"0.53471345",
"0.53407633",
"0.5339774",
"0.53127027",
"0.52768147",
"0.52578795",
"0.52... | 0.85374075 | 1 |
Basic test of parse_seat() take 2 | def test_parse_basic_seat2():
assert parse_seat("FFFBBBFRRR") == {"row": 14, "column": 7, "seat_id": 119} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_basic_seat3():\n assert parse_seat(\"BBFFBBFRLL\") == {\"row\": 102, \"column\": 4, \"seat_id\": 820}",
"def test_parse_basic_seat1():\n assert parse_seat(\"BFFFBBFRRR\") == {\"row\": 70, \"column\": 7, \"seat_id\": 567}",
"def parse_setup(self):\n lines = self.part_dict['HEADER'].s... | [
"0.8579122",
"0.8529321",
"0.5840505",
"0.5739816",
"0.55351585",
"0.55129427",
"0.54623157",
"0.5452151",
"0.5420828",
"0.539439",
"0.5380525",
"0.5380499",
"0.5371762",
"0.5355425",
"0.5296033",
"0.52840745",
"0.5265628",
"0.5253251",
"0.52506924",
"0.5245793",
"0.52362573"... | 0.8702471 | 0 |
Basic test of parse_seat() take 3 | def test_parse_basic_seat3():
assert parse_seat("BBFFBBFRLL") == {"row": 102, "column": 4, "seat_id": 820} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_basic_seat2():\n assert parse_seat(\"FFFBBBFRRR\") == {\"row\": 14, \"column\": 7, \"seat_id\": 119}",
"def test_parse_basic_seat1():\n assert parse_seat(\"BFFFBBFRRR\") == {\"row\": 70, \"column\": 7, \"seat_id\": 567}",
"def parse_setup(self):\n lines = self.part_dict['HEADER'].sp... | [
"0.84098965",
"0.83057326",
"0.5861814",
"0.5641647",
"0.54532164",
"0.54085153",
"0.53704274",
"0.5341643",
"0.53390044",
"0.5319168",
"0.5299978",
"0.52995086",
"0.5283545",
"0.52800584",
"0.52565485",
"0.5240545",
"0.5204363",
"0.518812",
"0.51803",
"0.5157534",
"0.5145569... | 0.8695104 | 0 |
Basic test of find_max_seat_id() | def test_find_max_seat_id():
data = [
{"seat_id": 100},
{"seat_id": 101},
{"seat_id": 99},
]
assert find_max_seat_id(data) == 101 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_end_to_end_max_seat_id():\n assert process_max_seat_id(\"test/test_input.txt\") == 820",
"def highest_seat_id(raw_seat_string):\n\n seat_list = raw_seat_string.split('\\n')\n\n return max(list(map(find_seat, seat_list)))",
"def check_maximum_seat_number(data: list) -> int:\n max_id: int = ... | [
"0.77137196",
"0.7553079",
"0.75166106",
"0.7501319",
"0.7238762",
"0.71223587",
"0.6671076",
"0.625585",
"0.6194733",
"0.61750185",
"0.6145588",
"0.59299815",
"0.5890674",
"0.5838614",
"0.58339375",
"0.58192277",
"0.5777797",
"0.5762046",
"0.568597",
"0.56781447",
"0.5644486... | 0.8820734 | 0 |
Test of find_missing_seat_id() where there's a result | def test_find_missing_seat_id_pass():
data = [
{"seat_id": 80},
{"seat_id": 81},
{"seat_id": 82},
{"seat_id": 84},
{"seat_id": 85},
{"seat_id": 86},
]
assert find_missing_seat_id(data) == 83 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_missing_seat_id_fail():\n data = [\n {\"seat_id\": 80},\n {\"seat_id\": 81},\n {\"seat_id\": 82},\n {\"seat_id\": 85},\n {\"seat_id\": 86},\n ]\n assert not find_missing_seat_id(data)",
"def find_missing_seat():\n seats = get_seats()\n sorted_seats ... | [
"0.84039485",
"0.6629025",
"0.6296133",
"0.62026966",
"0.6195017",
"0.61910295",
"0.6171958",
"0.61654013",
"0.61432534",
"0.60634506",
"0.5918979",
"0.5813625",
"0.57519233",
"0.57492834",
"0.566189",
"0.5584641",
"0.5579634",
"0.557004",
"0.55649096",
"0.5564887",
"0.556014... | 0.8349828 | 1 |
Test of find_missing_seat_id() where there's not result | def test_find_missing_seat_id_fail():
data = [
{"seat_id": 80},
{"seat_id": 81},
{"seat_id": 82},
{"seat_id": 85},
{"seat_id": 86},
]
assert not find_missing_seat_id(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_missing_seat_id_pass():\n data = [\n {\"seat_id\": 80},\n {\"seat_id\": 81},\n {\"seat_id\": 82},\n {\"seat_id\": 84},\n {\"seat_id\": 85},\n {\"seat_id\": 86},\n ]\n assert find_missing_seat_id(data) == 83",
"def find_missing_seat():\n seats = ... | [
"0.8486856",
"0.7042897",
"0.67516935",
"0.66206664",
"0.64159155",
"0.62605554",
"0.62197137",
"0.6132457",
"0.61267906",
"0.6034019",
"0.59460545",
"0.59395224",
"0.5898013",
"0.5690201",
"0.5640423",
"0.5616132",
"0.5612573",
"0.5598565",
"0.557603",
"0.5569318",
"0.555612... | 0.86334753 | 0 |
Split data intro training and validation sets. | def split_data_into_training_and_validation(self, data):
training_dataset = self.get_data_from_indices(data, np.arange(self.num_training_samples))
validation_dataset = self.get_data_from_indices(data, np.arange(self.num_training_samples,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __split_dataset(self):\n self.train, self.valid, _, _ = train_test_split(self.data, self.data, test_size=0.2)\n self.valid, self.test, _, _ = train_test_split(self.valid, self.valid, test_size=0.5)",
"def DataSplit(self, data):\n train_X,test_X,train_y,test_y=train_test_split(data[0],dat... | [
"0.82524365",
"0.7918833",
"0.7907695",
"0.78744817",
"0.77934724",
"0.77841425",
"0.7553694",
"0.75316596",
"0.749883",
"0.7467271",
"0.7454004",
"0.74421185",
"0.740271",
"0.7402066",
"0.7382333",
"0.72420216",
"0.7212905",
"0.7212459",
"0.7185964",
"0.71719664",
"0.7147314... | 0.8119909 | 1 |
Generate a training batch from the dataset. | def generate_training_batch(self, start_index):
assert self.training_dataset is not None
assert self.data_tags is not None
return self.get_data_from_indices(self.training_dataset,
np.arange(start_index, start_index + self.p.trainer.batch_size)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _train_batch(self):\n\n # start epoch\n for i, (source, target) in enumerate(self.train_dataset):\n result = self._batch_iter(source, target, i)\n\n # yield\n yield result",
"def train(self, num_batches: int):",
"def train(self, batch):\n pass",
"def ... | [
"0.75087404",
"0.74954695",
"0.743804",
"0.74340117",
"0.7427906",
"0.7394658",
"0.7330686",
"0.72800916",
"0.7218783",
"0.72080266",
"0.71831626",
"0.7147844",
"0.71367556",
"0.7100532",
"0.7089717",
"0.70591307",
"0.7027639",
"0.6986205",
"0.69554514",
"0.69537956",
"0.6950... | 0.76348877 | 0 |
Generate a validation batch from the dataset. | def generate_validation_batch(self):
assert self.validation_dataset is not None
assert self.data_tags is not None
# Sample indices and get data
index_array = np.random.choice(self.num_validation_samples, self.p.trainer.batch_size)
return self.get_data_from_indices(self.v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_validation_iterator(dataset_name, batch_size, prepro_fn):\n dataset, dataset_info = tfds.load(\n dataset_name,\n split=tfds.Split.VALIDATION,\n as_supervised=True,\n with_info=True\n )\n n_samples = dataset_info.splits['validation'].num_examples\n steps_per_epoch =... | [
"0.72375077",
"0.71314913",
"0.68508476",
"0.68276167",
"0.67395735",
"0.6738885",
"0.6708039",
"0.6707825",
"0.670537",
"0.66959596",
"0.6686347",
"0.6665691",
"0.6643919",
"0.6639715",
"0.65344036",
"0.6525875",
"0.6516666",
"0.65052766",
"0.6426993",
"0.640457",
"0.6393356... | 0.8522161 | 0 |
Shuffle the training and the validation datasets. This could be helpful in between the epochs for randomization. | def shuffle_datasets(self):
assert self.data_tags is not None
assert self.training_dataset is not None
assert self.validation_dataset is not None
self.training_dataset = self.shuffle_data_dictionary(self.training_dataset)
self.validation_dataset = self.shuffle_data_dictionary(sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle(self):\n self.x['train'], self.y['train'] = self._shuffle(\n self.x['train'],\n self.y['train']\n )",
"def shuffle_data(self):\n images = list(self.train_images)\n labels = list(self.train_labels)\n self.train_images = []\n self.train_la... | [
"0.78809863",
"0.7656801",
"0.74136424",
"0.728946",
"0.72745824",
"0.72745824",
"0.7274557",
"0.7032044",
"0.69678795",
"0.6923199",
"0.6871457",
"0.68283004",
"0.6759741",
"0.67200774",
"0.66847324",
"0.6634174",
"0.66236967",
"0.6616891",
"0.65153325",
"0.65012527",
"0.648... | 0.8032974 | 0 |
Shuffle a dictionary of the data. | def shuffle_data_dictionary(self, data_dictionary):
num_samples = np.shape(data_dictionary[self.data_tags[0]])[0]
shuffle_order = np.random.permutation(num_samples)
for data_tag in self.data_tags:
data_dictionary[data_tag] = data_dictionary[data_tag][shuffle_order]
return dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle_data_set(in_dict):\n tot_rows = in_dict['data'].shape[0]\n new_order = range(tot_rows)\n for _ in range(5):\n shuffle(new_order)\n\n out_dict = in_dict\n out_data = np.zeros((tot_rows, 3072), dtype=in_dict['data'].dtype)\n out_labels = [0] * tot_rows\n out_filenames = [\"\"]... | [
"0.69337624",
"0.65201235",
"0.62541014",
"0.6168857",
"0.61554205",
"0.61415964",
"0.6026391",
"0.593638",
"0.5859248",
"0.5713894",
"0.56773514",
"0.5676496",
"0.56371605",
"0.56341565",
"0.560438",
"0.5603332",
"0.5573811",
"0.5572391",
"0.5542036",
"0.5492935",
"0.5478818... | 0.6964315 | 0 |
Concatenate the data from different files in the file list. This function assumes that each file in file_list stores a dictionary and each element of that dictionary is an array with the zeroth dimension being the batch dimension. | def concatenate_file_data(self, file_list):
# Get all the tags in the data
if self.data_tags is None:
self.get_data_tags(file_list[0])
# Create all the keys
data = {}
for tag in self.data_tags:
data[tag] = []
# Load the data
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_data(data_files_dict):\n key_list = list(data_files_dict.keys())\n no_col = len(data_files_dict[key_list[0]])\n combined = []\n for n in range(0, no_col):\n d = np.empty(shape=[0, 1])\n for k in data_files_dict:\n d = np.append(d, data_fi... | [
"0.69127077",
"0.6761783",
"0.643715",
"0.6170756",
"0.61159426",
"0.60453576",
"0.5961572",
"0.5929535",
"0.59248734",
"0.58651626",
"0.58449316",
"0.5838416",
"0.58362633",
"0.58087844",
"0.5807969",
"0.5807938",
"0.58022875",
"0.57335716",
"0.57174873",
"0.5713997",
"0.571... | 0.7810755 | 0 |
Get the data corresponding to a given indices. | def get_data_from_indices(self, data_dictionary, indices):
data = {}
for tag in self.data_tags:
try:
data[tag] = data_dictionary[tag][indices]
except KeyError:
print("no this key in the current data file!")
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_by_indexes(indexes: list, data: np.ndarray) -> np.ndarray:\n return np.asarray([data[i, j] for i, j in indexes])",
"def get_data(features, labels_aud, labels_foc, files, indices):\n features = [features[idx] for idx in indices]\n labels_aud = [labels_aud[idx] for idx in indices]\n labels... | [
"0.7586238",
"0.73127365",
"0.70574576",
"0.67401016",
"0.6729097",
"0.6729097",
"0.67080015",
"0.66936725",
"0.6658126",
"0.6643573",
"0.65621924",
"0.6513033",
"0.6510402",
"0.6452007",
"0.6452007",
"0.64503914",
"0.64347494",
"0.64340377",
"0.6278575",
"0.62494344",
"0.623... | 0.7435763 | 1 |
Return a new unique ID for a Bokeh object. Normally this function will return UUIDs to use for identifying Bokeh objects. This is especally important for Bokeh objects stored on a Bokeh server. However, it is convenient to have more humanreadable IDs during development, so this behavior can be overridden by setting the... | def make_id():
global _simple_id
import uuid
from ..settings import settings
if settings.simple_ids(False):
_simple_id += 1
new_id = _simple_id
else:
new_id = uuid.uuid4()
return str(new_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeid(cls):\n return str(uuid.uuid4().hex)",
"def generateID(self):\n\n return str(uuid.uuid1())",
"def unique_id() -> str:",
"def unique_id(self) -> str:\n return \"{}-{}-{}\".format(*self._id)",
"def unique_id(self) -> str:\n return f\"{self.entry_id}_{self.module_id}_{se... | [
"0.7192764",
"0.6900491",
"0.68102014",
"0.6803424",
"0.6764766",
"0.6673727",
"0.6633095",
"0.65790826",
"0.6565736",
"0.6547194",
"0.65454394",
"0.6533682",
"0.6533682",
"0.6533682",
"0.6533682",
"0.6533682",
"0.6533682",
"0.6533682",
"0.6533682",
"0.65050566",
"0.6498698",... | 0.7228821 | 0 |
Test whether a given Bokeh object graph fragment is a reference. A Bokeh "reference" is a ``dict`` with ``"type"`` and ``"id"`` keys. | def is_ref(frag):
return isinstance(frag, dict) and \
frag.get('type') and \
frag.get('id') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isReference(node):\n return bool(isinstance(node, nodes.Referential)\n and node.get(DuAttrRefid, None))",
"def IsObjectReference(object_id):\n rhobj = rhutil.coercerhinoobject(object_id, True, True)\n return rhobj.IsReference",
"def IsReference(*args):\n return _XCAFD... | [
"0.7208989",
"0.68978435",
"0.6656231",
"0.65108323",
"0.64892554",
"0.64139205",
"0.633647",
"0.6287697",
"0.62567234",
"0.620393",
"0.62034136",
"0.61802816",
"0.61635923",
"0.61586934",
"0.6132557",
"0.61000454",
"0.5889549",
"0.578792",
"0.57384413",
"0.5651174",
"0.56364... | 0.82877874 | 0 |
Apply a function to JSON fragments that match the given predicate and return the collected results. Recursively traverses a nested collection of ``dict`` and ``list``, applying ``check_func`` to each fragment. If True, then collect ``func(fragment)`` in the final output | def json_apply(fragment, check_func, func):
if check_func(fragment):
return func(fragment)
elif isinstance(fragment, list):
output = []
for val in fragment:
output.append(json_apply(val, check_func, func))
return output
elif isinstance(fragment, dict):
out... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visititems(\n self, func: Callable[[str, H5ObjectLike], Optional[Any]]\n ) -> Optional[Any]:\n for key, val in self._recurse():\n result = func(key, val)\n if result is not None:\n return result",
"def _find_all_tree(tree: dict,\n func: ... | [
"0.52178305",
"0.5062513",
"0.5043645",
"0.49546078",
"0.49350768",
"0.49013165",
"0.48733497",
"0.48595333",
"0.48160285",
"0.4800665",
"0.47297716",
"0.47068483",
"0.4687181",
"0.46739703",
"0.46727103",
"0.46270838",
"0.46149638",
"0.45808113",
"0.4577964",
"0.45530745",
"... | 0.745029 | 0 |
transforms pandas series into array of values | def transform_series(obj):
vals = obj.values
return transform_array(vals) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_real_series(self, data: pd.Series) -> pd.Series:\n ...",
"def as_series(self, arraylike: Iterable) -> pd.Series:\n return pd.Series(arraylike, index=self.data.index)",
"def to_series(self) -> pd.Series:\n df = self.to_dataframe(\"* values *\")\n dims = self.dims_list\n ... | [
"0.71704954",
"0.7061575",
"0.7031719",
"0.69319797",
"0.69065505",
"0.68227774",
"0.67641383",
"0.67072475",
"0.66763926",
"0.66559494",
"0.65532196",
"0.6527722",
"0.65187865",
"0.6429818",
"0.63917977",
"0.6334467",
"0.6334109",
"0.63249093",
"0.63155305",
"0.6302324",
"0.... | 0.7271901 | 0 |
recursively dig until a flat list is found if numpy is available convert the flat list to a numpy array and send off to transform_array() to handle nan, inf, inf otherwise iterate through items in array converting nonjson items | def traverse_data(datum, is_numpy=is_numpy, use_numpy=True):
is_numpy = is_numpy and use_numpy
if is_numpy and not any(isinstance(el, (list, tuple)) for el in datum):
return transform_array(np.asarray(datum))
datum_copy = []
for item in datum:
if isinstance(item, (list, tuple)):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_flatten(obj):\n if type(obj) == list:\n return np.array(obj).flatten()\n return obj.flatten()",
"def flatten_array(arr):\n flat_array = []\n for item in arr:\n if isinstance(item, (list, tuple, set, np.ndarray)):\n flat_array.extend(flatten_array(item))\n el... | [
"0.61158556",
"0.60884506",
"0.60208136",
"0.6006318",
"0.59179527",
"0.5890883",
"0.58638185",
"0.5857572",
"0.58142793",
"0.5808231",
"0.5718021",
"0.5715654",
"0.5709441",
"0.570873",
"0.5690526",
"0.56904566",
"0.5660346",
"0.56412864",
"0.56313366",
"0.5619322",
"0.56070... | 0.72211057 | 0 |
iterate through the data of a ColumnSourceData object replacing nonJSONcompliant objects with compliant ones | def transform_column_source_data(data):
data_copy = {}
for key in iterkeys(data):
if is_pandas and isinstance(data[key], (pd.Series, pd.Index)):
data_copy[key] = transform_series(data[key])
elif isinstance(data[key], np.ndarray):
data_copy[key] = transform_array(data[key]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_data(self, data):\n for i, v in data.items():\n field_type = self.get_field_type(i)\n #log.info('i = %s, type = %s', i, field_type)\n if field_type == 'datetime' and isinstance(v, (str, unicode)):\n data[i] = datetime_from_string(v)\n return... | [
"0.5759236",
"0.5545789",
"0.5420785",
"0.54079247",
"0.53066033",
"0.5293256",
"0.526405",
"0.5231333",
"0.51467055",
"0.51421887",
"0.51374346",
"0.51202625",
"0.511182",
"0.50502455",
"0.50161517",
"0.49781084",
"0.4963979",
"0.4945259",
"0.49395826",
"0.49278015",
"0.4920... | 0.5899925 | 0 |
Create a new empty Hamiltonian dictionary with specified system level and qubit number. | def createHam(title: str, dt: float, qubitNum: int, sysLevel: Union[int, List[int]]) -> Dict[str, Any]:
ham = {"file": {
"title": title
}, "circuit": {
"dt": dt,
"qubits": qubitNum,
"sys_level": sysLevel,
"max_time_dt": 0,
"max_time_ns": 0
}, "drift": {},... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_hamiltonian(self, system):\n system.clear_hamiltonian()\n if 'bh' in system.left_block.operators.keys():\n system.add_to_hamiltonian(left_block_op='bh')\n if 'bh' in system.right_block.operators.keys():\n system.add_to_hamiltonian(right_block_op='bh')\n sys... | [
"0.59474945",
"0.58868927",
"0.5753628",
"0.55825675",
"0.557898",
"0.5478521",
"0.54647094",
"0.5365894",
"0.5333174",
"0.53028595",
"0.52734804",
"0.5255026",
"0.5235981",
"0.5233131",
"0.522762",
"0.51917464",
"0.5190359",
"0.51874644",
"0.5156378",
"0.5135316",
"0.5122525... | 0.710059 | 0 |
r""" Add a coupling term to the Hamiltonian. | def addCoupling(ham: Dict[str, Any], name: str, onQubits: Union[int, List[int]], g: float = 1.0) -> None:
assert len(onQubits) == 2, "Coupling term should be defined on two qubits."
# Obtain the system energy level.
if isinstance(ham["circuit"]["sys_level"], int):
d = ham["circuit"]["sys_level"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coupled_transmons_hamiltonian_new(w_q0, w_q1, alpha_q0, alpha_q1, J):\n\n H = w_q0 * n_q0 + w_q1 * n_q1 + \\\n 1/2*alpha_q0*(a.dag()*a.dag()*a*a) + 1/2*alpha_q1*(b.dag()*b.dag()*b*b) +\\\n J * (a.dag() + a) * (b + b.dag())\n H = H * (2*np.pi)\n return H",
"def coupled_transmons_hamilt... | [
"0.59127986",
"0.58933884",
"0.567439",
"0.5669956",
"0.5665846",
"0.55873823",
"0.5579496",
"0.5308816",
"0.52689976",
"0.52271956",
"0.5218155",
"0.51553357",
"0.51507616",
"0.5132085",
"0.51029915",
"0.5091421",
"0.5080393",
"0.50720584",
"0.5067808",
"0.50453013",
"0.5035... | 0.67748654 | 0 |
r""" Add a control term to the Hamiltonian. | def addControl(ham: Dict[str, Any], name: str, onQubits: Union[int, List[int]] = None,
matrices: Union[numpy.ndarray, List[numpy.ndarray]] = None) -> None:
sysLevel = ham["circuit"]["sys_level"]
qubitNum = ham["circuit"]["qubits"]
if onQubits is None:
# Input the complete matrices d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Hamiltonian(self):\n return None",
"def add_control(operation, num_ctrl_qubits, label):\n if isinstance(operation, UnitaryGate):\n # attempt decomposition\n operation._define()\n if _control_definition_known(operation, num_ctrl_qubits):\n return _control_predefined(operation... | [
"0.6014562",
"0.58964604",
"0.5785383",
"0.57070196",
"0.5706033",
"0.5582274",
"0.55815625",
"0.5538332",
"0.5494557",
"0.5494557",
"0.5494557",
"0.5494557",
"0.5484656",
"0.54816395",
"0.5398298",
"0.537979",
"0.53433686",
"0.52998674",
"0.5242221",
"0.5181041",
"0.5178365"... | 0.5920499 | 1 |
Extract a specified subsystem from a given Hamiltonian. The drift and control terms local to the specified subsystem remains. | def subSystem(ham: Dict[str, Any], onQubits: Union[int, List[int]], title: str = "") -> Dict[str, Any]:
subHam = copy.deepcopy(ham)
# clear cache
clearCache(subHam)
# Set title
if title == "":
subHam["file"]["title"] = f"{ham['file']['title']} (extracted)"
else:
subHam["file"][... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsystem(self) -> str:\n return self.raw.get(\"subsystem\", \"\")",
"def residue_subsystem():\n net = residue_network()\n state = (0, 0, 0, 0, 0)\n return Subsystem(net, state)",
"def macro_subsystem():\n net = macro_network()\n state = (0, 0, 0, 0)\n return Subsystem(net, state)"... | [
"0.509761",
"0.5022062",
"0.47142285",
"0.47015378",
"0.46661595",
"0.46575657",
"0.4640884",
"0.46092615",
"0.46068785",
"0.45206052",
"0.45048797",
"0.4498211",
"0.44765916",
"0.4446519",
"0.44277662",
"0.44175613",
"0.4412923",
"0.43960357",
"0.43945765",
"0.43541312",
"0.... | 0.54028475 | 0 |
Check whether all the items in listB are in listA | def allIn(listA: Union[int, List[int]], listB: Union[int, List[int]]) -> bool:
if isinstance(listA, int):
listA = [listA]
if isinstance(listB, int):
return listB in listA
else:
for item in listB:
if item not in listA:
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_subset(listA,listB):\n all(item in listA for item in listB)",
"def all_in_list (list1, list2):\n return all(map(lambda c: c in list2, list1) )",
"def is_in_list(list_one, list_two):\n \n for element in list_one:\n if element in list_two:\n return True\n return False",
"d... | [
"0.81238544",
"0.78284025",
"0.77208227",
"0.72385806",
"0.7131593",
"0.696522",
"0.69296336",
"0.6863823",
"0.6837614",
"0.67882943",
"0.67406625",
"0.6687766",
"0.6684608",
"0.66245824",
"0.65946794",
"0.6580066",
"0.65580344",
"0.6549663",
"0.65339845",
"0.6515715",
"0.650... | 0.83678997 | 0 |
Remove all waveforms in the specified control terms. If names is None, remove all waveforms in all control terms. | def clearWaves(ham: Dict[str, Any], names: Union[str, List[str]] = None) -> None:
if names is None:
for name in ham["control"].keys():
ham["control"][name]["waveforms"] = []
elif isinstance(names, str):
ham["control"][names]["waveforms"] = []
elif isinstance(names, list):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteWaveforms(self, Names):\n if isinstance(Names, basestring):\n dlmsg='WLISt:WAVeform:DELete \"'+Names+'\"'\n else:\n try:\n dlmsg=[]\n for name in Names:\n dlmsg.append('WLISt:WAVeform:DELete \"'+name+'\"')\n e... | [
"0.67089903",
"0.6554026",
"0.5963383",
"0.5631787",
"0.56165075",
"0.5514197",
"0.5471474",
"0.5434557",
"0.5421915",
"0.5359623",
"0.5246939",
"0.5246315",
"0.5231294",
"0.52220976",
"0.5188711",
"0.5177745",
"0.49799165",
"0.49662146",
"0.4963406",
"0.4963406",
"0.4963406"... | 0.7360348 | 0 |
Add waveforms to the control terms by waveData (generated by ``Utils.Waveforms.makeWaveData()``). Quanlse provides this function to add waveforms by dictionary data. In this way, users can save the wave data as a dictionary or a JSON string and import the wave batch by one function. | def addWaveData(ham: Dict[str, Any], waveData: Union[Dict[str, Any], List[Dict[str, Any]]]) -> None:
if isinstance(waveData, list):
for wave in waveData:
addWave(ham, wave['name'], t0=wave['insert_ns'], t=wave['duration_ns'], f=wave['func'], para=wave['para'])
elif isinstance(waveData, dic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddWave(self, wave_data):\n wave = OpBasedWave(wave_data, self)\n self._waves[wave.GetId()] = wave\n return wave",
"def add_waveform_analog(self):\r\n # make sure that the square wave tab is active now\r\n channel_keyword = self.current_Analog_channel.currentText()\r\n\r\n #----... | [
"0.6991151",
"0.68400174",
"0.62823683",
"0.61520255",
"0.59977305",
"0.5874419",
"0.58543944",
"0.5766652",
"0.5729535",
"0.56891096",
"0.5535386",
"0.552397",
"0.54914343",
"0.5385513",
"0.5384693",
"0.53394216",
"0.5331566",
"0.52651244",
"0.52641565",
"0.5230273",
"0.5184... | 0.695878 | 1 |
Remove a specified drift term from the Hamiltonian. | def removeDrift(ham: Dict[str, Any], names: Union[str, List[str]]) -> None:
if isinstance(names, str):
assert names in ham["drift"].keys(), "Term does not exist."
# We first extract necessary information of the circuit from Hamiltonian dictionary
ham["drift"].pop(names)
else:
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeCoupling(ham: Dict[str, Any], names: Union[str, List[str]]) -> None:\n if isinstance(names, str):\n assert names in ham[\"drift\"].keys(), \"Term does not exist.\"\n # We first extract necessary information of the circuit from Hamiltonian dictionary\n ham[\"drift\"].pop(names)\n ... | [
"0.5706451",
"0.5674799",
"0.5542834",
"0.55415416",
"0.536862",
"0.533996",
"0.5323749",
"0.53077793",
"0.522951",
"0.5217614",
"0.5192812",
"0.51636577",
"0.51423055",
"0.5127007",
"0.5126967",
"0.5091271",
"0.5065023",
"0.5056498",
"0.50562525",
"0.5037618",
"0.5020626",
... | 0.6817793 | 0 |
Remove a specified coupling term from Hamiltonian. | def removeCoupling(ham: Dict[str, Any], names: Union[str, List[str]]) -> None:
if isinstance(names, str):
assert names in ham["drift"].keys(), "Term does not exist."
# We first extract necessary information of the circuit from Hamiltonian dictionary
ham["drift"].pop(names)
ham["drift... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeControl(ham: Dict[str, Any], names: Union[str, List[str]]) -> None:\n if isinstance(names, str):\n assert names in ham[\"control\"].keys(), \"Term does not exist.\"\n # We first extract necessary information of the circuit from Hamiltonian dictionary\n ham[\"control\"].pop(names)\... | [
"0.63329244",
"0.5949252",
"0.59374124",
"0.5762517",
"0.5757833",
"0.57031626",
"0.55806273",
"0.54910016",
"0.54567546",
"0.54410404",
"0.54252124",
"0.54219544",
"0.54199535",
"0.5403475",
"0.5387251",
"0.5371275",
"0.5362766",
"0.535371",
"0.5347938",
"0.53265214",
"0.532... | 0.71377814 | 0 |
Remove a specified control term from the Hamiltonian. | def removeControl(ham: Dict[str, Any], names: Union[str, List[str]]) -> None:
if isinstance(names, str):
assert names in ham["control"].keys(), "Term does not exist."
# We first extract necessary information of the circuit from Hamiltonian dictionary
ham["control"].pop(names)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, atom):\n try:\n self.hutch.remove_atom(atom)\n except:# AttributeError or ValueError:\n pass\n self.atoms.remove(atom)\n self.natoms -= 1\n self.atomtypes[atom.z] -= 1",
"def removeControl(*args):",
"def removeControl(*args):",
"def re... | [
"0.6204277",
"0.6125393",
"0.6125393",
"0.6125393",
"0.6125393",
"0.58538765",
"0.5638136",
"0.5616294",
"0.5519861",
"0.5486321",
"0.5455528",
"0.5454094",
"0.5450255",
"0.54496413",
"0.54461575",
"0.5417173",
"0.5378567",
"0.5368653",
"0.53245497",
"0.5314238",
"0.5312071",... | 0.71903634 | 0 |
Generate the cache for further usage. In this function, we run ``buildOperatorCache()`` and ``buildSequenceCache()`` to build the global operator matrices and the pulse sequences before saving them to cache. | def buildCache(ham: Dict[str, Any]) -> None:
# Initialize the Hamiltonian
clearCache(ham)
# Build operators and sequences
buildOperatorCache(ham)
buildSequenceCache(ham) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildOperatorCache(ham: Dict[str, Any]) -> None:\n sysLevel = ham[\"circuit\"][\"sys_level\"]\n qubitNum = ham[\"circuit\"][\"qubits\"]\n\n # Generator the operator for all of the drift terms\n for key in ham[\"drift\"]:\n drifts = ham[\"drift\"][key]\n operator = generateOperator(dri... | [
"0.6599837",
"0.64631325",
"0.62695783",
"0.6259583",
"0.6210449",
"0.6173838",
"0.59399456",
"0.592894",
"0.59132767",
"0.59029585",
"0.58979404",
"0.58667684",
"0.5851416",
"0.58304054",
"0.5804928",
"0.57113016",
"0.5695036",
"0.5671874",
"0.566925",
"0.5595141",
"0.558278... | 0.6505631 | 1 |
Transform a string (generated by ``toJson()``) to the Hamiltonian dictionary. | def createFromJson(jsonStr: str) -> Dict[str, Any]:
jham = json.loads(jsonStr)
clearCache(jham)
# Transform the control operators
for key in jham["control"]:
ctrls = jham["control"][key]
# Modify the matrices
if isinstance(ctrls["matrices"], list):
mats = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dashes_to_hm(s: str) -> str:\n\t\treturn str(s).replace(Chars.em, '-').replace(Chars.en, '-').replace(Chars.fig, '-').replace(Chars.minus, '-').replace(Chars.hyphen, '-').replace(Chars.nbhyphen, '-')",
"def get_string_stech_dict(stech_string):\n stech_dict = {}\n try:\n stech_lst = stech_string.... | [
"0.5425376",
"0.5285156",
"0.50045025",
"0.49990407",
"0.4964661",
"0.49217862",
"0.4919732",
"0.48082206",
"0.48077932",
"0.47730815",
"0.4758701",
"0.47280112",
"0.47058347",
"0.47031832",
"0.4698787",
"0.46656302",
"0.46461138",
"0.46228218",
"0.46191093",
"0.46165276",
"0... | 0.5489021 | 0 |
return the detection probability as a function of the single exposure efficiencies | def detectionProb(efficiency, trigger=1):
if trigger > 1.:
raise ValueError('Trigger > 1 not implemented yet\n')
q = 1.0 - np.asarray(efficiency)
# probability of 0 detections
logq = np.log(q)
logpiq = logq.sum()
piq = np.exp(logpiq)
return 1.0 - piq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def det_probability(input_state, detection_event):\n st_aft_det_unappl = detection(input_state, detection_event)\n st_aft_det_conj_app = np.conj(make_state_appliable_4ch(st_aft_det_unappl))\n input_state_appl = make_state_appliable_4ch(input_state)\n st = np.multiply(input_state_appl, st_aft_det_conj_a... | [
"0.6501317",
"0.6443905",
"0.6361818",
"0.61561155",
"0.60535234",
"0.6006996",
"0.5985686",
"0.594117",
"0.593815",
"0.5896055",
"0.58739215",
"0.5822818",
"0.5815063",
"0.58043927",
"0.58011496",
"0.57922727",
"0.57537085",
"0.5731171",
"0.5729343",
"0.5726372",
"0.5721446"... | 0.70480144 | 0 |
Return a dictionary specifying the defaults for this form. This dictionary shall be used to inject the initial values for an Angular controller using the directive 'nginit={{thisform.get_initial_data|js|safe}}'. | def get_initial_data(self):
data = {}
for name, field in self.fields.items():
if hasattr(field, 'widget') and 'ng-model' in field.widget.attrs:
data[name] = self.initial and self.initial.get(name) or field.initial
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def defaults():\n\n dummy = FieldTemplate.dummy\n\n return {\"disease_demographic_id\": dummy(\"demographic_id\"),\n }",
"def your_reservation_defaults(self, defaults):\n\n default_email = self.email()\n if default_email:\n defaults['email'] = self.email()\n\... | [
"0.70314217",
"0.7019184",
"0.69623965",
"0.6813803",
"0.67751884",
"0.67474955",
"0.663069",
"0.6547036",
"0.64795905",
"0.6336114",
"0.63260394",
"0.6297748",
"0.62811136",
"0.6272118",
"0.626164",
"0.6257755",
"0.6234373",
"0.6230987",
"0.6228861",
"0.6204141",
"0.61935157... | 0.715202 | 0 |
Determine the kind of input field and create a list of potential errors which may occur during validation of that field. This list is returned to be displayed in '$dirty' state if the field does not validate for that criteria. | def get_field_errors(self, bound_field):
errors = super(NgFormValidationMixin, self).get_field_errors(bound_field)
identifier = format_html('{0}.{1}', self.form_name, self.add_prefix(bound_field.name))
errors_function = '{0}_angular_errors'.format(bound_field.field.__class__.__name__)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_errors(self, field):\r\n identifier = format_html('{0}.{1}', self.form_name, field.name)\r\n return self.error_class([SafeTuple((identifier, '$pristine', '$pristine', 'invalid', e))\r\n for e in self.errors.get(field.name, [])])",
"def _validate_fields(self, ch... | [
"0.64596385",
"0.59634346",
"0.5905149",
"0.5889445",
"0.5847374",
"0.5789448",
"0.5700832",
"0.5699527",
"0.5686681",
"0.5601838",
"0.55697906",
"0.55529225",
"0.55170685",
"0.55064267",
"0.5455092",
"0.54352534",
"0.53829694",
"0.5356972",
"0.5354583",
"0.5330082",
"0.52914... | 0.669821 | 0 |
Build ModelForm from model | def get_form_class(self):
return modelform_factory(self.model) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_form(self):",
"def get_form_for_model(\n model,\n form_class=WagtailAdminModelForm,\n **kwargs,\n):\n\n # This is really just Django's modelform_factory, tweaked to accept arbitrary kwargs.\n\n meta_class_attrs = kwargs\n meta_class_attrs[\"model\"] = model\n\n # The kwargs passed h... | [
"0.6656406",
"0.65450215",
"0.6428031",
"0.6369436",
"0.6356058",
"0.6356058",
"0.63211066",
"0.615083",
"0.61396116",
"0.61139625",
"0.6083428",
"0.6065119",
"0.60369545",
"0.6027717",
"0.5952687",
"0.59455264",
"0.59442353",
"0.587769",
"0.5865732",
"0.58307207",
"0.5775871... | 0.66317123 | 1 |
Used when angular's query() method is called Build an array of all objects, return json response | def ng_query(self, request, *args, **kwargs):
return self.build_json_response(self.get_queryset()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_data():\n return jsonify(service.get_all_data())",
"def get_all_products(self):\n try: \n data = [ProductService.self_json(product) \n for product in self.productModel.query.all()] \n \n return Response(\n response=json.d... | [
"0.6735071",
"0.66806215",
"0.6582834",
"0.6573205",
"0.65703523",
"0.65511554",
"0.6521539",
"0.64924604",
"0.64832145",
"0.6463034",
"0.64612055",
"0.6439454",
"0.64274085",
"0.6410017",
"0.6385594",
"0.6356347",
"0.63551503",
"0.63498086",
"0.6339762",
"0.6311569",
"0.6296... | 0.77316815 | 0 |
Used when angular's get() method is called Returns a JSON response of a single object dictionary | def ng_get(self, request, *args, **kwargs):
return self.build_json_response(self.get_object()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get():\n #Return the corresponding value\n return json_back()",
"def get(self):\r\n return http.Request('GET', self.get_url()), parsers.parse_json",
"def get(self):\r\n return http.Request('GET', self.get_url()), parsers.parse_json",
"def get_json_response(obj):\n return HttpRespon... | [
"0.6821552",
"0.673916",
"0.673916",
"0.67282",
"0.67282",
"0.6662362",
"0.661337",
"0.66059166",
"0.6581269",
"0.6572601",
"0.6561801",
"0.64382976",
"0.64295214",
"0.6376674",
"0.6344746",
"0.6327519",
"0.6326064",
"0.6294211",
"0.62926847",
"0.6282645",
"0.6278337",
"0.6... | 0.83894086 | 0 |
Evaluate log density at th, which is (2,) or (n_samples, 2) np.array | def log_prob(self, th):
if len(th.shape) == 1:
th1, th2 = th[0], th[1]
elif len(th.shape) == 2:
th1, th2 = th[:,0], th[:,1]
else:
raise RuntimeError("th must be either (2,) or (n_samples, 2)")
mask = (
(th1 >= -2.)
* (th1 <= 2.)
* (th2 >= -1 - th1)
* (th2 >= th1 - 1)
* (th2 <= ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_prob(self, th):\n\n\t\tmask = self.__low <= th <= self.__high\n\t\tif len(th.shape) == 1:\n\t\t\tlength = 1\n\t\telif len(th.shape) == 2:\n\t\t\tlength = th.shape[0]\n\t\telse:\n\t\t\traise RuntimeError(\"th must be either (d,) or (n_samples, d)\")\n\t\tlogprobs = np.empty(length)\n\t\tlogprobs[mask] = 0.\... | [
"0.69107664",
"0.64126515",
"0.63633007",
"0.6281782",
"0.6158695",
"0.6144112",
"0.6141422",
"0.6132505",
"0.61037225",
"0.61035866",
"0.603744",
"0.60271156",
"0.59994197",
"0.59938765",
"0.5992722",
"0.5991237",
"0.5990691",
"0.5990691",
"0.598747",
"0.598747",
"0.5979198"... | 0.6512304 | 1 |
Creates a tuple expected by Requests from file path | def file_entry(file_path: str) -> Tuple[str, Any, str]:
file_name = os.path.split(file_path)[1]
file_handler = open(file_path, "rb")
content_type = "application/octet-stream"
return (file_name, file_handler, content_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_file(self, path: str) -> Tuple[str, bytes]:\n self._trace(\"fetching: %s\" % path)\n meta, resp = self._connection.files_download(path)\n return (meta.rev, resp.content)",
"def readfile(path):\n with open(path, 'r', encoding='utf-8') as f:\n param = tuple(f.readlines())\n ... | [
"0.6163452",
"0.6103697",
"0.5977744",
"0.5952086",
"0.5695823",
"0.56858265",
"0.5680875",
"0.5667716",
"0.56023204",
"0.553311",
"0.54913247",
"0.5480908",
"0.54769737",
"0.5473954",
"0.54552585",
"0.54475963",
"0.54387265",
"0.5420151",
"0.5408895",
"0.5406862",
"0.5384725... | 0.62068725 | 0 |
returns aStr cropped to maxLen if necessary. Cropped strings are returned with an ellipsis marker. | def makeEllipsis(aStr, maxLen=60):
if len(aStr)>maxLen:
return aStr[:maxLen-3]+"..."
return aStr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeLeftEllipsis(aStr, maxLen=60):\n\tif len(aStr)>maxLen:\n\t\treturn \"...\"+aStr[-maxLen+3:]\n\treturn aStr",
"def _truncate_string(self, text, max_size):\n import textwrap\n\n if len(text) <= max_size:\n return text\n return textwrap.wrap(text, max_size-3)[0] + \"...\"",
... | [
"0.73459494",
"0.7190673",
"0.7079169",
"0.7044328",
"0.70351",
"0.6975324",
"0.69679075",
"0.6856357",
"0.6771841",
"0.67603016",
"0.6724185",
"0.66830474",
"0.6633533",
"0.6623028",
"0.65862703",
"0.65635395",
"0.6535034",
"0.6520394",
"0.6520394",
"0.6520394",
"0.6520394",... | 0.770175 | 0 |
returns aStr shortened to maxLen by dropping prefixes if necessary. Cropped strings are returned with an ellipsis marker. >>> makeLeftEllipsis("0123456789"2, 11) '...23456789' | def makeLeftEllipsis(aStr, maxLen=60):
if len(aStr)>maxLen:
return "..."+aStr[-maxLen+3:]
return aStr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeEllipsis(aStr, maxLen=60):\n\tif len(aStr)>maxLen:\n\t\treturn aStr[:maxLen-3]+\"...\"\n\treturn aStr",
"def ellipsis(s, maxlen=232):\n s = stringify(s)\n if len(s) > maxlen:\n return s[:maxlen - 3] + '...'\n else:\n return s\n\n # TODO: do we really want ... at end, or in middl... | [
"0.7711692",
"0.7123479",
"0.7025371",
"0.6594846",
"0.64420605",
"0.6430601",
"0.64254445",
"0.6422693",
"0.6402405",
"0.63921213",
"0.6391795",
"0.6384326",
"0.6378199",
"0.6369671",
"0.63505864",
"0.6315771",
"0.63147795",
"0.6311971",
"0.6292114",
"0.6276397",
"0.6276397"... | 0.87820166 | 0 |
returns the file stem of a file path. The base name is what remains if you take the base name and split off extensions. The extension here starts with the last dot in the file name, except up to one of some common compression extensions (.gz, .xz, .bz2, .Z, .z) is stripped off the end if present before determining the ... | def getFileStem(fPath):
for ext in [".gz", ".xz", ".bz2", ".Z", ".z"]:
if fPath.endswith(ext):
fPath = fPath[:-len(ext)]
break
return os.path.splitext(os.path.basename(fPath))[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stem(fp) -> str:\n return os.path.splitext(os.path.split(fp)[1])[0]",
"def stem(self) -> str:",
"def getStem(self,):\n\t\treturn self.stem;",
"def stem(s):\r\n if len(s) < 5 :\r\n return s\r\n \r\n if s[-3:] == 'ing':\r\n if s[-4] == s[-5]:\r\n if s[-4] == 'l' :\r... | [
"0.70235664",
"0.638332",
"0.6057964",
"0.59228826",
"0.59093267",
"0.5903577",
"0.58876365",
"0.58703774",
"0.5851869",
"0.58013976",
"0.5796463",
"0.5764346",
"0.5760799",
"0.5752325",
"0.5701137",
"0.5676355",
"0.5638632",
"0.5581725",
"0.55812526",
"0.5578713",
"0.5567055... | 0.78443646 | 0 |
returns a string containing a text representation of tabular data. All columns of data are simply stringified, then the longest member determines the width of the text column. The behaviour if data does not contain rows of equal length is unspecified; data must contain at least one row. If you have serialised the value... | def formatSimpleTable(data, stringify=True):
if stringify:
data = [[str(v) for v in row] for row in data]
if not data:
return ""
colWidthes = [max(len(row[colInd]) for row in data)
for colInd in range(len(data[0]))]
fmtStr = " ".join("%%%ds"%w for w in colWidthes)
table = "\n".join(fmtStr%tuple(row) for r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n\n table_list = [self.headers]\n\n for row in self.data:\n table_list.append([row[col] or \"\" for col in self.headers])\n\n return create_table_string(table_list)",
"def as_text(self, max_rows=0, sep=\" | \"):\n if not max_rows or max_rows > self.num_ro... | [
"0.6451867",
"0.6264562",
"0.62537986",
"0.62405264",
"0.62400794",
"0.6196569",
"0.61724645",
"0.61646146",
"0.6154997",
"0.6147526",
"0.6112702",
"0.6110626",
"0.6037535",
"0.6021504",
"0.5992952",
"0.5984068",
"0.5971838",
"0.594819",
"0.5947715",
"0.5941354",
"0.59386104"... | 0.74977344 | 0 |
returns rest if fullPath has the form rootPath/rest and raises an exception otherwise. Pass liberalChars=False to make this raise a ValueError when URLdangerous characters (blanks, amperands, pluses, nonASCII, and similar) are present in the result. This is mainly for products. | def getRelativePath(fullPath, rootPath, liberalChars=True):
if not fullPath.startswith(rootPath):
raise ValueError(
"Full path %s does not start with resource root %s"%(fullPath, rootPath))
res = fullPath[len(rootPath):].lstrip("/")
if not liberalChars and not _SAFE_FILENAME.match(res):
raise ValueError("File... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_short_path(short_path):",
"def _test_trailing_slashes(self, allowed_origins):\n eq_(filter(lambda v: v.endswith('/'), allowed_origins), [])",
"def test_append_slash_slashless_resource(self):\n\n def get_response(req):\n return HttpResponse(\"Here's the text of the web page... | [
"0.5029412",
"0.4954075",
"0.4817368",
"0.47890925",
"0.47834828",
"0.4697663",
"0.46614882",
"0.46436748",
"0.46392095",
"0.4614624",
"0.46116313",
"0.45980006",
"0.45639986",
"0.4529755",
"0.45204502",
"0.45174444",
"0.45069516",
"0.45009154",
"0.44938397",
"0.4474402",
"0.... | 0.60958695 | 0 |
joins relPath to rootPath and makes sure the result really is in rootPath. | def resolvePath(rootPath, relPath):
relPath = relPath.lstrip("/")
fullPath = os.path.realpath(os.path.join(rootPath, relPath))
if not fullPath.startswith(rootPath):
raise ValueError(
"Full path %s does not start with resource root %s"%(fullPath, rootPath))
if not os.path.exists(fullPath):
raise ValueError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relatif (path, root = None):\n\tfrom os import sep, getcwd\n\tpath = normalizePath(path)\n\tif root != None:\n\t\troot =normalizePath(root)\n\t# If the path is empty\n\tif len(path) == 0:\n\t\treturn \"\"\n\n\t# If the root is not defined\n\tif root == None:\n\t\t# Take the current directory\n\t\troot = getcwd... | [
"0.6213788",
"0.606893",
"0.6012407",
"0.6010755",
"0.5976683",
"0.590214",
"0.5892095",
"0.5815842",
"0.58149546",
"0.5803265",
"0.5786024",
"0.57689214",
"0.5762937",
"0.57578284",
"0.5755756",
"0.5749681",
"0.5737344",
"0.5735316",
"0.5711752",
"0.57046556",
"0.56874233",
... | 0.679479 | 0 |
returns code with all whitespace from governingLine removed from every line and newIndent prepended to every line. governingLine lets you select a line different from the first one for the determination of the leading white space. Lines before that line are left alone. >>> fixIndentation(" foo\\n bar", "") 'foo\\nbar' ... | def fixIndentation(code, newIndent, governingLine=0):
codeLines = [line for line in code.split("\n")]
reserved, codeLines = codeLines[:governingLine], codeLines[governingLine:]
while codeLines:
if codeLines[0].strip():
firstIndent = re.match("^\s*", codeLines[0]).group()
break
else:
reserved.append(code... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_indents(self):\n indent_map = list(map(self._get_indent, self.config_lines_str))\n fixed_indent_map = []\n for i in range(len(indent_map)):\n if i == 0:\n ### Assume the first line is not indented\n fixed_indent_map.append(0)\n co... | [
"0.6018222",
"0.60079324",
"0.5889278",
"0.58191836",
"0.57753325",
"0.56360745",
"0.562741",
"0.5499804",
"0.54032934",
"0.5389742",
"0.5336005",
"0.5314965",
"0.5309831",
"0.52828723",
"0.5275989",
"0.5219555",
"0.52109426",
"0.5199615",
"0.5171671",
"0.51571655",
"0.513382... | 0.8144964 | 0 |
returns a name mapping dictionary from a list of assignments. This is the preferred form of communicating a mapping from external names to field names in records to macros in a string that contains | def parseAssignments(assignments):
return dict([(lead, trail) for lead, trail in
[litPair.split(":") for litPair in assignments.split()]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_list2map(variable_lists):\n return_dict = dict()\n for single_variable in variable_lists:\n return_dict[single_variable[\"name\"]] = single_variable[\"value\"]\n return return_dict",
"def resolution_map(names, env):\n return dict(zip(names, [resolve(n, env) for n in names]))",
"d... | [
"0.5940826",
"0.5781063",
"0.5669497",
"0.5649312",
"0.54847765",
"0.5410644",
"0.5397019",
"0.53371227",
"0.53124726",
"0.52344745",
"0.52309954",
"0.522859",
"0.52177083",
"0.51845324",
"0.51816136",
"0.5166589",
"0.51553416",
"0.51543194",
"0.51465905",
"0.5145704",
"0.514... | 0.68383265 | 0 |
returns the time angle (h m s.decimals) as a float in degrees. >>> "%3.8f"%hmsToDeg("22 23 23.3") '335.84708333' | def hmsToDeg(hms, sepChar=None):
hms = hms.strip()
try:
if sepChar=="":
parts = hms[:2], hms[2:4], hms[4:]
else:
parts = hms.split(sepChar)
if len(parts)==3:
hours, minutes, seconds = parts
elif len(parts)==2:
hours, minutes = parts
seconds = 0
else:
raise ValueError("Too many parts")
ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fracHoursToDeg(fracHours):\n\treturn float(fracHours)*360./24.",
"def dmsToDeg(dmsAngle, sepChar=None):\n\tdmsAngle = dmsAngle.strip()\n\tsign = 1\n\tif dmsAngle.startswith(\"+\"):\n\t\tdmsAngle = dmsAngle[1:].strip()\n\telif dmsAngle.startswith(\"-\"):\n\t\tsign, dmsAngle = -1, dmsAngle[1:].strip()\n\ttry:\... | [
"0.69034564",
"0.6659978",
"0.6633685",
"0.6584065",
"0.6549116",
"0.63649076",
"0.6357029",
"0.63425636",
"0.63278055",
"0.63217",
"0.6280798",
"0.62666005",
"0.62301016",
"0.62295395",
"0.6139292",
"0.6031674",
"0.6026495",
"0.5987285",
"0.5951982",
"0.5940332",
"0.59133637... | 0.7676824 | 0 |
returns the degree minutes secondsspecified dmsAngle as a float in degrees. >>> "%3.8f"%dmsToDeg("45 30.6") '45.51000000' | def dmsToDeg(dmsAngle, sepChar=None):
dmsAngle = dmsAngle.strip()
sign = 1
if dmsAngle.startswith("+"):
dmsAngle = dmsAngle[1:].strip()
elif dmsAngle.startswith("-"):
sign, dmsAngle = -1, dmsAngle[1:].strip()
try:
if sepChar=="":
parts = dmsAngle[:2], dmsAngle[2:4], dmsAngle[4:]
else:
parts = dmsAngl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rad_to_deg(radians):\n if isinstance(radians, (Angle,)): #Ephem doesn't output a numerical value with unicode\n radians = Decimal(float(radians))\n else:\n radians = Decimal(unicode(radians))\n degrees = radians * (360/TWO_PI)\n degrees = degrees % (Decimal(\"360\"))\n return degre... | [
"0.7078239",
"0.69546986",
"0.6894301",
"0.6798216",
"0.679597",
"0.67803764",
"0.67683977",
"0.6717655",
"0.67032504",
"0.66977334",
"0.66681755",
"0.6660562",
"0.6619473",
"0.65747017",
"0.65482783",
"0.65456957",
"0.65062934",
"0.6505719",
"0.6491589",
"0.6483754",
"0.6464... | 0.7369881 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.