query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Operator converter for unique. | def convert_unique(g, op, block):
x = g.get_node(op.input("X")[0])
return_index = op.attr("return_index")
return_inverse = op.attr("return_inverse")
return_counts = op.attr("return_counts")
axis = op.attr("axis")
dtype = op.attr("dtype")
dtype = _convert_dtype_value(dtype)
if len(axis)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_operator(self, operator):",
"def to_operator(operator):\n if isinstance(operator, str):\n return ValueConstraintOperators.STRING_OPERATOR_MAP[operator]\n else:\n return operator",
"def unique_op(\n input, sorted=True, return_inverse=False, return_counts=False,... | [
"0.626151",
"0.5960307",
"0.592088",
"0.5738333",
"0.555993",
"0.5519061",
"0.5512299",
"0.55050915",
"0.55033237",
"0.5481525",
"0.5453998",
"0.53691906",
"0.5314363",
"0.52950007",
"0.5234563",
"0.52270406",
"0.521875",
"0.52079684",
"0.5202873",
"0.5116122",
"0.5079995",
... | 0.60067236 | 1 |
Operator converter for where_index. | def convert_where_index(g, op, block):
condition = g.get_node(op.input("Condition")[0])
out = _op.argwhere(condition)
g.add_node(op.output("Out")[0], out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_operator(operator):\n if isinstance(operator, str):\n return ValueConstraintOperators.STRING_OPERATOR_MAP[operator]\n else:\n return operator",
"def operator(self):\n col = self.pos\n operators = [\"||\", \"&&\", \">>\", \"<<\", \"!=\", \">=\", \"<=\", \"=... | [
"0.6114681",
"0.5815883",
"0.577079",
"0.57605284",
"0.57485235",
"0.5709471",
"0.5677706",
"0.5662906",
"0.5612391",
"0.55882066",
"0.55861455",
"0.55713516",
"0.55713516",
"0.55713516",
"0.55186635",
"0.547143",
"0.547143",
"0.546239",
"0.546239",
"0.5401785",
"0.53838646",... | 0.63641554 | 0 |
Check the shape information of model's inputs, fixed shape is recommended. | def check_input_shape(self, op, block):
ipt_name = op.input(op.input_names[0])
ipt_shape = block.var(ipt_name).shape
for i in ipt_shape:
if i < 0:
warning_msg = (
f"Input {ipt_name}(shape={ipt_shape}) has unkown dimension shapes. "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(input_shape):\n msg = ('Input to SpatialExpansion must be 4D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_features), '\n 'but received shape: {}'.format(input_shape))\n assert len(input_shape) == 4, msg",
"def _check_shape(input_sha... | [
"0.74172133",
"0.73516583",
"0.72337633",
"0.712786",
"0.71125764",
"0.7111507",
"0.70951205",
"0.70870256",
"0.70416397",
"0.6832654",
"0.67188287",
"0.670385",
"0.66634417",
"0.6658165",
"0.6656481",
"0.66102976",
"0.65338516",
"0.65208566",
"0.6515411",
"0.6500788",
"0.650... | 0.80289024 | 0 |
Construct the TVM relay expression from PaddlePaddle TranslatedLayer. | def from_translated_layer(self, layer, shape_dict):
self.shape_dict = shape_dict
program = layer.program()
parameters = dict()
for param in layer.parameters() + layer.buffers():
parameters[param.name] = np.array(param.value().get_tensor())
self.check_unsupported_ops(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(self):\n # Generate a 4x4 identity matrix, which will be the basis for the view matrix.\n vtm = np.identity( 4, float )\n # Generate a translation matrix to move the VRP to the origin and then premultiply the vtm by the translation matrix.\n t1 = np.matrix( [[1, 0, 0, -self.vr... | [
"0.53328145",
"0.5297721",
"0.5216436",
"0.51589155",
"0.515236",
"0.50780714",
"0.5076957",
"0.5028861",
"0.50055116",
"0.49860832",
"0.49845412",
"0.4975263",
"0.49668294",
"0.4960485",
"0.493919",
"0.48898166",
"0.48114258",
"0.48068392",
"0.47904983",
"0.47838023",
"0.472... | 0.5676115 | 0 |
Convert a PaddlePaddle model into an equivalent Relay Function. PaddlePaddle Program/TranslatedLayer represent the computation graph of PaddlePaddle model, and PaddlePaddle scope stores all the weights of PaddlePaddle model. | def from_paddle(program_or_layer, shape_dict=None, scope=None):
import paddle
# disable system signal capturing in paddle framework
# the signal capturing may cause conflict while running autotvm with paddle frontend
paddle.disable_signal_handler()
g = GraphProto()
if isinstance(program_or_la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_relay(tflite_model_buf, bind_params_by_name=True):\n # TFLite.Model.Model has changed to TFLite.Model from 1.14 to 2.1\n try:\n import tflite.Model # pylint: disable=import-outside-toplevel\n\n tflite_model = tflite.Model.Model.GetRootAsModel(tflite_model_buf, 0)\n except Att... | [
"0.5702648",
"0.5349275",
"0.5262561",
"0.52105623",
"0.5174496",
"0.5168294",
"0.5095048",
"0.5083902",
"0.5042046",
"0.50407904",
"0.5004864",
"0.49550307",
"0.4926888",
"0.49212012",
"0.49205035",
"0.49155945",
"0.49133554",
"0.4906746",
"0.4887602",
"0.48809993",
"0.48793... | 0.6145294 | 0 |
Parses the map file and constructs a directed graph | def load_map(map_filename):
#print("Loading map from file...")
campus_graph = Digraph() # 实例化Digraph
with open(map_filename) as file_object:
lines = file_object.readlines()
for line in lines:
list = line.split()
if not campus_graph.has_node(Node(list[0])):
campus_gra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_map(map_filename):\n\n data_file = open(map_filename, 'r')\n map_graph = Digraph()\n for line in data_file:\n source_node, dest_node, total_distance, outdoor_distance = line.split(' ')\n source = Node(source_node)\n dest = Node(dest_node)\n edge = WeightedEdge(source, ... | [
"0.78509665",
"0.7194932",
"0.7056183",
"0.6915113",
"0.6662199",
"0.6650366",
"0.6495219",
"0.6488005",
"0.64375037",
"0.64144105",
"0.63904667",
"0.6390194",
"0.6385786",
"0.63557357",
"0.6337814",
"0.63212186",
"0.6304936",
"0.63046056",
"0.6298356",
"0.6282649",
"0.627714... | 0.7572843 | 1 |
Pretty print embedding results. | def pretty_print(results: List[Tuple[str, torch.Tensor]]):
for item in results:
print("...[%.2f] - %s" % (item[1], item[0])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Display(self, unused_args, result):\n util.PrettyPrint(result)",
"def Display(self, unused_args, result):\n util.PrettyPrint(result)",
"def printpretty(self):\n print(self.string_rep())",
"def PrettyPrint(self):\r\n print(self.data)\r\n return",
"def pretty_print_nlp_parsing_... | [
"0.62115407",
"0.62115407",
"0.6193696",
"0.610191",
"0.60906863",
"0.60840976",
"0.601019",
"0.5973436",
"0.5950919",
"0.5925772",
"0.5920908",
"0.5889996",
"0.58798903",
"0.5879005",
"0.5826232",
"0.5793017",
"0.5765513",
"0.5763611",
"0.57520866",
"0.5722096",
"0.571961",
... | 0.6587914 | 0 |
Get the n closest words to your word. | def get_closest(target_word: str, word_to_idx: Dict, embeddings: torch.Tensor, n: int = 5) -> List[Tuple[str, torch.Tensor]]:
# Calculate distances to all other words
word_embedding = embeddings[word_to_idx[target_word.lower()]]
distances = []
for word, index in word_to_idx.items():
if word ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_words(self, word, n):\n\n vector = self.get_vector(word)\n\n if vector is None:\n return None\n\n distances = [\n (w, torch.dist(vector, self.get_vector(w)).item())\n for w in self.glove.itos\n ]\n\n return [w for w, v in sorted(distan... | [
"0.85090446",
"0.7184001",
"0.7184001",
"0.7184001",
"0.7084324",
"0.7013904",
"0.70045865",
"0.69496286",
"0.6733632",
"0.6690089",
"0.66638166",
"0.6642329",
"0.662226",
"0.64919543",
"0.648842",
"0.64838004",
"0.6478753",
"0.64702743",
"0.6438521",
"0.6431349",
"0.64137644... | 0.7542553 | 1 |
Add the constraint that fix the id of the transition pos in both idTransitionFaultyPath and idTransitionNormalPath. | def addConstraintOnIdTransition(self, pos):
super().addConstraintOnIdTransition(pos)
self.s.add(Implies(self.startLoop == pos, self.faultOccursByThePast[pos]))
for j in range(len(self.transitionList)):
self.s.add(Implies(self.faultyPath[pos - 1] == j, self.stateFaultyPath[pos] == s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incBound(self):\n # increment the bound for the local variables.\n self.incVariableList()\n super().incBound()\n\n # get the last variable.\n idx = len(self.stateNormalPath) - 1\n assert(idx > 0)\n\n # we add the constraints that specify the id of the transition... | [
"0.5525097",
"0.4986752",
"0.49125832",
"0.4824557",
"0.4780409",
"0.46428606",
"0.4635765",
"0.4612767",
"0.45898598",
"0.45873132",
"0.45833403",
"0.45586896",
"0.4558465",
"0.4533727",
"0.45331892",
"0.45319754",
"0.45227927",
"0.45210004",
"0.45153922",
"0.45131692",
"0.4... | 0.7892838 | 0 |
Increment all the list with one new z3 variable. | def incVariableList(self):
super().incVariableList()
idx = len(self.faultyPath) + 1
self.stateFaultyPath.append(Int("stateF_" + str(idx)))
self.stateNormalPath.append(Int("stateN_" + str(idx))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment(self):\r\n self.add_output()\r\n for i in range(self.length-1, 0, -1):\r\n self.slots[i].item = self.slots[i-1].item\r\n self.slots[0].item = Item.random()",
"def addZ(self,name):\n return self._addVar(name,self._zNames)",
"def increase_counter(self):\n ... | [
"0.5772783",
"0.5734561",
"0.5648563",
"0.5566747",
"0.55280125",
"0.54985213",
"0.549282",
"0.54718703",
"0.5464716",
"0.544653",
"0.5406159",
"0.54022837",
"0.53569204",
"0.535667",
"0.53444505",
"0.5337709",
"0.53326064",
"0.5322427",
"0.5283722",
"0.52826965",
"0.5281535"... | 0.5805008 | 0 |
Extend the bound allowing a new transition. | def incBound(self):
# increment the bound for the local variables.
self.incVariableList()
super().incBound()
# get the last variable.
idx = len(self.stateNormalPath) - 1
assert(idx > 0)
# we add the constraints that specify the id of the transition
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_constraint(self, g, g_min, g_max):\n self.g += g\n self.g_min += g_min\n self.g_max += g_max",
"def bind(self):\n super(BoundedTime, self).bind()\n otc = self.on_trait_change\n otc(self._send_minimum, 'minimum')\n otc(self._send_maximum, 'maximum')\n ... | [
"0.5575941",
"0.5537301",
"0.55363774",
"0.5402459",
"0.5361493",
"0.5308574",
"0.5286832",
"0.52651685",
"0.5251278",
"0.5245371",
"0.5196944",
"0.51907897",
"0.5178333",
"0.5178333",
"0.5178333",
"0.51618075",
"0.5126061",
"0.51059085",
"0.5098416",
"0.5092218",
"0.50730306... | 0.6209893 | 0 |
[DEBUG FUNCTION] Check out if the given model satisfies basic property s.t. transitions follow a valid scheme, the id are correct, ... | def checkModel(self, model):
# TODO | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_model(self, model):\n self.check_initial_conditions(model)\n self.check_variables(model)",
"def is_valid(self, data_model: DataModel) -> bool:",
"def test_parameterisation_model(self):\n self.topo.assign_force_field(self.ff)\n for atom in self.topo.get_atoms(inc_alt_states... | [
"0.6045005",
"0.58442265",
"0.58208436",
"0.56169814",
"0.55978364",
"0.55305094",
"0.55228",
"0.5426027",
"0.5401597",
"0.53866255",
"0.53504485",
"0.5265981",
"0.52595747",
"0.52566576",
"0.52254784",
"0.521269",
"0.52003694",
"0.519948",
"0.51923305",
"0.51910585",
"0.5189... | 0.6646549 | 0 |
Whole frequency average velocity | def AllFreAverageV(self,):
v_array = self.data
aaverage_v = np.average(v_array[:,1])
print('Whole frequency average group velocity:\nVw=',aaverage_v/1000,'km/s')
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getavgvel(self):\n if self.total_time:\n return (6.28)/(self.total_time)",
"def get_average(self, s_freq, e_freq):\n s_ind = self.get_bin(s_freq)\n e_ind = self.get_bin(e_freq)\n lst = self.mags[s_ind:e_ind+1]\n try:\n avg = sum(lst)/len(lst)\n ... | [
"0.71112543",
"0.67167395",
"0.64713854",
"0.64713854",
"0.64713854",
"0.63108134",
"0.63091594",
"0.63008803",
"0.62593424",
"0.6182441",
"0.61564493",
"0.6137675",
"0.61102104",
"0.60870063",
"0.6085764",
"0.6080587",
"0.6073182",
"0.60669917",
"0.60464746",
"0.60282415",
"... | 0.75745636 | 0 |
return list of stripped, lower case words from a file | def get_word_list(filename):
f = open(filename,'r')
word_list = list()
for line in f:
for word in line.split():
word_list.append(word.lower().strip())
return word_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_words(file_path):\r\n with open(file_path, encoding='utf-8') as hfile:\r\n return hfile.read().lower().split()",
"def get_words(file_path):\r\n with open(file_path, encoding='utf-8') as hfile:\r\n return hfile.read().lower().split()",
"def get_word_list():\n data_file = open(\"un... | [
"0.77933574",
"0.77933574",
"0.76475996",
"0.7631628",
"0.74474925",
"0.7428373",
"0.73852956",
"0.73748136",
"0.73176396",
"0.73051643",
"0.7284429",
"0.7240503",
"0.72317314",
"0.7218456",
"0.72133315",
"0.72100157",
"0.71904",
"0.7175142",
"0.71502703",
"0.71485853",
"0.71... | 0.7961392 | 0 |
return a list of ntop tuples corresponding to the top ngrams | def top_ngrams(ngram_dict,ntop):
# get list of all ngrams and counts
ngrams = ngram_dict.items()
# sort according to the count
# we use a python lambda function here to say that we want to sort by the
# second item in the tuples contained in the list
ngrams.sort(key=lambda x: x[1], reverse=True)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_top_n_grams():\n ngrams = NgramFrequencies()\n unigrams_dic = {\n \"COUNT\": 10,\n \"time_burton's\": 5,\n \"burton's_corpse\": 4,\n \"corpse_bride\": 1\n }\n top_n_unigrams = ngrams.top_n_grams(unigrams_dic, 2)\n assert top_n_unigrams == [\n (\"time_burto... | [
"0.800804",
"0.751927",
"0.749917",
"0.7207912",
"0.68349135",
"0.6805759",
"0.66989297",
"0.66568947",
"0.66084427",
"0.6597613",
"0.65344614",
"0.65219206",
"0.6519241",
"0.6489179",
"0.6435913",
"0.6420072",
"0.6388739",
"0.6388739",
"0.63686657",
"0.6344633",
"0.6342086",... | 0.77536154 | 1 |
Returns the number of conversations in this forum. | def getNumberOfConversations(node, catalog=None):
if catalog is None:
catalog = getToolByName(node, 'portal_catalog')
return len(catalog(
object_provides=IConversation.__identifier__,
path='/'.join(node.getPhysicalPath()))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_count(self):\n return len(self.messages)",
"def message_count(self):\n return self._message_count",
"def count_chat_with(self, actor_label):\n query = read_query('trust/count_chat_with') % actor_label\n response = self._submit_query(query)\n\n return response[0]['... | [
"0.7046309",
"0.67483366",
"0.6559145",
"0.647817",
"0.6411175",
"0.6347197",
"0.6342727",
"0.63276786",
"0.6303933",
"0.6276361",
"0.6274735",
"0.62053746",
"0.6204217",
"0.619952",
"0.6168952",
"0.6164415",
"0.6070203",
"0.60651463",
"0.60547584",
"0.59845173",
"0.597897",
... | 0.72814435 | 0 |
Function combines netCDF files to create one file for entire time period considered (model input STANDARD MODEL) directory where data sits variable being considered (must be the name used in the netCDF file) model name of model | def combine_netCDF_model(directory, model):
# Make a list of the files in the above folder to loop through
list_files = glob.glob(directory)
list_files = np.array(list_files)
newlist = np.sort(list_files)
# Make a cubelist to add each file (cube) to
Cubelist = iris.cube.CubeList([])
# loo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_netCDF_cmip5(directory, variable, model):\n\n # Make a list of the files in the above folder to loop through\n list_files = glob.glob(directory)\n list_files = np.array(list_files)\n newlist = np.sort(list_files)\n\n # Make a cubelist to add each file (cube) to\n Cubelist = iris.cube.... | [
"0.68928534",
"0.6818621",
"0.6708779",
"0.65313953",
"0.646652",
"0.6359362",
"0.6272831",
"0.62308544",
"0.6121085",
"0.60468936",
"0.6014649",
"0.59575146",
"0.5944848",
"0.5917936",
"0.5826349",
"0.5815866",
"0.5800723",
"0.5794005",
"0.5780657",
"0.577857",
"0.5743063",
... | 0.774098 | 0 |
Function combines netCDF files to create one file for entire time period considered (CMIP5 models) directory where data sits variable being considered (must be the name used in the netCDF file) model name of model | def combine_netCDF_cmip5(directory, variable, model):
# Make a list of the files in the above folder to loop through
list_files = glob.glob(directory)
list_files = np.array(list_files)
newlist = np.sort(list_files)
# Make a cubelist to add each file (cube) to
Cubelist = iris.cube.CubeList([])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_netCDF_model(directory, model):\n\n # Make a list of the files in the above folder to loop through\n list_files = glob.glob(directory)\n list_files = np.array(list_files)\n newlist = np.sort(list_files)\n\n # Make a cubelist to add each file (cube) to\n Cubelist = iris.cube.CubeList([... | [
"0.7850885",
"0.7306603",
"0.72696733",
"0.7100179",
"0.64973336",
"0.6383024",
"0.6218998",
"0.6071201",
"0.6049516",
"0.60359675",
"0.6024158",
"0.59682137",
"0.59461755",
"0.5821918",
"0.58180207",
"0.5722471",
"0.569949",
"0.56754404",
"0.5649554",
"0.5615507",
"0.5559738... | 0.7691586 | 1 |
Function combines netCDF files to create one file for entire time period considered (CMIP6 models, rh variable) directory where data sits variable being considered (must be the name used in the netCDF file) model name of model | def combine_netCDF_rh_cmip6(directory, model):
# Make a list of the files in the above folder to loop through
list_files = glob.glob(directory)
list_files = np.array(list_files)
newlist = np.sort(list_files)
# Make a cubelist to add each file (cube) to
Cubelist = iris.cube.CubeList([])
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_netCDF_model(directory, model):\n\n # Make a list of the files in the above folder to loop through\n list_files = glob.glob(directory)\n list_files = np.array(list_files)\n newlist = np.sort(list_files)\n\n # Make a cubelist to add each file (cube) to\n Cubelist = iris.cube.CubeList([... | [
"0.7696358",
"0.728996",
"0.7249743",
"0.70379186",
"0.6743888",
"0.66946185",
"0.6342759",
"0.625893",
"0.6240598",
"0.62353903",
"0.6177495",
"0.608527",
"0.6048175",
"0.60078746",
"0.5997762",
"0.5959528",
"0.59490365",
"0.5930562",
"0.5833487",
"0.5824405",
"0.58158284",
... | 0.7548332 | 1 |
Function combines netCDF files to create one file for entire time period considered (CMIP6 models, cSoil variable) directory where data sits variable being considered (must be the name used in the netCDF file) model name of model | def combine_netCDF_cSoil_cmip6(directory, model):
# Make a list of the files in the above folder to loop through
list_files = glob.glob(directory)
list_files = np.array(list_files)
newlist = np.sort(list_files)
# Make a cubelist to add each file (cube) to
Cubelist = iris.cube.CubeList([])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_netCDF_model(directory, model):\n\n # Make a list of the files in the above folder to loop through\n list_files = glob.glob(directory)\n list_files = np.array(list_files)\n newlist = np.sort(list_files)\n\n # Make a cubelist to add each file (cube) to\n Cubelist = iris.cube.CubeList([... | [
"0.77082074",
"0.75135547",
"0.73613507",
"0.72303194",
"0.6822005",
"0.68120897",
"0.64225453",
"0.6307422",
"0.62916094",
"0.62495536",
"0.62431705",
"0.61107767",
"0.60765994",
"0.6037625",
"0.60132587",
"0.59606695",
"0.5928667",
"0.5913941",
"0.590283",
"0.5897709",
"0.5... | 0.75927645 | 1 |
Function returns the time, latitude and longitude coordinates of the cube | def define_attributes(new_cube):
time_cmip5 = new_cube.coord('time').points # Defining the time variable
lats_cmip5 = new_cube.coord('latitude').points # Defining the lat variable
lons_cmip5 = new_cube.coord('longitude').points # Defining the lon variable
return time_cmip5, lats_cmip5, lons_cmip5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_spatial_info(cube, add_cyclic=False):\n\n if add_cyclic:\n data, x = add_cyclic_point(cube.data, coord=cube.coord('longitude').points)\n else:\n data = cube.data\n x = cube.coord('longitude').points\n\n y = cube.coord('latitude').points\n inproj = input_projections[cube.att... | [
"0.7040231",
"0.63205254",
"0.6076105",
"0.6048038",
"0.6033739",
"0.6033739",
"0.59600973",
"0.59600973",
"0.59279996",
"0.5906063",
"0.5903138",
"0.5890932",
"0.5886519",
"0.58584267",
"0.58453494",
"0.57595617",
"0.57523465",
"0.5738042",
"0.57239646",
"0.57233423",
"0.571... | 0.6564638 | 1 |
Function calculates time average for cube in current time unit | def time_average(new_cube):
time_average_cube = new_cube.collapsed('time', iris.analysis.MEAN)
return time_average_cube | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def averageTime(self):\n \n pass",
"def avg(self):\n return sum(self.times) / len(self.times)",
"def avg(self):\n return sum(self.times) / len(self.times)",
"def avg(self):\n return sum(self.times) / len(self.times)",
"def avgtime(self):\n return (self._total_time['val... | [
"0.75424707",
"0.6668823",
"0.6668823",
"0.6668823",
"0.6641949",
"0.6560551",
"0.6341996",
"0.62143457",
"0.62049913",
"0.61932725",
"0.61585253",
"0.6117308",
"0.61129653",
"0.6065391",
"0.60597736",
"0.6014156",
"0.59945554",
"0.59869194",
"0.596089",
"0.59294224",
"0.5929... | 0.8113791 | 0 |
Function calculates annual average for cube | def annual_average(new_cube):
annual_average_cube = new_cube.aggregated_by('year', iris.analysis.MEAN)
return annual_average_cube | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decadal_average(new_cube):\n\n decadal_average_cube = new_cube.aggregated_by('decade', iris.analysis.MEAN)\n\n return decadal_average_cube",
"def time_average(new_cube):\n\n time_average_cube = new_cube.collapsed('time', iris.analysis.MEAN)\n\n return time_average_cube",
"def average(self):\n ... | [
"0.7322889",
"0.682975",
"0.6732727",
"0.66880816",
"0.6628982",
"0.65268344",
"0.6518737",
"0.651228",
"0.65111697",
"0.6504521",
"0.64897555",
"0.6473421",
"0.64011014",
"0.6364405",
"0.6337323",
"0.6323115",
"0.6272767",
"0.6247576",
"0.62355834",
"0.6217674",
"0.6189736",... | 0.81573606 | 0 |
Function calculates annual average for cube | def decadal_average(new_cube):
decadal_average_cube = new_cube.aggregated_by('decade', iris.analysis.MEAN)
return decadal_average_cube | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annual_average(new_cube):\n\n annual_average_cube = new_cube.aggregated_by('year', iris.analysis.MEAN)\n\n return annual_average_cube",
"def time_average(new_cube):\n\n time_average_cube = new_cube.collapsed('time', iris.analysis.MEAN)\n\n return time_average_cube",
"def average(self):\n ... | [
"0.8157628",
"0.68300956",
"0.673333",
"0.66885495",
"0.66296524",
"0.6527324",
"0.6519271",
"0.6513142",
"0.6511767",
"0.6505344",
"0.6490278",
"0.6473977",
"0.6401659",
"0.636489",
"0.6337939",
"0.6323608",
"0.6273331",
"0.62478477",
"0.62362915",
"0.6218078",
"0.6190439",
... | 0.73231924 | 1 |
Function that converts a 1, 2, or 3 dimensional numpy array to a cube. (Inverse is array = cube.data) | def numpy_to_cube(np_array, similar_cube, dimensions):
new_cube = iris.cube.Cube.copy(similar_cube) # copy similar cube
# time, lat, lon
if dimensions == 3:
new_cube.data[:,:,:] = np.nan # convert new cube entries to nan
new_cube.data[:,:,:] = np_array # fill with numpy array data
# l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten_cube(cube):\n nb=cube.shape[0]\n cube_flattened = np.zeros_like(cube)\n for i in range(nb):\n cube_flattened[i,:,:] = flatten_image(cube[i,:,:])\n return cube_flattened",
"def cube_array(self):\n cube_sides = {}\n\n for side in SIDES:\n cube_sides[side] = [... | [
"0.66912556",
"0.6495883",
"0.6406177",
"0.6327084",
"0.6305096",
"0.62907904",
"0.62812686",
"0.6161554",
"0.6142271",
"0.6139485",
"0.6103207",
"0.60907686",
"0.60612667",
"0.60612667",
"0.604151",
"0.6035362",
"0.60351485",
"0.5980265",
"0.5909507",
"0.5898174",
"0.585094"... | 0.72946566 | 0 |
Function regrids cube to the dimensions of regridcube | def regrid_model(cube, regridcube):
regridcube.coord('latitude').standard_name = 'latitude'
regridcube.coord('longitude').standard_name = 'longitude'
model_units = cube.coord('latitude').units
regridcube.coord('latitude').units = model_units
regridcube.coord('longitude').units = model_units
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_reshape(cube, nside):\n half_nside = 2**nside / 2\n \n dim1 = cube.shape[1]/2 - half_nside\n dim2 = cube.shape[1]/2 + half_nside\n dim3 = cube.shape[2]/2 - half_nside\n dim4 = cube.shape[2]/2 + half_nside\n\n return cube[:, dim1:dim2, dim3:dim4]",
"def flatten_cube(cube):\n nb=cu... | [
"0.5857552",
"0.5744787",
"0.5737622",
"0.5690372",
"0.5581273",
"0.5580333",
"0.5541399",
"0.54786754",
"0.54719657",
"0.5455025",
"0.54404634",
"0.5436574",
"0.54133695",
"0.54082054",
"0.54025525",
"0.53952885",
"0.5368514",
"0.5363978",
"0.5330306",
"0.5327167",
"0.530444... | 0.6995665 | 0 |
Function to create weighted area average, by collapse a cube to a weighted area average over a specified region, | def area_average(cube, region):
# Specify the latitudes and longitudes starting from the smallest number to largest or in latitude and longitude from south to north and east to west
lon1, lon2, lat1, lat2 = region[0], region[1], region[2], region[3]
# Then intersect the data at these points
cube =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_average(mycube, coord1, coord2):\n import iris.analysis.cartography\n #mycube.coord(coord1).guess_bounds()\n #mycube.coord(coord2).guess_bounds()\n grid_areas = iris.analysis.cartography.area_weights(mycube)\n result = mycube.collapsed([coord1, coord2], iris.analysis.MEAN, weights=grid_area... | [
"0.6913126",
"0.691189",
"0.6342483",
"0.59746987",
"0.564882",
"0.55653477",
"0.5514208",
"0.54767644",
"0.5418298",
"0.533287",
"0.5287598",
"0.52873445",
"0.52814347",
"0.5261448",
"0.52592933",
"0.52577037",
"0.5253883",
"0.52283365",
"0.5221859",
"0.52215064",
"0.5207845... | 0.7545134 | 0 |
Observational dataset version Function to create weighted area average, by collapse a cube to a weighted area average over a specified region, | def area_average_obs(cube, region, model_units):
# Specify the latitudes and longitudes starting from the smallest number to largest or in latitude and longitude from south to north and east to west
lon1, lon2, lat1, lat2 = region[0], region[1], region[2], region[3]
print(cube.coord('latitude').var_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_average(cube, region):\n \n # Specify the latitudes and longitudes starting from the smallest number to largest or in latitude and longitude from south to north and east to west\n lon1, lon2, lat1, lat2 = region[0], region[1], region[2], region[3] \n # Then intersect the data at these points\n... | [
"0.73286384",
"0.6768182",
"0.6255096",
"0.58832103",
"0.56891227",
"0.5565041",
"0.5517444",
"0.54737264",
"0.5437687",
"0.543342",
"0.5398539",
"0.5370421",
"0.53356874",
"0.53291744",
"0.53115916",
"0.5299375",
"0.52825046",
"0.5246105",
"0.51787895",
"0.51728666",
"0.5152... | 0.70315075 | 1 |
Add or Update CODEOWNERS. | def add(orgname, pat, reponame, branchname):
g = Github(pat)
repo = g.get_organization(orgname).get_repo(reponame)
all_files = []
contents = repo.get_contents("")
while contents:
file_content = contents.pop(0)
if file_content.type == "dir":
contents.extend(repo.get_conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_codes(self, codes: str) -> None:\n with open(\"codes\", 'w') as file:\n file.writelines(codes)\n self._codes = codes.split()",
"def update_code(self, new_code):\n self.code = new_code\n\n # Fill in the rest",
"def add_code(self, code):\n self.code += co... | [
"0.55941725",
"0.5247351",
"0.5173246",
"0.5171711",
"0.5171711",
"0.5171689",
"0.514086",
"0.5092468",
"0.5064967",
"0.50472623",
"0.5045446",
"0.5045446",
"0.48126653",
"0.47647685",
"0.47123468",
"0.46902317",
"0.46770835",
"0.46646088",
"0.46453065",
"0.4630909",
"0.46276... | 0.55856395 | 1 |
Gets the death of the creature | def get_death(self):
if self.dead:
self.dead = False
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n try:\n dth = fetch_current_mother_death(self.national_id)\n if self.birth_date and self.child_number:\n dth = fetch_child_death(self.national_id, self.birth_date, self.child_number)\n return dth\n except:\n raise MchCriticalE... | [
"0.7560721",
"0.64127785",
"0.6382229",
"0.6364352",
"0.6329732",
"0.6298581",
"0.6295828",
"0.6264418",
"0.62300104",
"0.62263477",
"0.61510205",
"0.6107857",
"0.60790807",
"0.60565805",
"0.5977672",
"0.5943413",
"0.5921369",
"0.5911695",
"0.5893046",
"0.5889807",
"0.5868352... | 0.65386254 | 1 |
Initialize shitf with shiftdate, starttime, endtime and summary | def __init__(self, date, startTime, endTime, summary, offset):
self.summary = summary
self.start = datetime.datetime.strptime(
date + startTime, "%B %d, %Y%I:%M %p")
self.end = datetime.datetime.strptime(
date + endTime, "%B %d, %Y%I:%M %p")
self.length = self.en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__, *,\n end_date: str,\n start_date: str,\n time: str):\n pulumi.set(__self__, \"end_date\", end_date)\n pulumi.set(__self__, \"start_date\", start_date)\n pulumi.set(__self__, \"time\", time)",
"def __init__(self, step_tim... | [
"0.6367719",
"0.6251153",
"0.6137436",
"0.6111023",
"0.6073479",
"0.58639795",
"0.5841218",
"0.5784541",
"0.5752838",
"0.57325613",
"0.57300085",
"0.572106",
"0.5698278",
"0.5662084",
"0.5651666",
"0.5648332",
"0.56428844",
"0.5628727",
"0.55748963",
"0.55634373",
"0.55548733... | 0.63153726 | 1 |
Merge shift with other shift, changing the ending time and adding a lunchbreak in event description | def mergeShift(self, shift):
self.end = shift.end
if shift.summary == "Lunch":
self.description = str(int(
shift.length.seconds / 60)) + " minuter lunchrast!" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateCalendar(page, offset=\"+02:00\"):\n\n dashboard = BeautifulSoup(page.content, features=\"lxml\")\n\n # Only search in the agenda portion of the dashboard\n agenda = dashboard.find(\"div\", class_=\"pane__body agenda-spacer\")\n\n # List to store the all the shift of the next 7 days\n shif... | [
"0.53368765",
"0.5287871",
"0.5286334",
"0.5272928",
"0.5262467",
"0.5219377",
"0.5150225",
"0.50966203",
"0.5078247",
"0.507187",
"0.5053098",
"0.5049378",
"0.5049378",
"0.5015672",
"0.4989651",
"0.49886978",
"0.4988594",
"0.49789613",
"0.4944345",
"0.49178886",
"0.490327",
... | 0.81993693 | 0 |
Get a the shift in a Google Calendar event format | def getEvent(self):
event = {
"summary": "H1 " + self.summary,
"location": LOCATION,
# The H1 tag "classifies" event as a shift
"description": self.description + "\n\nH1 Communication arbetspass",
"start": {
"dateTime": "{0}T{1}{2}".fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_google(c_event):\n g_dict = {}\n\n g_dict[\"iCalUID\"] = c_event.id\n # if self.google_id:\n # g_dict[\"id\"] = self.google_id\n g_dict[\"summary\"] = c_event.subject\n\n if c_event.updated:\n # je rajoute une microsecondes pour que google m'emmerde pas avec des formats de date ... | [
"0.5894306",
"0.5804386",
"0.56109",
"0.55186474",
"0.55066156",
"0.5452542",
"0.5432442",
"0.54125553",
"0.5390357",
"0.5386071",
"0.53731745",
"0.5334295",
"0.5334295",
"0.53330165",
"0.53121805",
"0.52881366",
"0.52879095",
"0.5283361",
"0.52468383",
"0.51945484",
"0.51945... | 0.746466 | 0 |
Comprehensive update calendar function linked to button in GUI | def btnUpdateCalendar():
page = getDataPage(uNameEntry.get(), pWordEntry.get())
if page is not None:
promptString.set("Updated!")
promptLabel.config(fg="green2")
updateCalendar(page, offsetString.get())
# "Updated!"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_calendar():\n manage.refresh_calendar()",
"def main():\n# year = int(input(\"Enter year for calendar: \"))\n# first_day = first_day_of_year(year)\n\n # Loop through months 1 through 12\n # for month in range(1, NUM_MONTHS + 1):\n# first_day = print_month(first_day, month, year)\n\n ... | [
"0.705256",
"0.699359",
"0.6620295",
"0.64442635",
"0.6369916",
"0.63661087",
"0.6326337",
"0.6267138",
"0.62598336",
"0.6253632",
"0.623109",
"0.6225931",
"0.61823964",
"0.61339366",
"0.6096235",
"0.6018332",
"0.5996281",
"0.59210324",
"0.5905926",
"0.5905926",
"0.58939666",... | 0.7829396 | 0 |
Directories containing shared libraries that must be on the runtime library search path. | def library_dirs(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linking_library_dirs(self):",
"def library_search_path(self, pedantic=False):\n return []",
"def lib_directories(self):\n if self._lib_directories is None:\n self._lib_directories = []\n app_path = os.getcwd()\n contents = os.listdir(app_path)\n for... | [
"0.75469124",
"0.7403588",
"0.71833014",
"0.7128075",
"0.70617986",
"0.6924565",
"0.66645074",
"0.6522542",
"0.64480674",
"0.6352177",
"0.6319995",
"0.6318672",
"0.6300596",
"0.62622315",
"0.62427896",
"0.6205989",
"0.61918676",
"0.6189307",
"0.6185732",
"0.6102581",
"0.60970... | 0.7558966 | 0 |
A dict to use as this Executable's execution environment. | def as_invocation_environment_dict(self):
lib_env_var = self._platform.resolve_platform_specific({
'darwin': lambda: 'DYLD_LIBRARY_PATH',
'linux': lambda: 'LD_LIBRARY_PATH',
})
return {
'PATH': create_path_env_var(self.path_entries),
lib_env_var: create_path_env_var(self.library_dirs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def environment(self) -> dict:\n return self._environment_info",
"def get_environment_map(self):\n return {'oxmeta': self.env}",
"def environment(self):\n return self._environ",
"def _create_extra_environment(self):\n return {}",
"def env_dict(self): # type: () -> t.Dict[str, s... | [
"0.7325461",
"0.718793",
"0.7046197",
"0.6894638",
"0.68697304",
"0.6829901",
"0.6806014",
"0.6795331",
"0.6795331",
"0.6795331",
"0.6772731",
"0.67310315",
"0.67218786",
"0.662578",
"0.6617546",
"0.66135913",
"0.6605698",
"0.65840006",
"0.65572524",
"0.65489554",
"0.6547647"... | 0.7302436 | 1 |
Directories to search for libraries needed at link time. | def linking_library_dirs(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def library_dirs(self):",
"def lib_directories(self):\n if self._lib_directories is None:\n self._lib_directories = []\n app_path = os.getcwd()\n contents = os.listdir(app_path)\n for c in contents:\n # ensure content starts with lib, is directory... | [
"0.8093109",
"0.76354676",
"0.75914395",
"0.7270887",
"0.71270585",
"0.69573325",
"0.68820333",
"0.68035865",
"0.6796537",
"0.67551184",
"0.6521241",
"0.6508131",
"0.6459326",
"0.63513607",
"0.63117814",
"0.6301882",
"0.6295595",
"0.6295595",
"0.61999345",
"0.61815035",
"0.61... | 0.79840356 | 1 |
Directories to search for header files to include during compilation. | def include_dirs(self): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_include_files(self):\n for dirpath, dirnames, filenames in os.walk(self.IncludesDirectory):\n for f in filenames:\n rel_name = path.join(dirpath, f)\n if f.endswith('.pyx'):\n yield (rel_name, 'PyRex')\n elif f.endswith('.h'... | [
"0.7077578",
"0.6932059",
"0.6760445",
"0.6757965",
"0.6601764",
"0.64238584",
"0.6305247",
"0.62566674",
"0.6254538",
"0.6241335",
"0.62157947",
"0.61766666",
"0.6160378",
"0.61014384",
"0.60742205",
"0.60271347",
"0.6017583",
"0.60026914",
"0.5968775",
"0.5937765",
"0.58890... | 0.74102336 | 0 |
Split the given dataset into training, development, and testing sets using the given ratio | def make_train_devel_test_split(data: Iterable, ratio: str) -> (Iterable, Iterable, Iterable):
# Parse the splitting ratio
train, devel, test = [int(x) for x in ratio.split(':')]
# First split into training+development and test
train_devel, _test = train_test_split(data, test_size=(test / (train + deve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_split(dataset, val_ratio=0.1, test_ratio=0.1, seed=1234):\n\n\t# How you grab the labels will depend on what type of Pytorch Dataset object 'dataset' is\n\t# (i.e. ImageFolder/DatasetFolder or not)\n\n\t# For fun, check the method resolution order (MRO) of 'dataset'\n\tprint('Dataset object\\'s inheritanc... | [
"0.79161614",
"0.7906666",
"0.7821396",
"0.7798361",
"0.7738746",
"0.7702149",
"0.76962346",
"0.76860684",
"0.76637816",
"0.7625668",
"0.76185",
"0.7562421",
"0.75390583",
"0.74471146",
"0.7435983",
"0.7387401",
"0.7357427",
"0.733066",
"0.7273315",
"0.7260147",
"0.72379297",... | 0.7978173 | 0 |
Run the given model using the given cohort and experimental settings contained in args. | def run_model(model, raw_cohort, delta_encoder):
import scipy
snapshot_sizes = []
for chronology in raw_cohort.chronologies():
for snapshot in chronology.snapshots:
snapshot_sizes.append(len(snapshot))
print('Statistics on snapshot sizes:', scipy.stats.describe(snapshot_sizes))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_pytorch_model(model_name, create_model, X_train, y_train, cohorts_train,\n X_val, y_val, cohorts_val,\n X_test, y_test, cohorts_test,\n all_tasks, FLAGS, samp_weights):\n model_fname_parts = get_model_fname_parts(model_name, FLAGS)\n if F... | [
"0.6540495",
"0.632571",
"0.62278086",
"0.62278086",
"0.62278086",
"0.6226528",
"0.61738354",
"0.6093629",
"0.60406893",
"0.5989501",
"0.59611666",
"0.58799607",
"0.5861833",
"0.58534724",
"0.5781252",
"0.5774069",
"0.5773607",
"0.57524866",
"0.57196677",
"0.56881243",
"0.566... | 0.7173955 | 0 |
Fetch the given metrics from the given dataset metric dictionary in the order they were given | def _evaluate(dataset: dict, name: str, metrics=None):
if metrics is None:
metrics = ['Accuracy', 'AUROC', 'AUPRC', 'Precision', 'Recall', 'F1', 'F2']
measures = [dataset[metric] for metric in metrics]
measures.insert(0, name)
return measures | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_with_metrics(self, dataset, metrics, *args, **kwargs):\n\n utils.assert_raise(isinstance(metrics, dict), ValueError,\n '\"metrics\" must be a dict with metric_name -> metric_function')\n result = dict()\n\n for sample in dataset:\n output = sel... | [
"0.6575992",
"0.6156549",
"0.5982362",
"0.5958017",
"0.5932443",
"0.56794566",
"0.5569475",
"0.5496162",
"0.5475641",
"0.5436359",
"0.54316115",
"0.54244566",
"0.5416602",
"0.5412184",
"0.5409456",
"0.5398741",
"0.53750396",
"0.5357566",
"0.53525865",
"0.5339576",
"0.53367436... | 0.63646007 | 1 |
Use this command in your questions channel | async def question_setup(self, ctx):
config = self.bot.db['questions'].setdefault(str(ctx.guild.id), {})
if str(ctx.channel.id) in config:
msg = await hf.safe_send(ctx, "This will reset the questions database for this channel. "
"Do you wish to cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def set_questions(self, ctx: commands.Context):\n\n def check(m):\n return m.author == ctx.author and m.channel == ctx.channel\n\n await ctx.send(\n \"Let's set up those questions we've not pre-filled:\\nYou will be setting questions 8-12. You can view the preloaded questi... | [
"0.6865836",
"0.67297447",
"0.6513587",
"0.6453275",
"0.64262396",
"0.6419227",
"0.6329059",
"0.62837905",
"0.6257158",
"0.6200049",
"0.6185644",
"0.6135143",
"0.61101407",
"0.6103426",
"0.60928136",
"0.6085484",
"0.6081694",
"0.60556054",
"0.6040353",
"0.60199344",
"0.601905... | 0.67852944 | 1 |
Reopens a closed question, point message_id to the log message in the log channel | async def open(self, ctx, message_id):
config = self.bot.db['questions'][str(ctx.guild.id)][str(ctx.channel.id)]
for question in config['questions']:
if int(message_id) == config['questions'][question]['log_message']:
question = config['questions'][question]
b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_question(request, question_id):\n question = get_object_or_404(Question, id=question_id)\n if not auth.can_close_question(request.user, question):\n raise Http404\n if not question.closed:\n return _close_question(request, question)\n else:\n return _reopen_question(reque... | [
"0.620179",
"0.5718971",
"0.5581178",
"0.5541239",
"0.5506532",
"0.54992765",
"0.5397318",
"0.5368448",
"0.53246254",
"0.5228746",
"0.52244455",
"0.5162922",
"0.5124592",
"0.5122743",
"0.5119608",
"0.5106137",
"0.5105371",
"0.5103737",
"0.5090048",
"0.5089565",
"0.5081385",
... | 0.7623594 | 0 |
Shows a list of currently open questions | async def question_list(self, ctx, target_channel=None):
if not target_channel:
target_channel = ctx.channel
try:
config = self.bot.db['questions'][str(ctx.guild.id)]
except KeyError:
await hf.safe_send(target_channel, f"There are no questions channels on this... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(request):\n extra_context = {\n # TODO Retrieve extra context required for index page\n }\n return question_list(request, index_question_views, 'index.html',\n questions_per_page=50, page_number=1,\n extra_context=extra_context)",
"def ask... | [
"0.6398322",
"0.6321389",
"0.6257754",
"0.62307966",
"0.6210564",
"0.6204572",
"0.61423963",
"0.613693",
"0.6119014",
"0.60827774",
"0.6081294",
"0.6023545",
"0.59992516",
"0.59712636",
"0.5964277",
"0.58866954",
"0.5885314",
"0.5877331",
"0.58682114",
"0.5843453",
"0.5804163... | 0.643861 | 0 |
Respond to a question in the question log and log your response. You must do this in the channel \ | async def respond(self, ctx, index, *, response):
try:
config = self.bot.db['questions'][str(ctx.guild.id)][str(ctx.channel.id)]
except KeyError:
return
if not response:
await hf.safe_send(ctx, "You need to type something for your response.")
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _post_log(self, ctx):\n try:\n config = self.bot.db['questions'][str(ctx.guild.id)][str(ctx.channel.id)]\n except KeyError:\n return\n\n log_channel = ctx.guild.get_channel(config['log_channel'])\n if not log_channel:\n await hf.safe_send(ctx, ... | [
"0.69319063",
"0.67566717",
"0.6573071",
"0.64403784",
"0.64403784",
"0.63855106",
"0.63534033",
"0.63115925",
"0.6278882",
"0.62717414",
"0.6263568",
"0.622931",
"0.6221601",
"0.61904585",
"0.61805254",
"0.61630356",
"0.6149683",
"0.61187774",
"0.6109084",
"0.609677",
"0.608... | 0.7784228 | 0 |
Internal command for deleting the last message in log channel if it is `;q list` result | async def _delete_log(self, ctx):
try:
config = self.bot.db['questions'][str(ctx.guild.id)][str(ctx.channel.id)]
except KeyError:
return
log_channel = ctx.guild.get_channel(config['log_channel'])
if not log_channel:
await hf.safe_send(ctx, "The origin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def remove_last_element(message: types.Message):\n commands.remove_last(message.chat.id)\n await message.answer('Done 👌')",
"async def logremove(self, ctx):\n if await check_if_logged(channel_id=ctx.channel.id):\n c.execute(\"DELETE FROM logging.channels WHERE channelid = %s\", (ct... | [
"0.67126006",
"0.6399114",
"0.61968356",
"0.60765827",
"0.6069464",
"0.60446584",
"0.6029817",
"0.5899143",
"0.5856955",
"0.5779672",
"0.57305145",
"0.5726048",
"0.5722046",
"0.5719388",
"0.5719388",
"0.56835306",
"0.565366",
"0.5632941",
"0.5613715",
"0.5613586",
"0.5601329"... | 0.755016 | 0 |
Change the value of the global variable team. | def change_team():
# Use team in global scope
global team
# Change the value of team in global: team
team ="justice league" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_team():\n\n # Use team in global scope\n global team\n\n # Change the value of team in global: team\n team = 'newEclerx'",
"def set_team(self, team):\n self.team = team.upper()",
"def team(self, team):\n\n self._team = team",
"def team(self, team):\n\n self._team =... | [
"0.8964348",
"0.81824064",
"0.7520355",
"0.7520355",
"0.7520355",
"0.7520355",
"0.73338187",
"0.6892088",
"0.67718667",
"0.6756867",
"0.6716827",
"0.670985",
"0.6658303",
"0.65838724",
"0.6552398",
"0.65387535",
"0.65211505",
"0.6513031",
"0.6482544",
"0.6466852",
"0.6441778"... | 0.89437294 | 1 |
Returns a string concatenated with '!!!'. | def inner(word):
return word + '!!!' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shout():\n # Concatenate the strings: shout_word\n shout_word = 'congratulations'+'!!!'\n\n # Print shout_word\n print(shout_word)",
"def repeat(s,exclaim):\n result = s+s+s\n if exclaim:\n result = result + '!!!'\n return result",
"def shout():\n # Concatenate the strings: shout_word\... | [
"0.6222425",
"0.62033045",
"0.61873996",
"0.59948725",
"0.59948725",
"0.59463835",
"0.59098756",
"0.5884046",
"0.57748294",
"0.5744767",
"0.57358265",
"0.57358265",
"0.57358265",
"0.5682084",
"0.5681596",
"0.5601378",
"0.5575337",
"0.5566258",
"0.5560172",
"0.5552537",
"0.554... | 0.6519947 | 0 |
Concatenate echo copies of word1 and three exclamation marks at the end of the string. | def shout_echo(word1, echo=1):
# Raise an error with raise
if echo < 0:
raise ValueError('echo must be greater than 0')
# Concatenate echo copies of word1 using *: echo_word
echo_word = word1 * echo
# Concatenate '!!!' to echo_word: shout_word
shout_word = echo_word + '!!!'
# Ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inner(word):\n return word + '!!!'",
"def shout(word1, word2):\n # Concatenate word1 with '!!!': shout1\n shout1=word1+'!!!'\n \n # Concatenate word2 with '!!!': shout2\n shout2=word2+'!!!'\n \n # Concatenate shout1 with shout2: new_shout\n new_shout=shout1 +shout2\n\n # Ret... | [
"0.7053086",
"0.6753476",
"0.66559994",
"0.65202314",
"0.6513149",
"0.6500432",
"0.6500432",
"0.64625895",
"0.64625895",
"0.64625895",
"0.6428077",
"0.6428077",
"0.642766",
"0.6398502",
"0.6359664",
"0.6292465",
"0.6271142",
"0.62307423",
"0.6201465",
"0.6185885",
"0.6133357"... | 0.6897572 | 1 |
Promote inner enumeration classes to root classes. | def promote(self, target: Class):
for inner in list(target.inner):
if inner.is_enumeration:
target.inner.remove(inner)
clone = self.clone_enumeration(inner, target.name)
self.container.add(clone)
for attr in target.attrs:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flag_inner_classes(obj):\n for tup in class_members(obj):\n tup[1]._parent = obj\n tup[1]._parent_inst = None\n tup[1].__getattr__ = my_getattr\n flag_inner_classes(tup[1])",
"def test_type_builder_handles_top_level_enumerations():\n schema = [\n SchemaEnum(name=\"Tes... | [
"0.5597397",
"0.551863",
"0.5394508",
"0.5193353",
"0.51649934",
"0.5152086",
"0.5149415",
"0.5119464",
"0.5002037",
"0.49531645",
"0.49510548",
"0.49382526",
"0.49345383",
"0.4919199",
"0.4906258",
"0.48903167",
"0.4871637",
"0.48355246",
"0.48324627",
"0.48048753",
"0.47771... | 0.6503705 | 0 |
This allows to override the default parameters of the HTTPConnectionPool constructor. For example, to increase the poolsize to fix problems with "HttpConnectionPool is full, discarding connection" | def patch_http_connection_pool(**constructor_kwargs):
class MyHTTPConnectionPool(connectionpool.HTTPConnectionPool):
def __init__(self, *args, **kwargs):
kwargs.update(constructor_kwargs)
super(MyHTTPConnectionPool, self).__init__(*args, **kwargs)
poolmanager.pool_classes_by_sche... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pool_size: float = 10):\n self.pool_size = pool_size",
"def update_connection_pool(maxsize=1):\n get_pool().connection_pool_kw.update(maxsize=maxsize)",
"def __init__(self, pool_size):\n \n self.pool_size=pool_size;",
"def __init__(__self__, *,\n pool_si... | [
"0.71038437",
"0.67619383",
"0.66508365",
"0.66208494",
"0.63541883",
"0.6333262",
"0.6247927",
"0.6240192",
"0.617527",
"0.6174266",
"0.6133966",
"0.61313546",
"0.6122735",
"0.6122276",
"0.60972023",
"0.6002233",
"0.5935005",
"0.5896573",
"0.58955556",
"0.5869677",
"0.586501... | 0.7543071 | 0 |
Reconstruct a single series according to the time stamp The missing parts will be imputed with zeroes | def reconstruct_data(time_stamp, values=None, label=None):
time_stamp = np.asarray(time_stamp, np.int64)
if len(time_stamp.shape) != 1:
raise ValueError('`time_stamp` must be an 1-D array!')
src_index = np.argsort(time_stamp) # Sorted indices
time_stamp_sorted = time_stamp[src_index] # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fillna(ts: TimeSeries, fill: float = 0) -> TimeSeries:\n\n return TimeSeries.from_times_and_values(ts.time_index(), ts.pd_dataframe().fillna(value=fill))",
"def ts_fit(series: TimeSeries) -> TimeSeries:\n pass",
"def _none_drift(frame_times):\n return np.reshape(np.ones_like(frame_times), (np.... | [
"0.5711128",
"0.5696913",
"0.5666906",
"0.566565",
"0.56124264",
"0.55890685",
"0.55890685",
"0.558441",
"0.5575237",
"0.55733806",
"0.55624354",
"0.552414",
"0.5518508",
"0.55140245",
"0.5491514",
"0.5489598",
"0.54666287",
"0.54636514",
"0.54582536",
"0.54465455",
"0.538316... | 0.6125694 | 0 |
The main loop of the machine learning process This loop is run in a seperate process, and communicates with the game process. Note that the game process won't wait for the ml process to generate the GameInstrcution. It is possible that the frame of the GameInstruction is behind of the current frame in the game process.... | def ml_loop():
# === Here is the execution order of the loop === #
# 1. Put the initialization code here.
# 2. Inform the game process that ml process is ready before start the loop.
filename="predicDirection.sav"
filepath = os.path.join(os.path.dirname(__file__), filename)
super_sid = pickle.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n TOTAL_NUM = 500\n IMG_NAME = 'img'\n LABEL_NAME = 'label'\n\n img = fluid.layers.data(name=IMG_NAME, shape=[1, 28, 28], dtype='float32')\n # gradient should flow\n img.stop_gradient = False\n label = fluid.layers.data(name=LABEL_NAME, shape=[1], dtype='int64')\n logits = mnist... | [
"0.66156954",
"0.6592174",
"0.65795803",
"0.6561198",
"0.652788",
"0.6512555",
"0.6511562",
"0.6461014",
"0.6416258",
"0.64090216",
"0.6348187",
"0.6322364",
"0.63154984",
"0.63084966",
"0.6275682",
"0.62529373",
"0.6248192",
"0.62150025",
"0.6174055",
"0.6156201",
"0.6142303... | 0.76215136 | 0 |
Creates boto3 client for provided service. | def boto_client(account_id, service_name, region):
logger.info('Creating boto3 client for account_id: {}, '
'service_name: {}'.format(account_id, service_name))
return boto3.client(service_name, region_name=region) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_boto3_client(config, service):\n session = boto3.Session(profile_name=config.get('AWS_ACCESS', 'AWS_PROFILE'))\n return session.client(service, region_name=config.get('AWS_ACCESS', 'AWS_REGION'))",
"def create_client(service, region, access_key_id, secret_access_key):\n client = boto3.client(... | [
"0.86203206",
"0.81236863",
"0.81236863",
"0.78701615",
"0.771792",
"0.75774705",
"0.7506647",
"0.7479139",
"0.7359011",
"0.7259947",
"0.7192553",
"0.7117116",
"0.7069467",
"0.6817082",
"0.67918366",
"0.67495674",
"0.6709679",
"0.66619575",
"0.6657035",
"0.661893",
"0.6618055... | 0.84027034 | 1 |
Perform the lazy matvec product, where vec is either a tree with the same structure as params or a ravelled vector | def onthefly_mat_treevec(
S: QGTOnTheFly, vec: Union[PyTree, jnp.ndarray]
) -> Union[PyTree, jnp.ndarray]:
# if has a ndim it's an array and not a pytree
if hasattr(vec, "ndim"):
if not vec.ndim == 1:
raise ValueError("Unsupported mat-vec for chunks of vectors")
# If the input i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_vector_prod(m,u):\n each_product = []\n for v in m:\n each_product.append(dot_prod(v, u))\n return each_product",
"def _z2matvecmul(self, mat, vec):\n prod = np.mod(np.dot(mat, vec), 2)\n return prod",
"def matvec(self, x):\n return self * x",
"def prod(vector)... | [
"0.6020575",
"0.59572285",
"0.5829562",
"0.5790131",
"0.5767388",
"0.5751265",
"0.5732051",
"0.5656311",
"0.5630666",
"0.55937207",
"0.5583709",
"0.5516516",
"0.55007994",
"0.5467974",
"0.5454353",
"0.5452895",
"0.5392581",
"0.538201",
"0.5380759",
"0.53781724",
"0.5338067",
... | 0.6851942 | 0 |
Convert the lazy matrix representation to a dense matrix representation | def _to_dense(self: QGTOnTheFlyT) -> jnp.ndarray:
Npars = nkjax.tree_size(self._params)
I = jax.numpy.eye(Npars)
if self._chunking:
# the linear_call in mat_vec_chunked does currently not have a jax batching rule,
# so it cannot be vmapped but we can use scan
# which is better for r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapDBMatrix(self,mat):\n return mat.todense()",
"def todense(self):\n d = np.zeros(self.shape)\n for index,value in zip(self.index, self.value):\n d[index] = value\n return d",
"def to_dense(self):\n rep = self.rep\n\n if rep.fmt == 'dense':\n re... | [
"0.68869424",
"0.6709543",
"0.6661523",
"0.6647116",
"0.65625423",
"0.6417341",
"0.635445",
"0.624063",
"0.61100817",
"0.6105737",
"0.60766107",
"0.60749143",
"0.6071458",
"0.6066217",
"0.60322756",
"0.6031761",
"0.6020581",
"0.6011145",
"0.60058963",
"0.5989705",
"0.592235",... | 0.68174934 | 1 |
Convert medical imaging volumes to TFRecords. Volumes must all be the same shape. This will overwrite existing TFRecords files. | def convert(*, csv, tfrecords_template, volume_shape, volumes_per_shard, to_ras, gzip, verify_volumes, num_parallel_calls, verbose):
# TODO: improve docs.
volume_filepaths = _read_csv(csv)
num_parallel_calls = None if num_parallel_calls == -1 else num_parallel_calls
if num_parallel_calls is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_multipart_volumes(pid, multipart_legacy_recid, migration_volumes):\n volumes = {}\n # Combine all volume data by volume number\n click.echo('Creating volume for {}...'.format(multipart_legacy_recid))\n for obj in migration_volumes:\n volume_number = obj['volume']\n if volume_nu... | [
"0.5980204",
"0.55791706",
"0.5408041",
"0.5367784",
"0.53065264",
"0.5280676",
"0.52806556",
"0.5248773",
"0.52067465",
"0.5202369",
"0.5160102",
"0.5150483",
"0.51413417",
"0.51386124",
"0.51344407",
"0.5118625",
"0.51114666",
"0.5085689",
"0.50827205",
"0.5079441",
"0.5063... | 0.61405885 | 0 |
redraw the graphic PSD plot if needed i.e.new data have been given to get_psd | def refresh_psd(self, z=None):
if self.need_refresh:
try:
self.canvas.draw()
self.need_refresh = False
except IndexError as err_idx:
print("Warning:", err_idx)
self.tk_root.after(2000, self.refresh_psd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_psd(self):\n from .error import show_error\n from ..backend.viz_raw import \\\n _plot_topomap, _plot_matrix, _plot_all_psd\n\n if self.plotType == 'Topomap':\n try:\n _plot_topomap(self)\n except ValueError:\n show_error(\... | [
"0.6820242",
"0.6493793",
"0.64711475",
"0.64711475",
"0.6251599",
"0.61965746",
"0.6141617",
"0.6096861",
"0.60455394",
"0.60293007",
"0.60182506",
"0.5982424",
"0.5980295",
"0.5980295",
"0.5980295",
"0.5980295",
"0.5980295",
"0.5976722",
"0.5962926",
"0.59223557",
"0.589140... | 0.65734637 | 1 |
Compute the padding necessary to ensure that convolving 'X' with a 2D kernel of shape 'kernel_shape' and stride 'stride' produces outputs with dimension 'out_dim' | def calc_pad_dims_2D(X_shape, out_dim, kernel_shape, stride, dilation=0):
if not isinstance(X_shape, tuple):
raise ValueError("X_shape must be of type tuple")
if not isinstance(out_dim, tuple):
raise ValueError("out_dim must be of type tuple")
if not isinstance(kernel_shape, tuple):
raise ValueError("kernel_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_pad_dims_2D(X_shape, out_dim, kernel_shape, stride, dilation=0):\n if not isinstance(X_shape, tuple):\n raise ValueError(\"`X_shape` must be of type tuple\")\n\n if not isinstance(out_dim, tuple):\n raise ValueError(\"`out_dim` must be of type tuple\")\n\n if not isinstance(kernel_s... | [
"0.8247134",
"0.7567151",
"0.7563502",
"0.75364166",
"0.7374004",
"0.7361205",
"0.7306342",
"0.729063",
"0.7279653",
"0.7209143",
"0.7207988",
"0.7174449",
"0.7173881",
"0.71691567",
"0.71236885",
"0.71168876",
"0.7110765",
"0.709979",
"0.7019291",
"0.6944721",
"0.6938874",
... | 0.8221825 | 1 |
Compute the padding necessary to ensure that convolving 'X' with a 1D kernel of shape 'kernel_shape' and stride 'stride' produces outputs with length 'l_out' | def calc_pad_dims_1D(X_shape, l_out, kernel_width, stride, dilation=0, causal=False):
if not isinstance(X_shape, tuple):
raise ValueError("X_shape must be type tuple")
if not isinstance(l_out, int):
raise ValueError("l_out must be type int")
if not isinstance(kernel_width, int):
raise ValueError("kernel_widt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l_out(l_in: int, padding: int, dilation: int, kernel: int, stride: int) -> int:\n return (l_in + 2 * padding - dilation * (kernel - 1) - 1) // stride + 1",
"def l_out_pool(l_in, kernel_size, stride=None, padding=0, dilation=1):\n if stride == None:\n stride = kernel_size\n l_out = int(\n ... | [
"0.7611012",
"0.733894",
"0.72302073",
"0.7213094",
"0.71773523",
"0.7081073",
"0.6933778",
"0.68309605",
"0.67562455",
"0.668144",
"0.6660785",
"0.66606504",
"0.6654768",
"0.6646968",
"0.66388535",
"0.66267",
"0.6568458",
"0.6564548",
"0.6563976",
"0.65409815",
"0.65240794",... | 0.79546314 | 0 |
Dilate the 4D volumn 'X' by 'd' References .. [1] Dumoulin & Visin (2016). "A guide to convolution arithmetic for deep | def dilate(X, d):
n_ex, in_rows, in_cols, n_in = X.shape
r_ix = np.repeat(np.arange(1, in_rows), d)
c_ix = np.repeat(np.arange(1, in_cols), d)
Xd = np.insert(X, r_ix, 0, axis=1)
Xd = np.insert(Xd, c_ix, 0, axis=2)
return Xd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ddx(a):\n\t# avoid corner effects\n\tthick = 2\n\ta = np.concatenate((a[(thick-1)::-1],a,a[:-(thick+1):-1]))\n\tmode=\"same\"\n\tmode = \"valid\"\n\t\n\tK = np.array([-0.5,0,0.5])\n\tda = scig.convolve(a,K,mode=mode)\n\treturn da",
"def conv4d(data,filters,bias=None,permute_filters=True,use_half=False):\n ... | [
"0.6547426",
"0.6445476",
"0.6338323",
"0.5974971",
"0.597283",
"0.5940121",
"0.5848455",
"0.5810694",
"0.5791508",
"0.5781973",
"0.5754638",
"0.573389",
"0.5725913",
"0.5719282",
"0.57154363",
"0.57099086",
"0.569137",
"0.56793755",
"0.5670417",
"0.56598794",
"0.5645608",
... | 0.68139446 | 0 |
compute the fanin and fanout for a weight matrix | def calc_fan(weight_shape):
if len(weight_shape) == 2:
fan_in, fan_out = weight_shape
elif len(weight_shape) in [3, 4]:
in_ch, out_ch = weight_shape[-2:]
kernel_size = np.prod(weight_shape[:-2])
fan_in, fan_out = in_ch * kernel_size, out_ch * kernel_size
else:
raise ValueError('unrecognized weight dimensio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_fans(shape):\n if len(shape) == 2:\n # 2D weight matrix, which maps from fan-in to fan-out\n # Shape: [fan-in, fan-out]\n fan_in = shape[0]\n fan_out = shape[1]\n elif len(shape) == 4:\n # 4D weight matrix, representing a set of convolutional kernels/filters\n ... | [
"0.6973531",
"0.6040282",
"0.5788856",
"0.5637249",
"0.5604988",
"0.55755883",
"0.5575273",
"0.55383766",
"0.55220973",
"0.54855496",
"0.5439649",
"0.54370713",
"0.5403235",
"0.5391632",
"0.53903145",
"0.53801125",
"0.53787583",
"0.53724223",
"0.5347184",
"0.531767",
"0.52966... | 0.6871772 | 1 |
pads and rearrange overlapping windows of the input volume into column vectors, returning the concatenated padded vectors in a matrix 'X_col' Notes A numpy reimaginning of matlabs im2col sliding function Code extended from Andrej Karpathy's ``im2col.py``. | def im2col(X, W_shape, pad, stride, dilation=0):
fr, fc, n_in, n_out = W_shape
s, p, d = stride, pad, dilation
n_ex, in_rows, in_cols, n_in = X.shape
# zero-pad the input
X_pad, p = pad2D(X, p, W_shape[:2], stride=s, dilation=d)
pr1, pr2, pc1, pc2 = p
# change to have channels as the first dim
X_pad = X_pad.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def im2col(A, window, stepsize=1):\n return viewW(np.ascontiguousarray(A), (window[0], window[1])).reshape(-1,\n window[0] * window[1]).T[:, ::stepsize]",
"def col2im(X_col, X_shape, W_shape, pad, stride, dilation=0):\n\tif not(isinstanc... | [
"0.6478389",
"0.6469344",
"0.6116257",
"0.6009265",
"0.5859572",
"0.57657206",
"0.5757209",
"0.57050896",
"0.56626934",
"0.5656507",
"0.56151724",
"0.55749243",
"0.5530006",
"0.54665685",
"0.5361076",
"0.53352684",
"0.53114575",
"0.5281283",
"0.52577585",
"0.5206046",
"0.5206... | 0.6598939 | 0 |
Perform a "deconvolution" (more accurately, a transposed convolution) of an input volume `X` with a weight kernel `W`, incorporating stride, pad, and dilation. Notes Rather than using the transpose of the convolution matrix, this approach uses a direct convolution with zero padding, which, while conceptually straightfo... | def deconv2D_naive(X, W, stride, pad, dilation=0):
if stride > 1:
X = dilate(X, stride-1)
stride = 1
# pad the input
X_pad, p = pad2D(X, pad, W.shape[:2], stride=stride, dilation=dilation)
n_ex, in_rows, in_cols, n_in = X.shape
fr, fc, n_in, n_out = W.shape
s, d = stride, dilation
pr1, pr2, pc1, pc2 = p
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv2D(X, W, stride, pad, dilation=0):\n\ts, d = stride, dilation\n\t_, p = pad2D(X, pad, W.shape[:2], s, dilation=dilation)\n\n\tpr1, pr2, pc1, pc2 = p\n\tfr, fc, in_ch, out_ch = W.shape\n\tn_ex, in_rows, in_cols, in_ch = X.shape\n\n\t# update effective filter shape based on dilation factor\n\t_fr, _fc = fr *... | [
"0.7789402",
"0.7657116",
"0.73724806",
"0.7076886",
"0.70751727",
"0.7072442",
"0.6950653",
"0.6888651",
"0.68331355",
"0.6727414",
"0.66853243",
"0.6679687",
"0.66354847",
"0.6598508",
"0.6594285",
"0.6574297",
"0.6558899",
"0.6554841",
"0.6531102",
"0.6515422",
"0.65014327... | 0.84939915 | 0 |
Calls Blender to generate report.json file. | def generate_report():
if not os.path.isdir(samples_path):
print("Couldn't find glTF-Sample-Models/2.0/")
print("Get it by running `git submodule update --init --recursive`")
print("See README.md for more instructions")
print("Tests did not run")
sys.exit(1)
# Print Blen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __execute_reporter(self):\n if not self.__args.report:\n return\n reporter.HTMLReporter().generate_report_from_file(\n self.__lst_json_files)",
"def test_json_report(self):\n self._test_reports_helper({\"--json-report\": \"\"}, [\"report.json\"])",
"def gReport(se... | [
"0.65139496",
"0.6475727",
"0.62491685",
"0.62459195",
"0.6183049",
"0.6111938",
"0.6077824",
"0.58888966",
"0.5873378",
"0.5815633",
"0.5793972",
"0.5780772",
"0.5777372",
"0.5724937",
"0.566903",
"0.5664086",
"0.56546944",
"0.5636915",
"0.5617519",
"0.5603056",
"0.5587537",... | 0.66431546 | 0 |
Print report from report.json file. Exits with the appropriate exit code afterwards. | def print_report():
with open(report_path) as f:
report = json.load(f)
tests = report['tests']
num_passed = 0
num_failed = 0
failures = []
ok = '\033[32m' + 'ok' + '\033[0m' # green 'ok'
failed = '\033[31m' + 'FAILED' + '\033[0m' # red 'FAILED'
for test in tests:
name =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_json_report(self):\n self._test_reports_helper({\"--json-report\": \"\"}, [\"report.json\"])",
"def __execute_reporter(self):\n if not self.__args.report:\n return\n reporter.HTMLReporter().generate_report_from_file(\n self.__lst_json_files)",
"def load_repor... | [
"0.67418486",
"0.66656893",
"0.63787967",
"0.63585967",
"0.615841",
"0.5990054",
"0.5982868",
"0.5856646",
"0.5760464",
"0.5746996",
"0.57335913",
"0.57209665",
"0.571939",
"0.5695433",
"0.56914556",
"0.5657688",
"0.5655098",
"0.5600166",
"0.5593361",
"0.5589117",
"0.5582583"... | 0.75914735 | 0 |
returns the elements of data in random order | def in_random_order(data):
idx = [i for i, _ in enumerate(data)]
random.shuffle(idx)
for i in idx:
yield data[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_random_order(data):\n indexes = [i for i, _ in enumerate(data)]\n random.shuffle(indexes)\n\n for i in indexes:\n yield data[i]",
"def in_random_order(data):\n indexes = [i for i, _ in enumerate(data)] # create a list of indexes\n random.shuffle(indexes) # shuff... | [
"0.75018305",
"0.74617875",
"0.73098755",
"0.691129",
"0.6792",
"0.6766596",
"0.6694262",
"0.6679834",
"0.66480845",
"0.66374534",
"0.66288435",
"0.6598994",
"0.6572494",
"0.6509845",
"0.648893",
"0.64252573",
"0.64252573",
"0.64226705",
"0.63941073",
"0.63508236",
"0.6324967... | 0.75514704 | 0 |
Opens default emailclient and send email to designated contact address | def email(self):
webbrowser.open("mailto: gorm90@gmail.com") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(self, email):\n client = self.clients[email.addressee]\n client.receive(email)",
"def test_send_email(self):\n\t\trecipient = \"\"\n\t\tself.email.send_email(self.subject, recipient, self.content)",
"def test_email():\n recipients = configs[\"email_to\"].split(\", \")\n email_body ... | [
"0.67359126",
"0.667154",
"0.6645954",
"0.6437304",
"0.6392894",
"0.6365626",
"0.6336011",
"0.6295565",
"0.6294974",
"0.62904304",
"0.624172",
"0.6240785",
"0.6201093",
"0.6160263",
"0.6157899",
"0.61497194",
"0.61476564",
"0.613291",
"0.61311436",
"0.611862",
"0.6106002",
... | 0.6867667 | 0 |
Def for adding the menu and updating the statusbar | def add_menus_and_status(self):
# Adding the statusbar and menubar
self.statusBar().showMessage("")
menubar = self.menuBar()
# Adding the first menu to the menubar
menu = menubar.addMenu("Menu")
# Adding the first "choise" in the menu
contact_action = QAction("Contact", self)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_menu_bar(self):\n menu_bar = self.shell_obj.menu_bar\n if menu_bar is not None:\n self.widget.setMenuBar(menu_bar.toolkit_widget)\n else:\n self.widget.setMenuBar(None)",
"def create_status_bar(self):\n self.statusbar = self.CreateStatusBar()",
"def ... | [
"0.7483258",
"0.7465695",
"0.735614",
"0.73042005",
"0.7258475",
"0.72503686",
"0.7215026",
"0.7196534",
"0.71423554",
"0.7107126",
"0.7066844",
"0.7043995",
"0.7040087",
"0.7020882",
"0.7008742",
"0.6952434",
"0.69149894",
"0.6901692",
"0.687026",
"0.6861022",
"0.6808619",
... | 0.775899 | 0 |
run_plugins(optlist, args, instances) fork and run a plugin for each instance and generate a summary as the result | def run_plugins(optlist, args, instances):
# XXX This algorithm for forking children and gatheing results is
# primitive - would be better to gather the results from the children
# as they become available - also should handle timeouts for children
# that return slow - would be better to return a descriptive error... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(args, plugins):\n\n # This has to happen before we parse the args, otherwise we might\n # get subcommand not found.\n for name, instance in plugins.items():\n if isinstance(instance, SubCommandPlugin):\n logging.debug('Adding SubCommandPlugin %s' % name)\n try:\n ... | [
"0.6810858",
"0.6195527",
"0.6155021",
"0.603338",
"0.6006884",
"0.59203917",
"0.58977133",
"0.5843426",
"0.5729732",
"0.57188326",
"0.57152474",
"0.57053983",
"0.5678058",
"0.564045",
"0.5614309",
"0.56119937",
"0.55956453",
"0.5594814",
"0.5566953",
"0.5549476",
"0.5545883"... | 0.79936993 | 0 |
Checks status code for unauthenticated user on bucketlists resource | def test_get_request_on_bucketlist_resource(self):
response = self.client.get("/bucketlists/")
self.assertEqual(response.status_code, 401) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_authorization_is_enforced(self):\n new_client = APIClient()\n res = new_client.get('/bucketlists/', kwargs={'pk': 2}, format=\"json\")\n self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)",
"def test_if_forbiden_for_authenticated_permissions(self):\r\n res = self... | [
"0.69821775",
"0.6785179",
"0.6771964",
"0.648102",
"0.6345668",
"0.63175774",
"0.6261946",
"0.62487084",
"0.62151897",
"0.61897516",
"0.61853725",
"0.61794126",
"0.6139188",
"0.6134894",
"0.6128795",
"0.6081943",
"0.6073182",
"0.60182977",
"0.5987124",
"0.5980558",
"0.596958... | 0.74207366 | 0 |
Test for failing to get auth token for invalid user credentials | def test_failing_auth_token_for_invalid_user(self):
response = self.client.post(
"/auth/login",
data=dict(username='random_test_user', password='random_test_password')
)
self.assertEqual(response.status_code, 401) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fail_token(client, request):\n res = client.get('/token?uid=1')\n\n assert res.status_code == 400\n assert 'User does not exist' in res.data.decode('utf-8')",
"def test_get_token_failure(self):\n url = '/api-token-auth/'\n data = {'username': 'adam', 'password': '321'}\n\n ... | [
"0.8102997",
"0.7945774",
"0.7934029",
"0.7864483",
"0.78641933",
"0.7798869",
"0.77983093",
"0.7778654",
"0.77361274",
"0.7645643",
"0.764208",
"0.7635275",
"0.76208466",
"0.7603388",
"0.7593273",
"0.75691026",
"0.7556424",
"0.753166",
"0.7528433",
"0.74639946",
"0.7459939",... | 0.83376944 | 0 |
Test for getting all bucketlists for authenticated users | def test_list_all_bucektlists_for_authenticated_user(self):
response = self.client.get(
"/bucketlists/",
headers={'Authorization': self.user_token}
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, '[]\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_request_on_bucketlist_resource(self):\n\n response = self.client.get(\"/bucketlists/\")\n self.assertEqual(response.status_code, 401)",
"def test_user_can_get_list_of_buckets(self):\n with self.client:\n response = self.client.get(\n '/bucketlists/',\n ... | [
"0.75702184",
"0.73931646",
"0.737584",
"0.72757727",
"0.7117869",
"0.68473583",
"0.6828582",
"0.68203723",
"0.6745276",
"0.67044246",
"0.6607629",
"0.65381175",
"0.65305597",
"0.6440864",
"0.6419552",
"0.6409762",
"0.62961596",
"0.6276382",
"0.6253651",
"0.6235496",
"0.62313... | 0.841216 | 0 |
Test for creating and getting bucketlist and constituent items | def test_creating_and_getting_a_bucketlist_for_authenticated_user(self):
# test all bucketlists
response = self.client.post(
"/bucketlists/",
data=dict(name='test_bucketlist'),
headers={'Authorization': self.user_token}
)
bucketlist = json.loads(respo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_bucketlist_items(self):\n resp = self.client.post('/bucketlists',\n data=json.dumps(self.bucketlist),\n content_type=\"application/json\", headers={\n \"Authorization\": self.token\n ... | [
"0.7643662",
"0.73914295",
"0.7356936",
"0.73352313",
"0.72897893",
"0.72300017",
"0.7208685",
"0.71998215",
"0.7146859",
"0.71368647",
"0.7119349",
"0.7117094",
"0.7090583",
"0.7025843",
"0.7002102",
"0.69745415",
"0.6969966",
"0.6968271",
"0.69138056",
"0.68787915",
"0.6868... | 0.74604183 | 1 |
Test registering an object which is not a HoudiniEventItem. | def test_register_item__non_item(self, init_event):
event = init_event()
with pytest.raises(TypeError):
event.register_item(None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_register_item(self, init_event, mocker):\n mock_map = {}\n\n mocker.patch.object(\n houdini_toolbox.events.event.HoudiniEvent,\n \"item_map\",\n new_callable=mocker.PropertyMock(return_value=mock_map),\n )\n\n # Mock the item via the reference i... | [
"0.71924025",
"0.67803055",
"0.6385045",
"0.63366866",
"0.6124942",
"0.6093676",
"0.60012996",
"0.5941234",
"0.5940534",
"0.59031093",
"0.5886501",
"0.5803487",
"0.577021",
"0.57480663",
"0.57303554",
"0.5718742",
"0.5707656",
"0.56993145",
"0.5692769",
"0.5670106",
"0.564635... | 0.74548024 | 0 |
Test registering a HoudiniEventItem. | def test_register_item(self, init_event, mocker):
mock_map = {}
mocker.patch.object(
houdini_toolbox.events.event.HoudiniEvent,
"item_map",
new_callable=mocker.PropertyMock(return_value=mock_map),
)
# Mock the item via the reference in the module so ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hook_register(self):\n self.assertEqual(list(self.registry), [])\n\n item = self.DummyItem(123)\n self.hook_cls(self.extension, item)\n\n self.assertIn(item, self.registry)",
"def test_register_item__non_item(self, init_event):\n event = init_event()\n\n with py... | [
"0.7102815",
"0.6727169",
"0.65970755",
"0.63842475",
"0.6344709",
"0.6337002",
"0.6331795",
"0.62204796",
"0.6214558",
"0.6179057",
"0.6161228",
"0.6129463",
"0.61196876",
"0.6090717",
"0.608867",
"0.60840595",
"0.60620797",
"0.60323733",
"0.6018322",
"0.60131985",
"0.600610... | 0.7670347 | 0 |
Test running an event that is disabled. | def test_run__not_enabled(self, init_event, mocker):
mocker.patch.object(
houdini_toolbox.events.event.HoudiniEvent,
"enabled",
new_callable=mocker.PropertyMock(return_value=False),
)
event = init_event()
scriptargs = {"key": "value"}
event.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notEnabledDummy(self, ev):\n pass",
"def test_atevent_disabled(self):\n from plone.api.exc import InvalidParameterError\n with self.assertRaises(InvalidParameterError):\n self.event = api.content.create(\n type='Event',\n title=u'Invalid event',\n... | [
"0.73344505",
"0.6940424",
"0.6882688",
"0.6618547",
"0.65076876",
"0.63975555",
"0.637556",
"0.6334032",
"0.62870544",
"0.6278889",
"0.6274787",
"0.62465155",
"0.6219108",
"0.6206939",
"0.6192045",
"0.6192045",
"0.61783445",
"0.6163216",
"0.61597544",
"0.6153424",
"0.6145253... | 0.7541339 | 0 |
Test that the topic can be reconfigured | def test_reconfigure_then_listen(sysmon_tester_agent):
new_config = _test_config.copy()
new_config['base_topic'] = 'test2/sysmon'
sysmon_tester_agent.vip.rpc.call('platform.sysmon', 'reconfigure',
**new_config)
listen(sysmon_tester_agent, new_config) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_topic_config(self):\n test_topic_config = {\n 'test.topic': {\n 'schema_name': 'test.schema'\n }\n }\n local_topic_config = eventlogging.topic.get_topic_config()\n local_topic_config.update(test_topic_config)\n\n # append the n... | [
"0.7354661",
"0.63973534",
"0.6261035",
"0.6246225",
"0.62360907",
"0.61642444",
"0.6157085",
"0.6148605",
"0.60968477",
"0.6091283",
"0.6085819",
"0.60656655",
"0.606183",
"0.6060499",
"0.6038964",
"0.600878",
"0.5996884",
"0.59766686",
"0.5975446",
"0.5940485",
"0.5890435",... | 0.6400014 | 1 |
returns True if ad_url is in filter list, meaning it is not an ad and should be filtered | def filter_obvious_non_ads(ad_url):
filter = [
'http:pagead2.googlesyndication.compageadimagesgoogle-logo.png',
'http:pagead2.googlesyndication.compageadimagesgreen-check.png',
'http:pagead2.googlesyndication.compageadimagesnessie_icon_thin_chevron_white.png',
'http:pagead2.googlesyndication.compageadima... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_audience(self, request, audience):\n if not self.audiences:\n return audience == request.host_url\n for audience_pattern in self._audience_patterns:\n if audience_pattern.match(audience):\n return True\n return False",
"def contains_ads(self):\... | [
"0.63571125",
"0.60815376",
"0.59847295",
"0.596617",
"0.57923347",
"0.5784023",
"0.5747687",
"0.56860244",
"0.56672096",
"0.56461245",
"0.56422883",
"0.5639728",
"0.55854344",
"0.5545889",
"0.5516618",
"0.55105555",
"0.5492124",
"0.54894924",
"0.54785776",
"0.5471862",
"0.54... | 0.79558086 | 0 |
Makes sure that key parameters are set in the baseconfig file before proceeding. | def check_params_set():
critical = {'machineinfo' : MACHINEID,
'error_serverinfo' : ERROR_SERVER,
'serverinfo' : SERVER}
for i, val in critical.iteritems():
if not val:
print "ERROR: Set value for \"%s\" in baseconfig.cfg file first\n" % i
sys.exit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_valid_config(self):\n default_keys = self.default_config.keys()\n current_keys = self.config.keys()\n\n if default_keys != current_keys:\n msg = f\"Config must have the following keys : {list(default_keys)}\"\n self.logger.critical(msg)\n sys.exit(0)... | [
"0.6588877",
"0.6356727",
"0.6240514",
"0.62288004",
"0.6227784",
"0.62156284",
"0.62156",
"0.6152337",
"0.61002505",
"0.60910964",
"0.608933",
"0.6030099",
"0.6027299",
"0.60176873",
"0.6008519",
"0.59613204",
"0.5959057",
"0.5959057",
"0.59521765",
"0.59511214",
"0.594009",... | 0.6504181 | 1 |
Use the strategy_func to map inputs to outputs. | def __init__(self, name, inputs, outputs, strategy_func):
assert str(name) == name
assert not [i for i in inputs if not isinstance(i, Variable)]
assert not [o for o in outputs if not isinstance(o, Variable)]
self.name = name
self.inputs = inputs
self.outputs = outputs
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _map(self, p_input:Element, p_output:Element):\r\n \r\n self._sl_model.eval()\r\n\r\n # Input pre processing\r\n input = self.input_preproc(p_input)\r\n\r\n # Make prediction\r\n output = self.forward(input)\r\n\r\n # Output post processing\r\n output = s... | [
"0.6291727",
"0.6219836",
"0.603235",
"0.6030753",
"0.59667563",
"0.59434015",
"0.5831094",
"0.57122934",
"0.56967837",
"0.5674113",
"0.5641309",
"0.5601978",
"0.55927503",
"0.558404",
"0.5574578",
"0.55710554",
"0.5530461",
"0.55249345",
"0.54486156",
"0.5434627",
"0.5416974... | 0.6490302 | 0 |
Calculate output given variable / state assignments | def calculate(self, assignments):
# Build a tuple of the relevant input states from the set of
# assignments given.
states = tuple([assignments[v] for v in self.inputs])
# Look them up
try:
results = self.lookup[states]
except KeyError:
raise Runt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_output(self):",
"def compute_output(self):\n x, y = self.input_nodes\n print(x.name, y.name)\n self.output_value = backend.dot(x.output_value, y.output_value)\n return self.output_value",
"def execute(self):\n \n self.outvar = self.invar + .01",
"def co... | [
"0.69763994",
"0.6395449",
"0.6359248",
"0.62636006",
"0.622528",
"0.61479604",
"0.61364317",
"0.6109713",
"0.5990465",
"0.59824497",
"0.5956442",
"0.58683634",
"0.58658874",
"0.58613735",
"0.58592486",
"0.583734",
"0.58146715",
"0.5746362",
"0.57352674",
"0.57166874",
"0.570... | 0.68775105 | 1 |
Output the mapping equation in a nice way We do this a longwinded way, but it allows pandas to do the nice formatting for us. We generate a row for every single possibility of input and outputs states of this variable, then use the pivot_table to construct a table for us with nice row/column headings. | def to_frame(self):
# Create a set of dictionaries/lists for each column
data = dict([(i_var.name, []) for i_var in self.inputs])
data.update({self.OUTPUT_LABEL: [], self.INPUT_LABEL: [], self.name: []})
# A very ugly loop to produce all the probabilities in a nice way.
# Note t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_table(self):\n states = self.get_canonical_collection()\n # self.print_canonical_collection(states)\n table = [{} for _ in range(len(states))]\n\n for index in range(len(states)):\n state = states[index]\n first_rule_cnt = 0\n second_rule_cn... | [
"0.5648607",
"0.5487772",
"0.54274684",
"0.5362632",
"0.53043276",
"0.52970064",
"0.52371854",
"0.5230833",
"0.5229916",
"0.5222644",
"0.5201632",
"0.5192592",
"0.5179158",
"0.51752585",
"0.5171843",
"0.50911134",
"0.50904775",
"0.5077961",
"0.5070272",
"0.5046656",
"0.501529... | 0.5967231 | 0 |
This just makes things pretty for graphviz output. | def graphviz_prettify(self, network):
graph_settings = {
'rankdir': 'LR',
'dpi': 60,
}
network.graph.update(graph_settings)
for n in network.nodes():
if isinstance(n, Variable):
network.nodes[n]['label'] = n.name
elif isins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_format(out, graph, name=\"digraph\"):\n\n out.write(\"digraph %s {\\n\" % name)\n for step, deps in each_step(graph):\n for dep in deps:\n out.write(\" \\\"%s\\\" -> \\\"%s\\\";\\n\" % (step, dep))\n\n out.write(\"}\\n\")",
"def pretty_print(self,depth=0):\n\t\tfor i in range(... | [
"0.6844516",
"0.6843064",
"0.6818959",
"0.6749471",
"0.6525039",
"0.6498898",
"0.6472254",
"0.6440659",
"0.64076364",
"0.63983643",
"0.63929254",
"0.6340841",
"0.63119",
"0.6310816",
"0.62969655",
"0.6253518",
"0.62191635",
"0.6218191",
"0.621614",
"0.62150705",
"0.6189956",
... | 0.7204607 | 0 |
Get the joint distribution, given root & do variables | def generate_joint(self, root_dist, do_dist=None):
tree = self.generate_tree(root_dist, do_dist)
return TreeDistribution(tree) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_joint(self):\n return sum([\n self.log_marg_like(self.gamma, self.gamma0, self.lamb, self.nu),\n self._gamma0_distribution.logpdf(self.gamma0),\n self._nu_distribution.logpdf(self.nu),\n self._lambda_distribution.logpdf(self.lamb),\n self.probit... | [
"0.6066082",
"0.6000554",
"0.59337634",
"0.5773621",
"0.5636868",
"0.56196445",
"0.5608468",
"0.551572",
"0.550742",
"0.54691815",
"0.5441921",
"0.5420077",
"0.54195935",
"0.54154027",
"0.54135996",
"0.53891844",
"0.53379655",
"0.5291863",
"0.52758497",
"0.5199462",
"0.518617... | 0.6872651 | 0 |
If content of local key is not right according to key got from lham server, return True. If not, return False. | def keyContentCompare(key_server_side,key_client_side):
len_server_key = len(key_server_side)
len_client_key = len(key_client_side)
ret_code = True
if len_client_key >= len_server_key:
for i in range(len_client_key - len_server_key + 1):
if key_client_side[i:(i+len_server_key)] == ke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_ssh_key(self):\n return True",
"def checkKey(self):\n # TO DO for checking API authentication\n if self.apikey is None:\n return False\n else:\n return True",
"def verify_local_token(self, token):\n return token == self.master_local_token.get_t... | [
"0.67030597",
"0.6490952",
"0.6313417",
"0.6311734",
"0.6273744",
"0.61946976",
"0.61946976",
"0.61946976",
"0.60918677",
"0.60133904",
"0.6004889",
"0.5994134",
"0.5974909",
"0.59530616",
"0.59292185",
"0.59218955",
"0.59029984",
"0.58981496",
"0.5891507",
"0.5873076",
"0.58... | 0.6552375 | 1 |
Given a number, format result as a C array of words (littleendian, same as ESP32 RSA peripheral or mbedTLS) | def number_as_bignum_words(number):
result = []
while number != 0:
result.append("0x%08x" % (number & 0xFFFFFFFF))
number >>= 32
return "{ " + ", ".join(result) + " }" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_serialize_number():\n num = 18178\n assert [\n 0b1000_0010,\n 0b1000_1110,\n 0b0000_0001\n ] == list(UnsignedInt.to_bytes(num))",
"def char32_t(n):\n return int(n).to_bytes(32, byteorder='little', signed=False)",
"def nt_to_cw(cur_enc, cur_nt):\r\n return array(map(... | [
"0.605906",
"0.60365444",
"0.59728605",
"0.5972278",
"0.5940351",
"0.59329253",
"0.58650845",
"0.5861218",
"0.58192366",
"0.573779",
"0.5737778",
"0.5727628",
"0.5727203",
"0.569448",
"0.5642862",
"0.5639466",
"0.5621677",
"0.560104",
"0.5571194",
"0.55552775",
"0.55466133",
... | 0.6760171 | 0 |
Given a sequence of bytes, format as a char array | def bytes_as_char_array(b):
return "{ " + ", ".join("0x%02x" % x for x in b) + " }" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes2hexstr(bytes_buffer, sep=''):\t\n\treturn sep.join(map(lambda x: '{0:02X}'.format(x), bytes_buffer))",
"def str_blocks_hex(buf):\n return ' '.join(['%s%s%s%s%02X'%(\n '' if i == 0 or i%32 != 0 else '\\n', # add a line-feed every 8 blocks\n '' if i == 0 or i%128 != 0 else '\\n',# add an... | [
"0.66176945",
"0.63705194",
"0.63642526",
"0.62680066",
"0.62679666",
"0.62608945",
"0.6200919",
"0.6192748",
"0.618539",
"0.6158791",
"0.6107734",
"0.6096393",
"0.6080172",
"0.60790116",
"0.6056689",
"0.6004936",
"0.5954062",
"0.59523267",
"0.5951398",
"0.59291905",
"0.59101... | 0.76434 | 0 |
Saves predicted df/sem + input (+ target, if any) to mesh visualization. | def export_prediction_to_mesh(outprefix, input_sdf, output_df, output_sem,
target_df, target_sem):
# Add back (below floor) padding for vis (creates the surface on the bottom).
(scene_dim_z, scene_dim_y, scene_dim_x) = input_sdf.shape
save_input_sdf = constants.TRUNCATION * np.ones(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_prediction(self):\n if DataLoader.data is None:\n messagebox.showerror(\"Information\", \"Data file is empty, please load the data first.\")\n return\n if Trainer.y_pred is None:\n messagebox.showerror(\"Information\", \"Preciction has not been made, please t... | [
"0.61205375",
"0.5868651",
"0.58200294",
"0.5786487",
"0.5699894",
"0.56885695",
"0.5680314",
"0.5654975",
"0.56547266",
"0.56200755",
"0.561145",
"0.55820036",
"0.55701745",
"0.55654573",
"0.5564276",
"0.5519289",
"0.5510049",
"0.54942364",
"0.5471618",
"0.54639095",
"0.5454... | 0.7413728 | 0 |
Test that a historic dummy engagement is created if the employee engagement start date is older than the corresponding org unit | def test_create_historic_dummy_engagement(mock_uuid4):
# Arrange
mock_uuid4.side_effect = ["historic_org_unit_uuid", "engagement_uuid"]
sd = get_sd_importer()
org_unit_uuid = str(uuid4())
sd.nodes[org_unit_uuid] = attrdict(
{
"name": "org_unit",
"date_from": "2000-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_past_meeting_details(self):\n pass",
"def test_program_first_unexpired_run():\n program = ProgramFactory()\n course = CourseFactory.create(program=program)\n now = now_in_utc()\n end_date = now + timedelta(days=100)\n enr_end_date = now + timedelta(days=100)\n first_run = Course... | [
"0.6522765",
"0.6132434",
"0.6048755",
"0.5988972",
"0.5982079",
"0.59723586",
"0.5948075",
"0.5928769",
"0.5923481",
"0.58987296",
"0.5892337",
"0.5864673",
"0.5855764",
"0.58530265",
"0.5835172",
"0.58044785",
"0.5799048",
"0.57584393",
"0.57481873",
"0.5708368",
"0.5704391... | 0.6755884 | 0 |
Test that engagements are not created for SD employees with an SD "let go" (i.e. retired etc.) employment status | def test_skip_creation_of_sd_let_go_employments(employment_status: str) -> None:
# Arrange
sd = get_sd_importer()
sd.importer = MagicMock()
person = {
"PersonCivilRegistrationIdentifier": "1234567890",
"Employment": [
{"EmploymentStatus": {"EmploymentStatusCode": employment_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_other_enrollments(self):\n user = self.make_user()\n EnrollmentFactory()\n\n with self.login(user):\n self.get_check_200(\"reports:index\")\n\n assert list(self.get_context(\"enrollments\")) == []",
"def test_meeting_registrant_status(self):\n pass",
"d... | [
"0.62864995",
"0.6109226",
"0.6097539",
"0.60638374",
"0.60442054",
"0.6009332",
"0.59526455",
"0.5904792",
"0.58630407",
"0.58318824",
"0.5747615",
"0.57435656",
"0.57178295",
"0.5678614",
"0.56211954",
"0.5571534",
"0.555612",
"0.55492544",
"0.55361027",
"0.55357414",
"0.55... | 0.7528638 | 0 |
Insert a vote in votes table | def create_vote(self):
con = psycopg2.connect(**self.config)
cur = con.cursor(cursor_factory=RealDictCursor)
try:
query = "INSERT INTO votes(user_id, answer_id, vote) VALUES(%s, %s, %s)"
cur.execute(query, (self.user_id, self.answer_id, self.vote_value))
con.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self)->None:\n database.cursor.execute(\"INSERT INTO votes(question,user_id,value) VALUES(%s,%s,%s) RETURNING id\", (\n self.question,\n self.user,\n self.value\n ))\n super().save()",
"def create_vote(self, data, header):\n return self.client.pos... | [
"0.69463617",
"0.6698563",
"0.660448",
"0.64760953",
"0.6464339",
"0.64528763",
"0.6309453",
"0.6256306",
"0.6252943",
"0.6239647",
"0.6223079",
"0.6216126",
"0.61967146",
"0.61759114",
"0.6136012",
"0.6062798",
"0.6014227",
"0.5927826",
"0.5920131",
"0.59112227",
"0.58873177... | 0.7771154 | 0 |
Modify record from votes table | def update_vote(self):
if not self.answer_id:
return False
try:
con = psycopg2.connect(**self.config)
cur = con.cursor(cursor_factory=RealDictCursor)
query = "UPDATE votes SET vote=%s WHERE answer_id=%s AND user_id=%s"
cur.execute(query, (self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self)->None:\n database.cursor.execute(\"UPDATE votes SET value = %s WHERE id = %s\", (\n self.value,\n self.id\n ))\n database.connection.commit()",
"def record_vote(self, obj, user, vote):\r\n if vote not in (+1, 0, -1):\r\n raise ValueErr... | [
"0.7097145",
"0.6574508",
"0.65182835",
"0.62903124",
"0.62770456",
"0.62625843",
"0.6224583",
"0.615644",
"0.6060661",
"0.60546535",
"0.60498565",
"0.6023743",
"0.59779423",
"0.5952618",
"0.58973706",
"0.58949363",
"0.5858892",
"0.5834581",
"0.58181053",
"0.5812845",
"0.5811... | 0.6805918 | 1 |
Switch bus for updating or creating a vote | def vote(self):
if self.vote_exists():
return self.update_vote()
return self.create_vote() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transit_to_voting(self, **kwargs):\n logging.debug(\"in _transit_to_voting\")\n handler = kwargs['handler']\n\n game = models.Hangout.get_by_id(self.hangout_id).current_game.get()\n if not game:\n if handler:\n handler.accumulate_response(\n {'status': 'ERROR',\n ... | [
"0.62944984",
"0.62010765",
"0.5964257",
"0.5925911",
"0.5875525",
"0.5862123",
"0.5856673",
"0.5772937",
"0.5760269",
"0.5759789",
"0.57481307",
"0.57456076",
"0.5707525",
"0.56780016",
"0.56722",
"0.56581825",
"0.5640457",
"0.5639389",
"0.5634383",
"0.5619043",
"0.5609678",... | 0.6500325 | 0 |
Create data for Book | def create_book():
Book.objects.create(book_id="test_id",
title="test_title",
authors="test_author",
published_date="2021",
categories=["test_category"],
average_rating=5,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_books_data():\n pass",
"def create(self, book_info, destroy):\n self.connect()\n bid = book_info[0].get()\n title = book_info[1].get()\n author = book_info[2].get()\n status = book_info[3].get()\n status = status.lower()\n\n q = \"insert into {} valu... | [
"0.8802132",
"0.71960455",
"0.7122072",
"0.70988894",
"0.69868475",
"0.68307406",
"0.6696561",
"0.6666475",
"0.66428024",
"0.6628996",
"0.6628703",
"0.650922",
"0.6489773",
"0.6391302",
"0.6376024",
"0.6376024",
"0.6339053",
"0.6325645",
"0.627604",
"0.62371653",
"0.6167471",... | 0.72323495 | 1 |
Matches dictionaries containing a value satisfying a given matcher. | def has_value(value):
return IsDictContainingValue(wrap_matcher(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(dictionary, query, policy='relaxed', matches=None):\n if query is None:\n return True\n assert policy in ['relaxed', 'strict'], \"\"\n\n for field, value in query.iteritems():\n if field not in dictionary:\n if policy == 'relaxed':\n ... | [
"0.65134305",
"0.619819",
"0.60576916",
"0.59644574",
"0.5942667",
"0.58448154",
"0.575335",
"0.57134974",
"0.5685054",
"0.56309897",
"0.55961084",
"0.5556968",
"0.5548223",
"0.5547046",
"0.55083245",
"0.5496346",
"0.54962635",
"0.5471478",
"0.5402717",
"0.5395664",
"0.538346... | 0.653798 | 0 |
Send the request headers to a given stream ID. | async def _send_request_headers(self, request: Request, stream_id: int) -> None:
end_stream = not has_body_headers(request)
# In HTTP/2 the ':authority' pseudo-header is used instead of 'Host'.
# In order to gracefully handle HTTP/1.1 and HTTP/2 we always require
# HTTP/1.1 style header... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_headers(self, stream_id, immediate=False):\n send_stream = self.send_streams.get(stream_id)\n\n if not send_stream:\n return\n\n headers = send_stream.headers_to_send(not immediate)\n if headers:\n self.conn.send_headers(stream_id, headers, end_stream=Fals... | [
"0.749921",
"0.6374763",
"0.61077857",
"0.6006791",
"0.58958006",
"0.58726394",
"0.5825478",
"0.5819301",
"0.57882994",
"0.5768293",
"0.5722658",
"0.5702611",
"0.5702192",
"0.5570894",
"0.5567575",
"0.5561807",
"0.5487843",
"0.5428832",
"0.5373414",
"0.5361269",
"0.53070873",... | 0.74215686 | 1 |
Iterate over the request body sending it to a given stream ID. | async def _send_request_body(self, request: Request, stream_id: int) -> None:
if not has_body_headers(request):
return
assert isinstance(request.stream, typing.AsyncIterable)
async for data in request.stream:
await self._send_stream_data(request, stream_id, data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_iteration(self):\n for stream_id in list(self.send_streams.keys()):\n self.send_headers(stream_id)\n self.send_data(stream_id)",
"async def _receive_response_body(\n self, request: Request, stream_id: int\n ) -> typing.AsyncIterator[bytes]:\n while True:\n ... | [
"0.6849117",
"0.65955675",
"0.65768796",
"0.62579274",
"0.6119602",
"0.57820255",
"0.5778004",
"0.56675404",
"0.5542927",
"0.54798776",
"0.54767394",
"0.5473506",
"0.54328704",
"0.5410615",
"0.54032713",
"0.53901696",
"0.5382639",
"0.53460133",
"0.53174686",
"0.53163767",
"0.... | 0.77006096 | 0 |
Send an empty data frame on on a given stream ID with the END_STREAM flag set. | async def _send_end_stream(self, request: Request, stream_id: int) -> None:
self._h2_state.end_stream(stream_id)
await self._write_outgoing_data(request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_stream(self, stream_id):\n send_stream = self.send_streams.pop(stream_id)\n\n try:\n trailers = send_stream.trailers_to_send()\n if trailers:\n self.conn.send_headers(stream_id, trailers, end_stream=True)\n else:\n self.conn.end_s... | [
"0.6147131",
"0.60258174",
"0.601658",
"0.58929867",
"0.5823561",
"0.5814709",
"0.56416553",
"0.56024575",
"0.5526932",
"0.5488927",
"0.5481889",
"0.5456016",
"0.5426482",
"0.5396286",
"0.53955007",
"0.5391962",
"0.53498054",
"0.5345032",
"0.531354",
"0.5295027",
"0.5280714",... | 0.64167637 | 0 |
Return the response status code and headers for a given stream ID. | async def _receive_response(
self, request: Request, stream_id: int
) -> typing.Tuple[int, typing.List[typing.Tuple[bytes, bytes]]]:
while True:
event = await self._receive_stream_event(request, stream_id)
if isinstance(event, h2.events.ResponseReceived):
brea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, id_stream):\n\n session = current_app.session\n\n stream = session.query(StreamDao).filter(StreamDao.id == id_stream).first()\n\n if stream is None:\n return None, 204\n\n return stream, 200",
"def get_status(id):\n task = run_ctx_request.AsyncResult(id)\n ... | [
"0.69371593",
"0.62361753",
"0.5958376",
"0.5958376",
"0.5916345",
"0.59092075",
"0.58911866",
"0.5775636",
"0.56480587",
"0.5640041",
"0.562389",
"0.5521051",
"0.5510603",
"0.54690266",
"0.5435548",
"0.5429711",
"0.5356575",
"0.52586204",
"0.52449924",
"0.52412367",
"0.52138... | 0.76649284 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.