query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Return the value of the given state | def get_state_value(self, state):
values = self.get_all_state_action_values(state)
policy = self.target_policy(values)
return (values @ policy.probs.t()).item() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\r\n return self.values[state]",
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.values[state]",
"def getValue(self, state):\n return self.v... | [
"0.8866701",
"0.8836032",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.87983",
"0.8606197",
"0.8606197",
"0.8229139",
"0.8229139",
"0.81572795",
"0.7989323",
"0.79809093",
"0.78574026",
"0.7807... | 0.8202456 | 18 |
Return the value of the given stateaction pair | def get_state_action_value(self, state, action):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_value(self, state, action):\n return self.value_function[to_table_index(state, action)]",
"def getQValue(self, state, action):\n \"*** YOUR CODE HERE ***\"\n\n return self.values[(str(state), action)]",
"def getValue(self, state):\n return self.values[state]",
"def getQValu... | [
"0.80276626",
"0.7872588",
"0.76328826",
"0.75749767",
"0.75744814",
"0.7549472",
"0.7418124",
"0.73807997",
"0.73807997",
"0.73807997",
"0.73807997",
"0.73456675",
"0.7332363",
"0.73264176",
"0.73264176",
"0.73264176",
"0.73264176",
"0.73264176",
"0.73264176",
"0.73264176",
... | 0.795146 | 1 |
Return an np.array with the values of each action at the given state | def get_all_state_action_values(self, state):
return torch.tensor([[self.get_state_action_value(state, action) for action in range(self.action_space.n)]]).float() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_action_values(self, state, state_values):\n action_values = []\n\n for action in self.grid.actions:\n probs = self.grid.state_actions[state][action]\n state_action_values = self.get_state_values(state, state_values)\n action_values.append(sum([p * b for ... | [
"0.73736566",
"0.7121883",
"0.70356697",
"0.69397134",
"0.69185406",
"0.68723077",
"0.67115843",
"0.66186494",
"0.66168016",
"0.6564694",
"0.6518128",
"0.6488189",
"0.64872617",
"0.6472288",
"0.6432845",
"0.6415775",
"0.64135164",
"0.64100045",
"0.6406626",
"0.6401399",
"0.63... | 0.76700497 | 0 |
Return a probability distribution over actions | def get_behaviour_policy(self, state):
return self.behaviour_policy(state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probs(self, states, actions):\n # YOUR CODE HERE\n \n # So we need to determine for every input state-action pair, what the resulting policy distribution is\n # This means that the input will be a single state and a single action per index. \n # We then need to determine ... | [
"0.75595576",
"0.74884176",
"0.74101245",
"0.7358138",
"0.735802",
"0.7321238",
"0.7288396",
"0.71977127",
"0.71067834",
"0.7035673",
"0.6961088",
"0.6902661",
"0.6881273",
"0.68251896",
"0.68138194",
"0.67901003",
"0.6788828",
"0.67773473",
"0.67678297",
"0.6754605",
"0.6737... | 0.0 | -1 |
Return a probability distribution over actions | def get_target_policy(self, state):
values = self.get_all_state_action_values(state)
return self.target_policy(values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probs(self, states, actions):\n # YOUR CODE HERE\n \n # So we need to determine for every input state-action pair, what the resulting policy distribution is\n # This means that the input will be a single state and a single action per index. \n # We then need to determine ... | [
"0.75595576",
"0.74884176",
"0.74101245",
"0.7358138",
"0.735802",
"0.7321238",
"0.7288396",
"0.71977127",
"0.71067834",
"0.7035673",
"0.6961088",
"0.6902661",
"0.6881273",
"0.68251896",
"0.68138194",
"0.67901003",
"0.6788828",
"0.67773473",
"0.67678297",
"0.6754605",
"0.6737... | 0.0 | -1 |
policy A function which takes as input an np.array of stateaction values, and returns an np.array with the probability of choosing each action. | def set_target_policy(self, policy):
self.target_policy = policy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probs(self, states, actions):\n # YOUR CODE HERE\n \n # So we need to determine for every input state-action pair, what the resulting policy distribution is\n # This means that the input will be a single state and a single action per index. \n # We then need to determine ... | [
"0.7958761",
"0.7905963",
"0.78103715",
"0.75601214",
"0.7534915",
"0.7508957",
"0.7473572",
"0.74198973",
"0.7383157",
"0.73744595",
"0.7345856",
"0.72633076",
"0.7256324",
"0.7172822",
"0.71219146",
"0.7105038",
"0.7037665",
"0.7022215",
"0.70126814",
"0.69851494",
"0.69751... | 0.0 | -1 |
creates a new order | def create_order(cls, invoice):
order = cls(
order_id=str(uuid.uuid4().int),
invoice=invoice
).save()
invoice_line_items = InvoiceLineItem.objects.filter(invoice=invoice, type="item").all()
for invoice_line_item in invoice_line_items:
OrderLineItem.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_order():",
"def create(self):\n return self.account.create_order(self)",
"def create_po(self):\n pricelist_id = 1\n partner_id = self.ref('base.res_partner_1')\n order = self.order_obj.create({\n 'partner_id': partner_id,\n 'location_id': self.ref('s... | [
"0.8507318",
"0.8097274",
"0.7790511",
"0.76661175",
"0.75579274",
"0.75245583",
"0.751463",
"0.7479486",
"0.74185747",
"0.73480666",
"0.73155725",
"0.72908413",
"0.7222212",
"0.716758",
"0.70897084",
"0.70735556",
"0.7067838",
"0.70678043",
"0.70182955",
"0.7016862",
"0.7011... | 0.6829674 | 31 |
create one order line item | def create_order_line_item(cls, order, invoice_line_item):
order_line_item = cls(
order_line_item_id=str(uuid.uuid4().int),
order=order,
invoice_line_item=invoice_line_item,
product=invoice_line_item.product,
quantity=invoice_line_item.quantity
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_order():",
"def create(self, values):\n res = super(PurchaseOrderLine, self).create(values)\n states = ['purchase', 'done']\n if res.order_id.state in states:\n raise UserError(_('You can not create an additional purchase order line in a confirmed order '))\n ret... | [
"0.68382525",
"0.6682892",
"0.6548729",
"0.65128845",
"0.64668953",
"0.6373227",
"0.63635635",
"0.6360986",
"0.6316091",
"0.6273517",
"0.62665236",
"0.6239777",
"0.62015444",
"0.61846673",
"0.6161077",
"0.6147953",
"0.6127971",
"0.6125744",
"0.61254907",
"0.60938317",
"0.6074... | 0.7364095 | 0 |
Validates the presence of the CLEANUP_LABEL and its values in a list of labels, raises ValueError otherwise | def validate_cleanup_in(labels):
if CLEANUP_LABEL not in labels:
raise ValueError("Cleanup label (%s) missing in pod labels." % CLEANUP_LABEL)
if labels[CLEANUP_LABEL] not in CLEANUP_VALUES:
raise ValueError(
"Cleanup value %s not permitted. Use one of: %s"
% (labels[CLEA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sanity(self):\n # ensure numeric labels\n try:\n list(map(int, flatten(self.labels[:1])))\n except ValueError as ve:\n error(\"Non-numeric label encountered: {}\".format(ve))\n except TypeError as ve:\n warning(\"Non-collection labelitem encoun... | [
"0.6698342",
"0.66343915",
"0.63469636",
"0.6159356",
"0.6035514",
"0.59548664",
"0.5923593",
"0.5908667",
"0.5836684",
"0.58320177",
"0.58224463",
"0.5822256",
"0.5822256",
"0.58083415",
"0.5801615",
"0.57459205",
"0.5715245",
"0.5709651",
"0.56885856",
"0.56879073",
"0.5670... | 0.79507273 | 0 |
Returns a random port, exclusions possible via parameter set | def rand_port(except_ports=None):
if except_ports is None:
except_ports = []
max_port_int = 65535
if len(set(except_ports)) > max_port_int >= max(except_ports):
raise ValueError(
"Cannot generate randomPort when all possible port numbers are exempt"
)
# choose random ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createPort():\n\n starting_interval = 0\n ending_interval = 65535\n port = randint(starting_interval, ending_interval)\n return port",
"def generate_new_port(n):\n ports = sample(portsPool,n)\n for p in ports:\n ind = portsPool.index(p)\n del portsPool[ind]\n return ports",... | [
"0.67183334",
"0.662854",
"0.659142",
"0.6523813",
"0.64168155",
"0.64105636",
"0.639417",
"0.63269585",
"0.6282659",
"0.6281016",
"0.624315",
"0.61483",
"0.6047048",
"0.5981397",
"0.5919755",
"0.59116197",
"0.590874",
"0.58993083",
"0.5888901",
"0.58814454",
"0.58575827",
... | 0.77935 | 0 |
Create mock for LIVISI login. | def mocked_livisi_login():
return patch(
"homeassistant.components.livisi.config_flow.AioLivisi.async_set_token"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_start_new_verification(self):\r\n user = UserFactory.create(username=\"rusty\", password=\"test\")\r\n self.client.login(username=\"rusty\", password=\"test\")",
"def test_get_login(self):\n login = Login(self.client, 123)\n\n self.assertEqual(login.id, 123)\n self.ass... | [
"0.68408084",
"0.68017936",
"0.67128634",
"0.6615558",
"0.6606319",
"0.6568284",
"0.65361714",
"0.6485376",
"0.6467578",
"0.64658",
"0.6450552",
"0.6434976",
"0.6406752",
"0.6350427",
"0.6317787",
"0.63006455",
"0.62698996",
"0.62626636",
"0.6260469",
"0.6254094",
"0.62511486... | 0.7251048 | 0 |
Create mock data for LIVISI controller. | def mocked_livisi_controller():
return patch(
"homeassistant.components.livisi.config_flow.AioLivisi.async_get_controller",
return_value=DEVICE_CONFIG,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialization(self, create_controller: Controller) -> None:\n pass",
"def setUp(self):\n self.data = DatabaseIntermediary()",
"def setUp(self):\n self.client = APIClient()\n\n self.speciality = models.Speciality.objects.create(\n name='Speciality'\n )\n\n... | [
"0.60595906",
"0.5908655",
"0.588172",
"0.5871097",
"0.5850077",
"0.5814449",
"0.57985973",
"0.57669646",
"0.5741265",
"0.5737485",
"0.5698321",
"0.56932724",
"0.56909657",
"0.5662723",
"0.56569046",
"0.56569046",
"0.56569046",
"0.56569046",
"0.56569046",
"0.56569046",
"0.565... | 0.6246136 | 0 |
Create mock for LIVISI setup entry. | def mocked_livisi_setup_entry():
return patch(
"homeassistant.components.livisi.async_setup_entry",
return_value=True,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n util.create_mocks()",
"def setUp(self):\n util.create_mocks()",
"def setUp(self):\n util.create_mocks()",
"def setUp(self):\n util.create_mocks()",
"def setUp(self):\n util.create_mocks()",
"def setUp(self):\n util.create_mocks()",
"def setUp... | [
"0.64558464",
"0.64558464",
"0.64558464",
"0.64558464",
"0.64558464",
"0.64558464",
"0.6400841",
"0.6392369",
"0.6374439",
"0.63366705",
"0.63170975",
"0.6301264",
"0.62422764",
"0.62139213",
"0.6213025",
"0.6212005",
"0.6205747",
"0.6205747",
"0.619228",
"0.61879796",
"0.616... | 0.7041195 | 0 |
Calculates the frequency of a term in a document | def get_tf(term, document):
term_list = [term.lower() for term in document.split()]
num_of_words_in_doc = len(document.split())
term_count_in_doc = term_list.count(term)
return term_count_in_doc / num_of_words_in_doc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freq(word, document):\n return document.split(None).count(word)",
"def calc_tf(doc):\r\n tf = {}\r\n for term in doc:\r\n if term not in tf:\r\n tf[term] = doc.count(term)\r\n return tf",
"def tf(word, document):\n return freq(word,document) / wordCount(document)",
"def count... | [
"0.81235516",
"0.8119225",
"0.78225225",
"0.78039134",
"0.7691848",
"0.75778145",
"0.75127393",
"0.75036216",
"0.74620545",
"0.74298257",
"0.741511",
"0.7379881",
"0.7361048",
"0.7351847",
"0.7333118",
"0.7298452",
"0.72859204",
"0.72812396",
"0.7246361",
"0.721513",
"0.72033... | 0.77748466 | 4 |
Calculates the total number of documents divided by the number of documents containing the term (word) | def get_idf(term, documents):
number_of_docs = len(documents)
documents_containing_term = len([document for document in documents if term in document])
idf = math.log10(number_of_docs / documents_containing_term)
return round(idf, 5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordCount(document):\n return float(len(document.split(None)))",
"def freq(word, document):\n return document.split(None).count(word)",
"def get_tf(term, document):\n\n term_list = [term.lower() for term in document.split()]\n num_of_words_in_doc = len(document.split())\n term_count_in_doc = term_list... | [
"0.7654439",
"0.7642951",
"0.75426686",
"0.7214574",
"0.7174845",
"0.7131627",
"0.7107488",
"0.71056914",
"0.70912236",
"0.7086784",
"0.7061234",
"0.6973578",
"0.6961282",
"0.69611657",
"0.69438815",
"0.688162",
"0.6801989",
"0.67932147",
"0.6783313",
"0.6762959",
"0.6736627"... | 0.6505874 | 46 |
Multiplies the term frequency (tf) with the inverse document frequency (idf) to return the tfidf | def get_tf_idf(term, document, documents):
tf_idf = get_tf(term, document) * get_idf(term, documents)
return round(tf_idf, 5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tfidf(term_frequency: int, document_frequency: int, document_count: int) -> float:\n if term_frequency == 0:\n return 0\n else:\n tf = 1 + np.log(term_frequency)\n idf = np.log(document_count / document_frequency)\n return tf * idf",
"def calc_tf_idf... | [
"0.84478635",
"0.81231076",
"0.7729778",
"0.7700121",
"0.7696099",
"0.7685472",
"0.7620046",
"0.74928373",
"0.7489668",
"0.7485096",
"0.7441081",
"0.73898596",
"0.7385134",
"0.7357741",
"0.73311794",
"0.7319226",
"0.7296906",
"0.72713435",
"0.7238135",
"0.72304106",
"0.721231... | 0.8173197 | 1 |
Calculates the score of a term in a document based on its position. Terms that appear earlier in the document are score higher. | def get_positional_score(term, document):
score = 0
number_of_words_in_doc = len(document.split())
for position, word in enumerate(document.split()):
if word.lower() == term.lower():
score += (number_of_words_in_doc - position) / number_of_words_in_doc
return round(score, 5) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answer(document, search_terms):\n idx = {k: [] for k in search_terms}\n doc = document.split()\n [idx[term].append(i) for i, term in enumerate(doc, start=1) if term in search_terms]\n min_score = sys.maxint\n winning_slice = None\n for term in idx.keys(): # ignore duplicate terms\n fo... | [
"0.70714647",
"0.6810209",
"0.67525667",
"0.67525667",
"0.66404283",
"0.65762305",
"0.653853",
"0.6511128",
"0.6495046",
"0.64873844",
"0.63907325",
"0.6371521",
"0.6264078",
"0.6224283",
"0.6223177",
"0.61510754",
"0.6149143",
"0.6130282",
"0.6129364",
"0.61181056",
"0.61028... | 0.7993231 | 0 |
Given the API ID for a GEE layer on Resource Watch, this function will clear the layer cache. If the cache is not cleared, when you view the dataset on Resource Watch, old and new tiles will be mixed together. | def flushTileCache(layer_id):
# generate the API url for this layer's cache
apiUrl = 'http://api.resourcewatch.org/v1/layer/{}/expire-cache'.format(layer_id)
# create headers to send with the request to clear the cache
headers = {
'Content-Type': 'application/json',
'Authorization': os.getenv('a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flushTileCache(layer_id):\n # generate the API url for this layer's cache\n apiUrl = 'http://api.resourcewatch.org/v1/layer/{}/expire-cache'.format(layer_id)\n # create headers to send with the request to clear the cache\n headers = {\n 'Content-Type': 'application/json',\n 'Authorization': o... | [
"0.7679626",
"0.62814665",
"0.5842842",
"0.5833658",
"0.5833109",
"0.57534224",
"0.573081",
"0.570053",
"0.55585086",
"0.55561376",
"0.55560607",
"0.5550327",
"0.5518862",
"0.55163455",
"0.5510354",
"0.5497515",
"0.54739076",
"0.54729617",
"0.5465945",
"0.54627556",
"0.542982... | 0.7669758 | 1 |
All message activities towards the bot enter this function. | async def on_message_activity(self, turn_context: TurnContext):
TurnContext.remove_recipient_mention(turn_context.activity)
turn_context.activity.text = turn_context.activity.text.strip()
if not self.unlocked:
await turn_context.send_activity("De bot is gedeactiveerd en kan dus niet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def messages(self, ctx):\n\n\t\tawait self.message_leaderboard(ctx, \"messages\")",
"async def on_message_activity(self, turn_context: TurnContext):\n reply = MessageFactory.list([])\n # Get the state properties from the turn context.\n welcome_user_state = await self.user_state_access... | [
"0.67243636",
"0.648738",
"0.61207706",
"0.61096483",
"0.605643",
"0.5990261",
"0.5930036",
"0.5889592",
"0.5889592",
"0.5889592",
"0.5886627",
"0.58227986",
"0.58148575",
"0.58063346",
"0.57552063",
"0.569512",
"0.5689415",
"0.566552",
"0.56436557",
"0.56391877",
"0.56043863... | 0.7144678 | 0 |
FFT of v padded on the right with 2tau1 0s, used for multiplication below | def vfft(self):
# we could cache this, but so fast it isn't really necessary
# TODO: maybe it should be cached after all now that we don't need other stuff?
return rfft(self.v, 4*self.tau-3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ufft2(inarray):\n return ufftn(inarray, 2)",
"def fft1(x):\n assert x.size(-1) == 2\n x = ifftshift(x, dim=(-2,))\n x = torch.fft(x, 1, normalized=True)\n x = fftshift(x, dim=(-2,))\n return x",
"def convf(u, v, nf, dt):\n U = np.fft.fft(u, n=nf)\n V = np.fft.fft(v, n=nf)\n C = U... | [
"0.5909728",
"0.59049565",
"0.58655864",
"0.5834553",
"0.5826718",
"0.5802623",
"0.5723108",
"0.5679379",
"0.567855",
"0.5667368",
"0.56547946",
"0.5498447",
"0.54929113",
"0.5492728",
"0.5486339",
"0.54821134",
"0.5479368",
"0.54417783",
"0.543284",
"0.54169565",
"0.5405335"... | 0.6579955 | 0 |
Return new with lower or higher tau, trimming or padding with zeros as needed | def changetau(self, tau):
if tau == self.tau:
return self
elif tau < self.tau:
return AsymptoticTimeInvariant(self.v[self.tau - tau: tau + self.tau - 1])
else:
v = np.zeros(2*tau-1)
v[tau - self.tau: tau + self.tau - 1] = self.v
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shrink(X, tau):\n V = np.copy(X).reshape(X.size)\n for i in xrange(V.size):\n V[i] = math.copysign(max(abs(V[i]) - tau, 0), V[i])\n if V[i] == -0:\n V[i] = 0\n return V.reshape(X.shape)",
"def pad_shorter(a, b, ii=0):\n # global data_orig\n # global data_new\n diff ... | [
"0.6170798",
"0.56689346",
"0.560769",
"0.5552687",
"0.55477834",
"0.5516402",
"0.5436741",
"0.540298",
"0.53457826",
"0.533958",
"0.5335611",
"0.5302758",
"0.52767324",
"0.5217829",
"0.5213758",
"0.51950115",
"0.5166329",
"0.51507485",
"0.5133211",
"0.5113719",
"0.5113232",
... | 0.54448044 | 6 |
Get convenient slice of v, properly centered so 2 maps to entry v_(2), etc. | def __getitem__(self, i):
if isinstance(i, slice):
return self.v[slice(i.start+self.tau-1, i.stop+self.tau-1, i.step)]
else:
return self.v[i+self.tau-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def screw( v ):\n v = asarray(v)\n z = zeros_like(v[0,...])\n return array([\n [ z, -v[...,5], v[...,4], v[...,0] ],\n [ v[...,5], z,-v[...,3], v[...,1] ],\n [-v[...,4], v[...,3], z, v[...,2] ],\n [ z, z, z, z] ])",
"def __... | [
"0.61472094",
"0.5908876",
"0.5847893",
"0.58469534",
"0.57306516",
"0.5677182",
"0.5653847",
"0.5625661",
"0.5590378",
"0.55664724",
"0.55638695",
"0.5562008",
"0.5551617",
"0.5422652",
"0.54205483",
"0.54108125",
"0.53519386",
"0.53423834",
"0.5299802",
"0.52830124",
"0.528... | 0.50606567 | 45 |
If the vectors v and w represent the asymptotic diagonals of ATI matrices, their the product of the matrices is ATI, with asymptotic diagonals represented by vector x | def __matmul__(self, other):
if isinstance(other, AsymptoticTimeInvariant):
# make sure the two arguments have equal tau by enlarging the smaller
newself = self
if other.tau < self.tau:
other = other.changetau(self.tau)
elif other.tau > self.tau:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_dot(v, w):\n return np.dot(v, w)",
"def dot(v,w):\n return sum(v_i * w_i for v_i,w_i in zip(v,w))",
"def dot(v,w):\r\n return sum(v_i * w_i\r\n for v_i, w_i in zip(v, w))",
"def dot(v,w):\n return sum(v_i * w_i\n for v_i, w_i in zip(v,w))",
"def determinant(v,w... | [
"0.6268986",
"0.6259462",
"0.62223196",
"0.6191552",
"0.6171174",
"0.6153715",
"0.61317825",
"0.61108714",
"0.6099546",
"0.6084892",
"0.6084892",
"0.6084892",
"0.6084892",
"0.6084892",
"0.6082966",
"0.60363483",
"0.60275054",
"0.60023254",
"0.59915656",
"0.5932396",
"0.584686... | 0.0 | -1 |
Given a nested dict of ATI Jacobians that maps unknowns > targets, e.g. an asymptotic H_U matrix, get the inverse H_U^(1) as a nested dict. This is implemented by inverting the FFTbased multiplication that was implemented above | def invert_jacdict(jacdict, unknowns, targets, tau, test_invertible=False):
k = len(unknowns)
assert k == len(targets)
# stack the k^2 Jacobians relating unknowns to targets into an A matrix
A = jac.pack_asymptotic_jacobians(jacdict, unknowns, targets, tau)
if test_invertible:
# use windi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invert(data_dict, keys = 'all'):\n if keys.lower() == 'all':\n to_fix_keys = set(data_dict.keys()) - set({'time'})\n \n else:\n to_fix_keys = np.array([keys]).flatten()\n \n out = data_dict.copy()\n tmp = dict()\n \n for key in to_fix_keys:\n tmp.update({key... | [
"0.58155334",
"0.5399745",
"0.5310238",
"0.53086656",
"0.5305253",
"0.5250937",
"0.5212625",
"0.5209139",
"0.51955724",
"0.5156739",
"0.5155153",
"0.515414",
"0.51440793",
"0.51347655",
"0.50888896",
"0.50720143",
"0.506503",
"0.50603753",
"0.50432646",
"0.50033295",
"0.50025... | 0.6764515 | 0 |
A context manager yielding a database session. | def db_session_ctx(Session):
session = Session()
try:
yield session
session.commit()
except:
session.rollback()
raise
finally:
session.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_session() -> Generator:\n _session = session()\n try:\n yield _session\n finally:\n _session.close()",
"def db_session_context(db_name):\n try:\n db = psycopg2.connect(database=db_name)\n yield db\n finally:\n db.close()",
"def db_session():\n engine ... | [
"0.84718585",
"0.8074009",
"0.8037839",
"0.79979485",
"0.7983582",
"0.79507846",
"0.7949184",
"0.79094654",
"0.78912413",
"0.7855268",
"0.78155154",
"0.778266",
"0.7614033",
"0.7607433",
"0.7593117",
"0.7573233",
"0.75403404",
"0.7413446",
"0.74086285",
"0.7384218",
"0.737463... | 0.7547423 | 16 |
Checks that the version of the Solr core ``core`` matches the one in the schema. | def solr_version_check(core):
expected_version = SCHEMA[core].version
solr_uri = config.CFG.get("solr", "uri")
u = urllib2.urlopen("%s/%s/schema/version" % (solr_uri, core))
content = loads(u.read())
seen_version = content["version"]
if not seen_version == expected_version:
raise Version... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_solr_cores_version(cores):\n map(solr_version_check, cores)",
"def test_compare_schemas_major(self):\n status = schema_utils.compare_schemas(\n self.base_schema,\n self.major_removed_value\n )\n\n assert status == schema_utils.Update.major",
"def test_sch... | [
"0.6779413",
"0.5996153",
"0.5828003",
"0.57171905",
"0.57140726",
"0.56064177",
"0.55985236",
"0.55739886",
"0.5499899",
"0.54828817",
"0.5461677",
"0.5393078",
"0.53798366",
"0.53707933",
"0.5345438",
"0.5344237",
"0.5337947",
"0.5317535",
"0.5295003",
"0.5281345",
"0.52062... | 0.8537369 | 0 |
Checks multiple Solr cores for version compatibility | def check_solr_cores_version(cores):
map(solr_version_check, cores) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solr_version_check(core):\n expected_version = SCHEMA[core].version\n solr_uri = config.CFG.get(\"solr\", \"uri\")\n u = urllib2.urlopen(\"%s/%s/schema/version\" % (solr_uri, core))\n content = loads(u.read())\n seen_version = content[\"version\"]\n if not seen_version == expected_version:\n ... | [
"0.6550377",
"0.5824256",
"0.57431936",
"0.5562315",
"0.55221343",
"0.5507001",
"0.5468929",
"0.5466075",
"0.54544914",
"0.5420395",
"0.54134506",
"0.5408198",
"0.53689283",
"0.5358959",
"0.5356279",
"0.5342606",
"0.5332946",
"0.5316136",
"0.52860075",
"0.5266541",
"0.5238733... | 0.8674924 | 0 |
Creates a connection to an AMQP server. | def create_amqp_connection():
# type: () -> amqp.Connection
cget = partial(config.CFG.get, "rabbitmq")
return amqp.Connection(
host=cget("host"),
userid=cget("user"),
password=cget("password"),
virtual_host=cget("vhost"),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_connection(self):\n if self.conn:\n raise Exception(\"Connection already open\")\n cfg = self.config[self.MODULE_NAME]['amqp']['connection']\n log.debug(str(cfg))\n self.conn = pika.AsyncoreConnection(pika.ConnectionParameters(\n credentials = pika.PlainCredentials(cfg['login']... | [
"0.7788483",
"0.77012485",
"0.7328935",
"0.69165313",
"0.6882219",
"0.66203946",
"0.6586621",
"0.6561489",
"0.6474302",
"0.64725894",
"0.64424944",
"0.6413152",
"0.6287743",
"0.61842525",
"0.6181223",
"0.6165761",
"0.61318046",
"0.61280894",
"0.60530525",
"0.6042496",
"0.6028... | 0.8125475 | 0 |
Used to start a new timer with given delay. | def start(self, delay=None):
if self._timer:
raise Exception('Timer already exists. Use restart instead.')
if not delay:
delay = self.delay
self._timer = Timer(delay, self.callback)
# Starting the call in daemon mode so that it exits when the parent
# ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart(self, delay=None):\n if self._timer:\n self._timer.cancel()\n if not delay:\n delay = self.delay\n self._timer = Timer(delay, self.callback)\n self._timer.daemon = True\n self._timer.start()",
"def schedule(self, sleep_time, delay):\n se... | [
"0.6963895",
"0.68689024",
"0.6696189",
"0.6620824",
"0.6589489",
"0.65471387",
"0.6501219",
"0.6496462",
"0.6325117",
"0.6295213",
"0.6292513",
"0.6286179",
"0.62726414",
"0.6266713",
"0.62522584",
"0.6246776",
"0.6226407",
"0.6194945",
"0.61825365",
"0.60937047",
"0.6007753... | 0.7768124 | 0 |
Used to cancel an already running timer. | def cancel(self):
if self._timer:
self._timer.cancel()
self._timer = None
else:
raise Exception('Cannot cancel timer. No timer started.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _async_cancel_timer(self) -> None:\n if self._timer:\n self._timer.cancel()\n self._timer = None",
"def _cancel(self):\n self.waiter.set_result_if_pending(None)\n \n timer = self.timer\n if (timer is not None):\n self.timer = None\n ... | [
"0.8081997",
"0.799912",
"0.78773856",
"0.78552437",
"0.7820463",
"0.7676346",
"0.759786",
"0.7569698",
"0.7459538",
"0.74300826",
"0.7420995",
"0.7330113",
"0.7265205",
"0.72101563",
"0.7163342",
"0.7074851",
"0.70103073",
"0.6979206",
"0.6962197",
"0.6945083",
"0.6945083",
... | 0.8618206 | 0 |
Used to restart the timer and schedule a call after ``delay`` seconds. It will cancel any existing scheduled calls. If there are no existing timers scheduled it just starts a new timer. | def restart(self, delay=None):
if self._timer:
self._timer.cancel()
if not delay:
delay = self.delay
self._timer = Timer(delay, self.callback)
self._timer.daemon = True
self._timer.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self, delay=None):\n if self._timer:\n raise Exception('Timer already exists. Use restart instead.')\n\n if not delay:\n delay = self.delay\n\n self._timer = Timer(delay, self.callback)\n # Starting the call in daemon mode so that it exits when the parent... | [
"0.7109396",
"0.63238716",
"0.6171984",
"0.6101533",
"0.60576695",
"0.60144913",
"0.5958865",
"0.59566396",
"0.5858446",
"0.5857999",
"0.58413327",
"0.579634",
"0.56573534",
"0.5615492",
"0.55685216",
"0.55625427",
"0.55562544",
"0.5488137",
"0.5480548",
"0.5475354",
"0.54637... | 0.78188497 | 0 |
Change the current working directory to path | def ChangeDir(self, path: str) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_to_current_path(to_change_path):\n os.chdir(to_change_path)",
"def set_working_dir(path):\n full_path = os.path.abspath(os.path.expanduser(path))\n full_cwd = os.path.abspath(os.getcwd())\n if full_cwd != full_path:\n os.chdir(full_path)\n LOGGER.info('Changed current working... | [
"0.79257363",
"0.7811151",
"0.7559222",
"0.7551275",
"0.74620426",
"0.7388414",
"0.7362139",
"0.7349592",
"0.72936445",
"0.72502595",
"0.7201327",
"0.7131689",
"0.7103491",
"0.7092049",
"0.70705867",
"0.7037025",
"0.7014682",
"0.7013658",
"0.70134413",
"0.7000364",
"0.6970323... | 0.6645798 | 39 |
Return True if path exists | def Exists(self, path: str) -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists(self, path):",
"def exists(path: str) -> bool:\n pass",
"def path_exists(path):\r\n return os.path.exists(path)",
"def path_exists(self, path):\n try:\n os.stat(path)\n except OSError:\n return False\n return True",
"def file_exists(cls, path: Path)... | [
"0.8757863",
"0.87178504",
"0.8693969",
"0.8656877",
"0.86241084",
"0.86228925",
"0.8573195",
"0.8506621",
"0.8483986",
"0.8331406",
"0.8308598",
"0.82679445",
"0.8235729",
"0.8215931",
"0.8203297",
"0.81965387",
"0.8185852",
"0.8148072",
"0.8068592",
"0.80582017",
"0.8027614... | 0.88555646 | 0 |
Get the current path. Returns the current working directory (string) | def GetCurrentDir(self) -> str:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_directory():\n\treturn os.path.dirname(os.path.abspath(__file__))",
"def curdir(self):\n return self.var('getcwd()')",
"def get_cwd():\n return os.getcwd()",
"def get_working_directory():\n return os.getcwd()",
"def get_cwd():\n source_folder = os.getcwd()\n print(f'Curre... | [
"0.8435016",
"0.83408767",
"0.80879617",
"0.79797804",
"0.7972486",
"0.78806317",
"0.7818159",
"0.76701945",
"0.76598716",
"0.7544482",
"0.7529405",
"0.7498192",
"0.7475639",
"0.74753124",
"0.7466708",
"0.74665123",
"0.74010926",
"0.7363813",
"0.7304359",
"0.72918624",
"0.725... | 0.8061774 | 3 |
Make a new directory | def MakeDir(self, path: str) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_new_dir(path):\n\n if(not(os.path.isdir(path))):\n os.makedirs(path)\n\n return path",
"def makenewdir(newdir):\n \n try:\n os.makedirs(newdir)\n except OSError as e:\n if e.errno == 17:\n pass",
"def makenewdir(newdir):\n \n try:\n os.makedi... | [
"0.81844604",
"0.79172635",
"0.79172635",
"0.7891109",
"0.7888124",
"0.78564936",
"0.78549814",
"0.7852561",
"0.7847847",
"0.78464586",
"0.7844591",
"0.7844591",
"0.7794873",
"0.77578926",
"0.77468973",
"0.77453995",
"0.7706092",
"0.7691387",
"0.76074654",
"0.7594992",
"0.754... | 0.7709774 | 16 |
Rename a file from oldname to newname | def RenameFile(self, oldname: str, newname: str) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename(oldname, newname):",
"def rename_file(path, old_name, new_name):\n \n old_file = os.path.join(path, old_name)\n new_file = os.path.join(path, new_name)\n os.rename(old_file, new_file)",
"def rename(old, new):",
"def rename(old, new):",
"def rename_file (self):\n\t\tassert self.__file... | [
"0.8632374",
"0.84979236",
"0.8134407",
"0.8134407",
"0.80457723",
"0.7937986",
"0.792142",
"0.79126793",
"0.7826042",
"0.77334446",
"0.7610196",
"0.7591717",
"0.7557788",
"0.74950385",
"0.7452874",
"0.74074626",
"0.7406878",
"0.74068093",
"0.73771876",
"0.73677063",
"0.73240... | 0.9007254 | 0 |
Close an already opened file | def close(self) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_file(file):\n file.close()",
"def close_file(self):\r\n self.file.close()",
"def close_file(self):\n self.file.close()",
"def close_file(self):\n self.file.close()",
"def close(cls, file):\n file.close()",
"def _close(self):\n self.fh.close()",
"def close... | [
"0.81228495",
"0.78630376",
"0.78180325",
"0.78180325",
"0.7534868",
"0.7294435",
"0.72890824",
"0.7279854",
"0.72701734",
"0.7246864",
"0.722133",
"0.72084385",
"0.72084385",
"0.7186383",
"0.7181799",
"0.717374",
"0.717374",
"0.71668684",
"0.7151654",
"0.7151654",
"0.7142861... | 0.0 | -1 |
Read data from opened file | def read(self, size: int=-1) -> bytes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file():\n with open(FILE_NAME) as f:\n data = f.read()\n return data",
"def read(self, filename):\n pass",
"def read(self, filename):\n pass",
"def read_file(self, file):\n fd = open(file)\n data = fd.read()\n fd.close()\n return data",
"def r... | [
"0.74074805",
"0.7403446",
"0.7403446",
"0.73950624",
"0.725301",
"0.7251015",
"0.7235692",
"0.7105142",
"0.7072572",
"0.6985528",
"0.69563675",
"0.6918249",
"0.68952876",
"0.6879385",
"0.6865713",
"0.68526906",
"0.68487036",
"0.68400925",
"0.6830129",
"0.6809019",
"0.6794193... | 0.0 | -1 |
Read from opened file until newline or EOF occurs Returns data (bytes) | def readline(self) -> bytes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _readuntil(f, end=_TYPE_END):\n\tbuf = bytearray()\n\twhile True:\n\t\tbyte = f.read(1)\n\t\tif byte != end:\n\t\t\tbuf += byte\n\t\telse:\n\t\t\tbreak\n\treturn buf",
"def _read_until(self, c, chunk_size=96):\n s = io.BytesIO()\n fp = self._fp\n eof = False\n\n while True:\n ... | [
"0.6803695",
"0.654814",
"0.64560264",
"0.6439167",
"0.6427806",
"0.6427282",
"0.64232296",
"0.6373272",
"0.63722265",
"0.6344037",
"0.6308766",
"0.62977207",
"0.62821496",
"0.6201",
"0.61884266",
"0.6181169",
"0.6168779",
"0.61232746",
"0.61201227",
"0.6102346",
"0.61004347"... | 0.0 | -1 |
Returns the current cursor position Returns the current cursor position (int) | def tell(self) -> int:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cursor_pos(self):\n return self._cursor_pos",
"def _get_cursor_index_position(self) :\n return self._cursor_index_position",
"def get_cursor_pos(self):\n return (self.text_maker.pos[0] + 9, self.text_maker.pos[1] + 120 + 8)",
"def get_position():\n return win32api.GetCursorPos()",... | [
"0.86118525",
"0.8154433",
"0.80559796",
"0.78607714",
"0.74570525",
"0.74201083",
"0.73744303",
"0.737426",
"0.7334808",
"0.73254037",
"0.7270254",
"0.7270254",
"0.7270254",
"0.72682846",
"0.7259172",
"0.7259172",
"0.72527707",
"0.72268814",
"0.71493983",
"0.71493983",
"0.71... | 0.0 | -1 |
Write string or bytes to file | def write(self, data: Union[str, bytes]) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(file, string, codec='utf8'):\n if isinstance(string, str):\n file.write(string)\n elif isinstance(string, unicode):\n file.write(string.encode(codec))",
"def write_file(filename, string):\n import sys\n #ugly fix, hopefully we can find a better one\n if sys.version_info[0] ... | [
"0.75504446",
"0.7326269",
"0.73217624",
"0.72515404",
"0.71031237",
"0.7054103",
"0.70479435",
"0.70056266",
"0.69976777",
"0.6991522",
"0.69794124",
"0.69662696",
"0.69615513",
"0.69577014",
"0.6878844",
"0.6875704",
"0.6846947",
"0.6843987",
"0.6836143",
"0.6828241",
"0.68... | 0.7581854 | 0 |
Write iterable object such as a list of strings | def writelines(self, seq: list[str]) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stringify(iterable: Iterable, joinable: str = \"\\n\") -> str:\n return joinable.join(json.dumps(doc, default=json_util.default) for doc in iterable)",
"def __str__(self):\n return repr(self._iter)",
"def get_itr_str(iterable) -> str:\n\treturn str([str(i) for i in iterable])",
"def to(items, ... | [
"0.681082",
"0.67611057",
"0.6756745",
"0.6570508",
"0.65175813",
"0.6434539",
"0.6405177",
"0.6303219",
"0.62867403",
"0.6266485",
"0.62429994",
"0.62309164",
"0.6226173",
"0.62162364",
"0.62162167",
"0.6211152",
"0.61935943",
"0.6166531",
"0.61479837",
"0.61408585",
"0.6125... | 0.5764969 | 55 |
V.ExtendGraph(vtkMutableGraphHelper, vtkGraph) > int | def ExtendGraph(self, vtkMutableGraphHelper, vtkGraph):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend_labeled_graph(graph):\n la = community.best_partition(graph)\n nx.set_node_attributes(graph, la, 'community')\n nodes = graph.nodes(data=True)\n # nx.write_graphml(graph,'./data_2/clean_data/comm_graph.graphml')\n\n a = list(set(list(la.values())))\n temp = {}\n for comm in a:\n ... | [
"0.60209775",
"0.5857831",
"0.574126",
"0.5714577",
"0.5583012",
"0.5544032",
"0.54564947",
"0.54549074",
"0.544287",
"0.5436056",
"0.5405247",
"0.53960377",
"0.5376054",
"0.5341909",
"0.5317724",
"0.52974075",
"0.5286928",
"0.52845",
"0.52735144",
"0.5271774",
"0.5251576",
... | 0.880304 | 0 |
Create and return a new object. See help(type) for accurate signature. | def __new__(*args, **kwargs):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_object():\n return object()",
"def create(cls, _):\n return cls",
"def __newobj__(cls, *args):\n return cls.__new__(cls, *args)",
"def create(cls):\n pass\n return cls()",
"def __new__(cls):\n return object.__new__(cls)",
"def __new__(cls):\n return objec... | [
"0.75212413",
"0.74254465",
"0.7227017",
"0.7224189",
"0.7096888",
"0.7096888",
"0.7059055",
"0.70071834",
"0.69155335",
"0.68690395",
"0.6814675",
"0.6812803",
"0.6802038",
"0.66921675",
"0.6628809",
"0.6586155",
"0.6570953",
"0.6558287",
"0.6547422",
"0.65455115",
"0.654116... | 0.0 | -1 |
Implement setattr(self, name, value). | def __setattr__(self, *args, **kwargs):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setattr__(self, name, value):\n self.set(**{name: value})",
"def set_attr(self, name, value):\n setattr(self, name, value)",
"def __setattr__(self, name, value):\n if not hasattr(self, name):\n raise AttributeError(\"'%s' object has no attribute '%s'\" % (type(self).__name... | [
"0.868889",
"0.8361373",
"0.8290292",
"0.8283524",
"0.82243794",
"0.8204499",
"0.8099823",
"0.8099823",
"0.8071226",
"0.80402154",
"0.8024459",
"0.79978293",
"0.79883593",
"0.7987577",
"0.79493016",
"0.7936443",
"0.79316676",
"0.7890851",
"0.78896946",
"0.78018266",
"0.775468... | 0.0 | -1 |
Checks if the position is valid for the specified ship. | def can_add(self, btype, cell: Vector2, direction):
if not 0 <= cell.x < 10:
return False
if not 0 <= cell.y < 10:
return False
length = self.BOAT_LENGTHS[btype]
if direction in (self.F_EAST, self.F_WEST):
if cell.x + length > 10:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_ship(cls, ship_type, star_square, orientation):\n try:\n cls.validate_square(star_square)\n cls.validate_type(ship_type)\n cls.check_if_fit_in_grid(ship_type, star_square, orientation)\n except ValueError as e:\n raise ValueError('%s for %s at ... | [
"0.7653618",
"0.72050446",
"0.719211",
"0.7019702",
"0.6905886",
"0.6902876",
"0.68900186",
"0.6881666",
"0.68437445",
"0.6705292",
"0.66771096",
"0.667356",
"0.6618794",
"0.6602629",
"0.6591905",
"0.6572531",
"0.6504027",
"0.64742774",
"0.64548707",
"0.6448811",
"0.6420885",... | 0.0 | -1 |
return a set of tuples representing a reachable province and the path taken to get there for a given unit | def reachable_province(self, ctx):
return self.reachable_tiles(ctx) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible(self):\n return [tuple(path) for path in nx.all_shortest_paths(self._gpm.Graph, source=self.source, target=self.target)]",
"def all_DU_paths(CG, T):\n path_to_visit = []\n path_not_visited = []\n for var in CG.var:\n vert_var_in_defv=set()\n vert_var_in_refv=set()\n ... | [
"0.5669924",
"0.55684626",
"0.55611545",
"0.5506771",
"0.53537774",
"0.52936685",
"0.5282749",
"0.521364",
"0.520592",
"0.5202676",
"0.5176759",
"0.51723063",
"0.5166985",
"0.5161609",
"0.5159562",
"0.5154347",
"0.514914",
"0.514904",
"0.51467544",
"0.51268536",
"0.5124956",
... | 0.63907313 | 0 |
Loads the DNA sequence string at the address | def get_sequence(address):
ref = ''
with open(address,'rU') as ref_file:
next(ref_file) # skip header lines
for line in ref_file:
ref = ref + line.strip()
return ref | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_sequence(sequence_id, database='uniprot'):\n if sequence_id.startswith('UPI'):\n database = 'uniparc'\n url_template = 'http://www.uniprot.org/uniparc/{}.fasta'\n elif sequence_id.startswith('UniRef'):\n database = 'uniref'\n url_template = 'http://www.uniprot.org/uniref... | [
"0.57280564",
"0.56917346",
"0.5657723",
"0.5638905",
"0.56204945",
"0.5606745",
"0.56067204",
"0.551535",
"0.54936063",
"0.544783",
"0.5424682",
"0.53981584",
"0.5347417",
"0.5342145",
"0.53326404",
"0.53095555",
"0.530096",
"0.52704895",
"0.52681744",
"0.52631825",
"0.52602... | 0.6768632 | 0 |
Returns whether the count of reads at this locus looks like a SNP (41, 0, 0, 1) > False (0, 80, 1, 23) > True | def is_SNP(count):
counts = sum(count)
return counts and float(counts - max(count)) / counts > MAX_NOISE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tie_exists(self):\n return len(self.marks) == 9",
"def __call__(self, read, info: ModificationInfo):\n n_count = read.sequence.lower().count('n')\n if self.is_proportion:\n if len(read) == 0:\n return False\n return n_count / len(read) > self.cutoff\n... | [
"0.5871824",
"0.5798836",
"0.573859",
"0.5658492",
"0.5638939",
"0.55822027",
"0.55680424",
"0.55127084",
"0.55089444",
"0.5468778",
"0.546799",
"0.5460876",
"0.5456441",
"0.5437954",
"0.5425922",
"0.54156435",
"0.53983366",
"0.53702885",
"0.536321",
"0.5278724",
"0.52495486"... | 0.5779371 | 2 |
Currently implements Hamming distance but anything can be used | def distance(str1, str2):
return sum(c1 != c2 for c1, c2 in izip(str1, str2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hamming_distance(a, b):\n return np.count_nonzero(a != b)",
"def hamming_distance(x1: np.ndarray, x2: np.ndarray) -> int:\n assert isinstance(x1, np.ndarray) and isinstance(x2, np.ndarray)\n return (x1 != x2).sum()",
"def hamming_distance(s1, s2):\n assert(len(s1) == len(s2))\n return np.sum... | [
"0.76021296",
"0.75663364",
"0.75241053",
"0.7502226",
"0.7478643",
"0.74620634",
"0.73741263",
"0.73475194",
"0.7327267",
"0.7313422",
"0.7300163",
"0.7280397",
"0.72346234",
"0.7184089",
"0.71594864",
"0.71217275",
"0.71196294",
"0.71161664",
"0.7086809",
"0.70775294",
"0.7... | 0.0 | -1 |
Returns a list of the same length as distances where each element is probability that the read came from locus corresponding to that distance such that sum(list) = 1 Currently adds 1 to each distance, takes the inverse then normalizes vector | def probability(distances):
v = [1.0/(d + 1) for d in distances]
s = sum(v)
return [i/s for i in v] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(p,L): \r\n Norm = []\r\n for k in L:\r\n x = k - p\r\n norm = x.dot(x)**0.5\r\n if norm != 0:\r\n Norm.append(x/norm)\r\n else:\r\n print('warning: attempt to normalize 0')\r\n \r\n return Norm",
"def normalize(dist):\n return... | [
"0.6440643",
"0.6266799",
"0.609463",
"0.6016089",
"0.6015959",
"0.5988844",
"0.59724295",
"0.5963558",
"0.5931813",
"0.58614933",
"0.58591545",
"0.5857181",
"0.58184135",
"0.57240236",
"0.5697465",
"0.56647426",
"0.56549835",
"0.5632636",
"0.56282187",
"0.56282187",
"0.56162... | 0.68233 | 0 |
Return [P(A), P(C), P(G), P(T)] from the weighted reads | def distribution(bases, weights):
dist = [0, 0, 0, 0]
for base, weight in zip(bases, weights):
dist[BASES[base]] += weight
return dist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weights(cae, p):\n weights = []\n for i, j in pairwise(p):\n closed_open = len([e for e in cae if i <= e < j])\n weights.append(closed_open)\n return [value % 2 for value in weights]",
"def weights(self) -> List[float]:",
"d... | [
"0.6251709",
"0.57383025",
"0.56798667",
"0.5671376",
"0.56415194",
"0.55886143",
"0.5530866",
"0.5485737",
"0.5403283",
"0.5374044",
"0.53604966",
"0.53390896",
"0.5338203",
"0.5338203",
"0.5298174",
"0.5295084",
"0.5292437",
"0.5279747",
"0.52525043",
"0.52502537",
"0.52500... | 0.510105 | 45 |
Return a humanized string representation of a number of bytes. | def humanize_bytes(bytes, precision=1):
abbrevs = (
(1<<50L, 'PB'),
(1<<40L, 'TB'),
(1<<30L, 'GB'),
(1<<20L, 'MB'),
(1<<10L, 'kB'),
(1, 'bytes')
)
if bytes == 1:
return '1 byte'
for factor, suffix in abbrevs:
if bytes >= factor:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def human_bytes(n):\n if n < 1024:\n return '%d B' % n\n k = n/1024\n if k < 1024:\n return '%d KB' % round(k)\n m = k/1024\n if m < 1024:\n return '%.1f MB' % m\n g = m/1024\n return '%.2f GB' % g",
"def pretty_bytes(num: int) -> str:\n\n # Reject weird stuff\n tr... | [
"0.77269095",
"0.735353",
"0.73413354",
"0.7115547",
"0.71124417",
"0.7084452",
"0.695902",
"0.69254166",
"0.6898372",
"0.6874227",
"0.6845143",
"0.6827928",
"0.6794702",
"0.67726815",
"0.674324",
"0.6742227",
"0.66720736",
"0.6666954",
"0.66527635",
"0.66207796",
"0.6612311"... | 0.6907244 | 8 |
Constructs a Koch snowflake of at a given level | def drawFractalLine(t , distance , angle , level):
if level == 0:
t.setheading(angle)
t.forward(distance)
else:
drawFractalLine(t , distance/3 , angle , level - 1)
drawFractalLine(t , distance/3 , angle - 60 , level - 1)
drawFractalLine(t , distance/3 , angle +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, player):\n self._piece_type = 'knight'\n self._value = 6 if player == \"white\" else -6\n self._summary = 'W-Kt' if player == \"white\" else 'B-Kt'\n\n self._directions = []\n self._directions.append([(-2, -1)])\n self._directions.append([(-2, 1)])\n ... | [
"0.57684547",
"0.57310194",
"0.5729686",
"0.56385803",
"0.562059",
"0.555197",
"0.5506468",
"0.5499345",
"0.5406252",
"0.5355393",
"0.53018767",
"0.51964754",
"0.5063726",
"0.502936",
"0.5026911",
"0.50179434",
"0.5008726",
"0.4990818",
"0.49745867",
"0.4973746",
"0.49726737"... | 0.0 | -1 |
Creates and configures a check. Specialized objects representing resources, contexts, | def __init__(self, *objects):
self.resources = []
self.contexts = Contexts()
self.summary = Summary()
self.results = Results()
self.perfdata = []
self.name = ''
self.add(*objects) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_checkers(config):\n\n checkers = []\n if 'checkers' in config:\n for checker_name, checker_config in config['checkers'].iteritems():\n if checker_name in __checkers:\n configs = None\n if type(checker_config) == list:\n configs = c... | [
"0.573528",
"0.57158685",
"0.56430507",
"0.56092507",
"0.5593103",
"0.5576564",
"0.54734015",
"0.54684705",
"0.5460936",
"0.53804684",
"0.5364249",
"0.5355427",
"0.535259",
"0.5351944",
"0.53518295",
"0.5308847",
"0.53042376",
"0.5294851",
"0.52670014",
"0.5261421",
"0.525708... | 0.0 | -1 |
Adds domain objects to a check. | def add(self, *objects):
for obj in objects:
if isinstance(obj, Resource):
self.resources.append(obj)
if self.name == '':
self.name = self.resources[0].name
elif isinstance(obj, Context):
self.contexts.add(obj)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rule_objects ( self, rules ):\n pool = self.get_pool()\n # pool validates the rules' type\n for deprule in rules:\n pool.add ( deprule )\n return True",
"def _add_objects(self, object_list):\n\n object_types = set([t for _, t in object_list])\n if not object_type... | [
"0.634248",
"0.57259125",
"0.5718259",
"0.558317",
"0.5513544",
"0.55104226",
"0.54753804",
"0.54431826",
"0.53778946",
"0.5360804",
"0.5308531",
"0.52934825",
"0.5285274",
"0.5268482",
"0.51222855",
"0.5085067",
"0.50568503",
"0.50452095",
"0.5043744",
"0.50222576",
"0.49848... | 0.552463 | 4 |
Actually run the check. | def __call__(self):
for resource in self.resources:
self._evaluate_resource(resource)
self.perfdata = sorted([p for p in self.perfdata if p]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_and_check(self, *args, **kwargs) -> None:\n raise NotImplementedError",
"def start_check(self):\n pass",
"def run_command_check(self):\n pass",
"def run(self) -> None:\n self._does_apply = self.run_precondition()\n if not self._does_apply:\n self._check_r... | [
"0.78063136",
"0.7458518",
"0.73880637",
"0.72206384",
"0.70450824",
"0.7018149",
"0.6975723",
"0.69078135",
"0.68749475",
"0.6787489",
"0.6782267",
"0.6767137",
"0.67604446",
"0.67554766",
"0.67437744",
"0.6673308",
"0.66723305",
"0.66723305",
"0.66723305",
"0.66723305",
"0.... | 0.0 | -1 |
Allinone control delegation to the runtime environment. | def main(self, verbose=1, timeout=10):
runtime = Runtime()
runtime.execute(self, verbose, timeout) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_control(self):\n pass",
"def control():\n pass",
"def takeControl(self):\n mainloop()",
"def takeControl(self):\n mainloop()",
"def _run_env(self):\n raise NotImplementedError()",
"def __init__(self):\n super().__init__(interface.RemoteControl, DEFAULT_PRIORITIE... | [
"0.63256335",
"0.6320587",
"0.6107806",
"0.6107806",
"0.60794914",
"0.593996",
"0.593898",
"0.59318",
"0.59317994",
"0.5888752",
"0.58849436",
"0.5775705",
"0.57626367",
"0.5752265",
"0.573941",
"0.57339185",
"0.57339185",
"0.57248133",
"0.571832",
"0.5716955",
"0.5712277",
... | 0.0 | -1 |
Status line summary string. The first line of output that summarizes that situation as perceived by the check. The string is usually queried from a | def summary_str(self):
if not self.results:
return self.summary.empty() or ''
elif self.state == Ok:
return self.summary.ok(self.results) or ''
return self.summary.problem(self.results) or '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary(self):\n res = \", \".join(\n elem[\"summary\"] for elem in self.status[\"health\"][\"summary\"]\n )\n if res:\n return res\n elif self.detail:\n return self.detail[0]\n return \"\"",
"def get_status_line(self):\n return f'{st... | [
"0.7153659",
"0.7112404",
"0.7081728",
"0.69086766",
"0.69086766",
"0.67329484",
"0.669303",
"0.6665745",
"0.65905195",
"0.65501297",
"0.653058",
"0.6519172",
"0.6519172",
"0.6499029",
"0.64726174",
"0.63946587",
"0.6387232",
"0.63831663",
"0.6374549",
"0.63729835",
"0.636178... | 0.69025874 | 5 |
Additional lines of output. Long text output if check runs in verbose mode. Also queried | def verbose_str(self):
return self.summary.verbose(self.results) or '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verbose(self,text):\n if self.verbose:\n print(text)",
"def test_get_results_verbose(self):\n\t\tpass",
"def cmdPrint( self, *args):\n return self.cmd( *args, **{ 'verbose': True } )",
"def test_print_result(capsys):\n assert \"\"\"Total 5 hands solved\nTotal 4 hands solved w... | [
"0.6355862",
"0.6139787",
"0.61266494",
"0.61042213",
"0.608574",
"0.5961534",
"0.5899671",
"0.58981997",
"0.58808124",
"0.58677584",
"0.58553314",
"0.58420485",
"0.5824406",
"0.57913786",
"0.57524794",
"0.5742364",
"0.5728968",
"0.5700207",
"0.5699062",
"0.56920356",
"0.5691... | 0.5606257 | 31 |
Overall check exit code according to the Nagios API. | def exitcode(self):
try:
return int(self.results.most_significant_state)
except ValueError:
return 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_exit_code(self) -> int:",
"def check_exit_code(results):\n assert results[\"metrics\"][\"Exit code\"] == 0",
"def get_exit_code(self):",
"def test_check_exit_status(self):\n run_dir_success = 'data/nanopore_data/run4/done_demuxing/20200104_1412_MN19414_AAU644_68125dc2'\n succes... | [
"0.754436",
"0.72537285",
"0.70965946",
"0.6767254",
"0.63506246",
"0.624385",
"0.6144521",
"0.6139127",
"0.60949147",
"0.6094326",
"0.60873634",
"0.6065243",
"0.60579044",
"0.60116583",
"0.5979975",
"0.5958287",
"0.5949102",
"0.5946809",
"0.593075",
"0.5929302",
"0.5909324",... | 0.6254626 | 5 |
For a given image, assume that the line given by istart is the fiducial and then calculate the transformation between each line and that line in order to straighten the arc returns Wavlenght solution | def arcstraight(data, xarr, istart, ws=None, function='poly', order=3,
rstep=1, nrows=1, dcoef=None, ndstep=50, log=None, verbose=True):
ImageSolution={}
#extract the central row
oxarr=xarr.copy()
ofarr=data[istart]
print function, order
ws=WavelengthSolution.WavelengthSolution(xarr, x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arc_straighten(data, istart, ws, rstep=1):\n\n ImageSolution = {}\n # now step around the central row\n k = istart\n oxarr = np.arange(len(data[k]))\n ofarr = data[k]\n\n ws.xarr = oxarr\n ws.warr = oxarr\n ws.fit()\n ImageSolution[k] = ws\n\n for i in range(rstep, int(0.5 * len(d... | [
"0.6126928",
"0.6083784",
"0.5943457",
"0.58955705",
"0.5812499",
"0.5803975",
"0.5766157",
"0.56859535",
"0.5670781",
"0.5633762",
"0.55727136",
"0.55490685",
"0.55308104",
"0.5490967",
"0.54588026",
"0.5456496",
"0.5451841",
"0.54468757",
"0.544539",
"0.54355603",
"0.543404... | 0.6020044 | 2 |
Logging after every request. | def after_request(response):
# This avoids the duplication of registry in the log,
# since that 500 is already logged via @app.errorhandler.
if response.status_code != 500:
ts = strftime('[%Y-%b-%d %H:%M]')
message = '{0} {1} {2} {3} {4} {5}'.format(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_request(self):\n log = self.server.log\n if log:\n if hasattr(log, \"info\"):\n log.info(self.format_request() + '\\n')\n else:\n log.write(self.format_request() + '\\n')",
"def log(self):\n\n\t\theader_dict = dict(request.headers)\n\n\t\ttry:\n\t\t\ttracker_id = header_dict[\"tracker_... | [
"0.7003329",
"0.6845563",
"0.6789683",
"0.6605508",
"0.6590901",
"0.6537583",
"0.6496891",
"0.6439227",
"0.6408813",
"0.6405296",
"0.6395425",
"0.6384262",
"0.6379364",
"0.6357551",
"0.6351648",
"0.62906945",
"0.6280724",
"0.6242632",
"0.6223749",
"0.61718506",
"0.61493087",
... | 0.6515837 | 6 |
Make a plot demonstrating the generation of a psf from the pixelconvolved psf model. | def plot(model, center, extent, outname):
# define model grid
xg = np.linspace(-extent, extent, model.shape[0])
yg = xg.copy()
interp_func = RectBivariateSpline(xg, yg, model)
x = np.array([-2, -1, 0, 1, 2]) + center[0]
y = np.array([-2, -1, 0, 1, 2]) + center[1]
psf = interp_func(x, y)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def psf_plot(self, irfname=None, outfile='psf.csv', title=''):\n psf = self.get_psf(irfname)\n \n def bkg_size(e, ct):\n f2 = lambda delta: psf(e,ct, delta)**2 * 2*np.pi*delta\n return np.degrees(1./np.sqrt(np.pi*integrate.quad(f2, 0, np.inf)[0]))\n \n def loc_size... | [
"0.6895699",
"0.67193663",
"0.65856165",
"0.65186673",
"0.6500069",
"0.63485175",
"0.6284272",
"0.61868215",
"0.6121132",
"0.6109175",
"0.60861933",
"0.60637575",
"0.5998818",
"0.5998737",
"0.5974155",
"0.5966359",
"0.59579706",
"0.5955305",
"0.5924926",
"0.59012264",
"0.5896... | 0.5702139 | 45 |
For extra termination criterion, e.g. max time reached. True if terminate, else False. | def check_termination(self) -> bool:
return self.terminate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _termination(self):\n if self._never_terminate:\n return False\n\n if self._counter >= self._max_steps:\n return True\n\n return self.is_fallen() # terminates automatically when in fallen state",
"def should_terminate(self):\n if type(self.termination_criteria) == type(list()):\n ... | [
"0.7712576",
"0.7061782",
"0.6699192",
"0.66448426",
"0.655306",
"0.65208846",
"0.63292634",
"0.6323727",
"0.63231456",
"0.63203883",
"0.63082445",
"0.63071",
"0.62690514",
"0.6246849",
"0.6240451",
"0.6238575",
"0.6164089",
"0.6162817",
"0.614033",
"0.61350584",
"0.6126033",... | 0.6955455 | 2 |
Clean up state dict before processing, e.g. remove entries, transpose. To be overridden by subclasses. | def clean_dict_to_client(self) -> dict:
clean_state_dict = copy_dict(self.model.state_dict()) # not deepcopy
if self.client_is_sparse:
for layer, prefix in zip(self.model.param_layers, self.model.param_layer_prefixes):
key = prefix + ".bias"
if isinstance(lay... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __cleanState__(self, stateDict):\n for k in list(stateDict.keys()):\n if k.startswith('_'):\n stateDict.pop(k)\n return stateDict",
"def cleanup_state_dict_to_server(self) -> dict:\n clean_state_dict = copy_dict(self.model.state_dict()) # not deepcopy\n ... | [
"0.7480847",
"0.7382228",
"0.70599544",
"0.67913824",
"0.6472432",
"0.6443072",
"0.63911605",
"0.63313085",
"0.63285625",
"0.62495",
"0.62301445",
"0.62249994",
"0.6224543",
"0.621515",
"0.6206354",
"0.6164593",
"0.61535925",
"0.61352295",
"0.6121593",
"0.6071332",
"0.6020684... | 0.59866863 | 23 |
Process state dict before sending to client, e.g. to cpu, to sparse, keep values only. | def process_state_dict_to_client(self) -> dict:
clean_state_dict = self.clean_dict_to_client()
if not self.client_is_sparse:
return clean_state_dict
if self.is_adj_round():
for layer, prefix in zip(self.model.prunable_layers, self.model.prunable_layer_prefixes):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_state_dict_to_server(self) -> dict:\n clean_state_dict = self.cleanup_state_dict_to_server()\n\n if self.is_sparse:\n for key, param in clean_state_dict.items():\n if param.is_sparse:\n clean_state_dict[key] = param._values()\n\n if self... | [
"0.76180154",
"0.6854445",
"0.66149974",
"0.65147287",
"0.62516",
"0.62313724",
"0.61112785",
"0.6069947",
"0.60409844",
"0.5974067",
"0.5947056",
"0.5947056",
"0.591974",
"0.5886285",
"0.5876976",
"0.5823361",
"0.5823361",
"0.58231163",
"0.58231163",
"0.5822161",
"0.5803041"... | 0.7053615 | 1 |
Clean up state dict before process, e.g. remove entries, transpose. To be overridden by subclasses. | def cleanup_state_dict_to_server(self) -> dict:
clean_state_dict = copy_dict(self.model.state_dict()) # not deepcopy
if self.is_sparse:
for layer, prefix in zip(self.model.param_layers, self.model.param_layer_prefixes):
key = prefix + ".bias"
if isinstance(la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __cleanState__(self, stateDict):\n for k in list(stateDict.keys()):\n if k.startswith('_'):\n stateDict.pop(k)\n return stateDict",
"def _clean(self):\n map(self.__delitem__, self.keys())\n self._original = []\n self._columns = {}\n self._mo... | [
"0.71951675",
"0.68752795",
"0.68131024",
"0.6417723",
"0.64059037",
"0.63677466",
"0.6339097",
"0.6327316",
"0.6237535",
"0.62354624",
"0.6199999",
"0.61758786",
"0.6175496",
"0.61518264",
"0.61102843",
"0.610255",
"0.60923934",
"0.6078373",
"0.6065815",
"0.6062268",
"0.6054... | 0.7233356 | 0 |
Process state dict before sending to server, e.g. keep values only, extra param in adjustment round. | def process_state_dict_to_server(self) -> dict:
clean_state_dict = self.cleanup_state_dict_to_server()
if self.is_sparse:
for key, param in clean_state_dict.items():
if param.is_sparse:
clean_state_dict[key] = param._values()
if self.is_adj_round... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_state_dict_to_client(self) -> dict:\n clean_state_dict = self.clean_dict_to_client()\n if not self.client_is_sparse:\n return clean_state_dict\n\n if self.is_adj_round():\n for layer, prefix in zip(self.model.prunable_layers, self.model.prunable_layer_prefixes... | [
"0.6597636",
"0.6589529",
"0.63318616",
"0.6201117",
"0.5979139",
"0.5970754",
"0.5893874",
"0.5880639",
"0.58603626",
"0.5851453",
"0.5837013",
"0.5800075",
"0.5800075",
"0.5800006",
"0.5800006",
"0.578738",
"0.5785772",
"0.57822657",
"0.5777867",
"0.57579994",
"0.57440424",... | 0.7382162 | 0 |
Function to be used as a decorator for measuring time elapsed. | def time_elapsed(fun):
def wrapper(*args, **kwargs):
t0 = time.time()
fun(*args, **kwargs)
print("\nTime elapsed = %s" % (time.time() - t0))
return wrapper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed(func):\n def call_elapsed(*args, **kwargs):\n start_time = time.time()\n func(*args, **kwargs)\n sys.__stdout__.write('Time elapsed: %s'\n % (time.time() - start_time,))\n return make_decorator(func)(call_elapsed)",
"def timed(func):\n @wraps(... | [
"0.827335",
"0.8096769",
"0.7943362",
"0.7897353",
"0.7849219",
"0.7806063",
"0.77799284",
"0.77593815",
"0.7678783",
"0.7669037",
"0.7585005",
"0.755756",
"0.7538161",
"0.75191116",
"0.7516911",
"0.7505306",
"0.75011796",
"0.74958384",
"0.7489623",
"0.7487912",
"0.74834543",... | 0.82400656 | 1 |
Basic list processing. Using a data directory, a file list, start and end on that list, and a function to be applied to the data directory and a relative path from the list. | def process_list(data_dir, filelist, start, end, crash, fun):
print("$ python3 %s\n" % ' '.join(sys.argv))
for n, fname in elements(filelist, start, end):
print_element(n, fname)
if crash:
fun(data_dir, fname)
else:
try:
fun(data_dir, fname)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_by_list( dataset_file ):\n three_paths = []\n # From one input path, build the three paths to send on to move_and_record:\n with open( dataset_file, 'r' ) as f:\n for line in f:\n vnh = line.strip()\n three_paths.append( ( os.path.join('/p/css03/scratch/',vnh),\n ... | [
"0.59321105",
"0.58461875",
"0.5798538",
"0.5792798",
"0.5771745",
"0.5754246",
"0.5739142",
"0.57320946",
"0.5729682",
"0.56914705",
"0.56519324",
"0.564612",
"0.5645171",
"0.5587724",
"0.5561564",
"0.5547579",
"0.55469304",
"0.55424505",
"0.5532638",
"0.5530215",
"0.5530215... | 0.7580944 | 0 |
Generator over the lines in filelist, only yielding lines from line niumber start up to and including end. | def elements(filelist, start, end):
process = False
n = 1
with open(filelist) as fh:
for line in fh:
fname = line.strip()
if n == start:
process = True
if n > end:
return
if process:
yield (n, fname)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iter_list(self):\n # XXX better docstring for this one\n\n if self.plaintext:\n fin = io.StringIO(self.plaintext)\n else:\n try:\n filename = os.path.join(self.plaintext_dir, '%s.list' % self.list_name)\n fin = io.open(filename, encoding=... | [
"0.661907",
"0.6601885",
"0.64462453",
"0.6376909",
"0.6133469",
"0.6096831",
"0.60324067",
"0.6029716",
"0.6018468",
"0.6017219",
"0.6010689",
"0.5964823",
"0.58906317",
"0.5870396",
"0.58433306",
"0.57549626",
"0.57345665",
"0.5725584",
"0.5724956",
"0.57210445",
"0.5689125... | 0.72599405 | 0 |
Ensure the directory part of all file names exists. | def ensure_directory(*fnames):
for fname in fnames:
directory = os.path.split(fname)[0]
if not os.path.exists(directory):
os.makedirs(directory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ensure_dir_exists(self):\n pass",
"def _check_dirs(self):\r\n for dir in [self.papers_dir,\r\n self.buffer_dir]:\r\n if not os.path.exists(dir):\r\n message = f'Dir not exists: {dir}. Making it.'\r\n logging.warning(message)\r\n ... | [
"0.7356267",
"0.71693665",
"0.7007526",
"0.69387996",
"0.6898358",
"0.68749064",
"0.68032044",
"0.67036724",
"0.6685586",
"0.66848123",
"0.663925",
"0.6629318",
"0.66166574",
"0.66119087",
"0.6604366",
"0.66002417",
"0.65705216",
"0.6567934",
"0.65654266",
"0.65576756",
"0.65... | 0.7486347 | 0 |
Default method for getting options. | def get_options():
options = dict(getopt.getopt(sys.argv[1:], 'd:f:b:e:', ['crash'])[0])
data_dir = options.get('-d')
filelist = options.get('-f', 'files-random.txt')
start = int(options.get('-b', 1))
end = int(options.get('-e', 1))
crash = True if '--crash' in options else False
return data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_options(self):\n return self.options",
"def get_options(self):\n\t\treturn self.options",
"def _options(self):\n return",
"def options(self):\n return self.__options",
"def get_options(self):\n return []",
"def options(self):\r\n return self._options",
"def default_o... | [
"0.80497515",
"0.80299115",
"0.8010356",
"0.7919554",
"0.778794",
"0.7766878",
"0.7602395",
"0.7537503",
"0.7464148",
"0.7464148",
"0.7464148",
"0.7464148",
"0.7464148",
"0.7434978",
"0.7379406",
"0.73686075",
"0.73029923",
"0.73029923",
"0.723513",
"0.7225992",
"0.7223051",
... | 0.0 | -1 |
Function for generating model for given scenario and feature based model | def generate_model(simulation_folder, method='RF', mode='classification'):
Start = datetime.now()
project_directory = os.path.dirname(os.getcwd())
path_to_data = os.path.join(project_directory, "Data", simulation_folder)
path_to_characteristics_data = os.path.join(path_to_data, "Characteristics")
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model(train_inputs,train_labels,model_params,model_mode='classification',\n model_type='naive_bayes'):\n if model_mode == \"classification\":\n if model_type == \"naive_bayes\":\n model = GaussianNB()\n if model_type == \"knn\":\n model = KNeighbo... | [
"0.7047192",
"0.6940045",
"0.68838376",
"0.68168855",
"0.6798972",
"0.6764866",
"0.67100143",
"0.6697578",
"0.665994",
"0.66594493",
"0.66280913",
"0.6619747",
"0.66095245",
"0.6601167",
"0.6585843",
"0.65837723",
"0.65502596",
"0.65307325",
"0.6524048",
"0.6522005",
"0.65090... | 0.5981848 | 50 |
Load training and testing datasets based on their path | def load_data(path):
train = pd.read_csv(os.path.join(path,'train.csv'))
test = pd.read_csv(os.path.join(path,'test.csv'))
return train, test | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_datasets():\n from .dataset import num_classes, image_size\n\n train_filename = maybe_download('notMNIST_large.tar.gz', 247336696)\n test_filename = maybe_download('notMNIST_small.tar.gz', 8458043)\n\n train_folders = maybe_extract(train_filename)\n test_folders = maybe_extract(test_filenam... | [
"0.7542963",
"0.7522748",
"0.72478217",
"0.7155913",
"0.7114264",
"0.709831",
"0.7045667",
"0.7041976",
"0.7035369",
"0.70137733",
"0.70078444",
"0.6995081",
"0.69904816",
"0.69886416",
"0.6962951",
"0.6940555",
"0.69332427",
"0.69182503",
"0.6917499",
"0.6916794",
"0.6907609... | 0.7288703 | 2 |
Returns a list of tuples as a path from the given start to the given end in the given maze | def astar(maze, start, end):
# Create start and end node
start_node = Node(None, start)
start_node.g = start_node.h = start_node.f = 0
end_node = Node(None, end)
end_node.g = end_node.h = end_node.f = 0
# Initialize both open and closed list
open_list = []
closed_list = []
# Add t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backtrack_to_start_to_draw_purpose(board, end):\r\n cell = board.at(end)\r\n # print(cell)\r\n path = []\r\n lis = []\r\n while cell != None:\r\n path.append(cell)\r\n cell = cell.path_from\r\n for i in path[-1:]:\r\n for j in i.position:\r\n lis.ap... | [
"0.7354014",
"0.6893368",
"0.67995024",
"0.6577565",
"0.65503275",
"0.6525046",
"0.64721817",
"0.64531684",
"0.6449647",
"0.6447902",
"0.64381254",
"0.6377536",
"0.63698727",
"0.6340243",
"0.6304546",
"0.629712",
"0.6293771",
"0.6286109",
"0.62820053",
"0.6251899",
"0.6198696... | 0.6447902 | 11 |
This function initializes model runner which loads model from selected path and | def __init__(self, base_folder_path='./communities/default/versions/default/',
framework='keras', preprocessing_version='keras_v1') -> None:
self.framework = framework
if framework == 'keras':
self.graph = tf.Graph()
with self.graph.as_default():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(self) -> None:\n self.model = load(self.path)",
"def load_model(self, model_path: str):",
"def load(\n self,\n modelLoadPath\n ):\n pass",
"def init_model(self):\n pass",
"def load_model(self):\n pass",
"def __init__(self):\n cwd ... | [
"0.7832241",
"0.7505055",
"0.73870575",
"0.7380255",
"0.7363144",
"0.72303456",
"0.7228411",
"0.72195596",
"0.7209765",
"0.72026896",
"0.7163052",
"0.7122686",
"0.7110296",
"0.7106618",
"0.7029678",
"0.6996217",
"0.6985913",
"0.6965304",
"0.69458365",
"0.69114673",
"0.6911099... | 0.62814736 | 100 |
This function makes prediction of `text` toxicity using trained model. | def run(self, text) -> float:
preprocessed = self.preprocess(text)
if self.framework == 'keras':
keras.backend.set_session(self.session)
with self.graph.as_default():
probability = float(self.model.predict(x=preprocessed))
else:
raise ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_text_predictions(self, text, preprocessor):\n text = preprocessor.preprocess(text)\n y_pred = self.sgd_pipeline.predict_proba([text])\n return y_pred",
"def predict(self,text):\n\n text= \"[CLS] \" + text + \" [SEP]\"\n tokenized_text = self.tokenizer.tokenize(text)\n ... | [
"0.754851",
"0.7526877",
"0.7516073",
"0.75143737",
"0.7459022",
"0.7400885",
"0.7233393",
"0.72208285",
"0.71848124",
"0.7142477",
"0.70995235",
"0.7090822",
"0.7080714",
"0.70559317",
"0.7042861",
"0.70154345",
"0.69604945",
"0.6949035",
"0.69476473",
"0.6923206",
"0.690571... | 0.6222873 | 74 |
Class constructor Called when the object is initialized | def __init__(self, secured=False, verbose=False):
self._mh = MasterHead.get_head()
self._secured = secured
if (not self._secured):
self._client = SMTP()
else:
self._client = SMTP_SSL()
self._verbose = verbose
if (self.verbose):
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self) -> None:\n # TODO: Provide the complete constructor for this object",
"def __init__ (self):\n pass",
"def initialize(cls):",
"def __init__(self):\n\t\tprint(\"Class initilised\")",
"def init(self) -> None:\n ...",
"def init(self) -> None:",
"def init(self):\n ... | [
"0.8581114",
"0.8548315",
"0.8462899",
"0.8434955",
"0.8345252",
"0.8339785",
"0.8329959",
"0.8329959",
"0.8329959",
"0.8329959",
"0.8329959",
"0.8329959",
"0.8329959",
"0.8329959",
"0.83298635",
"0.82159376",
"0.81932527",
"0.81866586",
"0.8179381",
"0.8179381",
"0.81679076"... | 0.0 | -1 |
SMTP client property getter | def client(self):
return self._client | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_property(self, client):\r\n client.getProperty()",
"def email(self):\n return self.__email",
"def get_client(self):\n return self.client",
"def getClientIP(self):\n if isinstance(self.client, IPv4Address):\n return self.client.host\n return None",
"def get_... | [
"0.6910745",
"0.5989659",
"0.58590966",
"0.580442",
"0.5748582",
"0.5731645",
"0.5727624",
"0.5624233",
"0.56166255",
"0.56109554",
"0.558993",
"0.5561965",
"0.54838747",
"0.5473846",
"0.5464995",
"0.5433787",
"0.54239774",
"0.54149365",
"0.5399041",
"0.53975356",
"0.53652686... | 0.5472387 | 14 |
server host property getter | def host(self):
return self._host | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_host(self):\r\n return self.host",
"def getHost(self):\n return self._host",
"def get_host(self):\n return self.host",
"def getHost():",
"def getHost():",
"def getHost(self):\n return self._host",
"def gethost(self):\n return self.__host",
"def host(self... | [
"0.8127993",
"0.7984239",
"0.79128706",
"0.78472555",
"0.78472555",
"0.78438044",
"0.7781621",
"0.77646685",
"0.77191705",
"0.7635762",
"0.7635762",
"0.7635762",
"0.7635762",
"0.7635762",
"0.7635762",
"0.7635762",
"0.7486404",
"0.74833006",
"0.74823356",
"0.74674594",
"0.7369... | 0.7318721 | 23 |
server port property getter | def port(self):
return self._port | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_serverport(cobj):\n pass",
"def port(self):\r\n _, port = self.server_address\r\n return port",
"def server_port(self):\n return self._server_port",
"def server_port(self):\n return self._server_port",
"def port(self) -> int:",
"def port(self):\n return self.... | [
"0.8230907",
"0.81723696",
"0.8116878",
"0.8116878",
"0.8090991",
"0.8031322",
"0.8031322",
"0.8031322",
"0.8031322",
"0.8031322",
"0.8031322",
"0.80033934",
"0.7986188",
"0.79804695",
"0.79648024",
"0.79409605",
"0.79409605",
"0.79409605",
"0.79409605",
"0.79409605",
"0.7927... | 0.7712949 | 34 |
user password property getter | def passw(self):
return self._passw | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetPassword(self):\n pass",
"def GetPassword(self):\n return self._password",
"def get_password(self):\n raise NotImplementedError('get_password')",
"def getPassword(self):\n\t\treturn self.Password",
"def _get_password(self):\r\n return self._password",
"def _get_user_password(... | [
"0.8759262",
"0.8647866",
"0.8596812",
"0.85195065",
"0.85184133",
"0.85066795",
"0.84923244",
"0.8486835",
"0.8437402",
"0.8323411",
"0.82673454",
"0.82258314",
"0.81767637",
"0.8139852",
"0.8139852",
"0.8139852",
"0.81389266",
"0.81389266",
"0.81389266",
"0.81389266",
"0.80... | 0.0 | -1 |
verbose mode property getter | def verbose(self):
return self._verbose | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _showProperty(self):\n pass",
"def _get_verbose(self):\n self._validate_verbose()\n return deepcopy(self.verbose)",
"def verbose():\n return _verbose",
"def getVerbose(self):\n return self.__VERBOSE",
"def verbose(self):\n return self._verbose",
"def verbose(self... | [
"0.73023486",
"0.7042222",
"0.7023535",
"0.69736546",
"0.69604874",
"0.69604874",
"0.69604874",
"0.69604874",
"0.6915387",
"0.65532297",
"0.6550033",
"0.6525252",
"0.6363883",
"0.63366884",
"0.6332637",
"0.6306071",
"0.6279626",
"0.6272471",
"0.6242539",
"0.62308097",
"0.6182... | 0.662939 | 9 |
Method connects to server | def connect(self, host, port=None, user=None, passw=None, timeout=10):
try:
if (port == None):
port = 25 if (not self._secured) else 465
message = '{0}/{1}@{2}:{3} timeout:{4}'.format(
user, passw, host, port, timeout)
self._mh.demsg('htk_on... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self) -> None:\n self.client_socket.connect((self.server_name, self.server_port))",
"def connectToServer(self):\n self.client = Client(base_url = self.server)\n self.ping()",
"def connect(self):\n\n print(\"Connecting to server at {}:{}\".format(self.hostname, self.port)... | [
"0.76462835",
"0.76368177",
"0.7595585",
"0.74189913",
"0.73962307",
"0.7329637",
"0.7318585",
"0.73011315",
"0.7294635",
"0.7293998",
"0.72660106",
"0.7263239",
"0.7233658",
"0.7232783",
"0.7202371",
"0.7188405",
"0.7130243",
"0.7100755",
"0.7086954",
"0.7032786",
"0.7028723... | 0.0 | -1 |
Method disconnects from server | def disconnect(self):
try:
if (not self._is_connected):
self._mh.demsg('htk_on_warning', self._mh._trn.msg(
'htk_email_not_connected'), self._mh.fromhere())
return False
else:
self._client.quit()
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect(self) -> None:\n ...",
"def disconnect():\n logging.info('Client disconnected')",
"def disconnect(self):\n r = requests.post(f'{self.SERVER_ADDR}/api/disconnect', headers={'Authorization': 'Token ' + self.token})\n r.raise_for_status()",
"def disconnect(self):\n ... | [
"0.8190362",
"0.8072268",
"0.8055848",
"0.80359656",
"0.7916064",
"0.79097486",
"0.79097486",
"0.79097486",
"0.79097486",
"0.79097486",
"0.78659046",
"0.7855627",
"0.78464586",
"0.7841188",
"0.78290087",
"0.7827624",
"0.7797917",
"0.77728975",
"0.7753528",
"0.76885885",
"0.76... | 0.0 | -1 |
Makes sure that the kraus matrices are properly normalized and therefore preserve probability | def checknormkraus(k, n):
out = zeros((pow(2, n), pow(2, n)), dtype=complex)
for x in range(len(k)):
out += dot(ctranspose(k[x]), k[x])
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compute_unnormalized_scores(self):\n # todo: implement this test!\n pass",
"def standardize_sim_values(self):\n for user_id_A, row in self.sim_matrix.items(): # row is reference\n lA = len(self.users[user_id_A].covered_items)\n for user_id_B in row.keys():\n ... | [
"0.6199272",
"0.60676134",
"0.59419996",
"0.59406203",
"0.58727413",
"0.58247393",
"0.58019066",
"0.57957315",
"0.57488877",
"0.57387805",
"0.5725493",
"0.57249516",
"0.5707711",
"0.570238",
"0.56975055",
"0.5695627",
"0.5681611",
"0.5679419",
"0.5678707",
"0.56698096",
"0.56... | 0.59059787 | 4 |
Return an array of shape (n, nrows, ncols) where n nrows ncols = arr.size If arr is a 2D array, the returned array looks like n subblocks with each subblock preserving the "physical" layout of arr. | def blockshaped(arr, nrows, ncols):
h, w = arr.shape
return (arr.reshape(h//nrows, nrows, -1, ncols)
.swapaxes(1,2)
.reshape(-1, nrows, ncols)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blockshaped(arr, nrows, ncols):\r\n\t h, w = arr.shape\r\n\t return (arr.reshape(h//nrows, nrows, -1, ncols)\r\n\t .swapaxes(1,2)\r\n\t .reshape(-1, nrows, ncols))",
"def split(array, nrows, ncols):\r\n r, h = array.shape\r\n return (array.reshape(h//nrows, nrows, -1, ... | [
"0.8111831",
"0.6740403",
"0.6638184",
"0.64678365",
"0.6413465",
"0.62206024",
"0.618583",
"0.61262256",
"0.6110952",
"0.6007621",
"0.595044",
"0.5925052",
"0.5907911",
"0.58899516",
"0.58659804",
"0.5862319",
"0.5808406",
"0.5804738",
"0.5729923",
"0.56981754",
"0.5686918",... | 0.81093544 | 3 |
Return an array of shape (h, w) where h w = arr.size If arr is of shape (n, nrows, ncols), n sublocks of shape (nrows, ncols), then the returned array preserves the "physical" layout of the sublocks. | def unblockshaped(arr, h, w):
n, nrows, ncols = arr.shape
return (arr.reshape(h//nrows, -1, nrows, ncols)
.swapaxes(1,2)
.reshape(h, w)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blockshaped(arr, nrows, ncols):\r\n\t h, w = arr.shape\r\n\t return (arr.reshape(h//nrows, nrows, -1, ncols)\r\n\t .swapaxes(1,2)\r\n\t .reshape(-1, nrows, ncols))",
"def blockshaped(arr, nrows, ncols):\n h, w = arr.shape\n return (arr.reshape(h//nrows, nrows, -1, ncol... | [
"0.69460547",
"0.6816731",
"0.6816731",
"0.6816731",
"0.58214104",
"0.55275667",
"0.5430478",
"0.5429076",
"0.5418111",
"0.5407741",
"0.5375328",
"0.5324775",
"0.5278403",
"0.52337265",
"0.5231",
"0.5219745",
"0.51644814",
"0.51599187",
"0.51588565",
"0.51561743",
"0.51494306... | 0.69714326 | 0 |
Gets gives you a string in base less than 20 | def dec2base(n, base):
convertstring = "0123456789ABCDEF"
if n < base:
return convertstring[n]
else:
return dec2base(n // base, base) + convertstring[n % base] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str(x):\n return str(x)[:200]",
"def getString(self, int: int, int2: int) -> str:\n ...",
"def str_base(num, base=36, numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n if base < 2 or base > len(numerals):\n raise ValueError(\"`base` must be between 2 and %i\")\n\n if num == 0... | [
"0.61306405",
"0.5743126",
"0.5712135",
"0.56840897",
"0.56803316",
"0.5613111",
"0.55956316",
"0.5487813",
"0.5485353",
"0.54662246",
"0.5421135",
"0.5419046",
"0.5384076",
"0.53730214",
"0.53664714",
"0.53429157",
"0.5332639",
"0.53188115",
"0.53121996",
"0.5304874",
"0.530... | 0.0 | -1 |
Create a string of labels for making kraus matrices | def createlabel(q, n):
# When using dec2base function make sure to pad the string with the right number of zeros e.g for base 3 dec2base
# gives 1 rather than 01 if we were dealing with 2 qubits.
# The number of kraus matrices or labels is n^q
label = []
for i in range(pow(n, q)):
label.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def labels(self):\n\n param=self\n\n l=len(param)\n\n sweep_label=[]\n\n for index,name in enumerate(param.names):\n\n sweep_label.append((\\\n ''.join([c for c in name if c.isupper()]))\\\n .replace(\"IDT\",\"\")\\\n .replace(\"S\",\"\")\\\n ... | [
"0.67619133",
"0.663309",
"0.6551996",
"0.64509314",
"0.6398122",
"0.63851887",
"0.637231",
"0.6331695",
"0.6312578",
"0.6312468",
"0.6250509",
"0.6233009",
"0.6200263",
"0.6166632",
"0.6158342",
"0.6139826",
"0.6134953",
"0.61154574",
"0.6100781",
"0.60787743",
"0.60545135",... | 0.66556007 | 1 |
Gets gives you a string in base less than 20 | def padded_dec2base(n, q, base):
convertstring = "0123456789ABCDEF"
if n < base:
return convertstring[n].zfill(q)
else:
return (dec2base(n // base, base) + convertstring[n % base]).zfill(q) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str(x):\n return str(x)[:200]",
"def getString(self, int: int, int2: int) -> str:\n ...",
"def str_base(num, base=36, numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n if base < 2 or base > len(numerals):\n raise ValueError(\"`base` must be between 2 and %i\")\n\n if num == 0... | [
"0.6130242",
"0.5743642",
"0.57067406",
"0.56830925",
"0.5679255",
"0.5610704",
"0.5591267",
"0.5486736",
"0.54818887",
"0.5463564",
"0.541896",
"0.5418778",
"0.5381753",
"0.5369742",
"0.53678566",
"0.53397405",
"0.5329653",
"0.5317555",
"0.5309176",
"0.53040755",
"0.5300111"... | 0.0 | -1 |
This function has two uses, it either loads the data and plots it if val=1 or it just gets the data from the data file and puts it into arrays which it returns | def load_data(f='', use_cols=[], xlabel='', ylabel='',scatter=False,contour=False, connect=False,
errorbar=False, std_col=None, data_domain=None, labo=[], title='',
return_data=False, graph=False, multiple_files=None, file_stem='', folder=None,
file_list = None, color_list=None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_data(self):",
"def read_data(self,data_array):\n value_type = self.config['value_type']\n try:\n curr_value = data_array[self.index]\n except:\n curr_value = 'None'\n \n #if value is none\n if curr_value.strip() == 'None':\n #bre... | [
"0.6647763",
"0.64216316",
"0.6359169",
"0.63143903",
"0.6262408",
"0.6255117",
"0.6233591",
"0.61642987",
"0.615564",
"0.61097324",
"0.6082113",
"0.6058028",
"0.6043723",
"0.60317194",
"0.6011355",
"0.59696865",
"0.59659594",
"0.59338933",
"0.5926765",
"0.5913887",
"0.590078... | 0.6140941 | 9 |
This combines data from different files so that the first column of file 1 is concatenated with first column oof file 2 and so on | def combine_data(data_files_dict):
key_list = list(data_files_dict.keys())
no_col = len(data_files_dict[key_list[0]])
combined = []
for n in range(0, no_col):
d = np.empty(shape=[0, 1])
for k in data_files_dict:
d = np.append(d, data_files_dict[k][... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def joinInds(r1,r2,outfname):\n outf = open(outfname,'w')\n f1 = file(r1,'r')\n f2 = file(r2,'r')\n for row1 in f1:\n outf.write('%s\\n' % (row1.strip()))\n for row1 in f2:\n outf.write('%s\\n' % (row1.strip()))\n outf.close()",
"def combine_data(data_file_1,data_file_2,lookup,outfile):\n... | [
"0.69194674",
"0.68689555",
"0.68170476",
"0.68082374",
"0.6766507",
"0.6740994",
"0.65512586",
"0.649538",
"0.6470603",
"0.6433774",
"0.6398605",
"0.6366733",
"0.63394064",
"0.6321476",
"0.6318781",
"0.63122654",
"0.63077897",
"0.62968826",
"0.6234011",
"0.6232312",
"0.62031... | 0.64034826 | 10 |
Gets data from folder or list of files or file and graphs it in some manner | def data_graph(graph=False):
def axes_data(use_cols1, data1, domain=None):
if domain is not None:
axis = [0] * (2 * len(use_cols1))
for k in range(len(use_cols1)):
axis[2 * k] = domain
axis[2 * k + 1] = data1[k]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_folder(path):\r\n plt.figure(figsize=(20, 10))\r\n for filename in glob.glob(path + '/*.pspec'):\r\n x, y= np.loadtxt(fname=filename, delimiter='\\t',dtype=int, usecols = (1,2),\r\n skiprows=100, unpack = True)\r\n plt.plot(x, y)\r\n return plt.show()",
... | [
"0.6147145",
"0.6075623",
"0.6052255",
"0.60388416",
"0.6000848",
"0.59751105",
"0.5926414",
"0.59199905",
"0.5909472",
"0.5900133",
"0.5893431",
"0.5886188",
"0.58466923",
"0.5835453",
"0.58165103",
"0.5766947",
"0.57565695",
"0.57469636",
"0.57377124",
"0.5732059",
"0.57235... | 0.0 | -1 |
This was written as a quick and easy way of producing keys for a dictionary. | def generateDictKeys(string, n,step=1):
if type(string) != str or type(n) != int:
raise ValueError('Please input string and integer for first and second argument')
elif step == 1:
keylist = [string+str(i) for i in range(n)]
return keylist
else:
keylist = [string+str(i) for i ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dict_keys(typingctx, d):\n resty = types.DictKeysIterableType(d)\n sig = resty(d)\n codegen = _iterator_codegen(resty)\n return sig, codegen",
"def gen_keys():",
"def keysToString(indict):\r\n newD = {}\r\n for k, v in indict.iteritems():\r\n newD[k.name] = v\r\n return n... | [
"0.7005188",
"0.6934373",
"0.6890387",
"0.67853284",
"0.673573",
"0.65881485",
"0.65482956",
"0.64672315",
"0.6466475",
"0.63628036",
"0.6300725",
"0.6282017",
"0.62659967",
"0.62190944",
"0.62190944",
"0.61936593",
"0.61924356",
"0.6183557",
"0.61608386",
"0.6154461",
"0.613... | 0.6380825 | 9 |
This generates a string that is used to construct tensor products terms in Hamiltonian with a certain kind of interaction term. For example suppose we have an ising Hamiltonian with 4 qubits. We generate strings in a list 1100, 0110,0011. The zero will be used to tensor an identity and the 1 will be used to tensor the ... | def generatehamiltoniantring(n, s, onestring=None, pos=None, pad=None):
label = []
if onestring is None:
if isinstance(s, str):
for i in range(0, n):
strs = s
strs = strs.ljust(n-i, '0')
strs = strs.rjust(n, '0')
label.append(st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generatetensorstring(n, *args):\n out = ''\n label = 0\n arg = array(args) - 1\n\n for i in range(0, n):\n if i in arg:\n label += 1\n out += str(label)\n else:\n out += '0'\n return out",
"def generate_str (obj):\n d = obj.dim(obj)\n units ... | [
"0.67071134",
"0.6188811",
"0.61187154",
"0.60962516",
"0.60897434",
"0.5981579",
"0.59358764",
"0.57879096",
"0.57309914",
"0.57123774",
"0.5700587",
"0.56701165",
"0.5653385",
"0.5609417",
"0.55606216",
"0.55426735",
"0.55394495",
"0.5516998",
"0.5511794",
"0.550661",
"0.54... | 0.6213781 | 1 |
This is a function like generatehamiltonianstring except it allows for the possibility that we could have different operators in the interaction placed at arbitrary place. Plus this does not generate a list but just one string. IZIIXIY needs string '0100203'. Can't handle a term like 'IZZZ' because we need string '0111... | def generatetensorstring(n, *args):
out = ''
label = 0
arg = array(args) - 1
for i in range(0, n):
if i in arg:
label += 1
out += str(label)
else:
out += '0'
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generatehamiltoniantring(n, s, onestring=None, pos=None, pad=None):\n label = []\n if onestring is None:\n if isinstance(s, str):\n for i in range(0, n):\n strs = s\n strs = strs.ljust(n-i, '0')\n strs = strs.rjust(n, '0')\n la... | [
"0.6886402",
"0.62860495",
"0.6248529",
"0.60452443",
"0.59542227",
"0.5951492",
"0.5921407",
"0.58268994",
"0.58254063",
"0.58065975",
"0.5785644",
"0.5758566",
"0.5726359",
"0.5682617",
"0.56284726",
"0.559341",
"0.55856794",
"0.5582962",
"0.5550443",
"0.5527762",
"0.552414... | 0.56956476 | 13 |
This is the partial trace operator | def partial_trace(n, m, k):
out = 1
tensor_label = generatetensorstring(n, m)
terms = {"0": g.id(), "1": g.e_ij((2, 1), k, 1)}
out = superkron(terms, string=tensor_label, val=1)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trace(self, trace=...):\n ...",
"def trace(self, *args, **kwargs): # real signature unknown\n pass",
"def _tracer(self, a=None, b=None):",
"def gettrace(): # real signature unknown; restored from __doc__\n pass",
"def trace(self, frame, event, arg):\n if event == \"call\":\n ... | [
"0.7580509",
"0.73253495",
"0.7095109",
"0.6534398",
"0.65204096",
"0.6515735",
"0.643079",
"0.6427031",
"0.6426489",
"0.6408104",
"0.6340209",
"0.6321353",
"0.6320289",
"0.6298356",
"0.6297256",
"0.6279434",
"0.6278039",
"0.6278039",
"0.6278039",
"0.6278039",
"0.6278039",
... | 0.56244236 | 74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.