query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Fully connected autoencoder model, symmetric.
def autoencoder(dims, act='relu', init='glorot_uniform'): n_stacks = len(dims) - 1 # input input_img = Input(shape=(dims[0],), name='input') x = input_img # internal layers in encoder for i in range(n_stacks-1): x = Dense(dims[i + 1], activation=act, kernel_initializer=init, name='encode...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_full_conv_autoencoder():\n input_img = Input(shape=(84, 84, 3))\n\n x = Convolution2D(48, 8, 8, activation='relu', border_mode='same', name='c1')(input_img)\n x = MaxPooling2D((2, 2), border_mode='same')(x)\n x = Convolution2D(32, 4, 4, activation='relu', border_mode='same', name='c2')(x)\n ...
[ "0.7196832", "0.6893117", "0.67456645", "0.66887695", "0.66514546", "0.6596896", "0.657406", "0.65313935", "0.6445991", "0.6428346", "0.61691767", "0.6158236", "0.6151338", "0.6143695", "0.6066768", "0.6066054", "0.60190195", "0.6018256", "0.59953135", "0.5976885", "0.5951744...
0.64928
8
Returns binary falsealarm rate (b / [a + b]).
def binary_far(target_tensor, forecast_probability_tensor): return 1. - binary_success_ratio(target_tensor, forecast_probability_tensor)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def beat_division(a,b):\n if b == 0:\n return 0\n return a // b", "def brate(self):\n try:\n return self.pos / self.runtime\n except ZeroDivisionError:\n return 0", "def calculate_br_down_metric(br_down):\n if br_down < 1:\n br_down = 1\n min_baud =...
[ "0.629831", "0.62668025", "0.62656444", "0.6244402", "0.6130168", "0.6071424", "0.59376067", "0.5932433", "0.5911787", "0.5865121", "0.58485365", "0.5848011", "0.584345", "0.5835077", "0.58243525", "0.58224005", "0.58133054", "0.58064634", "0.57709444", "0.5767904", "0.574954...
0.5311653
71
Calculate the Mean Squared Error between y_true and y_pred, but ignore the beginning "warmup" part of the sequences. y_true is the desired output. y_pred is the model's output.
def loss_mse_warmup(y_true, y_pred, warmup_steps): # The shape of both input tensors are: # [batch_size, sequence_length, num_y_signals]. warmup_steps = 50 # Ignore the "warmup" parts of the sequences # by taking slices of the tensors. y_true_slice = y_true[:, warmup_steps:, :] y_pred_slice...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_time_step_mse(y_true, y_pred):\n return keras.metrics.mean_squared_error(y_true[:,-1],y_pred[:,-1])", "def mean_squared_error(y_true, y_pred):\n\tmse = np.mean(np.power(y_true, y_pred, 2))\n\treturn mse", "def mean_squared_error(y_true, y_pred):\n mse = np.mean(np.power(y_tru...
[ "0.77460986", "0.76258963", "0.7607816", "0.759333", "0.7541404", "0.7527679", "0.74821055", "0.74810493", "0.744844", "0.73893744", "0.7388422", "0.73515975", "0.7309956", "0.7309525", "0.7305922", "0.73050845", "0.7294609", "0.7216255", "0.7151546", "0.71480584", "0.7139245...
0.7707211
1
Update weights given a single training vector
def update_weights(self, w, orig_buf, orig_cov, new_buf, new_cov): # we don't handle changed lengths if len(orig_buf) != len(new_buf): return # which bytes changed? x = np.frombuffer(orig_buf, dtype=np.uint8) y = np.frombuffer(new_buf, dtype=np.uint8) mask = (x!=y) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_weights(self):\n\t\tpass", "def update_weights(self):\n self._weights = self._weights + self.update_weights_value", "def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()", "def update(self, values, train, eta=.1):\n\t\...
[ "0.7536002", "0.75317174", "0.7460652", "0.7342677", "0.72884965", "0.72348285", "0.7199392", "0.7134026", "0.7017342", "0.7012895", "0.70061976", "0.6992156", "0.69759417", "0.69600725", "0.691911", "0.68996286", "0.6828508", "0.6814213", "0.67085475", "0.6706435", "0.670259...
0.0
-1
return full path to filename without extension
def _getSavePath(self): path, filename = os.path.split(self.path) savePath = os.path.join(path, os.path.splitext(filename)[0]) return savePath
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_full_path(file_extension=True) -> str:\n return get_directory() + \"/\" + get_filename(file_extension=file_extension)", "def filepath_without_ext(filepath: str) -> str:\n return str(pathlib.Path(filepath).with_suffix(''))", "def get_path(filename):\n\tif filename != \"\":\n\t\treturn filename\n\t...
[ "0.82906616", "0.8139399", "0.8041835", "0.7955763", "0.7951013", "0.79177755", "0.7901852", "0.7833393", "0.7815615", "0.7787736", "0.77596796", "0.7756122", "0.7737132", "0.76814216", "0.7655609", "0.76459587", "0.7633767", "0.76196694", "0.7601764", "0.7595147", "0.7573102...
0.0
-1
add a callback for a hw defined pin for digital input/output.
def add_digital_hw_pin(self, pin, read=None, write=None, inital_state=None): if isinstance(pin, int): self._digital_hw_pins[pin] = HwPin(read=read, write=write, blynk_ref=self, initial_state=inital_state) else: raise ValueError("pin value must be an integer value")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_callback(self, callback, when='sensing'):\n if when == 'both':\n self.pin.add_edge_callback(callback, 'both')\n else:\n on_sensing = True if when == 'sensing' else False\n self.pin.add_edge_callback(\n callback, 'rising' if self.pinishigh ^ on_s...
[ "0.64690423", "0.61849064", "0.60085356", "0.5956483", "0.58475715", "0.5846543", "0.58439845", "0.57960975", "0.5764804", "0.57494897", "0.5732094", "0.5679671", "0.5678474", "0.56394964", "0.5625757", "0.56056213", "0.5589288", "0.5576595", "0.55610466", "0.5528439", "0.548...
0.6181535
2
add a callback for a hw defined pin for analog input/output.
def add_analog_hw_pin(self, pin, read=None, write=None, initial_state=None): if isinstance(pin, int): self._analog_hw_pins[pin] = HwPin(read=read, write=write, blynk_ref=self, initial_state=initial_state) else: raise ValueError("pin value must be an integer value")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def analog_in(my_board, pin):\n await my_board.set_pin_mode_analog_input(pin,\n callback=the_callback,\n differential=5)\n # run forever waiting for input changes\n while True:\n await asyncio.sleep(1)", ...
[ "0.6787534", "0.66301984", "0.6175324", "0.6110606", "0.5879358", "0.5879358", "0.5851162", "0.5816422", "0.5798553", "0.5776644", "0.576428", "0.57544374", "0.57486665", "0.574764", "0.57361037", "0.5732125", "0.57051325", "0.57048446", "0.5700954", "0.56429", "0.56251657", ...
0.65582013
2
Given a file path to an h5 file assumed to house a tensor, load that tensor into memory and return a pointer.
def load_h5_file(file_path): # load fr = h5py.File(file_path, 'r') a_group_key = list(fr.keys())[0] data = list(fr[a_group_key]) # transform to appropriate numpy array data=data[0:] data = np.stack(data, axis=0) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadh5(fname, path='/data'):\n fp = open_read(fname)\n slab = fp.get_node(path)\n mat = slab.read()\n fp.close()\n return mat", "def load_tensor(path: str, params: Optional[Params]) -> th.Tensor:\n path = get_path_with_hash(path, params)\n files = glob(f'{path}/*')\n return th.stack([th.tensor(...
[ "0.7437465", "0.7086714", "0.64194524", "0.63914806", "0.6389463", "0.6389463", "0.62561035", "0.61800593", "0.6088989", "0.6058085", "0.6040051", "0.60097253", "0.59888977", "0.5986875", "0.59607834", "0.59528995", "0.5927168", "0.5914489", "0.5912998", "0.59040385", "0.5881...
0.6384181
6
get the column name
def name(self): return self._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_name(self):\n return self.col_name", "def column_name(self) -> Optional[str]:\n return pulumi.get(self, \"column_name\")", "def columnName(self):\n return self.__column", "def column_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"column_name\")", "def colum...
[ "0.8722004", "0.8525398", "0.84734815", "0.8389005", "0.8389005", "0.8093533", "0.7813103", "0.7813103", "0.7811528", "0.7805676", "0.77438116", "0.7667634", "0.7592623", "0.7431208", "0.74292094", "0.7374318", "0.7342597", "0.72725135", "0.72502655", "0.7214682", "0.7174846"...
0.0
-1
Positive Test case to check paydays when the first payday was on a thursday because Friday was a holiday.
def test_is_payday_positive6(self): # Overriding first_payday self.first_payday = date_class(2020,12,24) date_to_check = date_class(2021,1,8) is_payday = self.pay_cycle.is_payday(date_to_check) assert is_payday == True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _day_rule_matches(self, rule, dt):\n if dt.weekday() == 4:\n sat = dt + datetime.timedelta(days=1)\n if super(SiteHolidays, self)._day_rule_matches(rule, sat):\n return True\n elif dt.weekday() == 0:\n sun = dt - datetime.timedelta(days=1)\n ...
[ "0.69821507", "0.6892618", "0.68650854", "0.6827666", "0.68080336", "0.678057", "0.6776829", "0.67488265", "0.67448634", "0.67296416", "0.66915363", "0.6690996", "0.666132", "0.6645861", "0.6611681", "0.6603818", "0.6584228", "0.6563129", "0.6484644", "0.6463486", "0.6461668"...
0.7197239
0
Negative Test case to check if holiday on default payday is not a payday.
def test_is_payday_negative1(self): date_to_check = date_class(2020,12,25) is_payday = self.pay_cycle.is_payday(date_to_check) assert is_payday == False date_to_check = date_class(2021,12,24) is_payday = self.pay_cycle.is_payday(date_to_check) assert is_payday == False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_payday_negative0(self):\n date_to_check = date_class(2019,1,24)\n is_payday = self.pay_cycle.is_payday(date_to_check)\n assert is_payday == False\n\n date_to_check = date_class(2018,12,27)\n is_payday = self.pay_cycle.is_payday(date_to_check)\n assert is_payday...
[ "0.72370386", "0.7209107", "0.698192", "0.6733371", "0.66267115", "0.65522903", "0.6491297", "0.64875156", "0.635192", "0.634339", "0.6284661", "0.62642896", "0.62449616", "0.61648744", "0.6158634", "0.6145223", "0.61119276", "0.6085228", "0.60596836", "0.6010778", "0.5996088...
0.7130374
2
\ returns the gravityScore as an integer from this node
def getScore(self, node): return self.getGravityScoreFromNode(node) or 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_score(self, node):\r\n return self.get_node_gravity_score(node) or 0", "def get_score(self, node):\n return self.get_node_gravity_score(node) or 0", "def get_g_score(self):\n return self._g_score", "def g_score(self):\n _, _, I_CK = self._entropies()\n return 2.0 * ...
[ "0.77843124", "0.7753792", "0.7575313", "0.72101176", "0.66739476", "0.6591245", "0.6487961", "0.6487961", "0.6487961", "0.648348", "0.6476078", "0.6476078", "0.6476078", "0.64231694", "0.63510644", "0.63401246", "0.6271765", "0.62565887", "0.6201718", "0.6166289", "0.6154911...
0.77894115
0
save data to csv file
def save_to_csv(list_return, name, fieldnames): os.makedirs(os.path.dirname(name + '.csv'), exist_ok=True) with open(name + '.csv', 'w') as csvfile: csvfile.write(','.join(map(str, field_names))) csvfile.write('\n') write = csv.writer(csvfile, delimiter=',') for x in range(0, len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_csv(self, filename): # DONE\n self.data.to_csv(filename)", "def save(self, data, outpath):\n data.to_csv(outpath)", "def save_csv(data): \n bank_data = data\n\n #Creating headers for the csv file\n header = [\"Lender\", \"Max Loan Amount\", \"Max LTV\", \"Max DTI\", \"Max Cred...
[ "0.8625337", "0.8366503", "0.8064626", "0.80550843", "0.7850091", "0.7809454", "0.7791235", "0.76801515", "0.7606095", "0.7568307", "0.75312597", "0.7505743", "0.7499881", "0.74998355", "0.7483528", "0.747047", "0.7465715", "0.745356", "0.7382077", "0.7374473", "0.7275115", ...
0.0
-1
Construct sampler, agent, and algorithm, and extract batch_spec from sampler.
def __init__(self, asa_factory: AsaFactory): super().__init__(asa_factory) # initialize step_in_progress flag self.agent, self.sampler, self.algo = asa_factory() self.batch_spec = self.sampler.batch_spec self.grad = None self.traj_infos = None self.opt_info = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sampler_building(self):\n with mmtools.utils.temporary_directory() as tmp_dir:\n template_script = self.get_implicit_template_script(tmp_dir)\n template_script['options']['resume_setup'] = True\n default_number_of_iterations = template_script['options']['default_num...
[ "0.6515116", "0.6461849", "0.6384936", "0.628581", "0.6170763", "0.59607005", "0.5916784", "0.5865914", "0.58441645", "0.5788901", "0.5703414", "0.5671846", "0.5613792", "0.5596434", "0.55431056", "0.5529666", "0.54254794", "0.5417996", "0.53996223", "0.5384365", "0.5327594",...
0.53369474
20
We should be able to coerce both keys and values.
def test_dictionary_coerce(): @type_checked def _run_test(something:{int: str}): for key, value in something.items(): assert isinstance(key, int) assert isinstance(value, str) _run_test(something={123: "abc", 2314: 12312, "123": "abc"})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coerce(cls, key, value):\n if isinstance(value, cls):\n return value\n if isinstance(value, dict):\n return NestedMutableDict.coerce(key, value)\n if isinstance(value, list):\n return NestedMutableList.coerce(key, value)\n return super().coerce(key, ...
[ "0.66428775", "0.644114", "0.631059", "0.6216179", "0.59431624", "0.59283566", "0.58532697", "0.58013433", "0.5754183", "0.57387424", "0.57219034", "0.57110184", "0.56964326", "0.56881064", "0.56483537", "0.5602489", "0.55659014", "0.54999113", "0.54999065", "0.5495686", "0.5...
0.6760135
0
Ensure the error message received when a value should be an iterable.
def test_nested_fail(): @type_checked def _run_test(thing:(float, float)): pass with pytest.raises(TypeError) as error: _run_test(12) assert error.exconly() == ( "TypeError: Argument length mismatch. Expected a tuple of float, float." )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _assert_valid_value_and_cast(self, value):\n if not hasattr(value, '__iter__'):\n raise AssertionError(f\"{value} is not a valid iterable type\")\n return value", "def _is_iterable(value):\n return isinstance(value, list) or isinstance(value, tuple)", "def _data_validation(d...
[ "0.7784095", "0.7031291", "0.68781084", "0.6853101", "0.6803907", "0.67837614", "0.65035963", "0.65023917", "0.64103526", "0.63571596", "0.6318355", "0.6266715", "0.62089264", "0.6175737", "0.61707807", "0.61684364", "0.6166309", "0.6139344", "0.613463", "0.61149335", "0.6101...
0.0
-1
Assert email vars in email. value_list is a list with email var names and values eg values_list = ['VAR_1', 'var_1_value', VAR_2, var_2_value]. merge_vars is a list of dictionaries
def _assert_merge_vars(self, merge_vars, values_list): mergedvars_values = self._get_merge_vars_keys_values(merge_vars) for value in values_list: self.assertIn(value, mergedvars_values)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mail_address(mail_addr_list):\n if mail_addr_list:\n mail_addr_list = mail_addr_list.replace(\" \", \"\")\n if \",\" in mail_addr_list:\n mail_addr_list = mail_addr_list.replace(\",\", \";\")\n mail_addr_list = mail_addr_list.split(\";\")\n for mail_addr in mail_addr_l...
[ "0.51052976", "0.503237", "0.49169227", "0.48936918", "0.487811", "0.48727146", "0.48643276", "0.4791017", "0.4767188", "0.47560823", "0.4685153", "0.46562046", "0.46514374", "0.46447858", "0.4549479", "0.4547794", "0.45294523", "0.4524114", "0.4499285", "0.44965535", "0.4491...
0.64705205
0
percentile minmax normalization from mricron
def percentile_normalization(data: np.ndarray, percentile: int = 1) -> np.ndarray: min_percentile = np.percentile(data, percentile) max_percentile = np.percentile(data, 100 - percentile) # limit maximum intensity of data by max_percentile data[data >= max_percentile] = max_percentile # limit mini...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def denormalize(x):\n x_max = np.percentile(x, 98)\n x_min = np.percentile(x, 2)\n x = (x - x_min) / (x_max - x_min)\n x = x.clip(0, 1)\n return x", "def denormalize(x):\n x_max = np.percentile(x, 98)\n x_min = np.percentile(x, 2)\n x = (x - x_min) / (x_max - x_min)\n x = x.clip(0, 1)\...
[ "0.6984449", "0.6984449", "0.6854181", "0.657489", "0.654012", "0.6374417", "0.6374417", "0.6244678", "0.6147104", "0.6138276", "0.6134927", "0.6103464", "0.60930365", "0.60615635", "0.6056778", "0.6041397", "0.604043", "0.60389805", "0.60320675", "0.6013818", "0.5977459", ...
0.6635372
3
Return a nonnaive, timezoneaware datetime object representing the current UTC time.
def utc(): return date_from_utc(dt.utcnow())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datetime_utc_now() -> datetime:\n return datetime.now(timezone.utc)", "def utcnow() -> datetime.datetime:\n return datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)", "def now_utc() -> datetime:\n return datetime.now(timezone.utc)", "def now_dt(tz='UTC'):\n if tz != 'UTC':\n raise No...
[ "0.8154258", "0.8108714", "0.80793", "0.79203063", "0.7919413", "0.78831565", "0.7870782", "0.78115773", "0.7806138", "0.7711203", "0.76865727", "0.75098777", "0.7408525", "0.7405564", "0.73967373", "0.73967373", "0.73540395", "0.7351858", "0.7347884", "0.73343015", "0.731173...
0.711821
28
Return a nonnaive, timezoneaware datetime object for the UTC timezone representing the given millisecondprecision UTC timestamp.
def date_from_utc_ts(ts): return date_from_utc(dt.utcfromtimestamp(ts / 1000.0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_timestamp(timestamp: float, tz_info: tzinfo = UTC) -> datetime:\n utc_dt = datetime.fromtimestamp(timestamp, tz=UTC)\n return convert_timezone(utc_dt, tz_info)", "def aware_utc_from_timestamp(timestamp):\n return datetime.utcfromtimestamp(timestamp).replace(tzinfo=pytz.utc)", "def datetim...
[ "0.6887081", "0.67324805", "0.65992945", "0.63663137", "0.63468874", "0.6339635", "0.6305643", "0.62278867", "0.62122345", "0.61936194", "0.61156034", "0.6111282", "0.6111282", "0.61079186", "0.60879314", "0.60730815", "0.6072521", "0.6053845", "0.6043639", "0.6009313", "0.59...
0.5444415
65
Return a nonnaive, timezoneaware datetime object for the UTC timezone of the given naive datetime object.
def date_from_utc(date): return pytz.utc.localize(date)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_naive_utc(date_time: datetime.datetime) -> datetime.datetime:\n utc_timezone = datetime.timezone(datetime.timedelta(seconds=0))\n return date_time.astimezone(utc_timezone).replace(tzinfo=None)", "def datetime_naive_to_utc(dt):\n\n if type(dt) != datetime.datetime:\n raise TypeError(f\"dt...
[ "0.7751766", "0.73286957", "0.7206129", "0.7127429", "0.7083304", "0.707239", "0.6938975", "0.676107", "0.67442095", "0.66904974", "0.6687902", "0.6657082", "0.66413766", "0.6593759", "0.65571004", "0.6496759", "0.6463543", "0.6447047", "0.64410704", "0.6437082", "0.64023274"...
0.56572044
90
Checks that matching metrics is correct when custom columns are used.
def testMatchingMetricsWithCustomColumnNames(self): default_class = TrimmedMatchGeoXDesign( GeoXType.HEAVY_UP, pretest_data=self.test_data, time_window_for_design=self.design_window, time_window_for_eval=self.evaluation_window, matching_metrics={'metric': 1.0}) self.asse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_custom_columns(record_custom_columns):\n\n\tcustom_column_name_errors = []\n\n\tfor k, v in record_custom_columns.items():\n\t\tfield_name = \"Custom Column: \" + k\n\t\tfield_desc = \"Column Description: \" + v\n\n\t\tif not re.match(character_regex_with_space, k):\n\t\t\tmessage = get_regex_mismatch...
[ "0.6424867", "0.62638515", "0.62408894", "0.61916", "0.6141973", "0.59872794", "0.5919444", "0.5906924", "0.58839124", "0.5855345", "0.5851866", "0.58319426", "0.58122677", "0.5767703", "0.5762941", "0.5725376", "0.5715428", "0.56894904", "0.564944", "0.56136674", "0.5612972"...
0.71387756
0
Checks an error is raised if the column specified as response is missing.
def testMissingResponseVariable(self): with self.assertRaisesRegex(ValueError, r'revenue is not available in pretest_data'): _ = TrimmedMatchGeoXDesign( GeoXType.HEAVY_UP, pretest_data=self.test_data, time_window_for_design=self.design_window, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run_missing_column(self):\n input_df = self.spark.createDataFrame(\n data=[\n (\"a\",),\n ],\n schema=StructType([\n StructField(\"baz\", StringType()),\n ])\n )\n with raises(AnalysisException):\n se...
[ "0.6921714", "0.6843131", "0.6812693", "0.6687044", "0.6596847", "0.65352863", "0.6481303", "0.6472438", "0.6429431", "0.6368351", "0.6337951", "0.6335738", "0.63041055", "0.6295739", "0.62406284", "0.6238891", "0.61448956", "0.61409754", "0.61281246", "0.61120534", "0.600841...
0.0
-1
Checks an error is raised if the column specified as spend is missing.
def testMissingSpendProxy(self): with self.assertRaisesRegex( ValueError, r'cost is not available in pretest_data'): _ = TrimmedMatchGeoXDesign( GeoXType.HEAVY_UP, pretest_data=self.test_data, time_window_for_design=self.design_window, time_window_for_ev...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run_missing_column(self):\n input_df = self.spark.createDataFrame(\n data=[\n (\"a\",),\n ],\n schema=StructType([\n StructField(\"baz\", StringType()),\n ])\n )\n with raises(AnalysisException):\n se...
[ "0.62697387", "0.62528425", "0.61799204", "0.588628", "0.5872444", "0.5840354", "0.57471985", "0.55836123", "0.55610335", "0.5543642", "0.5526747", "0.5464893", "0.5374478", "0.52955866", "0.52947986", "0.5278426", "0.52430004", "0.52384275", "0.52342325", "0.5232288", "0.522...
0.0
-1
Checks pairs are correctly created when matching_metrics is specified.
def testCreateGeoPairsMatchingMetric(self): self.test_class._matching_metrics = {'response': 1.0, 'spend': 0.5} self.test_class.create_geo_pairs(use_cross_validation=True) self.test_class.create_geo_level_eval_data() self.test_class.geo_level_eval_data[0].sort_values(by='geo', inplace=True) self.tes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testPassPairingWithMoreThanTwoGeosPerPair(self):\n # geo 1 and 2 appear in two pairs.\n pairs = [\n pd.DataFrame({\n 'geo1': [1, 2],\n 'geo2': [3, 4],\n 'pair': [1, 1]\n })\n ]\n with self.assertRaisesRegex(\n ValueError, r'a pair should only ha...
[ "0.6394126", "0.6326114", "0.6263803", "0.61781764", "0.61238843", "0.61099213", "0.610186", "0.6095023", "0.60889626", "0.6031706", "0.5990536", "0.5971731", "0.58707994", "0.5816052", "0.576236", "0.57584065", "0.5722042", "0.5704836", "0.56930596", "0.56879574", "0.5674097...
0.687965
0
Checks geo level data are the same whether we pass or not the same pairs.
def testCheckSameGeoLevelDataWhenPairsAreSpecifiedOrNot(self): self.test_class._matching_metrics = {'response': 1.0, 'spend': 0.5} self.test_class.create_geo_pairs(use_cross_validation=True) self.test_class.create_geo_level_eval_data() pairs_specified = [pd.DataFrame({ 'geo1': [1, 4], '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testCreateGeoLevelDataWhenPairsArePassed(self):\n pairs = [\n pd.DataFrame({\n 'geo1': [1, 2],\n 'geo2': [3, 4],\n 'pair': [1, 2]\n }),\n pd.DataFrame({\n 'geo1': [2],\n 'geo2': [4],\n 'pair': [2]\n })\n ]\n ...
[ "0.6965489", "0.6689868", "0.66069275", "0.65917724", "0.6465422", "0.6457013", "0.64382416", "0.6423893", "0.64047706", "0.6104063", "0.60927045", "0.6005924", "0.5967563", "0.5924918", "0.5919197", "0.58980715", "0.5896205", "0.58735794", "0.5829971", "0.5828158", "0.581853...
0.7615281
0
Checks the calculation with negative values in iroas_list.
def testReportCandidateDesignWithNegativeIROAS(self): new_data = pd.concat([self.test_data, self.add_pair], sort=False) test_class = TrimmedMatchGeoXDesign( GeoXType.HEAVY_UP, pretest_data=new_data, time_window_for_design=self.design_window, time_window_for_eval=self.evaluation_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_allnegative(self):\n\n slot = [[-1,-1,-1,0,0,0], [0,-1,0,0,0,0], [-1,-1,-1,0,0,0], [0,-9,2,-4,-4,0], [-7,0,0,-2,0,0],[0,0,-1,-2,-4,0]]\n self.assertEqual(array_func(slot), 0)", "def test_running_sum_mult_negatives(self):\n argument = [-1,-5,-3,-4]\n expected = [-1,-6,-9,-13]\...
[ "0.6291397", "0.6225531", "0.6114925", "0.59850025", "0.5969392", "0.59353596", "0.59150887", "0.586503", "0.58563614", "0.58259255", "0.580773", "0.576632", "0.5758486", "0.571908", "0.5713684", "0.56692547", "0.566484", "0.56017846", "0.5585194", "0.55750257", "0.5501258", ...
0.57869434
11
Check all assignments with a too large geo are rejected.
def testErrorGenerateBalancedAssignmentsMaximumFractionLargestGeo(self): pretest_data = pd.DataFrame({ 'date': pd.to_datetime(['2019-01-01', '2019-10-01'] * 20), 'geo': sorted(list(range(20)) * 2), 'response': range(100, 140), 'spend': range(40), }) test_class = TrimmedMatchG...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testTooFewGeos(self):\n for geox_type in GeoXType:\n if geox_type == GeoXType.CONTROL:\n continue\n self.test_class._geox_type = geox_type\n with self.assertRaisesRegex(\n ValueError,\n 'All pairings were rejected due to less than 10 pairs in the design.',\n ):\n...
[ "0.6518037", "0.6310688", "0.6293096", "0.60979944", "0.5902434", "0.5791618", "0.5776161", "0.5771639", "0.57166225", "0.56490976", "0.5613702", "0.5467408", "0.5456767", "0.5437315", "0.5396887", "0.5383301", "0.5363179", "0.534781", "0.53435796", "0.5335138", "0.5321679", ...
0.61391854
3
Tests whether ``GuildJoinRequest.copy`` works as intended.
def test__GuildJoinRequest__copy(): actioned_by = User.precreate(202305170026, name = 'Koishi') actioned_at = DateTime(2016, 5, 14) created_at = DateTime(2017, 7, 6) form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()] guild_id = 202305170027 last_seen_at = DateTime(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__GuildJoinRequest__copy_with__0():\n actioned_by = User.precreate(202305170029, name = 'Koishi')\n actioned_at = DateTime(2016, 5, 14)\n created_at = DateTime(2017, 7, 6)\n form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()]\n guild_id = 202305170030\n last_...
[ "0.76607436", "0.7598416", "0.7206342", "0.70395315", "0.690234", "0.59682065", "0.59415877", "0.5918088", "0.5646202", "0.5607029", "0.5599134", "0.5585532", "0.5553137", "0.55351955", "0.55151415", "0.54757655", "0.5446442", "0.54364395", "0.5431593", "0.5427204", "0.535932...
0.8029556
0
Tests whether ``GuildJoinRequest.copy_with`` works as intended.
def test__GuildJoinRequest__copy_with__0(): actioned_by = User.precreate(202305170029, name = 'Koishi') actioned_at = DateTime(2016, 5, 14) created_at = DateTime(2017, 7, 6) form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()] guild_id = 202305170030 last_seen_at = D...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__GuildJoinRequest__copy_with__1():\n old_actioned_by = User.precreate(202305170032, name = 'Koishi')\n old_actioned_at = DateTime(2016, 5, 14)\n old_created_at = DateTime(2017, 7, 6)\n old_form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()]\n old_guild_id = 202...
[ "0.78760326", "0.7804333", "0.7492444", "0.70733243", "0.666857", "0.5941189", "0.58620644", "0.57350147", "0.5664402", "0.5636084", "0.5625761", "0.5531903", "0.55028236", "0.5483786", "0.54580885", "0.5456632", "0.54441595", "0.54389566", "0.5431701", "0.53539276", "0.53002...
0.7920338
0
Tests whether ``GuildJoinRequest.copy_with`` works as intended.
def test__GuildJoinRequest__copy_with__1(): old_actioned_by = User.precreate(202305170032, name = 'Koishi') old_actioned_at = DateTime(2016, 5, 14) old_created_at = DateTime(2017, 7, 6) old_form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()] old_guild_id = 202305170033 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__GuildJoinRequest__copy_with__0():\n actioned_by = User.precreate(202305170029, name = 'Koishi')\n actioned_at = DateTime(2016, 5, 14)\n created_at = DateTime(2017, 7, 6)\n form_responses = [GuildJoinRequestFormResponse(), GuildJoinRequestFormResponse()]\n guild_id = 202305170030\n last_...
[ "0.7920338", "0.7804333", "0.7492444", "0.70733243", "0.666857", "0.5941189", "0.58620644", "0.57350147", "0.5664402", "0.5636084", "0.5625761", "0.5531903", "0.55028236", "0.5483786", "0.54580885", "0.5456632", "0.54441595", "0.54389566", "0.5431701", "0.53539276", "0.530024...
0.78760326
1
Tests whether ``GuildJoinRequest.user`` works as intended.
def test__GuildJoinRequest__user(): user_id = 202305170040 user = User.precreate(user_id, name = 'Koishi') event = GuildJoinRequest( user = user, ) output = event.user_id vampytest.assert_instance(output, int) vampytest.assert_eq(output, user_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test__GuildJoinRequestDeleteEvent__user():\n user_id = 202305160037\n \n event = GuildJoinRequestDeleteEvent(\n user_id = user_id,\n )\n \n output = event.user\n vampytest.assert_instance(output, ClientUserBase)\n vampytest.assert_eq(output.id, user_id)", "def check_can_join(se...
[ "0.68904227", "0.6755829", "0.6531361", "0.6418835", "0.62129945", "0.62129945", "0.60802335", "0.602413", "0.5972484", "0.5948083", "0.5905936", "0.5844805", "0.58197963", "0.5756364", "0.5749274", "0.57475656", "0.5735924", "0.5731473", "0.5722582", "0.57184786", "0.5663878...
0.7502258
0
Tests whether ``GuildJoinRequest.iter_form_responses`` works as intended.
def test__GuildJoinRequest__iter_form_responses(): form_responses_0 = GuildJoinRequestFormResponse() form_responses_1 = GuildJoinRequestFormResponse() for input_value, expected_output in ( (None, []), ([form_responses_1], [form_responses_1]), ([form_responses_0, form_responses_1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_has_form(self):\n form = self.resp.context['form']\n self.assertIsInstance(form, SubscriptionForm)", "def test_contains_forms(self):\n response = self.client.get(self.url)\n \n first_author_form = response.context.get('first_author_form')\n authors_fs = response...
[ "0.5541458", "0.54797256", "0.5383552", "0.52934766", "0.52596617", "0.52290154", "0.52258825", "0.51692307", "0.5149638", "0.51132447", "0.50784683", "0.50692415", "0.5053933", "0.5053454", "0.5037767", "0.5004849", "0.49907207", "0.4972271", "0.49295655", "0.48741913", "0.4...
0.8440957
0
Return the calibrated flux at the transformed position x
def flux(self, x): return self.cal_spec.get_flux(self(x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flux(self) -> ErrorValue:\n try:\n return ErrorValue(self._data['Flux'], self._data.setdefault('FluxError',0.0))\n except KeyError:\n return 1 / self.pixelsizex / self.pixelsizey / ErrorValue(self._data['NormFactor'],\n ...
[ "0.6305932", "0.6122351", "0.61079925", "0.60445327", "0.60138345", "0.59496135", "0.59249914", "0.5902242", "0.5895044", "0.58681285", "0.5867735", "0.58602226", "0.58382535", "0.58375496", "0.58217", "0.5759495", "0.5754971", "0.57394314", "0.5710734", "0.57101035", "0.5693...
0.78356826
0
Returns the actual number of nodes in the given tree after pruning. This differs from the `tree.node_count` property, which contains the number of nodes before pruning. Updating this value would break other features since the underlying data structures still have their original sizes.
def num_actual_nodes(tree): return (tree.n_node_samples > 0).sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_trees(self) -> int:\n\n return len(self.nodes)", "def count(self):\n return self.__tree.node_count", "def num_trees(self):\n return self._ll_tree_sequence.get_num_trees()", "def n_trees(self):\n return len(self.data_kd)", "def get_tree_size(self, node):\n\n # If t...
[ "0.75873274", "0.74049246", "0.73991156", "0.72687227", "0.72336507", "0.72197115", "0.71004504", "0.70869845", "0.70869845", "0.70720327", "0.706207", "0.7000754", "0.6995434", "0.69921255", "0.69874674", "0.6959695", "0.6940743", "0.69186306", "0.6913221", "0.6856822", "0.6...
0.73280436
3
Returns the number of leaves.
def num_leaves(tree): return ((tree.n_node_samples > 0) & (tree.feature == INVALID_VALUE)).sum()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_leaves(self) -> int:\n if self.root is None: # If tree is empty\n return 0\n\n return self.count_helper(self.root)", "def count_leaves(self) -> int:\n # binary search tree == empty\n if self.root is None:\n return 0\n\n #recursive helper fu...
[ "0.85978115", "0.83787316", "0.82263", "0.81612337", "0.78963137", "0.76902026", "0.7605821", "0.7436115", "0.73381245", "0.73281425", "0.723369", "0.7184199", "0.7143546", "0.7106629", "0.7078075", "0.706814", "0.704728", "0.7039034", "0.70122105", "0.6969123", "0.6941357", ...
0.7873495
5
Convert the node with the given ID to a leaf, pruning away its children.
def to_leaf(self, node_id, depths): # print("Converting node {} to leaf.".format(node_id)) self._kill_node(self.tree.children_left[node_id], depths) self._kill_node(self.tree.children_right[node_id], depths) self._unlink_children(node_id) self.tree.feature[node_id] = INVALID_VAL...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prune(self, id):\r\n assert id in self.node_ids, \"Node id does not exist in tree\"\r\n assert id!=self.root.id, \"Cannot prune at root node\"\r\n\r\n # Remove child from parent node\r\n self.get_node_by_id(id).parent.remove_child(id)\r\n\r\n # Remove child and all its descen...
[ "0.64349", "0.62493217", "0.6030108", "0.5816592", "0.564056", "0.55450803", "0.54807913", "0.5388099", "0.5380716", "0.5345132", "0.53075975", "0.5295506", "0.52422327", "0.5199169", "0.51945", "0.5169452", "0.516804", "0.5157946", "0.5155557", "0.513278", "0.512966", "0.5...
0.7639113
0
Test error with an invalid provider id.
def test_error_on_invalid_provider(self): self.ocp_data.update({"source_uuids": ["1dd7204c-72c4-4ec4-95bc-d5c447688b27"]}) with tenant_context(self.tenant): serializer = CostModelSerializer(data=self.ocp_data, context=self.request_context) with self.assertRaises(serializers.Valid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_valid_provider(provider_type: str) -> None:\n valid_types = get_valid_provider_types()\n if provider_type not in valid_types:\n raise MephistoDBException(\n f\"Supplied provider {provider_type} is not in supported list of providers {valid_types}.\"\n )", "def test_invali...
[ "0.67632014", "0.66781193", "0.6626693", "0.6573218", "0.64181876", "0.6378821", "0.6365212", "0.63023674", "0.6300867", "0.6290273", "0.6272328", "0.625435", "0.62524533", "0.6219248", "0.6210451", "0.61967003", "0.6172771", "0.61439645", "0.6102068", "0.6083161", "0.60818",...
0.666184
2
Test error when trying to create an empty rate.
def test_error_no_rate(self): self.ocp_data["rates"][0]["tiered_rates"] = [] with tenant_context(self.tenant): serializer = CostModelSerializer(data=self.ocp_data, context=self.request_context) with self.assertRaises(serializers.ValidationError): if serializer.is...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_error_on_rate_type(self):\n self.ocp_data[\"rates\"][0].pop(\"tiered_rates\")\n self.ocp_data[\"rates\"][0][\"bad_rates\"] = []\n with tenant_context(self.tenant):\n serializer = CostModelSerializer(data=self.ocp_data, context=self.request_context)\n with self.as...
[ "0.71448827", "0.7117846", "0.71133024", "0.69334674", "0.6767911", "0.6554728", "0.65060806", "0.6418866", "0.64169073", "0.6360861", "0.63442135", "0.63184583", "0.62939966", "0.62226033", "0.6201013", "0.619982", "0.6199733", "0.61617976", "0.6139146", "0.61344254", "0.613...
0.76443267
0
Test error when trying to create a negative tiered usage_end.
def test_error_neg_tier_usage_end(self): self.ocp_data["rates"][0]["tiered_rates"][0]["usage"] = { "usage_start": 10.0, "usage_end": float(round(Decimal(random.random()), 6) * -1), } with tenant_context(self.tenant): serializer = CostModelSerializer(data=self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_error_neg_tier_usage_start(self):\n self.ocp_data[\"rates\"][0][\"tiered_rates\"][0][\"usage\"] = {\n \"usage_start\": float(round(Decimal(random.random()), 6) * -1),\n \"usage_end\": 20.0,\n }\n with tenant_context(self.tenant):\n serializer = CostMod...
[ "0.7689643", "0.7423699", "0.7006133", "0.6990759", "0.68274146", "0.6688618", "0.6572525", "0.63987005", "0.63296044", "0.62030065", "0.615616", "0.61363685", "0.61202955", "0.6092118", "0.60778975", "0.60496855", "0.6036879", "0.6026556", "0.6020249", "0.60163254", "0.60161...
0.8067233
0
Test that usage_start greater than a usage end fails
def test_tag_rates_error_on_usage_start_greater_than_usage_end(self): tag_values_kwargs = [{"usage_start": 10, "usage_end": 2}] self.basic_model["rates"][0]["tag_rates"] = format_tag_rate(tag_values=tag_values_kwargs) with tenant_context(self.tenant): serializer = CostModelSerializer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_begin_greater_than_end():\n with pytest.raises(InvalidSegmentError):\n _validate([[1, 2], [5, 3]])", "def test_invalid_time_range(event_member):\n _, member, event_id = event_member\n current = date.today() + timedelta(days=6)\n start = datetime.combine(current, time(12, 30))...
[ "0.68418074", "0.65183944", "0.64100623", "0.6301605", "0.62582237", "0.6256351", "0.6194473", "0.61292624", "0.60796773", "0.6072625", "0.60472953", "0.6022867", "0.60205466", "0.6016129", "0.59997296", "0.59651965", "0.5945999", "0.5940881", "0.59050167", "0.58967", "0.5884...
0.62445045
6
Test validate source uuid error.
def test_validate_source_uuid_error(self): tag_value = {"tag_value": "key_one", "value": 0.2} self.basic_model["rates"][0]["tag_rates"] = format_tag_rate(tag_values=[tag_value]) with tenant_context(self.tenant): serializer = CostModelSerializer(data=self.basic_model, context=self.req...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_uuid(data):\n\n if not uuidutils.is_uuid_like(data):\n raise exceptions.DiagnoseException(\n \"'%s' is not a valid UUID\" % data)", "def test_bad_uuid_lowercase():\n bad_uiid_lower = \"7cfb2470-b600-4eb3-a2cd-c1439e45b91g\"\n m = CannedRe.UUID.match(bad_uiid_lower)\n as...
[ "0.71822476", "0.7001486", "0.68985564", "0.68224394", "0.67108595", "0.6688417", "0.6613139", "0.6507473", "0.6502515", "0.64869213", "0.6481389", "0.6477423", "0.6436688", "0.6434514", "0.64252555", "0.63792676", "0.6337465", "0.6265929", "0.62517154", "0.62136704", "0.6190...
0.76884663
0
Test if tagged rates do not match currency raises a validation error.
def test_tagged_not_matching_currency(self): tag_value = {"tag_value": "key_one", "value": 0.2, "unit": "JPY"} self.basic_model["rates"][0]["tag_rates"] = format_tag_rate(tag_values=[tag_value]) with tenant_context(self.tenant): serializer = CostModelSerializer(data=self.basic_model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tag_rates_error_on_negitive_tag_value(self):\n tag_values_kwargs = [{\"value\": -0.2}]\n self.basic_model[\"rates\"][0][\"tag_rates\"] = format_tag_rate(tag_values=tag_values_kwargs)\n with tenant_context(self.tenant):\n serializer = CostModelSerializer(data=self.basic_mode...
[ "0.74103373", "0.7091159", "0.7044231", "0.70375276", "0.68177766", "0.67642385", "0.6738917", "0.67341727", "0.6687807", "0.66032475", "0.65766674", "0.6547091", "0.637241", "0.63433045", "0.62080646", "0.6162519", "0.6153849", "0.61069226", "0.6105732", "0.60791004", "0.607...
0.78333116
0
Test that a none distribution_info object uses default options.
def test_none_distribution_info_returns_defaults(self): default_distrib_info_obj = { "distribution_type": metric_constants.CPU_DISTRIBUTION, "platform_cost": True, "worker_cost": True, } with tenant_context(self.tenant): instance = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_distribution_info_returns_defaults(self):\n\n default_distrib_info_obj = {\n \"distribution_type\": metric_constants.CPU_DISTRIBUTION,\n \"platform_cost\": True,\n \"worker_cost\": True,\n }\n self.ocp_data[\"distribution_info\"] = {}\n wi...
[ "0.73588645", "0.6633837", "0.6600473", "0.6319721", "0.6290802", "0.6281371", "0.62301576", "0.6215893", "0.61732876", "0.61114913", "0.610008", "0.6079119", "0.60456014", "0.6042367", "0.60312593", "0.60198504", "0.60163844", "0.59910524", "0.5973624", "0.5956456", "0.59550...
0.7377984
0
Test that an empty distribution_info object returns default options.
def test_empty_distribution_info_returns_defaults(self): default_distrib_info_obj = { "distribution_type": metric_constants.CPU_DISTRIBUTION, "platform_cost": True, "worker_cost": True, } self.ocp_data["distribution_info"] = {} with tenant_context(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_none_distribution_info_returns_defaults(self):\n\n default_distrib_info_obj = {\n \"distribution_type\": metric_constants.CPU_DISTRIBUTION,\n \"platform_cost\": True,\n \"worker_cost\": True,\n }\n with tenant_context(self.tenant):\n instanc...
[ "0.74222565", "0.6606047", "0.65748686", "0.6272284", "0.62059647", "0.6183231", "0.61572653", "0.6116565", "0.6092596", "0.60053897", "0.60026395", "0.5967195", "0.5960858", "0.592314", "0.59132314", "0.58770734", "0.5855554", "0.58357805", "0.5833142", "0.5831105", "0.58296...
0.75260514
0
Set up relevant mocks.
def setUp(self): self.inst = Publish() self.os_environ_get_patch = unittest.mock.patch.dict( "swift_sharing_tools.publish.os.environ", {"OS_PROJECT_ID": "project_id", "SWIFT_SHARING_URL": "http://example", "SWIFT_REQUEST_URL": "http://example"} ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setUp(self):\n util.create_mocks()", "def setup...
[ "0.8246676", "0.8246676", "0.8246676", "0.8246676", "0.8246676", "0.8246676", "0.76675224", "0.7256418", "0.7249775", "0.7236179", "0.7182452", "0.7146316", "0.71135795", "0.702895", "0.7012231", "0.7004711", "0.6953427", "0.69501853", "0.6928659", "0.6917208", "0.6907015", ...
0.0
-1
Test use of virtual bool operator==
def test07_virtual_operator_eq(self): import _cppyy b1 = _cppyy.gbl.v_opeq_base(1) b1a = _cppyy.gbl.v_opeq_base(1) b2 = _cppyy.gbl.v_opeq_base(2) b2a = _cppyy.gbl.v_opeq_base(2) assert b1 == b1 assert b1 == b1a assert not b1 == b2 assert not b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def __eq__(self,*args):\r\n pass", "def...
[ "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7468151", "0.7303349", "...
0.72320783
43
Calculates the entropy in bits of each site (or kmer) in a sequence alignment.
def alignmentEntropy(align, statistic='absolute', removeGaps=False, k=1, logFunc=np.log): if removeGaps: grabKmerFlag = 1 else: grabKmerFlag = 0 align = padAlignment(align) L = len(align[align.index[0]]) nKmers = L - k + 1 entropy = np.zeros(nKmers, dtype=float) for aai in ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entropy(group_counts):\n total = sum(group_counts)\n entro = 0\n for item_count in group_counts:\n entro += item_entropy(item_count, total)\n return entro", "def entropy(data):\n e = 0\n\n counter = collections.Counter(data)\n l = len(data)\n for count in counte...
[ "0.68068856", "0.66609603", "0.6641473", "0.6543691", "0.6512589", "0.64884704", "0.6485986", "0.64851624", "0.64623606", "0.6438327", "0.64323723", "0.6388064", "0.63875264", "0.63844836", "0.6354675", "0.6352094", "0.6332662", "0.63205934", "0.62933457", "0.62912333", "0.62...
0.62995726
18
Normazlize values of vec inplace to [mn, mx] interval
def mynorm(vec, mx=1, mn=0): vec -= np.nanmin(vec) vec = vec/np.nanmax(vec) vec = vec*(mx-mn)+mn return vec
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize(vec):\n min_ = np.min(vec)\n max_ = np.max(vec)\n if min_ != max_:\n n_vec = (vec-min_)/(max_-min_)\n return n_vec\n\n return vec", "def normalize(vec):\n return vec / length(vec)", "def normalization(x, x_min=-5.12, x_max=5.12):\n for i in range(len(x.vect)):\n ...
[ "0.70640945", "0.6896041", "0.68326116", "0.6704414", "0.66292596", "0.6489243", "0.6483377", "0.6474125", "0.64254105", "0.6373898", "0.63691574", "0.63480526", "0.6331625", "0.6326411", "0.632204", "0.6306971", "0.63032454", "0.62970144", "0.6295916", "0.6286131", "0.626961...
0.7029751
1
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(y_true, y_pred, normalize=False, title=None, cmap=plt.cm.Reds): if not title: if normalize: title = 'Normalized confusion matrix' else: title = 'Confusion matrix, without ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.81920755", "0.8093736", "0.8028212", "0.8017333", "0.79923165", "0.7989431", "0.79789335", "0.7974398", "0.795948", "0.79555666", "0.7935652", "0.7932704", "0.7932632", "0.7929465", "0.7924336", "0.7922666", "0.79221356", "0.7921299", "0.79209703", "0.7920307", "0.7916008"...
0.0
-1
Generate Synthetic Contexts via given mean and variance
def get_synthetic_context(self, args): #create_data = CreateData(args.num_of_users, args.num_of_arms, args.dim) mean = [0.2, 0.9, 0.5, 3, 1.1, 0.9, 2, 2.5, 1.6, 1.8] * int(self.dims / 10) var = [3, 2, 4, 3, 3.5, 5.5, 5, 3.5, 5, 3.5] * int(self.dims / 10) context_gen = self.data(mean, var...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian_sample(mean, var, scope=None):\n with tf.variable_scope(scope, 'gaussian_sample'):\n sample = tf.random_normal(tf.shape(mean), mean, tf.sqrt(var))\n sample.set_shape(mean.get_shape())\n return sample", "def sample(self, mean, std, n_samples, sample_seed):\n self.seed_s...
[ "0.61428994", "0.6106671", "0.604166", "0.60313785", "0.5942146", "0.5875524", "0.5866838", "0.58558154", "0.58526", "0.5772521", "0.57706803", "0.57576555", "0.57567716", "0.5745907", "0.57451", "0.5737471", "0.57281774", "0.57055485", "0.5695569", "0.5692652", "0.56873244",...
0.62686765
0
Initialize the perceptron with weights and an activation function. Weights[0] is the threshold value.
def __init__(self, weights, function): if(len(weights)<2): raise ValueError("The weight vector should have at least two elements") self.weights = np.array(weights) self.function = function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_weight_init(_p: Perceptron):\n\n _p.weights = [rd.choice([1-rd.random(), -1+rd.random()]) for _ in range(_p.input_size)]", "def perceptron_output(weights, bias, x):\n return step_function(dot(weights, x) + bias)", "def __init__(self, reg_penalty='l2', reg=0.001, k_fold=5, random_state=0):\n ...
[ "0.7037529", "0.7017507", "0.6753081", "0.66011214", "0.64372844", "0.63793373", "0.6317353", "0.6307274", "0.62973785", "0.62687516", "0.62687516", "0.6254778", "0.6186828", "0.61856526", "0.614779", "0.6139289", "0.61370665", "0.6116154", "0.60953873", "0.60846436", "0.6082...
0.58433455
46
Initialize attributes to describe a car.
def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.odometer_reading = 0 #Setting a default value for an Attribute
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, car):\n super(self.__class__, self).__init__(car)\n self.coordinator_name = car.get_faulty_coordinator_name()\n self.second_at_charge_name = car.get_second_at_charge_name()\n self.coordinated_car_name = car.get_corrected_coordinated_car_name()\n self.following_...
[ "0.7500984", "0.7397504", "0.6964254", "0.69572306", "0.68612015", "0.671638", "0.6585787", "0.6585787", "0.6585787", "0.6455301", "0.6448016", "0.64400023", "0.6431852", "0.63737345", "0.63079256", "0.6206326", "0.6174237", "0.6162698", "0.61395067", "0.6102099", "0.6102099"...
0.62494457
15
Spaces should be treated as empty string for contact_person
def test_charter_form_contact_person(self): data = { "language": 1, "countries": 1, "start_date_month": "1", "start_date_day": "1", "start_date_year": "2015", "end_date_month": "2", "end_date_day": "2", "end_date_ye...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_contact_first_name(app):\n name = app.get(CONTACT_NAME_KEY)\n if name:\n return ' {}'.format(name.split(' ')[0])", "def contact_full_name(self):\n first = self.contact_first_name\n last = self.contact_last_name\n if first and last:\n return f'{first} {last}'\...
[ "0.60656476", "0.6036715", "0.58960855", "0.5879749", "0.5824268", "0.57242966", "0.5672349", "0.56649154", "0.56594753", "0.5648827", "0.56370217", "0.5614726", "0.55946654", "0.5590085", "0.5577823", "0.5556776", "0.55301404", "0.5486221", "0.54791963", "0.5472377", "0.5447...
0.60292935
2
If opponent did not defect in first 7 rounds and the current round is from 8 to 180, return True. Else, return False.
def _opponent_triggers_alt_strategy(opponent: Player) -> bool: before_alt_strategy = first_n_rounds = 7 last_round_of_alt_strategy = 180 if _opponent_defected_in_first_n_rounds(opponent, first_n_rounds): return False current_round = len(opponent.history) + 1 return before_alt_strategy < curr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasWin(self) :\n comparison = self.compareNumberUser()\n if (comparison == 'equal') :\n return True\n else :\n return False", "def is_winning(self, curr_state):\n winning_combinations = [(0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)]\n ...
[ "0.7052794", "0.7049814", "0.6860032", "0.6838786", "0.67821", "0.67734504", "0.6751726", "0.67373693", "0.67115057", "0.670947", "0.6709172", "0.67056936", "0.66873807", "0.66754436", "0.6669558", "0.6657937", "0.66558623", "0.66521776", "0.6639915", "0.66145116", "0.6604215...
0.7024104
2
Convert a UTC datetime to a local timezone aware datetime.
def utc_to_local(utc_dt: datetime): utc_dt = utc_dt.replace(tzinfo=tz.gettz("UTC")) return utc_dt.astimezone(tz.tzlocal())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def utc_to_local_datetime(dt):\n return dt.astimezone(LOCAL)", "def utc_to_local(utc_dt: datetime) -> datetime:\n if utc_dt is None:\n return None\n local_dt = utc_dt.astimezone(tz.tzlocal())\n return local_dt", "def datetime_utc_to_local(dt):\n\n if type(dt) != datetime.datetime:\n ...
[ "0.7900555", "0.782654", "0.7825347", "0.78068715", "0.78055567", "0.7664376", "0.75477296", "0.74883157", "0.7459102", "0.745562", "0.745562", "0.745562", "0.73696595", "0.73594654", "0.7329128", "0.7315518", "0.7225434", "0.7159488", "0.70694953", "0.70017725", "0.69751024"...
0.7658484
6
Convert a local datetime to a UTC timezone aware datetime.
def local_to_utc(local_dt): local_dt = local_dt.replace(tzinfo=tz.tzlocal()) return local_dt.astimezone(tz.tzlocal())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_to_utc(local_dt: datetime) -> datetime:\n if local_dt is None:\n return None\n utc_dt = local_dt.astimezone(tz.UTC)\n return utc_dt", "def localToUTC(t, local_tz):\n t_local = local_tz.localize(t, is_dst=None)\n t_utc = t_local.astimezone(pytz.utc)\n return t_utc", "def local...
[ "0.8287512", "0.81530267", "0.7727855", "0.7727855", "0.7727855", "0.75681573", "0.74998", "0.73861265", "0.73799914", "0.7366012", "0.73063403", "0.72058237", "0.7192986", "0.71910477", "0.7143651", "0.71182036", "0.71056336", "0.70771176", "0.7045897", "0.70331764", "0.7025...
0.84535724
0
Sets the learning rate to the initial LR decayed by 10 every 30 epochs
def adjust_learning_rate(optimizer, epoch): lr = args.lr * (0.1**(epoch // 30)) for param_group in optimizer.param_groups: param_group['lr'] = lr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr", "def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l...
[ "0.79134107", "0.7906755", "0.7850054", "0.7775328", "0.773414", "0.7731414", "0.77228016", "0.7721925", "0.77193093", "0.77092254", "0.76932764", "0.76743245", "0.7665481", "0.7665481", "0.7665481", "0.7654962", "0.76418406", "0.7639415", "0.76375794", "0.7626146", "0.762473...
0.7588846
28
Return reward for each bandit. We sample the reward from normal distribution.
def step(self, action): # handling error assert (action < self.NumofBandits), "[ERROR] un-identified arm" # return reward. return 1 for success while 0 for failure return int(np.random.random() < self.prob[action])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rewards(self):\n for i in self.REWARDS:\n self.get_reward(i)", "def get_reward(self):\n \n ##get total reward value from Q\n total_reward = 0.0\n for value in self.Q.itervalues():\n total_reward = total_reward + value\n \n ##return th...
[ "0.6719637", "0.6447742", "0.6447742", "0.64104575", "0.6330021", "0.63227725", "0.63019806", "0.62858886", "0.6284767", "0.6270432", "0.62409127", "0.62245023", "0.62083197", "0.62067246", "0.61971927", "0.61877745", "0.61863387", "0.61597323", "0.6154886", "0.61548436", "0....
0.0
-1
Return reward for each bandit. We sample the reward from normal distribution.
def step(self, action): # handling error assert (action < self.NumofBandits)#, "[ERROR] un-identified arm" # return reward via sampling from normal distribution return np.random.normal(self.MeanList[action], self.sigma, 1)[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rewards(self):\n for i in self.REWARDS:\n self.get_reward(i)", "def get_reward(self):\n \n ##get total reward value from Q\n total_reward = 0.0\n for value in self.Q.itervalues():\n total_reward = total_reward + value\n \n ##return th...
[ "0.67188275", "0.64472455", "0.64472455", "0.63289034", "0.6322061", "0.63009375", "0.62848574", "0.6282357", "0.6269222", "0.6239948", "0.622316", "0.6206747", "0.6205615", "0.61963296", "0.6186974", "0.6185128", "0.6158747", "0.6153912", "0.6153713", "0.6151019", "0.6132025...
0.6409784
3
Pad lists (in a list) to make them of equal size and return a tensor.
def pad_lists(lists, pad_int, pad_len=None, dtype=torch.float, device=device): if pad_len is None: pad_len = max([len(lst) for lst in lists]) new_list = [] for lst in lists: if len(lst) < pad_len: new_list.append(lst + [pad_int] * (pad_len - len(lst))) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad_list(xs: torch.Tensor, pad_value: int):\n n_batch = len(xs)\n max_len = max(x.size(0) for x in xs)\n pad = xs[0].new(n_batch, max_len, *xs[0].size()[1:]).fill_(pad_value)\n\n for i in range(n_batch):\n pad[i, : xs[i].size(0)] = xs[i]\n\n return pad", "def collate_pad_tensors(sample_...
[ "0.7928946", "0.70802623", "0.7036446", "0.7004882", "0.69140816", "0.6833353", "0.6830676", "0.6824621", "0.675888", "0.671774", "0.6611086", "0.66103846", "0.65511066", "0.653545", "0.6519688", "0.6490463", "0.6470346", "0.6467035", "0.6462498", "0.6459834", "0.64073473", ...
0.8272532
0
Add values of one dictionary to another.
def add_dict(dest, src): for key in src.keys(): if key in dest.keys(): dest[key] += src[key] else: dest[key] = src[key]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iadd__(self, other):\n if not isinstance(other, dict):\n msg = 'Can not concatenate Dict and {}'.format(type(other))\n raise TypeError(msg)\n for key, val in other.items():\n if key in self:\n self._append_key(key, val)\n else:\n ...
[ "0.78800726", "0.78758186", "0.7720311", "0.7703897", "0.76613927", "0.7573357", "0.755781", "0.7509601", "0.7484375", "0.7423065", "0.74166244", "0.74166244", "0.7409427", "0.7409427", "0.7409427", "0.7409427", "0.7409427", "0.7409427", "0.7409427", "0.7409427", "0.74035805"...
0.77162653
3
Plot the MSE profile, values of which are recorded during training.
def cost_profile_plot(cost_values): ax = plt.figure(figsize = (7.5,4.5)).gca() cost_values = np.array(cost_values) span = np.arange(1,len(cost_values)+1) ax.plot(span,cost_values, color = 'k', alpha = 0.7) ax.xaxis.set_major_locator(MaxNLocator(integer=True)) ax.set_xlabel('Epoch') ax.s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_losses(train, test, mode):\n\tplt.figure()\n\tplt.plot(range(len(train)), train, 'r', label='Training')\n\tplt.plot(range(len(test)), test, 'b', label='Testing')\n\tplt.title('MSE Loss (batch type: ' + mode + ')')\n\tplt.legend()\n\tplt.show()", "def _plot_rmse(self, val=False):\n _, ax = plt.sub...
[ "0.68845105", "0.6802392", "0.65958416", "0.65566576", "0.6421743", "0.6320988", "0.6232892", "0.62275165", "0.6208934", "0.61788243", "0.61580956", "0.6141744", "0.60512906", "0.59781456", "0.59579766", "0.59454405", "0.59390724", "0.5923495", "0.59174556", "0.5905685", "0.5...
0.6050812
13
Return a JSON list of stations from the dataset.
def stations(): # Query results = session.query(Station.station).all() list = [] for result in results: list.append(result) return jsonify(list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stationdata():\n # * Return a JSON list of stations from the dataset.\n # as this should be a list, I'm just grabbing the station name\n session = Session(engine)\n results = session.query(Station.name).all()\n session.close()\n\n stations = list(np.ravel(results))\n return jsonify(stati...
[ "0.87502384", "0.87111616", "0.87103224", "0.8391929", "0.83858776", "0.8351123", "0.8318487", "0.83133906", "0.83088475", "0.82893324", "0.82849854", "0.82565653", "0.8246363", "0.82374954", "0.8237443", "0.82318974", "0.81887966", "0.81722414", "0.8110365", "0.8088061", "0....
0.8057517
22
Construct a test DriverManager Test instances are passed a list of extensions to work from rather than loading them from entry points.
def make_test_instance(cls, extension, namespace='TESTING', propagate_map_exceptions=False): o = super(DriverManager, cls).make_test_instance( [extension], namespace=namespace, propagate_map_exceptions=propagate_map_exceptions) return o
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_test_instance(cls, extensions, namespace='TESTING',\r\n propagate_map_exceptions=False):\r\n\r\n o = cls.__new__(cls)\r\n names = [e.name for e in extensions]\r\n o._init_attributes(namespace, names,\r\n propagate_map_exceptions=prop...
[ "0.68210334", "0.64566547", "0.6266577", "0.6199422", "0.6100687", "0.59511983", "0.59511983", "0.59273607", "0.5791091", "0.5771551", "0.5764548", "0.5736458", "0.57066774", "0.5698126", "0.568914", "0.5688465", "0.56750494", "0.5665882", "0.5660551", "0.56561756", "0.565304...
0.6960275
0
Construct a test ExtensionManager Test instances are passed a list of extensions to work from rather than loading them from entry points.
def make_test_instance(cls, extensions, namespace='TESTING', propagate_map_exceptions=False): o = cls.__new__(cls) o._init_attributes(namespace, propagate_map_exceptions=propagate_map_exceptions) o._init_plugins(extensions) re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_test_instance(cls, extensions, namespace='TESTING',\r\n propagate_map_exceptions=False):\r\n\r\n o = cls.__new__(cls)\r\n names = [e.name for e in extensions]\r\n o._init_attributes(namespace, names,\r\n propagate_map_exceptions=prop...
[ "0.683503", "0.6523426", "0.63674974", "0.63354075", "0.61325914", "0.5939689", "0.5933935", "0.59288704", "0.5856541", "0.58288246", "0.5825676", "0.5825676", "0.57974553", "0.5788786", "0.5779372", "0.57229006", "0.5717561", "0.57120913", "0.57022285", "0.56972903", "0.5691...
0.64716804
2
Produce iterator for the manager.
def __iter__(self): return iter(self.extensions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterator(self):\n yield", "def __iter__(self):\n return self.new_generator()", "def __iter__(self):\n items = self._fetch()\n for item in items:\n yield item", "def __iter__(self):\n for item in self._reader:\n yield item", "def __iter__(self):\n...
[ "0.75340784", "0.73575187", "0.7273645", "0.72415245", "0.70428497", "0.69231206", "0.6898364", "0.6839737", "0.68337345", "0.681993", "0.68043715", "0.6776717", "0.672246", "0.67145544", "0.66521364", "0.6611514", "0.65963024", "0.6593167", "0.6585427", "0.65735775", "0.6569...
0.0
-1
Construct a test NamedExtensionManager Test instances are passed a list of extensions to use rather than loading them from entry points.
def make_test_instance(cls, extensions, namespace='TESTING', propagate_map_exceptions=False): o = cls.__new__(cls) names = [e.name for e in extensions] o._init_attributes(namespace, names, propagate_map_exceptions=propagate_map_excepti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_test_instance(cls, extensions, namespace='TESTING',\r\n propagate_map_exceptions=False):\r\n\r\n o = cls.__new__(cls)\r\n o._init_attributes(namespace,\r\n propagate_map_exceptions=propagate_map_exceptions)\r\n o._init_plugins(extens...
[ "0.6400382", "0.6326444", "0.61112845", "0.6032441", "0.5863451", "0.58512866", "0.5825928", "0.57625884", "0.57516867", "0.5741049", "0.57076186", "0.5705964", "0.5683317", "0.567828", "0.5671668", "0.5671668", "0.5671478", "0.56609565", "0.56550723", "0.55624044", "0.555363...
0.682725
0
Returns True if the customer has not reached the checkout for the second time yet, False otherwise.
def is_active(self): if self.state != 'checkout': return True if self.state == 'checkout': return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_active(self):\n return self.state_after != 'checkout'", "def is_checked_out(self):\n return self._checkout_date is not None", "def is_active(self):\n if self.state[0] == 'checkout':\n return False\n else:\n return True", "def is_active(self):\n return s...
[ "0.64929485", "0.6470459", "0.63609177", "0.607506", "0.6039926", "0.60207117", "0.59912694", "0.5936701", "0.5877601", "0.58753103", "0.58472633", "0.58319205", "0.5771512", "0.57616276", "0.5664652", "0.5659652", "0.565341", "0.56347406", "0.5614151", "0.55955005", "0.55870...
0.6322319
3
Propagates the customer to the next state using a weighted random choice from the transition probabilities conditional on the current state. Returns nothing.
def next_state(self): self.state = np.random.choice(['checkout', 'dairy', 'drinks', 'fruit', 'spices'], p=self.tr_array_dict[f'{self.state}'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_state(self, current_state):\n return np.random.choice(\n self.states,\n p=self.transition_matrix[self.index_dict[current_state], :]\n )", "def next_state(self, current_state):\n\t\tchoices_amount = len(self.states)\n\t\tchoice_index = np.random.choice(\n\t\t\tchoices_amount, \n...
[ "0.6413612", "0.63567454", "0.63014746", "0.62140995", "0.61613214", "0.61054736", "0.608723", "0.6066509", "0.5973285", "0.5963853", "0.59341484", "0.5894978", "0.58632416", "0.58099186", "0.57741356", "0.5770447", "0.5762083", "0.5745629", "0.5739537", "0.5735988", "0.57331...
0.64606583
0
Return the eigenstuff of the normalized Laplacian matrix of graph associated with adjacency matrix A. Calculates via eigenvalues if K = D^(1/2) A D^(1/2) where `A` is the adjacency matrix and `D` is the diagonal matrix of node degrees. Since L = I K, the eigenvalues and vectors of L can be easily recovered.
def normalized_laplacian_eig(A, k=None): n, m = A.shape ## ## TODO: implement checks on the adjacency matrix ## degs = _flat(A.sum(axis=1)) # the below will break if inv_root_degs = [d ** (-1 / 2) if d > _eps else 0 for d in degs] inv_rootD = sps.spdiags(inv_root_degs, [0], n, n, format=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_eigen(self, left=False, **parameter_overrides):\n A, B = self.form_state_space_matrices(**parameter_overrides)\n\n if len(A.shape) == 3: # array version\n evals = np.zeros(A.shape[:2], dtype='complex128')\n evecs = np.zeros(A.shape, dtype='complex128')\n for...
[ "0.6362073", "0.635367", "0.6332865", "0.62966806", "0.62822485", "0.6276675", "0.6274914", "0.61986107", "0.6155604", "0.6097244", "0.60492", "0.6043199", "0.60268813", "0.60083264", "0.5970591", "0.59502953", "0.59069455", "0.5892187", "0.5877085", "0.5867786", "0.5853795",...
0.7696459
0
Pad A so A.shape is (N,N)
def _pad(A, N): n, _ = A.shape if n >= N: return A else: if issparse(A): # thrown if we try to np.concatenate sparse matrices side = sps.csr_matrix((n, N - n)) bottom = sps.csr_matrix((N - n, N)) A_pad = sps.hstack([A, side]) A_pad ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def padding(a, dim):\n\n return np.pad(a, (0, dim-len(a)), 'constant', constant_values=(0))", "def _pad(x, depth=4):\n divisor = np.power(2, depth)\n remainder = x.shape[0] % divisor\n\n # no padding because already of even shape\n if remainder == 0:\n return x\n # add zero rows after 1D...
[ "0.7302042", "0.7109349", "0.68898135", "0.68381727", "0.6645432", "0.6605946", "0.66048914", "0.659161", "0.65865594", "0.6565811", "0.65200776", "0.6506677", "0.64840966", "0.64758474", "0.6472073", "0.64639914", "0.64424163", "0.6419262", "0.6413586", "0.63964874", "0.6366...
0.7867299
0
Apply a reduction function over a given axis.
def _np_apply_along_axis(func1d, axis: int, arr: np.ndarray) -> np.ndarray: assert arr.ndim == 2 assert axis in [0, 1] if axis == 0: result = np.empty(arr.shape[1]) for i in range(len(result)): result[i] = func1d(arr[:, i]) return result result = np.empty(arr.shape...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce(self, ary, axis=0, out=None):\n from . import _bh\n\n if out is not None:\n if bhary.check(out):\n if not bhary.check(ary):\n ary = array_create.array(ary)\n else:\n if bhary.check(ary):\n ary = ary.c...
[ "0.6741761", "0.6684062", "0.63769835", "0.63107836", "0.6171605", "0.61247915", "0.6043316", "0.5966064", "0.5882841", "0.57360786", "0.57302636", "0.5667637", "0.56195", "0.5618175", "0.5597224", "0.55948985", "0.55537677", "0.5546106", "0.5494476", "0.54727393", "0.5468329...
0.7035871
0
In Windows return the path with the case it is stored in the filesystem
def normpath_with_actual_case(name): assert os.path.isabs(name) or os.path.ismount(name), "Not abs nor mount: " + name assert os.path.exists(name), "Not exists: " + name if os.name == "nt": name = os.path.realpath(name) from ctypes import create_unicode_buffer, windll buf = cre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(cls):\n from os.path import sep, join, exists\n from os import environ\n return join(environ.get(\"SystemRoot\", join(\"C:\", sep, \"Windows\")), \"System32\", \"mpclaim.exe\")", "def get_output_path():\n\n path = rs.DocumentPath()\n name = rs.DocumentName()\n \n if gc.o...
[ "0.7185384", "0.71397835", "0.7089066", "0.70267516", "0.7000493", "0.68770874", "0.6837504", "0.68313783", "0.6826676", "0.6817656", "0.67571396", "0.6720556", "0.67151684", "0.67130756", "0.6647219", "0.66304785", "0.65582865", "0.65368104", "0.6526411", "0.6507995", "0.649...
0.0
-1
Returns the average between list elements
def avg(l): return (sum(l)/float(len(l)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def avg(list):\n return sum(list) / len(list)", "def average(lst):\n return sum(lst)/len(lst)", "def average(l):\n return float(sum(l)/len(l))", "def avg(lst: list):\n return sum(lst) / len(lst)", "def _avg(cls, l):\n\n return sum(l) / float(len(l))", "def func(lst):\n tot = 0\n ...
[ "0.8697729", "0.85608894", "0.85284686", "0.85132545", "0.84142387", "0.82467264", "0.81847113", "0.81688476", "0.8168137", "0.81533706", "0.81466866", "0.81323886", "0.8113818", "0.80889785", "0.80831385", "0.80347633", "0.79539144", "0.7843527", "0.78250104", "0.7785941", "...
0.8581461
1
Return env var coerced into a type other than string. This function extends the standard os.getenv function to enable the coercion of values into data types other than string (all env vars are strings by default).
def _get_env(key, default=None, coerce=lambda x: x, required=False): try: value = os.environ[key] except KeyError: if required is True: raise RequiredSettingMissingError(key) else: return default try: return coerce(value) except Exception: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_env(key: str) -> str:\n value = os.getenv(key)\n assert isinstance(value, str), (\n f\"the {key} environment variable must be set and a string, \" f\"{value=}\"\n )\n return value", "def getenv(space, var):\n e = os.environ.get(var)\n if e is None:\n r...
[ "0.76501215", "0.7303949", "0.72537065", "0.70969427", "0.7068386", "0.7044829", "0.69519067", "0.6941644", "0.69243574", "0.6917646", "0.6864052", "0.68215847", "0.67054987", "0.6594356", "0.65189564", "0.65106696", "0.64454526", "0.6429852", "0.6423585", "0.64175195", "0.63...
0.6985049
6
Return env var cast as Decimal.
def get_envdecimal(key, *default): return get_env(key, *default, coerce=_decimal)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_env_as_float(varname, standard_value) -> float:\n return float(os.getenv(varname, standard_value))", "def env_var_float(key: str) -> float:\n try:\n return float(env_var_line(key))\n except (ValueError, TypeError):\n return 0", "def get_decimal(self):\n return self.decima...
[ "0.67681134", "0.66136485", "0.6281154", "0.62275624", "0.61424625", "0.61286604", "0.6054312", "0.5985711", "0.5914723", "0.5914723", "0.56757814", "0.5661769", "0.55677974", "0.5521617", "0.55185586", "0.54076403", "0.5345546", "0.5341182", "0.531731", "0.53090143", "0.5286...
0.743195
0
Return env var as a date.
def get_envdate(key, *default): return get_env(key, *default, coerce=_date)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_envdatetime(key, *default):\n return get_env(key, *default, coerce=_datetime)", "def get_date():\n now = datetime.now()\n date = now.strftime(\"%Y%m%d\")\n return date", "def get_date(date):\n return date", "def get_date(self):\n return self.date.strftime(\"%a %x\")", "def get...
[ "0.6968128", "0.6056123", "0.59355897", "0.5860234", "0.58551085", "0.5843248", "0.5822254", "0.5819293", "0.57896125", "0.5786972", "0.5774795", "0.57648563", "0.5726592", "0.5703257", "0.5671059", "0.56411946", "0.5633106", "0.56291234", "0.560024", "0.55212206", "0.5515892...
0.76205915
0
Return env var as a datetime.
def get_envdatetime(key, *default): return get_env(key, *default, coerce=_datetime)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_envdate(key, *default):\n return get_env(key, *default, coerce=_date)", "def get_date():\n\n return datetime.datetime.utcnow().isoformat()", "def getdate():\r\n import datetime\r\n return datetime.datetime.now()", "def _get_date():\n return datetime.datetime.now()", "def _time_string...
[ "0.7071849", "0.59546095", "0.59153426", "0.5906552", "0.5822599", "0.57773846", "0.5736514", "0.57009745", "0.5679071", "0.56064844", "0.5604816", "0.55953634", "0.5573831", "0.5569552", "0.55041194", "0.5493765", "0.5491371", "0.5489714", "0.5436459", "0.54062176", "0.53983...
0.77685875
0
Return env var as a dict.
def get_envdict(key, *default): return get_env(key, *default, coerce=_dict)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env_dict(self): # type: () -> t.Dict[str, str]\n return dict((item[0], item[1]) for item in [e.split('=', 1) for e in self.env])", "def _env(env):\n return dict((key.strip(), val)\n for line in env.strip().splitlines()\n for key, _, val in [line.partition('=')])", "def _gener...
[ "0.7834191", "0.7314489", "0.72624606", "0.7257618", "0.7250444", "0.72271985", "0.7154054", "0.7120214", "0.70461607", "0.70456606", "0.6999288", "0.6953993", "0.69387126", "0.6922534", "0.6922534", "0.6922534", "0.6922534", "0.6901835", "0.6897539", "0.6866394", "0.68658763...
0.73268276
1
Ensure that flask was set up correctly.
def test_index(self): tester = app.test_client(self) response = tester.get('/', content_type = 'html_text') self.assertEqual(response.status_code, 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_app():\n\n # 1 Create Flask application\n app = Flask(\n import_name=__name__,\n template_folder=\"templates\",\n static_folder=\"static\"\n )\n\n # 2 Update the apps configuration\n app = config_selector(app)\n register_error_handlers(app)\n\n cache.init_app(app...
[ "0.65213567", "0.6511258", "0.6488779", "0.6438346", "0.6426056", "0.64195246", "0.639304", "0.63141054", "0.6303326", "0.6283816", "0.62818795", "0.6274006", "0.6274006", "0.6244823", "0.6231454", "0.6229292", "0.62292063", "0.6157181", "0.61567634", "0.61461926", "0.6121306...
0.0
-1
Ensure index page loads the correct html.
def test_address_page(self): tester = app.test_client(self) response = tester.get('/', content_type = "html_text") self.assertTrue(b'Address Locator' in response.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_index_page(self):\n response = self.client.get(\"\")\n self.assertEqual(response.status_code, 200)\n self.assertTemplateUsed(response, \"search/base.html\")\n self.assertTemplateUsed(response, \"search/search_form.html\")\n self.assertTemplateUsed(response, \"search/inde...
[ "0.75835234", "0.7337169", "0.7254746", "0.7228072", "0.719496", "0.71897274", "0.71897274", "0.71897274", "0.7159639", "0.714778", "0.7092316", "0.70748943", "0.7063991", "0.70331514", "0.70152074", "0.7008574", "0.7008574", "0.69974965", "0.6994949", "0.69929343", "0.697841...
0.0
-1
Write out dictionary to json file
def write_dict_to_json(input_dictionary: dict, output_json_file_path: str): try: with open(output_json_file_path, "w") as outfile: json.dump(input_dictionary, outfile, indent=4) except Exception as err: logger.error(f"Failed to write out the file: {err}")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, _filepath=None):\n _json_txt = json.dumps(self.json_dict, indent=2)\n self._write_json_text(_json_txt, _filepath)", "def json_write(path, dictionary):\n json_output = json.dumps(dictionary, indent=4)\n with open(path, \"w\", encoding=\"utf-8\") as f:\n f.write(json_outp...
[ "0.81995416", "0.8187633", "0.81784356", "0.81601775", "0.80804926", "0.8072101", "0.8039865", "0.8031409", "0.79902846", "0.7973802", "0.7907194", "0.78902084", "0.78751594", "0.78143704", "0.76947194", "0.7672863", "0.7664839", "0.76622325", "0.76510084", "0.76499575", "0.7...
0.7370663
39
Returns True if the gridded perm `gp` is not required by any requirement list of the tiling.
def not_required(self, gp: GriddedPerm) -> bool: return all( any(gp not in req for req in req_list) for req_list in self._tiling.requirements )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _can_fuse_set_of_gridded_perms(\n self, fuse_counter: Counter[GriddedPerm]\n ) -> bool:\n return all(\n self._is_valid_count(count, gp) for gp, count in fuse_counter.items()\n )", "def check_position_is_legal(grid, num, i, j):\n args = (grid, num, i, j)\n return (not ...
[ "0.6223415", "0.611037", "0.60662913", "0.598745", "0.59720534", "0.59085554", "0.58274746", "0.5792744", "0.57842225", "0.5743536", "0.5741679", "0.5731525", "0.5724459", "0.57217807", "0.5704941", "0.5687381", "0.5682111", "0.5665865", "0.5648995", "0.5637984", "0.56355864"...
0.9139876
0
Check authentication with a bad password.
def test_bad_password(self): user = 'santos.gallegos' passw = '1234' result = self.ucuenca.authentication(user, passw) self.assertFalse(result['autenticacion'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_auth_password(self, username, password):\n return AUTH_FAILED", "def test_authenticate_invalid_password(self):\r\n print(\"Authenticate user invalid password (wrong)\")\r\n username = \"admin\"\r\n password = \"password9999\"\r\n\r\n self.assertEqual(self.system.authe...
[ "0.83268", "0.79804206", "0.76954114", "0.7669489", "0.765827", "0.7529443", "0.74932975", "0.74909323", "0.74781746", "0.7469865", "0.7434012", "0.74336827", "0.74277186", "0.74157834", "0.74099976", "0.7406136", "0.73766184", "0.7374548", "0.7330363", "0.7312958", "0.727881...
0.7906404
2
Returns db_client by name.
def get_db_client(self, connection_name: str) -> BaseDBAsyncClient: return self._db_client_map[connection_name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_client(self, name):\n return self.get_clients(as_dict=True).get(name)", "def get_client(self, clientname):\n client = self.dbsession.query(Client).filter_by(clientname=clientname).all()\n if not client:\n return self.create_client({'clientname': clientname})\n else:...
[ "0.78296703", "0.7668197", "0.74287224", "0.727629", "0.7272978", "0.71989816", "0.70706093", "0.70001584", "0.69900364", "0.698624", "0.6894745", "0.68710726", "0.6765762", "0.6756239", "0.6692928", "0.66787255", "0.6594556", "0.65889996", "0.6535446", "0.65013194", "0.64413...
0.7699964
1
Get model object for the given app_label, model_name if exists. Throws ConfigurationError if the app_label is not registered or the model_name is not registered within the app.
def get_app_model(self, app_label: str, model_name: str): if app_label not in self._app_models_map: raise ConfigurationError(f"No app with name '{app_label}' registered.") related_app = self._app_models_map[app_label] if model_name not in related_app: raise Configuratio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_model(self, app_label, model_name,\n seed_cache=True, only_installed=True):\n if seed_cache:\n self._populate()\n if only_installed and app_label not in self.app_labels:\n return None\n return self.app_models \\\n .get(app_label, Sorted...
[ "0.78485733", "0.7082722", "0.70226425", "0.6928417", "0.68882036", "0.6885856", "0.68026227", "0.6793628", "0.67777944", "0.6712374", "0.66769797", "0.6662793", "0.66241264", "0.66158926", "0.6583572", "0.6583498", "0.64938504", "0.64297664", "0.63554895", "0.63403225", "0.6...
0.82028925
0
Get the model object from the specified model. Throws ConfigurationError if the app_label is not registered or the model_name is not registered within the app.
def get_model(self, full_name: Union[Type[Model], str], reference_model: Type[Model]): if isinstance(full_name, str): name_parts = full_name.split(".") if len(name_parts) == 1: return self.get_app_model(reference_model._meta.app_label, full_name) elif len(na...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_app_model(self, app_label: str, model_name: str):\n\n if app_label not in self._app_models_map:\n raise ConfigurationError(f\"No app with name '{app_label}' registered.\")\n\n related_app = self._app_models_map[app_label]\n if model_name not in related_app:\n rais...
[ "0.80125505", "0.7660824", "0.72989625", "0.7265658", "0.7216853", "0.71832865", "0.71465296", "0.7118152", "0.70814025", "0.7041705", "0.6987792", "0.69459504", "0.6939642", "0.6913814", "0.68858165", "0.6831372", "0.67279863", "0.6714864", "0.6668034", "0.6626076", "0.66239...
0.67327976
16
Tries to drop all databases provided in config passed to ``.init()`` method. Normally should be used only for testing purposes.
async def drop_databases(self) -> None: if not self._inited: raise ConfigurationError("You have to call .init() first before deleting schemas") for db_client in self._db_client_map.values(): await db_client.close() await db_client.db_delete() self._reset()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_databases(self):\n\t\tfor db in self.test_dbs:\n\t\t\tif self.db_exists(db):\n\t\t\t\tself.drop_database(db)\n\t # leave some time for synchonization between nodes\n\t\t\ttime.sleep(3)\n\t\t\tself.create_database(db)\n\t\t\tself.create_index(db)", "def remove_dbs():\n conn = pm.MongoC...
[ "0.74539274", "0.7128077", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6883254", "0.6871104", "0.68534213", "0.68434805", "0.6834674", "0.68253684", "0.68212247", "0.68212247", "0.68138313", "0.6794285", "0.672502...
0.80037254
0
Name of the device.
def name(self): return self.raw.get("name")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self):\n return self._device.name", "def name(self):\n return self._device.name", "def name(self):\n return self._device.name", "def name(self):\n return f\"{get_device_name(self._data, 0, self._name)}\"", "def name(self):\n return self.device.name()", "def nam...
[ "0.90980077", "0.90980077", "0.90980077", "0.9062028", "0.9025963", "0.88166", "0.8686434", "0.8569197", "0.85582256", "0.8555482", "0.8555482", "0.85317177", "0.85317177", "0.8468815", "0.84063196", "0.8375968", "0.8366276", "0.8347895", "0.8282472", "0.8153554", "0.80649626...
0.0
-1
Human readable type of the device.
def type(self): return self.raw.get("type")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type(self) -> str:\n return self._device_info[\"Type\"]", "def type(self):\n return self._device.type_name", "def device_type(self):\n # type: () -> string_types\n return self._device_type", "def device_type(self) -> str:\n return self.profile_device.device_type", "de...
[ "0.85876435", "0.8561536", "0.84254235", "0.8390936", "0.8309306", "0.8309306", "0.8074338", "0.8051152", "0.79265195", "0.7829699", "0.7681807", "0.7592714", "0.7592481", "0.7592481", "0.7592481", "0.749323", "0.749323", "0.74519265", "0.73468775", "0.7281621", "0.724784", ...
0.0
-1
Compute the blocks. Returns list A list of blocks defined as simple meshes. Notes This method is used by the ``from_geometry`` constructor of the assembly data structure to create an assembly "from geometry".
def blocks(self): step_phi = (2 * pi - 0) / (2 * self.meridians) phi_delta = (2 * pi - 0) / self.meridians theta_delta = (self.spring - self.oculus) / self.hoops phi = [] for i in range(self.meridians + 1): phi.append(0 + i * phi_delta) theta = [] fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_blocks(self) -> list:\n self.clingo = ClingoBridge() # reset clingo\n\n base = ('base', '')\n self.clingo.add_file('initial-states.lp')\n self.clingo.run([base], n=1)\n output = self.clingo.output[0]\n\n blocks = []\n for atom in output:\n if ato...
[ "0.7377238", "0.71764034", "0.71163285", "0.67889595", "0.6671237", "0.65829414", "0.64209443", "0.6397945", "0.6170541", "0.61612225", "0.6155401", "0.61021245", "0.60757184", "0.60635793", "0.6054973", "0.5994955", "0.5989133", "0.59436375", "0.5941112", "0.5905711", "0.589...
0.5967128
17
Return an iterator itself.
def __iter__(self) -> Iterator[HiddenWord]: return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n return self.next()", "def __iter__(self):\n return self._next()", "def __iter__(self):\n return self._next()", "def __iter__(self):\n return self._next()", "def __next__(self):\n return next(self.iterator)", "def __iter__(self):\n self._firs...
[ "0.7915176", "0.78963923", "0.78963923", "0.78963923", "0.7860743", "0.7773823", "0.7739521", "0.76727694", "0.7556349", "0.75467515", "0.7486576", "0.7481177", "0.7448736", "0.7432475", "0.74168515", "0.7313966", "0.7313966", "0.7313966", "0.7313966", "0.7313966", "0.7313966...
0.0
-1
Generate hashes for files
def generate_hash(self, fname, args): fobj = self._open_file(fname, args.binary) hash_value = self._calculate_hash(fobj) line = '{0} {1}{2}\n'.format(hash_value, '*' if args.binary else ' ', fname) if '//' in line: line = '//' + line.rep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_hash(files: Iterable[str], root: str) -> str:\n file_hash = hashlib.md5()\n for file_name in sorted(files):\n file_path = os.path.join(root, file_name)\n file_hash.update((file_name + \"\\0\").encode())\n with open(file_path, \"rb\") as file_:\n # pylint: disabl...
[ "0.7723938", "0.7686026", "0.76240444", "0.7530267", "0.7373168", "0.7304723", "0.72284627", "0.7226467", "0.7151861", "0.71343106", "0.71280813", "0.7071096", "0.70319146", "0.7005902", "0.6999786", "0.6983353", "0.6967195", "0.6966729", "0.6966729", "0.69665474", "0.6963066...
0.7015337
13
Apply a 3D binary mask to a 1channel, 3D ndarray `img` by creating a 3channel image with masked regions shown in transparent blue.
def make_imgs(img: ndarray, imin: Any = None, imax: Any = None) -> [ndarray]: imin = img.min() if imin is None else imin imax = img.max() if imax is None else imax scaled = np.array(((img - imin) / (imax - imin)) * 255, dtype=int) # img if len(img.shape) == 3: return [scaled] * 3 raise Valu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_05_01_mask_of3D(self):\n x=cpi.Image()\n x.image = np.ones((10,10,3))\n self.assertTrue(x.mask.ndim==2)", "def apply_mask(im, mask, color=(1, 0, 0)):\n masked = np.zeros(im.shape)\n for x, y in mask: masked[x][y] = color\n return masked", "def apply_mask(image, mask, cls2...
[ "0.70189404", "0.6783082", "0.67464733", "0.6717791", "0.66600746", "0.6624861", "0.6616954", "0.66123575", "0.6611253", "0.65764576", "0.6551049", "0.65426993", "0.6517732", "0.64748716", "0.6459323", "0.6412765", "0.64072037", "0.6404231", "0.634529", "0.63237524", "0.62145...
0.0
-1
r"""Returns a list of all node types of the graph.
def node_types(self) -> List[NodeType]: return list(self._node_store_dict.keys())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_node_types(self):\n return list(nodelist.all_nodes.keys())", "def ntypes(self) -> Sequence[str]:\n ntypes = list(self.num_nodes_dict.keys())\n return ntypes", "def allNodeTypes(*args, includeAbstract: bool=True, **kwargs)->List[AnyStr]:\n pass", "def ntypes(self): # -> list[s...
[ "0.8699017", "0.7544778", "0.71158206", "0.687072", "0.668334", "0.666216", "0.6657601", "0.6638916", "0.6620646", "0.66054773", "0.65891874", "0.65883136", "0.657425", "0.65098506", "0.65061986", "0.639409", "0.6382757", "0.63734514", "0.63697994", "0.63673884", "0.6296806",...
0.794649
1
r"""Returns a list of all edge types of the graph.
def edge_types(self) -> List[EdgeType]: return list(self._edge_store_dict.keys())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_edge_types(schema_map):\n etypes = schema_map[constants.STR_EDGE_TYPE]\n etype_etypeid_map = {e: i for i, e in enumerate(etypes)}\n etypeid_etype_map = {i: e for i, e in enumerate(etypes)}\n return etype_etypeid_map, etypes, etypeid_etype_map", "def list_node_types(self):\n return list...
[ "0.6919327", "0.6717635", "0.67048246", "0.66213083", "0.65957046", "0.659519", "0.6545016", "0.64593863", "0.6416189", "0.63508534", "0.63071203", "0.6303682", "0.62558943", "0.6243591", "0.6243591", "0.6243591", "0.6243591", "0.6243591", "0.6243591", "0.622016", "0.6205077"...
0.84606266
0
r"""Returns a list of all edge storages of the graph.
def edge_stores(self) -> List[EdgeStorage]: return list(self._edge_store_dict.values())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edge_items(self) -> List[Tuple[EdgeType, EdgeStorage]]:\n return list(self._edge_store_dict.items())", "def edges(self):\r\n return self.capacity.keys()", "def edges_list(self):\n return self._edges_list", "def edge_types(self) -> List[EdgeType]:\n return list(self._edge_store...
[ "0.7861114", "0.6988891", "0.69227576", "0.67443895", "0.67098343", "0.66551125", "0.66181535", "0.6594692", "0.6589905", "0.6551342", "0.6551342", "0.6551342", "0.6551342", "0.6551342", "0.6551342", "0.65036345", "0.65020996", "0.64662606", "0.646204", "0.6430415", "0.640389...
0.81558895
0
Get absolute path to resource, works for dev and for PyInstaller
def resource_path(relative_path=None): try: # PyInstaller creates a temp folder and stores path in _MEIPASS base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") if not relative_path: return base_path return os.path.join(base_path, relative_path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep", "def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa...
[ "0.83695304", "0.8280964", "0.8249083", "0.81390584", "0.81140167", "0.8098592", "0.80797243", "0.8067683", "0.8067355", "0.80624765", "0.80624765", "0.80624765", "0.80624765", "0.80624765", "0.80624765", "0.80624765", "0.8056985", "0.80545896", "0.80448395", "0.80448395", "0...
0.8094061
6
Return a unittest.TestSuite to be used by test.py.
def suite(): return unittest.makeSuite(OpenedTestCase)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTestSuite():\n test_suite = unittest.TestSuite([])\n\n test_suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestDistReaders))\n test_suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestPySnpTools))\n test_suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestDistri...
[ "0.86233354", "0.8542358", "0.8460056", "0.8416129", "0.8415284", "0.83607024", "0.8335729", "0.830533", "0.82570344", "0.82052696", "0.81683713", "0.8149417", "0.81144106", "0.80783606", "0.807753", "0.80536795", "0.8046343", "0.8034924", "0.8033455", "0.8013062", "0.7994615...
0.78976077
27