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
For each cluster calculate the distance from each point to the centroid/medoid
def calculate_all_distances_to_center(self): all_distances = pd.DataFrame() for label in np.unique(self.embedding_df['cluster']): distance_df = self.calculate_distances_for_cluster(label) all_distances = pd.concat([all_distances, distance_df]) self.emb...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calc_distance(self, X):\n distances = np.zeros((X.shape[0], self.n_clusters))\n print(distances.shape)\n for i, centroid in enumerate(self.centroids):\n distances[:, i] = np.linalg.norm(X - centroid, axis=1)\n return distances", "def clusterAndDistance(self, data):\n\t...
[ "0.7406177", "0.7224814", "0.7208233", "0.7151215", "0.708985", "0.7055581", "0.7028743", "0.70208573", "0.6990872", "0.6973009", "0.696932", "0.6856841", "0.6850477", "0.6842931", "0.68366003", "0.680196", "0.6769376", "0.67255235", "0.67136353", "0.6698315", "0.66856843", ...
0.70009273
8
For a given cluster_id calculate the distance from each point to the centroid/medoid.
def calculate_distances_for_cluster(self, cluster_id): cluster_of_interest = self.embedding_df[self.embedding_df['cluster'] == cluster_id].copy() if cluster_of_interest.empty: raise ValueError(f'Cluster id {cluster_id} not found') # Don't calculate distances for the...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calcDistortion(medoids, clusters, class_header=\"Class\"):\n distortion = 0\n for medoid_row_index, medoid_tuple in enumerate(medoids.iterrows()): # For every Medoid\n for _, datum in clusters[medoid_row_index].iterrows(): # For each point in the medoid cluster\n # Add...
[ "0.67842567", "0.67745066", "0.6764742", "0.67052865", "0.6705151", "0.6693539", "0.6685048", "0.65840197", "0.6572326", "0.65583515", "0.64906234", "0.6264555", "0.6253788", "0.6250515", "0.62433743", "0.62167305", "0.6175956", "0.61737406", "0.6170333", "0.61438906", "0.614...
0.7704725
0
For a given cluster return a pandas dataframe of points ranked by distance to the cluster centroid/medoid
def rank_cluster_points_by_distance(self, cluster_id): cluster_of_interest = self.embedding_df[self.embedding_df['cluster'] == cluster_id].copy() if cluster_of_interest.empty: raise ValueError(f'Cluster id {cluster_id} not found') if 'dist_to_rep_point' not in s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_cluster_rankings(self):\n if 'dist_to_rep_point' not in self.embedding_df.columns:\n self.calculate_all_distances_to_center()\n\n self.embedding_df['rank_in_cluster'] = self.embedding_df.groupby('cluster')['dist_to_rep_point'].rank(method='min')", "def cluster_spatial_positio...
[ "0.74079317", "0.67105204", "0.64238435", "0.63077164", "0.6306624", "0.6294445", "0.62434506", "0.6157537", "0.6113591", "0.61009115", "0.6098193", "0.607835", "0.60371375", "0.6021003", "0.60085094", "0.60084623", "0.5979887", "0.59464717", "0.59397215", "0.5935677", "0.592...
0.74946755
0
Calculate the rank of each point within a cluster
def get_all_cluster_rankings(self): if 'dist_to_rep_point' not in self.embedding_df.columns: self.calculate_all_distances_to_center() self.embedding_df['rank_in_cluster'] = self.embedding_df.groupby('cluster')['dist_to_rep_point'].rank(method='min')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rank():\n return 0", "def rankNeighbors(Data):\r\n strokeDist = []\r\n for i in range(len(Data)):\r\n strokeDist.append([])\r\n index = 0\r\n for point1 in Data:\r\n dist = []\r\n index1=0\r\n for point2 in Data:\r\n #dist.append(math.sqrt((center1[0]-cen...
[ "0.70503414", "0.7008832", "0.6786571", "0.6764138", "0.67443216", "0.66818386", "0.6654572", "0.6623286", "0.6598719", "0.65756667", "0.65539867", "0.6456434", "0.6411865", "0.6378525", "0.63583297", "0.63149124", "0.6295258", "0.62677336", "0.6262239", "0.6217441", "0.61610...
0.7514025
0
Get the N closest points to the cluster centroid/medoid
def get_closest_samples_for_cluster(self, cluster_id, n_samples=5): return self.rank_cluster_points_by_distance(cluster_id).head(n_samples)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def closest_centroid(x,centroids):\n\tK =len(centroids)\n\tN = len(x)\n\tDistance = np.zeros((N,K))\n\tfor j in range(K):\n\t\tmu = centroids[j]\n\t\tDistance[:,j] = np.linalg.norm(x-mu,axis=1)\n\tout = np.argmin(Distance,axis=1) \n\treturn out", "def closestCentroids(self, points , centroids ):\n dists =...
[ "0.7343606", "0.72781867", "0.71205705", "0.6924735", "0.6859449", "0.6853737", "0.6829529", "0.6827063", "0.6808693", "0.6704461", "0.66894203", "0.6678887", "0.66732544", "0.66403407", "0.6632764", "0.66146874", "0.6592352", "0.656101", "0.65443325", "0.65115714", "0.650200...
0.67615163
9
Get the N points furthest away from the cluster centroid/medoid
def get_furthest_samples_for_cluster(self, cluster_id, n_samples=5): return self.rank_cluster_points_by_distance(cluster_id).tail(n_samples)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def closest_centroid(x,centroids):\n\tK =len(centroids)\n\tN = len(x)\n\tDistance = np.zeros((N,K))\n\tfor j in range(K):\n\t\tmu = centroids[j]\n\t\tDistance[:,j] = np.linalg.norm(x-mu,axis=1)\n\tout = np.argmin(Distance,axis=1) \n\treturn out", "def find_centroid_for_each(self):", "def find_closest_centroid(...
[ "0.66241753", "0.6465052", "0.641947", "0.64152354", "0.6400747", "0.633942", "0.6306366", "0.6299195", "0.62724966", "0.6231763", "0.6229463", "0.6175052", "0.6131195", "0.61069965", "0.6090556", "0.6089263", "0.60883355", "0.6073964", "0.60512024", "0.60488605", "0.60463613...
0.625018
9
It should train the BM25 model on the given corpus docs Return nothing
def fit(self, X): X = self.tf_vectorizer.fit_transform(X).toarray() if not sp.issparse(X): X = sp.csc_matrix(X) n_samples, n_features = X.shape if sp.isspmatrix_csr(X): df = bincount(X.indices, minlength=X.shape[1]) else: df = np.diff(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_with_corpus(corpus):\n\n chatbot.set_trainer(\"chatterbot.trainers.ChatterBotCorpusTrainer\")\n chatbot.train(corpus)", "def train(self, corpus):\n self.tokens = []\n self.tags = []\n sentences = corpus.split(NEW_LINE)\n for sentence in sentences:\n start = ...
[ "0.6795744", "0.6774191", "0.6740312", "0.6709312", "0.6631094", "0.6580085", "0.6452751", "0.64361066", "0.6405335", "0.63766575", "0.6367579", "0.6351783", "0.63233477", "0.63163066", "0.6267682", "0.62623096", "0.625112", "0.6227979", "0.62257004", "0.62190145", "0.6202841...
0.0
-1
Train the BM25 model and return a vectorspace representation of the corpus Return a matrix where each row is one document, each column is feature
def fit_transform(self, X): self.fit(X) return self.transform(X)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trainingModel4wmd(corpus):\n model = Word2Vec(corpus, workers = nCores, size = 100, window = 300,\n min_count = 2, iter = 250)\n # model = Word2Vec(corpus)\n\n # use the following if we want to normalize the vectors\n model.init_sims(replace=True)\n\n return model", "def build_model(self, ...
[ "0.68189424", "0.65753895", "0.6421289", "0.6344367", "0.6242432", "0.62343466", "0.6107891", "0.6102696", "0.6091877", "0.6071134", "0.60613745", "0.60417163", "0.60304743", "0.5970605", "0.5967089", "0.59405553", "0.59382325", "0.5937518", "0.59349877", "0.59299314", "0.592...
0.0
-1
Find text in collections
def fuzzyfinder(user_input, collection): suggestions = [] pattern = '.*?'.join(user_input) # Converts 'djm' to 'd.*?j.*?m' regex = re.compile(pattern, re.IGNORECASE) for item in collection: match = regex.search(item) if match: suggestions.append(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_search():\n existing_fields = self.attr_name_map[object_class]\n text = \"%{}%\".format(exp[\"text\"])\n p = lambda f: f.ilike(text)\n return or_(*(\n with_key(field, p)\n for field in fields\n if field in existing_fields\n ))", "def find_matches(self,...
[ "0.6595098", "0.6506341", "0.6453324", "0.64229476", "0.63823557", "0.628753", "0.6222342", "0.6208727", "0.6166719", "0.61623925", "0.61597556", "0.6141293", "0.6113045", "0.609483", "0.609124", "0.6073653", "0.60039556", "0.59964216", "0.5945154", "0.5939557", "0.59151816",...
0.5410252
75
Adds the object to this world.
def add_object(self, object_to_be_added): new_mapping = Map.add_object(self.id, object_to_be_added) if new_mapping: object_to_be_added.save() new_mapping.ref_id = object_to_be_added.id return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_world(self, thing):\n\t\tthing.set_world_info(self.current_id, self)\n\t\tself.gameObjects.append(thing)\n\t\tself.current_id += 1", "def add_object(self, obj):\n\t\tself.objects.append(obj)", "def add(self, obj):\n raise NotImplementedError", "def add(self, obj):\n self.objects.appe...
[ "0.7806233", "0.7238987", "0.7172745", "0.71658224", "0.71255547", "0.7012599", "0.6983041", "0.6965109", "0.6878019", "0.68778664", "0.67840016", "0.6766624", "0.66833013", "0.6667035", "0.66547865", "0.6638408", "0.66247624", "0.6623228", "0.66065276", "0.65824896", "0.6509...
0.62936544
31
Removes the object from this world.
def remove_object(self, object_to_be_removed): Map.remove_object(object_to_be_removed) object_to_be_removed.query.delete()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_obj(self, obj_name):\n self.scene.remove_world_object(obj_name)", "def remove(self):\n self._world.remove_mob(self)", "def remove_object(self, name):\n if name in self._objects:\n del self._objects[name]\n else:\n raise ValueError('Object {} not in s...
[ "0.8095782", "0.7762199", "0.7431813", "0.7195679", "0.7184229", "0.7052576", "0.69814664", "0.6966261", "0.6925698", "0.69233143", "0.6888144", "0.6798792", "0.673691", "0.6721849", "0.6594416", "0.65179706", "0.65097326", "0.6495488", "0.6477363", "0.6472084", "0.6472084", ...
0.6862572
11
Returns the object located at given coordinates.
def get_object_at_location(self, x, y): object_map_at_target_location = self.maps.get((x, y)) if not object_map_at_target_location: return None return object_map_at_target_location.get_real_object()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_object_at_location(cls, x, y):\n object_map_at_target_location = cls.query\\\n .filter_by(x=x, y=y).one_or_none()\n if not object_map_at_target_location:\n return None\n return object_map_at_target_location.get_real_object()", "def get_object_at(self, position, ...
[ "0.7401787", "0.65084153", "0.64662015", "0.6462374", "0.6404084", "0.62852186", "0.61791605", "0.6087064", "0.5851252", "0.5840479", "0.58224994", "0.58224994", "0.5814853", "0.5790992", "0.57650596", "0.5756242", "0.5745209", "0.5740608", "0.5726151", "0.5704214", "0.566702...
0.71457946
1
Creates a food object randomly somewhere in this world.
def generate_food(self): x = random.randint(0, self.width) y = random.randint(0, self.height) new_food = Food(self.id, x, y) food_created = self.add_object(new_food) if not food_created: existing_object = self.get_object_at_location(x, y) if isinstance(exi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_food(self):\n self.penup()\n self.shape(\"circle\")\n self.color(\"green\")\n self.x_cordinates = random.randint(-210, 210)\n self.y_cordinates = random.randint(-210, 210)\n self.goto(self.x_cordinates, self.y_cordinates)\n print(f\"This Is Food {self.x_c...
[ "0.7924229", "0.7388662", "0.68496233", "0.67906237", "0.6670745", "0.66257876", "0.6595156", "0.64915293", "0.63676316", "0.63369346", "0.63189137", "0.6317571", "0.61416024", "0.6115891", "0.6053006", "0.6016661", "0.60126746", "0.6003472", "0.58886176", "0.58674264", "0.58...
0.79373443
0
Return True if the choice's value is empty string or None.
def _choice_has_empty_value(choice): value, _, crige = choice return value is None or value == ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def non_empty(val):\n return val is not None and val != \"\"", "def is_str_none_or_empty(val):\n if val is None:\n return True\n if isinstance(val, string_types):\n val = val.strip()\n if not val:\n return True\n return False", "def empty(self, value):\r\n return ...
[ "0.7685549", "0.76462", "0.74445015", "0.74445015", "0.74445015", "0.74445015", "0.74445015", "0.73680663", "0.7361419", "0.73225313", "0.7155328", "0.7097266", "0.7065049", "0.7033588", "0.70299554", "0.6994321", "0.69693965", "0.691823", "0.6896403", "0.687022", "0.6839705"...
0.8938283
0
Return a list of optgroups for this widget.
def optgroups(self, name, value, attrs=None): groups = [] has_selected = False for index, (option_value, option_label, option_crige) in enumerate(self.choices): if option_value is None: option_value = '' subgroup = [] if isinstance(option_lab...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_options(self):\n return [o for g in self.parser.option_groups for o in g.option_list]", "def optgroups(self, name, value, attrs=None):\n options = []\n\n for index, (name, product_data) in enumerate(self.product_fields.items()):\n quantity = product_data['quantity']\n ...
[ "0.7063895", "0.69440085", "0.67643887", "0.65815574", "0.6523809", "0.6515766", "0.6399603", "0.6360311", "0.6360311", "0.6360311", "0.63217825", "0.63090414", "0.62958103", "0.62820065", "0.6253235", "0.62510276", "0.6211395", "0.62001765", "0.6191107", "0.61584747", "0.614...
0.75911134
0
Mend aligns by input params.
def mend(aligns_dict, predictions, bound_info): wav_names, bound_indices, times = zip(*bound_info) print('bound_info length: %d' % len(bound_info)) print('predictions length: %d' % len(predictions)) df = pd.DataFrame({'wav_names': wav_names, 'bound_indices': bound_indices, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def align(self):\n ...", "def align(args) :\n from aligner import align_reads\n align_reads(args)", "def align(model,\n left,\n right,\n max_length = 512):\n inputs = preprocess(left, right, max_length)\n output = model(inputs)\n output = expand(output)\n scores, pat...
[ "0.7231606", "0.67981696", "0.6597057", "0.6065707", "0.60352206", "0.6033263", "0.59736323", "0.5951408", "0.5867845", "0.58485246", "0.58053076", "0.5780781", "0.5771312", "0.57659185", "0.57253075", "0.57080555", "0.5691342", "0.56656057", "0.56472176", "0.5637257", "0.563...
0.0
-1
Judge three predictions, decide new boundary time and frame distance
def __update_boundary(preds, old_frame_dist, old_time, fs=16000): assert len(preds) == 3 new_frame_dist = old_frame_dist new_time = old_time moved = False move_dist = None func_map = { '0-0-0': lambda t, d: (t+2*d/fs, d), '0-0-1': lambda t, d: (t+...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_predictions(batch_size, tmd_detector, input_features):\n prediction_start_time = datetime.now()\n predictions = tmd_detector.predict(\n data_frame=input_features,\n batch_size=batch_size,\n verbose=0\n )\n prediction_time = datetime.now() - predi...
[ "0.59344226", "0.5907747", "0.58271396", "0.5826764", "0.57885784", "0.5745873", "0.574444", "0.57349", "0.57344997", "0.5724456", "0.5713037", "0.569263", "0.56828284", "0.566919", "0.5641135", "0.5640334", "0.56383985", "0.5628863", "0.5605123", "0.55969495", "0.558236", ...
0.54329145
32
I change this column name ["", "", "", "", ""]
def changeName(name): if name in ["<OPEN>", "<HIGH>", "<LOW>", "<CLOSE>"]: # Frist charector is upper case name = name.replace('<', '').replace('>', '') #name = name[0] + name[1:].lower() elif name in ["<VOL>"]: #name = name.replace("<VOL>", "Volume") name = name.replace("<VOL>", "VOLUME") elif name in [...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __clean_column_names(self, columns):\r\n cols = []\r\n for column in columns:\r\n cols.append(column.replace('\"', ''))\r\n return cols", "def _str_colnames(self):\n return ', '.join(self.galcat.colnames)", "def initialize(self, col):\n\t\treturn []", "def _str_coln...
[ "0.67438745", "0.6026874", "0.59722286", "0.58937585", "0.58894145", "0.5864143", "0.5821138", "0.57198566", "0.57062376", "0.5703257", "0.5650095", "0.56361", "0.55772233", "0.5573053", "0.55623305", "0.55594975", "0.55338067", "0.5524322", "0.5494165", "0.5484127", "0.54837...
0.0
-1
Read securities data for given symbols from CSV files.
def loadManySymbols(symbols, dates, column_name, base_dir): df = pd.DataFrame(index=dates) # empty data frame that has indexs as dates if 'SET' not in symbols: # add SET for reference, if absent symbols = np.append(['SET'],symbols) base_dir = join(DIR_CURRENT,base_dir) for symbol in symbols: # read CS...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_from_csv(self, file_path):\n securities = []\n\n with open(file_path, \"r\") as f:\n # skip the first line (=column names)\n next(f)\n\n for line in f:\n security_code, num_shares = line.strip(\"\\n\").split(\",\")\n # omit the...
[ "0.70758045", "0.6342294", "0.63347614", "0.6088766", "0.6008428", "0.5867371", "0.57658195", "0.5764524", "0.574373", "0.56270605", "0.5578219", "0.5574559", "0.55543303", "0.55240345", "0.5507941", "0.5496809", "0.549038", "0.5484136", "0.54798716", "0.54472065", "0.5444511...
0.0
-1
Returns list of urls, or error string
def _find_impl(url, query, count, auto_complete): try: res = requests.get( url, params={"q": query, "count": count, "autoCorrect": ("true" if auto_complete else "false")}, ) except (requests.ConnectionError, requests.ConnectTimeout): return "`connection error`" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def urls(self) -> list[str]:\r\n ...", "def getURLs():", "def get_urls():\r\n return []", "def job(url):\n\n from urllib.parse import urlparse\n try:\n if urlparse(url).netloc.split('.')[-1] != 'org':\n raise TypeError(\"Nonvalid url: top level domain is not '.org': {}\"...
[ "0.69925624", "0.6787655", "0.67783505", "0.65709436", "0.6514724", "0.64058846", "0.6393377", "0.6393377", "0.63506687", "0.61886406", "0.61525303", "0.61129975", "0.6084383", "0.608359", "0.60652596", "0.6063299", "0.60621506", "0.605111", "0.6028378", "0.59947616", "0.5966...
0.0
-1
Find first suitable connection entry from yaml config
def find_connection(hint): if not hint: for con in connections: yield con else: for con in connections: for tag in con.get_hints(): if tag.find(hint) != -1: yield con break
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config(hostname=get_hostname()):\n for doc in load():\n if doc['name'] == hostname:\n return doc\n elif hostname == \"upload_tsm\":\n return hostname\n raise LookupError(\"Unknown host %s\" % hostname)", "def read_auto_connect():\n path = os.path.dirname(verti...
[ "0.63480306", "0.6143009", "0.6014163", "0.5998037", "0.59677744", "0.59520304", "0.5819446", "0.5767711", "0.57654124", "0.5715848", "0.56998444", "0.5584522", "0.55842286", "0.5579001", "0.5482194", "0.5459207", "0.5435058", "0.54290324", "0.5413872", "0.5412218", "0.5329",...
0.5773705
7
Resets defaults values when new file is opened
def set_initial_values(self): #Stores each line of the text file in a list self.text = [] #Scrolling distance self.scroll = 0 #Zooming level (font size) self.zoom = 12 #Factor by which is decrement self.zoom self.factor = 0 #Number of ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_values(self):\n self.parse_config_file()", "def reset( self ):\n self.conf = self.defaults", "def reset(self):\n self.keyToFile=dict()", "def reset_file_stat(self):\n # FIXME: this state does not make sense\n self.file_spdx_id_set = False\n self.file_commen...
[ "0.68603104", "0.66013277", "0.64490455", "0.63831466", "0.6246266", "0.61875665", "0.61627656", "0.61585855", "0.61492133", "0.6111486", "0.6111127", "0.6110097", "0.60785025", "0.60501724", "0.6042729", "0.6037925", "0.60298276", "0.60199016", "0.5993268", "0.5968947", "0.5...
0.0
-1
Sets up the cairo context and pango layout
def set_up_pangocairo(self, widget, event): # Create the cairo context self.cr = self.window.cairo_create() #Create a pango layout self.pg = self.cr.create_layout() # Restrict Cairo to the exposed area; avoid extra work self.cr.rectangle(event.area.x, event.ar...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_on_surface(surface):\n pangocairo_ctx = pangocairo.CairoContext(cairo.Context(surface))\n layout = pangocairo_ctx.create_layout()\n\n pango_ctx = layout.get_context()\n if language is not None:\n pango_ctx.set_language(pango.Language(language))\n\n if rtl:\n ...
[ "0.6378648", "0.63250196", "0.5820568", "0.5630213", "0.5574149", "0.5553529", "0.5505494", "0.54557025", "0.5414631", "0.54144245", "0.5352626", "0.53398526", "0.53367114", "0.5331944", "0.5321142", "0.53158367", "0.5298759", "0.5253618", "0.52352786", "0.52059555", "0.51881...
0.7677612
0
Handles expose event. Sets up cairo and calls draw() to draw the text
def do_expose_event(self, widget, event): self.set_up_pangocairo(widget, event) self.draw(*self.window.get_size())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expose (self,widget,event):\n #Creating Cairo drawing context\n self.ctx = self.bin_window.cairo_create()\n #Setting context size to available size\n self.ctx.rectangle(event.area.x, event.area.y, event.area.width, event.area.height)\n self.ctx.clip()\n self.ctx.transl...
[ "0.63333666", "0.6331875", "0.6298491", "0.6249288", "0.62065977", "0.62057835", "0.60598", "0.6035482", "0.5889406", "0.58473253", "0.5832056", "0.58307505", "0.5823392", "0.5807295", "0.579405", "0.579405", "0.579405", "0.5785034", "0.57550627", "0.5724503", "0.5721456", ...
0.7019397
0
Decides if the current line is indented to the same number of tabs as the previous one. If not, sets self.indent to the current value.
def indentation(self, text): tab = text.rfind(' '*4) if tab != -1: if tab%4 == 0: if tab//4 + 1 == self.indent: return True else: self.indent = tab//4 + 1 return False el...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _increaseindentation(self):\n self._indentlist.append(self._curindent)\n if not self._equalsigns[-1]:\n self._curindent = self._curindent + self._indent", "def tab_insert_indent():\n before_cursor = get_app().current_buffer.document.current_line_before_cursor\n\n return bool(be...
[ "0.7080106", "0.69619274", "0.66611207", "0.6653787", "0.6653787", "0.6587194", "0.65701425", "0.6553675", "0.6551975", "0.65384454", "0.6438995", "0.6405378", "0.6339694", "0.63215977", "0.6304247", "0.62886304", "0.62533724", "0.6213156", "0.6186852", "0.61589515", "0.61540...
0.6743172
2
Builds a list of the indentation level in the text
def parse_text(self): line_number = 0 line_min = 0 while line_number < self.line_count: if self.indentation(self.text[line_number]): self.tab_index.append(self.indent) self.text[line_number] = self.text[line_number].strip() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addIndents(self, prevLevel, nextLevel):\n for num in range(self.level - prevLevel):\n self.textLines[0] = u'<div>%s' % self.textLines[0]\n for num in range(self.level - nextLevel):\n self.textLines[-1] = u'%s</div>' % self.textLines[-1]\n return self.level", "def in...
[ "0.66050494", "0.65871197", "0.65823054", "0.6440294", "0.64322656", "0.6333226", "0.6261572", "0.6217952", "0.61256063", "0.61097354", "0.60586256", "0.60115117", "0.59732586", "0.59445643", "0.5935486", "0.5909733", "0.5906865", "0.5904378", "0.58506644", "0.58386153", "0.5...
0.563083
42
Finds chunks of text with the same indentation level and renders it as one block Invokes cairo and pango to draw the text
def draw(self, width, height): line_spacing = 20 #TODO:Smart algorithm to map mouse position to the scrolling speed #zooming level should go here if self.scroll > 20: self.factor = self.scroll * 0.1 elif self.scroll < -20: self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __indent_text_block(text):\n lines = text.splitlines()\n if len(lines) > 1:\n out = lines[0] + \"\\r\\n\"\n for i in range(1, len(lines)-1):\n out = out + \" \" + lines[i] + \"\\r\\n\"\n out = out + \" \" + lines[-1]\n return out\n return text", "...
[ "0.6800062", "0.63557124", "0.61851245", "0.6127625", "0.6115382", "0.6084938", "0.60630584", "0.6026112", "0.6017145", "0.60155404", "0.5953256", "0.59228796", "0.59067875", "0.58991575", "0.5875876", "0.5869328", "0.5866471", "0.58534825", "0.5838097", "0.58362037", "0.5799...
0.59040713
13
Invalidates the cairo area and updates the pango layout when text needs to be redrawn
def redraw_canvas(self, dy): self.scroll = dy/20 if self.scroll > 0: if self.min_cairo < -20: self.min_cairo = 0 self.min_text += 1 self.max_text += 1 #When bottom of document is reached stop scrolling ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invalidate_canvas(self):\n\n if self.window:\n x, y, w, h = self.get_allocation()\n self.window.invalidate_rect((0,0,w,h), False)\n self.cr = self.window.cairo_create()\n self.cr.update_layout(self.pg)", "def rebuild(self):\n self.set_image(self.ui_ma...
[ "0.6700877", "0.63284457", "0.6169983", "0.61484647", "0.61177415", "0.6110256", "0.6046499", "0.6024855", "0.5980619", "0.59752417", "0.5955907", "0.5922319", "0.5891851", "0.583136", "0.58131385", "0.57919127", "0.5738633", "0.5721444", "0.57081723", "0.5688249", "0.5679972...
0.0
-1
Invalidates the canvas to allow cairo to redraw
def invalidate_canvas(self): if self.window: x, y, w, h = self.get_allocation() self.window.invalidate_rect((0,0,w,h), False) self.cr = self.window.cairo_create() self.cr.update_layout(self.pg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def undraw(self):\n \n if not self.canvas: return\n if not self.canvas.isClosed():\n #self.canvas.delete(self.id)\n _tkExec(self.canvas.delete, self.id)\n if self.canvas.autoflush:\n #_root.update()\n _tkCall(_root.update)\n ...
[ "0.7170448", "0.70177877", "0.6811474", "0.67474014", "0.6741104", "0.65798086", "0.6572473", "0.651364", "0.64646524", "0.6450033", "0.64039034", "0.6386848", "0.6327218", "0.62746847", "0.62502813", "0.6237061", "0.6207101", "0.612459", "0.6124122", "0.6107939", "0.6056458"...
0.8453374
0
Set up the window, events and the UIManager
def __init__(self): __gsignals__ = { 'expose-event' : 'override'} self.filename = "" self.source_id = 0 self.dy = 0 # Create a top level window self.window = gtk.Window() #Get y position of mouse at start of drag self.mouse_click_point...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initializeUI(self):\n self.setGeometry(100, 100, 300, 200)\n self.setWindowTitle('Event Handling Example')\n\n self.show()", "def setupWindow(self):\n\n\t\tself.main_menu_window = MenuFrame.MainMenuFrame(self.uiCoordinator)\n\t\tself.menu_window = self.main_menu_window._mf\n\t\tself.scor...
[ "0.81075317", "0.80308354", "0.7943606", "0.7784395", "0.7664296", "0.7630357", "0.7612189", "0.7465434", "0.7305418", "0.72996294", "0.72887415", "0.71909666", "0.71893406", "0.70785546", "0.70698625", "0.7056159", "0.70504737", "0.6988536", "0.6979893", "0.69747025", "0.692...
0.0
-1
Calls redraw_cavas() and returns True
def continuous_scroll(self, context): self.drawing.redraw_canvas(self.dy) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redraw(self):\r\n self.c.update()", "def redraw(self):\n self.vispy_viewer.canvas.update()", "def redraw_viz():\n\tglobal g_last_draw\n\tif (rospy.Time.now().to_sec() > (refresh_rate + g_last_draw)):\n\t\tg_last_draw = rospy.Time.now().to_sec()\n\t\t# redraw imu box\n\t\tdoDraw()", "def red...
[ "0.6453343", "0.62267697", "0.6218675", "0.60894597", "0.60264426", "0.5925996", "0.58668894", "0.5866463", "0.575936", "0.5751097", "0.5726546", "0.5658623", "0.5649218", "0.5599826", "0.5599826", "0.5561367", "0.55488133", "0.5458545", "0.5447202", "0.54120916", "0.53936327...
0.0
-1
Calls continuous_scroll every 38 ms until drag stops and the gobject.source is removed
def start_refresh(self, widget, context): self.source_id = gobject.timeout_add(38, self.continuous_scroll, context)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def continuous_scroll(self, context):\n\n self.drawing.redraw_canvas(self.dy)\n \n return True", "def on_scroll(self, event):\n if event.button == 'up':\n self.generations += 4000\n elif event.button == 'down':\n if self.generations >= 4000:\n ...
[ "0.67773175", "0.65299225", "0.6115261", "0.6041647", "0.5851163", "0.57974243", "0.5567167", "0.5549752", "0.5510689", "0.54062074", "0.5401114", "0.5395652", "0.53080606", "0.5282082", "0.5279963", "0.52645594", "0.519223", "0.5188579", "0.517752", "0.51675165", "0.5145534"...
0.65430206
1
Handles the drag event. Causes the canvas to be redrawn
def drag_motion(self, widget, context, x, y, t): if self.mouse_click_point: self.dy = y - self.mouse_click_point else: self.mouse_click_point = y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drag(self, event):\n\t\tif len(self.coord_list) > 0:\n\t\t\tself.canvas.create_line(event.x, event.y, \n\t\t\t\tself.coord_list[-1][0], self.coord_list[-1][1])\n\n\t\tself.coord_list.append([event.x, event.y])\n\n\t\tpoly_list = check_contained(self.coord_list) - self.drawn_list\n\t\tfor polygon in poly_list:\...
[ "0.6755301", "0.66262746", "0.6443391", "0.6423392", "0.64204735", "0.64061475", "0.6399093", "0.6296843", "0.6262739", "0.61266", "0.6086573", "0.60591775", "0.6016381", "0.60085255", "0.600779", "0.6007358", "0.60010016", "0.5979957", "0.5976792", "0.5972171", "0.59691787",...
0.53998744
90
Resets the mouse y and t values so they can be reassigned at the start of the next drag
def stop_drag_motion(self, widget, context): gobject.source_remove(self.source_id) self.mouse_click_point = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.t = 0.0\n self.last_t = None\n self.current_y = np.copy(self.start_y)\n self.current_yd = np.copy(self.start_yd)", "def drag_motion(self, widget, context, x, y, t):\n \n if self.mouse_click_point:\n self.dy = y - self.mouse_click_point\...
[ "0.70719177", "0.66845477", "0.6261427", "0.62466776", "0.61253417", "0.60505104", "0.60348666", "0.60143536", "0.59680414", "0.58639413", "0.58259994", "0.578046", "0.5754565", "0.5749707", "0.57274145", "0.56919", "0.568994", "0.568535", "0.5658506", "0.56407124", "0.563473...
0.5843788
10
Opens a file chooser dialog and returns the filename. Canvas is redrawn if a valid file is opened
def open_file(self, widget, data=None): #Displays a fiel chooser dialog dialog = gtk.FileChooserDialog("Open..",None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dia...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_file():\r\n import tkinter\r\n from tkinter import filedialog\r\n\r\n root_window = tkinter.Tk()\r\n root_window.withdraw()\r\n\r\n return filedialog.askopenfilename()", "def filepicker():\n import tkinter as tk\n from tkinter import filedialog\n\n root = tk.Tk()\n root.with...
[ "0.76964045", "0.751905", "0.7503324", "0.72405404", "0.7215795", "0.7140923", "0.71118176", "0.70581174", "0.704689", "0.70024866", "0.6878962", "0.6876016", "0.6872203", "0.68558186", "0.68206304", "0.681948", "0.67540073", "0.67213887", "0.6719352", "0.67114747", "0.670216...
0.68085396
16
CPU kernel for 3d mesh to particles quantity interpolation
def mesh_to_particles_CPU_3d(mesh, mesh_quantity, indices, weights): ip, jp, kp = indices stridex = mesh.nx stridey = mesh.ny mq = np.ravel(mesh_quantity) @np.vectorize def check_outside(ip, jp, kp): outside_idx = (jp < 0 or jp >= mesh.nx - 1 or ip < 0 or ip >= me...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init():\n\tN = np.int32(DIM) #prepare for stitching\n\t#HII_DIM = np.int32(HII_DIM)\n\tf_pixel_factor = DIM/HII_DIM;\n\tscale = np.float32(BOX_LEN)/DIM\n\tHII_scale = np.float32(BOX_LEN)/HII_DIM\n\tshape = (N,N,N)\n\t\n\tMRGgen = MRG32k3aRandomNumberGenerator(seed_getter=seed_getter_uniform, offset=0)\n\n\tker...
[ "0.6445836", "0.6372974", "0.61668825", "0.59983677", "0.5791244", "0.5653549", "0.5652757", "0.56389385", "0.56339914", "0.55467594", "0.55444217", "0.55392367", "0.5479442", "0.5449648", "0.5441298", "0.5424582", "0.54130393", "0.53808963", "0.5377156", "0.5375097", "0.5365...
0.6884111
0
CPU kernel for 3d mesh to particles quantity interpolation
def mesh_to_particles_CPU_2d(mesh, mesh_quantity, indices, weights): ip, jp = indices stridex = mesh.nx mesh_quantity = np.ravel(mesh_quantity) @np.vectorize def check_outside(ip, jp): outside_idx = (jp < 0 or jp >= mesh.nx - 1 or ip < 0 or ip >= mesh.ny - 1) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mesh_to_particles_CPU_3d(mesh, mesh_quantity, indices, weights):\n ip, jp, kp = indices\n stridex = mesh.nx\n stridey = mesh.ny\n mq = np.ravel(mesh_quantity)\n\n @np.vectorize\n def check_outside(ip, jp, kp):\n outside_idx = (jp < 0 or jp >= mesh.nx - 1 or\n ip <...
[ "0.6884111", "0.6445836", "0.61668825", "0.59983677", "0.5791244", "0.5653549", "0.5652757", "0.56389385", "0.56339914", "0.55467594", "0.55444217", "0.55392367", "0.5479442", "0.5449648", "0.5441298", "0.5424582", "0.54130393", "0.53808963", "0.5377156", "0.5375097", "0.5365...
0.6372974
2
Train and test in default environment
def train_and_test(resume_training=False, tensorboard_debug=False, cli_debug=False): if tensorboard_debug: # Open tf debug session connected to tensor board, this only really works well on linux k.set_session(TensorBoardDebugWrapperSession(tf.Session(), '127.0.0.1:6064')) elif cli_debug: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_training():\n assert init_engine('train', [\"config=first_run_test/default.yaml\"]).run() is None", "def test_training(self):\n\t\tpass", "def test_training(self):\n warnings.filterwarnings('ignore')\n example_args = example_args_parser()\n example_args.unittest = True\n ...
[ "0.7525882", "0.7500203", "0.7246843", "0.71062607", "0.69893485", "0.6936413", "0.6892855", "0.68209904", "0.68061465", "0.68000853", "0.6799948", "0.6743294", "0.67357713", "0.67064327", "0.66930574", "0.66568553", "0.66525966", "0.665014", "0.6642741", "0.6628566", "0.6626...
0.6182469
70
reverses a sequence and returns it to the user
def reverse_this(seq): r_seq = seq[::-1] return r_seq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse(seq):\n return seq[::-1]", "def reverse(seq):\n return seq[::-1]", "def reverse(self):\n self._sequence.reverse()", "def reverseComplement(seq):\n seq=seq.upper()\n # complement\n compl = complement(seq)\n # reverse\n return compl[::-1]", "def _reverse_seq(sequence, ...
[ "0.796331", "0.796331", "0.7332736", "0.6942727", "0.6893406", "0.68597776", "0.6836763", "0.67643976", "0.6720687", "0.6716236", "0.6703137", "0.669068", "0.66748995", "0.66173595", "0.6607935", "0.65751666", "0.6458668", "0.6386909", "0.6376833", "0.63744164", "0.6360942", ...
0.7664587
2
constructs a complement of the sequence and returns it to the user
def complement_this(seq): compliment_dict = {'A':'T', 'T':'A', 'C':'G', 'G':'C'} rev_seq = '' for nuc in seq: if nuc in ['A', 'T', 'G', 'C']: rev_seq += compliment_dict[nuc] return rev_seq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complement(seq):\n if PY3:\n table = str.maketrans('ACTGNactg', 'TGACNtgac')\n elif PY2:\n table = string.maketrans('ACTGNactg', 'TGACNtgac')\n return str(seq).translate(table)", "def complement(seq,transl=None):\n transl = string.maketrans('aAcCgGtTnNxX-\\t\\n ','tTgGcCaAnNxX-\\t\\...
[ "0.7661928", "0.7610491", "0.7571766", "0.7463382", "0.7420495", "0.72710407", "0.7256517", "0.7193674", "0.71363926", "0.7096717", "0.6944678", "0.6880034", "0.6877921", "0.68603486", "0.6837575", "0.67390704", "0.6724134", "0.6708142", "0.667533", "0.6671418", "0.665009", ...
0.711648
9
Combines the reverse_this and complement_this function into one
def rev_comp(seq): return(complement_this(reverse_this(seq)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complement_reverse(self):\n self._data.switch_complement(whether=False)\n return self", "def reverse_complement(seq):\n seq = reverse(seq)\n seq = complement(seq)\n return seq", "def __invert__(self):\n return self.reverse()", "def reverseComplement(seq):\n seq=seq.upper(...
[ "0.6944674", "0.6616649", "0.65044445", "0.64138985", "0.6405666", "0.6344894", "0.6276499", "0.62029034", "0.61942494", "0.6179005", "0.6177534", "0.61766183", "0.61220694", "0.6119256", "0.6107478", "0.61074305", "0.6086203", "0.6032122", "0.6007763", "0.5948127", "0.591033...
0.6428619
3
Log the best parameters from optimization to the parent experiment.
def log_best(run: mlflow.entities.Run, metric: str) -> None: client = mlflow.tracking.MlflowClient() runs = client.search_runs( [run.info.experiment_id], "tags.mlflow.parentRunId = '{run_id}' ".format(run_id=run.info.run_id)) best_run = min(runs, key=lambda run: run.data.metri...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_best_performer(self) -> None:\n best = self.get_highest_accuracy()\n self.logger.info(f\"\\n\\nThe model with the highest accuracy {best[0]} has the following characteristics: \\n\")\n for k, v in best[1].items():\n if k != 'best_performer':\n self.logger.info...
[ "0.63622415", "0.6299336", "0.61905897", "0.6175902", "0.61196154", "0.60865855", "0.60865855", "0.60865855", "0.6016687", "0.6003699", "0.5999502", "0.5911572", "0.5862312", "0.58506644", "0.58495724", "0.5821478", "0.5821416", "0.58152115", "0.57748735", "0.5770013", "0.576...
0.0
-1
Make a short score with pick up and two voices.
def makeScoreWithPickup(self): sc = stream.Score() num_voices = 2 pitches = ['C', 'A-'] for i in range(num_voices): part = stream.Part() part.id = 'part %d' % i time_sig = meter.TimeSignature('4/4') key_sig = key.Key('c') # Add pickup measure. pickup = stream.Measure...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeScore(self):\n sc = stream.Score()\n num_voices = 2\n pitches = ['C', 'A-']\n for i in range(num_voices):\n part = stream.Part()\n part.id = 'part %d' % i\n time_sig = meter.TimeSignature('4/4')\n key_sig = key.Key('c')\n\n # Make a note.\n n1 = music21_note.Note(p...
[ "0.6722317", "0.58068377", "0.5768385", "0.57021904", "0.56786025", "0.56589353", "0.5603751", "0.55136603", "0.549756", "0.5485879", "0.54847825", "0.5401103", "0.5356562", "0.5330451", "0.53275734", "0.53220344", "0.52828926", "0.5266709", "0.52593845", "0.5259334", "0.5244...
0.70795625
0
Make a short score with pick up and two voices.
def makeScore(self): sc = stream.Score() num_voices = 2 pitches = ['C', 'A-'] for i in range(num_voices): part = stream.Part() part.id = 'part %d' % i time_sig = meter.TimeSignature('4/4') key_sig = key.Key('c') # Make a note. n1 = music21_note.Note(pitches[i]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeScoreWithPickup(self):\n sc = stream.Score()\n num_voices = 2\n pitches = ['C', 'A-']\n for i in range(num_voices):\n part = stream.Part()\n part.id = 'part %d' % i\n time_sig = meter.TimeSignature('4/4')\n key_sig = key.Key('c')\n\n # Add pickup measure.\n pickup ...
[ "0.70795625", "0.58068377", "0.5768385", "0.57021904", "0.56786025", "0.56589353", "0.5603751", "0.55136603", "0.549756", "0.5485879", "0.54847825", "0.5401103", "0.5356562", "0.5330451", "0.53275734", "0.53220344", "0.52828926", "0.5266709", "0.52593845", "0.5259334", "0.524...
0.6722317
1
Check the key, mode, tonic pitch class extraction from key signature.
def testExtractionOfKeySignatureAttributes(self): num_to_major_key = {0: 'C', 1: 'G', 2: 'D', 3: 'A', 4: 'E', 5: 'B', 6: 'F#', 7: 'C#', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_key(self, key):\n raise NotImplementedError", "def __getKeyInformation( self , flaglist ):\n\t\tkeyinfo = 0\n\t\tif 'HMAC_MD5_RC4' in flaglist:\n\t\t\tkeyinfo = setBit( keyinfo , 0 )\n\t\tif 'HMAC_SHA1_AES' in flaglist:\n\t\t\tkeyinfo = setBit( keyinfo , 1 )\n\t\tif 'group' in flaglist:\n\t\t\t...
[ "0.5945108", "0.57941103", "0.57145506", "0.56614727", "0.55908537", "0.557824", "0.5512754", "0.55084723", "0.54874986", "0.54785895", "0.5465614", "0.5448584", "0.53911096", "0.536824", "0.53185785", "0.5297847", "0.529589", "0.5281158", "0.52718353", "0.52686393", "0.52467...
0.66755116
0
Test pretty_music21 score by comparing to music21 score.
def testCompareScores(self): for score_type, source in self.sources.iteritems(): simple_score = self.simple_scores[score_type] # Check overall length. self.assertAlmostEqual(source.duration.quarterLength / 2.0, simple_score.total_time) # Check number of parts. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_music21(music: \"Music\") -> Score:\n # Create a new score\n score = Score()\n\n # Metadata\n if music.metadata:\n score.append(to_music21_metadata(music.metadata))\n\n # Tracks\n for track in music.tracks:\n # Create a new part\n part = Part()\n part.partName =...
[ "0.6397026", "0.61292386", "0.60153556", "0.5894335", "0.5888303", "0.584743", "0.58399576", "0.58220565", "0.5753058", "0.57522446", "0.5727253", "0.5703115", "0.565216", "0.5651552", "0.5611833", "0.5602852", "0.5571321", "0.5554371", "0.54933465", "0.544632", "0.5432133", ...
0.6417285
0
Test if notes are sorted by start time.
def testSortedNotes(self): for simple_score in self.simple_scores.values(): notes = simple_score.sorted_notes assert all(notes[i].start_time <= notes[i + 1].start_time for i in range(len(notes) - 1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _can_add_note(self, start_step):\n return self.last_on is None or start_step - self.offset > self.last_on", "def order_by_start(self):\n return self.order_by(\"start_time\")", "def cmpBeginDate(artist1, artist2):\n return int(artist1['BeginDate']) < int(artist2['BeginDate'])", "def cmpArtist...
[ "0.61224854", "0.5865765", "0.57295513", "0.55280834", "0.5441577", "0.5399074", "0.53915083", "0.5378046", "0.5370285", "0.53318506", "0.53177214", "0.52837706", "0.52716595", "0.52472234", "0.5236269", "0.52277195", "0.52230084", "0.5207091", "0.5160097", "0.51134276", "0.5...
0.74918807
0
Runs the given command and gathers the output. If a callback is provided, then the output is sent to it, otherwise it is just returned. Optionally, the output of the command can be "watched" and whenever new output is detected, it will be sent to the given `callback`.
def run_cmd(cmd, callback=None, watch=False, background=False, shell=False): if watch and not callback: raise RuntimeError( "You must provide a callback when watching a process." ) output = None if shell: proc = subprocess.Popen(cmd, shell=True, stdout=subpro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AddOutputCallback(self, callback):\n self.output_callbacks.append(callback)", "def execute():\n command_line_args = argv[1:]\n args = cli(command_line_args)\n\n callback = args.callback\n kwargs = {\n k: v\n for k, v in args.__dict__.items()\n if k != \"callback\"\n }\n...
[ "0.60572314", "0.58634955", "0.58029765", "0.5787524", "0.573274", "0.5612282", "0.5592784", "0.5578011", "0.5532359", "0.5510294", "0.55036664", "0.54866433", "0.5473412", "0.5423298", "0.5419067", "0.5387715", "0.53372276", "0.5322813", "0.53072083", "0.53039205", "0.527183...
0.61989796
0
Composes artificial mixtures of host and pathogen reads
def __init__(self, composition: dict, reads: int = 10000, verbose: bool = False): PoreLogger.__init__(self, level=logging.INFO if verbose else logging.ERROR) self.composition = composition self.reads = reads self.check_proportions() self.fastq: dict = self.prepare_fa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmaq_pa_master(paths_and_readers,tslice=None,kslice=None,jslice=None,islice=None):\n from ..pappt.kvextract import tops2shape,pblhghts2tops\n files=[]\n iprf = None\n concf = None\n for p,r in paths_and_readers:\n if not os.path.exists(p):\n raise ValueError, \"File at %s does ...
[ "0.5511749", "0.53719014", "0.5315182", "0.531374", "0.53083897", "0.52912027", "0.52875346", "0.52785015", "0.52527505", "0.52501774", "0.5247675", "0.52469015", "0.5245823", "0.5242995", "0.52415043", "0.52280927", "0.5213287", "0.5211441", "0.52108234", "0.5204272", "0.519...
0.0
-1
Checks file paths of input files and creates indices
def prepare_fastq(self) -> dict: fastq = {} for organism, data in self.composition.items(): file = data['file'] file_path = Path(file) if not file_path.exists(): raise ValueError(f'File {file_path} does not exist.') else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_files():\n\n print(\"Indexing files\")\n\n for root, _, files in os.walk(image_directory):\n for item in files:\n for file_type in file_types:\n if file_type in item:\n images_in_directory.append(os.path.join(root, item))\n\n print(f'Finished i...
[ "0.6722114", "0.6616186", "0.64285046", "0.6245991", "0.61874163", "0.6159094", "0.611452", "0.6091763", "0.60779333", "0.60487247", "0.6039412", "0.59922653", "0.5976259", "0.5961315", "0.5959076", "0.59473675", "0.59240466", "0.5910848", "0.5897322", "0.5875426", "0.5875290...
0.0
-1
Check that proportions in composition file sum to 1
def check_proportions(self): proportions = [ v['proportion'] for k, v in self.composition.items() ] if sum(proportions) < 1.0: raise ValueError('Sum of proportions between host and pathogen must be 1.0.') elif sum(proportions) > 1.0: raise V...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_proportion(control, test):\n return set(control) == set(test) == {0, 1}", "def __call__(self, read, info: ModificationInfo):\n n_count = read.sequence.lower().count('n')\n if self.is_proportion:\n if len(read) == 0:\n return False\n return n_count / l...
[ "0.6806141", "0.6376372", "0.63674873", "0.6106981", "0.59485376", "0.59462976", "0.5868693", "0.58353674", "0.5807831", "0.5794899", "0.57598245", "0.57089925", "0.56516993", "0.5600838", "0.55719936", "0.5553505", "0.5544299", "0.5544022", "0.5519452", "0.55115443", "0.5487...
0.7553237
0
Compose an artifical mixture of reads Read names / decription headers are renamed according to sequentially numbered keys in the composition file, e.. saureus_0, saureus_1 ... to better distinguish between composition components later.
def compose(self, fout: Path, shuffle: bool = True): self.logger.info('Sample and mix read data') reads_out = [] for organism, fastq in self.fastq.items(): read_names = [read.name for read in fastq] # need to solve iterator for sampling, names avoid memory sampl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rename_headers(reads: list, organism: str):\r\n\r\n i = 0\r\n read_strings = []\r\n for read in reads:\r\n read_str = read.raw.splitlines()\r\n read_str[0] = f'@{organism}_{i}'\r\n read_str = '\\n'.join(read_str)\r\n read_strings.append(read_str)...
[ "0.70786226", "0.56654173", "0.56248975", "0.54763", "0.5253606", "0.52192986", "0.51597726", "0.5147048", "0.51259553", "0.50931907", "0.5083531", "0.5069386", "0.5045505", "0.50086147", "0.49696004", "0.4952995", "0.49505538", "0.49412456", "0.4937527", "0.48982477", "0.489...
0.48016357
29
Clean up the Fastq index files from Pyfastx
def clean(self): for _, data in self.composition.items(): index_file = Path(data['file'] + '.fxi') if index_file.exists(): index_file.unlink()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_index(self):\n if self.index_module:\n self.index_module = None\n gc.collect()", "def cleanup(self):\n index_id = self.params[\"index_id\"]\n\n # Remove the index document from the database.\n self.db.indexes.delete_one({\"_id\": index_id})\n\n ...
[ "0.6486027", "0.6483935", "0.61997026", "0.6186733", "0.6184694", "0.6120797", "0.61112803", "0.61034113", "0.6067713", "0.6043162", "0.6007758", "0.60064405", "0.5943808", "0.59250754", "0.59225947", "0.5922426", "0.59017795", "0.5857676", "0.58406806", "0.583989", "0.583783...
0.7508633
0
Rename read headers from the Pyfastx reads (readonly)
def rename_headers(reads: list, organism: str): i = 0 read_strings = [] for read in reads: read_str = read.raw.splitlines() read_str[0] = f'@{organism}_{i}' read_str = '\n'.join(read_str) read_strings.append(read_str) i += 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reset_header(self):\n new_header = []\n for col_name in self.header:\n is_left = self.left_cols.get(col_name)\n if is_left:\n new_header.append(col_name)\n self.header = new_header", "def modify_bam_header(self, in_bam, out_bam):\n #bam_header...
[ "0.60041726", "0.5952062", "0.59352136", "0.59297824", "0.59085053", "0.588155", "0.58796203", "0.5815924", "0.5812585", "0.56827", "0.5642944", "0.56334716", "0.56306666", "0.56273365", "0.56152153", "0.56103003", "0.55797523", "0.5561919", "0.5546493", "0.55092734", "0.5469...
0.7097539
0
Sample a list of Fastq reads / read names
def sample(fastq: list, reads: int = None, replacement: bool = False): if replacement: sampled_reads = random.choices(fastq, k=reads) else: sampled_reads = random.sample(fastq, k=reads) return sampled_reads
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_read_list(samfile):\n read_sampler = ReadSampler()\n for line in samfile:\n line = sam_utils.SamAlignment(line)\n vals = line.get_aligned_blocks()\n if len(vals) > 1:\n logging.info(\"Skipping gapped read %s %s\"%(line.QNAME, str(vals))) \n read_sampler.a...
[ "0.6420504", "0.6299379", "0.5943049", "0.5809539", "0.5767165", "0.5739098", "0.57060987", "0.5696739", "0.5689907", "0.56789887", "0.55646765", "0.55259854", "0.5509567", "0.5490724", "0.54807556", "0.5477975", "0.54732245", "0.547267", "0.5464326", "0.54481435", "0.5440680...
0.68244636
0
Set item in nested dictionary
def set_nested_item(data_dict: dict, key_list: tuple or list, value): reduce(getitem, key_list[:-1], data_dict)[key_list[-1]] = value return data_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __setitem__(self, key, value):\n self.tree[key] = value", "def visit_dict(self, sydict):\n self.current.update(sydict)", "def set(cls, hierarchical_dict: dict, key: str, value: Any) -> None:\n # split according to '.'\n hierarchical_key = key.split(\".\")\n\n # go over th...
[ "0.66427284", "0.65705705", "0.6513432", "0.650163", "0.6474375", "0.64307684", "0.6408831", "0.63907933", "0.63844234", "0.6381398", "0.6353006", "0.63405037", "0.6324578", "0.63165903", "0.63117933", "0.63100886", "0.63035226", "0.6276476", "0.62579644", "0.6254745", "0.622...
0.77281743
0
Plot the loss curves
def plot_history(trials, tid, scores=["loss", "f1", "accuracy"], figsize=(15, 3)): history = trials.train_history(tid) fig = plt.figure(figsize=figsize) for i, score in enumerate(scores): plt.subplot(1, len(scores), i + 1) plt.plot(history[score], label="train") plt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_loss_curve(num_epochs, losses):\n plt.xlabel('Epochs')\n plt.ylabel('Loss') \n plt.title('Loss Curve') \n plt.plot(range(num_epochs), losses)\n plt.show()", "def plot_loss():\n df = pd.read_csv('data/loss.csv', encoding='utf-8')\n loss = df['loss'].values\n val_loss = df['v...
[ "0.8343297", "0.8235588", "0.8180274", "0.7986687", "0.79283375", "0.7702147", "0.769155", "0.76334995", "0.75938815", "0.7522587", "0.750068", "0.7465745", "0.745679", "0.7422474", "0.7414001", "0.7325398", "0.73173654", "0.7295649", "0.7292924", "0.72741723", "0.72360086", ...
0.0
-1
Return a table with model metrics as columns
def metrics_dt(m, datasets, add_eval_metrics={"auc": cem.auc, "auprc": cem.auprc}): data = [{"dataset": k, **eval_model(m, d, add_eval_metrics)} for k, d in datasets.items()] colorder = ["dataset"] + m.metrics_names + list(add_eval_metrics.keys()) return pd.DataFrame(data)[colorder]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_performance_table(self):\n table = Table()\n table.add_column(\"Classifier\", ratio=25)\n table.add_column(\"Score\", ratio=10, justify=\"center\", no_wrap=True)\n table.add_column(\"Params\", ratio=25, no_wrap=False)\n table.add_column(\"Model ID\",ratio=40, no_wrap=...
[ "0.68475515", "0.67694277", "0.6301734", "0.62993044", "0.6283047", "0.6254017", "0.6179174", "0.6083647", "0.6063116", "0.6007498", "0.60040426", "0.5994601", "0.5992395", "0.5990162", "0.5973742", "0.5968707", "0.59684587", "0.5965415", "0.595515", "0.59278136", "0.59160846...
0.56586915
53
returns a list of axes of a variable mv
def allAxes( mv ): if mv is None: return None return mv.getAxisList()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_axes(self) -> VGroup:\n return self.axes", "def get_axes(self) -> VGroup:\n return self.axes", "def axes(self):\n return self._axes", "def axes(self):\n return self._axes", "def axes(*x: Iterable[int]):\n return [_ti_core.Axis(i) for i in x]", "def axes(self) -> np....
[ "0.6138203", "0.6138203", "0.6132842", "0.6132842", "0.6125584", "0.6117667", "0.6023415", "0.59184104", "0.5736616", "0.5717504", "0.57096046", "0.55749345", "0.54218215", "0.5417657", "0.54154396", "0.5380405", "0.52959144", "0.5287406", "0.52542454", "0.5213043", "0.519815...
0.7132127
0
Sometimes we get time units which aren't compatible with cdtime. This function will (try to) fix them. The input argument is a string, e.g. "months since Jan 1979" and the return value is another string, e.g.
def fix_time_units( timeunits ): imon = timeunits.find("months since ") if imon==0: since="months since " else: iday = timeunits.find("days since ") if iday==0: since="days since " else: ihour = timeunits.find("hours since ") if ihour==0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(string):\n units = {'s':1, 'm':60, 'h':60*60, 'd':24*60*60, 'M':30*24*60*60}\n string = string.replace(' ','')\n p = re.compile('(\\d+)\\s*(\\w+)')\n num, unit = p.match(string).groups()\n num = float(num)\n return num * units[unit]", "def clean_unit(unit):\n return 'M' if unit.lower() =...
[ "0.62871355", "0.62632513", "0.6058695", "0.60543835", "0.60210484", "0.6020246", "0.59578264", "0.5928724", "0.5863947", "0.585928", "0.5834382", "0.57287663", "0.56812316", "0.5627189", "0.5626828", "0.5603379", "0.5575414", "0.55661714", "0.5550087", "0.5532709", "0.550852...
0.80670094
0
Input is a variable which depends on latitude. This function will copy it to a new variable, except that the new variable's latitude axis will be restricted to latmin<=lat<=latmax; and of course the data will be restricted to correspond.
def restrict_lat( mv, latmin, latmax ): if latmin==-90: latmin = -91 # just to make sure if latmax==90: latmax = 91 # axes latax,idx = latAxis2(mv) if latax is None: return None imin = min( [i for i in range(len(latax)) if latax[i]>=latmin and latax[i]<=latmax ] ) imax = max( [i for i in ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self):\n return type(self)(self.lat_lon[0], self.lat_lon[1], **self._attrs)", "def latvar( mv ):\n # First get the axis. This is probably not as general as we'll need...\n if mv is None: return None\n lat_axis = latAxis(mv)\n #latmv = mv.clone() # good if mv has only a lat axis\n ...
[ "0.58231395", "0.5813714", "0.56509984", "0.52055085", "0.5196696", "0.51875114", "0.51552486", "0.5142588", "0.5094556", "0.50887316", "0.5085515", "0.50473696", "0.504018", "0.49421754", "0.4902313", "0.48965225", "0.4887742", "0.486856", "0.48649704", "0.48557973", "0.4848...
0.7229858
0
returns the mean of the variable over the supplied latitude range (in degrees, based on values of lat, not lat_bnds) The computed quantity is a scalar but is returned as a cdms2 variable, i.e. a MV. The input mv is a cdms2 variable, assumed to be indexed as is usual for CFcompliant variables, i.e. mv(time,lat,lon). At ...
def reduce2scalar_zonal_old( mv, latmin=-90, latmax=90, vid=None ): # For now, I'm assuming that the only axes are time,lat,lon - so that zm is a scalar. # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average) # If they aren't, it's best to use area from cell_measures a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2scalar_zonal( mv, latmin=-90, latmax=90, vid=None ):\n if vid==None:\n vid = 'reduced_'+mv.id\n axes = allAxes( mv )\n ilat = None\n for i,ax in enumerate(axes):\n if ax.id=='lat': ilat = i\n # reduce size of lat axis to (latmin,latmax)\n # Let's home a direct search will...
[ "0.67416596", "0.6548467", "0.6509797", "0.62889326", "0.6226794", "0.6226794", "0.6008768", "0.59134054", "0.5877358", "0.57791483", "0.5682933", "0.5665746", "0.55882084", "0.55698764", "0.55633837", "0.55565643", "0.55452055", "0.55107474", "0.5478772", "0.54400945", "0.53...
0.6658991
1
returns the mean of the variable over the supplied latitude range (in degrees, based on values of lat, not lat_bnds) The computed quantity is a scalar but is returned as a cdms2 variable, i.e. a MV. The input mv is a cdms2 variable too. This function uses the cdms2 avarager() function to handle weights and do averages
def reduce2scalar_zonal( mv, latmin=-90, latmax=90, vid=None ): if vid==None: vid = 'reduced_'+mv.id axes = allAxes( mv ) ilat = None for i,ax in enumerate(axes): if ax.id=='lat': ilat = i # reduce size of lat axis to (latmin,latmax) # Let's home a direct search will be fast enou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2scalar_zonal_old( mv, latmin=-90, latmax=90, vid=None ):\n # For now, I'm assuming that the only axes are time,lat,lon - so that zm is a scalar.\n # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average)\n # If they aren't, it's best to use area from cell_me...
[ "0.6483892", "0.6449936", "0.63286823", "0.6259683", "0.6259683", "0.60817444", "0.59398943", "0.5792978", "0.5686484", "0.5672774", "0.5669752", "0.5493353", "0.548496", "0.5436766", "0.541976", "0.541753", "0.5412601", "0.54037213", "0.53908765", "0.53008914", "0.529571", ...
0.65369064
0
averages mv over the full range all axes, to a single scalar. Uses the averager module for greater capabilities
def reduce2scalar( mv, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id axes = allAxes( mv ) axis_names = [ a.id for a in axes ] axes_string = '('+')('.join(axis_names)+')' avmv = averager( mv, axis=axes_string ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mean(self):\r\n for i in range(1,len(self.data[0])):\r\n self.prom.append(np.mean(self.data[:,i]))", "def manual_mean(arr):\n my_sum = 0\n for i in range(0, arr.shape[0]):\n for j in range(0, arr.shape[1]):\n my_sum += arr[i,j]\n return my_sum / arr.si...
[ "0.6626889", "0.63578427", "0.625352", "0.6220642", "0.619339", "0.6153601", "0.61507607", "0.61103404", "0.61103404", "0.6092938", "0.60919166", "0.6082729", "0.602311", "0.6023065", "0.60227084", "0.6014731", "0.59958345", "0.59730744", "0.5966355", "0.5960948", "0.5960868"...
0.6819693
0
returns the mean of the variable over all axes but latitude, as a cdms2 variable, i.e. a MV. The input mv is a also cdms2 variable, assumed to be indexed as is usual for CFcompliant variables, i.e. mv(time,lat,lon). At present, no other axes (e.g. level) are supported. At present mv must depend on all three axes.
def reduce2lat_old( mv, vid=None ): # >>> For now, I'm assuming that the only axes are time,lat,lon # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average) # If they aren't, it's best to use area from cell_measures attribute if available; otherwise # compute it with...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2lat( mv, vid=None ):\n if vid==None: # Note that the averager function returns a variable with meaningless id.\n vid = 'reduced_'+mv.id\n axes = allAxes( mv )\n axis_names = [ a.id for a in axes if a.id!='lat' ]\n axes_string = '('+')('.join(axis_names)+')'\n\n avmv = averager( m...
[ "0.6196711", "0.61690545", "0.6022679", "0.5879041", "0.57352066", "0.56729776", "0.5658441", "0.56343806", "0.56343806", "0.5478811", "0.54540074", "0.5406501", "0.5377368", "0.53606015", "0.53185415", "0.5281884", "0.52813756", "0.5268177", "0.525204", "0.52350086", "0.5188...
0.6457875
0
as reduce2lat_old, but uses the averager module for greater capabilities
def reduce2lat( mv, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id axes = allAxes( mv ) axis_names = [ a.id for a in axes if a.id!='lat' ] axes_string = '('+')('.join(axis_names)+')' avmv = averager( mv, axis=axes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2lat_old( mv, vid=None ):\n # >>> For now, I'm assuming that the only axes are time,lat,lon\n # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average)\n # If they aren't, it's best to use area from cell_measures attribute if available; otherwise\n # comput...
[ "0.71746695", "0.7159011", "0.693063", "0.6655468", "0.6433842", "0.60125995", "0.59771603", "0.5941421", "0.5817719", "0.57721925", "0.57491624", "0.57213616", "0.5685925", "0.5673032", "0.559728", "0.5517831", "0.544977", "0.5412728", "0.53823274", "0.53628594", "0.5176197"...
0.7389955
0
as reduce2lat, but averaging reduces coordinates to (lev,lat)
def reduce2levlat( mv, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id if levAxis(mv) is None: return None if latAxis(mv) is None: return None axes = allAxes( mv ) timeax = timeAxis(mv) if timeax.getBounds()==No...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2lat( mv, vid=None ):\n if vid==None: # Note that the averager function returns a variable with meaningless id.\n vid = 'reduced_'+mv.id\n axes = allAxes( mv )\n axis_names = [ a.id for a in axes if a.id!='lat' ]\n axes_string = '('+')('.join(axis_names)+')'\n\n avmv = averager( m...
[ "0.69857925", "0.6807853", "0.6773293", "0.6564294", "0.6501866", "0.64869905", "0.6404557", "0.6294769", "0.59781444", "0.595413", "0.5908495", "0.5811801", "0.5792106", "0.577163", "0.57321805", "0.5651219", "0.55763006", "0.5573147", "0.5571079", "0.5546693", "0.55466807",...
0.6961548
1
as reduce2levlat, but data is averaged only for time restricted to the specified season; as in reduce2lat_seasona.
def reduce2levlat_seasonal( mv, seasons=seasonsyr, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id if levAxis(mv) is None: return None if latAxis(mv) is None: return None axes = allAxes( mv ) timeax = timeAxis(mv) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2latlon_seasonal( mv, seasons=seasonsyr, vid=None ):\n # This differs from reduce2lat_seasonal only in the line \"axis_names =\"....\n # I need to think about how to structure the code so there's less cut-and-paste!\n if vid==None:\n vid = 'reduced_'+mv.id\n # Note that the averager fu...
[ "0.75936365", "0.74594027", "0.688166", "0.6238695", "0.61847365", "0.6133317", "0.60225564", "0.5992159", "0.58987415", "0.5852854", "0.5766803", "0.5747153", "0.555478", "0.54478663", "0.5436463", "0.5383689", "0.53339547", "0.53088355", "0.5280703", "0.5271107", "0.5259503...
0.74663657
1
as reduce2lat, but averaging reduces coordinates to (lat,lon)
def reduce2latlon( mv, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id axes = allAxes( mv ) axis_names = [ a.id for a in axes if a.id!='lat' and a.id!='lon' ] axes_string = '('+')('.join(axis_names)+')' for ax in ax...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gavg(idata):\n\t\n\twgt1=np.cos(np.deg2rad(idata.lat))*(idata*0+1)\n\tga=(wgt1*idata).sum(dim=['lat','lon'])/wgt1.sum(dim=['lat','lon'])\n\n\treturn ga", "def _sum_over_lat_lon(arr):\n return arr.sum(internal_names.LAT_STR).sum(internal_names.LON_STR)", "def reduce2lat( mv, vid=None ):\n if vid==None...
[ "0.6802166", "0.6642348", "0.6556299", "0.6508638", "0.6453023", "0.6349028", "0.63084924", "0.6272458", "0.61608815", "0.6047154", "0.59499687", "0.591246", "0.58452344", "0.58440655", "0.5839892", "0.58179414", "0.58040535", "0.5800975", "0.5782415", "0.5766302", "0.5753359...
0.66085106
2
as reduce2lat, but averaging reduces only the time coordinate
def reduce_time( mv, vid=None ): if vid==None: # Note that the averager function returns a variable with meaningless id. vid = 'reduced_'+mv.id axes = allAxes( mv ) axis_names = [ a.id for a in axes if a.id=='time' ] axes_string = '('+')('.join(axis_names)+')' if len(axes_string)>2: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2scalar_zonal_old( mv, latmin=-90, latmax=90, vid=None ):\n # For now, I'm assuming that the only axes are time,lat,lon - so that zm is a scalar.\n # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average)\n # If they aren't, it's best to use area from cell_me...
[ "0.6574507", "0.65092766", "0.6464141", "0.6426075", "0.6411295", "0.61637866", "0.61182755", "0.59607893", "0.5948452", "0.59184855", "0.590027", "0.5854279", "0.58315974", "0.57817066", "0.57384855", "0.5659206", "0.5647667", "0.56162596", "0.56059456", "0.5603186", "0.5548...
0.5652815
16
as reduce2lat, but data is used only for time restricted to the specified season. The season is specified as an object of type cdutil.ties.Seasons, and defaults to the whole year. The returned variable will still have a time axis, with one value per season specified.
def reduce2lat_seasonal( mv, seasons=seasonsyr, vid=None ): if vid==None: vid = 'reduced_'+mv.id # Note that the averager function returns a variable with meaningless id. # The climatology function returns the same id as mv, which we also don't want. # The slicers in time.py require getBounds()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2latlon_seasonal( mv, seasons=seasonsyr, vid=None ):\n # This differs from reduce2lat_seasonal only in the line \"axis_names =\"....\n # I need to think about how to structure the code so there's less cut-and-paste!\n if vid==None:\n vid = 'reduced_'+mv.id\n # Note that the averager fu...
[ "0.67101383", "0.61974657", "0.6165893", "0.57036895", "0.54976517", "0.5443406", "0.5429207", "0.5275951", "0.5232346", "0.52280706", "0.5203124", "0.5159468", "0.515358", "0.51510376", "0.5138082", "0.50527817", "0.50496626", "0.5037915", "0.49941966", "0.4983268", "0.49606...
0.6925929
0
as reduce2lat_seasonal, but both lat and lon axes are retained.
def reduce2latlon_seasonal( mv, seasons=seasonsyr, vid=None ): # This differs from reduce2lat_seasonal only in the line "axis_names =".... # I need to think about how to structure the code so there's less cut-and-paste! if vid==None: vid = 'reduced_'+mv.id # Note that the averager function retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2lat_seasonal( mv, seasons=seasonsyr, vid=None ):\n if vid==None:\n vid = 'reduced_'+mv.id\n # Note that the averager function returns a variable with meaningless id.\n # The climatology function returns the same id as mv, which we also don't want.\n\n # The slicers in time.py require ...
[ "0.7120988", "0.65913016", "0.5912345", "0.58565855", "0.5846651", "0.5827005", "0.5757517", "0.5742788", "0.56260955", "0.5573889", "0.5551024", "0.5517785", "0.5454073", "0.5447219", "0.5380435", "0.5367206", "0.53613245", "0.5329884", "0.52797866", "0.527883", "0.5270271",...
0.7579458
0
as reduce2lat_seasonal, but all nontime axes are retained.
def reduce_time_seasonal( mv, seasons=seasonsyr, vid=None ): if vid==None: vid = 'reduced_'+mv.id # Note that the averager function returns a variable with meaningless id. # The climatology function returns the same id as mv, which we also don't want. # The slicers in time.py require getBounds(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2latlon_seasonal( mv, seasons=seasonsyr, vid=None ):\n # This differs from reduce2lat_seasonal only in the line \"axis_names =\"....\n # I need to think about how to structure the code so there's less cut-and-paste!\n if vid==None:\n vid = 'reduced_'+mv.id\n # Note that the averager fu...
[ "0.74530834", "0.70475537", "0.6324904", "0.59645534", "0.5937632", "0.58018863", "0.57699883", "0.57024586", "0.5577448", "0.5530543", "0.54834914", "0.54797405", "0.5413724", "0.5400654", "0.5268981", "0.51579803", "0.5137244", "0.5122184", "0.5121492", "0.5113712", "0.5081...
0.5721398
7
Input is a leveldependent variable mv and a level slev to select. slev is an instance of udunits thus it has a value and a units attribute. This function will create and return a new variable mvs without a level axis. The values of mvs correspond to the values of mv with level set to slev. Interpolation isn't done yet,...
def select_lev( mv, slev ): levax = levAxis(mv) # Get ig, the first index for which levax[ig]>slev # Assume that levax values are monotonic. dummy,slev = reconcile_units( levax, slev ) # new slev has same units as levax if levax[0]<=levax[-1]: ids = numpy.where( levax[:]>=slev.value ) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def levvar( mv ):\n # First get the axis. This is probably not as general as we'll need...\n if mv is None: return None\n lev_axis = levAxis(mv)\n #levmv = mv.clone() # good if mv has only a lev axis\n #levmv[:] = lev_axis[:]\n levmv = cdms2.createVariable( lev_axis[:], axes=[lev_axis], id='lev...
[ "0.67565304", "0.6339013", "0.5813282", "0.55218333", "0.55123705", "0.54566956", "0.54150814", "0.5345006", "0.53043866", "0.52986836", "0.5298433", "0.5282433", "0.5152977", "0.5144597", "0.50879806", "0.50478345", "0.50315887", "0.5008072", "0.5002643", "0.49997583", "0.49...
0.77553666
0
returns a transient variable which is dimensioned along the lat axis but whose values are the latitudes
def latvar( mv ): # First get the axis. This is probably not as general as we'll need... if mv is None: return None lat_axis = latAxis(mv) #latmv = mv.clone() # good if mv has only a lat axis #latmv[:] = lat_axis[:] latmv = cdms2.createVariable( lat_axis[:], axes=[lat_axis], id='lat', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latlons(self):\n\t\t\n\t\t# First check we have a grid feature type\n\t\tif self.featuretype in ['Grid', 'GridSeries']:\n\n\t\t\tlatvar = self.latitude_variable\n\t\t\tlonvar = self.longitude_variable\n\n\t\t\tlatdims = self.coordinates_mapping['latitude']['map']\n\t\t\tlondims = self.coordinates_mapping['long...
[ "0.67513454", "0.66928744", "0.6395381", "0.63260347", "0.61951125", "0.61491525", "0.613318", "0.6064862", "0.6063187", "0.6053654", "0.6050005", "0.6028488", "0.5952476", "0.58669955", "0.5862181", "0.5862181", "0.58513904", "0.58510435", "0.5826054", "0.58009094", "0.58002...
0.74743557
0
returns a transient variable which is dimensioned along the lon axis but whose values are the longitudes
def lonvar( mv ): # First get the axis. This is probably not as general as we'll need... if mv is None: return None lon_axis = lonAxis(mv) latmv = cdms2.createVariable( lon_axis[:], axes=[lon_axis], id='lon', attributes={'units':lon_axis.units}, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latvar( mv ):\n # First get the axis. This is probably not as general as we'll need...\n if mv is None: return None\n lat_axis = latAxis(mv)\n #latmv = mv.clone() # good if mv has only a lat axis\n #latmv[:] = lat_axis[:]\n latmv = cdms2.createVariable( lat_axis[:], axes=[lat_axis], id='lat...
[ "0.67902434", "0.6771255", "0.67498714", "0.6621353", "0.6568897", "0.6417901", "0.617368", "0.61442626", "0.6087874", "0.60350233", "0.5941551", "0.59397936", "0.5933728", "0.5912952", "0.5898972", "0.58715075", "0.5850327", "0.57997036", "0.579611", "0.5794126", "0.57769763...
0.7568185
0
returns a transient variable which is dimensioned along the lev (level) axis but whose values are the levels
def levvar( mv ): # First get the axis. This is probably not as general as we'll need... if mv is None: return None lev_axis = levAxis(mv) #levmv = mv.clone() # good if mv has only a lev axis #levmv[:] = lev_axis[:] levmv = cdms2.createVariable( lev_axis[:], axes=[lev_axis], id='lev', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_lev( mv, slev ):\n levax = levAxis(mv)\n # Get ig, the first index for which levax[ig]>slev\n # Assume that levax values are monotonic.\n dummy,slev = reconcile_units( levax, slev ) # new slev has same units as levax\n if levax[0]<=levax[-1]:\n ids = numpy.where( levax[:]>=slev.va...
[ "0.61772287", "0.60954696", "0.6019012", "0.5921437", "0.57173896", "0.56935555", "0.55191696", "0.55090266", "0.5501754", "0.5488749", "0.5447241", "0.5427211", "0.54218185", "0.54218185", "0.54218185", "0.5372012", "0.5331837", "0.52983266", "0.52873015", "0.5285758", "0.52...
0.7218306
0
From a variable or axis of pressures, this function converts to millibars, and returns the result as a numpy array.
def pressures_in_mb( pressures ): if not hasattr( pressures, 'units' ): return None if pressures.units=='mb': pressures.units = 'mbar' # udunits uses mb for something else return pressures[:] tmp = udunits(1.0,pressures.units) s,i = tmp.how('mbar') pressmb = s*pressures[:] + i re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale_mag_1(x):\n return np.array([np.true_divide(ui, mag(x)) for ui in x])", "def cm2inch(x: Union[float, Sequence[float], NDArray]) -> Sequence[float]:\n return list(np.array(x) / 2.54)", "def convertUnits(self, varname, arr):\n if varname == \"SPDQ\" or varname == \"PHQ\":\n retu...
[ "0.50821847", "0.50635743", "0.5063201", "0.5052912", "0.50040376", "0.49670303", "0.48602846", "0.47888026", "0.47871676", "0.47724292", "0.47648123", "0.47488585", "0.46842295", "0.46627557", "0.46367168", "0.46319687", "0.4622999", "0.46144953", "0.46112272", "0.45830104", ...
0.5553397
0
returns a transient variable which is dimensioned along the lev (level) axis and whose values are the heights corresponding to the pressure levels found as the lev axis of mv. Levels will be converted to millibars. heights are returned in km
def heightvar( mv ): if mv is None: return None lev_axis = levAxis(mv) heights = 0.001 * press2alt.press2alt( pressures_in_mb(lev_axis) ) # 1000 m = 1 km heightmv = cdms2.createVariable( heights, axes=[lev_axis], id=mv.id, attributes={'units':"km"} ) return heig...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def levvar( mv ):\n # First get the axis. This is probably not as general as we'll need...\n if mv is None: return None\n lev_axis = levAxis(mv)\n #levmv = mv.clone() # good if mv has only a lev axis\n #levmv[:] = lev_axis[:]\n levmv = cdms2.createVariable( lev_axis[:], axes=[lev_axis], id='lev...
[ "0.6776988", "0.6006147", "0.590526", "0.5898939", "0.55466783", "0.54994154", "0.547498", "0.5466537", "0.5447086", "0.54124725", "0.5391253", "0.5389002", "0.53862095", "0.5358909", "0.5290569", "0.5286262", "0.5192268", "0.51763445", "0.5174741", "0.51733345", "0.5168547",...
0.77257425
0
returns a transient variable which is dimensioned as whichever of mv1, mv2 has the fewest latitude points but whose values are the latitudes
def latvar_min( mv1, mv2 ): if mv1 is None: return None if mv2 is None: return None lat_axis1 = latAxis(mv1) lat_axis2 = latAxis(mv2) if len(lat_axis1)<=len(lat_axis2): lat_axis = lat_axis1 mv = mv1 else: lat_axis = lat_axis2 mv = mv2 latmv = cdms2.createVaria...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lonvar_min( mv1, mv2 ):\n if mv1 is None: return None\n if mv2 is None: return None\n lon_axis1 = lonAxis(mv1)\n lon_axis2 = lonAxis(mv2)\n if len(lon_axis1)<=len(lon_axis2):\n lon_axis = lon_axis1\n mv = mv1\n else:\n lon_axis = lon_axis2\n mv = mv2\n lonmv = c...
[ "0.69351184", "0.62349105", "0.6094042", "0.5838326", "0.5824384", "0.58051234", "0.57359993", "0.5527261", "0.5517576", "0.5458443", "0.54356056", "0.5415327", "0.54134643", "0.54001105", "0.5361201", "0.52343124", "0.52035445", "0.51936215", "0.5187855", "0.51732856", "0.51...
0.73494667
0
returns a transient variable which is dimensioned as whichever of mv1, mv2 has the fewest longitude points but whose values are the longitudes
def lonvar_min( mv1, mv2 ): if mv1 is None: return None if mv2 is None: return None lon_axis1 = lonAxis(mv1) lon_axis2 = lonAxis(mv2) if len(lon_axis1)<=len(lon_axis2): lon_axis = lon_axis1 mv = mv1 else: lon_axis = lon_axis2 mv = mv2 lonmv = cdms2.createVaria...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latvar_min( mv1, mv2 ):\n if mv1 is None: return None\n if mv2 is None: return None\n lat_axis1 = latAxis(mv1)\n lat_axis2 = latAxis(mv2)\n if len(lat_axis1)<=len(lat_axis2):\n lat_axis = lat_axis1\n mv = mv1\n else:\n lat_axis = lat_axis2\n mv = mv2\n latmv = c...
[ "0.68968886", "0.66709334", "0.6106323", "0.59900844", "0.5892058", "0.57636064", "0.57299185", "0.5693455", "0.5671543", "0.56326985", "0.5609396", "0.5597439", "0.5474902", "0.5423528", "0.5386049", "0.53539693", "0.5313379", "0.5313333", "0.53117704", "0.53086036", "0.5308...
0.7268381
0
returns a transient variable which is dimensioned as whichever of mv1, mv2 has the fewest level points but whose values are the levels
def levvar_min( mv1, mv2 ): if mv1 is None: return None if mv2 is None: return None lev_axis1 = levAxis(mv1) lev_axis2 = levAxis(mv2) if len(lev_axis1)<=len(lev_axis2): lev_axis = lev_axis1 mv = mv1 else: lev_axis = lev_axis2 mv = mv2 levmv = cdms2.createVaria...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_lev( mv, slev ):\n levax = levAxis(mv)\n # Get ig, the first index for which levax[ig]>slev\n # Assume that levax values are monotonic.\n dummy,slev = reconcile_units( levax, slev ) # new slev has same units as levax\n if levax[0]<=levax[-1]:\n ids = numpy.where( levax[:]>=slev.va...
[ "0.60400754", "0.5711261", "0.53916866", "0.5316189", "0.5314503", "0.5262245", "0.5258733", "0.5256473", "0.52382195", "0.5228566", "0.5206168", "0.51694137", "0.51330495", "0.51280445", "0.51269424", "0.5126678", "0.5115695", "0.51080126", "0.50934094", "0.5042593", "0.5039...
0.65224934
0
interpolates a variable mv along its second axis, normally latitude, so as to match the new axis (which should be coarser, i.e. fewer points), and returns a numpy array of the interpolated values. The first axis is normally levels, and isn't expected to be very large (usually <20; surely <50) There shall be no more tha...
def interp2( newaxis1, mv ): missing = mv.get_fill_value() axes = allAxes(mv) if len(newaxis1[:])>len(axes[1][:]): return mv new_vals = numpy.ma.masked_all( ( len(axes[0]), len(newaxis1[:]) ) ) for i in range(len( axes[0] )): new_vals[i,:] = numpy.interp( newaxis1[:], axes[1][:], mv[i,:], l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce2lat_old( mv, vid=None ):\n # >>> For now, I'm assuming that the only axes are time,lat,lon\n # And I'm assuming equal spacing in lon (so all longitudes contribute equally to the average)\n # If they aren't, it's best to use area from cell_measures attribute if available; otherwise\n # comput...
[ "0.6127793", "0.61027855", "0.6082101", "0.59283215", "0.5838112", "0.57578194", "0.5623196", "0.5599504", "0.55420876", "0.54633516", "0.5410154", "0.5350282", "0.5312561", "0.52844816", "0.52626956", "0.5179751", "0.5162937", "0.5137714", "0.5093342", "0.5058199", "0.503866...
0.62990654
0
returns mv1[0,]mv2[0,]; they should be dimensioned alike. Attributes will be fixed up where I know how.
def aminusb0( mv1, mv2 ): mv = mv1[0,] - mv2[0,] if hasattr(mv,'long_name'): if mv.long_name==mv1.long_name: # They're different, shouldn't have the same long_name mv.long_name = '' return mv
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _gu_matvec(x1, x2):\n return (x1 @ x2[..., np.newaxis])[..., 0]", "def get_molecular_matrix_and_vector(single_body, two_body):\n x, y = single_body.shape\n func = np.vectorize(round_custom)\n _new_dim = x * y\n single_one_dim = func(single_body.reshape(_new_dim, 1))\n two_body_two_dim = fun...
[ "0.5995994", "0.5515784", "0.5483453", "0.5478269", "0.5441555", "0.5402159", "0.5384988", "0.5359179", "0.52837175", "0.5270582", "0.5260968", "0.5260383", "0.525911", "0.5228595", "0.5210489", "0.5195151", "0.5183675", "0.51530695", "0.51313037", "0.51037055", "0.5097388", ...
0.56507003
1
returns a transient variable representing mv1mv2, where mv1 and mv2 are variables with exactly two axes, with the first axis the same for each (but it's ok to differ only in units, which could be converted). To perform the subtraction, one of the variables is linearly interpolated in its second dimension to the second ...
def aminusb_ax2( mv1, mv2 ): if hasattr(mv1,'units') and hasattr(mv2,'units') and mv1.units!=mv2.units: print "WARING: aminusb_ax2 is subtracting variables with different units!",mv1,mv1 axes1 = allAxes(mv1) axes2 = allAxes(mv2) # TO DO: convert, interpolate, etc. as needed to accomodate differi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aminusb_1ax( mv1, mv2 ):\n mv1, mv2 = reconcile_units( mv1, mv2 )\n if hasattr(mv1,'units') and hasattr(mv2,'units') and mv1.units!=mv2.units:\n print \"WARNING: aminusb_1ax1 is subtracting variables with different units!\",mv1,mv1\n if mv1 is None or mv2 is None: return None\n missing = mv1...
[ "0.6669163", "0.64997256", "0.6459063", "0.6129442", "0.59882194", "0.5982143", "0.59319377", "0.59233034", "0.58952814", "0.5881865", "0.585033", "0.5835218", "0.57343096", "0.5712189", "0.5709772", "0.56709397", "0.5657024", "0.563904", "0.56342083", "0.5616154", "0.5580523...
0.6472477
2
returns a transient variable representing mv1mv2, where mv1 and mv2 are variables, normally transient variables, which depend on exactly two axes, typically lonlat. To perform the subtraction, the variables will be interpolated as necessary to the axes which are minimal (fewest points) in each direction. Note that if m...
def aminusb_2ax( mv1, mv2 ): return mv2 mv1, mv2 = reconcile_units( mv1, mv2 ) missing = mv1.get_fill_value() axes1 = allAxes(mv1) axes2 = allAxes(mv2) if axes1 is None or axes2 is None: return None if len(axes1)!=2: print "ERROR @1, wrong number of axes for aminusb_2ax",axes1 if len(axe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aminusb_1ax( mv1, mv2 ):\n mv1, mv2 = reconcile_units( mv1, mv2 )\n if hasattr(mv1,'units') and hasattr(mv2,'units') and mv1.units!=mv2.units:\n print \"WARNING: aminusb_1ax1 is subtracting variables with different units!\",mv1,mv1\n if mv1 is None or mv2 is None: return None\n missing = mv1...
[ "0.6842053", "0.6623479", "0.6418362", "0.6201654", "0.6115403", "0.6079604", "0.6074351", "0.588521", "0.5873079", "0.5828353", "0.57805383", "0.5740809", "0.5714796", "0.56725395", "0.56446743", "0.55954033", "0.55467427", "0.55024266", "0.5496881", "0.5487313", "0.54748785...
0.5110343
38
returns a transient variable representing mv1mv2, where mv1 and mv2 are variables, normally transient variables, which are required to depend only one axis. To perform the subtraction, one of the variables is linearly interpolated to the axis of the other. The axis used will be the coarsest (fewest points) of the two a...
def aminusb_1ax( mv1, mv2 ): mv1, mv2 = reconcile_units( mv1, mv2 ) if hasattr(mv1,'units') and hasattr(mv2,'units') and mv1.units!=mv2.units: print "WARNING: aminusb_1ax1 is subtracting variables with different units!",mv1,mv1 if mv1 is None or mv2 is None: return None missing = mv1.get_fill_va...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def basic_sub(mv1, mv2):\n obj = expand(mv1.obj - mv2.obj)\n return MV(obj)", "def displacement(cls, v1, v2):\n return np.array([v2 - v1])", "def aminusb_ax2( mv1, mv2 ):\n if hasattr(mv1,'units') and hasattr(mv2,'units') and mv1.units!=mv2.units:\n print \"WARING: aminusb_ax2 is...
[ "0.6467121", "0.6038152", "0.60112774", "0.598649", "0.5940264", "0.59214985", "0.5907114", "0.5860278", "0.5774416", "0.57667285", "0.5750668", "0.56914055", "0.5675003", "0.5616137", "0.56054354", "0.5589946", "0.5553921", "0.55365384", "0.55223125", "0.5514815", "0.5504505...
0.66377026
0
Returns time averages of the cems2 variable mv. The average is comuted only over times which lie in the specified season(s). The returned variable has the same number of dimensions as mv, but the time axis has been reduced to the number of seasons requested. The seasons are specified as an object of type cdutil.times.S...
def timeave_seasonal( mv, seasons=seasonsyr ): return seasons.climatology(mv)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce_time_seasonal( mv, seasons=seasonsyr, vid=None ):\n if vid==None:\n vid = 'reduced_'+mv.id\n # Note that the averager function returns a variable with meaningless id.\n # The climatology function returns the same id as mv, which we also don't want.\n\n # The slicers in time.py require...
[ "0.7113886", "0.68064904", "0.6650361", "0.61950076", "0.5758541", "0.5734643", "0.55560625", "0.54895353", "0.5439703", "0.522154", "0.51681584", "0.5160492", "0.5129565", "0.5069776", "0.50522226", "0.50236505", "0.4989968", "0.49448606", "0.49113876", "0.48840415", "0.4866...
0.6935159
1
Returns a time average of the cdms2 variable mv. mv is a cdms2 variable, assumed to be timedependent and indexed as is usual for CFcompliant variables, i.e. mv(time,...). What's returned is a numpy array, not a cdms2 variable. (I may change this in the future).
def timeave_old( mv ): # I haven't thought yet about how missing values would work with this... # If time intervals be unequal, this will have to be changed... sh = mv.shape # e.g. [312,90,144] for t,lat,lon n = sh[0] # BTW, this is the size of everything else: # n2 = reduce( operator.mul, sh...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce_time( mv, vid=None ):\n if vid==None: # Note that the averager function returns a variable with meaningless id.\n vid = 'reduced_'+mv.id\n axes = allAxes( mv )\n axis_names = [ a.id for a in axes if a.id=='time' ]\n axes_string = '('+')('.join(axis_names)+')'\n if len(axes_string...
[ "0.58772254", "0.569831", "0.54306823", "0.5339006", "0.52570695", "0.5178657", "0.51458687", "0.5114982", "0.5073207", "0.50591934", "0.50121516", "0.5010453", "0.50002575", "0.49653572", "0.49469918", "0.492515", "0.492515", "0.48782063", "0.48579815", "0.4835696", "0.48353...
0.5918535
0
returns a TransientVariable containing the minimum and maximum values of all the variables provided as arguments
def minmin_maxmax( *args ): rmin = min( [ mv.min() for mv in args ] ) rmax = max( [ mv.max() for mv in args ] ) rmv = cdms2.createVariable( [rmin,rmax] ) return rmv
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_minimum():\n return [\n convert_variables([0.78547, 0.78547, 0.78547]),\n ]", "def __minimum_remaining_values(self, unassigned_vars):\n min_var = None\n for var in unassigned_vars:\n if min_var is None:\n min_var = var\n elif len...
[ "0.6460465", "0.61516154", "0.603381", "0.5994661", "0.5891523", "0.5836747", "0.58244497", "0.57395023", "0.5681477", "0.5667921", "0.56678796", "0.5662136", "0.56610906", "0.5639008", "0.562747", "0.5615644", "0.5598546", "0.55895096", "0.5584579", "0.5576427", "0.5575043",...
0.7315337
0
If mv depends on an axis with just one value, create a copy of mv without that axis, and without the corresponding data dimension. Normally this happens when time has been averaged out, but there is still a onevalued time axis left (thus one would normally use id='time'). You can specify the axis id if there might be m...
def delete_singleton_axis( mv, vid=None ): axes = allAxes(mv) saxis = None si = None for i in range(len(axes)): if len(axes[i])==1 and (vid==None or axes[i].id==vid): saxis = axes[i] si = i del axes[si] break if saxis==None: return mv data ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce_time( mv, vid=None ):\n if vid==None: # Note that the averager function returns a variable with meaningless id.\n vid = 'reduced_'+mv.id\n axes = allAxes( mv )\n axis_names = [ a.id for a in axes if a.id=='time' ]\n axes_string = '('+')('.join(axis_names)+')'\n if len(axes_string...
[ "0.6247364", "0.59301597", "0.55981517", "0.55702573", "0.53490317", "0.5049275", "0.49913675", "0.49404666", "0.48569542", "0.4843272", "0.4835321", "0.47630703", "0.47483668", "0.47441968", "0.47385386", "0.46919236", "0.46870866", "0.4654426", "0.46510515", "0.46408376", "...
0.71518254
0
Not much tested I decided against doing overlapping line plots this way. The input arguments are two variables (cdms2 MVs, normally TransientVariables), with whatever compatibility is needed for this function to work. New axes are computed which can be used for both variables. These axes are returned as a list of tuple...
def common_axes( mv1, mv2 ): axes1 = [a[0] for a in mv1.getDomain()] axes2 = [a[0] for a in mv2.getDomain()] if len(axes1)!=len(axes2): print "ERROR. common_axes requires same number of axes in",mv1," and",mv2 return None axes3 = [] for i in range(len(axes1)): axes3.append(c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_axes(self):\n fig = plt.figure(1)\n axs = fig.add_subplot(1, 1, 1)\n fig.clf()\n axs = plt.subplots(1, 2)\n ax1 : plt.axis = axs[0]\n ax2 : plt.axis = axs[1]\n fig.canvas.draw()\n \n line1_t, = ax1.plot([], label='train')\n line1_v, = ...
[ "0.57410544", "0.57360107", "0.5571669", "0.55329823", "0.5515343", "0.54836935", "0.5431624", "0.5425385", "0.5408111", "0.5307821", "0.5279651", "0.5267647", "0.52437675", "0.52202445", "0.51879686", "0.5187689", "0.51863897", "0.5173515", "0.51703244", "0.5135122", "0.5129...
0.63710725
0
Not much tested I decided against doing overlapping line plots this way. The input arguments are two axes (AbstractAxis class), as compatible as necessary for the following to be sensible. This function has 3 return values. It returns a TransientAxis which includes all the points of the input axes. It may be one of the...
def common_axis( axis1, axis2 ): if hasattr( axis1, 'units' ): units1 = axis1.units.lower().replace(' ','_') if axis1.isTime(): axis1.toRelativeTime( units1 ) #probably will change input argument else: units1 = None if hasattr( axis2, 'units' ): units2 = axis2.un...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def common_axes( mv1, mv2 ):\n axes1 = [a[0] for a in mv1.getDomain()]\n axes2 = [a[0] for a in mv2.getDomain()]\n if len(axes1)!=len(axes2):\n print \"ERROR. common_axes requires same number of axes in\",mv1,\" and\",mv2\n return None\n axes3 = []\n for i in range(len(axes1)):\n ...
[ "0.61138195", "0.6088058", "0.6041942", "0.5724058", "0.55722874", "0.54428166", "0.5421346", "0.5317659", "0.53087", "0.52630603", "0.5246884", "0.521855", "0.5203898", "0.5200251", "0.51671886", "0.5156836", "0.51552814", "0.5126504", "0.51036406", "0.5095335", "0.5079292",...
0.69112474
0
Not much tested I decided against doing overlapping line plots this way. Returns a TransientVaraible made by replacing an axis axisold of a TransientVariable mv with a new axis. The new axis will have all points of the old axis, but may have more, thus requiring the new variable to have more missing data. The variable ...
def convert_axis( mv, axisold, axisindnew ): (axisnew, indexina3) = axisindnew axes = allAxes(mv) kold = None for k in range(len(axes)): if axes[k]==axisold: kold=k if kold==None: print "ERROR. convert_axis cannot find axis",axisold," in variable",mv if len(axisold)==len(axisnew)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_axis(self, dim:NamedIndex,\n mapping_or_old:'Union[Mapping[NamedIndex, NamedIndex], NamedIndex]',\n new:'Optional[NamedIndex]'=None):\n\n axes = self[dim] # disable idx_dim access\n # axes = self.get(dim) or self._dim_axes[dim] # dim:'Union[int, Nam...
[ "0.5527314", "0.5408021", "0.5342411", "0.52576274", "0.52193874", "0.52078605", "0.5200823", "0.5182296", "0.5143223", "0.5039198", "0.5026079", "0.49834254", "0.49665734", "0.48400095", "0.48353782", "0.48336178", "0.4820047", "0.48099452", "0.4761784", "0.47465044", "0.471...
0.71285164
0
From a filename, extracts the first part of the filename as the possible name of a family of files; e.g. from 'ts_Amon_bcccsm11_amip_r1i1p1_197901200812.nc' extract and return 'ts_Amon_bcccsm11_amip_r1i1p1'. To distinguish between the end of a file family name and the beginning of the filespecific part of the filename,...
def extract_filefamilyname( self, filename ): matchobject = re.search( r"^.*_\d\d", filename ) if matchobject is None: return filename else: familyname = filename[0:(matchobject.end()-3)] return familyname
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reFileName(str_):\n rv = 'None', str_\n m = re.match(r'((?:[a-zA-Z0-9-]){4,})_(.*)$', str_)\n if m:\n rv = m.group(1), m.group(2)\n else:\n m = re.match(r'(\\d+-\\d+)\\.-\\.(.*)$', str_)\n if m:\n rv = m.group(1), m.group(2)\n return rv", "def parse_rarefaction_...
[ "0.7018564", "0.68886405", "0.6759327", "0.6749364", "0.6716706", "0.6699516", "0.6672866", "0.66605604", "0.6640363", "0.65921485", "0.6585", "0.65480256", "0.6478625", "0.64543766", "0.64543766", "0.6446561", "0.6443001", "0.64351195", "0.6385604", "0.6374533", "0.6354233",...
0.7713043
0
Finds and opens the files containing data required for the variable, Applies the reduction function to the data, and returns an MV. When completed, this will treat missing data as such. At present only CFcompliant files are supported.
def reduce( self, vid=None ): if vid is None: vid = self._vid rows = self._filetable.find_files( self.variableid, time_range=self.timerange, lat_range=self.latrange, lon_range=self.lonrange, level_range=sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_files(self):\n if not self.unbalanced:\n if not self.validation:\n datas={}\n for var in self.variables:\n datas[var]=xr.open_dataset(\n f'/{self.dlfile_directory}/{self.climate}_{self.variable_translate(var).lower()...
[ "0.5547697", "0.51804596", "0.51175356", "0.50851357", "0.49448034", "0.49235836", "0.49108392", "0.49066615", "0.49041834", "0.4902881", "0.48873246", "0.48858833", "0.48858833", "0.48857036", "0.48537314", "0.47822648", "0.47778893", "0.4767607", "0.47633898", "0.4755537", ...
0.62348145
0
Prepare the file locker. Specify the file to lock and optionally the maximum timeout and the delay between each attempt to lock.
def __init__(self, file_name, timeout=10, delay=.05): self.is_locked = False #self.lockfile = os.path.join(os.getcwd(), "%s.lock" % file_name) self.lockfile = file_name + '.lock' self.file_name = file_name self.timeout = timeout self.delay = delay
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, file_name, timeout=10, delay=.05):\n self.is_locked = False\n self.lockfile = os.path.abspath(file_name)\n self.file_name = file_name\n self.timeout = timeout\n self.delay = delay\n self.fd = None", "def __init__(self, protected_file_path, timeout=None...
[ "0.7269624", "0.6982146", "0.69293517", "0.67427164", "0.6594269", "0.6411413", "0.6381823", "0.63453645", "0.63121194", "0.63120097", "0.62144", "0.6043685", "0.59835607", "0.5917388", "0.5861188", "0.577998", "0.5779113", "0.57543266", "0.5674176", "0.56467295", "0.5624611"...
0.72758126
0
Acquire the lock, if possible. If the lock is in use, it check again every `wait` seconds. It does this until it either gets the lock or exceeds `timeout` number of seconds, in which case it throws an exception.
def acquire(self): start_time = time.time() import getpass userName = getpass.getuser() import platform computerName = platform.uname()[1] while True: try: self.fd = os.open(self.lockfile, os.O_CREAT|os.O_EXCL|os.O_RDWR) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acquire(self, timeout=None): \n if self._locked:\n raise RuntimeError(\"lock already locked\")\n result = False\n timer = self.timerClass(timeout)\n timer.start()\n if ExclusiveLock.acquire(self, timeout):\n try:\n while timer.haveT...
[ "0.71883535", "0.7154213", "0.7148563", "0.7108066", "0.70570654", "0.70437825", "0.6900739", "0.68663", "0.67674184", "0.6726042", "0.6638591", "0.6588066", "0.6562686", "0.63730717", "0.63200384", "0.6303491", "0.6290304", "0.6253313", "0.619019", "0.6133735", "0.612871", ...
0.57434064
43
Get rid of the lock by deleting the lockfile. When working in a `with` statement, this gets automatically called at the end.
def release(self): if self.is_locked: os.close(self.fd) os.unlink(self.lockfile) self.is_locked = False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release_lock():\n lock_file = get_lock_file()\n if exists(lock_file):\n LOG.info('Removing lock file %r' % lock_file)\n os.unlink(lock_file)\n else:\n LOG.warning('Lock file %r did not exist.' % lock_file)", "def release(self):\n fcntl.flock(self.lock_file, fcntl.LOCK_UN)...
[ "0.84547544", "0.8364578", "0.8101169", "0.80762964", "0.8035398", "0.80157477", "0.7947669", "0.793357", "0.788736", "0.78680533", "0.78488946", "0.78055084", "0.77679634", "0.7763988", "0.7752474", "0.7686199", "0.7607583", "0.75954175", "0.7480247", "0.7437406", "0.7421161...
0.7873586
9
Activated when used in the with statement. Should automatically acquire a lock to be used in the with block.
def __enter__(self): if not self.is_locked: self.acquire() return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __enter__(self):\n return self._lock.__enter__()", "async def __aenter__(self):\n self.acquired = True\n return self", "def __enter__(self):\r\n self.acquire()\r\n return self", "def __enter__(self):\n self.acquire()\n return self", "def __enter__(self):...
[ "0.76681423", "0.75623655", "0.7512478", "0.74385935", "0.74385935", "0.7426379", "0.7235537", "0.7198601", "0.7103257", "0.7099194", "0.70519584", "0.6976629", "0.6971899", "0.6971899", "0.6871852", "0.6831314", "0.6821339", "0.6815241", "0.67311513", "0.67223877", "0.668817...
0.7459506
3