query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Returns a neatly formatted string representation of the Edge object | def __str__(self):
# string representation includes values of all inner fields
return \
"Edge Weight: " + str(self.weight) + "\n" + \
"Edge Attributes: " + str(self.attributes) + "\n" + \
"First Incident Node: \n" + str(self.first_incident_node.get_name()) + "\n" + \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n s = f\"GraphViaEdges '{self.name}',\\nedges :\\n\"\n for edge, edgetype in self.edges.items():\n s += f\" {edge[0]} {edgetype.value} {edge[1]}\\n\"\n\n return s",
"def __repr__(self) -> str:\n if self._has_direction:\n return (\n ... | [
"0.82040614",
"0.8060393",
"0.7995197",
"0.7733873",
"0.7632803",
"0.76063347",
"0.74718153",
"0.74718153",
"0.7468327",
"0.73569363",
"0.72818464",
"0.72779083",
"0.72449094",
"0.7231813",
"0.7149456",
"0.7144907",
"0.70975465",
"0.7085748",
"0.7036638",
"0.7021868",
"0.6974... | 0.82814515 | 0 |
Given an Edge object, checks whether this Edge object is equal to the input Edge object equality of two Edge objects is defined in terms of equality of inner fields and not as identical objects in memory | def __eq__(self, other):
# check equality of names and attributes as well as that of the incident Node objects
return \
self.weight == other.get_weight() and \
self.attributes.__eq__(other.get_attributes()) and \
self.get_incident_nodes().__eq__(other.get_incident_nod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not type(other) == type(self):\n return False\n sedges, oedges = self.edges, other.edges\n return ((len(sedges) == len(oedges)) and\n all(numpy.all(se == oe) for (se, oe) in zip(sedges, oedges)))",
"def __eq__(self, other: Vertex) -> bo... | [
"0.74431676",
"0.72960687",
"0.705057",
"0.70363057",
"0.69611436",
"0.69486606",
"0.68862784",
"0.68857896",
"0.6836915",
"0.68208396",
"0.6810775",
"0.6760811",
"0.6709949",
"0.66960603",
"0.6661585",
"0.6647696",
"0.6606761",
"0.6606037",
"0.65925986",
"0.65676755",
"0.656... | 0.6921303 | 6 |
Returns the set of incident nodes of the edge | def get_incident_nodes(self):
# return the set of incident edges
return \
{
self.first_incident_node,
self.second_incident_node
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_incident_edges(self):\n return set(self.incident_edges) # return the set of incident edges",
"def get_incident_edges(self):\n return set(self.incident_edges) # return the set of incident edges",
"def get_edges(self):\n return \\\n set({\n edge\n ... | [
"0.81497467",
"0.81497467",
"0.79593974",
"0.6999665",
"0.69706666",
"0.6923077",
"0.6884884",
"0.6862551",
"0.6847484",
"0.6847341",
"0.66978186",
"0.66516453",
"0.66198707",
"0.6604278",
"0.6597416",
"0.65804565",
"0.65804565",
"0.65804565",
"0.65804565",
"0.65804565",
"0.6... | 0.84504414 | 0 |
Constructor for the UndirectedGraph class used to initialize all necessary fields of the UndirectedGraph object | def __init__(self, nodeset):
self.nodeset = nodeset # initialize all necessary fields
self.__check_validity() # check if graph is valid - throws exception if not | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._graph = DirectedGraph()\n self._graph_copies = []",
"def __init__(self):\n self.graph = None",
"def __init__(self):\n self._adjacency_list = {\n\n }",
"def __init__(self):\n self.graph = {}\n self.edges = 0\n self.vertices = ... | [
"0.7334895",
"0.72836196",
"0.6959662",
"0.6936605",
"0.688283",
"0.67758995",
"0.6768145",
"0.6719209",
"0.6694202",
"0.66806513",
"0.6675121",
"0.6643877",
"0.6641952",
"0.6630725",
"0.6620418",
"0.6611511",
"0.66015965",
"0.6595077",
"0.65761536",
"0.65761536",
"0.65744764... | 0.6142115 | 99 |
Given an UndirectedGraph object, checks whether this UndirectedGraph object is equal to the input UndirectedGraph object equality of two UndirectedGraph objects is defined in terms of equality of inner fields and not as identical objects in memory | def __eq__(self, other):
# check equality of the nodesets
return self.nodeset.__eq__(other.get_nodeset()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, Model):\n return False\n return self.graph == other.graph",
"def __eq__(self, other):\n if not type(other) == type(self):\n return False\n sedges, oedges = self.edges, other.edges\n return ((len(sedges) == len(oedges))... | [
"0.7523416",
"0.75222325",
"0.7511622",
"0.7403132",
"0.7257212",
"0.7236885",
"0.71853983",
"0.71622",
"0.71622",
"0.71622",
"0.71622",
"0.71622",
"0.7143371",
"0.71366626",
"0.71069914",
"0.7105524",
"0.7102913",
"0.70744616",
"0.70490736",
"0.70204526",
"0.69930714",
"0.... | 0.705797 | 18 |
Helper function that adds a duplicate edge to the input graph and returns the modified graph. Useful for extracting subgraphs. | def __induced_subgraph_helper(G, edge):
first_incident_node = \
GraphProcessing.search_node_names(
G.get_nodeset(),
edge.get_first_incident_node().get_name()
).pop() # obtain the disconnected copy of the first incident node
second_incident_node =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate(self):\n\t\treturn Graph(self.vertices[:], self.edges[:])",
"def add_edge(self, edge):\n edge = set(edge)\n (vertex1, vertex2) = tuple(edge)\n if vertex1 in self.graph_dict:\n self.graph_dict[vertex1].append(vertex2)\n else:\n self.graph_dict[vertex... | [
"0.7245972",
"0.711353",
"0.7053633",
"0.6733795",
"0.6715932",
"0.6670997",
"0.6650648",
"0.64860946",
"0.64417297",
"0.6236953",
"0.6235841",
"0.6192263",
"0.6180105",
"0.6116902",
"0.60675865",
"0.60634625",
"0.60634625",
"0.6043934",
"0.60427433",
"0.6018553",
"0.6018553"... | 0.6925253 | 3 |
Returns True if the graph has multiple edges originating from and leading to the same node and False otherwise | def __has_multiple_edges(self):
return \
len(
list(
[
tuple((edge.get_first_incident_node().get_name(), edge.get_second_incident_node().get_name()))
for edge in self.get_edges()
] # the length of... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_multiple_edges(self):\n # Create a list of edge 2-tuples (a, b)\n edge_tuples = [(e['from_id'], e['to_id']) for e in self._edges]\n if len(edge_tuples) > len(set(edge_tuples)): # Do 'real' multiple edges exist?\n return True\n\n # Create a list of edge 2-tuples (a, b... | [
"0.7612069",
"0.7316966",
"0.7045262",
"0.7041747",
"0.6953627",
"0.6944002",
"0.6906258",
"0.6894936",
"0.68891203",
"0.68841875",
"0.68400526",
"0.682799",
"0.6795179",
"0.6794149",
"0.67861754",
"0.67733485",
"0.67662656",
"0.6754904",
"0.6741777",
"0.67363137",
"0.6730243... | 0.76320726 | 0 |
Helper to create an initialized Variable with weight decay. Note that the Variable is initialized with a truncated normal distribution. A weight decay is added only if one is specified. | def _variable_with_weight_decay(name, shape, stddev, wd):
var = _variable_on_cpu(name, shape,
tf.truncated_normal_initializer(stddev=stddev))
if wd:
weight_decay = tf.mul(tf.nn.l2_loss(var), wd, name='weight_loss')
tf.add_to_collection('losses', weight_decay)
return var | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _variable_with_weight_decay(name, shape, stddev, wd):\n var = variable(\n name,\n shape,\n initializer=tf.truncated_normal_initializer(stddev=stddev, dtype=tf.float32))\n if wd is not None:\n weight_decay = tf.multiply(tf.nn.l2_loss(var), wd, name='weight_loss')\n tf.ad... | [
"0.7514996",
"0.74297583",
"0.7427654",
"0.73323244",
"0.73323244",
"0.73174566",
"0.73167795",
"0.72758734",
"0.7265685",
"0.7255274",
"0.7237691",
"0.71960557",
"0.7104415",
"0.6970338",
"0.6799838",
"0.67324245",
"0.6716466",
"0.6677384",
"0.6564459",
"0.65503156",
"0.6548... | 0.7274419 | 8 |
Gets the maximum population size in a run | def get_max_run(run):
max = 0
max_i = 0
for i in range(800, 900):
if int(run[i]) > int(max):
max = run[i]
max_i = i
return max, max_i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max(self) -> int:\n return self._status['party_size'][1]",
"def maxContigLength(self):\n\t\tstats = self.scores()\n\t\treturn stats['largestContig']",
"def size(self):\n population = self._population\n if population is None:\n return 0\n else:\n return len(... | [
"0.69212866",
"0.68412",
"0.6781325",
"0.6757765",
"0.6755588",
"0.67328644",
"0.6716556",
"0.6716556",
"0.6714173",
"0.67063975",
"0.6704005",
"0.66716623",
"0.6659488",
"0.664889",
"0.66412914",
"0.6582964",
"0.65644836",
"0.6526689",
"0.65228426",
"0.6510454",
"0.64592606"... | 0.65834653 | 15 |
Remove comments and new line | def _PreParse(line: str) -> str:
line = line.rstrip("\n")
commentIndex = line.find("/")
# no comment found
if commentIndex == - 1:
return line
# truncate
return line[0:commentIndex] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_comments(self):\n new_lines = list()\n for line in self.lines:\n if ((not line.startswith(\"//\")) & (not line.isspace()) &\n (not line.startswith(\"/*\") & (not line.startswith(\"*/\")))):\n line = Parser.strip_line(line)\n new_li... | [
"0.8335459",
"0.7778711",
"0.7778711",
"0.76206267",
"0.7578965",
"0.74520445",
"0.731222",
"0.7271957",
"0.7263193",
"0.7231542",
"0.72007823",
"0.71217996",
"0.7110644",
"0.7033847",
"0.7028351",
"0.7017453",
"0.6964428",
"0.690862",
"0.68862206",
"0.6879813",
"0.6851116",
... | 0.58337724 | 85 |
Finds all restricted words and their conditions of the given string 1. strips special chars + spaces 2. finds all restricted words that are substrings of 'content' 3. finds condition info with the 'word id' for each restricted word in 'content' pairs each word with its condition info in a dict 4. returns json containin... | def get_restricted_words_conditions(content):
stripped_content = RestrictedWords.strip_content(content)
try:
restricted_words_dict = RestrictedWords.find_restricted_words(stripped_content)
except exc.SQLAlchemyError as err:
current_app.logger.debug(err.with_traceback(N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_restricted_words(content):\n restricted_words_obj = db.engine.execute(\"select * from restricted_word;\")\n restricted_words_dict = []\n for row in restricted_words_obj:\n if ' ' + row[1].upper().strip() + ' ' in content:\n restricted_words_dict.append({'id':... | [
"0.7591177",
"0.5981314",
"0.5789155",
"0.5605926",
"0.556458",
"0.5535346",
"0.54419225",
"0.54311794",
"0.5392195",
"0.5356077",
"0.5334967",
"0.5321158",
"0.53209925",
"0.5296926",
"0.5277071",
"0.52698666",
"0.5234821",
"0.5234098",
"0.52301294",
"0.522406",
"0.52131975",... | 0.71821505 | 1 |
Initialize RNN for learning the response metric. | def __init__(self, sess, **kwargs):
outputs = self._build_rnn(**kwargs)
x_anc, x_pos, x_neg, train, loss, embed_anc, embed_pos, embed_neg = outputs
self.anchor = x_anc
self.pos = x_pos
self.neg = x_neg
self.embed_anchor = embed_anc
self.embed_pos = embed_pos
self.embed_neg = embed_neg
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, config_dictionary): #completed\n self.mode = 'test'\n super(RNNLM_Tester,self).__init__(config_dictionary)\n self.check_keys(config_dictionary)\n \n self.weight_matrix_name = self.default_variable_define(config_dictionary, 'weight_matrix_name', arg_type='string... | [
"0.64805114",
"0.63750297",
"0.6325332",
"0.62590796",
"0.62460816",
"0.62377024",
"0.6220376",
"0.6186108",
"0.61828625",
"0.6161586",
"0.6160966",
"0.61445755",
"0.61436206",
"0.6118667",
"0.611263",
"0.6049739",
"0.60281134",
"0.5983516",
"0.59619683",
"0.5945069",
"0.5945... | 0.58027387 | 33 |
Gives RNN embedding of x_in. | def embed_rnn(x_in):
x_in_flat = tf.reshape(x_in, [batch_size*time_window, n_cells])
w_in = tf.get_variable("w_in", shape=[n_cells, hidden_layer_size],
initializer=tf.random_normal_initializer())
b_in = tf.get_variable("b_in", shape=[hidden_layer_size],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embed(self, x):\n if self.embedding is None:\n return x\n else:\n return self.embedding(x)",
"def add_embedding(self):\n #with tf.variable_scope(\"RNN\", reuse = tf.AUTO_REUSE):\n embeddings = tf.get_variable(\"embeddings\", initializer = self.pretrained_embe... | [
"0.6534581",
"0.64001054",
"0.6389327",
"0.63428414",
"0.63109326",
"0.6294589",
"0.6207175",
"0.617457",
"0.61326677",
"0.60898113",
"0.60811156",
"0.6067596",
"0.6050508",
"0.60446",
"0.6039447",
"0.602483",
"0.59878796",
"0.595955",
"0.59588444",
"0.5946203",
"0.59192175",... | 0.7203094 | 0 |
Test that moving a page with WAGTAILSIMPLETRANSLATION_SYNC_PAGE_TREE disabled doesn't apply to its translations. | def test_unmovable_translation_pages(self):
self.login()
# BlogIndex needs translated pages before child pages can be translated
self.fr_blog_index = self.en_blog_index.copy_for_translation(self.fr_locale)
self.de_blog_index = self.en_blog_index.copy_for_translation(self.de_locale)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_translation_count_in_context(self):\n self.login()\n\n # BlogIndex needs translated pages before child pages can be translated\n self.fr_blog_index = self.en_blog_index.copy_for_translation(self.fr_locale)\n self.de_blog_index = self.en_blog_index.copy_for_translation(self.de_l... | [
"0.6345104",
"0.63098896",
"0.5931454",
"0.5797064",
"0.57853794",
"0.57045573",
"0.568899",
"0.56284195",
"0.55567646",
"0.549087",
"0.5488178",
"0.54736084",
"0.54512286",
"0.5443057",
"0.53974795",
"0.53561413",
"0.5353193",
"0.53478533",
"0.5313943",
"0.5244605",
"0.52300... | 0.74702215 | 0 |
Test the context info is correct in the confirm_delete.html template. | def test_delete_confirmation_template(self):
self.login()
# BlogIndex needs translated pages before child pages can be translated
self.fr_blog_index = self.en_blog_index.copy_for_translation(self.fr_locale)
# Create a copy of the en_blog_post object as a translated page
self.fr_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_commentary_view_delete(self):\n \n test_response = self.client.get('/papers/commentary/1/delete')\n self.assertEqual(test_response.status_code, 200)\n self.assertTrue('object' in test_response.context) \n self.assertTemplateUsed(test_response, 'base.html')\n ... | [
"0.7784873",
"0.68129754",
"0.6680758",
"0.6495699",
"0.6452206",
"0.6397493",
"0.62806404",
"0.62697196",
"0.6256095",
"0.6196811",
"0.61854",
"0.6152297",
"0.6134135",
"0.6126343",
"0.60810006",
"0.6049257",
"0.6019478",
"0.6010736",
"0.5992513",
"0.5991509",
"0.59868765",
... | 0.6753589 | 2 |
Return the information for group type and name. | def get_group_types(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group_id_and_members(self, group_name, group_type=\"exclusivity\"):\n group_details = self.check_group_exists(group_name)\n\n try:\n if group_details is None:\n GeneralLogger.log_info(\"Creating group\")\n create_response = self.create_group(group_name... | [
"0.68182933",
"0.6790353",
"0.65697926",
"0.65398145",
"0.63632655",
"0.63375264",
"0.62905514",
"0.6250018",
"0.62018716",
"0.62002045",
"0.6187684",
"0.6180423",
"0.6180334",
"0.61587197",
"0.6105385",
"0.61001325",
"0.60850614",
"0.6070986",
"0.60471135",
"0.60231036",
"0.... | 0.716048 | 0 |
Set atoms as new list. | def set_atoms(self, atoms):
self.__atoms = atoms | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atoms(self,\n value: Union[List[Atom], Atoms, None]):\n self._atoms = Atoms(value) if value is not None else None",
"def _get_atoms(self):\n atoms = []\n invarioms = []\n\n for molecule in self.values():\n atoms += [atom for atom in molecule.atoms]\n ... | [
"0.64921635",
"0.62474805",
"0.6131976",
"0.6116909",
"0.6065645",
"0.59862775",
"0.5974076",
"0.59594613",
"0.59221935",
"0.5892651",
"0.5850862",
"0.5796815",
"0.5751149",
"0.5737333",
"0.56685233",
"0.5596711",
"0.55773705",
"0.5567906",
"0.5566636",
"0.5546234",
"0.553856... | 0.7304434 | 0 |
assume energies has energy units and return flux in flux units. | def get_dnde(spectrum,energies):
energies=units.tonumpy(energies,units.MeV)
dnde=SpectrumPlotter.get_dnde_mev(spectrum,energies)
return units.tosympy(dnde,units.ph/units.cm**2/units.s/units.MeV) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flux(self, x):\n return self.cal_spec.get_flux(self(x))",
"def ensemble_flux(self):\n return transition_matrices.flux_measure(self.ensemble_transition_matrix)",
"def flux():\n delta = 0.01 # film thickness, [dm]\n c = pre * 10 ** 2 / (R * tem) # total concentration calculated by ideal... | [
"0.69974995",
"0.6963157",
"0.68555844",
"0.6633164",
"0.66011536",
"0.654915",
"0.6457882",
"0.6343487",
"0.6338429",
"0.63239986",
"0.6266599",
"0.62627566",
"0.62520486",
"0.62454754",
"0.62452394",
"0.620821",
"0.6168983",
"0.61646634",
"0.6155122",
"0.61509204",
"0.61449... | 0.0 | -1 |
assume energies has energy units and return flux in flux units. | def get_dnde_error(spectrum,covariance_matrix,energies):
energies=units.tonumpy(energies,units.MeV)
dnde_error=SpectrumPlotter.get_dnde_error_mev(spectrum,covariance_matrix,energies)
return units.tosympy(dnde_error,units.ph/units.cm**2/units.s/units.MeV) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flux(self, x):\n return self.cal_spec.get_flux(self(x))",
"def ensemble_flux(self):\n return transition_matrices.flux_measure(self.ensemble_transition_matrix)",
"def flux():\n delta = 0.01 # film thickness, [dm]\n c = pre * 10 ** 2 / (R * tem) # total concentration calculated by ideal... | [
"0.6992403",
"0.6960369",
"0.68521965",
"0.66305506",
"0.65944445",
"0.6545115",
"0.64580876",
"0.6340136",
"0.6337281",
"0.63203204",
"0.62660766",
"0.6262048",
"0.62566465",
"0.62435746",
"0.62399626",
"0.6207805",
"0.6169491",
"0.616759",
"0.6151849",
"0.6145921",
"0.61428... | 0.0 | -1 |
asume energy in mev and return flux in units of ph/cm2/s/MeV. | def get_dnde_mev(spectrum,energies):
if isinstance(spectrum,dict):
return SpectrumPlotter.get_dnde_mev(dict_to_spectrum(spectrum),energies)
elif isinstance(spectrum,pyLikelihood.Function):
return SpectrumPlotter.get_dnde_mev_gtlike(spectrum,energies)
elif isinstance(spect... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def V2E(V):\n# for v in m/s returns energy in meV\n return 5.227e-6*V*V",
"def get_energy(self):\n return self.momentum*self.momentum/(2*self.mass)",
"def E2V(E):\n# for energy in mev returns velocity in m/s\n return sqrt(E/5.227e-6)",
"def energy(self):\n nocc, ntot, gmo, e = self.nocc... | [
"0.6786896",
"0.6494946",
"0.6491758",
"0.6481541",
"0.64616996",
"0.64482963",
"0.6383973",
"0.62659645",
"0.62378734",
"0.61247027",
"0.611011",
"0.6085963",
"0.6080484",
"0.6068067",
"0.6065201",
"0.6053852",
"0.59490985",
"0.5922774",
"0.59090346",
"0.5907285",
"0.5899263... | 0.0 | -1 |
asume energy in mev and return flux in units of ph/cm2/s/MeV. | def get_dnde_error_mev_gtlike(spectrum,covariance_matrix,energies):
from . models import gtlike_unscale_all_parameters
spectrum = gtlike_unscale_all_parameters(spectrum)
dnde_err = np.empty_like(energies)
for i,energy in enumerate(energies):
# method taken from pyLikelihood... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def V2E(V):\n# for v in m/s returns energy in meV\n return 5.227e-6*V*V",
"def get_energy(self):\n return self.momentum*self.momentum/(2*self.mass)",
"def E2V(E):\n# for energy in mev returns velocity in m/s\n return sqrt(E/5.227e-6)",
"def energy(self):\n nocc, ntot, gmo, e = self.nocc... | [
"0.6786505",
"0.6493319",
"0.6490341",
"0.6479747",
"0.64619136",
"0.644653",
"0.63808095",
"0.6266306",
"0.6239441",
"0.61250776",
"0.61099756",
"0.6086027",
"0.6079539",
"0.6066857",
"0.6064897",
"0.6054837",
"0.5947557",
"0.5922441",
"0.59097433",
"0.59057546",
"0.58995396... | 0.0 | -1 |
Choose the peaks corresponding to point x,y | def select_x_y( cf, x, y, step=0.25):
so = np.sin( np.radians( cf.omega ) )
co = np.cos( np.radians( cf.omega ) )
dty_calc_int = np.round((x*co + y*so)/step).astype(int)
dtyi = np.round( cf.dty/step ).astype(int)
icf = cf.copy()
icf.filter( dtyi == dty_calc_int )
return icf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peaks(self, **kwargs):\n peaks, properties = self.peak_indices(**kwargs)\n return self.xs[peaks], properties",
"def peak_indices(self, **kwargs):\n kwarg_defaults = {\n 'width': 5, # ensure small spikes are ignored\n }\n kwarg_defaults.update(kwargs)\n re... | [
"0.70081353",
"0.69391865",
"0.68195677",
"0.6759043",
"0.6710816",
"0.6409172",
"0.63777024",
"0.63564837",
"0.63548744",
"0.6336582",
"0.63109726",
"0.62950945",
"0.62950677",
"0.62950677",
"0.62231237",
"0.62030494",
"0.6187273",
"0.61756575",
"0.61653316",
"0.6165042",
"0... | 0.0 | -1 |
The view should only operate on profile items belonging to the specified topic. | def test_get_queryset(list_entry_factory, profile_item_factory):
item = profile_item_factory()
list_entry_factory(profile_item=item)
list_entry_factory()
view = views.ListEntryListView()
view.kwargs = {"pk": item.pk}
assert list(view.get_queryset()) == list(item.list_entries.all()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return models.ProfileItem.objects.filter(topic=self.kwargs.get(\"pk\"))",
"def get_queryset(self):\n return models.ProfileTopic.objects.filter(\n profile__pk=self.kwargs.get(\"pk\")\n )",
"def get_queryset(self, request):\n qs = super(TopicAdmin,... | [
"0.7220275",
"0.67885256",
"0.6610144",
"0.5929561",
"0.591494",
"0.5904914",
"0.5812586",
"0.5808425",
"0.5755044",
"0.57337576",
"0.57100403",
"0.5693986",
"0.56728226",
"0.5651503",
"0.56485724",
"0.56184536",
"0.56066394",
"0.5564422",
"0.5554585",
"0.5519211",
"0.5512079... | 0.0 | -1 |
Checks whether the given object is an estimator of sklearnlibrary (Code from sklearn.base.clone()) | def _isSklearnEstimator(self, estimator):
return hasattr(estimator, 'get_params') and not isinstance(estimator, type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sklearn_estimator(obj):\n if not isclass(obj):\n obj = type(obj)\n\n is_in_sklearn = issubclass(obj, SklearnBaseEstimator)\n is_in_sktime = issubclass(obj, BaseObject)\n\n is_sklearn_est = is_in_sklearn and not is_in_sktime\n return is_sklearn_est",
"def is_estimator(obj):\n i... | [
"0.8051364",
"0.78775334",
"0.76269525",
"0.7348721",
"0.7162278",
"0.696898",
"0.6945187",
"0.6865845",
"0.6823968",
"0.6768385",
"0.67387277",
"0.6689152",
"0.63498086",
"0.6218306",
"0.6176209",
"0.60381263",
"0.59505427",
"0.59373426",
"0.5926252",
"0.5922796",
"0.5903188... | 0.74265784 | 3 |
Initialize the ball and its starting position | def __init__(self, screen):
self.screen = screen
#Load the ball image
self.image = pygame.image.load('Images/ball.bmp')
self.rect = self.image.get_rect()
self.screen_rect = screen.get_rect()
#Start ball in center
self.rect.centerx = self.screen_rect.centerx
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pos=(0, 0)):\n super().__init__() # Call 'turtle' initiation\n self.penup() # Stop displaying trail\n self.shapesize(stretch_wid=1, stretch_len=1) # Set dimensions of ball object to same height and width\n ... | [
"0.7526015",
"0.74091625",
"0.729483",
"0.7253316",
"0.71886206",
"0.70889515",
"0.70707536",
"0.7052182",
"0.6984171",
"0.69805896",
"0.6899886",
"0.68200874",
"0.6811955",
"0.6733119",
"0.67150885",
"0.66971225",
"0.6684712",
"0.6611438",
"0.66027737",
"0.6567602",
"0.65643... | 0.7121195 | 5 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(optimizer, lr_factor, epoch):
#lr = args.lr * (0.1 ** (epoch // 30))
print('the learning rate is set to {0:.5f}'.format(lr_factor[epoch]*args.lr))
for param_group in optimizer.param_groups:
param_group['lr'] = lr_factor[epoch]*args.lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.7912448",
"0.7905818",
"0.78496826",
"0.77745205",
"0.77331823",
"0.77298284",
"0.77224445",
"0.77215135",
"0.77187204",
"0.77081376",
"0.7692789",
"0.7673609",
"0.7664976",
"0.7664976",
"0.7664976",
"0.7654216",
"0.76410955",
"0.76391095",
"0.76370764",
"0.7625343",
"0.76... | 0.75664645 | 35 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Loads the Inception graph and classes | def loadInception(self):
self.reqsize = self.confs["Classifier"]["ImageSize"]
with open(self.confs["Classifier"]["NetworkPath"] + self.confs["Classifier"]["InceptionGraph"], mode='rb') as f:
ncsGraphFile = f.read()
self.allocateGraph(ncsGraphFile)
with open(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_graph():\n\t# Creates graph from saved graph_def.pb.\n\twith tf.gfile.FastGFile('./models/inception_v4.pb', 'rb') as f:\n\t\tgraph_def = tf.GraphDef()\n\t\tgraph_def.ParseFromString(f.read())\n\t\t_ = tf.import_graph_def(graph_def, name='')",
"def load_model(self):\n self.pred_net.load((self.save_p... | [
"0.6511181",
"0.64528036",
"0.64337915",
"0.61772007",
"0.61719984",
"0.61360323",
"0.6123919",
"0.6072896",
"0.60557735",
"0.60510826",
"0.6048289",
"0.601576",
"0.5998613",
"0.5986519",
"0.5985819",
"0.5976342",
"0.5969458",
"0.5956845",
"0.5922292",
"0.58771574",
"0.586822... | 0.8139506 | 0 |
Go to test page | def setUp(self):
self.driver.get('http://taqc-opencart.epizy.com/') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_homepage(self):\n rv = self.app.get('/')\n assert 'Enter your url here' in rv.data",
"def test_home(self):\n self.selenium.get('{}/'.format(self.live_server_url))",
"def go(self, url):\n self.driver.get(url)",
"def test_first_page_passes(self):\n\n self.page.open_s... | [
"0.7551494",
"0.7259827",
"0.7064684",
"0.70475477",
"0.7046293",
"0.6929917",
"0.6924912",
"0.6918897",
"0.69008166",
"0.68792135",
"0.68698084",
"0.68595827",
"0.6844422",
"0.68273646",
"0.6810299",
"0.6784199",
"0.67750263",
"0.67750263",
"0.67746055",
"0.6754976",
"0.6750... | 0.0 | -1 |
Return the index.html page of the Password Universe website. | def index():
return render_template("index.html"), 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_page():\n \n return render_template(\"index.html\")",
"def index_page():\n\n return render_template(\"index.html\")",
"def index_page():\n\n return render_template(\"index.html\")",
"def index_page():\n\n return render_template(\"index.html\")",
"def main():\n return render_temp... | [
"0.71260875",
"0.7054246",
"0.7054246",
"0.7054246",
"0.70494664",
"0.70494664",
"0.70068157",
"0.70067465",
"0.7004832",
"0.69887996",
"0.69621223",
"0.69468725",
"0.6938778",
"0.6937886",
"0.6933447",
"0.69050145",
"0.6891349",
"0.6890243",
"0.6870681",
"0.6870681",
"0.6870... | 0.6891909 | 16 |
Test that root does not have mc_select_envs (it does not make sense to exclude everything) | def test_root_no_mc_select_envs():
with raises(AttributeError) as exinfo:
@mc_config(ef, load_now=True)
def config(rt):
rt.mc_select_envs(exclude=[dev1])
assert "'McConfigRoot' object has no attribute 'mc_select_envs'" in str(exinfo.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mc_config_root_no_mc_select_envs():\n\n with raises(AttributeError) as exinfo:\n with McConfigRoot() as rt:\n rt.mc_select_envs()\n\n assert \"'McConfigRoot' object has no attribute 'mc_select_envs'\" in str(exinfo.value)",
"def test_defaults():\n config = Config(\n env... | [
"0.7592168",
"0.61023694",
"0.59756315",
"0.59184957",
"0.591061",
"0.59063035",
"0.5830476",
"0.5829531",
"0.57927436",
"0.57542735",
"0.5740126",
"0.573774",
"0.5733296",
"0.57254755",
"0.57113105",
"0.5710605",
"0.5707892",
"0.569747",
"0.56814545",
"0.5673697",
"0.5667233... | 0.796145 | 0 |
Wrapper around ndarray aliasing hack. >>> x = array([1.0, 2.0, 3.0, 4.0, 5.0]) >>> array_equal(x, _deserialize_byte_array(x.shape, x.data, 0)) True >>> x = array([1.0, 2.0, 3.0, 4.0]).reshape(2,2) >>> array_equal(x, _deserialize_byte_array(x.shape, x.data, 0)) True | def _deserialize_byte_array(shape, ba, offset):
ar = ndarray(shape=shape, buffer=ba, offset=offset, dtype="float64",
order='C')
return ar.copy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arrays_are_same(a1, a2):\n try:\n return a1.__array_interface__['data'] == a2.__array_interface__['data'] \\\n and a1.strides == a2.strides\n except AttributeError:\n return False",
"def test_conversion(backend):\n\n x = np.random.rand(10, 10)\n x_b = backend.from_numpy(x... | [
"0.6361858",
"0.6245808",
"0.6227964",
"0.6193836",
"0.6155957",
"0.60416263",
"0.59381014",
"0.59291565",
"0.5817922",
"0.57907975",
"0.5745442",
"0.57209456",
"0.5706878",
"0.568244",
"0.568091",
"0.5647656",
"0.56448275",
"0.56415445",
"0.5618394",
"0.56103987",
"0.5607068... | 0.5615291 | 19 |
Deserialize a double vector from a mutually understood format. >>> x = array([1.0, 2.0, 3.0, 4.0, 1.0, 0.0, 0.0]) >>> array_equal(x, _deserialize_double_vector(_serialize_double_vector(x))) True | def _deserialize_double_vector(ba):
if type(ba) != bytearray:
raise TypeError("_deserialize_double_vector called on a %s; "
"wanted bytearray" % type(ba))
if len(ba) < 16:
raise TypeError("_deserialize_double_vector called on a %d-byte array, "
"which is too short... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _serialize_double_vector(v):\n if type(v) != ndarray:\n raise TypeError(\"_serialize_double_vector called on a %s; \"\n \"wanted ndarray\" % type(v))\n if v.dtype != float64:\n raise TypeError(\"_serialize_double_vector called on an ndarray of %s; \"\n \"wanted... | [
"0.6707795",
"0.6113284",
"0.5786269",
"0.56795543",
"0.5495888",
"0.54919577",
"0.5456707",
"0.5354497",
"0.53364736",
"0.5333154",
"0.53231746",
"0.53171945",
"0.52942795",
"0.5292617",
"0.52296126",
"0.52151054",
"0.5191334",
"0.50949425",
"0.50904024",
"0.5087779",
"0.504... | 0.7254384 | 0 |
Check that x is a onedimensional vector of the right shape. This is a temporary hackaround until I actually implement bulk predict. | def _linear_predictor_typecheck(x, coeffs):
if type(x) == ndarray:
if x.ndim == 1:
if x.shape == coeffs.shape:
pass
else:
raise RuntimeError("Got array of %d elements; wanted %d"
% (shape(x)[0], shape(coeffs)[0]))
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vector(x):\r\n return len(x.shape) == 1",
"def is_vec(x):\n return x.ndim == 1 or (x.ndim == 2 and \n (x.shape[0] == 1 or x.shape[1] == 1))",
"def is_line_vec(x):\n return x.ndim == 1",
"def _check_shape(self, X):\n return all([X.shape[i] == self.train_shape[i] for i in range(2)... | [
"0.7342536",
"0.6889477",
"0.6531228",
"0.63374406",
"0.61370045",
"0.61367226",
"0.6098564",
"0.607217",
"0.60542035",
"0.59740096",
"0.59663516",
"0.59615034",
"0.5911842",
"0.5901362",
"0.5886204",
"0.58270955",
"0.57948434",
"0.5725792",
"0.5725418",
"0.5720275",
"0.56826... | 0.6094588 | 7 |
Stays the same for a given instance. | def _get_params_filepath(self):
return os.path.join(self.workdir, "params.txt") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance(self, instance):\n self._instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, ins... | [
"0.56533366",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.54724264",
"0.5452471",
"0.5417543",
"0.5372319",
"0.5335833",
"0.5326472",
"0.51769525",
"0.5175158",
"0.5168104",
"0.5144223",
"0.51336",
"0.5116122",
"0.5110856",
"0.5081676",
"0.5040539... | 0.0 | -1 |
Stays the same for a given instance. | def _get_conv_filepath(self):
return os.path.join(self.workdir, "conv.txt") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance(self, instance):\n self._instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, ins... | [
"0.56533366",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.54724264",
"0.5452471",
"0.5417543",
"0.5372319",
"0.5335833",
"0.5326472",
"0.51769525",
"0.5175158",
"0.5168104",
"0.5144223",
"0.51336",
"0.5116122",
"0.5110856",
"0.5081676",
"0.5040539... | 0.0 | -1 |
Stays the same for a given instance. | def _get_psf_filepath(self):
return os.path.join(self.workdir, "default.psf") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance(self, instance):\n self._instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, instance):\n self.instance = instance",
"def set_instance(self, ins... | [
"0.56533366",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.55378175",
"0.54724264",
"0.5452471",
"0.5417543",
"0.5372319",
"0.5335833",
"0.5326472",
"0.51769525",
"0.5175158",
"0.5168104",
"0.5144223",
"0.51336",
"0.5116122",
"0.5110856",
"0.5081676",
"0.5040539... | 0.0 | -1 |
Clip bboxes to fit the image shape. | def bbox_clip(bboxes,img_shape):
assert bboxes.shape[-1] % 4 == 0
clipped_bboxes = np.empty_like(bboxes,dtype=bboxes.dtype)
clipped_bboxes[...,0::2] = np.maximum(np.minimum(bboxes[...,0::2],img_shape[1]-1),0)
clipped_bboxes[...,1::2] = np.maximum(np.minimum(bboxes[...,1::2],img_shape[0]-1),0)
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_bboxes(self, bboxes, max_width, max_height):\n with tf.variable_scope('clip_bboxes'):\n max_width = tf.cast(max_width, tf.float32)\n max_height = tf.cast(max_height, tf.float32)\n\n y, x, h, w = tf.split(bboxes, 4, axis=1)\n\n minx = tf.minimum(tf.maximum... | [
"0.778881",
"0.7772928",
"0.7660154",
"0.75552136",
"0.75552136",
"0.7549674",
"0.7549674",
"0.7529571",
"0.7487794",
"0.7414111",
"0.74131626",
"0.7376993",
"0.72794527",
"0.72648734",
"0.7036597",
"0.7036597",
"0.7002851",
"0.69426197",
"0.69376284",
"0.6869409",
"0.6854082... | 0.8199216 | 0 |
Show an index page. | def index_page():
return render_template("index.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_index_page():\n\n return render_template('index.html')",
"def index():\n return render_template(\"index.html\",\n title='Index')",
"def index():\n return render_template('pages/index.html', isNav=True)",
"def index():\n return render_template('index.html')",... | [
"0.8531908",
"0.80338854",
"0.7943412",
"0.77842605",
"0.77842605",
"0.7766452",
"0.7744886",
"0.76850814",
"0.76816297",
"0.7678797",
"0.7672546",
"0.7672546",
"0.7657335",
"0.76573086",
"0.7628134",
"0.76141024",
"0.76105523",
"0.75957036",
"0.75957036",
"0.75957036",
"0.75... | 0.7667954 | 14 |
Constructor to store the first name,last name and health of a patient instance. | def __init__(self, first_name, last_name, health):
super(Patient, self).__init__(first_name, last_name)
if health < 0:
"""Health points should not go below zero."""
self.health = 0
elif health > 100:
"""Health points can't be more than 100."""
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, firstname, lastname, healthstatus, status):\n self.firstname = firstname\n self.lastname = lastname\n self.healthstatus = healthstatus\n self.status = status",
"def __init__(self, patient_number):\n logging.info(\"Creating patient {}...\".format(patient_numbe... | [
"0.71669364",
"0.65691054",
"0.65114737",
"0.64892024",
"0.6474344",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64555013",
"0.64144146",
"0.63724023",
"0.6336638",
"0.6305234",
"0.6273053",
"0.6251734",
"0.62514305",
"... | 0.7335338 | 0 |
Get the entry for the given row and column | def get_entry(self, row_index: int, column_header: str) -> str:
return self.get_entry_from_row(self.content[row_index], column_header) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCell(self, row, column):\n\t\t\t\t\n\t\t\t\tif ((row is None) or (column is None)):\n\t\t\t\t\traise NotImplementedError()\n\n\t\t\t\treturn self.thing[self.convertColumn(row = row, column = column)]",
"def get_cell(self, row, column):\n return self.sudoku_matrix[row][column]",
"def entry(self, i... | [
"0.7507318",
"0.7456228",
"0.74014276",
"0.7325261",
"0.72512394",
"0.7212305",
"0.71460277",
"0.7102703",
"0.7090901",
"0.7063147",
"0.7022075",
"0.7019966",
"0.7002386",
"0.6979934",
"0.6979934",
"0.6979934",
"0.69701535",
"0.6965903",
"0.6949171",
"0.69463885",
"0.6943153"... | 0.7086427 | 9 |
Get the entry belonging to the given column from the given row | def get_entry_from_row(self, row: [str], column_header: str) -> str:
column_index = self.header.index(column_header)
return row[column_index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_row(self, row):\n \n return self.sudoku_matrix[row]",
"def get(self, column_name, row_index):\n self.check_for_column(column_name)\n return self.data[column_name][row_index]",
"def get_value(self, row, colName):\n\t\treturn self[row][self._columns[colName]]",
"def getItem(... | [
"0.7296542",
"0.7152905",
"0.71496636",
"0.7088844",
"0.6985232",
"0.6937727",
"0.6935333",
"0.6747563",
"0.6728058",
"0.6713525",
"0.6684846",
"0.6662804",
"0.66605157",
"0.66015303",
"0.65883416",
"0.65693355",
"0.6501107",
"0.6488285",
"0.6462475",
"0.6456663",
"0.6439121"... | 0.78629786 | 0 |
very very naive pluralize, just adds s | def pluralize(num, string, precision=2):
if round(Decimal(num), precision) > round(Decimal("1.00"), precision):
return "%ss" % string
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pluralize(n, s):\n if n == 1:\n return f'1 {s}'\n else:\n return f'{n} {s}s'",
"def plural(n):\n\n if n == 1:\n return ''\n else:\n return 's'",
"def plural(n):\n if n != 1:\n return \"s\"\n else:\n return \"\"",
"def plural(unit, amount):\n ... | [
"0.79829484",
"0.7915699",
"0.78340757",
"0.7617053",
"0.7535224",
"0.730487",
"0.70135933",
"0.698556",
"0.68743074",
"0.68722934",
"0.6788626",
"0.67601335",
"0.6614811",
"0.66109085",
"0.6584668",
"0.651783",
"0.649231",
"0.64409363",
"0.64108646",
"0.63652754",
"0.6350769... | 0.6653324 | 12 |
gets the value from the configuration object | def get_item(self, key):
return self.config[key] if key in self.config.keys() else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_value(self, name):\r\n if name in self.config_values:\r\n return self.config_values[name]",
"def _get_config_value(self, section, key):\n return config.get(section, key)",
"def value(self) -> str:\n return self._config.get('value')",
"def get_value(self, key):\n... | [
"0.77354336",
"0.7606471",
"0.7420668",
"0.7387481",
"0.7344595",
"0.71818465",
"0.71232295",
"0.70952135",
"0.7087758",
"0.70867974",
"0.7083559",
"0.70619535",
"0.7059382",
"0.70289695",
"0.6982438",
"0.69510937",
"0.6898194",
"0.6863989",
"0.68603384",
"0.6844882",
"0.6830... | 0.6711421 | 33 |
u"""Divide gray image into blocks. | def grayimage2block(img, size):
image_height = int(img.shape[0])
image_width = int(img.shape[1])
block_height = int(size[0])
block_width = int(size[1])
#print(image_height, image_width, block_height, block_width)
if image_height%block_height != 0 or image_width%block_width != 0:
print('Please give an approp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grayblock2image(blocks):\n\tblock_y, block_x, block_height, block_width = blocks.shape\n\t\n\timage = np.empty((0,block_x*block_width), int)\n\n\tfor x in blocks:\n\t\tcol_block = np.empty((block_height,0), int)\n\t\tfor block in x:\n\t\t\tcol_block = np.concatenate([col_block, block], axis=1)\n\t\timage = np.... | [
"0.6731676",
"0.6658642",
"0.6568362",
"0.606704",
"0.59839576",
"0.5975712",
"0.59656936",
"0.5910308",
"0.58338696",
"0.58223164",
"0.58062303",
"0.5800758",
"0.5782312",
"0.57337934",
"0.56755203",
"0.5625667",
"0.562036",
"0.5574986",
"0.55627763",
"0.55623704",
"0.555712... | 0.7180591 | 0 |
u"""Divide color image into blocks. | def colorimage2block(img, size):
image_height = int(img.shape[0])
image_width = int(img.shape[1])
block_height = int(size[0])
block_width = int(size[1])
color_num = int(img.shape[2])
#print(image_height, image_width, block_height, block_width)
if image_height%block_height != 0 or image_width%block_width != 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getparts(image, block_len):\n img = image.convert('L') if image.mode != 'L' else image\n w, h = img.size \n parts = []\n # Bluring image for abandoning image details and noise.\n global opt\n for n in range(int(opt.imblev)):\n img = img.filter(ImageFilter.SMOOTH_MORE)\n # Converting image to custom palette\n ... | [
"0.65155435",
"0.624646",
"0.6239561",
"0.62394613",
"0.6135836",
"0.6135836",
"0.60933346",
"0.6022509",
"0.59738773",
"0.59429914",
"0.59008485",
"0.58460575",
"0.58390707",
"0.583048",
"0.57971483",
"0.5779264",
"0.5772563",
"0.5752157",
"0.5730624",
"0.57300776",
"0.57203... | 0.7383179 | 0 |
u"""Get only Y from YCC image. | def get_y(img):
height = img.shape[0]
width = img.shape[1]
y_data = np.empty([height,width])
for i in np.arange(height):
for j in np.arange(width):
y_data[i][j] = img[i][j][0]
return y_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cy(y):\n return pic_height + ch(y - global_min_y)",
"def get_y():\n metadata = get_dataset_metadata(['shape_y', 'type_y'])\n return get_ndarray(name='y_original',\n arr_shape=metadata['shape_y'],\n arr_type=metadata['type_y'])",
"def Y_ret(img):\r\n ... | [
"0.65909845",
"0.6411533",
"0.63502985",
"0.6156765",
"0.60780954",
"0.6013728",
"0.6013346",
"0.5999833",
"0.59865606",
"0.5937645",
"0.5896112",
"0.58949685",
"0.5894247",
"0.5873268",
"0.585955",
"0.58450264",
"0.57808733",
"0.5779396",
"0.5777858",
"0.5773827",
"0.5767510... | 0.6605728 | 0 |
Get str representation of Timestamp obj. | def to_str(self):
return self.PATTERN % (self.hours, self.minutes, self.seconds, self.milliseconds) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp_str(self,\n tz: Optional[datetime.tzinfo] = None,\n timespec: str = 'auto') -> str:\n dt = datetime.datetime.fromtimestamp(self.timestamp / 1000, tz)\n dt += datetime.timedelta(microseconds=self.timestamp % 1000000)\n return dt.isoformat(... | [
"0.7700884",
"0.7622101",
"0.71152836",
"0.6918671",
"0.68974334",
"0.68974334",
"0.68914753",
"0.6861705",
"0.68483186",
"0.68179756",
"0.68154323",
"0.67821974",
"0.67821974",
"0.6756783",
"0.674591",
"0.668406",
"0.66679394",
"0.6653605",
"0.66450053",
"0.6610342",
"0.6592... | 0.6435426 | 28 |
Sets the learning rate to the initial LR decayed by D every E epochs | def adjust_learning_rate(opt, epoch):
d, e = args.lr_decay
lr = args.lr * (d ** -(epoch // e))
for param_group in opt.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate_D(start_lr, optimizer, epoch):\n #lr = start_lr * (0.1 ** (epoch // 30))\n lr = start_lr * (0.3 ** (epoch // 5))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def update_learning_rate(self) -> None:\n self.epsilon = self.initial_epsilon /... | [
"0.79788506",
"0.7453891",
"0.7453891",
"0.74239624",
"0.737331",
"0.7358115",
"0.73497933",
"0.73324907",
"0.72884756",
"0.7259489",
"0.7258635",
"0.72108644",
"0.7198025",
"0.71921885",
"0.71896166",
"0.717072",
"0.71688414",
"0.7167585",
"0.71649855",
"0.7160978",
"0.71523... | 0.7132064 | 24 |
Takes a dictionary and writes it to JSON file. | def write_json(json_file, in_dict):
with open(json_file, "w+") as fp:
json.dump(in_dict, fp, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_write(path, dictionary):\n json_output = json.dumps(dictionary, indent=4)\n with open(path, \"w\", encoding=\"utf-8\") as f:\n f.write(json_output)",
"def save_to_json(dict, file):\n with open(file, 'w') as f:\n json.dump(dict, f, indent=2)\n return file",
"def write_json(dic... | [
"0.8643125",
"0.86294276",
"0.85052043",
"0.85014194",
"0.841116",
"0.81844026",
"0.81315315",
"0.81022525",
"0.80936927",
"0.8084935",
"0.807246",
"0.80614495",
"0.8059166",
"0.795476",
"0.78906167",
"0.78708726",
"0.7823375",
"0.7806617",
"0.78030896",
"0.77584386",
"0.7751... | 0.8544851 | 2 |
Takes a JSON file and returns a dictionary | def read_json(json_file):
with open(json_file, "r") as fp:
data = json.load(fp)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_json(json_file: str) -> dict:\n json_data = {}\n\n if not os.path.isfile(json_file):\n error_log(os.path.basename(json_file) + ' does not exist.')\n sys.exit(1)\n\n with open(json_file) as f:\n json_data = json.load(f)\n\n return json_data",
"def dictionary_from_json_fi... | [
"0.8422568",
"0.8301822",
"0.8219417",
"0.8140747",
"0.80515075",
"0.80420357",
"0.7942872",
"0.7899943",
"0.7843489",
"0.78176135",
"0.7786652",
"0.77566785",
"0.77397615",
"0.7688224",
"0.7687582",
"0.7679812",
"0.7628684",
"0.7620761",
"0.7614746",
"0.7612159",
"0.7604614"... | 0.76727957 | 16 |
The min played from all songs | def songminplay():
played = Song.objects.filter(score__gte=0).aggregate(Min('played'))
if played['played__min'] is None:
result = 0
else:
result = played['played__min']
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_players(self):\n return self._min_players",
"def findQueued(self):\r\n songs = Queue.objects.filter(played=False, playtime__lte = datetime.datetime.now()).order_by('-priority', 'id')\r\n if not songs: # Since OR queries have been problematic on production server earlier, we do this h... | [
"0.65163004",
"0.6432951",
"0.62016034",
"0.6162245",
"0.61431795",
"0.61414146",
"0.6057275",
"0.60077447",
"0.58519214",
"0.57888436",
"0.57389116",
"0.57225204",
"0.57199043",
"0.57173324",
"0.5711706",
"0.57039195",
"0.5695126",
"0.5690211",
"0.56678027",
"0.5665134",
"0.... | 0.7974759 | 0 |
Remove and return top element of Stack self. Assume Stack self is not emp. >>> s = Stack() >>> s.add(5) >>> s.add(7) >>> s.remove() 7 | def remove(self) -> object:
return self._contains.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self):\n return self.stack_list.pop()",
"def Pop(self):\n # Alternativly use built-in pop()\n #return self.list.pop()\n top = self.list[len(self.list) - 1]\n self.list.remove(top)\n return top",
"def pop(self) -> Any:\r\n if self.is_empty():\r\n raise IndexErro... | [
"0.80629367",
"0.7931176",
"0.7917126",
"0.7774958",
"0.7739002",
"0.7729922",
"0.77208126",
"0.76893616",
"0.7678212",
"0.7652607",
"0.76382715",
"0.7633024",
"0.761818",
"0.760966",
"0.75917655",
"0.75876814",
"0.754995",
"0.75227964",
"0.75086695",
"0.74909174",
"0.7467124... | 0.0 | -1 |
Return whether Stack self is empty. >>> s = Stack() >>> s.is_empty() True >>> s.add(5) >>> s.is_empty() False | def is_empty(self) -> bool:
return len(self._contains) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.the_stack) == 0",
"def is_empty(self): #checks to see if stack is empty or not\n if self.num_items == 0:\n return True\n else:\n return False",
"def is_empty(self):\n return len(self.stack) == 0",
"def is_e... | [
"0.855077",
"0.8483018",
"0.84812194",
"0.83824253",
"0.8365015",
"0.8311074",
"0.82961464",
"0.8262513",
"0.8237809",
"0.81858057",
"0.81858057",
"0.8162426",
"0.81405157",
"0.81287754",
"0.81247586",
"0.81058663",
"0.8104045",
"0.8104045",
"0.8080431",
"0.80754447",
"0.8036... | 0.0 | -1 |
takes the sequence column of a wga.bed and returns true if INDEL is reference specific | def unique_to_ref(sequences):
ref = sequences[0]
outgroups = sequences[1:]
# check for seq conservation in outgroup
for spp in outgroups:
if spp.count('-') != outgroups[0].count('-'):
return False
# check ref not same as outgroups
if ref.count('-') == outgroups[0].count('-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_refseq(val):\n return refseq_regexp.match(val)",
"def is_legit_DNA_sequence(record_seq: str) -> bool:\n nts = {\"A\", \"G\", \"T\", \"C\", \"N\"}\n seq_symbols = {s.upper() for s in record_seq}\n return seq_symbols.issubset(nts)",
"def __contains__(self, seq):\n return bool(libhts.fai... | [
"0.6160675",
"0.5821415",
"0.57303554",
"0.56204385",
"0.55308646",
"0.55237347",
"0.5521176",
"0.5458686",
"0.5451818",
"0.53763634",
"0.53569275",
"0.5340711",
"0.53387123",
"0.5326899",
"0.529347",
"0.5272458",
"0.52553964",
"0.52283573",
"0.5220181",
"0.52161914",
"0.5202... | 0.563189 | 3 |
Reset all of the InferenceEngine's caches. | def reset(self):
self.cache = EvaluationCache(
loop=self.loop,
keycalc=self.compute_ref,
keytransform=self.get_actual_ref
)
self.reference_map = {}
self.constructors = {
prim: cons()
for prim, cons in self._constructors.items()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n\n self.simple_cache = {}\n self.complex_cache = {}\n self.target_cache = {}",
"def reset_cache(self):\n self.izx.reset_cache()\n self.ezx.reset_cache()",
"def reset_cache(self):\n self.cache = [None] * self.n_layers\n self.offset = 0\n ... | [
"0.7868653",
"0.7644266",
"0.74462676",
"0.70547193",
"0.7020653",
"0.69841766",
"0.6940243",
"0.6937187",
"0.6867262",
"0.68052256",
"0.672163",
"0.67167383",
"0.6698589",
"0.6693518",
"0.66860414",
"0.6682639",
"0.66790634",
"0.6634859",
"0.6626176",
"0.6604577",
"0.6604063... | 0.7343298 | 3 |
App route function for the homepage. | def home():
# Detect login status
login_status = None
if 'email' in login_session:
login_status = True
# Generate state token for Google Sign-In
state = ''.join(random.choice(string.ascii_uppercase + string.digits)
for x in range(32))
login_session['state'] = state
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n logging.info('Entering route: HOME')\n\n logging.info('Rendering template: main.html')\n return render_template('main.html')",
"def go_home(request):\n\n url = request.route_url('home', _app_url=get_app_url(request))\n return HTTPFound(location=url)",
"def homepage():\n return r... | [
"0.78022426",
"0.7568384",
"0.7434946",
"0.735678",
"0.7213179",
"0.7199198",
"0.7145265",
"0.71114254",
"0.7109418",
"0.7098216",
"0.709711",
"0.70954907",
"0.70900023",
"0.70505875",
"0.70505875",
"0.70505875",
"0.70505875",
"0.70505875",
"0.70505875",
"0.7038412",
"0.70345... | 0.0 | -1 |
Forward propgate the input through the NN and output the activations of the last layer. | def predict(self, input):
input = input.reshape((input.shape[0], 1))
return self.feedforward(input) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_propagate(self, inputs):\n\n activations = inputs\n self.activations[0] = inputs\n\n for i, w in enumerate(self.weights):\n # Calculate the net inputs\n net_inputs = np.dot(activations, w)\n\n # Calculate the activations\n activations = self._sigmoid(net_inputs)\n self... | [
"0.7504301",
"0.7402312",
"0.73639065",
"0.7323897",
"0.73121256",
"0.7260464",
"0.7260464",
"0.7221287",
"0.72073746",
"0.7159437",
"0.7155914",
"0.71521133",
"0.71360034",
"0.7127911",
"0.7115368",
"0.70961785",
"0.7093189",
"0.7084813",
"0.7078287",
"0.7044685",
"0.7044489... | 0.0 | -1 |
Gets RxCUI for a given drug. | def get_rxcui(drug_id, id_type):
if id_type not in ['name', 'ndc']:
raise ValueError("Sorry! id_type must be either 'name' or 'ndc'")
try:
path = 'https://rxnav.nlm.nih.gov/REST/rxcui.json'
if id_type == 'name':
r = requests.get(path + f"?name={drug_id}")
if id_type =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drug_and_interactors(self):\n if self.results is not None and 'drug' in self.results.columns:\n return self.results[['drug', 'interactor_name']]",
"def _get_drug_entry(self,cid):\n result = None\n search_str = \"drugbank:drug/drugbank:drugbank-id/.[@primary='true']/..[drugbank... | [
"0.51848173",
"0.50451195",
"0.49801227",
"0.4976184",
"0.4945317",
"0.49125826",
"0.4843322",
"0.48027936",
"0.47699386",
"0.47515327",
"0.47100946",
"0.4672981",
"0.45692477",
"0.45569628",
"0.4523084",
"0.4509458",
"0.44925392",
"0.4448462",
"0.4367492",
"0.4337862",
"0.43... | 0.73186564 | 0 |
From a column label, gets numerical ZT time. | def extract_zt(self, s):
assert "ZT" in s
m = re.search("ZT([0-9]\.?[0-9]*)", s)
if m == None:
raise Exception("Badly formed ZT time, bro!")
return float(m.group(1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time_col(self):\n return self.time_col",
"def get_tmid(l):\n return Time(l['date-obs'], format='fits') + l['exptime']/2*u.s",
"def construct_obstime(self, row):\n return time.Time(self['mjd'][row], format='mjd')",
"def time(self, u):\n return self._ll_tree.get_time(u)",
"def... | [
"0.61929613",
"0.5722301",
"0.56998736",
"0.5694093",
"0.56104845",
"0.55867994",
"0.55804175",
"0.5538305",
"0.5529717",
"0.55292004",
"0.55292004",
"0.54735035",
"0.5436888",
"0.54153395",
"0.5384827",
"0.5384393",
"0.5363586",
"0.53618324",
"0.5360558",
"0.53585005",
"0.53... | 0.6237694 | 0 |
Splits SQL text into list. Text should be delimited by a comma. | def parse(text):
# Make sure that there's text to be split
if text == None:
return text
return text.split(',') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, text):\n\n return [x.strip() for x in text.split(\",\")]",
"def _split(self, sql):\n\n placeholder = \"\\ufffc\" # unicode object replacement character\n\n if self._delimiter == ';':\n return sqlparse.split(sql)\n\n # We must find a string that original sql... | [
"0.7266849",
"0.7073962",
"0.70081115",
"0.65453166",
"0.65445995",
"0.63893896",
"0.6296578",
"0.62681395",
"0.6262549",
"0.6235158",
"0.62129486",
"0.62125826",
"0.61667824",
"0.61415637",
"0.6136977",
"0.6063075",
"0.60546774",
"0.6010854",
"0.5987965",
"0.59820384",
"0.59... | 0.7011453 | 2 |
Rejoins list into commadelimited string for storage in database. | def rejoin(textList):
return ','.join(textList) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listToStr(lst):\n return ','.join(lst)",
"def sqllist(lst):\n if isinstance(lst, basestring): \n return lst\n else:\n return ', '.join(lst)",
"def list_str(lis):\r\n as_str = \"\"\r\n for item in lis:\r\n as_str += \" \" + str(item) + \",\"\r\n return as_str[:-1]",
... | [
"0.7462827",
"0.7449191",
"0.7351027",
"0.7093535",
"0.7080787",
"0.7071568",
"0.7057957",
"0.69338745",
"0.69092566",
"0.6905546",
"0.68478066",
"0.67825806",
"0.67806244",
"0.67595553",
"0.6743379",
"0.66823757",
"0.66760206",
"0.66661733",
"0.66403437",
"0.6612989",
"0.655... | 0.7691195 | 0 |
Returns the given date_time string formatted with date_format as timestamp, in a PY2/3 compatible way | def get_timestamp(date_time, date_format="%Y-%m-%dT%H:%M:%S"):
date_time = datetime.strptime(date_time, date_format)
try:
return date_time.timestamp()
# There is no timestamp method on datetime objects in Python 2
except AttributeError:
import time
return time.mktime(date_time.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date_time(time_stamp, date_format):\n time_arr = time.localtime(time_stamp)\n return time.strftime(date_format, time_arr)",
"def format_time(timestamp=None, format=r\"%Y%m%d-%H%M%S\"):\n time_str = time.strftime(format, time.localtime(timestamp if timestamp else time.time()))\n return time_st... | [
"0.7694034",
"0.7516344",
"0.74994844",
"0.74418426",
"0.7325264",
"0.73093706",
"0.72688025",
"0.7134653",
"0.7115484",
"0.70885175",
"0.70763326",
"0.6975815",
"0.6940705",
"0.6905071",
"0.6895671",
"0.68947285",
"0.6847823",
"0.6847294",
"0.68285996",
"0.6777699",
"0.67666... | 0.69727254 | 12 |
Merge names of environments by leaving the last nonblank one | def merge_names(names):
actual_names = [name for name in names if name]
if actual_names:
return actual_names[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(env, current_env):\n\n result = current_env.copy()\n for key, value in env.items():\n value = lib.partial_format(value, data=current_env, missing=\"\")\n result[key] = value\n\n return result",
"def environments(self):\n envs = self.config[\"tox\"][\"envlist\"]\n #r... | [
"0.6135013",
"0.5953949",
"0.5896729",
"0.57350785",
"0.5734773",
"0.57154953",
"0.558945",
"0.55229133",
"0.5433475",
"0.5207432",
"0.5201507",
"0.5188975",
"0.51800877",
"0.51742756",
"0.5172692",
"0.51722693",
"0.5166253",
"0.50655353",
"0.50587493",
"0.5055376",
"0.505196... | 0.5304375 | 9 |
Return whether the graph doesn't contain a cycle | def validate(self):
if len(self.independent_nodes) > 0:
try:
self.topological_sort()
return True
except ValueError:
return False
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_cycle(self):\n traversed = dict()\n for i in self.adj_list:\n traversed[i] = False\n\n for i in self.adj_list:\n if not traversed[i]:\n if self.has_cycle_helper(i, traversed, -1):\n return True\n return False",
"def has_c... | [
"0.8170607",
"0.8127583",
"0.798393",
"0.78322",
"0.773429",
"0.76222944",
"0.7594766",
"0.75538254",
"0.74817705",
"0.7325417",
"0.7205659",
"0.719672",
"0.71861297",
"0.71527576",
"0.71388316",
"0.7125199",
"0.7100493",
"0.70241714",
"0.7011045",
"0.7003908",
"0.6999341",
... | 0.0 | -1 |
Calculate precision. `labels` will be used to Arguments | def precision(y_true, y_pred, average, labels):
y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)
# At this point, you can be sure that y_true and y_pred are one hot encoded.
result = None
m = len(y_true)
n = len(labels)
#call get_confusion_matrix function and put the result ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gold_labels, predicted_labels):\n \n true_pos = 0 #gold pos sys pos\n false_pos = 0 #gold neg sys pos\n\n for i in range(0, len(gold_labels)):\n if(gold_labels[i] == predicted_labels[i] == \"1\"):\n true_pos += 1\n elif(gold_labels[i] == \"0\" and predicted_labels[i] == \"1\"):\n ... | [
"0.7269268",
"0.69795805",
"0.68197227",
"0.68104523",
"0.67358947",
"0.66702604",
"0.66301626",
"0.66046584",
"0.65841097",
"0.65733427",
"0.65733427",
"0.65733427",
"0.65733427",
"0.65733427",
"0.65733427",
"0.65641636",
"0.655487",
"0.6541217",
"0.6541217",
"0.6541217",
"0... | 0.69519407 | 2 |
Calculate recall. `labels` will be used to Arguments | def recall(y_true, y_pred, average, labels):
y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)
result = None
m = len(y_true)
n = len(labels)
confusion_matrix = get_confusion_matrix(y_true, y_pred, labels).T
if average == "micro":
numerator = np.trace(confusion_matr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall(gold_labels, predicted_labels):\n \n true_pos = 0 #gold pos sys pos\n false_neg = 0 #gold pos sys neg\n\n for i in range(0, len(gold_labels)):\n if(gold_labels[i] == predicted_labels[i] == \"1\"):\n true_pos += 1\n elif(gold_labels[i] == \"1\" and predicted_labels[i] == \"0\"):\n fal... | [
"0.7338403",
"0.70431715",
"0.69503856",
"0.68975264",
"0.6780457",
"0.677081",
"0.6578526",
"0.6557324",
"0.6553921",
"0.6531879",
"0.65238833",
"0.652297",
"0.64937663",
"0.6459216",
"0.6423728",
"0.64160484",
"0.64160484",
"0.64160484",
"0.64160484",
"0.64160484",
"0.64160... | 0.7166566 | 1 |
Checks that .png files have the right file name format, which must be in the form of NAME_expected(_(skia|skiapaths))?(_(win|mac|linux))?.pdf..png. This format must be the same as the one used in PDFium's PRESUBMIT.py's _CheckPNGFormat(). | def _CheckPngNames(input_api, output_api):
png_regex = input_api.re.compile(
r'.+_expected(_(skia|skiapaths))?(_(win|mac|linux))?\.pdf\.\d+.png')
warnings = []
for f in input_api.AffectedFiles(include_deletes=False):
local_path = f.LocalPath()
if local_path.endswith('.png'):
if not png_regex.m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_png(filename):\n return '.png' in filename",
"def _is_png(filename):\n return filename.endswith(b'.png')",
"def image_format_check(img_path):\n \n suffix = img_path.split('.')[-1]\n if suffix in ImgConf._VALID_IMAGE_SUFFIXES:\n return True\n \n return False",
"def is_fi... | [
"0.6886442",
"0.6752584",
"0.65919787",
"0.61115843",
"0.60981864",
"0.6089255",
"0.6009296",
"0.5970936",
"0.59649247",
"0.5929344",
"0.592229",
"0.5903049",
"0.58974063",
"0.58870816",
"0.58729017",
"0.58368284",
"0.58309925",
"0.5826213",
"0.5799892",
"0.57856745",
"0.5783... | 0.8107115 | 0 |
Creates an empty Trie data structure. | def __init__(self):
self.root = SimpleNode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty_trie():\n trie = Trie()\n return trie",
"def empty_trie():\n from trie import Trie\n trie = Trie()\n return trie",
"def __init__(self):\n self.root = TrieNode(None)",
"def __init__(self):\n self.root = TrieNode(None)",
"def __init__(self):\n self.root = TrieNod... | [
"0.8166488",
"0.79128367",
"0.7602523",
"0.7602523",
"0.7431437",
"0.7385183",
"0.7369724",
"0.7351714",
"0.73250306",
"0.7312923",
"0.73109144",
"0.7294403",
"0.72811514",
"0.72055435",
"0.71812075",
"0.71812075",
"0.71812075",
"0.71812075",
"0.71812075",
"0.71812075",
"0.71... | 0.0 | -1 |
init the weight of some layers | def _init_weights(self):
nn.init.xavier_normal_(self.out.weight) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_layer(self.conv1)\n init_layer(self.conv2)\n init_bn(self.norm1)\n init_bn(self.norm2)",
"def init_layer(layer):\n \n if layer.weight.ndimension() == 4:\n (n_out, n_in, height, width) = layer.weight.size()\n n = n_in * height * width\n ... | [
"0.8651084",
"0.8243662",
"0.7972445",
"0.79263115",
"0.78876466",
"0.7880778",
"0.7865069",
"0.78641295",
"0.77994853",
"0.7797192",
"0.77273303",
"0.7702495",
"0.7659687",
"0.76342404",
"0.76224715",
"0.76123804",
"0.7553077",
"0.7527488",
"0.7527488",
"0.7527488",
"0.75160... | 0.0 | -1 |
Initialize the encoder hidden state. | def _init_rnn_state(self, encoder_hidden):
if encoder_hidden is None:
return None
if isinstance(encoder_hidden, tuple):
encoder_hidden = tuple(
[self._cat_directions(h) for h in encoder_hidden])
else:
encoder_hidden = self._cat_directions(encod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_hidden_state(self, encoder_out: torch.Tensor):\n pass",
"def _init_state(self, encoder_hidden):\n if encoder_hidden is None:\n return None\n if isinstance(encoder_hidden, tuple):\n encoder_hidden = tuple([self._cat_directions(h) for h in encoder_hidden])\n ... | [
"0.83275086",
"0.77102697",
"0.77102697",
"0.74040484",
"0.7290414",
"0.7279931",
"0.7215229",
"0.7215229",
"0.70479804",
"0.6901168",
"0.68980813",
"0.689464",
"0.68280524",
"0.6804546",
"0.67857987",
"0.6757444",
"0.6757444",
"0.6757444",
"0.66996604",
"0.6488062",
"0.62742... | 0.69852823 | 9 |
Test Campaign model creation. | def test_create_campaign(self):
campaign = self.campaign
self.assertTrue(isinstance(campaign, Campaign))
self.assertEqual(campaign.name, "Test Campaign") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_campaign(self):\n acc1 = Account.objects.create(name='acc1', code='111-111')\n row = {'PROJ_NAME1': 'China Fund', 'PROJ_NO': 'CFD-111',\n 'LOCATION': 'CHINA', 'SUMMARY': 'Ssssss'}\n sync.create_campaign(acc1, row, 'China Fund', Account.COUNTRY)\n campaign =... | [
"0.78902245",
"0.7651008",
"0.7359439",
"0.71211284",
"0.67662543",
"0.67198855",
"0.6708729",
"0.6648027",
"0.65363836",
"0.65191734",
"0.64824545",
"0.6344745",
"0.63350147",
"0.63057655",
"0.6257441",
"0.62380844",
"0.62292516",
"0.620606",
"0.61954194",
"0.61694616",
"0.6... | 0.84397465 | 0 |
Test Location model creation. | def test_create_location(self):
location = self.location
self.assertTrue(isinstance(location, Location))
self.assertEqual(location.name, "Test Location") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location_fixture():\n return _create_location()",
"def create_location(self, location):\n \"Does nothing\"",
"def test_model_inst_created(self):\n self.c.force_login(self.u)\n response = self.c.get(reverse(submit_point), data)\n self.assertEqual(Point.objects.last().lat, data... | [
"0.73845196",
"0.70042175",
"0.7003142",
"0.69560915",
"0.6769358",
"0.6760668",
"0.6760372",
"0.6750908",
"0.66711414",
"0.6621288",
"0.6592469",
"0.6591204",
"0.6536766",
"0.6521401",
"0.65132946",
"0.6496338",
"0.63848555",
"0.6367077",
"0.6346326",
"0.6325834",
"0.6314009... | 0.8253273 | 0 |
Convert time strings to seconds. Strings can be of the | def str_to_seconds(tstring):
if tstring.endswith('m'):
secs = 60 * int(tstring.replace('m', ''))
elif tstring.endswith('h'):
secs = 60 * 60 * int(tstring.replace('h', ''))
elif tstring.endswith('d'):
secs = 24 * 60 * 60 * int(tstring.replace('d', ''))
elif tstring.endswith('y'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time2secs( s ):\n t = s.split( ':' )\n nf = len( t )\n if nf == 1:\n # Seconds only!\n secs = int( t[0] )\n elif nf == 2:\n # Minutes & seconds!\n secs = int( t[1] ) + int( t[0] ) * 60\n elif nf == 3:\n # Hours, minutes & seconds!\n secs = int( t[2] ) + int( t[1] ) * 60 ... | [
"0.7774056",
"0.7758759",
"0.77493227",
"0.76101214",
"0.7355431",
"0.73487556",
"0.73450696",
"0.7279362",
"0.72536737",
"0.72536737",
"0.72315645",
"0.72298837",
"0.713335",
"0.7079136",
"0.70435554",
"0.7030023",
"0.7013202",
"0.695403",
"0.69182235",
"0.6909746",
"0.69088... | 0.7723457 | 3 |
Return True if the event is too old or too far in the future to process; return False otherwise. | def event_too_old_or_in_future(event, config):
current_time = time.time()
try:
event_time = datetime.strptime(event['time'], constants.TIMEFMT).\
replace(tzinfo=timezone.utc).timestamp()
except ValueError:
event_time = datetime.strptime(event['time'], constants.ALT_TIMEFMT).\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_check(self):\r\n if len(self.event_queue) > 0:\r\n event = self.event_queue.pop(0) # oldest\r\n self.event_queue_proc(event)\r\n return True\r\n return False",
"def check_event_update_safe(old_event: event_models.Event,\n new... | [
"0.75837344",
"0.6788557",
"0.6575105",
"0.64717174",
"0.64503145",
"0.64024466",
"0.63278306",
"0.62811536",
"0.62544596",
"0.62283874",
"0.6224967",
"0.6211071",
"0.6204464",
"0.61829203",
"0.6167654",
"0.61507803",
"0.61417854",
"0.6135952",
"0.6129829",
"0.6121233",
"0.61... | 0.74514717 | 1 |
Will find where the brace ends in a control statement. | def get_end_brace(self):
# Find the code to run
brack_num, found_first = 0, False
for iline, line in enumerate(self.file_ltxt[self.line_num:]):
if '{' in line: brack_num += 1
if '}' in line: brack_num -= 1
if not found_first:
if brack_num > 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def searchEndBlock( strList ):\n\tindex0 = strList.find('(')+1\n\tnumP = 1\n\tfor c in xrange(index0,len(strList)):\n\t\tif strList[c] == ')':\n\t\t\tnumP -= 1\n\t\telif strList[c] == '(':\n\t\t\tnumP += 1\n\t\t\n\t\tif numP == 0:\n\t\t\treturn strList[:c+1]",
"def _get_next_bracket(self) -> int:\n return... | [
"0.62316036",
"0.6064271",
"0.5846728",
"0.5740664",
"0.57180727",
"0.571373",
"0.5700736",
"0.5651915",
"0.56058455",
"0.55664545",
"0.5517524",
"0.5394171",
"0.53695446",
"0.5360177",
"0.53203243",
"0.531651",
"0.5316293",
"0.5306972",
"0.52825934",
"0.52331245",
"0.5200116... | 0.7725958 | 0 |
Will find the variables that have been used in a string (i.e. with the $). If any variables found aren't declared an error will be thrown | def find_vars_in_str(self, line):
self.E_str = "find_vars_in_str"
any_vars = [i[1:] for i in re.findall(IN_STR_VAR_REGEX, line)]
for check_var in any_vars:
# Check the variable exists
if check_var not in self.variables:
self.print_error(f"Can't find variab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regex_findall_variables(raw_string: Text) -> List[Text]:\n try:\n match_start_position = raw_string.index(\"$\", 0)\n except ValueError:\n return []\n\n vars_list = []\n while match_start_position < len(raw_string):\n\n # Notice: notation priority\n # $$ > $var\n\n ... | [
"0.6805193",
"0.62757117",
"0.6274954",
"0.61823285",
"0.6043678",
"0.6012364",
"0.5927913",
"0.5924077",
"0.5872563",
"0.58598167",
"0.5839836",
"0.5799833",
"0.5774229",
"0.570927",
"0.5708174",
"0.56886286",
"0.56884277",
"0.56582034",
"0.5654751",
"0.56535",
"0.5652215",
... | 0.7143965 | 0 |
Returns the list of data elements excluding zero padding elements. | def samples(self):
return self._values[:self.nsamples] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_empty(data):\n out = []\n for item in data:\n if item == '':\n continue\n out.append(item)\n return out",
"def non_zero_components(self) :\n return list(self.parent().characters())",
"def compact_list(self):\n return [ele for ele in self if ele is not ... | [
"0.6466449",
"0.64213526",
"0.615112",
"0.608498",
"0.5921419",
"0.58596534",
"0.5856476",
"0.5835441",
"0.5750241",
"0.5690156",
"0.5689491",
"0.567011",
"0.5668841",
"0.5654338",
"0.5653573",
"0.56457525",
"0.56206554",
"0.5619142",
"0.5576521",
"0.5570819",
"0.5568666",
... | 0.0 | -1 |
Tunes a window settings for the given parameters. | def tuned(sample_rate, freqs, min_fres=None, power_of_2=False, use_padding=True, wndtype=Type.rectangle, dtype=np.float_):
freqs = np.atleast_1d(freqs)
high_f = np.max(freqs)
assert (sample_rate / 2) >= high_f, "Highest target frequency violates Nyquist sampling theorem."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weights(self, w):\n self.nn.set_param_values(w)",
"def set_weights(self, wts):\n\t\tself.wts = wts",
"def setWalabotSettings():\n wlbt.SetProfile(wlbt.PROF_SENSOR)\n wlbt.SetArenaR(R_MIN, R_MAX, R_RES)\n wlbt.SetArenaTheta(THETA_MIN, THETA_MAX, THETA_RES)\n wlbt.SetArenaPhi(PHI_MIN, ... | [
"0.534648",
"0.5311427",
"0.5152892",
"0.5060417",
"0.48906752",
"0.48856765",
"0.4831677",
"0.48254257",
"0.4791882",
"0.478922",
"0.47399178",
"0.47190318",
"0.47018352",
"0.46973658",
"0.46945414",
"0.46941888",
"0.46799698",
"0.46716556",
"0.46669194",
"0.4658543",
"0.465... | 0.5419968 | 0 |
Return True if the priority queue is empty. | def is_empty(self): # concrete method assuming abstract len
return len(self) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.priority_queue) == 0",
"def is_empty(self):\n return len(self.the_queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return self.queue == []",... | [
"0.9179846",
"0.8469489",
"0.8437107",
"0.8437107",
"0.8436066",
"0.838734",
"0.836409",
"0.8344005",
"0.83305556",
"0.83305556",
"0.83042455",
"0.83034027",
"0.82889843",
"0.82803255",
"0.8267934",
"0.8259419",
"0.82293385",
"0.8219118",
"0.82072806",
"0.8198649",
"0.8182699... | 0.0 | -1 |
Return the number of items in the priority queue. | def __len__(self):
raise NotImplementedError('must be implemented by subclass') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n return len(self._queue_items)",
"def queue_count(self):\n with self.mutex:\n return len(self.queues)",
"def get_num_items(self):\r\n return self.num_items",
"def size(self): #returns the size or number of items in the stack\n if self... | [
"0.73094535",
"0.7214424",
"0.71406925",
"0.7130484",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7050724",
"0.7050724",
"0.70315284",
"0.70315284",
"0.70139974",
"0.6985575",
"0.6979711",
"0.69724464",
"0.6955107",
"0.6938039",
"0.6901929",
"0.681586",
"0.6785586"... | 0.0 | -1 |
Create a new empty Priority Queue. | def __init__(self):
self._data = PositionalList() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_empty_queue():\n return Queue(0, None, None)",
"def priority_queue():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n return priority_queue",
"def priority_queue_full():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n p... | [
"0.7893713",
"0.74452215",
"0.71636957",
"0.7081834",
"0.7081834",
"0.6581613",
"0.6313973",
"0.63086706",
"0.6265996",
"0.6179255",
"0.61486804",
"0.6126521",
"0.60874456",
"0.6058897",
"0.60504574",
"0.6046229",
"0.60360074",
"0.6026002",
"0.5990476",
"0.5980345",
"0.597111... | 0.0 | -1 |
Return the number of items in the priority queue. | def __len__(self):
return len(self._data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n return len(self._queue_items)",
"def queue_count(self):\n with self.mutex:\n return len(self.queues)",
"def get_num_items(self):\r\n return self.num_items",
"def size(self): #returns the size or number of items in the stack\n if self... | [
"0.73094535",
"0.7214424",
"0.71406925",
"0.7130484",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7050724",
"0.7050724",
"0.70315284",
"0.70315284",
"0.70139974",
"0.6985575",
"0.6979711",
"0.69724464",
"0.6955107",
"0.6938039",
"0.6901929",
"0.681586",
"0.6785586"... | 0.0 | -1 |
Return Position of item with minimum key. | def _find_min(self):
if self.is_empty(): # is_empty inherited from base class
raise Empty('Priority queue is empty')
small = self._data.first()
walk = self._data.after(small)
while walk is not None:
if walk.element() < small.element():
small = walk
walk = self._data.after(walk)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_position(self, key):\n return bisect.bisect_left(self.keys, key)",
"def min_key(self):\n return self.__keys[self.__pq[1]]",
"def minchild(self, pos):\n minpos = minkey = None\n for c in self.children(pos):\n if minkey == None or self.heap[c].key < minkey:\n ... | [
"0.77470106",
"0.7666157",
"0.7395155",
"0.73203367",
"0.7254431",
"0.72505504",
"0.7220308",
"0.7152589",
"0.70716697",
"0.7071603",
"0.70055217",
"0.6933423",
"0.6918526",
"0.6828535",
"0.6828328",
"0.6822287",
"0.6822287",
"0.67781764",
"0.67364544",
"0.6730928",
"0.673092... | 0.6869165 | 13 |
Create a new empty Priority Queue. | def __init__(self):
self._data = PositionalList() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_empty_queue():\n return Queue(0, None, None)",
"def priority_queue():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n return priority_queue",
"def priority_queue_full():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n p... | [
"0.7893713",
"0.74452215",
"0.71636957",
"0.7081834",
"0.7081834",
"0.6581613",
"0.6313973",
"0.63086706",
"0.6265996",
"0.6179255",
"0.61486804",
"0.6126521",
"0.60874456",
"0.6058897",
"0.60504574",
"0.6046229",
"0.60360074",
"0.6026002",
"0.5990476",
"0.5980345",
"0.597111... | 0.0 | -1 |
Return the number of items in the priority queue. | def __len__(self):
return len(self._data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n return len(self._queue_items)",
"def queue_count(self):\n with self.mutex:\n return len(self.queues)",
"def get_num_items(self):\r\n return self.num_items",
"def size(self): #returns the size or number of items in the stack\n if self... | [
"0.73094535",
"0.7214424",
"0.71406925",
"0.7130484",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7050724",
"0.7050724",
"0.70315284",
"0.70315284",
"0.70139974",
"0.6985575",
"0.6979711",
"0.69724464",
"0.6955107",
"0.6938039",
"0.6901929",
"0.681586",
"0.6785586"... | 0.0 | -1 |
Create a new empty Priority Queue. | def __init__(self):
self._data = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_empty_queue():\n return Queue(0, None, None)",
"def priority_queue():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n return priority_queue",
"def priority_queue_full():\n from src.priorityq import PriorityQueue\n priority_queue = PriorityQueue()\n p... | [
"0.7893713",
"0.74452215",
"0.71636957",
"0.7081834",
"0.7081834",
"0.6581613",
"0.6313973",
"0.63086706",
"0.6265996",
"0.6179255",
"0.61486804",
"0.6126521",
"0.60874456",
"0.6058897",
"0.60504574",
"0.6046229",
"0.60360074",
"0.6026002",
"0.5990476",
"0.5980345",
"0.597111... | 0.0 | -1 |
Return the number of items in the priority queue. | def __len__(self):
return len(self._data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n return len(self._queue_items)",
"def queue_count(self):\n with self.mutex:\n return len(self.queues)",
"def get_num_items(self):\r\n return self.num_items",
"def size(self): #returns the size or number of items in the stack\n if self... | [
"0.73094535",
"0.7214424",
"0.71406925",
"0.7130484",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7051237",
"0.7050724",
"0.7050724",
"0.70315284",
"0.70315284",
"0.70139974",
"0.6985575",
"0.6979711",
"0.69724464",
"0.6955107",
"0.6938039",
"0.6901929",
"0.681586",
"0.6785586"... | 0.0 | -1 |
Attempts to convert a string to the most appropriate valid Python identifier (for entity ID enums). Removes useless prefixes, like "SFX ". Removes spaces and capitalizes any letters that appear after them. Replaces some spaces with underscores, like spaces before "mXXXX". Removes invalid characters. Adds leading "_" to... | def string_to_identifier(spaces_string: str, remove_prefixes=(), preserve_models=True) -> str:
id_string = spaces_string.strip(" ")
model_re = re.compile(r"[cohm]\d\d\d\d") if preserve_models else None
for prefix in remove_prefixes:
id_string = id_string.removeprefix(prefix)
while (space_index :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_python_identifier(string):\n # Todo: check for variable uniqueness\n # perhaps maintain a list of current variables and their translations??\n # Todo: check that the output is actually a valid python identifier\n\n string = string.lower()\n\n # remove leading and trailing whitespace\n s... | [
"0.7303983",
"0.7028515",
"0.695694",
"0.6928142",
"0.69110376",
"0.67664975",
"0.6756843",
"0.6541595",
"0.6538051",
"0.65297824",
"0.6222688",
"0.62155825",
"0.6186026",
"0.6184884",
"0.6179486",
"0.6157909",
"0.61505485",
"0.6143066",
"0.6111259",
"0.6080164",
"0.60718894"... | 0.7555152 | 0 |
Converts the original matrix to RFPF based on the Transr and Uplo parameters. Note that Fortran of A is required, otherwise, the matrix will be taken as a transpose of the original one. | def to_rfpf(a, transr='N', uplo='U', out=None):
a_cols, a_rows = a.shape
if a_cols != a_rows:
raise ValueError('Matrix is not square.')
if a.flags.c_contiguous:
a = np.asfortranarray(a)
# TODO raise ValueError('Input matrix A needs to be F-contiguous.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_R_F_trafo(self, row):\r\n\r\n # [x, y, z, roll, pitch, yaw] format\r\n if 'Goal x' in row:\r\n rot_R_F = Rotation.from_euler('xyz',\r\n [row['Goal roll'], row['Goal pitch'], row['Goal yaw']],\r\n degr... | [
"0.5849987",
"0.5813485",
"0.5658212",
"0.5588726",
"0.5402625",
"0.53986967",
"0.5344376",
"0.52956057",
"0.5285376",
"0.5284727",
"0.52596354",
"0.52595824",
"0.52395636",
"0.5228851",
"0.5207768",
"0.5207023",
"0.5200803",
"0.5186005",
"0.5160041",
"0.5150841",
"0.5133533"... | 0.7669588 | 0 |
Dumps the simulated data to a pandas DataFrame. This is convenient for use with popular Python statistical packages or to simply write a CSV file containing the simulated data to disk. | def to_dataframe(self):
import pandas as pd
d = OrderedDict({"y": self.y})
for pred in self.predictors:
d[pred.name] = pred.x
df = pd.DataFrame(d)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print(self):\n df = self.gen_test()\n # print(df)\n df.to_csv('some_dated_file.csv', index=False)\n return df",
"def to_pandas_df(self):\n data = self._get_data(pd=True)\n return data",
"def runSimulationDF(cls, **kwargs):\r\n fittedTS = NamedTimeseries(name... | [
"0.6228638",
"0.6172396",
"0.61369705",
"0.60617644",
"0.6025214",
"0.5964169",
"0.5955786",
"0.5955786",
"0.59400773",
"0.5937557",
"0.5924051",
"0.59146446",
"0.58873343",
"0.58598584",
"0.579721",
"0.5752081",
"0.57507753",
"0.572597",
"0.5709258",
"0.5701143",
"0.56337845... | 0.57468003 | 17 |
returns whether or not the entity has the component of the specified class | def has(self, entity):
return entity.has_component(self.component_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, component):\n if issubclass(component, Component):\n try:\n my_component = self.type.components[component.interface]\n except KeyError:\n return False\n else:\n return issubclass(my_component, component)\n ... | [
"0.7239293",
"0.68413556",
"0.67001134",
"0.6527737",
"0.65255064",
"0.638794",
"0.636948",
"0.6339106",
"0.62741023",
"0.6241453",
"0.62410194",
"0.62317437",
"0.61038023",
"0.6094753",
"0.6085668",
"0.6075856",
"0.6073516",
"0.60707146",
"0.60639143",
"0.60556614",
"0.60514... | 0.78403777 | 0 |
Displays image and the topn predicted probabilities in a bar graph | def plot_preds(image, preds):
#image
plt.imshow(image)
plt.axis('off')
#bar graph
plt.figure()
order = list(reversed(range(len(preds))))
bar_preds = [pr[2] for pr in preds]
labels = (pr[1] for pr in preds)
plt.barh(order, bar_preds, alpha=0.5)
plt.yticks(order, labels)
plt.xla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotPred(img, pred):\n\n #plota a imagem.\n plt.imshow(img)\n plt.axis('off')\n\n #grafico de barras.\n plt.figure() \n order = list(reversed(range(len(pred)))) \n bar_preds = [pr[2] for pr in pred]\n labels = (pr[1] for pr in pred)\n plt.barh(order, bar_preds, alpha=0.5)\n plt.... | [
"0.77978665",
"0.7721485",
"0.769006",
"0.76070917",
"0.7603528",
"0.71370405",
"0.70984143",
"0.7009505",
"0.68326867",
"0.6766593",
"0.6606671",
"0.6594294",
"0.6510035",
"0.64082754",
"0.63103276",
"0.63035893",
"0.62614477",
"0.6234734",
"0.6204136",
"0.62028116",
"0.6188... | 0.7922684 | 0 |
returns full class name for instance | def get_full_class_name(instance):
return "%s.%s" % (instance.__module__, instance.__class__.__name__) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name(cls):\n return cls.__name__",
"def class_name(cls):\n return cls.__name__",
"def class_name(self) -> str:\n return pulumi.get(self, \"class_name\")",
"def f_get_class_name(self):\n return self.__class__.__name__",
"def className(self):\n namevalue = self.__class__.... | [
"0.8666152",
"0.8666152",
"0.85594887",
"0.85485005",
"0.8518022",
"0.8463381",
"0.8461112",
"0.8461112",
"0.843077",
"0.8349398",
"0.8326935",
"0.8158884",
"0.80965906",
"0.80774647",
"0.80329406",
"0.7957002",
"0.79116803",
"0.7911652",
"0.7868199",
"0.7855517",
"0.7822544"... | 0.8530454 | 4 |
Initialize the battery's attributes. | def __init__(self,battery_size=85):
self.battery_size = battery_size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, battery_size=40):\n self.battery_size = battery_size",
"def __init__(self, battery_size=70):\r\n\t\tself.battery_size = battery_size",
"def __init__(self, battery_size=70):\n self.battery_size = battery_size",
"def __init__(self, battery_size=70):\n self.battery_size =... | [
"0.7382995",
"0.73729676",
"0.73598105",
"0.73598105",
"0.73598105",
"0.73419243",
"0.73419243",
"0.7318721",
"0.73161864",
"0.7284151",
"0.72274315",
"0.7195436",
"0.69978577",
"0.69625956",
"0.69494915",
"0.6906689",
"0.6906689",
"0.6906689",
"0.6906689",
"0.6906689",
"0.69... | 0.7206751 | 11 |
The name of the channel. | def channel(self):
return self._channel | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def channel_name(self) -> str:\n return self._channel_name",
"def channel_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"channel_name\")",
"def channel_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"channel_name\")",
"def channel_name(self) -> pulumi.Input[str... | [
"0.9192925",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.8496867",
"0.83327353",
... | 0.7171293 | 27 |
Construct a new `MainFrame' instance. All arguments are passed asis to the `Tix.Frame' constructor. | def __init__(self, master=None, *args, **kw):
Tix.Frame.__init__(self, master, *args, **kw)
self._init_widgets()
self._init_bindings()
self._root().title("KaeChat")
self._page_serial = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, master, _type=REGULAR, **kw):\r\n Frame.__init__(self, master, **kw)\r\n self.main_frame = Frame(self, bd=1)\r\n self.main_frame.pack()",
"def create_main(self):\n self.frame = wxMediatorMainFrame(self)",
"def __init__(self,*args, **kwargs):\n tk.Tk.__init_... | [
"0.623563",
"0.60203487",
"0.5910724",
"0.5901951",
"0.580496",
"0.5598728",
"0.5498089",
"0.54192674",
"0.537996",
"0.53550845",
"0.53512836",
"0.5348354",
"0.5335231",
"0.5321712",
"0.524399",
"0.5225888",
"0.51881254",
"0.51840496",
"0.517467",
"0.5141346",
"0.5126489",
... | 0.5854602 | 4 |
This function takes either a json string or a path to a json file, it loads the json into memory and returns the corresponding Python object. | def get_pyobj_from_json(str_or_path):
try:
# see if treating str_or_path as a path works
fp = codecs.open(str_or_path, mode="r", encoding="utf-8")
doc = json.load(fp, encoding="utf-8")
except:
# if it doesn't work load the text
doc = json.loads(str_or_path)
return doc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(_json):\n if isinstance(_json, (str, Path)):\n return from_json_dict(json.loads(_json))\n else: # assume a file-like object\n return from_json_dict(json.load(_json))",
"def _localloadjson(path: str) -> JSONType:\n with open(path, encoding=\"utf-8\") as fh:\n return js... | [
"0.79873586",
"0.7819393",
"0.7774818",
"0.77054214",
"0.77010757",
"0.7643722",
"0.74792045",
"0.7475597",
"0.7443932",
"0.7403512",
"0.7401574",
"0.7313957",
"0.7312576",
"0.7296914",
"0.7287474",
"0.72822225",
"0.7282216",
"0.72820985",
"0.72766435",
"0.7263966",
"0.725663... | 0.8028446 | 0 |
Sanitize a URL against XSS attacks. See the docstring on markdown.inlinepatterns.LinkPattern.sanitize_url. | def sanitize_url(url: str) -> Optional[str]:
try:
parts = urllib.parse.urlparse(url.replace(" ", "%20"))
scheme, netloc, path, params, query, fragment = parts
except ValueError:
# Bad URL - so bad it couldn't be parsed.
return ""
# If there is no scheme or netloc and there i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_url(self, url):\r\n if not self.markdown.safeMode:\r\n # Return immediately bipassing parsing.\r\n return url\r\n \r\n try:\r\n scheme, netloc, path, params, query, fragment = url = urlparse(url)\r\n except ValueError:\r\n # Bad u... | [
"0.76825964",
"0.7267443",
"0.7074259",
"0.68428046",
"0.6672135",
"0.65712535",
"0.6517339",
"0.63524514",
"0.6350029",
"0.6321725",
"0.61863273",
"0.6176373",
"0.6112945",
"0.61007994",
"0.60385245",
"0.6029643",
"0.60176325",
"0.6013761",
"0.60058284",
"0.59789073",
"0.597... | 0.6313954 | 10 |
Return a list of values sorted by keys. | def sorted_values(dictionary):
keys = sorted_keys(dictionary)
return [dictionary[key] for key in keys] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values_as_sorted_list(dict):\n return [dict[k] for k in keys_as_sorted_list(dict)]",
"def keys_sorted_by_value(d):\n # By Daniel Schult, 2004/01/23\n # http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52306\n items=d.items()\n backitems=[ [v[1],v[0]] for v in items]\n backitems.sort(... | [
"0.81164074",
"0.7441192",
"0.73108894",
"0.72504437",
"0.721299",
"0.68719834",
"0.68652326",
"0.6843726",
"0.68216145",
"0.6769109",
"0.67602456",
"0.67507297",
"0.6729393",
"0.67024803",
"0.66808075",
"0.66176605",
"0.65959835",
"0.658811",
"0.6572188",
"0.654413",
"0.6519... | 0.7722557 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.