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
Convert a float to 32bit integer
def float_to_int_32(x): return np.float32(x).view(np.int32)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_int32(f):\n from numpy import array, clip\n\n img = array(clip(f,-2147483647,2147483647)).astype('i')\n return img", "def to_float32(n):\n return np.cast[\"float32\"](n)", "def bin_to_float32(b):\n bf = int_to_bytes(int(b, 2), 4) # 4 bytes needed for IEEE 754 binary32.\n return struct...
[ "0.7797767", "0.7367003", "0.73220885", "0.72220695", "0.6944232", "0.6939441", "0.6875976", "0.6756007", "0.6687747", "0.6678737", "0.66762525", "0.66639346", "0.666378", "0.6621309", "0.6610098", "0.6544187", "0.6530338", "0.6523839", "0.64904106", "0.64755565", "0.63935524...
0.8072008
0
Convert a float to 64bit integer
def float_to_int_64(x): return np.float64(x).view(np.int64)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert_int_to_i64(val):\n if val > 0x7FFFFFFFFFFFFFFF:\n val -= 0x10000000000000000\n return val", "def bin_to_float64(b):\n bf = int_to_bytes(int(b, 2), 8) # 8 bytes needed for IEEE 754 binary64.\n return struct.unpack(\">d\", bf)[0]", "def float_to_bin64(value):\n [d] = struct.un...
[ "0.6942918", "0.6889584", "0.669873", "0.6556856", "0.6440175", "0.63891", "0.6360378", "0.6333624", "0.62157387", "0.61884594", "0.61860836", "0.61694336", "0.61260474", "0.6114865", "0.60392386", "0.59791774", "0.59192514", "0.5894881", "0.5893504", "0.5890302", "0.586931",...
0.72442496
0
Convert a float to integer with precision prec
def float_to_int(x, prec=64): if prec == 16: return float_to_int_16(x) elif prec == 32: return float_to_int_32(x) elif prec == 64: return float_to_int_64(x) else: raise ValueError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _float2int(x: float) -> int:\n return round(x * 100)", "def set_num_precision(number, precision, mode='int'):\n fmt = '{:.%ie}' % (precision - 1)\n value = float(fmt.format(number))\n if mode == 'int':\n return int(value)\n else:\n return value", "def int_r(f):\n return int(np...
[ "0.7167975", "0.6879536", "0.6711734", "0.6599057", "0.64479166", "0.63786715", "0.6356254", "0.62676", "0.6264848", "0.6208819", "0.6200068", "0.6175348", "0.61597306", "0.6158532", "0.6128278", "0.61098605", "0.60939324", "0.6079625", "0.60612583", "0.6056072", "0.60408086"...
0.77927786
0
Convert an integer to an nbit binary number
def int_to_binary(x, n=64): return format(x, 'b').zfill(n)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intToBinary(x, N):\n return (\"{0:0\" + str(N) + \"b}\").format(x)", "def int2bin(n: int) -> str:", "def int2bin(n, bits=13):\n return \"\".join([str((n >> y) & 1) for y in range(bits - 1, -1, -1)])", "def num_to_binary(n):\n if n == 0:\n return ''\n elif n % 2 == 1:\n return nu...
[ "0.8351496", "0.8306802", "0.7986127", "0.79528177", "0.78577054", "0.7826324", "0.78063375", "0.7724613", "0.7661041", "0.7647572", "0.7646287", "0.7626045", "0.7545623", "0.74988794", "0.74691707", "0.74666137", "0.7465818", "0.7416674", "0.7400173", "0.7377615", "0.7353318...
0.84325266
0
Convert a float to an nbit binary number
def float_to_binary(x, n=64): return _fix_sign(int_to_binary(float_to_int(x, n), n))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def float_to_bin(value): # For testing.\n [d] = struct.unpack(\">Q\", struct.pack(\">d\", value))\n return '{:064b}'.format(d)", "def float_to_bin (x):\n assert type (x) is float\n s_hex = float.hex (x)\n hex_parts = RE_FLOAT_HEX_PARTS.match (s_hex)\n assert hex_parts\n \n ...
[ "0.7727614", "0.7064918", "0.6937852", "0.6915586", "0.68823963", "0.68155485", "0.6747921", "0.6724134", "0.67205435", "0.66596603", "0.66441965", "0.66304857", "0.6585514", "0.65364355", "0.6523004", "0.6493496", "0.6451158", "0.63342595", "0.63248837", "0.63212866", "0.630...
0.81579816
0
Convert each float in a pandas.dataframe column to binary representation.
def row_to_binary(row): binaryrow = '' for item, val in row.iteritems(): binaryrow += float_to_binary(val) return binaryrow
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_binary(df, variable_names):\n recoded_df = df.copy()\n recoded_df[variable_names] = (\n recoded_df[variable_names]\n .astype(bool)\n .astype(\"int64\")\n )\n return recoded_df", "def binary_encoding(df, bin_cols):\n for col in bin_cols:\n enc ...
[ "0.65553796", "0.653674", "0.643313", "0.63819706", "0.6041284", "0.5914992", "0.5717357", "0.5704", "0.56280065", "0.56196666", "0.559938", "0.5566888", "0.5526704", "0.55197924", "0.5503003", "0.5501224", "0.5498036", "0.5497775", "0.5450568", "0.54475963", "0.542765", "0...
0.70190734
0
Convert a binary string to elements of the field GF(2m_gf).
def binary_string_to_gf_elements(b, m_gf): if m_gf == 1: return np.fromiter(map(int, b), int) else: assert(len(b)%m_gf == 0) res = np.zeros(len(b)//m_gf) for i in range(len(b)//m_gf): res[i] = int(b[i*m_gf:(i+1)*m_gf], 2) return res.astype(int)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_to_gf_array(data, m_gf = 1, floatprec = 64):\n data_binary = []\n for val in data:\n data_binary.append(binary_string_to_gf_elements(float_to_binary(val, floatprec), m_gf))\n return np.array(data_binary,dtype=int)", "def parse_binary_field(b):\n\n\n codec, length, params = struct.unp...
[ "0.61993897", "0.5916638", "0.55031425", "0.54492235", "0.5442366", "0.5400809", "0.539698", "0.5385185", "0.5367709", "0.52807707", "0.52589214", "0.52526057", "0.52484083", "0.52085364", "0.5184683", "0.5174587", "0.51419324", "0.50609285", "0.4980555", "0.4975593", "0.4955...
0.7760681
0
Convert an array of floats to their representation in GF(2m_gf).
def array_to_gf_array(data, m_gf = 1, floatprec = 64): data_binary = [] for val in data: data_binary.append(binary_string_to_gf_elements(float_to_binary(val, floatprec), m_gf)) return np.array(data_binary,dtype=int)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_float(array):\n finial_array = []\n\n for number in array:\n finial_array.append(float(number))\n return finial_array", "def convertToFloatArray(booleanArray: typing.List[bool]) -> typing.List[float]:\n ...", "def floatArrayToPrt(float_array):\n\n util = O...
[ "0.6489259", "0.6212854", "0.59715474", "0.57902944", "0.57456523", "0.56836855", "0.5678308", "0.5571374", "0.5543376", "0.55162495", "0.5508774", "0.54554605", "0.54518443", "0.5439809", "0.5423405", "0.5413057", "0.5378946", "0.5377641", "0.5377641", "0.53730404", "0.53656...
0.7589889
0
Evaluates the chwirut objective function at a given set of points in ``H["x"]``. If ``"obj_component"`` is a field in ``sim_specs["out"]``, only that component of the objective will be evaluated. Otherwise, all 214 components are evaluated and returned in the ``"fvec"`` field.
def chwirut_eval(H, _, sim_specs): batch = len(H["x"]) O = np.zeros(batch, dtype=sim_specs["out"]) for i, x in enumerate(H["x"]): if "obj_component" in H.dtype.names: if ( "user" in sim_specs and "component_nan_frequency" in sim_specs["user"] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_obj(self, hparams):\n\n return [self.id, hparams, self.objective(hparams, self.device)]", "def clhess(obj, exe, arg, delta=DELTA):\n f, x = get_method_and_copy_of_attribute(obj, exe, arg)\n def hess_f(*args, **kwargs):\n hess_val = numpy.zeros(x.shape + x.shape)\n it = num...
[ "0.55313957", "0.53080523", "0.5189676", "0.51875687", "0.511367", "0.51000154", "0.50619596", "0.50266045", "0.5026222", "0.50165236", "0.5009043", "0.5007817", "0.50025773", "0.49932408", "0.49886763", "0.49766004", "0.49728853", "0.49723494", "0.49722487", "0.49674708", "0...
0.70898503
0
Generates CSV given a list of summaries
def generate_csv(summaries, filename): with open(filename, 'wb') as f: header = ','.join(['ACTIVATION', 'HIDDEN SIZE', 'TRAIN LOSS', 'VAL LOSS', 'TRAIN PPX', 'VAL PPX']) + '\n' f.write(header) def extract_best(summary, metric): return min([h.metrics[metric] for h in summary['his...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_csv(filename, summaries, float_format='%.02f'):\n data = [['solution', 'total time', 'ok', 'errors']]\n\n for var, s in summaries[0].stats.iteritems():\n for stat in s:\n data[0].append('%s %s' % (var, stat))\n\n for summary in summaries:\n row = [summary.solution, float...
[ "0.698654", "0.6883718", "0.6254284", "0.62226987", "0.6196189", "0.6109199", "0.609774", "0.6094412", "0.607479", "0.60741484", "0.6022636", "0.60143197", "0.5970486", "0.5954475", "0.5951993", "0.592181", "0.59141076", "0.5913574", "0.5880284", "0.5856723", "0.5838795", "...
0.7734259
0
You're designing the menu at a fancy restaurant and it's important to you that the courses be linked together by common ingredients. So, the first course and the second course must share an ingredient, the second and the third course must share an ingredient, etc. Write a function that tests a menu to make sure this co...
def course_tester(courses): return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_course_available(data, course):\n for i in range(len(data['menu']['meal']['course'])):\n for key, value in data['menu']['meal']['course'][i].items():\n if key == 'name':\n if value.upper() == course.upper():\n return True\n return False", "def t...
[ "0.70271784", "0.62023354", "0.6105342", "0.59191686", "0.5909621", "0.58131725", "0.5804522", "0.5736799", "0.5727533", "0.57244295", "0.57106405", "0.57088274", "0.5666606", "0.56663203", "0.566413", "0.559278", "0.5579136", "0.55358875", "0.55228984", "0.5516206", "0.55063...
0.6984037
1
The equivalent of the normal `flag` decorator, but for TriBitMask.
def triflag(func: Callable[[Any], int]) -> TriBitMask: return TriBitMask(func(None))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flags(self) -> UserFlag:", "def _flag():\n current_flag = _flag.flag\n _flag.flag <<= 1\n return current_flag", "def TransformFlags(self) -> _n_2_t_0[bool]:", "def setFlag(flagbyte, pos, status):\n if status:\n return flagbyte | 2**pos\n else:\n return flagbyte & ~2**pos", ...
[ "0.6482749", "0.64294463", "0.6405516", "0.6219988", "0.6217365", "0.616181", "0.6008068", "0.60012144", "0.59498453", "0.58851945", "0.5867022", "0.5866195", "0.5804603", "0.5781837", "0.57502043", "0.5726512", "0.56852627", "0.56843007", "0.56681556", "0.561124", "0.5581491...
0.71491706
0
Initialize a permission overwrite object from Discord data. This is used because a PermissionOverwrite object is often initialized by users.
def from_data(cls: Type[SELF], data: Dict) -> SELF: self = cls.__new__(cls) self.type = PermissionTarget(data['type']) self.allow = Permissions(int(data['allow'])) self.deny = Permissions(int(data['deny'])) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_perm(self, permission, user, obj, ctype=None):\n if getattr(obj, 'pk', None) is None:\n raise ObjectNotPersisted(\"Object %s needs to be persisted first\" % obj)\n\n if not ctype:\n ctype = ContentType.objects.get_for_model(obj)\n\n if not isinstance(permission...
[ "0.5088103", "0.50488174", "0.5030711", "0.49461928", "0.4939557", "0.49180445", "0.48853058", "0.48666456", "0.4836884", "0.48114455", "0.48099852", "0.48095408", "0.4808097", "0.4794472", "0.4790157", "0.476699", "0.4765125", "0.47534674", "0.47128752", "0.4712254", "0.4709...
0.63469905
0
Find the average score from the sentence value dictionary
def average_score(self, sentenceValue): sumValues = 0 for entry in sentenceValue: sumValues += sentenceValue[entry] # Average value of a sentence from original summary_text average = (sumValues / len(sentenceValue)) return average
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _find_average_score(self, sentenceValue):\n sumValues = 0\n for entry in sentenceValue: \n sumValues += sentenceValue[entry]\n \n try:\n average = (sumValues / len(sentenceValue))\n except:\n average = 0\n return average", "def ave...
[ "0.84489435", "0.8114358", "0.71427697", "0.7107199", "0.7078907", "0.69673705", "0.680161", "0.6781092", "0.6773353", "0.67545366", "0.67071134", "0.67013216", "0.6655128", "0.6633259", "0.6628792", "0.66243255", "0.65700173", "0.65391093", "0.6483531", "0.6468535", "0.64666...
0.8261746
1
Run this function to get output/discounted_values.csv 100 gamma (discount factor) values for each node in data/treeNodePolicyIncludingN=1.csv
def values_per_gamma(): keys, data = parse("data/treeNodePolicyIncludingN=1.csv") gammas = [1] + [round(0.01*i,2) for i in range(100)] with open('output/discounted_values.csv', mode='w') as out_file: out_writer = csv.writer(out_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n\n ''' Reading the training data file '''\n original_training_data = pd.read_csv(\"DT_Data_CakeVsMuffin_v012_TRAIN.csv\")\n\n ''' Storing the final decision tree '''\n final_tree = decision_tree(original_training_data,0)\n\n ''' Printing the final decision tree '''\n print(\"This is ...
[ "0.57843393", "0.5482357", "0.533252", "0.5228378", "0.51823413", "0.5179032", "0.5170734", "0.5143776", "0.51375896", "0.51173586", "0.51173353", "0.5109973", "0.51017237", "0.5076362", "0.5057087", "0.5021839", "0.5016955", "0.4993695", "0.49849457", "0.49696085", "0.495366...
0.7776143
0
test access control is superuser as anonymous raises access control error
def test_access_control_is_superuser_as_anonymous_raises_access_control_error( self, ): # Arrange mock_request = create_mock_request(user=self.anonymous_user) # Act # Assert with self.assertRaises(AccessControlError): access_control_api.is_superuser( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_allowed_if_superuser(self):\n\n @task_or_superuser_only\n def view(request):\n return HttpResponse(\"Hello\")\n\n class User(object):\n is_superuser = True\n is_authenticated = True\n\n request = self.factory.get(\"/\")\n request.user = N...
[ "0.7597112", "0.74517125", "0.7409692", "0.7355642", "0.73188114", "0.7184771", "0.7074764", "0.7070715", "0.7055787", "0.70354146", "0.70207727", "0.7013449", "0.7003477", "0.69959384", "0.6991272", "0.6991272", "0.6991272", "0.6991272", "0.6985662", "0.6980759", "0.69780344...
0.7768883
0
Map a task over a tree of values (list of lists of ...). This is an example of custom higherorder task (i.e. a task that takes another task as an argument).
def map_tree(a_task: Task, tree: Any) -> Any: def map_node(node): if isinstance(node, list): return [map_node(child) for child in node] else: return a_task(node) return map_node(tree)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tree_map(fn, t):\n \"*** YOUR CODE HERE ***\"\n if t.is_leaf():\n return Tree(fn(t.root), [])\n map_tree = [tree_map(fn,i) for i in t.branches]\n return Tree(fn(t.root), mapped_subtrees)", "def map_my(self, func: Callable[[Union[float, int]], int]) -> None:\n def list_func(lst: List...
[ "0.6279525", "0.62746316", "0.6270376", "0.6263661", "0.6263661", "0.6263661", "0.6263661", "0.6263661", "0.6094713", "0.60795045", "0.60553247", "0.59218323", "0.5794635", "0.57860726", "0.578406", "0.5725684", "0.5725684", "0.5725526", "0.5705644", "0.56726545", "0.5658746"...
0.8091863
0
Extract a patch of size `dim` centered on `pos`. Patches may not be centered on `pos` if `allow_shifts`=True
def get_patch(self, pos, dim, allow_shifts=False): assert(len(pos)==3 and len(dim)==3) patch = None # Is the patch contained within the bounding box? if allow_shifts: box = containing_box(pos, dim, self._bbox) else: box = centered_box(pos, dim) i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch(self, patch_center, patch_size, expand_patch=True):\n # x-axis corresponds to the columns of the image\n # y-axis corresponds to the rows of the image\n padding_x = int(patch_size[1]/2)\n padding_y = int(patch_size[0]/2)\n\n min_x = patch_center[0, 0] - padding_x\n ...
[ "0.61094743", "0.59083855", "0.57726455", "0.57071066", "0.5649377", "0.5638825", "0.55698454", "0.5552992", "0.55500853", "0.5524652", "0.548065", "0.5401572", "0.5388224", "0.5387365", "0.5349579", "0.5345006", "0.5341573", "0.5296573", "0.5295754", "0.521929", "0.51876324"...
0.76689285
0
Get a valid range for extracting patches of size `dim`.
def valid_range(self, dim): assert(len(dim)==3) if any([dim[i] > self._dim[i] for i in range(3)]): return None dim = Vec3d(dim) top = dim // 2 # Top margin btm = dim - top - (1,1,1) # Bottom margin vmin = self._offset + top vmax = self._of...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bounds(dimension):\n bounds = np.tile(np.nan, [dimension, 2])\n bounds[:, 0], bounds[:, 1] = -10, 10\n return bounds", "def which_patches(extent):\n # TODO check input\n ramin, ramax, decmin, decmax = extent\n p1 = which_patch(ramin, decmin) # lower left\n p2 = which_patch(ramax, dec...
[ "0.5927587", "0.5761949", "0.5760646", "0.5629314", "0.55331284", "0.55257386", "0.5446492", "0.54096425", "0.54078543", "0.53363216", "0.53345877", "0.5310692", "0.5300406", "0.52919734", "0.52734375", "0.52633286", "0.52361447", "0.5209971", "0.51845366", "0.5177192", "0.51...
0.66113824
0
All festivals have been created with admin, so zero have been migrated.
def test_number_of_festivals_migrated(self): festival_count = Festival.festivals.count() self.assertEqual(festival_count, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_festivals(self):\n self.cursor.execute(\"select * from festivals\")\n self.connection.commit()\n return self.cursor.fetchall()", "def _reset_admin(self):\r\n DBSession.execute(\r\n \"UPDATE users SET activated='1' WHERE username='admin';\")\r\n Activation...
[ "0.58556074", "0.52402407", "0.5173738", "0.513151", "0.5100251", "0.50860196", "0.50360054", "0.50225085", "0.5019569", "0.5018516", "0.5003454", "0.4987341", "0.494545", "0.4918814", "0.49040917", "0.4880145", "0.48653144", "0.48578307", "0.48517138", "0.48111472", "0.48005...
0.66384596
0
Calculate accuracy by char of 2 string
def calculate_ac(str1, str2): total_letters = len(str1) ocr_letters = len(str2) if total_letters == 0 and ocr_letters == 0: acc_by_char = 1.0 return acc_by_char diff = difflib.SequenceMatcher(None, str1, str2) correct_letters = 0 for block in diff.get_matching_blocks(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_accuracy(self):\n same = 0\n dif = 0\n for x, y in zip(self.test_string[3:], self.prediction[3:]):\n if x == y:\n same += 1\n else:\n dif += 1\n\n accuracy = round((same / (same + dif)) * 100, 2)\n print(f'Compute...
[ "0.70896775", "0.6846165", "0.6845839", "0.6526451", "0.6467602", "0.64582926", "0.6425335", "0.64106536", "0.6405775", "0.6374497", "0.6372071", "0.63578576", "0.6352264", "0.6317024", "0.6304939", "0.6288348", "0.6282892", "0.62719584", "0.6262974", "0.6262393", "0.6243479"...
0.7735831
0
Init by loading param file and running one simulation
def __init__(self, name=None, params=None, params_from_file=False, params_from_user=False): print("") if name: self._name = name else: self._name = input("Simulation Name : ") print("Name : "+str(self._name)) self.plot_path = os.getcwd()+'/session/'+sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init(sysargv=sys.argv):\n # The paramscript is given as commandline argument, so we have to load it dynamically.\n # NOTE: the GPU=... argument was replaced by giving params.GPU = ...\n paramsfile_default = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'params_default.py')\n myparamsfile...
[ "0.74145514", "0.7046797", "0.68025666", "0.6763831", "0.675749", "0.66793156", "0.6660954", "0.6620679", "0.6596364", "0.65661407", "0.65359855", "0.6486038", "0.6465894", "0.6434889", "0.64232063", "0.6396819", "0.6377265", "0.635895", "0.63383824", "0.6292895", "0.6278178"...
0.71622616
1
Print out name, current params and stored simulation runs
def __str__(self): print("") s = "NAME : "+self._name+"\n\n" s += "PARAMS :" print(s) for key, val in self.params.items(): l = (21-len(key))//7 print("{0}".format(key)+"\t"*l+":\t{0}".format(val)) s = "\nRuns stored in DEFAULT_RUNS = "+str(len(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_sim_parameters(self):\n pprint.pprint(vars(self))\n return", "def print_params(self):\n\n logger.info('SimulatedMaps has been initialised with the following attributes:')\n for key in self.params.keys():\n logger.info('{} = {}'.format(key, self.params[key]))", ...
[ "0.66638035", "0.6654243", "0.65848184", "0.64983094", "0.63729537", "0.6371522", "0.63300407", "0.628227", "0.6249049", "0.6231643", "0.6209212", "0.62031406", "0.619824", "0.61875284", "0.61813885", "0.61715716", "0.6169657", "0.6163123", "0.61437184", "0.61434895", "0.6134...
0.72447944
0
run a bunch of simulations, modulating one parameter each time synapse_distr should be a tuple from i_o.get_synapse_range() store output in tuple containing list of simulation run objects and mod_range
def run_modulation(self,parameter="cav_p_open",mod_range=[(x+1)/20 for x in range(20)],synapse_distr=False): sim_runs = [] print("Running Modulation of "+parameter+" for range:") print(mod_range) print("") for x in range(len(mod_range)): print("Run #"+str(x+1)+" wit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(sim_attr_generator):\n#TODO: clean\n#TODO: integrate analyses\n def analyze_and_save(simulation,simulation_attributes):\n#? Ugly conf file analyses integration.\n if simulation_attributes.analyses and Args.output_file != None:\n verbose_print(\"Saving analyses for {0}.\".format(simulat...
[ "0.6438255", "0.6201443", "0.61361796", "0.6124959", "0.6070049", "0.6008676", "0.59633213", "0.59452456", "0.59047467", "0.5833178", "0.58227533", "0.57990956", "0.57914954", "0.5789886", "0.57396877", "0.57264465", "0.5724978", "0.5724084", "0.57111406", "0.57068664", "0.57...
0.7253336
0
to plot where a certain synapse and trace is on the hill function (only one trace/synapse at a time)
def plot_hill_func(self,sim_run=None,trace=0,synapse=0,average=False): if sim_run is None: sim_run = self.default_runs[0] cav_hits = sim_run.data["Ca_t"][:,trace,synapse] p_v_func = hill(np.arange(200)/100.,S=1,ec50=sim_run.params["ca_ec50"],n=sim_run.params["ca_coop"]) pl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot(self):\n\t\tself.plotOfHeatingCurrent().plot()", "def plot_vanHove_dt(comp,conn,start,step_size,steps):\n \n (fin,) = conn.execute(\"select fout from comps where comp_key = ?\",comp).fetchone()\n (max_step,) = conn.execute(\"select max_step from vanHove_prams where comp_key = ?\",comp).fetc...
[ "0.650976", "0.6214818", "0.6204351", "0.619511", "0.6171883", "0.61140436", "0.6093575", "0.6076139", "0.60694313", "0.60479563", "0.60235536", "0.60000885", "0.59608746", "0.59412897", "0.5924625", "0.59066564", "0.5855065", "0.5822589", "0.5816968", "0.581117", "0.5810692"...
0.7128453
0
>>> download_agents()[0].x Donwloads data from website, checks the first agent's position 20
def download_agents(): #this is a doc test. r = requests.get('http://www.geog.leeds.ac.uk/courses/computing/practicals/python/agent-framework/part9/data.html') content = r.text soup = bs4.BeautifulSoup(content, 'html.parser') td_ys = soup.find_all(attrs={"class": "y"}) td_xs = soup.fin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_agent_if_missing(filename):\n if file_missing(filename):\n print filename+'is missing, downloading it first'\n download(filename)", "def fetch_urls(browser, number_publications):\n links = []\n links.extend(re.findall(\"/p/([^/]+)/\", browser.page_source))\n n_scrolls = scr...
[ "0.5376987", "0.536853", "0.5361143", "0.53058916", "0.5111806", "0.51035786", "0.50865966", "0.50805527", "0.50465304", "0.5031586", "0.5016632", "0.5014493", "0.49960774", "0.4984048", "0.4972873", "0.49680972", "0.49671388", "0.4966262", "0.4927262", "0.49094528", "0.48945...
0.5899962
0
Plots the average estimated response and average observed response for groups of a specified variable. A bar chart to display the count within each group is also provided.
def avg_response(df, x, y_obs, y_est, save=False, show=True): fig, ax1 = plt.subplots(figsize=(15,15)) ax2 = ax1.twinx() x_name = x if df[x].dtype == "int": x = df[x].astype("category") elif df[x].dtype == "float": x = pd.cut(df[x], bins=10) metrics = {"mean":"mean", "std er...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot(var):\n # MISSCHIEN KUNNEN WE HIER NOG IETS MEE\n # total_dead = len(train_data[\"Survived\"] == 0)\n # total_survived = len(train_data[\"Survived\"] == 1)\n # died = train_data[train_data[\"Survived\"] == 0][var].value_counts() / total_dead\n # survived = train_data[train_data[\"Survived\"...
[ "0.6272986", "0.58815676", "0.58753604", "0.58711225", "0.5843219", "0.5785193", "0.5747456", "0.57237816", "0.5717383", "0.5712674", "0.5618445", "0.5618378", "0.55925804", "0.5560634", "0.55557597", "0.55506545", "0.5549811", "0.55497795", "0.55254406", "0.54724264", "0.546...
0.6649256
0
Creates a pdf report with avg response plots for each variable specified in var_list.
def avg_response_report(df, var_list, y_obs, y_est, file): page = PdfPages(file) for var in var_list: avg_response(df, var, y_obs, y_est, show=False) page.savefig() page.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_ave(results_list):\n x_range = range(len(results_list[0]))\n err_x, err_y, std_list = [], [], []\n\n for i in x_range:\n if i % 10 == 0:\n #get average for each generation\n column = [] \n for result in results_list:\n column.append(resul...
[ "0.62130785", "0.5782566", "0.57189924", "0.56687677", "0.56392014", "0.5576962", "0.5452435", "0.53628135", "0.5344447", "0.53296703", "0.53150797", "0.5289431", "0.5255784", "0.5237809", "0.52253234", "0.5200862", "0.5194412", "0.51737", "0.51735514", "0.5161112", "0.513948...
0.8189606
0
Constructor creates a straight line with xcoefficient inita, ycoefficient initb, and constant coefficient initc
def __init__(self, inita=0, initb=1, initc=0): self.a = inita self.b = initb if self.a == 0 and self.b == 0: raise Exception("Invalid straight line equation") self.c = initc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, c, p1=Point(), p2 = Point()):\n Line.__init__(self, p1, p2)\n self.cnv = c", "def __init__(self, x, y):\n super().__init__()\n\n # Calculate the quadratic coefficients\n x_sq = [xx**2 for xx in x]\n A = np.vstack([x_sq, x, np.ones(len(x))]).T\n ...
[ "0.692951", "0.626148", "0.61403966", "0.60645384", "0.60610247", "0.60569686", "0.60559434", "0.5993065", "0.5984651", "0.5981468", "0.5981468", "0.5981468", "0.5981468", "0.5981468", "0.59266686", "0.5915448", "0.59000385", "0.5891752", "0.5891752", "0.58851874", "0.5878546...
0.76026696
0
Return the slope of the straight line. If the line is vertical, None is returned.
def slope(self): if self.b == 0: return None else: return (-1) * self.a/self.b
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_segment_slope(segment: Tuple[Point]):\n return (\n (segment[0].y - segment[1].y) / (segment[0].x - segment[1].x)\n if (segment[0].x - segment[1].x) != 0\n else float(\"inf\")\n )", "def slope(start, end):\n\tx1 = start[0]\n\ty1 = start[1]\n\tx2 = end[0]\n\ty2 = end[1]\n\ttop = ...
[ "0.7364191", "0.7166937", "0.7103884", "0.7045604", "0.7019451", "0.69471735", "0.692469", "0.6909021", "0.6900345", "0.6852268", "0.6656526", "0.66505015", "0.66357017", "0.6598907", "0.65987", "0.6584361", "0.65671134", "0.6559925", "0.6549819", "0.6510047", "0.6503251", ...
0.74592346
0
Return the yintercept of the straight line If the line is vertical, None is returned
def yintercept(self): if self.slope() is None: return None else: return self.c/self.b
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_x_y_for_line(bounds, y_intercept, slope): \n\n x = np.sort(bounds)\n\n y = y_intercept + (slope * x)\n\n return x, y", "def get_line_end_pts(line_segment, y1, y2):\n if line_segment is None:\n return None\n\n slope, intercept = line_segment\n\n x1 = int((y1 - intercept) / slop...
[ "0.6660918", "0.6624468", "0.6600898", "0.6539037", "0.6424764", "0.6338208", "0.5991932", "0.5986083", "0.5951831", "0.5908803", "0.5907358", "0.5875608", "0.5825497", "0.5823314", "0.5785119", "0.57730496", "0.57594156", "0.57528734", "0.5750194", "0.57497287", "0.57426494"...
0.75867695
0
Return the xintercept of the straight line If the line is horizontal, None is returned
def xintercept(self): if self.slope() == 0: return None else: return self.c/self.a
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line(intercept, slope, x):\n return slope*x + intercept", "def get_horizontal_line(self, point: Sequence[float], **kwargs) -> Line:\n\n return self.get_line_from_axis_to_point(1, point, **kwargs)", "def begining_of_line():\r\n set_point(point().begining_of_line())", "def line_intercept(p1,p2,p...
[ "0.64042056", "0.6259456", "0.6209308", "0.6192073", "0.6158778", "0.60954744", "0.60718787", "0.5957172", "0.5929775", "0.5878907", "0.58247787", "0.58001995", "0.5797645", "0.57681197", "0.57325584", "0.57325584", "0.5690906", "0.568494", "0.56811166", "0.56772906", "0.5662...
0.7362088
0
Return True if L is parallel to the straight line, and False otherwise
def parallel(self, L): return self.slope() == L.slope()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perpendicular(self, L):\n if self.slope() is None: # if the line is vertical, L must be horizontal\n return L.slope() == 0\n elif self.slope() == 0: # if the line is horizontal, L must be vertical\n return L.slope() is None\n else:\n return self.slope() ...
[ "0.7166783", "0.7142611", "0.6976377", "0.69568163", "0.6914358", "0.68621224", "0.68530166", "0.68178743", "0.6817851", "0.6717622", "0.6670572", "0.6657986", "0.66080886", "0.6605518", "0.657581", "0.65120167", "0.6476982", "0.64696604", "0.6432958", "0.64147866", "0.638021...
0.78763753
0
Return True if L is perpendicular to the straight line, and False otherwise
def perpendicular(self, L): if self.slope() is None: # if the line is vertical, L must be horizontal return L.slope() == 0 elif self.slope() == 0: # if the line is horizontal, L must be vertical return L.slope() is None else: return self.slope() * L.slope()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_perpendicular_to(self, vector):\n\n if abs(self.dot(vector)) < 0.01:\n return True\n return False", "def ll(L1, L2):\n if not all(isinstance(L, Line) for L in (L1, L2)):\n raise TypeError('ll() expects two lines')\n return L1.normal_vector() ** L2.normal_vector() == 0...
[ "0.7048503", "0.7046053", "0.6906444", "0.68979657", "0.68731594", "0.67885673", "0.67519236", "0.6713218", "0.66297054", "0.65473384", "0.6544193", "0.6527107", "0.6505562", "0.64810836", "0.6360246", "0.63600093", "0.6325344", "0.6318955", "0.6314899", "0.6292119", "0.62794...
0.86484283
0
Return the intersection point (a 2tuple) of L with the straight line. If the line is parallel to L, None is returned.
def intersection(self, L): if self.slope() == L.slope(): return None intpt_xcood = (self.c * L.b - L.c * self.b)/(self.a * L.b - L.a * self.b) intpt_ycood = (self.c * L.a - L.c * self.a)/(self.b * L.a - L.b * self.a) return (intpt_xcood, intpt_ycood)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersection(self, line: AbstractLine) -> Optional[AbstractPoint]:\n plane = Plane(self.__point_a,\n self.__point_b - self.__point_a,\n self.__point_c - self.__point_a)\n\n point = plane.intersection(line)\n if point is not None:\n if se...
[ "0.74953175", "0.72366256", "0.71736336", "0.7018175", "0.6921521", "0.6889775", "0.67568314", "0.67477953", "0.6587873", "0.6492234", "0.6457997", "0.6406959", "0.6392092", "0.6383066", "0.63744235", "0.6335968", "0.6276457", "0.62747335", "0.6262454", "0.626192", "0.6230714...
0.72639793
1
record is a 2 element list [personA, personB]
def mapper(record): personA = record[0] personB = record[1] mr.emit_intermediate(personA, personB)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def RECORD(record_or_list, dates_as_iso=False, expand_refs=0):\n if isinstance(record_or_list, Record):\n return _prepare_record_dict(record_or_list, dates_as_iso=dates_as_iso, expand_refs=expand_refs)\n\n try:\n records = list(record_or_list)\n assert all(isinstance(r, Record) for r in records)\n exce...
[ "0.6047177", "0.59028745", "0.57715553", "0.5690277", "0.56728095", "0.5669321", "0.558235", "0.5566881", "0.55136764", "0.54689837", "0.54680896", "0.5428929", "0.54203427", "0.5380737", "0.53656065", "0.5343676", "0.53307116", "0.5328262", "0.53270775", "0.53258866", "0.531...
0.62028843
0
Raises a ValueError if the provided Message is not a FHIR reference.
def _validate_reference(reference: message.Message) -> None: if not annotation_utils.is_reference(reference): raise ValueError( f'Message {reference.DESCRIPTOR.name} is not a FHIR reference.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, message, text=None, reference=None, contact=None):\n self.openid_message = message\n self.reference = reference\n self.contact = contact\n assert type(message) not in [str, str]\n Exception.__init__(self, text)", "def test_invalid_ref_in_property(self):\n ...
[ "0.53380877", "0.53224725", "0.52386135", "0.51981986", "0.5152795", "0.5132949", "0.5045758", "0.49936837", "0.49792278", "0.4978647", "0.49724352", "0.49381897", "0.48967144", "0.48853883", "0.487848", "0.48769715", "0.48400518", "0.482421", "0.48176172", "0.4797601", "0.47...
0.7516594
0
Returns the reference ID field for a provided resource type.
def get_reference_id_field_for_resource( reference: message.Message, resource_type: str) -> descriptor.FieldDescriptor: _validate_reference(reference) field_name = path_utils.camel_case_to_snake_case(resource_type) + '_id' field = reference.DESCRIPTOR.fields_by_name.get(field_name) if field is None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(type_: Dict[str, str]) -> int:\n return int(type_[f'{type_name}_id'])", "def reference_id(self) -> str:\n return pulumi.get(self, \"reference_id\")", "def getTypeID(self) -> int:\n ...", "def get_id_from_ref(ref):\n ref_id = None\n if ref is not None and len(ref) > 0...
[ "0.7214203", "0.6473589", "0.64262575", "0.6391519", "0.6350565", "0.6340821", "0.63336617", "0.6285277", "0.6248177", "0.622544", "0.6193647", "0.61639434", "0.61486083", "0.6090768", "0.60696644", "0.6055495", "0.602719", "0.60268337", "0.60031354", "0.5948144", "0.5941824"...
0.8575352
0
Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data.
def getmodebase(mode): return ImageMode().getmode(mode).basemode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getmodetype(mode):\r\n return ImageMode().getmode(mode).basetype", "def getmode(self, mode):\r\n modes = {}\r\n # core modes\r\n for m, (basemode, basetype, bands) in _MODEINFO.items():\r\n modes[m] = ModeDescriptor(m, bands, basemode, basetype)\r\n # extra experimen...
[ "0.74193406", "0.6618623", "0.63047886", "0.6293309", "0.6206783", "0.6195586", "0.61842334", "0.6122007", "0.6116381", "0.61054254", "0.61054254", "0.6093441", "0.6092703", "0.6055182", "0.6052117", "0.60268027", "0.60268027", "0.60268027", "0.60228217", "0.6016279", "0.5993...
0.8632918
0
Gets the storage type mode. Given a mode, this function returns a singlelayer mode suitable for storing individual bands.
def getmodetype(mode): return ImageMode().getmode(mode).basetype
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mode(self):\n return self._data.get('mode', None)", "def get_mode(self):\r\n return self._api.get_mode()", "def get_mode(self):\r\n return self.mode", "def getmode(self):\n return self.mode", "def getmode(self, mode):\r\n modes = {}\r\n # core modes\r\n ...
[ "0.72878486", "0.70554715", "0.70130104", "0.6983565", "0.6965334", "0.69422174", "0.69383216", "0.6925486", "0.6925486", "0.6924492", "0.6924492", "0.6924492", "0.6917303", "0.6915846", "0.6915617", "0.6906055", "0.6906055", "0.6905283", "0.6902822", "0.6902822", "0.6900335"...
0.73119026
0
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use
def getmodebandnames(mode): return ImageMode().getmode(mode).bands
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getmodebands(mode):\r\n return len(ImageMode().getmode(mode).bands)", "def bands(self):\n\t\treturn self._bands", "def bands(self):\n return self._bands", "def get_worker_bands(self) -> List[BandType]:", "def bandname(self):\n return self._properties[\"bandname\"]", "def getBandnames...
[ "0.7001149", "0.6439917", "0.6196185", "0.6136903", "0.6134504", "0.61022913", "0.60811275", "0.6024488", "0.5933279", "0.59185696", "0.587115", "0.5865979", "0.58442855", "0.5841001", "0.5840017", "0.57507384", "0.5698309", "0.5633168", "0.5614396", "0.55924386", "0.5540013"...
0.84709096
0
'Inplace' analog of Image.alpha_composite. Composites an image onto this image.
def alpha_composite(self, im, dest=(0, 0), source=(0, 0)): if not isinstance(source, (list, tuple)): raise ValueError("Source must be a tuple") if not isinstance(dest, (list, tuple)): raise ValueError("Destination must be a tuple") if not len(source) in (2, 4): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alpha_composite(im1, im2):\r\n r1, g1, b1, a1 = Image().split(im1)\r\n r2, g2, b2, a2 = Image().split(im2)\r\n alphacomp = np.zeros(im1.shape, dtype=im1.dtype)\r\n im3 = composite(alphacomp, im1, a1)\r\n alphacomp = np.zeros(im2.shape, dtype=im2.dtype)\r\n im4 = composite(alphacomp, im2, a2)\...
[ "0.74177617", "0.7093004", "0.70563364", "0.64599884", "0.64136696", "0.6405975", "0.6344653", "0.63076115", "0.623741", "0.62366575", "0.6189054", "0.6123106", "0.6010139", "0.59794265", "0.5974006", "0.59513146", "0.5915312", "0.5914474", "0.58987004", "0.58516055", "0.5836...
0.75862175
0
Returns a histogram for the image. The histogram is returned as a list of pixel counts, one for each pixel value in the source image. If the image has more than one band, the histograms for all bands are concatenated (for example, the histogram for an "RGB" image contains 768 values). A bilevel image (mode "1") is trea...
def histogram(self, mask=None, extrema=None): uni, counts = self._getcolors() return [l for l in counts]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def describe(self, image, mask=None):\n histogram = cv2.calcHist([image], [0, 1, 2], mask, self.bins, [0, 256, 0, 256, 0, 256])\n cv2.normalize(histogram, histogram)\n\n return histogram.flatten()", "def histograms(self, *args, **kwargs):\n return _image.image_histograms(self, *args, ...
[ "0.69900167", "0.6610396", "0.6552293", "0.6299862", "0.61408544", "0.6139109", "0.6043549", "0.60427636", "0.60298526", "0.595549", "0.5829149", "0.5772954", "0.57710135", "0.5740489", "0.57032293", "0.5678399", "0.567833", "0.56576544", "0.56424284", "0.559242", "0.557964",...
0.6618615
1
Adds or replaces the alpha layer in this image. If the image does not have an alpha layer, it's converted to "LA" or "RGBA". The new layer must be either "L" or "1".
def putalpha(self, alpha): channels, depth = self._get_channels_and_depth(self._mode) if isinstance(alpha, np.ndarray): paste_image = True else: paste_image = False if channels==4: r, g, b, a = self.split() if not paste_image: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overlay_alpha_layers(layers, keepalpha=True, dtype=np.float32):\n layer_iter = iter(layers)\n img1 = next(layer_iter)\n rgb1, alpha1 = _prep_rgb_alpha(img1, dtype=dtype)\n\n for img2 in layer_iter:\n rgb2, alpha2 = _prep_rgb_alpha(img2, dtype=dtype)\n rgb1, alpha1 = _alpha_blend_inpla...
[ "0.68926454", "0.66775626", "0.6642565", "0.6370327", "0.6348562", "0.6272967", "0.6214976", "0.61931974", "0.6173027", "0.61116505", "0.60668963", "0.60490817", "0.60149103", "0.59393996", "0.5928146", "0.58661455", "0.581233", "0.58113575", "0.5784807", "0.57517695", "0.574...
0.6711814
1
Copies pixel data to this image. This method copies data from a sequence object into the image, starting at the upper left corner (0, 0), and continuing until either the image or the sequence ends. The scale and offset values are used to adjust
def putdata(self, dat, scale=1.0, offset=0.0): data = np.array(dat) data = data * scale + offset channels, depth = self._get_channels_and_depth(self._mode) siz = self.size _im = np.ravel(self._instance) data = data[:len(_im)] _im = _im[:len(data)] = data ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, frame, offset=OFS):\n frame[\n OFS : OFS + self.image.shape[0], OFS : OFS + self.image.shape[1]\n ] = self.image", "def adjust_image_data(self):\r\n\r\n print('Adjusting image data: ')\r\n\r\n if self.removeFirstSequence: # used to remove the first trial fro...
[ "0.5834029", "0.5822663", "0.55779636", "0.5547315", "0.554644", "0.5539611", "0.5520755", "0.55167884", "0.55137485", "0.54911315", "0.5476981", "0.5425262", "0.5422462", "0.53885484", "0.5386036", "0.538219", "0.5372337", "0.5331992", "0.53313965", "0.53288794", "0.5293788"...
0.5909142
0
Seeks to the given frame in this sequence file. If you numpy2gifek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0. Note that in the current version of the library, most sequence formats only allows you to seek to the ne...
def seek(self, frame): if frame>=self.n_frames: raise EOFError("Frame number is beyond the number of frames") else: self._frame_nr = frame self._instance = self.frames[frame]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_frame(self, n):\n self.sound.seek(n)\n self._current_frame = n", "def advance_in_file(self, file_pos):\n if self.is_open:\n try:\n self.fd.seek(file_pos)\n except (AttributeError, ValueError): # pragma: debug\n if self.is_open:...
[ "0.581889", "0.57004464", "0.5665532", "0.5629413", "0.56082237", "0.5516672", "0.54625636", "0.5416819", "0.53481257", "0.5330396", "0.53217256", "0.5236598", "0.522815", "0.5198737", "0.5169777", "0.51654124", "0.51011217", "0.5089388", "0.5058896", "0.5026361", "0.50190157...
0.67903125
0
Make this image into a thumbnail. This method modifies the image to contain a thumbnail version of itself, no larger than the given size. This method calculates an appropriate thumbnail size to preserve the aspect of the image, calls the
def thumbnail(self, size, resample=BICUBIC): # preserve aspect ratio x, y = self.size if x > size[0]: y = int(max(y * size[0] / x, 1)) x = int(size[0]) if y > size[1]: x = int(max(x * size[1] / y, 1)) y = int(size[1]) size ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize_image(image, size=(926, 617)):\n\n im = Image.open(image)\n im.convert('RGB')\n im.thumbnail(size)\n thumb_io = BytesIO()\n im.save(thumb_io, 'JPEG', quality=85)\n thumbnail = File(thumb_io, name=image.name)\n return thumbnail", "def img_resize(infile, size):\n try:\n in...
[ "0.7389323", "0.72575986", "0.7197877", "0.71460813", "0.69607085", "0.6918584", "0.6914563", "0.6866507", "0.6844879", "0.68147904", "0.67465633", "0.6732139", "0.6689216", "0.66817874", "0.6676919", "0.664664", "0.65712076", "0.6569657", "0.6549778", "0.64706296", "0.645972...
0.7940607
0
calculate point (x,y) for a given angle ang on an ellipse with its center at centerx, centery and its horizontal radiush and its vertical radiusv
def _get_pointFromEllipseAngle(self, centerx, centery, radiush, radiusv, ang): th = np.radians(ang) ratio = (radiush/2.0)/float(radiusv/2.0) x = centerx + radiush/2.0 * np.cos(th) y = centery + radiusv/2.0 * np.sin(th) return int(x), int(y)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ellipse(self):\n f = self.img\n x = self.x\n y = self.y\n x2 = self.x2\n y2 = self.y2\n xy = self.xy\n self.a2 = (x2+y2) + sqrt(((x2-y2)/2.)**2 + xy**2)\n self.b2 = (x2+y2) - sqrt(((x2-y2)/2.)**2 + xy**2)\n self.a = sqrt(self.a2)\n self.b = sqrt(self....
[ "0.7398188", "0.7084216", "0.7043236", "0.688056", "0.6867334", "0.6799484", "0.6770698", "0.67403173", "0.6703428", "0.66681963", "0.66667646", "0.6660637", "0.65539074", "0.6545677", "0.6435292", "0.6419396", "0.6383157", "0.6372657", "0.6366095", "0.636599", "0.63603014", ...
0.836559
0
A simple 2D drawing interface for PIL images.
def Draw(im, mode=None): # try: # return im.getdraw(mode) # except AttributeError: # return ImageDraw(im, mode) return ImageDraw(im)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw(self, x, y, dx, dy, color):\n\n draw = ImageDraw.Draw(self.image)\n\n draw.rectangle([(x,y),(dx,dy)], color, outline=None)", "def get_image(self):\n image = Image.new('1', (8, 16))\n draw = ImageDraw.Draw(image)\n for x in xrange(8):\n for y in xrange(16):\n...
[ "0.63596463", "0.6330536", "0.6326034", "0.62757623", "0.62357527", "0.61913747", "0.6174545", "0.61168766", "0.6074993", "0.606635", "0.59896314", "0.59639984", "0.5949333", "0.5922507", "0.5905733", "0.58952296", "0.5886632", "0.5886068", "0.5878178", "0.5874104", "0.585492...
0.6600076
0
Gets a mode descriptor for the given mode.
def getmode(self, mode): modes = {} # core modes for m, (basemode, basetype, bands) in _MODEINFO.items(): modes[m] = ModeDescriptor(m, bands, basemode, basetype) # extra experimental modes modes["RGBa"] = ModeDescriptor("RGBa", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mode(self, ):\n return self.get_parameter('mode')", "def mode(self):\n return self._data.get('mode', None)", "def get_mode(self):\r\n return self._api.get_mode()", "def get_mode(self):\r\n return self.mode", "def getmode(self):\n return self.mode", "def get_mode...
[ "0.70583034", "0.70422727", "0.7036573", "0.7019406", "0.7012943", "0.7008377", "0.69788706", "0.6930293", "0.6914595", "0.6872009", "0.6854045", "0.6854045", "0.6854045", "0.68409944", "0.6836563", "0.6831456", "0.6831456", "0.6831456", "0.6809317", "0.68004644", "0.6780946"...
0.7578383
0
Common check to enforce type and sanity check on size tuples
def _check_size(size): if not isinstance(size, (list, tuple)): raise ValueError("Size must be a tuple") if len(size) != 2: raise ValueError("Size must be a tuple of length 2") if size[0] < 0 or size[1] < 0: raise ValueError("Width and height must be >= 0") return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_list_of_equal_len():\n\n @type_checked\n def _run_test(something:[str, int, bool]):\n assert isinstance(something[0], str)\n assert isinstance(something[1], int)\n assert isinstance(something[2], bool)\n\n _run_test(something=[None, \"12\", 1])", "def __size_restriction_inc...
[ "0.7021964", "0.68438643", "0.68385047", "0.6774464", "0.676999", "0.6747268", "0.67050594", "0.66413397", "0.6622299", "0.65459746", "0.6538224", "0.64933", "0.649159", "0.64404726", "0.64403695", "0.64007986", "0.6389875", "0.63648", "0.6346499", "0.63307214", "0.6302581", ...
0.7576245
0
Creates a new image with the given mode and size.
def new(mode, size, color=0): _check_size(size) if color is None: # don't initialize _im = Image()._new(mode, size) return Image(_im) if type(color).__name__ == "str": # css3-style specifier color = ImageColor().getcolor(color, mode) color = Ima...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_image(storage, filename, size=(100, 100), image_mode='RGB', image_format='PNG'):\n data = BytesIO()\n PIL.Image.new(image_mode, size).save(data, image_format)\n data.seek(0)\n if not storage:\n return data\n image_file = ContentFile(data.read())\n return storage.save(filename, i...
[ "0.7050601", "0.7033265", "0.6980973", "0.6725615", "0.64338475", "0.63699013", "0.62156343", "0.5979368", "0.5970218", "0.5810323", "0.5792077", "0.57874864", "0.5786103", "0.57712936", "0.5710684", "0.56795233", "0.5660675", "0.56303596", "0.56022155", "0.55955166", "0.5585...
0.76179135
0
Creates an image memory from an object exporting the array interface (using the buffer protocol). If obj is not contiguous, then the tobytes method is called
def fromarray(obj, mode=None): if isinstance(obj, np.ndarray): _mode = Image()._get_mode(obj.shape, obj.dtype) if _mode == 'RGB': obj = cv2.cvtColor(obj, cv2.COLOR_RGB2BGR) elif mode == "RGBA": obj = cv2.cvtColor(obj, cv2.COLOR_RGBA2BGRA) return Image(o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _tobuffer(self, object_):\n\n raise NotImplementedError", "def serialize(obj):\n return np.fromstring(pickle.dumps(obj), dtype=np.uint8).astype(np.float32)", "def serialize(obj):\n return np.fromstring(pickle.dumps(obj), dtype=np.uint8).astype(np.float32)", "def asarray(obj, itemsize=None, u...
[ "0.6534533", "0.6064485", "0.6064485", "0.6059072", "0.59939635", "0.59344447", "0.5844922", "0.57877684", "0.57358426", "0.56880414", "0.56742525", "0.56553286", "0.5627507", "0.5627507", "0.5589481", "0.55763996", "0.55743444", "0.55666006", "0.5551432", "0.5528058", "0.552...
0.6243654
1
Alpha composite im2 over im1.
def alpha_composite(im1, im2): r1, g1, b1, a1 = Image().split(im1) r2, g2, b2, a2 = Image().split(im2) alphacomp = np.zeros(im1.shape, dtype=im1.dtype) im3 = composite(alphacomp, im1, a1) alphacomp = np.zeros(im2.shape, dtype=im2.dtype) im4 = composite(alphacomp, im2, a2) return blend...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _blend(img1, img2, alpha):\n return img1.mul(alpha).add(1 - alpha, img2)", "def overlay_two_imgs(img1, img2, alpha=0.5):\n # Validate alpha\n if alpha > 1 or alpha < 0:\n fatal_error(\"The value of alpha should be in the range of (0,1)!\")\n\n # Validate image sizes are the same\n size_...
[ "0.7826415", "0.76921284", "0.7499772", "0.73837155", "0.71249557", "0.6970056", "0.69635725", "0.6951903", "0.68631494", "0.6629562", "0.65333754", "0.652154", "0.6500405", "0.6471415", "0.63709354", "0.636076", "0.6339621", "0.63121444", "0.62808", "0.62233764", "0.62221324...
0.85184
0
Take a question file, and returning a list of `Question` objects.
def get_questions(qn_filepath): array = [] with open(qn_filepath, 'rb') as file: for line in file: array.append(line) delete = ['<top>\r\n', '\r\n', '<desc> Description:\r\n', '</top>\r\n'] for i in delete: array = list(filter((i).__ne__, array)) final_array = [] for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_questions(file_name='questions.csv'):\n questions = []\n\n with open(file_name) as csvfile:\n csvreader = csv.reader(csvfile, delimiter=',', quotechar='\"')\n\n for index, row in enumerate(csvreader):\n questions.append(Question(int(row[0]),\n ...
[ "0.7246751", "0.7241736", "0.68975824", "0.6749347", "0.64885396", "0.6372762", "0.6370283", "0.6272366", "0.6198504", "0.6065089", "0.6028565", "0.5912043", "0.58960605", "0.5824803", "0.5816058", "0.57964784", "0.57829934", "0.5780258", "0.57793343", "0.575813", "0.57577366...
0.7270864
0
Given the question id and path to answers for all questions, return the list of documents that contain answers
def get_documents(path_to_dir, qn_id): files_to_question = [] directory = os.path.join(path_to_dir, str(qn_id)) filenames = os.listdir(directory) filenames.sort(key=int) for filename in filenames: doc_name, _ = os.path.splitext(filename) document_filepath = os.path.join(directory, f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_answers(path: str):\n if not os.path.exists(path):\n raise FileNotFoundError(\"file {} does not exists\".format(path))\n\n collection = {}\n with open(path, 'r') as file:\n for l in file.readlines():\n split = l.split(' ')\n index, doc_id = int(split[0]), int(s...
[ "0.66400397", "0.5719572", "0.57046854", "0.56917447", "0.5655302", "0.55065054", "0.54775417", "0.5461554", "0.5448024", "0.5443218", "0.52777815", "0.5240148", "0.52308375", "0.519296", "0.51627445", "0.51517123", "0.51205117", "0.5093833", "0.5086946", "0.50797665", "0.507...
0.6150074
1
Run any available automatic updates
def _do_automatic_updates(self): from .updates import Updates for update_name in Updates.check_automatic_updates(): print("Applying automatic update: {}".format(update_name)) Updates.do_update(update_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update( ):\r\n pass", "def run_update():\n\n args = _parse_arguments()\n\n # get dependencies\n dependencies = get_dependencies(args.folder)\n\n # get update config of dependencies\n update_info = get_update_info()\n\n install_queue = build_queue(\n update_info, dependencies, ...
[ "0.68387514", "0.67803097", "0.67694116", "0.67483944", "0.6739298", "0.6739298", "0.673246", "0.6704835", "0.6684409", "0.66661066", "0.66234773", "0.6621876", "0.65760237", "0.6525605", "0.65126944", "0.6494933", "0.645831", "0.6454078", "0.6441949", "0.6441283", "0.6387731...
0.85161316
0
Get directory for output files. Uses environment variable ``BRIGHTWAY2_OUTPUT_DIR``; ``preferences['output_dir']``; or directory ``output`` in current project. Returns output directory path.
def output_dir(self): ep, pp = ( maybe_path(os.getenv("BRIGHTWAY2_OUTPUT_DIR")), maybe_path(config.p.get("output_dir")), ) if ep and ep.is_dir(): return ep elif pp and pp.is_dir(): return pp else: return self.request_dir...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_output_path():\n return os.getcwd() + \"/output/\"", "def get_output_dir(self):\n return self.output_dir", "def outputdir():\n return __OUTPUT_DIR__", "def output_dir(self):\n return os.path.join(self._sandbox, 'output' + os.path.sep)", "def get_output_dir(self):\n return...
[ "0.7468781", "0.7314277", "0.7295703", "0.7294863", "0.72655517", "0.71530145", "0.7125894", "0.7114579", "0.70545405", "0.70489943", "0.6987306", "0.6768059", "0.6752238", "0.66888946", "0.6680562", "0.66408074", "0.66290057", "0.6622328", "0.6595422", "0.6581295", "0.651601...
0.8114319
0
Copy current project to a new project named ``new_name``. If ``switch``, switch to new project.
def copy_project(self, new_name, switch=True): if new_name in self: raise ValueError("Project {} already exists".format(new_name)) fp = self._base_data_dir / safe_filename(new_name, full=self.dataset.full_hash) if fp.exists(): raise ValueError("Project directory already e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def switch_project(self, project_name, check=True):\n with self.app.page_base.dropdown_menu_project as menu:\n\n if menu.label_project.value == project_name:\n self.app.current_project = project_name\n return\n\n menu.click()\n menu.item_project...
[ "0.6570881", "0.6161404", "0.59923553", "0.58610016", "0.5829468", "0.58159685", "0.5797276", "0.55726177", "0.5498399", "0.54869246", "0.5472639", "0.5428517", "0.5388308", "0.534181", "0.53339595", "0.53120494", "0.5292763", "0.5220154", "0.5190714", "0.5187932", "0.5186884...
0.7932269
0
Point the ProjectManager towards a temporary directory instead of `user_data_dir`. Used exclusively for tests.
def _use_temp_directory(self): if not self._is_temp_dir: self._orig_base_data_dir = self._base_data_dir self._orig_base_logs_dir = self._base_logs_dir temp_dir = Path(tempfile.mkdtemp()) self._base_data_dir = temp_dir / "data" self._base_logs_dir = temp_dir / "log...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_user_data_dir(self):\n self._user_data_dir = tempfile.TemporaryDirectory(prefix=f'{self.USER_DATA_DIR_PREFIX}_tmp_')\n return self._user_data_dir.name", "def _temp_dir(self):\n tmp_dir = os.path.join(self.output_dir, self.config.find_tune[\"run_dir\"])\n try:\n ...
[ "0.73173493", "0.72052014", "0.7195199", "0.70279366", "0.6918659", "0.67983097", "0.67747945", "0.67627513", "0.6749146", "0.6715924", "0.67100096", "0.6691613", "0.6691613", "0.6640233", "0.6619128", "0.6543333", "0.6543333", "0.6543333", "0.6543333", "0.6543333", "0.654333...
0.72850245
1
Point the ProjectManager back to original directories. Used exclusively in tests.
def _restore_orig_directory(self): if not self._is_temp_dir: return self._base_data_dir = self._orig_base_data_dir del self._orig_base_data_dir self._base_logs_dir = self._orig_base_logs_dir del self._orig_base_logs_dir self.db.change_path(self._base_data_dir ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\r\n self._root_dir = None", "def resetWorkingDirectory( self ):\n self.cwd = self.path", "def tearDown(self):\n # unittest.TestCase.tearDown(self)\n\n root = os.path.join(\".\", \"files\")\n endingList = os.listdir(root)\n rmList = [fn for fn in endingList if ...
[ "0.67874736", "0.6360402", "0.6320904", "0.6313339", "0.6269328", "0.6205224", "0.6093901", "0.6037744", "0.60184413", "0.6004511", "0.5974991", "0.59655535", "0.5955894", "0.5949952", "0.5928603", "0.5928603", "0.58895755", "0.5884733", "0.5855362", "0.584434", "0.58135843",...
0.75356644
0
Delete project ``name``, or the current project. ``name`` is the project to delete. If ``name`` is not provided, delete the current project. By default, the underlying project directory is not deleted; only the project name is removed from the list of active projects. If ``delete_dir`` is ``True``, then also delete the...
def delete_project(self, name=None, delete_dir=False): victim = name or self.current if victim not in self: raise ValueError("{} is not a project".format(victim)) if len(self) == 1: raise ValueError("Can't delete only remaining project") ProjectDataset.delete()....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_project(\n name\n):\n\n cmd = dict()\n cmd[\"type_\"] = \"delete_project\"\n cmd[\"name_\"] = name\n\n comm.send(cmd)", "def delete(self):\n _url = f\"{self.connector.base_url}/projects/{self.project_id}\"\n\n self.connector.http_call(\"delete\", _url)\n\n self....
[ "0.6074884", "0.5668781", "0.5642265", "0.538783", "0.5384421", "0.5348353", "0.5290247", "0.52060354", "0.5159435", "0.5111131", "0.5070248", "0.4955428", "0.49289957", "0.4893168", "0.4855105", "0.4854254", "0.4787456", "0.47696927", "0.47509116", "0.4750903", "0.47246382",...
0.79898983
0
Give a report on current projects, including installed databases and file sizes. Returns tuples of ``(project name, number of databases, size of all databases (GB))``.
def report(self): from . import databases _current = self.current data = [] def get_dir_size(dirpath): """Modified from http://stackoverflow.com/questions/12480367/how-to-generate-directory-size-recursively-in-python-like-du-does. Does not follow symbolic links...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_project_stats(self, pool, project):\n svc = self.project_path % (pool, project)\n ret = self.rclient.get(svc)\n if ret.status != restclient.Status.OK:\n exception_msg = (_('Error getting project stats: '\n 'pool: %(pool)s '\n ...
[ "0.62372994", "0.59644437", "0.5955234", "0.5950448", "0.5801446", "0.57668406", "0.573293", "0.5653337", "0.56500965", "0.56373423", "0.5555827", "0.55301195", "0.54763895", "0.5459824", "0.54540616", "0.54517734", "0.5411624", "0.53499293", "0.53321147", "0.5308962", "0.529...
0.7339567
0
Function that generates a donorvector. If there is >=3 searchvariables then the adaptive scaling factor is implimented. Otherwise just the constant. It gnerates candidates for the donorvector by randomly choosing rows from the initial matrix, but not the ith element. Paramaters
def mutation(i,N_p,t,T,P,N_vars,F_min,F_const): #Adaptive scaling factor if N_vars >= 3: F=F_min*2**np.exp(1-(T/(T+1-t))) else: F = F_const #candidates are assigned without the i-th element candidates= np.delete(np.arange(N_p), np.where(np.arange(N_p)==i)) #3 target vectors are ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_vector(size):\n solution = []\n for i in range(size):\n rand_num = uniform(-size, size)\n solution.append(rand_num)\n return np.array(solution)", "def generateProbabilisticVector(size, empty):\n\n res = np.zeros(size)\n\n if(empty):\n\n #Generate th...
[ "0.5713445", "0.5688836", "0.5642662", "0.55862236", "0.5564165", "0.5489675", "0.5482834", "0.54093033", "0.53940886", "0.53795874", "0.5373351", "0.5359693", "0.53555995", "0.5331755", "0.53237486", "0.5314485", "0.52926415", "0.5291193", "0.5287574", "0.5285245", "0.528524...
0.64224416
0
Crossover function for differential evolution. This function uses adaptive crossover rate. The minimum and the maximum range is set by user. It decides whether or not to use donorvector's jth elements in the U matrix. Paramaters
def crossover(f,P_c_min,P_c_max,i,D,V,P,U): #ADAPTIVE Crossover if f[i] < np.mean(f): P_c = P_c_min + (P_c_max-P_c_min)*((f[i]-np.mean(f))/(np.max(f)-np.mean(f))) else: P_c = P_c_min delta = np.random.randint(0,D-1) for j in np.arange(D): if np.random.uniform(0,1) <= P_c o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _cross_over(self,mp,cross_rate,eta):", "def crossover(NN1, NN2, p_c, p_m):\n if np.random.choice([0, 1], p=[1-p_c, p_c]):\n return nn.mate_neural_nets(NN1, NN2, p_m)\n else:\n return np.random.choice([NN1, NN2])", "def ciou(pred, target, eps=1e-7):\n # overlap\n lt = torch.max(pre...
[ "0.62787056", "0.5401195", "0.536973", "0.53535783", "0.53305084", "0.52989906", "0.5220156", "0.5086378", "0.5010793", "0.50038093", "0.5000887", "0.497259", "0.49526855", "0.4950322", "0.49460703", "0.4939531", "0.49298885", "0.49173522", "0.49152607", "0.4909205", "0.49014...
0.67585707
0
Function that uses pythagorean theorem to calculate distance between the found point and known location. NB!!! This function is not used in the main prgram so thist must be called itself.
def distance(known_loc,found_loc,N_vars,): undersqrt=np.zeros(N_vars) for i in (np.arange(N_vars)): undersqrt[i] =(known_loc[i]-found_loc[i])**2 dist = np.sqrt(sum(undersqrt)) return dist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _computeDistance(self, mote, neighbor):\n\n return 1000*math.sqrt((mote.x - neighbor.x)**2 +\n (mote.y - neighbor.y)**2)", "def _computeDistance(self, mote, neighbor):\n\n return 1000*math.sqrt((mote.x - neighbor.x)**2 +\n (mote.y - neig...
[ "0.67001003", "0.67001003", "0.668429", "0.66520405", "0.66520405", "0.66172695", "0.6616293", "0.66006625", "0.65998554", "0.65997404", "0.65976804", "0.6571387", "0.6536612", "0.6525614", "0.6512911", "0.65055317", "0.64955235", "0.6490895", "0.6487881", "0.6487362", "0.648...
0.6931908
0
Prints the accuracy of a model in a nice format.
def print_accuracy(acc: float, model_name: str) -> None: print(f"accuracy of {model_name} = {round(100* acc,2)}%")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_accuracy(self):\r\n return round(accuracy_score(self.actual, self.predicted),2)", "def print_model_analysis(predictions, targets, print_conf_matrix=False):\n accuracy = accuracy_per_shift(predictions, targets)\n built_in_accuracy = accuracy_score(targets, predictions)\n\n conf_matrix = c...
[ "0.7742356", "0.71960884", "0.70556444", "0.7024729", "0.69513243", "0.6905513", "0.6895574", "0.6863374", "0.6848317", "0.6816727", "0.67776877", "0.67469156", "0.6731067", "0.66809744", "0.66269875", "0.65719056", "0.65452284", "0.6532581", "0.6512558", "0.646412", "0.64499...
0.81111825
0
Checks whether the specified 'childid' halo is a subhalo of 'parentid' halo.
def is_subhalo(self, childid, parentid): if (childid in self._halos[parentid].properties['children']): return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_child(self, parent, child): # type: (str, str) -> bool\n return child != parent and child.startswith(parent + \".\")", "def is_subpath_of(parent, child):\n # Based on https://stackoverflow.com/a/37095733 .\n\n # In Python 3.9, the `Path.is_relative_to()` method will supplant this, so\n #...
[ "0.7011642", "0.6519133", "0.6421444", "0.6203408", "0.61802125", "0.6062339", "0.604538", "0.60408974", "0.60153866", "0.5923618", "0.59223753", "0.58900964", "0.5889205", "0.5869861", "0.58656186", "0.58480877", "0.5774682", "0.57726324", "0.5757294", "0.57391155", "0.57132...
0.8721258
0
Creates a 'grp' array which labels each particle according to its parent halo.
def make_grp(self): try: self.base['grp'] except: self.base['grp'] = np.zeros(len(self.base),dtype='i') for halo in self._halos.values(): halo[name][:] = halo._halo_id if config['verbose']: print "writing %s"%(self._base().filename+'.grp') s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getGroups(self):\n groups_ = {'black': [], 'white': []}\n for color, stones in self.stones.items():\n if not stones: continue\n # (group_labels) is a parallel array to (stones). Where each value is an\n # int and each int value represents a group. Examples:\n ...
[ "0.60749334", "0.6051593", "0.60361016", "0.59773016", "0.58477736", "0.57438767", "0.5581628", "0.55605465", "0.553918", "0.5472934", "0.5423763", "0.53898454", "0.5385271", "0.5360189", "0.5349044", "0.5325815", "0.5325815", "0.53235996", "0.53167826", "0.531357", "0.530960...
0.70059013
0
Creates a 'children' array inside each halo's 'properties' listing the halo IDs of its children. Used in case the reading of substructure data from the AHFsupplied _substructure file fails for some reason.
def _setup_children(self): for i in xrange(self._nhalos): self._halos[i+1].properties['children'] = [] for i in xrange(self._nhalos): host = self._halos[i+1].properties.get('hostHalo', -2) if host > -1: try: self._halos[host+1].pr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setup_children(self):\n\n for i in xrange(self._nhalos):\n self._halos[i + 1].properties['children'] = []\n\n for i in xrange(self._nhalos):\n host = self._halos[i + 1].properties.get('hostHalo', -2)\n if host > -1:\n try:\n self...
[ "0.7406418", "0.6090226", "0.5948918", "0.58916914", "0.5828866", "0.58213186", "0.5682286", "0.5663575", "0.5655514", "0.5655187", "0.56005794", "0.55924815", "0.5587395", "0.55825055", "0.5578867", "0.55643857", "0.55631024", "0.55561423", "0.55486053", "0.55143625", "0.551...
0.7425512
0
write a condensed skid.stat style ascii file from ahf_halos file. header + 1 halo per line. should reproduce `Alyson's idl script' except does not do last 2 columns (Is it a satellite?) and (Is central halo is `false'ly split?). output units are set to Mpc Msun, km/s. user can specify own hubble constant hubble=(H0/(10...
def writestat(self, outfile=None, hubble=None): s = self._base() mindarkmass = min(s.dark['mass']) if hubble is None: hubble = s.properties['h'] if outfile is None: outfile = self._base().filename+'.stat' print "write stat file to ", outfile fpout = open(out...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writehalos(self, snapshot, halos, hubble=None, outfile=None):\n s = snapshot\n grpoutfile = s.filename + \".amiga.grp\"\n statoutfile = s.filename + \".amiga.stat\"\n tipsyoutfile = s.filename + \".amiga.gtp\"\n halos.writegrp(s, halos, grpoutfile)\n halos.writestat(s,...
[ "0.66609514", "0.6492009", "0.5822685", "0.58220613", "0.58087313", "0.55292356", "0.5503008", "0.544077", "0.5423525", "0.53699297", "0.53241825", "0.5292673", "0.5285925", "0.52806836", "0.5273414", "0.5246686", "0.52335835", "0.5232767", "0.51816946", "0.5146505", "0.51451...
0.6493145
1
write halos to tipsy file (write as stars) from ahf_halos file. returns a shapshot where each halo is a star particle. user can specify own hubble constant hubble=(H0/(100 km/s/Mpc)), ignoring the snaphot arg for hubble constant (which sometimes has a large roundoff error).
def writetipsy(self, outfile=None, hubble=None): from . import analysis from . import tipsy from .analysis import cosmology from snapshot import _new as new import math s = self._base() if outfile is None: outfile = s.filename+'.gtp' print "write tipsy fil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writehalos(self, snapshot, halos, hubble=None, outfile=None):\n s = snapshot\n grpoutfile = s.filename + \".amiga.grp\"\n statoutfile = s.filename + \".amiga.stat\"\n tipsyoutfile = s.filename + \".amiga.gtp\"\n halos.writegrp(s, halos, grpoutfile)\n halos.writestat(s,...
[ "0.7275809", "0.6712091", "0.64900565", "0.6376433", "0.557622", "0.5441786", "0.53530097", "0.52741796", "0.5257279", "0.5211083", "0.5197172", "0.5094587", "0.5081192", "0.50688195", "0.5064385", "0.50592387", "0.5035094", "0.5020665", "0.50188285", "0.49892023", "0.4965852...
0.67932194
1
Creates a 'children' array inside each halo's 'properties' listing the halo IDs of its children. Used in case the reading of substructure data from the AHFsupplied _substructure file fails for some reason.
def _setup_children(self): for i in xrange(self._nhalos): self._halos[i + 1].properties['children'] = [] for i in xrange(self._nhalos): host = self._halos[i + 1].properties.get('hostHalo', -2) if host > -1: try: self._halos[host +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setup_children(self):\n\n for i in xrange(self._nhalos):\n self._halos[i+1].properties['children'] = []\n\n for i in xrange(self._nhalos):\n host = self._halos[i+1].properties.get('hostHalo', -2)\n if host > -1:\n try:\n self._ha...
[ "0.74248827", "0.60904205", "0.59497046", "0.58910304", "0.5828248", "0.58218026", "0.56816673", "0.5663531", "0.5654989", "0.565448", "0.5599524", "0.559273", "0.5586169", "0.55819756", "0.5578019", "0.5564336", "0.55633384", "0.5557217", "0.5547155", "0.5513899", "0.5512633...
0.7405761
1
Get the starting positions of each halo's particle information within the AHF_particles file for faster access later
def _get_file_positions(self,filename): if os.path.exists(self._ahfBasename + 'fpos'): f = util.open_(self._ahfBasename + 'fpos') for i in range(self._nhalos): self._halos[i+1].properties['fstart'] = int(f.readline()) f.close() else: f = ut...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_ahf_particle_block(self, f, nparts=None):\n ng = len(self.base.gas)\n nd = len(self.base.dark)\n ns = len(self.base.star)\n nds = nd+ns\n\n if nparts is None:\n startline = f.readline()\n if len((startline.split()))==1:\n startline =...
[ "0.619073", "0.59944826", "0.5959006", "0.5894076", "0.58502007", "0.58053553", "0.57826936", "0.57551414", "0.57096756", "0.5669289", "0.55754834", "0.55319995", "0.5517277", "0.551446", "0.5512527", "0.548089", "0.5454202", "0.54331416", "0.5425648", "0.54220545", "0.537746...
0.6874911
0
Load the particles for the next halo described in particle file f
def _load_ahf_particle_block(self, f, nparts=None): ng = len(self.base.gas) nd = len(self.base.dark) ns = len(self.base.star) nds = nd+ns if nparts is None: startline = f.readline() if len((startline.split()))==1: startline = f.readline() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_particle_ic(self, file_name):\n \n\n data = np.genfromtxt(file_name, names = True)\n\n self.N_part = np.size(data['x'])\n\n self.pos = np.array([data['x'], data['y'], data['z']])\n self.pos = self.pos.T.reshape(self.N_part,3)\n self.vel = np.array([data['vx'], data['vy...
[ "0.6476038", "0.62456244", "0.62420654", "0.5975579", "0.5904623", "0.58064884", "0.5734992", "0.5640551", "0.56393373", "0.5608404", "0.5608129", "0.5560564", "0.55414915", "0.55377823", "0.5471918", "0.5459634", "0.5459327", "0.5428468", "0.54155725", "0.540176", "0.5399098...
0.66399556
0
Write the (ahf) halo catalog to disk. This is really a wrapper that calls writegrp, writetipsy, writestat. Writes .amiga.grp file (ascii group ids), .amiga.stat file (ascii halo catalog) and .amiga.gtp file (tipsy halo catalog). default outfile base simulation is same as snapshot s. function returns simsnap of halo cat...
def writehalos(self, snapshot, halos, hubble=None, outfile=None): s = snapshot grpoutfile = s.filename + ".amiga.grp" statoutfile = s.filename + ".amiga.stat" tipsyoutfile = s.filename + ".amiga.gtp" halos.writegrp(s, halos, grpoutfile) halos.writestat(s, halos, statoutfi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def writegrp(self, grpoutfile=False):\n snapshot = self[1].ancestor\n try:\n snapshot['grp']\n except:\n self.make_grp()\n if not grpoutfile:\n grpoutfile = snapshot.filename + '.grp'\n logger.info(\"Writing grp file to %s\" % grpoutfile)\n ...
[ "0.6592326", "0.6552484", "0.64661205", "0.5749943", "0.5684815", "0.55851275", "0.5578105", "0.551729", "0.5509045", "0.54342794", "0.54312193", "0.5402147", "0.5394604", "0.5379659", "0.5317676", "0.53172624", "0.52944994", "0.52812386", "0.5244382", "0.52434015", "0.523645...
0.7460119
0
Lists days on which error requests make up more than 1% all requests
def error_dates(): results = query_database(QUERIES[2]) print('\nOn which days did more than 1% of requests lead to errors?\n') for date, rate in results: print(' * {} -- {:.2%}'.format(date, rate))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def days_with_request():\n\n # To print information\n information_string = '3. Days with more than ' \\\n '1% of request that lead to an error:\\n'\n\n # Query string\n query = \"\"\"select * from (select date(time),\n round(100.0*sum(case log.status\n whe...
[ "0.7756553", "0.7632925", "0.7542556", "0.72305334", "0.70753413", "0.69370914", "0.69317937", "0.6914181", "0.6869531", "0.6851303", "0.68247795", "0.68124545", "0.6742325", "0.6640619", "0.6598854", "0.62288076", "0.62149715", "0.6205723", "0.61201817", "0.61027896", "0.600...
0.77700573
0
Generates a random Hermitian matrix as a numpy array.
def random_numpy_hermitian(nqubits, dtype=np.complex128): shape = 2 * (2 ** nqubits,) m = random_numpy_complex(shape, dtype) return (m + m.T.conj()) / 2.0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_matrix(rows, cols):\n return np.random.randn(rows, cols)", "def generate_matrix(size) -> np.ndarray:\n np.random.seed(1)\n return np.random.rand(size, size) - 0.5", "def generate_matrix(rows, cols):\n matrix_random = np.random.rand(rows, cols)\n return matrix_random", "def generate_...
[ "0.66864717", "0.6652837", "0.65999264", "0.65480554", "0.644787", "0.63744944", "0.63523203", "0.63135517", "0.62188065", "0.621837", "0.62032086", "0.6190402", "0.61276305", "0.61273324", "0.5980093", "0.5980093", "0.591237", "0.59014493", "0.5889934", "0.58402646", "0.5815...
0.6777068
0
Generates a random density matrix. Note that the density matrix generated by this method is not necessarily positive. This is okay for most tests but may not work for some cases such as the entanglement entropy calculation.
def random_density_matrix(nqubits: int, dtype=np.complex128) -> np.ndarray: rho = random_numpy_hermitian(nqubits, dtype=dtype) # Normalize ids = np.arange(2 ** nqubits) rho[ids, ids] = rho[ids, ids] / np.trace(rho) return rho.astype(dtype)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_density_matrix(states=None, dimensions=None):\n if states is None:\n tdim = np.prod(dimensions)\n dmtotal0 = np.eye(tdim) / tdim\n\n return dmtotal0\n\n dmtotal0 = np.eye(1, dtype=np.complex128)\n\n for i, s in enumerate(states):\n\n if not hasattr(s, \"__len__\"):\n ...
[ "0.63794065", "0.6172743", "0.6084907", "0.6083014", "0.60053265", "0.5925018", "0.59105027", "0.58204406", "0.5809415", "0.5804072", "0.57617676", "0.5752207", "0.57248026", "0.57116", "0.562421", "0.5615175", "0.5615049", "0.56099176", "0.56061727", "0.55972105", "0.5587987...
0.692391
0
Test IO of .surf
def test_geometry(): surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "inflated")) coords, faces = read_geometry(surf_path) assert_equal(0, faces.min()) assert_equal(coords.shape[0], faces.max() + 1) # Test quad with sphere surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "sphere")) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_surf():\n def f(x, y):\n sin, cos = numpy.sin, numpy.cos\n return sin(x + y) + sin(2 * x - y) + cos(3 * x + 4 * y)\n\n x, y = numpy.mgrid[-7.:7.05:0.1, -5.:5.05:0.05]\n s = surf(x, y, f)\n mlab.show()\n #cs = contour_surf(x, y, f, contour_z=0)\n return", "def test_morph_d...
[ "0.6641745", "0.5991208", "0.5901561", "0.5861314", "0.5859329", "0.5802738", "0.56625646", "0.5633906", "0.56201524", "0.56140715", "0.56027144", "0.55701965", "0.55435073", "0.55309486", "0.55102223", "0.548895", "0.54658955", "0.5429626", "0.538379", "0.5362354", "0.530977...
0.6341031
1
Test IO of morphometry data file (eg. curvature).
def test_morph_data(): curv_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "curv")) curv = read_morph_data(curv_path) assert_true(-1.0 < curv.min() < 0) assert_true(0 < curv.max() < 1.0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_open_file(self):\n\t\tposition, potential = schrodinger.open_file('potential_energy.dat')\n\t\tself.assertEqual(position, [0.0, 1.57079, 3.14159, 4.71238, 6.28318, 7.85398, 9.42477])\n\t\tself.assertEqual(potential, [0.0, 6.0, 0.0, -6.0, 0.0, 6.0, 0.0])", "def test_read(self):\n for root, dirs, f...
[ "0.6433859", "0.62288296", "0.59984636", "0.59970236", "0.59490573", "0.5776016", "0.572016", "0.56419414", "0.563778", "0.56109965", "0.5610844", "0.56056154", "0.5592752", "0.55828625", "0.55790675", "0.5567408", "0.5532343", "0.5524342", "0.5518242", "0.55145156", "0.55132...
0.71642715
0
Test IO of .annot
def test_annot(): annots = ['aparc', 'aparc.a2005s'] for a in annots: annot_path = pjoin(data_path, "label", "%s.%s.annot" % ("lh", a)) labels, ctab, names = read_annot(annot_path) assert_true(labels.shape == (163842, )) assert_true(ctab.shape == (len(names), 5))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_format_of_annotation_in_file(self):\n if not self.is_span_valid():\n sys.exit()", "def test_st_annotation00101m1_positive(mode, save_output, output_format):\n assert_bindings(\n schema=\"sunData/SType/ST_annotation/ST_annotation00101m/ST_annotation00101m1.xsd\",\n ins...
[ "0.6033968", "0.59515923", "0.5841626", "0.58330965", "0.5818863", "0.5812621", "0.5801064", "0.5762653", "0.57568604", "0.5750474", "0.5732317", "0.5732033", "0.5713418", "0.570204", "0.56920904", "0.5657469", "0.56272537", "0.5614729", "0.5610254", "0.5597071", "0.5585642",...
0.7134083
0
Test IO of .label
def test_label(): label_path = pjoin(data_path, "label", "lh.BA1.label") label = read_label(label_path) # XXX : test more assert_true(np.all(label > 0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_label(self):\n xs = t.Label(t.Exactly(\"x\"), 'CustomLabel')\n self.assertEqual(writePython(xs),\n dd(\"\"\"\n def _G_label_1():\n _G_exactly_2, lastError = self.exactly('x')\n ...
[ "0.698072", "0.6907531", "0.68103695", "0.68100667", "0.6782609", "0.67555594", "0.67435974", "0.64980084", "0.64621615", "0.6399174", "0.6392844", "0.62826055", "0.62643975", "0.6254232", "0.62371147", "0.6222561", "0.6195714", "0.61815184", "0.617836", "0.6169217", "0.61692...
0.7863483
0
Returns signature for a given message, z
def sign(self, msg): z = int.from_bytes(helper.hash256(msg), "big") k = self.deterministic_k(z) k_inv = pow(k, N-2, N) r = (k*G).x.num s = (z + r * self.secret) * k_inv % N if s > N/2: s = N - s return Signature(r, s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_signature_for_message(message, filename='private.key'):\n message = dict(sorted(message.items()))\n message = json.dumps(message)\n\n private_key_path = os.path.join('keys', filename)\n with open(private_key_path, 'rb') as file:\n private_key = RSA.importKey(file.read...
[ "0.6678753", "0.6355302", "0.63198376", "0.63083655", "0.61424166", "0.60656065", "0.6020981", "0.59173757", "0.5842446", "0.5833741", "0.5825016", "0.5815025", "0.5803164", "0.57968223", "0.5784481", "0.5772108", "0.5763404", "0.57533115", "0.57256067", "0.57234585", "0.5681...
0.6566361
1
Check the permissions store for user and level
def check_permissions(user, actor_id, level): permissions = get_permissions(actor_id) for pem in permissions: if pem['user'] == user: if pem['level'] >= level: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasPerm(self,request):\n request.needAuthType(request.ADMIN)\n request.checkArgs(\"perm_name\",\"admin_username\")\n if request.auth_name!=request[\"admin_username\"]: \n request.getAuthNameObj().canDo(\"SEE ADMIN PERMISSIONS\")\n return admin_main.getLoader().getA...
[ "0.66214114", "0.65142685", "0.64695644", "0.64119565", "0.64119565", "0.6395322", "0.63662887", "0.63351125", "0.6318051", "0.631077", "0.63089794", "0.6278865", "0.62344545", "0.6213699", "0.62013096", "0.61916727", "0.6188883", "0.61668557", "0.6153456", "0.6152701", "0.61...
0.65215534
1
Add a permission for a user and level to an actor.
def add_permission(user, actor_id, level): try: permissions = get_permissions(actor_id) except PermissionsException: permissions = [] permissions.append({'user': user, 'level': level}) permissions_store[actor_id] = json.dumps(permissions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def permissions_add(\n self,\n ctx,\n type_: str.lower,\n name: str,\n *,\n user_or_role: Union[Role, utils.User, str],\n ):\n\n if type_ not in {\"command\", \"level\"}:\n return await ctx.send_help(ctx.command)\n\n command = level = None...
[ "0.7045652", "0.65704656", "0.64027405", "0.62560606", "0.62560606", "0.6157055", "0.6120105", "0.61065036", "0.6088077", "0.6032174", "0.59692377", "0.596524", "0.594055", "0.5916958", "0.5858972", "0.5845438", "0.56916314", "0.56907296", "0.5688241", "0.5676378", "0.5671096...
0.79164106
0
Add new permissions for an actor
def post(self, actor_id): try: Actor.from_db(actors_store[actor_id]) except KeyError: raise APIException( "actor not found: {}'".format(actor_id), 404) args = self.validate_post() add_permission(args['user'], actor_id, args['level']) permis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_permission(user, actor_id, level):\n try:\n permissions = get_permissions(actor_id)\n except PermissionsException:\n permissions = []\n permissions.append({'user': user,\n 'level': level})\n permissions_store[actor_id] = json.dumps(permissions)", "def _add...
[ "0.7235166", "0.69934314", "0.67583215", "0.6371254", "0.6335169", "0.62054914", "0.61273474", "0.6100005", "0.6073607", "0.60484934", "0.60419154", "0.6008811", "0.599937", "0.5988471", "0.5971591", "0.59599745", "0.59585696", "0.5911363", "0.5890705", "0.5861503", "0.586150...
0.70016277
1
Constitutive equation for NabarroHerring creep.
def nabarro_herring_creep( temperature: np.ndarray, n_shear_stress: np.ndarray) -> np.ndarray: numerator = ( A_NH * MU * V * D_L * n_shear_stress * np.exp(-H_L / (R * temperature)) ) denomenator = R * D ** 2 * temperature strain_rate = numerator/denomenator return strain_r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coble_creep(\n temperature: np.ndarray, n_shear_stress: np.ndarray) -> np.ndarray:\n numerator = (\n A_C * MU * V * D_G * W * n_shear_stress *\n np.exp(-H_G / (R * temperature))\n )\n denomenator = R * D ** 3 * temperature\n \n strain_rate = numerator/denomenator\n\n return ...
[ "0.66120404", "0.6235676", "0.62089044", "0.6159591", "0.60804176", "0.6045265", "0.602658", "0.6014804", "0.6000879", "0.59716594", "0.5961475", "0.59098405", "0.58900356", "0.5887956", "0.5883903", "0.58825594", "0.586504", "0.57670516", "0.57556", "0.5742544", "0.5737319",...
0.67318976
0
Constitutive equation for Coble creep.
def coble_creep( temperature: np.ndarray, n_shear_stress: np.ndarray) -> np.ndarray: numerator = ( A_C * MU * V * D_G * W * n_shear_stress * np.exp(-H_G / (R * temperature)) ) denomenator = R * D ** 3 * temperature strain_rate = numerator/denomenator return strain_rate
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calc_C(self, lambdify=True):\n\n C = None\n C_func = None\n # check to see if we have our term saved in file\n C, C_func = self._load_from_file('C', lambdify)\n\n if C is None and C_func is None:\n # if no saved file was loaded, generate function\n prin...
[ "0.64477867", "0.6385757", "0.63402474", "0.6321891", "0.6290459", "0.6224188", "0.6208865", "0.61290115", "0.6116374", "0.6108744", "0.61077815", "0.609768", "0.6049114", "0.60460794", "0.6044214", "0.5993522", "0.599171", "0.59859544", "0.5965093", "0.5962999", "0.5953919",...
0.6640319
0
Finds the maximum value between three np.ndarrays in a list.
def three_array_max(array_list: List[np.ndarray]) -> np.ndarray: temp = np.maximum(array_list[0], array_list[1]) all_maxs = np.maximum(temp, array_list[2]) return all_maxs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_max(list):\n return find_value_at(list, 0)", "def getMax(array_list):\n m = array_list[0]\n m_index = 0\n for i,value in enumerate(array_list):\n if value > m:\n m = value\n m_index = i\n return (m_index,m)", "def compare_max(values, weights):\n return np...
[ "0.7007491", "0.6992208", "0.6961825", "0.69369406", "0.6824932", "0.66760194", "0.65985566", "0.6580838", "0.6564666", "0.655405", "0.6506097", "0.6486567", "0.64407647", "0.64095294", "0.6400788", "0.63668877", "0.6343359", "0.63175714", "0.63098747", "0.63023937", "0.62990...
0.86902034
0
This function returns the list of prime number lesser than N.
def liste_N_nb_premier(N): liste = [] i = 0 while len(liste) < N: if is_prime(i): liste.append(i) i += 1 return liste
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_primes(n):\n primeList = []\n for i in range(n):\n if is_prime(i):\n primeList.append(i)\n return primeList", "def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]", "def generate_prime_less_than_n(n):\n\tif n <= 1:\n\t\treturn []\n\tlist_of_primes = [2]\n\tfor i in range...
[ "0.79166585", "0.78252643", "0.77794", "0.7731997", "0.7727879", "0.76638025", "0.7577047", "0.7568607", "0.7564964", "0.7522414", "0.7501913", "0.7497206", "0.74915093", "0.74915093", "0.74238646", "0.7420592", "0.7341136", "0.7333776", "0.73223823", "0.7292376", "0.7289568"...
0.7917129
0
This function checks whether or not a number is truncatable, ie every subnumber written by removing a front or back number is still a prime number.
def is_truncatable(nb): nb = str(nb) if is_prime(int(nb)): for i in range(1, len(nb)): if not is_prime(int(nb[i:])) or not is_prime(int(nb[:len(nb)-i])): return False return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_truncatable(number: int):\n\n str_number = str(number)\n index = 0\n\n # Left shift:\n while index < len(str_number):\n if not is_prime(int(str_number[index:])):\n return False\n\n index += 1\n\n # Right shift:\n index = len(str_number)\n while index > 0:\n ...
[ "0.792935", "0.6656063", "0.64213675", "0.63436365", "0.62462485", "0.6234058", "0.6154132", "0.61109185", "0.6067006", "0.6060549", "0.6056523", "0.60431683", "0.60208267", "0.6009649", "0.5997058", "0.59954643", "0.59928215", "0.597895", "0.5948257", "0.59479547", "0.594297...
0.80308694
0
This function looks for the 11 numbers greater than 7 which are truncatable.
def truncatable_primes(): list_tp = [] i = 8 while len(list_tp) < 11: if is_truncatable(i): list_tp.append(i) i += 1 if i % 100 == 0: print("i : ", i) return list_tp, sum(list_tp)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def problem_52():\n\n for number in xrange(1, 123456789):\n sorted_num = ''.join(sorted(str(number)))\n if len([value for value in xrange(2, 7)\n if ''.join(sorted(str((value * number)))) == sorted_num]) == 5:\n return number", "def has_seven(k):\n \n if k % 10 ==...
[ "0.57979983", "0.56591105", "0.5636077", "0.55226547", "0.55226547", "0.55226547", "0.5470952", "0.53913707", "0.5387149", "0.5335019", "0.52921695", "0.52763057", "0.52684706", "0.5260989", "0.5238879", "0.522795", "0.52069545", "0.5164485", "0.51632535", "0.5145592", "0.511...
0.5993087
0
The datetime of the last ping from the SrcSink
def last_ping(self) -> datetime: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_source_stamp(self):", "def get_source_stamp(self):", "def last_update_datetime(self):\n return datetime.strptime(self.last_update, \"%Y-%m-%d %H:%M:%S.%f\")", "def last_update_datetime(self):\n return datetime.strptime(self.last_update, \"%Y-%m-%d %H:%M:%S.%f\")", "def dest_time(self)...
[ "0.6409875", "0.6409875", "0.62572974", "0.62572974", "0.6114063", "0.60457677", "0.60435784", "0.5990316", "0.59827757", "0.59827757", "0.5948047", "0.59379625", "0.59183204", "0.5909179", "0.589342", "0.58412385", "0.5840549", "0.5835009", "0.58120304", "0.58074075", "0.578...
0.7502264
0
The SrcSink the Meta data relates to.
def srcsink(self) -> SrcSink: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Source(self):\r\n\t\treturn self._get_attribute('source')", "def get_sink(self, **kwargs: Dict) -> Sink:\n if kwargs[\"format\"] in SINK_MAP:\n s = SINK_MAP[kwargs[\"format\"]]\n return s(self, **kwargs)\n else:\n raise TypeError(f\"{kwargs['format']} in an unre...
[ "0.61999077", "0.6132542", "0.5978382", "0.5866137", "0.5770781", "0.57464147", "0.57042056", "0.5678696", "0.5667629", "0.5667629", "0.5667629", "0.5667629", "0.5667629", "0.5651825", "0.5609882", "0.5577742", "0.55600435", "0.55342245", "0.5527913", "0.5527913", "0.5527913"...
0.7397219
0
Normalize Base String URI per `Section 3.4.1.2`_.
def normalize_base_string_uri(uri, host=None): uri = to_unicode(uri) scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri) # The scheme, authority, and path of the request resource URI `RFC3986` # are included by constructing an "http" or "https" URI representing # the request reso...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _urlnorm(self, uri):\r\n (scheme, authority, path, query, fragment) = parse_uri(uri)\r\n if not scheme or not authority:\r\n raise Exception(\"Only absolute URIs are allowed. uri = %s\" % uri)\r\n authority = authority.lower()\r\n scheme = scheme.lower()\r\n if not...
[ "0.7852068", "0.7516662", "0.74561626", "0.7409289", "0.71349496", "0.7097236", "0.6995842", "0.68973535", "0.6676458", "0.65969145", "0.6584086", "0.65773904", "0.6558476", "0.65522295", "0.6540962", "0.64854604", "0.64476895", "0.6379877", "0.6377486", "0.6352593", "0.63271...
0.7584172
1
Generate signature base string from request.
def generate_signature_base_string(request): host = request.headers.get('Host', None) return construct_base_string( request.method, request.uri, request.params, host)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _GenerateSignatureBaseString(self, method, request_url_base, params):\n return self._EscapeAndJoin([method, request_url_base,\n self._FormatUrlParams(params)])", "def signature(request) -> str:\n return get_test_data(request, __name__, \"signature\", \"r\")", "def _build...
[ "0.81524706", "0.7412255", "0.7397509", "0.71844584", "0.71188706", "0.7089657", "0.6939644", "0.6879352", "0.68650514", "0.68331236", "0.68296903", "0.67501324", "0.67149013", "0.6704014", "0.6614577", "0.65598744", "0.65263504", "0.6508957", "0.6507487", "0.6457547", "0.645...
0.8285932
0
Generate signature via PLAINTEXT method, per `Section 3.4.4`_. The "PLAINTEXT" method does not employ a signature algorithm. It MUST be used with a transportlayer mechanism such as TLS or SSL (or sent over a secure channel with equivalent protections). It does not utilize the signature base string or the "oauth_timesta...
def plaintext_signature(client_secret, token_secret): # The "oauth_signature" protocol parameter is set to the concatenated # value of: # 1. The client shared-secret, after being encoded (`Section 3.6`_). # # .. _`Section 3.6`: https://tools.ietf.org/html/rfc5849#section-3.6 signature = escap...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GenSampleSignature(text):\r\n demo_keypair = ('RSA.mVgY8RN6URBTstndvmUUPb4UZTdwvwmddSKE5z_jvKUEK6yk1'\r\n 'u3rrC9yN8k6FilGj9K0eeUPe2hf4Pj-5CmHww=='\r\n '.AQAB'\r\n '.Lgy_yL3hsLBngkFdDw1Jy9TmSRMiH6yihYetQ8jy-jZXdsZXd8V5'\r\n 'ub3kuBHHk4M39i3Td...
[ "0.6079742", "0.5759598", "0.5742009", "0.5716066", "0.5678872", "0.5528024", "0.5516478", "0.5481387", "0.5392312", "0.5375917", "0.53083646", "0.528393", "0.5281056", "0.52782965", "0.5267875", "0.5240674", "0.52330804", "0.520887", "0.52030885", "0.5187856", "0.51490825", ...
0.5771276
1
Sign a HMACSHA1 signature.
def sign_hmac_sha1(client, request): base_string = generate_signature_base_string(request) return hmac_sha1_signature( base_string, client.client_secret, client.token_secret)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_rsa_sha1(client, request):\n base_string = generate_signature_base_string(request)\n return rsa_sha1_signature(base_string, client.rsa_key)", "def hashAndSign(self, bytes):\r\n hashBytes = SHA1(bytearray(bytes))\r\n prefixedHashBytes = self._addPKCS1SHA1Prefix(hashBytes)\r\n s...
[ "0.7322658", "0.69608504", "0.6795846", "0.6739002", "0.66943777", "0.66635305", "0.6322254", "0.6264413", "0.62420106", "0.6241299", "0.6170932", "0.6157063", "0.60972005", "0.6070152", "0.6054219", "0.6030812", "0.602599", "0.59852517", "0.5922484", "0.5917426", "0.59022945...
0.8078111
0
Sign a RSASSAPKCS 1 v1.5 base64 encoded signature.
def sign_rsa_sha1(client, request): base_string = generate_signature_base_string(request) return rsa_sha1_signature(base_string, client.rsa_key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rsa_sha1_signature(base_string, rsa_private_key):\n from .rsa import sign_sha1\n base_string = to_bytes(base_string)\n s = sign_sha1(to_bytes(base_string), rsa_private_key)\n sig = binascii.b2a_base64(s)[:-1]\n return to_unicode(sig)", "def base64sign(plaintext, private_key):\n shahash = SH...
[ "0.7349005", "0.68615925", "0.68418187", "0.6789189", "0.6698838", "0.6683597", "0.66149825", "0.6538047", "0.6537051", "0.6440535", "0.64177877", "0.63638127", "0.6333892", "0.6318501", "0.6309397", "0.6236319", "0.6219438", "0.62098646", "0.6176856", "0.6170527", "0.6128557...
0.7381339
0