query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Get a random software license.
def software_license(self) -> str: return self.random.choice(LICENSES)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_license(self) -> APIReturn:\n return await self._request(\"GET\", \"/getLicense\")", "def get_license():\n repo_fs()\n return LICENSE", "def license(self): # noqa: A003\n logger.debug(\"Get license\")\n return self._raw_api.license.get()", "def license_plate(self) ->...
[ "0.7257501", "0.71489984", "0.70458555", "0.6904726", "0.6888948", "0.68682706", "0.6559753", "0.63974625", "0.6345092", "0.63441616", "0.63224334", "0.62866235", "0.6221269", "0.6201027", "0.6021887", "0.597207", "0.5964664", "0.593197", "0.59197384", "0.5912311", "0.5888606...
0.8545533
0
Get a random programming language from the list.
def programming_language(self) -> str: return self.random.choice(PROGRAMMING_LANGS)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def language():\r\n\r\n cursor.execute('SELECT name from languages order by RANDOM() limit 1;')\r\n return cursor.fetchone()[0]", "def choose_language(self):\n\n current_dir = os.curdir\n path = os.path.join(current_dir, \"audio\")\n languages = os.listdir(path)\n language_num =...
[ "0.7798375", "0.75217885", "0.6663096", "0.657567", "0.6547032", "0.6538302", "0.6538302", "0.6538302", "0.6450568", "0.6426865", "0.62987846", "0.6250212", "0.624393", "0.62252414", "0.6214424", "0.62047374", "0.61436826", "0.61385137", "0.6122823", "0.6067962", "0.6052699",...
0.7644547
1
Get a random operating system or distributive name.
def os(self) -> str: return self.random.choice(OS)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_rand_name() -> str:\n suf = \"\".join(random.choices(string.ascii_uppercase + string.digits, k=6))\n return f\"exporters_{suf}\"", "def GetOSName():\n return Config.osName_", "def platform_distro():\n distro = platform_information()[0] or ''\n return distro.strip().lower()", "def...
[ "0.71472675", "0.7110732", "0.7060906", "0.6976703", "0.69478893", "0.6882059", "0.6790889", "0.6751498", "0.66147846", "0.659943", "0.6580307", "0.657741", "0.6558327", "0.653063", "0.65062135", "0.6499304", "0.6496545", "0.6487284", "0.6480682", "0.6479354", "0.64615834", ...
0.7919382
0
Get a random boolean value.
def boolean(self) -> bool: return self.random.choice([True, False])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_random_bool() -> bool:\n\n return random.choice([True, False])", "def random_bool():\n return bool(randint(0, 1))", "def rand_bool() -> bool:\n # use random() < 0.5 instead of choice([True, False]) since choice\n # is substantially slower\n return rand_uni_val() < 0.5", "def _rand_bool...
[ "0.90538865", "0.8984839", "0.83036524", "0.80328023", "0.78080684", "0.7787965", "0.7787965", "0.7749643", "0.7569312", "0.7337185", "0.6960545", "0.6957034", "0.6845757", "0.67257595", "0.6721427", "0.6721427", "0.6425786", "0.63970894", "0.63023657", "0.6301153", "0.629088...
0.8287165
3
Get a random system quality attribute. Within systems engineering, quality attributes are realized nonfunctional requirements used to evaluate the performance of a system. These are sometimes named "ilities" after the suffix many of the words share.
def system_quality_attribute(self) -> str: return self.random.choice(SYSTEM_QUALITY_ATTRIBUTES)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ility(self) -> str:\n return self.system_quality_attribute()", "def quality(self):\n try:\n qid = int((self.tool_metadata or {}).get(\"quality\", 0))\n except:\n qid = 0\n\n # We might be able to get the quality strings from the item's tags\n internal_...
[ "0.6713973", "0.64897156", "0.61726063", "0.6065477", "0.5870625", "0.55420256", "0.55384314", "0.5526172", "0.541174", "0.53634155", "0.53470075", "0.53367925", "0.53191906", "0.52884704", "0.52797884", "0.52781254", "0.52720535", "0.52499086", "0.5233074", "0.5218162", "0.5...
0.8372629
0
Get a random system quality attribute. An alias for system_quality_attribute().
def ility(self) -> str: return self.system_quality_attribute()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system_quality_attribute(self) -> str:\n return self.random.choice(SYSTEM_QUALITY_ATTRIBUTES)", "def quality(self):\n try:\n qid = int((self.tool_metadata or {}).get(\"quality\", 0))\n except:\n qid = 0\n\n # We might be able to get the quality strings from t...
[ "0.87941146", "0.61170155", "0.6050746", "0.5851535", "0.5762336", "0.5579478", "0.55139697", "0.5418243", "0.5411513", "0.535925", "0.53295076", "0.52709144", "0.52343696", "0.520349", "0.51900476", "0.5188331", "0.5184759", "0.5182861", "0.5176378", "0.51667213", "0.5160519...
0.6239924
1
Ensure we don't have NaN.
def nonull(val): return val if not pd.isnull(val) else None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ISNA(value):\n return isinstance(value, float) and math.isnan(value)", "def pd_isnan(val):\n return val is None or val != val", "def _is_nan(self, x: any) -> bool:\n return isinstance(x, float) and math.isnan(x)", "def is_scalar_nan(x):\n return isinstance(x, numbers.Real) and math.isnan(x)...
[ "0.74678445", "0.7439126", "0.7396373", "0.73362786", "0.72977227", "0.72257054", "0.72256404", "0.7209149", "0.7195599", "0.70729196", "0.7055828", "0.7042421", "0.703449", "0.70032156", "0.6979396", "0.6954666", "0.6935699", "0.6926086", "0.69070715", "0.6897858", "0.688702...
0.64056647
49
Traintest validation info and the validity of dataset
def load_dataset_param(splits_path, skeletal_data_path): f = h5py.File(splits_path, 'r') tr_subjects = f['tr_subjects'][:].T te_subjects = f['te_subjects'][:].T f = h5py.File(skeletal_data_path, 'r') validity = f['skeletal_data_validity'][:] return tr_subjects, te_subjects, validity
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_data(self):\n\n return self.__valid_data, self.__valid_labels", "def test_valid_dataset():\n train = ((\"Lorem ipsum dolor sit amet\", 3, 4.5),\n (\"Sed ut perspiciatis unde\", 5, 5.5))\n val = ((\"ipsum quia dolor sit\", 10, 3.5),)\n test = ((\"Ut enim ad minima veniam\", 10...
[ "0.718173", "0.71711063", "0.69936323", "0.6841453", "0.677554", "0.6762862", "0.67480487", "0.6578853", "0.6523762", "0.65092194", "0.6489128", "0.64737314", "0.6444687", "0.6402101", "0.63978356", "0.6348448", "0.6341878", "0.63343483", "0.63258463", "0.62966496", "0.629389...
0.0
-1
Fit scaler and return self Winsorise `X` at `quantile` and `1quantile`. Scale each variable (as long as they aren't binary in which case they are already rules).
def fit(self, X, y=None): self.fit_transform(X, y) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_transform(self, X, y=None):\n self.scale = np.ones(X.shape[1])\n self.lower = np.percentile(X, self.quantile*100, axis=0)\n self.upper = np.percentile(X, (1-self.quantile)*100, axis=0)\n \n # Winsorize at `self.quantile`\n winX = X.copy()\n is_lower = (winX ...
[ "0.7750412", "0.69842714", "0.67774415", "0.6224853", "0.59984505", "0.5898211", "0.584077", "0.5825821", "0.5710472", "0.56034803", "0.5498527", "0.54985", "0.5478132", "0.5443603", "0.5424732", "0.5424317", "0.54221374", "0.5416531", "0.54004645", "0.5383857", "0.5380486", ...
0.0
-1
Fit scaler and transform input data Winsorise `X` at `quantile` and `1quantile`. Scale each variable (as long as they aren't binary in which case they are already rules).
def fit_transform(self, X, y=None): self.scale = np.ones(X.shape[1]) self.lower = np.percentile(X, self.quantile*100, axis=0) self.upper = np.percentile(X, (1-self.quantile)*100, axis=0) # Winsorize at `self.quantile` winX = X.copy() is_lower = (winX < self.lower...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit(self, X):\n q_min, q_max = self.quantile_range\n self.center_ = np.nanmedian(X, axis=0) if self.with_centering else None\n \n if self.with_scaling:\n quantiles = []\n for feature_idx in range(X.shape[1]):\n column_data = X[:, feature_idx]\n ...
[ "0.6935344", "0.6514156", "0.6485185", "0.6348961", "0.62394345", "0.606469", "0.5963839", "0.591956", "0.5840398", "0.58116454", "0.58023864", "0.5767737", "0.5724162", "0.5704402", "0.5686381", "0.5667723", "0.56520194", "0.5641679", "0.5634941", "0.5634244", "0.562591", ...
0.7883213
0
Transform input data Winsorise `X` at prefitted `quantile` and `1quantile`. Scale each variable (as long as they aren't binary in which case they are already rules) accorded to the already fitted scale factors.
def transform(self, X): winX = X.copy() is_lower = (winX <= self.lower) is_higher = (winX >= self.upper) for col in range(X.shape[1]): winX[is_lower[:, col], col] = self.lower[col] winX[is_higher[:, col], col] = self.upper[col] return winX*self.scale
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_transform(self, X, y=None):\n self.scale = np.ones(X.shape[1])\n self.lower = np.percentile(X, self.quantile*100, axis=0)\n self.upper = np.percentile(X, (1-self.quantile)*100, axis=0)\n \n # Winsorize at `self.quantile`\n winX = X.copy()\n is_lower = (winX ...
[ "0.75867057", "0.67999154", "0.66214746", "0.5967192", "0.5888989", "0.5855381", "0.5718839", "0.57124597", "0.5695854", "0.56935406", "0.5588703", "0.5585414", "0.5556105", "0.5542959", "0.5531994", "0.55186", "0.55175906", "0.54948944", "0.54849446", "0.54643995", "0.545754...
0.0
-1
Fit model to data
def fit(self, X, y, sample_weight=None): self.fit_transform(X, y, sample_weight=sample_weight) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit(self, X):", "def fit_training_data(self):\n self.model.fit(self.X_train)", "def fit(self, X, y):", "def fit(self, X, y):", "def fit(self, X, y):", "def fit_from_model_data(self, model_data: np.ndarray) -> f.FitDataset:\r\n return f.FitDataset(dataset=self.dataset, model_data=model_d...
[ "0.80873185", "0.80705625", "0.7782671", "0.7782671", "0.7782671", "0.7780884", "0.77498704", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7740986", "0.7647624", "0.7614556", "0.7578705", "0.75735605",...
0.0
-1
Transform data into modified features (before being passed to penalised regression step). If `linear_features=True` then this will be scaled linear features followed by the onehotencoding signifying which rules are "on". Otherwise this is just the onehotencoding signifying which rules are "on".
def transform(self, X, y=None): if isinstance(X, DataFrame): is_df = True # Serves no purpose X = check_array(X) # Validate input data X = self.ext_scaler.transform(X) # Scale and centre features if self.linear_features: X_scale = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_linear_transform(self):\n \n with tf.variable_scope(\"linear_transform\"):\n \n # feature scales/weights\n self.w = tf.get_variable(\"weights\", shape=[self.dim_input], \n initializer= tf.contrib.layers.xavier_initializer())\n ...
[ "0.64672863", "0.6376041", "0.620645", "0.6029789", "0.59679097", "0.59625727", "0.5958583", "0.5933087", "0.59234154", "0.5873284", "0.57592976", "0.57417256", "0.5729975", "0.57214034", "0.571568", "0.57002", "0.56780124", "0.56722736", "0.5665581", "0.5648128", "0.56347185...
0.65656894
0
Fit and Transform data into modified features (before being passed to penalised regression step). If `linear_features=True` then this will be scaled linear features followed by the onehotencoding signifying which rules are "on". Otherwise this is just the onehotencoding signifying which rules are "on". Fitting process ...
def fit_transform(self, X, y, sample_weight=None): # Instantiate rule ensemble generator and set parameters if isinstance(self.base_estimator, XGBClassifier): self.base_estimator.set_params(n_estimators=self.n_estimators, silent=(self.verbose>0), max...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_transform(self, X, y=...):\n ...", "def add_linear_transform(self):\n \n with tf.variable_scope(\"linear_transform\"):\n \n # feature scales/weights\n self.w = tf.get_variable(\"weights\", shape=[self.dim_input], \n initiali...
[ "0.6590726", "0.643329", "0.6249411", "0.615591", "0.61489266", "0.6111732", "0.60932124", "0.60849077", "0.607622", "0.60694087", "0.6060681", "0.60569435", "0.6055038", "0.6030073", "0.602565", "0.60254604", "0.6016208", "0.60057116", "0.59939456", "0.5983849", "0.5976737",...
0.5769847
68
Get names of features in the model Returns numpy.ndarray
def get_feature_names(self): if self.linear_features: self.features_ = np.concatenate([self.features, np.array(self.extract_rules(labels=self.features))], 0)[self.feature_mask_] else: self.features_ = np.array(self.extract_rules(labels=self.features))[self.feature_mask_] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_feature_names(self):\n\t\treturn np.array(['nouns', 'adjectives', 'verbs', 'adverbs'])", "def get_feature_names(self):\n ...", "def get_feature_names(self, input_features=...):\n ...", "def featureNames(self):\n return [feature.name for feature in self.features]", "def get_feat...
[ "0.80556595", "0.7707658", "0.7469094", "0.7322007", "0.7156526", "0.71266407", "0.71156085", "0.69819415", "0.6880327", "0.6811052", "0.6799486", "0.6770631", "0.67257535", "0.67219526", "0.67001486", "0.6681642", "0.6681472", "0.66336685", "0.6609487", "0.6586122", "0.65850...
0.75093997
2
Output model prediction probability
def predict_proba(self, X): return self.LR.predict_proba(self.transform(X))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prediction_prob(self):\n return self.a[np.arange(self.a.shape[0]), self.prediction]", "def probability_of_default(model, prediction_features):\n return model.predict_proba(prediction_features)[:, 1]", "def predict_prob(self, _input_data):\n yhat_probs = (self.merged_model).predict(_input_d...
[ "0.7202168", "0.7175441", "0.7088755", "0.7079597", "0.7038377", "0.7032993", "0.70295215", "0.69809556", "0.6980515", "0.69351923", "0.69144815", "0.68655604", "0.6802924", "0.6756837", "0.67535657", "0.6752373", "0.67346364", "0.6727757", "0.67167795", "0.6715653", "0.66885...
0.0
-1
Extract rule set from single decision tree according to `XGBClassifier` format
def __extract_xgb_dt_rules__(self, dt): md = self.max_depth + 1 # upper limit of max_depth? rules = [] levels = np.zeros((md, 3)) # Stores: (feature name, threshold, next node id) path = [] # Extract feature numbers and thresholds for all nodes feat_thresh_l = re.find...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_xgboost_dump(model):\n trees= []\n for tree_string in model._Booster.get_dump():\n nodes = [feature_regex.search('t' + node).groupdict() if '[' in node else leaf_regex.search('t' +node).groupdict() for node in tree_string.split('\\n')[:-1]]\n trees.append(nodes)\n return trees", ...
[ "0.5865318", "0.5536741", "0.54987574", "0.5455966", "0.54210675", "0.5409109", "0.5405483", "0.53791", "0.53362054", "0.53147733", "0.53034365", "0.52629757", "0.51678437", "0.51664716", "0.51662976", "0.5051097", "0.50148183", "0.49448028", "0.49409705", "0.49294248", "0.49...
0.63547754
0
Extract rule set from single decision tree according to sklearn binarytree format
def __extract_dt_rules__(self, dt): t = dt.tree_ # Get tree object rules = [] stack = [(0, -1, -1)] # (node id, parent depth, true[<=thresh]/false[>thresh] arm) path = [(0, -1, -1)] # Begin path at root while len(stack) > 0: # While nodes to visit is not empty n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __extract_xgb_dt_rules__(self, dt): \n md = self.max_depth + 1 # upper limit of max_depth?\n rules = []\n levels = np.zeros((md, 3)) # Stores: (feature name, threshold, next node id)\n path = []\n\n # Extract feature numbers and thresholds for all nodes\n feat_thresh...
[ "0.63081384", "0.5973033", "0.5891241", "0.5791572", "0.57859606", "0.5680792", "0.5676548", "0.56683165", "0.5648141", "0.5642845", "0.56323576", "0.562277", "0.5616259", "0.5608892", "0.5596876", "0.55703026", "0.55625194", "0.5539325", "0.54848295", "0.5470803", "0.5442930...
0.63386476
0
Convert rule represented by an array to readable format
def __convert_rule__(self, x, labels=None, scaler=None): strop = ['>', '<='] if scaler is None: # If no scaler, do not shift or scale nf = x[:, 0].astype(int).max()+1 scale = np.ones(nf) center = np.zeros(nf) else: scale = scaler.scale...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _serialize_rules(rules):\n result = [(rule_name, str(rule)) for rule_name, rule in rules.items()]\n return sorted(result, key=lambda rule: rule[0])", "def _serialize_rules(rules):\n result = [(rule_name, str(rule))\n for rule_name, rule in rules.items()]\n return sorted(result, key=l...
[ "0.6082314", "0.6008946", "0.59785944", "0.5761554", "0.57400596", "0.56420326", "0.5561496", "0.54893786", "0.54313695", "0.53977495", "0.5357339", "0.5324876", "0.5305204", "0.52618265", "0.5245784", "0.52239984", "0.5177636", "0.5156451", "0.5146912", "0.5122297", "0.51021...
0.5250311
14
Extract rules from `base_estimator`
def extract_rules(self, labels=None): # Extract flat list of rules in array form if isinstance(self.base_estimator, RandomForestClassifier): rules = list(it.chain(*[self.__extract_dt_rules__(dt) for dt in self.base_estimator.estimators_])) elif isinstance(self.base_estimator, Gradien...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _TP_estimator_requirements(estimator):\n if estimator == 'Natural':\n do_DD = True\n do_DR = False\n do_RR = True\n elif estimator == 'Davis-Peebles':\n do_DD = True\n do_DR = True\n do_RR = False\n elif estimator == 'Hewett':\n do_DD = True\n do...
[ "0.5808173", "0.5672008", "0.56038344", "0.55043817", "0.54182005", "0.5397512", "0.5376288", "0.53144646", "0.5294726", "0.52705055", "0.5173132", "0.5156924", "0.5128409", "0.5119125", "0.5093487", "0.5083402", "0.50692993", "0.50663245", "0.50592685", "0.5044347", "0.50386...
0.6383667
0
Returns offset of symbol name in loader string table. offset of symbol name in loader string table
def getNameOffset(self) -> int: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dlsym_offset():\n import ctypes\n libdl = ctypes.PyDLL('libdl.so')\n dlopen = ctypes.cast(libdl.dlopen, ctypes.c_void_p).value\n dlsym = ctypes.cast(libdl.dlsym, ctypes.c_void_p).value\n return dlsym - dlopen", "def get_symbol(self, name):\n if not self.ksymtab_initialized:\n self....
[ "0.66889083", "0.6611202", "0.6203252", "0.59230924", "0.5809549", "0.57707137", "0.5730276", "0.5715004", "0.5666472", "0.56297314", "0.56227905", "0.5597471", "0.5563141", "0.55597746", "0.5537753", "0.54879636", "0.5457473", "0.5412081", "0.53920466", "0.53888345", "0.5384...
0.6135863
3
Returns the index of the section, or pseudosection, for the symbol. the index of the section, or pseudosection, for the symbol
def getSectionIndex(self) -> int: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_index_for_symbol(self, symbol):\n for idx, state in enumerate(self):\n if state.symbol == symbol:\n return idx\n if value in self.symbol_synonyms:\n return self.index(self.symbol_synonyms[value])\n raise Exception(\"State with symbol of '%s' not d...
[ "0.6868311", "0.6411154", "0.6275179", "0.6243905", "0.59100974", "0.5822145", "0.5802371", "0.57700807", "0.5695456", "0.56313735", "0.55781096", "0.557163", "0.5570825", "0.55552155", "0.55312073", "0.5525112", "0.5520313", "0.5517731", "0.5509883", "0.55041385", "0.5454695...
0.6920975
0
Typically the symbol's offset within a section. the symbol's offset within a section
def getSymbolValue(self) -> int: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def address(self, symbol):\r\n return self.s_table[symbol]", "def find_offset(self,value):\n return self.header.find_offset(value)", "def offset(self):\r\n return self.buf[0].unib[9:11]", "def Offset(self) -> int:", "def Offset(self) -> int:", "def Offset(self) -> int:", "def word_offs...
[ "0.6427832", "0.62289804", "0.6227516", "0.61876094", "0.61876094", "0.61876094", "0.60639006", "0.5875493", "0.5856736", "0.58552986", "0.5801007", "0.578234", "0.5776204", "0.5775643", "0.57363254", "0.57303596", "0.5714447", "0.57119274", "0.5706985", "0.5676521", "0.56670...
0.55654424
29
Efficient line counter courtesy of Ryan Ginstrom answer in stack overflow
def map_count(filename): f = open(filename, "r+") buf = mmap.mmap(f.fileno(), 0) lines = 0 readline = buf.readline while readline(): lines += 1 return lines
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linecounter(x):\n return linecount(x) + longlines(x)", "def line_counter(self, event=None):\n try:\n text_area = self.get_current()\n self.canvas.delete('all')\n i = text_area.index(\"@0,0\")\n while True:\n dline = text_area.dlineinfo(...
[ "0.82242316", "0.7129824", "0.6832569", "0.6802114", "0.67156047", "0.6707557", "0.66925406", "0.6651793", "0.6629119", "0.6614643", "0.6609141", "0.65214765", "0.65072346", "0.6484806", "0.6471491", "0.6464803", "0.644661", "0.64097726", "0.6376117", "0.6325442", "0.63130695...
0.6225128
29
Read logfile with the profiles written
def read_log(prefix): l = [] with open('%s.log' % prefix) as F: for line in F: if 'profile written' not in line: continue else: l.append(line.split()[0]) return l
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_linelog():", "def log(length, file):\n\n if user_init.check_pre_init() and user_utility.check_drive_init() == 'True':\n \n data = user_utility.read_log(length, file)\n\n for log in data:\n print(log)\n\n\n else:\n user_utility.print_error(\"Sink folder not Fo...
[ "0.64771223", "0.6366919", "0.6224004", "0.6189014", "0.6156716", "0.589416", "0.56880486", "0.5653552", "0.5653552", "0.5563616", "0.55355364", "0.55350137", "0.55187297", "0.5504658", "0.5428539", "0.54203796", "0.54149693", "0.5402457", "0.53929543", "0.53881913", "0.53774...
0.66682994
0
Execute line with subprocess
def executeLine(line): pl = Popen(line, shell=True, stderr=PIPE, stdout=PIPE) o, e = pl.communicate() return o, e
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subproc(self,line):\n self.set_stdout()\n proc = subprocess.Popen(line.split(),stdout=self.stdout)\n proc.wait() #ensures that the subprocess executes and terminates before returning to the shell", "def do_shell(self, line):\n os.system(line)", "def do_shell(self, line):\n ...
[ "0.748457", "0.7471307", "0.7392303", "0.71741265", "0.7088497", "0.69453466", "0.68881345", "0.6846201", "0.6814815", "0.67655087", "0.6763409", "0.6605997", "0.65672106", "0.6551925", "0.6531274", "0.65091294", "0.64287466", "0.6407803", "0.6388115", "0.63674563", "0.634924...
0.78371656
0
Read a bim/fam files from the plink fileset
def read_BimFam(prefix): Bnames = ['CHR', 'SNP', 'cM', 'BP', 'A1', 'A2'] bim = pd.read_table('%s.bim' % (prefix), delim_whitespace=True, header=None, names=Bnames) Fnames = ['FID', 'IID', 'father', 'mother', 'Sex', 'Phenotype'] fam = pd.read_table('%s.fam' % (prefix), delim_white...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_plink(file_prefix, verbose=True):\n\n fn = {s: \"%s.%s\" % (file_prefix, s) for s in ['bed', 'bim', 'fam']}\n\n with TimeIt(\"Reading %s...\" % fn['bim'], not verbose):\n bim = _read_bim(fn['bim'])\n nmarkers = bim.shape[0]\n\n with TimeIt(\"Reading %s...\" % fn['fam'], not verbose):\n ...
[ "0.64510775", "0.5825708", "0.5510868", "0.55018467", "0.5465175", "0.5433269", "0.54157674", "0.53745013", "0.52349013", "0.5129814", "0.5121936", "0.51169163", "0.50746495", "0.5056231", "0.5055647", "0.50515175", "0.5049878", "0.5017783", "0.5001219", "0.4999236", "0.49899...
0.6117494
1
Generate and read frequency files and filter based on threshold
def read_freq(bfile, plinkexe, freq_threshold=0.1, maxmem=1700, threads=1): high = 1 - freq_threshold low = freq_threshold if not os.path.isfile('%s.frq.gz' % bfile): nname = os.path.split(bfile)[-1] frq = ('%s --bfile %s --freq gz --keep-allele-order --out %s --memory ' '%d -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_frequencies(self, args):\n\n for file in args.frequencies:\n self._check_valid_file(file[0])", "def automatic_checking(files):\n for i in range(10):\n fft_checking(files[i])", "def update_freq_dist(filename):\r\n pass", "def test_filtered_scan(self):\n self.run...
[ "0.6244121", "0.615341", "0.60893506", "0.6055009", "0.5997631", "0.58850914", "0.58467615", "0.5836657", "0.5833301", "0.5826538", "0.5804678", "0.5772488", "0.5745384", "0.5713081", "0.5678326", "0.56347597", "0.5622866", "0.5610701", "0.56093115", "0.55927515", "0.5584923"...
0.6175935
1
Generate a list of individuals for training and a list for validation. The list is to be passed to plink. It will take one split as validation and the rest as training.
def train_test_gen_only(prefix, bfile, plinkexe, splits=10, maxmem=1700, threads=1): fam = pd.read_table('%s.fam' % bfile, delim_whitespace=True, header=None, names=['FID', 'IID', 'a', 'b', 'c', 'd']) fold = int(np.ceil(fam.shape[0] / splits)) msk = fam.IID.is...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def separate_train_valid(positives, validation_split):\n val_set = []\n shuffled_positives = shuffle_annotations(positives)\n upper = int(round(len(shuffled_positives)*validation_split))\n subset = shuffled_positives[0:upper]\n for each in subset:\n val_set.append(each)\n shuffled_pos...
[ "0.694381", "0.6477071", "0.63907367", "0.6256524", "0.6256524", "0.6180422", "0.61586004", "0.61576384", "0.6142876", "0.61150426", "0.6102051", "0.60976", "0.6076763", "0.6031108", "0.6026102", "0.5993668", "0.59823596", "0.596547", "0.59640354", "0.5938702", "0.59328055", ...
0.0
-1
Generate a list of individuals for training and a list for validation. The list is to be passed to plink. It will take one split as validation and the rest as training.
def train_test(prefix, bfile, plinkexe, pheno, splits=10, maxmem=1700, threads=1): pheno = read_pheno(pheno) # trainthresh = (splits - 1) / splits fn = os.path.split(bfile)[-1] keeps = { '%s_train' % prefix: (os.path.join(os.getcwd(), '%s_train.keep' % fn), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def separate_train_valid(positives, validation_split):\n val_set = []\n shuffled_positives = shuffle_annotations(positives)\n upper = int(round(len(shuffled_positives)*validation_split))\n subset = shuffled_positives[0:upper]\n for each in subset:\n val_set.append(each)\n shuffled_pos...
[ "0.69447994", "0.64780825", "0.63923746", "0.62567776", "0.62567776", "0.618161", "0.6159413", "0.61588293", "0.6143759", "0.6115408", "0.61027634", "0.60997844", "0.6078819", "0.6032173", "0.60267323", "0.59953797", "0.5984372", "0.5966264", "0.5965173", "0.5940122", "0.5934...
0.0
-1
Read a phenotype file with plink profile format
def read_pheno(pheno): if 'FID' in open(pheno).readline(): ## asumes that has 3 columns with the first two with headers FID adn ## IID pheno = pd.read_table(pheno, delim_whitespace=True) pheno.rename(columns={pheno.columns[-1]: 'Pheno'}, inplace=True) else: Pnames = ['FID...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_profile (filename, index):\n \n col_names = ['m', 'r', 'F', 'P', 'rho', 'T', 'u', 's', \n 'c_P', 'gamma_ad', 'nabla_ad', 'mu', 'n_e', \n 'P_e', 'P_rad', 'nabla_rad', 'nabla', 'v_c',\n 'kappa', 'q_nuc', 'q_PP', \n 'q_CNO', 'q_3a', 'q_nun...
[ "0.5962115", "0.5881954", "0.58440053", "0.5538421", "0.5515155", "0.5454003", "0.5426866", "0.5300091", "0.5294381", "0.5292129", "0.52890533", "0.52845263", "0.52685696", "0.5247038", "0.5205397", "0.5202352", "0.51866144", "0.514892", "0.5131193", "0.5130793", "0.5128464",...
0.521891
14
Parse and sort clumped file
def parse_sort_clump(fn, allsnps): # make sure allsnps is a series allsnps = pd.Series(allsnps) try: df = pd.read_table(fn, delim_whitespace=True) except FileNotFoundError: spl = fn.split('.') if spl[0] == '': idx = 1 else: idx = 0 fn = '.'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _out_order(self, fname):\r\n # t = 1\r\n orderDict = {}\r\n order = []\r\n readWells = False\r\n lastBlock = False\r\n addOrder = False\r\n with open(fname, \"r\") as fp:\r\n for line in fp:\r\n item ...
[ "0.6187829", "0.6099515", "0.6068014", "0.6001136", "0.59910196", "0.5986808", "0.58804303", "0.5873911", "0.57860065", "0.5770826", "0.5711253", "0.57094413", "0.5662024", "0.5638028", "0.5623567", "0.5581438", "0.553245", "0.5521676", "0.55184275", "0.5508633", "0.55056983"...
0.62394416
0
helper function to parallelize smartcotagsort
def helper_smartsort(grouped, key): df = grouped.get_group(key) head = df.loc[df.index[0], :] tail = df.loc[df.index[1:], :] return head, tail
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_sort(arr):\n pass", "def test_three_split():\n run_mergesort([3, 0, 3], [0, 3, 3])", "def keysort(*args, **kwargs): # real signature unknown\n pass", "def mergesort_vs_quicksort():\n runtime_merge = []\n runtime_quick = []\n runtime_system = []\n\n for size in array_sizes:\n\n...
[ "0.675029", "0.6308638", "0.6267418", "0.62532204", "0.6149817", "0.6148415", "0.61287344", "0.6116317", "0.6070241", "0.6069463", "0.60656625", "0.6064378", "0.6029623", "0.6017315", "0.60042125", "0.596248", "0.59614336", "0.5955538", "0.59521264", "0.59444284", "0.5929214"...
0.0
-1
helper function to parallelize smartcotagsort
def helper_smartsort2(grouped, key): df = grouped.get_group(key) return df.loc[df.index[0], :]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_sort(arr):\n pass", "def test_three_split():\n run_mergesort([3, 0, 3], [0, 3, 3])", "def keysort(*args, **kwargs): # real signature unknown\n pass", "def mergesort_vs_quicksort():\n runtime_merge = []\n runtime_quick = []\n runtime_system = []\n\n for size in array_sizes:\n\n...
[ "0.675029", "0.6308638", "0.6267418", "0.62532204", "0.6149817", "0.6148415", "0.61287344", "0.6116317", "0.6070241", "0.6069463", "0.60656625", "0.6064378", "0.6029623", "0.6017315", "0.60042125", "0.596248", "0.59614336", "0.5955538", "0.59521264", "0.59444284", "0.5929214"...
0.0
-1
perform a 'clumping' based on Cotagging score, but retain all the rest in the last part of the dataframe
def smartcotagsort(prefix, gwascotag, column='Cotagging', ascending=False, title=None): picklefile = '%s_%s.pickle' % (prefix, ''.join(column.split())) if os.path.isfile(picklefile): with open(picklefile, 'rb') as F: df, beforetail = pickle.load(F) else: print(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_cat(df_, feature, top=10):\n alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')\n labels = alphabet[:top]\n other = alphabet[top + 1]\n top_violation_codes = df_.groupby(feature)[feature].count().sort_values(ascending=False).head(\n top).index.tolist()\n map_values ...
[ "0.5458474", "0.5458474", "0.53750175", "0.53088534", "0.5261422", "0.52310926", "0.52100956", "0.51852643", "0.5119328", "0.51189196", "0.5037852", "0.502742", "0.5006158", "0.50013584", "0.4982252", "0.49814147", "0.49682853", "0.49582946", "0.49404126", "0.49257052", "0.49...
0.46529695
61
Define the range starting by adding one snp up the the first step
def set_first_step(nsnps, step, init_step=2, every=False): # Fool proofing if nsnps < 20: print('Really? running with less than 20 snps? I am setting your step ' 'to 1, and making every equals True') every = True step = 1 init_step = 1 onesnp = 100. / float(nsnp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range100(self):\r\n return self.init(100)", "def incr_min_step( bgn , end , stepSize ):\n # NOTE: The actual step size will be the size that produces an evenly-spaced list of trunc( (end - bgn) / stepSize ) elements\n return np.linspace( bgn , end , num = trunc( (end - bgn) / stepSize ) , endpoi...
[ "0.6326634", "0.63014925", "0.62043864", "0.61233854", "0.607282", "0.6032687", "0.6021261", "0.59809196", "0.59704834", "0.592812", "0.5888085", "0.5760751", "0.57563084", "0.5753656", "0.5750209", "0.5745185", "0.57287705", "0.57117313", "0.5686095", "0.5671224", "0.5671058...
0.6189637
3
Generate qrange file to be used with plink qrange
def gen_qrange(prefix, nsnps, prunestep, every=False, qrangefn=None): order = ['label', 'Min', 'Max'] # dtype = {'label': object, 'Min': float, 'Max': float} if qrangefn is None: # Define the number of snps per percentage point and generate the range percentages = set_first_step(nsnps, prune...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_qubits(self):\n return cq.LineQubit.range(4)", "def process_qrange_file(filename):\n\n f = open(filename, 'r')\n q_ranges = yaml.load(f)\n\n return q_ranges", "def write_q_table_file(q_table, q_file=\"Q_Table.txt\"):\n file = open(q_file, \"w+\")\n rows = len(q_table)\n c...
[ "0.60668355", "0.56891936", "0.5675259", "0.56339264", "0.55886894", "0.5510636", "0.5363446", "0.535094", "0.53416795", "0.5267484", "0.5214582", "0.5211727", "0.51969045", "0.5183751", "0.51725626", "0.5170478", "0.51103914", "0.5081725", "0.5069747", "0.50608844", "0.50602...
0.6948805
0
Read the profile file a.k.a. PRS file or scoresum
def read_scored_qr(profilefn, phenofile, alpha, nsnps, score_type='sum'): if score_type == 'sum': col = 'SCORESUM' else: col = 'SCORE' # Read the profile sc = pd.read_table(profilefn, delim_whitespace=True) # Read the phenotype file pheno = pd.read_table(phenofile, delim_whitespa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadProfile(fname):\n \n x = np.loadtxt(fname)\n return x[:,1]", "def read_profile (filename, index):\n \n col_names = ['m', 'r', 'F', 'P', 'rho', 'T', 'u', 's', \n 'c_P', 'gamma_ad', 'nabla_ad', 'mu', 'n_e', \n 'P_e', 'P_rad', 'nabla_rad', 'nabla', 'v_c',\n ...
[ "0.67490244", "0.6539704", "0.64265704", "0.63860035", "0.6299824", "0.6296246", "0.6175478", "0.61677104", "0.6160291", "0.6003463", "0.59651375", "0.59021604", "0.58780545", "0.5768216", "0.56579554", "0.5647066", "0.561981", "0.5615413", "0.560589", "0.5548813", "0.5522177...
0.57425326
14
Estimate the potential size of an array
def estimate_size(shape): total_bytes = reduce(np.multiply, shape) * 8 return total_bytes / 1E6
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_size(self):\n return self._array_size", "def num(an_array):\n return an_array.size", "def ndarray_size(self) -> int:\n pass", "def get_length(array):\n return len(list(array))", "def size(self):\n return len(self.arr)", "def numel(array):\n _import_modules()\n m...
[ "0.754894", "0.7541969", "0.7452033", "0.7308454", "0.7239921", "0.7226865", "0.714513", "0.7108841", "0.70963943", "0.7083458", "0.7077772", "0.7043401", "0.70346034", "0.7033545", "0.70216477", "0.6995221", "0.6987276", "0.6980619", "0.6974536", "0.694953", "0.6943104", "...
0.7038034
12
Find the nearest positivedefinite matrix to input A Python/Numpy port of John D'Errico's `nearestSPD` MATLAB code [1], which credits [2] from Ahmed Fasih
def nearestPD(A, threads=1): isPD = lambda x: da.all(np.linalg.eigvals(x) > 0).compute() B = (A + A.T) / 2 _, s, V = da.linalg.svd(B) H = da.dot(V.T, da.dot(da.diag(s), V)) A2 = (B + H) / 2 A3 = (A2 + A2.T) / 2 if isPD(A3): return A3 spacing = da.spacing(da.linalg.norm(A)) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nearestPD(A):\n\n B = (A + A.T) / 2\n _, s, V = np.linalg.svd(B)\n\n H = np.dot(V.T, np.dot(np.diag(s), V))\n\n A2 = (B + H) / 2\n\n A3 = (A2 + A2.T) / 2\n\n if isPD(A3):\n return A3\n\n spacing = np.spacing(np.linalg.norm(A))\n # The above is different from [1]. It appears that ...
[ "0.68542147", "0.6521094", "0.64592224", "0.63368255", "0.6250634", "0.62383735", "0.61633074", "0.6163099", "0.61562115", "0.6106572", "0.5934725", "0.59224224", "0.58703405", "0.58235496", "0.58216244", "0.5798199", "0.57948667", "0.57833314", "0.5778119", "0.576644", "0.57...
0.6320866
4
Helper function to paralellize score_qfiles
def single_score_plink(prefix, qr, tup, plinkexe, gwasfn, qrange, frac_snps, maxmem, threads): qfile, phenofile, bfile = tup suf = qfile[qfile.find('_') + 1: qfile.rfind('.')] ou = '%s_%s' % (prefix, suf) # score = ('%s --bfile %s --score %s 2 4 7 header --q-score-range %s %s ' # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task3(dataset,writepickle=False,pfilename=None,usepickle=True):\n model,bitext = task1(dataset,printoutput = False,writepickle=writepickle,pfile = pfilename,usepickle=usepickle)\n phrases = extract_phrases(bitext,model)\n scored_phrases = phrase_scoring_ranking(phrases,model,dataset,bitext)\n print...
[ "0.575768", "0.56732047", "0.5492514", "0.548684", "0.54390764", "0.5437585", "0.54353154", "0.5411575", "0.53655994", "0.5360998", "0.53581184", "0.535637", "0.5347568", "0.5334679", "0.5334244", "0.53258014", "0.53248626", "0.53238755", "0.5297921", "0.5297799", "0.52928126...
0.5791598
0
Prune and score a dataframe of sorted snps
def prune_it(df, geno, pheno, label, step=10, threads=1): print('Prunning %s...' % label) print('First 200') gen = ((df.iloc[:i], geno, pheno, label) for i in range(1, min(201, df.shape[0] + 1), 1)) delayed_results = [dask.delayed(single_score)(*i) for i in gen] with ProgressBar(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyse_and_sort(self, df):\n if (type(df) is pd.Series):\n df = df.to_frame(\"score\")\n elif (type(df) is pd.DataFrame):\n df.columns = [\"score\"]\n df = self._filter(df)\n df = self._argrelmax(df)\n df = self._drop_close_extrema(df) # by = [deb1[0]]...
[ "0.5949003", "0.57834405", "0.57237935", "0.5530729", "0.5455612", "0.5381943", "0.53662086", "0.5360469", "0.5339884", "0.5305047", "0.5300142", "0.5277637", "0.5252278", "0.5250166", "0.52499807", "0.5238071", "0.5236248", "0.52102304", "0.5197937", "0.5192069", "0.5158917"...
0.5152658
22
Initialize a `METARdata` instance, and set its default property values.
def __init__(self): self.site = ('http://vortex.plymouth.edu/cgi-bin/gen_statlog-u.cgi') """Root of URL to query for data.""" yesterday = datetime.today() - timedelta(days=1) self.year = yesterday.year """Year to get data for.""" self.month = yesterday.month """Mo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, defaults={}, data=None):\n\n super().__init__(\n defaults={**ThermodynamicsParameters.parameters, **defaults}, data=data\n )", "def __init__(self):\n\n # initialise the empty mappings dictionary\n self.data = {\n 'loan_id': None,\n ...
[ "0.65249085", "0.65091693", "0.6461086", "0.6457381", "0.6440995", "0.6382057", "0.63357127", "0.63347465", "0.63210326", "0.62682796", "0.6264791", "0.6264062", "0.62361246", "0.620263", "0.61959344", "0.61653787", "0.6160545", "0.6140136", "0.6102526", "0.6089607", "0.60844...
0.0
-1
Return a list of strings of METAR meteorological data for the specified station on sthe specified date.
def get_met_data(self, stn, ignore_errors, retries, **kwargs): # Validate the common station name and convert it to the # corresponding official station ID try: stn = self.stns[stn] except: raise UnknownStationError, stn # Process the date components in th...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metar_data(station, begin, end, ignore_errors, retries):\n\n def _parse_date(date_str):\n \"\"\"Minimal date parser.\"\"\"\n yr, mo, day = [int(x) for x in date_str.split('-')]\n try:\n return date(yr, mo, day)\n except ValueError:\n raise InvalidDateError, ...
[ "0.6079679", "0.60203874", "0.59128946", "0.5794843", "0.57113194", "0.5494066", "0.5489716", "0.5488133", "0.5465871", "0.53732324", "0.53613657", "0.5346025", "0.5334262", "0.5303991", "0.5268003", "0.5259103", "0.523938", "0.52334833", "0.52326477", "0.5229239", "0.5220071...
0.6702449
0
Return the METAR data page as a list of strings.
def _get_metars(self, stn, retries): # Build the URL parameter string. Note that order of the # parameters apparently matters to vortex.plymouth.edu, so we # can't use urllib.urlencode() params = '='.join(('ident', stn)) params += '&' + '='.join(('pl', 'none0')) params +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_data():\n return scrape()", "def exportAsArray(self):\n data = []\n data.append(self.title)\n data.append(self.director)\n data.append(self.cast)\n data.append(self.producer)\n data.append(self.writer)\n data.append(self.country)\n data.append(s...
[ "0.59596455", "0.5940351", "0.5872467", "0.5713039", "0.5710403", "0.57034284", "0.56698006", "0.56524384", "0.55789405", "0.5549929", "0.55382067", "0.55309206", "0.55184513", "0.5496536", "0.5486317", "0.547058", "0.54679865", "0.5464709", "0.5449131", "0.5445956", "0.54454...
0.52604043
61
Validate and clean up the METAR data.
def _clean_data(self, stn, ignore_errors): # Confirm that we got some data, and confirm that it's the # expected web page by checking the <title> tag contents if (not self.data) | (not self.data[0].startswith( '<TITLE>Generate WXP 24-Hour Meteogram</TITLE>')): if ignore_e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_up_data(self):\n pass", "def validate_metadata(self):\n\n # check sampling rate\n if self.has_data():\n # check start time\n if self.start != self.run_metadata.time_period.start:\n if (\n self.run_metadata.time_period.start\n ...
[ "0.64654624", "0.62384987", "0.6129969", "0.6084937", "0.6040723", "0.5976599", "0.5952668", "0.5908923", "0.5872254", "0.57705694", "0.57631445", "0.5757449", "0.57375824", "0.5724756", "0.56940866", "0.56893945", "0.56518936", "0.56177545", "0.55992085", "0.5596849", "0.559...
0.60454017
4
Parse the command line options.
def parse_options(): # Build the option parser from optparse import OptionParser desc = ("Retrieve the METAR data for the specified station " "and date range and write it to stdout.") parser = OptionParser(description=desc) parser.usage += ' station' help = "beginning date for METAR...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_options():\n global parser\n parser.add_option(\"-r\", \"--regions\", dest=\"input_brain_regions\",\n help=\"Input file for brain region data\",\n action=\"store\", type='string')\n\n parser.add_option(\"-g\", \"--gray\", dest=\"input_gray_levels\",\n ...
[ "0.79766136", "0.790654", "0.75567454", "0.75388986", "0.7532519", "0.7529125", "0.74911195", "0.7424969", "0.73958135", "0.73735034", "0.7299791", "0.72880006", "0.7285438", "0.7278607", "0.72572947", "0.7228134", "0.7213546", "0.72073394", "0.715399", "0.71270114", "0.71148...
0.0
-1
Return the METAR data for the specified station and date range.
def metar_data(station, begin, end, ignore_errors, retries): def _parse_date(date_str): """Minimal date parser.""" yr, mo, day = [int(x) for x in date_str.split('-')] try: return date(yr, mo, day) except ValueError: raise InvalidDateError, begin ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_met_data(self, stn, ignore_errors, retries, **kwargs):\n # Validate the common station name and convert it to the\n # corresponding official station ID\n try:\n stn = self.stns[stn]\n except:\n raise UnknownStationError, stn\n # Process the date comp...
[ "0.7159997", "0.5764372", "0.5731595", "0.5731141", "0.56950647", "0.5617954", "0.5477128", "0.5425443", "0.542119", "0.540292", "0.5396697", "0.5381608", "0.5376013", "0.536097", "0.53551173", "0.53006876", "0.5294632", "0.52827334", "0.5266694", "0.52493864", "0.524286", ...
0.7412664
0
Class and Instance Variables.
def test_class_and_instance_variables(): # pylint: disable=too-few-public-methods class Dog: """Dog class example""" kind = "canine" # Class variable shared by all instances. def __init__(self, name): self.name = name # Instance variable unique to each instance. fid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def variable(self):", "def __init__():", "def attributes(self):", "def __init__(__self__):\n pass", "def __init__(__self__):\n pass", "def __init__(__self__):\n pass", "def __init__(__self__):\n pass", "def __init__(__self__):\n pass", "def __init__(__self__):\n ...
[ "0.7025008", "0.67684484", "0.67454106", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.6679362", "0.66515243", "0.6616021", "0.6606844", "0.6606844", "0.6606844", "0.6606844", "0.6606844", "0.6606844", ...
0.0
-1
Add trick to the dog This function illustrate mistaken use of mutable class variable tricks (see below).
def add_trick(self, trick): self.tricks.append(trick)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_class_and_instance_variables():\n\n # pylint: disable=too-few-public-methods\n class Dog:\n \"\"\"Dog class example\"\"\"\n\n kind = \"canine\" # Class variable shared by all instances.\n\n def __init__(self, name):\n self.name = name # Instance variable unique to e...
[ "0.62275213", "0.54250777", "0.5253472", "0.5125945", "0.50684893", "0.50618595", "0.50537896", "0.50460774", "0.50388473", "0.5032443", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.5029293", "0.502929...
0.5709575
1
Add trick to the dog This function illustrate mistaken use of mutable class variable tricks (see below).
def add_trick(self, trick): self.tricks.append(trick)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_class_and_instance_variables():\n\n # pylint: disable=too-few-public-methods\n class Dog:\n \"\"\"Dog class example\"\"\"\n\n kind = \"canine\" # Class variable shared by all instances.\n\n def __init__(self, name):\n self.name = name # Instance variable unique to e...
[ "0.62278074", "0.5426456", "0.52543545", "0.5125915", "0.50691813", "0.50625455", "0.50529546", "0.504636", "0.50389963", "0.50328195", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", "0.50298977", ...
0.5709806
2
friend and msg needs to be strings @ this point
def new_message_from_conn(self, friend, msg): print("new_msg signal activated with friend",friend,"and msg",msg) if not self.stack.get_child_by_name(friend): new_chat_window = chat_layout.ChatLayout(orientation=Gtk.Orientation.VERTICAL,friend=friend) new_chat_window.show_all() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, msg):\n self.msg = msg", "def __init__(self, msg):\n self.msg = msg", "def __init__(self, msg):\n self.msg = msg", "def __init__(self, msg):\n self.msg = msg", "def __init__(self, msg):\n self.msg = msg", "def __init__(self, msg):\n self.msg = ...
[ "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.6737745", "0.66940606", "0.66782755", "0.6591113", "0.6541398", "0.6541398", "0.6407637", "0.63755196", "0.6330417", "0.62995756",...
0.0
-1
Start the instance of the class
def __init__(self): self.db = Databank() self.db.connection() # self.db.cursor.execute('USE library')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start (self):\n pass", "def start (self):\n pass", "def start(self):\n ...", "def Start(self) :\n\t\t...", "def start(self) -> None:\n ...", "def start(self) -> None:\n ...", "def start(self):\n pass", "def start(self):\n pass", "def start(self):...
[ "0.7587983", "0.7587983", "0.7575441", "0.75613564", "0.7483918", "0.7483918", "0.7472124", "0.7472124", "0.7472124", "0.7472124", "0.7472124", "0.7472124", "0.7472124", "0.7472124", "0.74645305", "0.7455854", "0.7399919", "0.7399919", "0.73621386", "0.73125386", "0.73125386"...
0.0
-1
This method register the book in the books table, but before checks if the books is already registered. I decided to use the barcode in data string, because I can use the both bar code parameters. And the stock is defined in 0, because if the user doesn't pass the stock, the quantity is already set to 0
def register_book(self, title: str, author: str, price: float, barcode: str, stock=0): try: if not self.verify_register(barcode): self.db.cursor.execute('INSERT INTO books (title, author, price, bar_code, stock) VALUES (%s, %s, %s, ' '%s, %s)', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_book(self, data):\n exists = self.check_if_exists(data['isbn'])\n\n if exists:\n query = f\"\"\"UPDATE {TABLE} SET quantity = quantity + 10 WHERE bookID = '{data[\"isbn\"]}'\"\"\"\n else:\n query = f\"\"\"INSERT INTO {TABLE}(bookID, title, authors, avg_rating, rat...
[ "0.7018125", "0.67015535", "0.6207142", "0.6084916", "0.60626495", "0.60456854", "0.59645706", "0.591887", "0.5900992", "0.5860568", "0.5826839", "0.57534194", "0.5710244", "0.57028556", "0.5676682", "0.56455344", "0.56382316", "0.5637503", "0.5599727", "0.5594511", "0.558963...
0.824485
0
This method update the price of the books, by the barcode.
def update_price_books(self, barcode, new_price): try: self.db.cursor.execute('UPDATE books SET price = %s where id_books = %s', (round(new_price, 2), barcode)) except Exception as error: print(error) else: self.db.con.commit() self.db.con.close() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __on_update_bookticker(self, action, bookticker):\n self.best_bid_price = float(bookticker['b'])\n self.best_ask_price = float(bookticker['a'])", "def update(self, price, volume):\r\n if price > self.hig:\r\n self.hig = price\r\n if price < self.low:\r\n self...
[ "0.6417695", "0.62173057", "0.61378425", "0.603132", "0.5936183", "0.5868149", "0.58071566", "0.5730834", "0.57285744", "0.5673982", "0.5657812", "0.56183827", "0.5603246", "0.55851513", "0.55851513", "0.55851513", "0.55851513", "0.55597377", "0.555364", "0.55461675", "0.5521...
0.8498672
0
This method deleted books already registered in the database, by the barcode.
def delete_book(self, barcode): try: self.db.cursor.execute('DELETE FROM books where id_books = %s', (barcode,)) except Exception as error: print(error) else: self.db.con.commit() self.db.con.close() print('Deleted Successfully!')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self, book_info, destroy):\n self.connect()\n bid = book_info[0].get()\n\n delete_sql = f\"delete from {self.book_table} where bid = '{bid}'\"\n delete_issue = f\"delete from {self.issued_table} where bid = '{bid}'\"\n try:\n self.cur.execute(delete_sql)\n ...
[ "0.72892725", "0.7267948", "0.70717716", "0.6985194", "0.6930456", "0.6827797", "0.6826523", "0.6772539", "0.67015284", "0.6700609", "0.6663117", "0.66131103", "0.6519632", "0.6362935", "0.63454336", "0.63371575", "0.6292271", "0.62690663", "0.6228916", "0.6208259", "0.614254...
0.8566365
0
This method return the specifications of the books, consulting the database by barcode
def consult_books(self, bar_code: str): try: book_data = [] self.db.cursor.execute('SELECT * from books WHERE bar_code = %s', (bar_code,)) for i in self.db.cursor.fetchall(): book_data.append(i) except Exception as error: print(error) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_book(code: str) -> Dict:\n pass", "def get_all_books() -> List[Dict]:\n pass", "def search_for_redbooks(book_codes: tuple):\n\n book_dict = {}\n\n global setup\n\n for book_code in book_codes:\n URI_string = build_URI_string(book_code)\n search_web_page = requests.get(URI_...
[ "0.6242606", "0.6134235", "0.61072266", "0.6074063", "0.601683", "0.6006033", "0.5984732", "0.59228015", "0.59210134", "0.59080076", "0.5892924", "0.5887974", "0.5790417", "0.577142", "0.57639205", "0.57627887", "0.5726483", "0.5719359", "0.57189673", "0.5704592", "0.5703736"...
0.7258699
0
This method checks if the books is already registered in the database, by barcode.
def verify_register(self, barcode: str): try: test = [] self.db.cursor.execute(f'SELECT * FROM books where bar_code = {barcode}') for i in self.db.cursor.fetchall(): test.append(i) except Exception as error: print(error) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_book(self, title: str, author: str, price: float, barcode: str, stock=0):\n try:\n if not self.verify_register(barcode):\n self.db.cursor.execute('INSERT INTO books (title, author, price, bar_code, stock) VALUES (%s, %s, %s, '\n '%...
[ "0.7017784", "0.6627457", "0.6388775", "0.6382595", "0.6364732", "0.6298332", "0.6274584", "0.6257029", "0.620658", "0.6175331", "0.61634517", "0.6128748", "0.6127025", "0.6117657", "0.60925686", "0.6036167", "0.59862727", "0.5967401", "0.59655285", "0.5958692", "0.5928705", ...
0.8429786
0
A method to generate a nonce to send to the validation server. As specified by the protocol, the nonce must be between 16 and 40 alphanumeric characters long with random unique data.
def generate_nonce(): return uuid4().hex
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nonce():\n return random.randint(0, 4294967295)", "def nonce():\n return random.randint(0, 4294967295)", "def _generate_nonce(self):\n return str(random.randrange(100000, 999999))", "def gen_nonce(self, length=32):\n if(length < 32):\n res = {\"message\": 'Invalid nonce len...
[ "0.8042163", "0.8042163", "0.8010228", "0.7921566", "0.79005414", "0.78887206", "0.78473306", "0.78447676", "0.78447676", "0.77639616", "0.75877625", "0.75856775", "0.748053", "0.74550116", "0.7397726", "0.73679745", "0.73569447", "0.7110729", "0.70935357", "0.7075415", "0.70...
0.8238167
0
Check that the response is a valid response to our request that is, the otp that was returned is the otp we sent originally, that the nonce that was sent was the nonce we had originally, and that the signature (if C{self.api_key} is not C{None}) is valid
def _verify_response(self, text_response, orig_otp, orig_nonce): response_dict = dict([line.strip(' ').split('=', 1) for line in re.split(r'\r\n', text_response) if line.strip()]) if 'otp' in response_dict and response_dict['otp'] != orig_otp:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_response(self, response):\n pass", "def _check_response(self, res: requests.Response, token: str) -> None:\n return", "def verify_response_dict(api_key, response):\n LOGGER.debug('Verifying WSAPI response signature')\n\n # Remove signature from the response\n r = dict(respon...
[ "0.6813327", "0.6812169", "0.67820585", "0.65645856", "0.6504918", "0.6386462", "0.63724524", "0.6230743", "0.622919", "0.6145281", "0.6137439", "0.60897577", "0.608821", "0.6076044", "0.607178", "0.6069999", "0.60647804", "0.60482323", "0.6047397", "0.60116434", "0.59915906"...
0.7006299
0
If the response code is not 200, raise an error
def _check_200(self, response): if response.code != 200: raise YubiKeyVerificationError( "Received {0} response.".format(response.code)) return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _raise_if_error(response):\n if response.status_code != 200:\n raise SimpleHTTPException(response)", "def raise_for_status(response):\n if response.status_code != 200:\n res_data = response.json()\n if (response.status_code, res_data['error']) in error_map:\n raise error...
[ "0.8200442", "0.77988267", "0.7796814", "0.77532864", "0.77236915", "0.7602498", "0.75976735", "0.75056386", "0.74018836", "0.7371521", "0.73343915", "0.7306833", "0.73002267", "0.7287284", "0.7269197", "0.72426486", "0.719703", "0.71900296", "0.7165454", "0.7154237", "0.7149...
0.76849234
5
See if validation failed
def _check_results(results): if isinstance(results, list): # this means that none of the requests succeeded, since # otherwise the result would be a two-tuple for i, one_result in enumerate(results): if self.logger is not None: # pragma: n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validation(self):\n self.validationFails()", "def validate():", "def is_valid(self):\n return not self.errors", "def is_valid(self) -> bool:\n return self.errors == \"\"", "def hasErrors(self):\n return False", "def is_valid(self):\n self.clean()\n retur...
[ "0.78729135", "0.7572437", "0.7536559", "0.73924816", "0.735434", "0.732329", "0.7313274", "0.7291495", "0.7260773", "0.7211988", "0.71832144", "0.71390224", "0.71390224", "0.71390224", "0.71390224", "0.71390224", "0.70216286", "0.7015459", "0.7015459", "0.7015459", "0.701545...
0.0
-1
Verifies an OTP against the validation servers provided to the verifier. It queries all servers in parallel and waits for answers. Servers will not respond positively until it has synchronized the new OTP counter with the other servers, and this will wait until it has received one valid (200, otp and nonce match, and s...
def verify(self, otp, timestamp=None, sl=None, timeout=None): query_dict = { 'id': self.verifier_id, 'otp': otp, 'nonce': self.generate_nonce() } if timestamp is not None: query_dict['timestamp'] = int(bool(timestamp)) if sl is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_otp(request: Request, body: VerifyOTPIn, db: Session = Depends(get_db)):\n mgr = LoginManager()\n mgr.verify_otp(db, body.identifier, body.code)\n request.session[\"access_token\"] = secrets.token_hex(16)\n return {\"status\": \"OK\"}", "def sync_remote(self, otp_params, local_params, serv...
[ "0.5752108", "0.5737716", "0.56494606", "0.5645329", "0.5643826", "0.5574296", "0.5451564", "0.5326181", "0.53075504", "0.5299279", "0.52365446", "0.52112764", "0.5197768", "0.51941586", "0.51802087", "0.51605034", "0.514498", "0.51412606", "0.5097546", "0.508744", "0.5070752...
0.68441504
0
r"""Makes a gif using a list of images.
def make_gif(image_list, gif_name): if not gif_name.endswith(".gif"): gif_name += ".gif" imageio.mimsave(gif_name, [imageio.imread(x) for x in image_list])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_gif():\n anim_file = 'sample/training.gif'\n\n with imageio.get_writer(anim_file, mode='I') as writer:\n filenames = glob.glob('sample/*.jpg')\n filenames = sorted(filenames, key=lambda filename: int(filename[11:-4]))\n for filename in filenames:\n image = imageio.imread(filename)\n ...
[ "0.78579974", "0.7659993", "0.7557394", "0.75059664", "0.72135156", "0.7159185", "0.7140775", "0.7111952", "0.69703233", "0.6958537", "0.694323", "0.68651026", "0.68095165", "0.68038476", "0.6797115", "0.6718196", "0.6681492", "0.6675865", "0.66499966", "0.66303796", "0.65588...
0.818792
0
wrapper function for starting a net.Server connected to `pipe`
async def net_server(pipe): server = await net.Server(pipe, host="0.0.0.0", port=8080) return await server.wait_closed()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def net_proc(pipe):\n asyncio.run(net_server(pipe))", "def new_server(self, name, pipeline, port=None):\n if port is None:\n port = self.next_port\n self.next_port += 1\n\n self.servers[name] = port\n\n args = [\"owl-server\",\"--port\", str(port)] + pipeline.split()...
[ "0.7584677", "0.6351429", "0.6300604", "0.617805", "0.60826844", "0.5990248", "0.5973056", "0.5972735", "0.5965008", "0.5957159", "0.5957159", "0.5944811", "0.58804023", "0.5860215", "0.58540183", "0.58201164", "0.58175886", "0.57931465", "0.57761294", "0.5772888", "0.5771360...
0.8183566
0
wrapper for running net_server on its own thread/process
def net_proc(pipe): asyncio.run(net_server(pipe))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n server = TCPServer((self.host, self.port), TCPHandler)\n server.lymphocytes_getter = self.lymphocytes_getter\n\n #runs forever - so make this thread daemon\n server.serve_forever()", "async def net_server(pipe):\n server = await net.Server(pipe, host=\"0.0.0.0\", p...
[ "0.7307538", "0.68068635", "0.6780022", "0.6780022", "0.6734137", "0.6704307", "0.668211", "0.66599005", "0.6595216", "0.65842754", "0.6539571", "0.65383536", "0.6500156", "0.6459733", "0.64578015", "0.6419993", "0.6366262", "0.6355513", "0.63487566", "0.6294894", "0.62633705...
0.7150661
1
wait for both terminal and websocket handlers to run
async def main(): # duplex pipe for communication between network and terminal i/o tasks net_pipe, term_pipe = aiopipe.aioduplex() # network process with net_pipe.detach() as net_pipe: proc = multiprocessing.Process(target=net_proc, args=(net_pipe,)) proc.start() terminal = term.T...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait():\n pass", "def _wait(self):\n conn = None\n try:\n conn = libvirt.open(\"qemu:///system\")\n while True:\n time.sleep(10)\n try:\n state = conn.lookupByName(self.domain).info()[0]\n except (libvirt.l...
[ "0.64092374", "0.6264127", "0.6235764", "0.6235764", "0.6235764", "0.6235764", "0.61184424", "0.6097051", "0.6084436", "0.60687375", "0.6043218", "0.60034686", "0.5994405", "0.5990241", "0.59745866", "0.5932926", "0.5903162", "0.58702195", "0.5852462", "0.58505785", "0.584319...
0.54271877
63
This is the R^2 test, which measures how much of the variance in y is explained by the model f. It runs from 1 to 1, both being good while 0 is very bad
def R_squared(self): return 1 - ((self.y - self.y_hat(self.x))**2).sum() / ((self.y - self.y.mean())**2).sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def r2_score(self):\n print('R^2 (coefficient of determination) regression score function: ' +\n str(r2_score(self.model.dataset.get_y_test(), self.model.get_predicted())))", "def evaluate(self, X_test, y_test):\n \n y_pred = self.pipeline.predict(X_test)\n test_rmse = co...
[ "0.6759407", "0.6602552", "0.6591278", "0.6515553", "0.64896923", "0.64778274", "0.6439889", "0.63823986", "0.63823986", "0.63823986", "0.63823986", "0.63546026", "0.63121766", "0.6311863", "0.62866527", "0.6259391", "0.62301654", "0.6222997", "0.6214", "0.61959684", "0.61939...
0.57903486
56
This is a standard correlation test beteween x and y. A value of 1 or 1 implies that a linear model describes perfectly the data, while a value of 0 implies there is no correlation between x and y
def pearson_r(self): return ((self.x - self.x.mean()) * (self.y - self.error_weighted_average(self.y, self.dy))).sum() / self.x.std() / self.y.std()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correlation(x, y):\n stdev_x = standard_deviation(x)\n stdev_y = standard_deviation(y)\n if stdev_x > 0 and stdev_y > 0:\n return covariance(x, y) / stdev_x / stdev_y\n else:\n return 0", "def correlation(x, y):\n stdev_x = standard_deviation(x)\n stdev_y = standard_deviation(...
[ "0.74524945", "0.74524945", "0.72285455", "0.7078785", "0.70589435", "0.6973359", "0.68641263", "0.6852631", "0.68099797", "0.6698745", "0.6663148", "0.6663048", "0.66623944", "0.66447544", "0.6609", "0.65797305", "0.6571908", "0.65042186", "0.64830023", "0.6434808", "0.64323...
0.0
-1
Create a new user request. Modified from default such that the username is equal to the email address.
def create_account(request): if request.method == 'POST': post = request.POST form = forms.RegisterForm(post) if form.is_valid(): # create a new user user = models.HAWCUser.objects.create_user(post['email'], pos...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user(self, request):\n if User.query(User.name == request.user_name).get():\n raise endpoints.ConflictException(\n 'A User with that name already exists!')\n user = User(name=request.user_name, email=request.email)\n user.put()\n return StringMessage...
[ "0.8106865", "0.80964696", "0.79707193", "0.79511887", "0.7939506", "0.7904408", "0.7811179", "0.77868485", "0.77286077", "0.7665409", "0.76530784", "0.76077586", "0.76066804", "0.7586554", "0.756443", "0.7548708", "0.75199914", "0.7515655", "0.751103", "0.7509979", "0.742550...
0.0
-1
Dynamic import of CVXOPT dense interface.
def get_cvxopt_dense_intf(): import cvxpy.interface.cvxopt_interface.valuerix_interface as dmi return dmi.DenseMatrixInterface()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cvxopt_sparse_intf():\n import cvxpy.interface.cvxopt_interface.sparse_matrix_interface as smi\n return smi.SparseMatrixInterface()", "def dense2cvxopt(value):\n import cvxopt\n return cvxopt.matrix(value, tc='d')", "def test_import_type_dense():\n x = np.random.rand(7, 11)\n export_d...
[ "0.6213993", "0.6188066", "0.59842515", "0.59137076", "0.58391494", "0.55679363", "0.5485139", "0.5233388", "0.5186878", "0.5140729", "0.5139248", "0.5135993", "0.5131671", "0.5050744", "0.5043737", "0.5000771", "0.4989075", "0.49857393", "0.49512193", "0.4937559", "0.4929777...
0.76370394
0
Dynamic import of CVXOPT sparse interface.
def get_cvxopt_sparse_intf(): import cvxpy.interface.cvxopt_interface.sparse_matrix_interface as smi return smi.SparseMatrixInterface()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import_type_sparse():\n x = sps.csr_matrix(np.random.rand(7, 11))\n export_data('/tmp/test.sparse', x)\n assert x.dtype == import_data('/tmp/test.sparse').dtype", "def test_import_values_sparse():\n x = sps.csr_matrix(np.random.rand(7, 11))\n export_data('/tmp/test.sparse', x)\n assert...
[ "0.6678251", "0.6325364", "0.6168615", "0.61634254", "0.6101723", "0.6002239", "0.59741104", "0.5861257", "0.58531886", "0.5842924", "0.5654546", "0.56046325", "0.5598766", "0.559268", "0.557955", "0.5525964", "0.5518082", "0.550019", "0.5469042", "0.5434541", "0.5425496", ...
0.76998776
0
Converts a SciPy sparse matrix to a CVXOPT sparse matrix.
def sparse2cvxopt(value): import cvxopt if isinstance(value, (np.ndarray, np.matrix)): return cvxopt.sparse(cvxopt.matrix(value.astype('float64')), tc='d') # Convert scipy sparse matrices to coo form first. elif sp.issparse(value): value = value.tocoo() return cvxopt.spmatrix(val...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_sparse(self):\n from divisi2.sparse import SparseMatrix\n return SparseMatrix(self, self.row_labels, self.col_labels)", "def makesparse(matrix):\n n = matrix[0].size\n elements = []\n for i in range(n):\n for j in range(n):\n if matrix[i][j] != 0 :\n ...
[ "0.74020207", "0.7093455", "0.70311135", "0.6989213", "0.69172007", "0.68352145", "0.6795465", "0.67651546", "0.6756018", "0.6749724", "0.6736512", "0.67179906", "0.66992825", "0.6644021", "0.6587182", "0.65845096", "0.6561744", "0.6558976", "0.65500927", "0.65500927", "0.655...
0.80747503
0
Converts a NumPy matrix to a CVXOPT matrix.
def dense2cvxopt(value): import cvxopt return cvxopt.matrix(value, tc='d')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cvxopt2dense(value):\n return np.array(value)", "def sparse2cvxopt(value):\n import cvxopt\n if isinstance(value, (np.ndarray, np.matrix)):\n return cvxopt.sparse(cvxopt.matrix(value.astype('float64')), tc='d')\n # Convert scipy sparse matrices to coo form first.\n elif sp.issparse(valu...
[ "0.6312579", "0.6233762", "0.58347297", "0.5797177", "0.56139076", "0.5566805", "0.54767096", "0.5372099", "0.53622454", "0.535068", "0.5341642", "0.52930886", "0.52172667", "0.5217212", "0.51898384", "0.51890403", "0.5079698", "0.50713885", "0.5059637", "0.5054085", "0.50439...
0.66287154
0
Converts a CVXOPT matrix to a NumPy ndarray.
def cvxopt2dense(value): return np.array(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_numpy(x):\r\n return x.squeeze().detach().cpu().numpy()", "def toarray(x):\n if is_SparseDataFrame(x):\n x = x.to_coo().toarray()\n elif is_SparseSeries(x):\n x = x.to_dense().to_numpy()\n elif isinstance(x, (pd.DataFrame, pd.Series, pd.Index)):\n x = x.to_numpy()\n eli...
[ "0.67291087", "0.65662235", "0.6408317", "0.6399814", "0.63628644", "0.6203062", "0.61928123", "0.6082726", "0.6044713", "0.6028564", "0.6015846", "0.5950616", "0.5935821", "0.5877838", "0.58768505", "0.5856204", "0.5840025", "0.58212465", "0.58202916", "0.58162457", "0.58080...
0.6429498
2
Is the constant a sparse matrix?
def is_sparse(constant) -> bool: return sp.issparse(constant)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_sparse(A):\n if isinstance(A, torch.Tensor):\n return A.layout == torch.sparse_coo\n raise TypeError(\"expected Tensor but got %s\" % (type(A).__name__))", "def is_sparse(tensor):\n return isinstance(tensor, sparse_tensor.SparseTensor)", "def is_sparse(x: Any, backend=None) -> bool:\r\n ...
[ "0.76833653", "0.7436849", "0.74230564", "0.72037745", "0.7105081", "0.6872479", "0.6814387", "0.67973125", "0.67928153", "0.67843324", "0.66110086", "0.6596236", "0.6586943", "0.65716755", "0.6568378", "0.64620703", "0.641447", "0.6402279", "0.6368499", "0.62777996", "0.6246...
0.7981942
0
Convert 2D Numpy matrices or arrays to 1D.
def from_2D_to_1D(constant): if isinstance(constant, np.ndarray) and constant.ndim == 2: return np.asarray(constant)[:, 0] else: return constant
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_1d_array(self):\n return reshape_fns.to_1d(self._obj, raw=True)", "def _asarray1d(arr, copy=False):\n if copy:\n return asarray(arr).flatten()\n else:\n return asarray(arr).ravel()", "def _to_matrix(self, y):\n if hasattr(y, \"shape\"):\n if len(y.shape) == 1...
[ "0.70328456", "0.6536092", "0.6400261", "0.63641346", "0.63088894", "0.62903285", "0.6238182", "0.62333584", "0.6229632", "0.6153521", "0.61396265", "0.61174077", "0.60771555", "0.598066", "0.5975083", "0.5957192", "0.5935709", "0.588951", "0.5882828", "0.5869165", "0.5865906...
0.6170691
9
Convert 1D Numpy arrays to matrices.
def from_1D_to_2D(constant): if isinstance(constant, np.ndarray) and constant.ndim == 1: return np.mat(constant).T else: return constant
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_matrix(array):\n return Matrix(array.tolist())", "def n2m(a):\n if not isinstance(a, np.ndarray): a = np.array(a)\n return multiprocessing.Array(a.dtype.char, a.flat, lock=False), tuple(a.shape), a.dtype.char, isinstance(a, np.matrix)", "def array_to_matrix(array):\n\n assert len(array.shape) ...
[ "0.70715255", "0.65589106", "0.6528237", "0.6280818", "0.6259741", "0.62007457", "0.61990327", "0.61861753", "0.6150136", "0.6111489", "0.60827094", "0.6006862", "0.5995141", "0.5972217", "0.5919056", "0.5843375", "0.5827259", "0.580557", "0.57884365", "0.5774397", "0.5770293...
0.0
-1
Convert to appropriate type.
def convert(constant, sparse: bool = False, convert_scalars: bool = False): if isinstance(constant, (list, np.matrix)): return DEFAULT_INTF.const_to_matrix(constant, convert_scalars=convert_scalars) elif sparse: return DEFAULT_SPARSE_INTF.const_to_matr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cast(self, value):\n if value is None:\n return None\n return self.type(value)", "def convert(self):\n return", "def castType(self, valueType, value):\n try:\n return valueType(value)\n except (ValueError, TypeError):\n self.error('incorre...
[ "0.7190359", "0.7120859", "0.7052454", "0.7036384", "0.6984004", "0.68194294", "0.6797164", "0.67359906", "0.6674825", "0.6651274", "0.6601706", "0.6600411", "0.65880376", "0.65457416", "0.65385765", "0.6533269", "0.6526997", "0.64172775", "0.6411281", "0.6406562", "0.6404257...
0.0
-1
Return (is positive, is negative).
def sign(constant): if isinstance(constant, numbers.Number): max_val = constant min_val = constant elif sp.issparse(constant): max_val = constant.max() min_val = constant.min() else: # Convert to Numpy array. mat = INTERFACES[np.ndarray].const_to_matrix(constant) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_negative(self, a):\n return a < 0", "def sign(a):\n return (a > 0) - (a < 0)", "def isnegative(x):\n if x < 0 :\n return True\n return False", "def sign(a) :\n return (a>0) - (a<0)", "def is_Negative(self):\n return self.signature() < 0", "def positive_only...
[ "0.774261", "0.7723657", "0.7689608", "0.7508066", "0.7448095", "0.74278224", "0.74278224", "0.74278224", "0.7404295", "0.7345145", "0.7188604", "0.7182966", "0.7171951", "0.71586525", "0.7152506", "0.71260065", "0.71130836", "0.70752656", "0.7061648", "0.70083034", "0.695955...
0.0
-1
Return (is real, is imaginary).
def is_complex(constant, tol: float = 1e-5) -> bool: complex_type = np.iscomplexobj(constant) if not complex_type: return True, False if isinstance(constant, numbers.Number): real_max = np.abs(np.real(constant)) imag_max = np.abs(np.imag(constant)) elif sp.issparse(constant): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_imaginary(self):\r\n return self._real.is_zero()", "def is_real(self):\r\n return self._imag.is_zero()", "def is_imaginary(self) -> bool:\n return self < 0", "def imag(z):", "def complex(real, imag):", "def complex(real=0.0, imag=0.0):\n if imag == 0.0 and real == 0.0:\n ...
[ "0.782439", "0.7584804", "0.7500016", "0.6933671", "0.6915799", "0.6833551", "0.67918944", "0.6694675", "0.6663298", "0.66070265", "0.6590156", "0.65633804", "0.6449115", "0.6337711", "0.6312694", "0.62896824", "0.62289053", "0.6220184", "0.617657", "0.61523724", "0.6152128",...
0.5690715
43
Check if a matrix is Hermitian and/or symmetric.
def is_hermitian(constant) -> bool: complex_type = np.iscomplexobj(constant) if complex_type: # TODO catch complex symmetric but not Hermitian? is_symm = False if sp.issparse(constant): is_herm = is_sparse_symmetric(constant, complex=True) else: is_herm = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_Hermitian(q_1: Qs) -> bool:\n\n hc = Hermitian_conj(q_1, q_1.rows, q_1.columns)\n\n return equals(q_1, hc)", "def is_symmetric(mat):\n return np.allclose(mat.T, mat)", "def IsHermitian(self):\n \n Hermitian=True\n for Ind in self.IndList():\n Q=tuple(-x for x in ...
[ "0.7288421", "0.70511174", "0.695801", "0.660251", "0.6573264", "0.6567614", "0.6554783", "0.6513599", "0.65056306", "0.64851743", "0.64565355", "0.63981193", "0.6385611", "0.63054913", "0.62993294", "0.62919945", "0.6259792", "0.6143758", "0.6118125", "0.6030024", "0.6024043...
0.71756566
1
Check if a sparse matrix is symmetric
def is_sparse_symmetric(m, complex: bool = False) -> bool: # https://mail.scipy.org/pipermail/scipy-dev/2014-October/020101.html if m.shape[0] != m.shape[1]: raise ValueError('m must be a square matrix') if not isinstance(m, sp.coo_matrix): m = sp.coo_matrix(m) r, c, v = m.row, m.col, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def symmetric(matrix):\n return sp.allclose(matrix, matrix.T)", "def is_symmetric(mat):\n return np.allclose(mat.T, mat)", "def is_symmetric(mat, eps=None):\n if eps is None:\n eps = np.finfo(mat.dtype).eps\n\n assert mat.ndim == 2\n if mat.shape[0] != mat.shape[1]:\n return False\...
[ "0.8109215", "0.7986687", "0.75691277", "0.7378022", "0.71965635", "0.69735336", "0.6926111", "0.68735796", "0.68685687", "0.68559587", "0.6809457", "0.6783302", "0.66975164", "0.6593864", "0.6587962", "0.65538776", "0.64825404", "0.6459463", "0.6381787", "0.63341165", "0.632...
0.7317553
4
Get total current value.
def get_total(df): last_milestone_id = df[df.cmd.notnull()].tail(1).index.get_values()[0] total = df[last_milestone_id:].value.sum() return total
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetTotal(self):\n return(self.total)", "def total(self):\n\t\treturn self._total", "def total(self) -> float:\n return self._total", "def total_value(self):\n return self.parent.child_total_value[self.action]", "def total(self):\n if self.dynamic:\n self._update_d...
[ "0.82439566", "0.8206046", "0.814501", "0.7962158", "0.7755605", "0.77370954", "0.7563143", "0.75528264", "0.75345725", "0.7509995", "0.74133193", "0.74117213", "0.73834187", "0.7374968", "0.73463064", "0.7320118", "0.7301672", "0.72930855", "0.72901803", "0.7275583", "0.7254...
0.0
-1
Walks through the full state trie, yielding one missing node hash/prefix at a time. The yielded node info is wrapped in a TrackedRequest. The hash is marked as active until it is explicitly marked for review again. The hash/prefix will be marked for review asking a peer for the data. Will exit when all known node hashe...
async def _missing_trie_hashes(self) -> AsyncIterator[TrackedRequest]: # For each account, when we have asked for all known storage and bytecode # hashes, but some are still not present, we "pause" the account so we can look # for neighboring nodes. # This is a list of paused account...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _request_tracking_trie_items(\n self,\n request_tracker: TrieNodeRequestTracker,\n root_hash: Hash32) -> AsyncIterator[Tuple[Nibbles, Nibbles, bytes]]:\n if self._next_trie_root_hash is None:\n # We haven't started beam syncing, so don't know which root ...
[ "0.6850051", "0.6614492", "0.5646459", "0.5422282", "0.53472066", "0.5297117", "0.52896756", "0.5159195", "0.50123775", "0.4973791", "0.49718073", "0.4961415", "0.49293295", "0.49292937", "0.4928424", "0.4927427", "0.49176684", "0.4904762", "0.48756814", "0.4864487", "0.48493...
0.7028946
0
Walk through the supplied trie, yielding the request tracker and node request for any missing trie nodes.
async def _request_tracking_trie_items( self, request_tracker: TrieNodeRequestTracker, root_hash: Hash32) -> AsyncIterator[Tuple[Nibbles, Nibbles, bytes]]: if self._next_trie_root_hash is None: # We haven't started beam syncing, so don't know which root to start a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _missing_trie_hashes(self) -> AsyncIterator[TrackedRequest]:\n # For each account, when we have asked for all known storage and bytecode\n # hashes, but some are still not present, we \"pause\" the account so we can look\n # for neighboring nodes.\n # This is a list of pau...
[ "0.6288311", "0.56712145", "0.56443197", "0.5567986", "0.55481374", "0.54169506", "0.5246231", "0.5213265", "0.51985264", "0.51985264", "0.51985264", "0.51985264", "0.5185277", "0.5173819", "0.5107165", "0.50870496", "0.50870496", "0.50827366", "0.50448364", "0.50392336", "0....
0.6903136
0
Walks through the storage trie at the given root, yielding one missing storage node hash/prefix at a time. The yielded node info is wrapped in a ``TrackedRequest``. The hash is marked as active until it is explicitly marked for review again. The hash/prefix will be marked for review asking a peer for the data. Will exi...
async def _missing_storage_hashes( self, address_hash_nibbles: Nibbles, storage_root: Hash32, starting_main_root: Hash32) -> AsyncIterator[TrackedRequest]: if storage_root == BLANK_NODE_HASH: # Nothing to do if the storage has an empty root ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _request_tracking_trie_items(\n self,\n request_tracker: TrieNodeRequestTracker,\n root_hash: Hash32) -> AsyncIterator[Tuple[Nibbles, Nibbles, bytes]]:\n if self._next_trie_root_hash is None:\n # We haven't started beam syncing, so don't know which root ...
[ "0.70497036", "0.6926985", "0.5630191", "0.48730353", "0.48023686", "0.47926912", "0.4764393", "0.46911123", "0.4685286", "0.4670354", "0.46662426", "0.4628357", "0.46207827", "0.45691854", "0.45436504", "0.45341483", "0.44921196", "0.4481057", "0.44659668", "0.4446959", "0.4...
0.766844
0
Checks if this bytecode is missing. If so, yield it and then exit. If not, then exit immediately. This may seem like overkill, and it is right now. But... Code merkelization is coming (theoretically), and the other account and storage trie iterators work similarly to this, so in some ways it's easier to do this "overge...
async def _missing_bytecode_hashes( self, address_hash_nibbles: Nibbles, code_hash: Hash32, starting_main_root: Hash32) -> AsyncIterator[TrackedRequest]: if code_hash == EMPTY_SHA3: # Nothing to do if the bytecode is for the empty hash ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable_bytecode_generation():\n sentinel, sys.dont_write_bytecode = sys.dont_write_bytecode, True\n\n try:\n yield\n finally:\n sys.dont_write_bytecode = sentinel", "async def _missing_trie_hashes(self) -> AsyncIterator[TrackedRequest]:\n # For each account, when we have asked ...
[ "0.5561266", "0.5535464", "0.5518014", "0.49592614", "0.4936246", "0.4916298", "0.48616886", "0.470336", "0.46492574", "0.4646029", "0.46459916", "0.46368012", "0.4590937", "0.45884967", "0.4579382", "0.4562117", "0.45618558", "0.45422032", "0.4526873", "0.4470122", "0.446246...
0.713805
0
Estimate the completed fraction of the trie that is contiguous with the current index (which rotates every 32 blocks) It will be probably be quite noticeable that it will get "stuck" when downloading a lot of storage, because we'll have to blow it up to more than a percentage to see any significant change within 32 blo...
def _contiguous_accounts_complete_fraction(self) -> float: starting_index = bytes_to_nibbles(self._next_trie_root_hash) unknown_prefixes = self._account_tracker._trie_fog._unexplored_prefixes if len(unknown_prefixes) == 0: return 1 # find the nearest unknown prefix (typicall...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fraction_completed(self):\n return sum(self._chunk_done.values()) / len(self.chunks)", "def get_utilization(self):\n child_prefixes = Prefix.objects.filter(prefix__net_contained_or_equal=str(self.prefix))\n # Remove overlapping prefixes from list of children\n networks = cidr_merg...
[ "0.57871044", "0.57394934", "0.5700969", "0.557595", "0.55153626", "0.5491407", "0.54715765", "0.54007584", "0.53748786", "0.5336496", "0.5328934", "0.5310399", "0.5259188", "0.52554494", "0.5247512", "0.5241603", "0.5217785", "0.51893973", "0.51840824", "0.5177834", "0.51671...
0.764008
0
Stop iterating this node, until mark_for_review() is called
def pause_review(self, prefix: Nibbles) -> None: self._active_prefixes.add(prefix)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _review_printer(self):\n cont = input(\"Read a review? (y/n) \")\n if cont == 'y':\n review_count = len(self.user_reviews)\n for i in range(review_count):\n # Cycles through all reviews one at a time (amount is chosen by user)\n print('\\n' + se...
[ "0.55926895", "0.5364128", "0.5353215", "0.5327375", "0.5236763", "0.5153191", "0.5037302", "0.5021179", "0.5010047", "0.49338165", "0.49248472", "0.49155876", "0.49141592", "0.48874277", "0.4864139", "0.4858734", "0.48342335", "0.4833316", "0.48259443", "0.48172835", "0.4799...
0.0
-1
Return the Trie Fog that can be searched, ignoring any nodes that are currently being requested.
def _get_eligible_fog(self) -> fog.HexaryTrieFog: return self._trie_fog.mark_all_complete(self._active_prefixes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty_trie():\n trie = Trie()\n return trie", "def empty_trie():\n from trie import Trie\n trie = Trie()\n return trie", "def traversal_test_trie():\n from trie import Trie\n trie = Trie()\n trie.insert('alpha')\n trie.insert('alpaca')\n trie.insert('boy')\n return trie", ...
[ "0.5776142", "0.57360816", "0.5326462", "0.5315044", "0.5267867", "0.5225813", "0.51331353", "0.5095872", "0.50827706", "0.49944326", "0.49880475", "0.496863", "0.48768044", "0.4836348", "0.48069534", "0.4800665", "0.47692093", "0.47494227", "0.47216982", "0.47108996", "0.469...
0.7354035
0
Return title + episode (if series)
def inclusive_title(self): return self.title + (" %s" % (self.episode_to_string(self.latest_season, self.latest_episode),) if self.is_series() else "")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def episode_title_for_tvdb(self):\n \n # strip out the year from the episode title:\n return \"Episode %d\"%self.episode_number[1]", "def episode_title_for_tvdb(self):\n return self.episode_title", "def episode_title_for_tvdb(self):\n \n # strip out the year from the e...
[ "0.74555385", "0.7378745", "0.6963783", "0.68400466", "0.66249967", "0.6508349", "0.64518964", "0.6446037", "0.6445582", "0.6437754", "0.6297738", "0.62690187", "0.6210943", "0.6200764", "0.61216825", "0.6120273", "0.611263", "0.59974575", "0.5988067", "0.5951355", "0.5944540...
0.7791267
0
Predicts cluster basing on a data row and the model.
def som_predict(x, som) -> int: result = som.winner(np.array(x)) return 10 * result[0] + result[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_cluster(self, inputs):\n if not self.trained:\n if self.verbose:\n print(\"KMeans Model Class - Predict Cluster Function: No trained model\")\n return -1\n\n\n return self.model.predict(inputs)", "def predict(toPredict=None):\n\tif not toPredict:\n\t...
[ "0.7522711", "0.7326191", "0.7257883", "0.70320976", "0.65632576", "0.6549994", "0.6549688", "0.6518247", "0.6481188", "0.6445282", "0.6443695", "0.64254546", "0.6385586", "0.6377753", "0.6368531", "0.6351673", "0.63453573", "0.63428134", "0.6336442", "0.6334855", "0.6315561"...
0.0
-1
Trains selforganizing map and returns train and test datasets with predicted clusters.
def train_som(som_width: int, som_height: int, df: pd.core.frame.DataFrame, df_train: pd.core.frame.DataFrame, df_test: pd.core.frame.DataFrame, df_train_columns: pd.core.frame.DataFrame, n_iter: int, sigma=0.3, learning_rate=0.01): som = MiniSom(som_width, som_height, df_train.shape[1]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_train(self, dataset):\n pd_dataset = pandas.read_csv('../../data/Ragni2016.csv')\n pe = principleextractor.PrincipleExtractor()\n # NOTE this does not use CCOBRA's dataset; if different dataset is to be used, must be specified here and\n # not in the .json; or with argument give...
[ "0.65929526", "0.61541826", "0.6041843", "0.59890664", "0.5949455", "0.5890738", "0.58586735", "0.5857667", "0.5801546", "0.57741946", "0.5761678", "0.5756762", "0.575235", "0.57209086", "0.57159173", "0.569669", "0.5683529", "0.5674185", "0.5626972", "0.5618207", "0.56169873...
0.0
-1
Returns dataframe with mean profit per cluster basing on a df given as an argument
def get_profit_per_cluster(df: pd.core.frame.DataFrame) -> pd.core.frame.DataFrame: return pd.DataFrame(df.groupby(by='cluster')['profit'].mean(), columns=['profit']).reset_index()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mean_profit_per_class_from_train_df(df_profit_per_cluster_train: pd.core.frame.DataFrame) -> tuple:\n # if condition returns False, AssertionError is raised:\n assert len(df_profit_per_cluster_train) >= 3, \"Algorithm, returned less than 3 clusters.\"\n\n df_profit_per_cluster = df_profit_per_clus...
[ "0.77887636", "0.71788836", "0.68467784", "0.64547867", "0.62752557", "0.62094164", "0.6097976", "0.6032077", "0.59859556", "0.5968796", "0.5952526", "0.5906807", "0.59013987", "0.58965117", "0.58917665", "0.5887675", "0.5864871", "0.5808137", "0.5738972", "0.5717941", "0.564...
0.87321883
0
Basing on a dataframe given as an argument, returns mean profit per class (buy, sell) in training dataset. sort dataframe descending by profit marks 1/3 of clusters with the highest profit as buy marks 1/3 of clusters with the lowest profit as sell if data contains less than 3 different clusters returns AssertionError
def get_mean_profit_per_class_from_train_df(df_profit_per_cluster_train: pd.core.frame.DataFrame) -> tuple: # if condition returns False, AssertionError is raised: assert len(df_profit_per_cluster_train) >= 3, "Algorithm, returned less than 3 clusters." df_profit_per_cluster = df_profit_per_cluster_train.s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mean_profit_per_class_from_test_df(df_profit_per_cluster_test: pd.core.frame.DataFrame,\n buy_clusters_list: List[int], sell_clusters_list: List[int]) -> tuple:\n # if condition returns False, AssertionError is raised:\n assert len(buy_clusters_list) != 0 and...
[ "0.72233945", "0.6792338", "0.6017771", "0.58476025", "0.57573664", "0.5649134", "0.56137496", "0.5605749", "0.56018263", "0.55858415", "0.55482686", "0.55418605", "0.5532151", "0.551682", "0.5425047", "0.54250115", "0.5417848", "0.5410822", "0.5366402", "0.53150505", "0.5294...
0.78250796
0
Basing on a dataframe given as an argument, and list of buy and sell clusters returns mean profit per class (buy, sell) in testing dataset.
def get_mean_profit_per_class_from_test_df(df_profit_per_cluster_test: pd.core.frame.DataFrame, buy_clusters_list: List[int], sell_clusters_list: List[int]) -> tuple: # if condition returns False, AssertionError is raised: assert len(buy_clusters_list) != 0 and len(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mean_profit_per_class_from_train_df(df_profit_per_cluster_train: pd.core.frame.DataFrame) -> tuple:\n # if condition returns False, AssertionError is raised:\n assert len(df_profit_per_cluster_train) >= 3, \"Algorithm, returned less than 3 clusters.\"\n\n df_profit_per_cluster = df_profit_per_clus...
[ "0.8185011", "0.7136002", "0.5966785", "0.59034175", "0.58183724", "0.5765148", "0.5717098", "0.56850725", "0.56474286", "0.56181526", "0.5601236", "0.557191", "0.55662805", "0.5527561", "0.55179936", "0.55108774", "0.54241854", "0.5415164", "0.5412711", "0.5410539", "0.54015...
0.8361798
0
Used for creating a final strategy (not for testing) reads preprocessed split into training and testing sets data train som model calculates mean profit per cluster in training dataset gets list of sell and buy clusters
def create_final_strategy(filename: str, columns_list: List[str], som_width=Config.som_width, som_height=Config.som_height, n_iter=Config.n_iter, sigma=Config.sigma, learning_rate=Config.learning_rate) -> tuple: print( f'Creating final strategy for parame...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_predefined_split():\n\n average_performance = []\n fold_num = 'predefined'\n output_file_folder = \"output/{}\".format(args.experiment_name)\n output_file_name = \"{}/lnnel_{}.csv\".format(output_file_folder, fold_num)\n Path(output_file_folder).mkdir(parents=True, exist_ok=True)\n args....
[ "0.67675084", "0.6755315", "0.673634", "0.67276907", "0.67021465", "0.66885126", "0.6578545", "0.65512574", "0.65313745", "0.65287274", "0.6499436", "0.64882433", "0.64505625", "0.6448712", "0.6448493", "0.64040166", "0.6400989", "0.63855517", "0.6363851", "0.63565266", "0.63...
0.62798804
31
Creates strategy which can be used in testing part of the script. reads preprocessed split into training and testing sets data train som model calculates mean profit per cluster in training and testing dataset gets mean profits
def create_strategy(filename: str, columns_list: List[str], som_width: int, som_height: int, n_iter: int, sigma=0.3, learning_rate=0.01) -> tuple: # get prepared data df, df_prepared, df_train, df_test, df_train_columns = get_data(filename, columns_list) # train som final_df_train, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_train_test(option, transform, params, split=0.2):\r\n clip_im_dir = option.clip_im_dir\r\n matting_dir = option.matting_dir\r\n csv_path = option.csv_path\r\n \r\n print(\"create datasets\")\r\n \r\n \r\n data_df = pd.read_csv(csv_path)\r\n # data_df = MergeDataframe(clip_i...
[ "0.67197025", "0.6372317", "0.6326024", "0.62784594", "0.62007445", "0.6187098", "0.61727315", "0.61609745", "0.6150832", "0.61274564", "0.6109672", "0.60908484", "0.60526675", "0.60400504", "0.5990867", "0.59906036", "0.59859765", "0.5970628", "0.5950032", "0.5942936", "0.59...
0.6798001
0
Returns parameters which should be used in one iteration of the testing process.
def set_model_parameters(test_type: str, parameter_value: float): # assigning default parameters for the model som_width = Config.som_width som_height = Config.som_height n_iter = Config.n_iter sigma = Config.sigma learning_rate = Config.learning_rate # assign testing parameter to the model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_test_params(cls, parameter_set=\"default\"):\n params1 = {\n \"n_clusters\": 3,\n \"n_init\": 2,\n \"max_iter\": 2,\n \"tol\": 1e-3,\n \"verbose\": False,\n \"random_state\": 2,\n }\n params2 = {\n \"n_cluster...
[ "0.72552997", "0.7055899", "0.7055899", "0.7009616", "0.69649035", "0.6943783", "0.68921715", "0.68921447", "0.68385094", "0.6832389", "0.6796779", "0.6747082", "0.6738572", "0.6733773", "0.6733502", "0.6733482", "0.6692859", "0.6686844", "0.6658831", "0.6651606", "0.6640636"...
0.0
-1