query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Initializes indicating root Python module. The application will look for all `Resource` classes defined in the given root module.
def __init__(self, root): self._root = root if not self.get_resources(): raise Exception('Your application has no Resource.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, basedir=None):\n # ------------------------------------------------------------------------\n super(Resources, self).__init__()\n self.xInitialize(basedir or \"resources\")", "def __init__(self):\n self.modules = {}", "def init(self):\n\n self.loaded = False\n ...
[ "0.6172543", "0.6130026", "0.58406955", "0.5820272", "0.5808664", "0.56877095", "0.5673514", "0.5664736", "0.5635875", "0.561636", "0.5615964", "0.559234", "0.5569267", "0.5522192", "0.5514438", "0.5474632", "0.54634255", "0.54632753", "0.5462733", "0.54501873", "0.5443123", ...
0.7221802
0
Starts WSGI application flow.
def __call__(self, environ, start_response): middleware = Middleware(environ, start_response) middleware.application = self return middleware
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\r\n run_wsgi_app(app)", "def main():\n run_wsgi_app(APP)", "def start():\n from paste.deploy import loadapp, loadserver\n from moksha.config.environment import load_environment\n from moksha.config.middleware import make_app\n ini = 'config:' + path('development.ini').abspath()\n ...
[ "0.79540753", "0.77699536", "0.72703", "0.7218581", "0.7189519", "0.71686983", "0.7069771", "0.70377684", "0.70257485", "0.6954285", "0.69124424", "0.6888019", "0.6877595", "0.68580186", "0.68424517", "0.677765", "0.66754097", "0.66459525", "0.6637033", "0.6628596", "0.662671...
0.0
-1
Sinusoid position encoding table
def get_sinusoid_encoding_table(n_position, d_hid, padding_idx=None): def cal_angle(position, hid_idx): return position / np.power(10000, 2 * (hid_idx // 2) / d_hid) def get_posi_angle_vec(position): return [cal_angle(position, hid_j) for hid_j in range(d_hid)] sinusoid_table = np.array( [get_posi_angle_vec(pos_i) for pos_i in range(n_position)] ) sinusoid_table[:, 0::2] = np.sin(sinusoid_table[:, 0::2]) # dim 2i sinusoid_table[:, 1::2] = np.cos(sinusoid_table[:, 1::2]) # dim 2i+1 if padding_idx is not None: # zero vector for padding dimension sinusoid_table[padding_idx] = 0.0 return torch.FloatTensor(sinusoid_table)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_sinusoid_encoding_table(self, n_position, d_hid):\n denominator = torch.Tensor([\n 1.0 / np.power(10000, 2 * (hid_j // 2) / d_hid)\n for hid_j in range(d_hid)\n ])\n denominator = denominator.view(1, -1)\n pos_tensor = torch.arange(n_position).unsqueeze(-1...
[ "0.7326898", "0.72803426", "0.66477567", "0.6008105", "0.6005823", "0.59894025", "0.56817", "0.5652626", "0.56051815", "0.5601691", "0.5469565", "0.5458949", "0.5339877", "0.53386784", "0.53131545", "0.5309653", "0.52948576", "0.52931553", "0.52630687", "0.5255187", "0.524431...
0.6543115
3
Process data and return preprocessor instance
def process_data(self, clip_name) -> Preprocessor: config: Config = Config.get_config() folder_name = config.video_data video_data_file = ''.join(clip_name.split('.')[:-1]) + '.json' video = Video.from_json(os.path.join(folder_name, video_data_file)) # Convert to usable data type period_running_person division, alle fragment soorten preprocessor = Preprocessor(video) return preprocessor
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(self,data):\n preprocessObj = PreprocessData()\n preprocess_data = preprocessObj.preprocess(data)\n return preprocess_data", "def preprocess(data):\n raise NotImplementedError", "def main():\n p = DataPreprocessor()\n p.preprocess_and_save_data(p.path_to_file)", "...
[ "0.69076425", "0.66020375", "0.64183813", "0.62324464", "0.61948276", "0.6038848", "0.59573555", "0.5956903", "0.5925527", "0.5921275", "0.59206593", "0.5867471", "0.58528507", "0.5809913", "0.5783746", "0.5756985", "0.5732583", "0.5712453", "0.57105845", "0.56719923", "0.566...
0.6266177
3
Function to construct all plottable files. In principle to be used for visualisation.
def get_plottables(self, period_person_division, running_person_identifiers, running_fragments, turning_fragments): period_running_person_division = {period: {person: coords for person, coords in period_dictionary.items() if person in running_person_identifiers} for period, period_dictionary in period_person_division.items()} running_plottables = { period: {person: coords for person, coords in period_dictionary.items() if person in running_person_identifiers} for period, period_dictionary in period_person_division.items() if any(lower <= period <= upper for (lower, upper) in running_fragments)} turning_plottables = { period: {person: coords for person, coords in period_dictionary.items() if person in running_person_identifiers} for period, period_dictionary in period_person_division.items() if any(lower <= period <= upper for (lower, upper) in turning_fragments)} period_running_person_division = dict(filter(lambda x: x[1] != {}, period_running_person_division.items())) running_plottables = dict(filter(lambda x: x[1] != {}, running_plottables.items())) turning_plottables = dict(filter(lambda x: x[1] != {}, turning_plottables.items())) return period_running_person_division, running_plottables, turning_plottables
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_html(self, workdir, templatePath, imgFormat):\n plot_tables = []\n plot_set = [ self._expectedPlots_globalAvg, self._expectedPlots_Nino, self._expectedPlots_transportDiags ]\n\n # build up the plot_tables array\n for k in range(len(plot_set)):\n plot_table = []\n ...
[ "0.6867469", "0.6389346", "0.63584435", "0.63152426", "0.6292773", "0.6279732", "0.62315065", "0.6176681", "0.6134976", "0.6134058", "0.6121338", "0.6118336", "0.6118336", "0.60832316", "0.6075302", "0.60436225", "0.6041428", "0.6038445", "0.59721166", "0.5969328", "0.5969005...
0.0
-1
Initialize function which will be called to create the base frame upon which the animation takes place. This is used for blitting to create smoother animations
def func_init(self): self.points.set_data([], []) for line in self.lines: line.set_data([],[]) self.annotation.set_text('') return tuple(self.lines) + (self.points, self.annotation)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_frame(self : \"animation\",\n init_frame : \"matplotlib.figure.Figure\",\n init_ax : \"matplotlib.axes._subplots.AxesSubplot\"\n ):\n self._cframe = init_frame.canvas.copy_from_bbox(init_ax.bbox)", "def _init_anim(self):\n pass", ...
[ "0.723336", "0.72250724", "0.70384264", "0.70372236", "0.6962778", "0.69174445", "0.6851278", "0.6720123", "0.6609182", "0.6556792", "0.65386903", "0.65386903", "0.65386903", "0.65386903", "0.6523569", "0.64849484", "0.64721674", "0.6449021", "0.64271384", "0.64042795", "0.64...
0.0
-1
Function that is used by matplotlib.animation.FuncAnimation to iteratively plot given a frame
def plot_person(self, frame, plottables, image_h, image_w, zoom=True, pad=3): for person in plottables[frame].keys(): plot_coords = plottables[frame][person] plot_coords[:, 1] = plot_coords[:, 1] + image_h coord_dict = {key: value for key, value in dict(enumerate(plot_coords[:, :2])).items() if not (value == 0).any()} present_keypoints = set(coord_dict.keys()) present_connections = [connection for connection in self.connections if len(present_keypoints & set(connection)) == 2] plot_lines = [np.transpose([coord_dict[a], coord_dict[b]]) for a, b in present_connections] for coords, line in zip_longest(plot_lines, self.lines): if isinstance(coords, np.ndarray): line.set_data(coords[0],coords[1]) else: line.set_data([],[]) plot_coords = plot_coords[~(plot_coords == 0).any(axis=1)] self.points.set_data(plot_coords[:, 0], plot_coords[:, 1]) self.annotation.set_text('Frame: {}'.format(frame)) self.ax.set_xlabel('X coordinate') self.ax.set_ylabel('Y coordinate') if zoom: aspect = image_w / image_h xlow, xhigh = plot_coords[:, 0].min(), plot_coords[:, 0].max() # get x higher and lower limit xdiff = xhigh - xlow # calculate the total range of x xpad = ((self.ydiff * aspect) - xdiff) / 2 # calculate how much the xlimits should be padded on either side to set aspect ratio correctly self.ax.set_xlim(xlow - xpad, xhigh + xpad) # set new limits break return tuple(self.lines) + (self.points, self.annotation)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def animate(i):\r\n plot_x.set_data(history_samples[i][:, 0], history_samples[i][:, 1])", "def run_animation(self):\n\n def _get_frame(frame_index, plots):\n \"\"\" Should be called by run_animations only. \"\"\"\n\n # TODO Using the indices of the self.frames, plot in correct loc...
[ "0.70611054", "0.69869083", "0.6971987", "0.689324", "0.68860537", "0.6854017", "0.68523353", "0.65770304", "0.65645885", "0.6556076", "0.65512234", "0.6524661", "0.6517934", "0.65143037", "0.6452433", "0.64289904", "0.64282256", "0.6403286", "0.6378409", "0.63592017", "0.624...
0.0
-1
Complete pipeline to process and plot data.
def run_animation(self, clip_name, fragment, zoom=True, pad=3, interval=100): preprocessor = self.process_data(clip_name) period_person_division = preprocessor.period_person_division running_person_identifiers = preprocessor.get_running_person_identifiers() running_fragments = preprocessor.get_running_fragments() turning_fragments = preprocessor.get_turning_fragments() period_running_person_division, running_plottables, turning_plottables = self.get_plottables(period_person_division, running_person_identifiers, running_fragments, turning_fragments) if fragment == 'run': plottables = running_plottables elif fragment == 'turn': plottables = turning_plottables else: plottables = period_running_person_division self.set_axis_limits(plottables, preprocessor.height, preprocessor.width, zoom=zoom, pad=pad) animate = animation.FuncAnimation(fig=self.fig, func=self.plot_person, frames=plottables.keys(), fargs=(plottables, preprocessor.height, preprocessor.width, zoom, pad), interval=interval, init_func=self.func_init, blit=False, repeat=False) plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n self.set_pipeline()\n self.pipeline.fit(self.X, self.y)", "def main():\n df_data = import_clean_process()\n plot_data_matplotlib(df_data)\n return", "def pipeline_finished(self, pipeline):\n\n # Get the sizes of all output adios files\n self._get_adios_meta...
[ "0.6797422", "0.67031926", "0.63262737", "0.62594944", "0.6251043", "0.62087804", "0.61756724", "0.61126584", "0.61017734", "0.60401547", "0.59446293", "0.59367925", "0.592344", "0.5875977", "0.58692324", "0.5868876", "0.5862814", "0.5774588", "0.5762678", "0.5713469", "0.569...
0.0
-1
Initializes the dataset for loading.
def __init__( self, train_batch_size=1, val_batch_size=1, cuda=False, num_workers=1, path=None, random_resize_crop=(0, 0), scale=(0, 0), horizontal_flip_prob=0.0, vertical_flip_prob=0.0, gaussian_blur_prob=0.0, rotate_degree=0.0, cutout_prob=0.0, cutout_dim=(8, 8), hue_saturation_prob=0.0, contrast_prob=0.0 ): self.cuda = cuda self.num_workers = num_workers self.path = path self.train_batch_size = train_batch_size self.val_batch_size = val_batch_size self.sampler = None if not os.path.exists(self.path): raise ValueError('Invalid path specified.') # Set data augmentation parameters self.random_resize_crop = random_resize_crop self.scale = scale self.horizontal_flip_prob = horizontal_flip_prob self.vertical_flip_prob = vertical_flip_prob self.gaussian_blur_prob = gaussian_blur_prob self.rotate_degree = rotate_degree self.cutout_prob = cutout_prob self.cutout_dim = cutout_dim self.hue_saturation_prob = hue_saturation_prob self.contrast_prob = contrast_prob # Get dataset statistics self.image_size = self._get_image_size() self.mean = self._get_mean() self.std = self._get_std() # Get data self._split_data()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_al_dataset(self):\n\n self._init_dataset()\n\n train_dataset = self.datasets['train']\n\n dataset_size = len(train_dataset)\n self.budget = math.ceil(self.budget_frac*dataset_size)\n Sampler.__init__(self, config, self.budget) # TODO: Weird place to initialise this\...
[ "0.76784205", "0.757365", "0.7362059", "0.7325153", "0.7320442", "0.72897947", "0.720113", "0.7199336", "0.7177944", "0.7079859", "0.705883", "0.7033235", "0.7033188", "0.6956903", "0.69027686", "0.6867748", "0.68586814", "0.6850223", "0.68302983", "0.6828051", "0.6822883", ...
0.0
-1
Split data into training and validation set.
def _split_data(self): # Set training data self.train_data = torchvision.datasets.ImageFolder( os.path.join(self.path, 'train'), transform=self._transform() ) self.classes = self.train_data.classes # Set validation data self.val_data = torchvision.datasets.ImageFolder( os.path.join(self.path, 'test'), transform=self._transform(train=False) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_data_into_training_and_validation(self, data):\n training_dataset = self.get_data_from_indices(data, np.arange(self.num_training_samples))\n validation_dataset = self.get_data_from_indices(data, np.arange(self.num_training_samples,\n ...
[ "0.8642924", "0.83752245", "0.8353596", "0.8348435", "0.81380725", "0.80903614", "0.8082711", "0.7984082", "0.7881793", "0.78108215", "0.7794041", "0.76179", "0.761665", "0.7565056", "0.75570375", "0.7532845", "0.75105983", "0.75036824", "0.7495741", "0.7445284", "0.7443028",...
0.7568678
13
Return shape of data i.e. image size.
def _get_image_size(self): return (3, 224, 224)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_shape(self):\n return self.data.shape[:2]", "def image_shape(self):\n return self.data.shape[:2]", "def shape(self):\n return self.data.shape", "def shape(self):\n return self.data.shape", "def shape(self):\n return self.data.shape", "def shape(self):\n ...
[ "0.82124084", "0.82124084", "0.8147183", "0.8147183", "0.8147183", "0.8147183", "0.8147183", "0.80937505", "0.8010233", "0.8006064", "0.8006064", "0.8006064", "0.80019945", "0.79247403", "0.79092556", "0.78679425", "0.786282", "0.7814866", "0.7725889", "0.76113486", "0.75898"...
0.0
-1
Returns mean of the entire dataset.
def _get_mean(self): return (0.485, 0.456, 0.406)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean(self):\r\n return np.mean(self.data_array)", "def mean(self):\n return self.data.mean(axis=-1, keepdims=True)", "def mean(self):\n return self.aggregate(np.mean)", "def Mean(data):\n return data.mean()", "def mean(self):\n mean = sum(self.data)/self.size\n ret...
[ "0.82411206", "0.8131355", "0.8031648", "0.8015793", "0.79474837", "0.7917345", "0.7879034", "0.78769094", "0.7875092", "0.78153133", "0.76866186", "0.767841", "0.7648848", "0.7648848", "0.75604665", "0.7517856", "0.74952906", "0.7446794", "0.7446794", "0.7446794", "0.7443946...
0.0
-1
Returns standard deviation of the entire dataset.
def _get_std(self): return (0.229, 0.224, 0.225)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_std_dev(self, data):\n mean = 0\n data_arr = []\n for i in data:\n data_arr.append(i[1])\n return statistics.stdev(data_arr)", "def get_stddev(self):\r\n for i in range(1,len(self.data[0])):\r\n self.stddev.append(np.std(self.data[:,i]))", ...
[ "0.84144866", "0.82050383", "0.8168596", "0.8070408", "0.7985524", "0.796877", "0.79068154", "0.78719604", "0.78662646", "0.7861871", "0.7861871", "0.7852831", "0.78476846", "0.7799383", "0.77913153", "0.7748432", "0.7714268", "0.7689626", "0.76288074", "0.76285523", "0.76158...
0.0
-1
Return data based on train mode.
def data(self, train=True): data = self.train_data if train else self.val_data return data.data, data.targets
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data_train(self):\n return self.get_data(self.file_train, self.batch)", "def get_train_data():\n # train set\n train = pd.read_csv(\"train.csv\")\n\n return train", "def getTrainingData(self):\n raise NotImplementedError", "def train_data(self):\n return self._train_data...
[ "0.71724296", "0.70787793", "0.7011355", "0.6915143", "0.67346495", "0.6732012", "0.66541547", "0.66510093", "0.66510093", "0.66229326", "0.6598379", "0.658925", "0.6583259", "0.65264785", "0.6473328", "0.645411", "0.6418035", "0.6416727", "0.6339897", "0.6322232", "0.6320401...
0.6745248
4
Unnormalize a given image.
def unnormalize(self, image, transpose=False): return unnormalize(image, self.mean, self.std, transpose)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalise(image):", "def normalize_image(img):\n arr = np.array(img)\n new_img = Image.fromarray(normalize(arr).astype('uint8'),'L')\n return new_img", "def reverse_normalize(image):\n\n reverse = transforms.Normalize(mean=[-0.485 / 0.229, -0.456 / 0.224, -0.406 / 0.255],\n ...
[ "0.78914344", "0.76616216", "0.7482308", "0.7246689", "0.7187682", "0.71326315", "0.71250784", "0.69919527", "0.6929422", "0.6927052", "0.6911609", "0.6908462", "0.6908327", "0.69034034", "0.6890873", "0.6881274", "0.6876974", "0.68578804", "0.6824972", "0.68119633", "0.67838...
0.7967136
0
Normalize a given image.
def normalize(self, image, transpose=False, data_type=None): return normalize(image, self.mean, self.std, transpose)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalise(image):", "def normalize(image):\n min = np.min(image)\n max = np.max(image)\n normalImg = 255*(image - min) / (max - min)\n return normalImg", "def normalize_image(img):\n min_, max_ = float(np.min(img)), float(np.max(img))\n return (img - min_) / (max_ - min_)", "def normali...
[ "0.82951486", "0.8158422", "0.81137586", "0.8056085", "0.8043467", "0.80207026", "0.79855645", "0.79698676", "0.79609406", "0.79318285", "0.79120314", "0.78832763", "0.78212625", "0.7805976", "0.78015596", "0.77725065", "0.77711695", "0.77530694", "0.77530694", "0.774932", "0...
0.73125774
39
Handle imbalanced dataset through sampler.
def create_class_imbalance_sampler(self): count = [0] * len(self.classes) for item in self.train_data.imgs: count[item[1]] += 1 weight_per_class = [0.] * len(self.classes) for i in range(len(self.classes)): weight_per_class[i] = float(sum(count)) / float(count[i]) weights = [0] * len(self.train_data.imgs) for idx, val in enumerate(self.train_data.imgs): weights[idx] = weight_per_class[val[1]] weights = torch.DoubleTensor(weights) self.sampler = torch.utils.data.sampler.WeightedRandomSampler( weights, len(weights) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def balanced_sampling(dat: pd.DataFrame, logger=None):\n if logger == None:\n logging.basicConfig(\n level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n logger = logging.getLogger(__name__)\n \n \n # upsampling\n logger.info('Start balanced s...
[ "0.62204057", "0.61685914", "0.5826256", "0.5715278", "0.5707387", "0.5623797", "0.561231", "0.55672514", "0.5549182", "0.54543215", "0.5443967", "0.5442228", "0.5435967", "0.54301053", "0.5364784", "0.53321433", "0.53314674", "0.5326067", "0.5314146", "0.5309174", "0.5304186...
0.6245745
0
Load user with specified user ID.
def load_user(user_id): return User.query.get(int(user_id))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_user(user_id):\n return User.get_by_id(int(user_id))", "def load_user(user_id):\n return User.get_by_id(int(user_id))", "def load_user(user_id):\n return User.get_by_id(int(user_id))", "def load_user(user_id):\r\n return User.query.get(int(user_id))", "def load_user(id):\n return Us...
[ "0.8794154", "0.8794154", "0.8794154", "0.86955374", "0.8691932", "0.8611956", "0.857735", "0.8548633", "0.8518415", "0.8518415", "0.8510647", "0.8510647", "0.8510647", "0.8510647", "0.8504149", "0.84574586", "0.8455236", "0.84108514", "0.83591974", "0.8340407", "0.83372307",...
0.8645434
10
Get the selected locale from user settings.
def get_locale(): setting = Setting.query.filter(Setting.name == 'default_language').first() if setting is not None: return setting.value # Return default language when none found return 'en'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_locale():\n localLang = request.args.get('locale')\n supportLang = app.config['LANGUAGES']\n if localLang in supportLang:\n return localLang\n userId = request.args.get('login_as')\n if userId:\n localLang = users[int(userId)]['locale']\n if localLang in supportLang:\n ...
[ "0.7412174", "0.7108176", "0.69538045", "0.69421023", "0.68359756", "0.67491263", "0.67384523", "0.6731309", "0.650032", "0.63808835", "0.6361166", "0.63441944", "0.63441944", "0.6340159", "0.62725174", "0.61259097", "0.6097418", "0.6096102", "0.60663605", "0.60374147", "0.60...
0.73380387
1
Jinja2 filter to slugify text.
def slug(value): return slugify(value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slugified(text):\n return re.sub(\"-+\", \"-\", re.sub(r\"\\W\", \"-\", text.lower()))", "def slugify(text: str) -> str:\n return text.strip().replace(', ', '-').replace(' ', '_').lower()", "def slugify(text):\n concatenated = re.sub('\\s+', '-', text.lower())\n return re.sub('[^A-Za-z0-9_-]', ...
[ "0.7214419", "0.71937776", "0.70771027", "0.6860676", "0.6856058", "0.6818637", "0.68092954", "0.67907774", "0.6787663", "0.67330647", "0.67148125", "0.66974", "0.66480976", "0.6628109", "0.6619934", "0.6606258", "0.6593922", "0.6590047", "0.6588239", "0.65801233", "0.6554873...
0.7127615
2
Jinja2 filter to get language object from language code.
def language_name(value): return pycountry.languages.get(alpha_2=value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lang(context, field):\n lang = json.load(open(\"json/lang.json\", \"r\"))\n conf = json.load(open(\"json/serverconfig.json\", \"r\"))\n return lang[conf[str(context)][\"lang\"]][field]", "def language_code(self) -> str:\n return pulumi.get(self, \"language_code\")", "def get_language(se...
[ "0.6488083", "0.6458506", "0.64521635", "0.6425052", "0.6333819", "0.63314784", "0.62535805", "0.6156458", "0.61025834", "0.60967314", "0.60901237", "0.60439485", "0.602857", "0.60120213", "0.59964323", "0.5989398", "0.5981419", "0.5978724", "0.59718126", "0.59527946", "0.593...
0.6110068
8
Decodes a Base58Check encoded key.
def from_b58check(key): return HDKey.from_bytes(base58.b58decode_check(key))[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base58_decode(v: bytes) -> bytes:\n try:\n prefix_len = next(\n len(encoding[2])\n for encoding in base58_encodings\n if len(v) == encoding[1] and v.startswith(encoding[0])\n )\n except StopIteration:\n raise ValueError('Invalid encoding, prefix or le...
[ "0.65961087", "0.6403686", "0.6391344", "0.63413113", "0.6321229", "0.6299899", "0.61630493", "0.6157103", "0.61495435", "0.60469747", "0.600818", "0.59588367", "0.5914103", "0.5791583", "0.57892734", "0.5774782", "0.5729094", "0.5713923", "0.5695626", "0.5672472", "0.5671971...
0.74329513
0
Generates either a HDPrivateKey or HDPublicKey from the underlying bytes.
def from_bytes(b): if len(b) < 78: raise ValueError("b must be at least 78 bytes long.") version = int.from_bytes(b[:4], 'big') depth = b[4] parent_fingerprint = b[5:9] index = int.from_bytes(b[9:13], 'big') chain_code = b[13:45] key_bytes = b[45:78] rv = None if version == HDPrivateKey.MAINNET_VERSION or version == HDPrivateKey.TESTNET_VERSION: if key_bytes[0] != 0: raise ValueError("First byte of private key must be 0x00!") private_key = int.from_bytes(key_bytes[1:], 'big') rv = HDPrivateKey(key=private_key, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) elif version == HDPublicKey.MAINNET_VERSION or version == HDPublicKey.TESTNET_VERSION: if key_bytes[0] != 0x02 and key_bytes[0] != 0x03: raise ValueError("First byte of public key must be 0x02 or 0x03!") public_key = PublicKey.from_bytes(key_bytes) rv = HDPublicKey(x=public_key.point.x, y=public_key.point.y, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) else: raise ValueError("incorrect encoding.") return (rv, b[78:])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_ecdh_key_pair() -> tuple[X25519PrivateKey, bytes]:\n private_key = X25519PrivateKey.generate()\n public_key_raw = private_key.public_key().public_bytes(\n serialization.Encoding.Raw, serialization.PublicFormat.Raw\n )\n return private_key, public_key_raw", "def mk_keyobj_from_priv...
[ "0.6803569", "0.6298475", "0.6296541", "0.61843973", "0.6125002", "0.6038086", "0.6034926", "0.6032014", "0.6002514", "0.5997152", "0.598115", "0.59766436", "0.59530914", "0.59374905", "0.59370124", "0.5930606", "0.588195", "0.5862614", "0.5829133", "0.5813407", "0.58064556",...
0.7741583
0
Whether or not this is a master node.
def master(self): return self.depth == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_node_master(self) -> bool:\n self._assert_local_rank_set()\n return self.local_rank == 0", "def is_master(self):\n return self._is_master", "def is_master(self):\n return MPControl.is_master", "def is_master(self) -> bool:\n return self.zone.SharedRoomID and self.zon...
[ "0.8737156", "0.8224543", "0.8093627", "0.8079041", "0.787273", "0.7678137", "0.7496142", "0.7409133", "0.7236752", "0.7206599", "0.71834207", "0.6667358", "0.6657551", "0.66142035", "0.64824533", "0.6475769", "0.6441394", "0.6434042", "0.639641", "0.6376803", "0.6363649", ...
0.71505064
11
Whether or not this is a hardened node. Hardened nodes are those with indices >= 0x80000000.
def hardened(self): # A hardened key is a key with index >= 2 ** 31, so # we check that the MSB of a uint32 is set. return self.index & 0x80000000
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_leaf(self):\r\n return self.zero_son is None and self.one_son is None", "def is_internal(self):\n if self.is_leaf() or self.is_semileaf():\n return False\n return True", "def node_inode(self):\n return False", "def node_inode(self):\n return False", "d...
[ "0.62713253", "0.60492986", "0.5942298", "0.5942298", "0.5901078", "0.57642645", "0.5762194", "0.5736317", "0.57134473", "0.5682844", "0.5674507", "0.5665041", "0.56444204", "0.5642746", "0.56300306", "0.55741334", "0.55603236", "0.55570173", "0.55541235", "0.5552279", "0.552...
0.68602026
0
Returns the identifier for the key.
def identifier(self): raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_key_id(self):", "def key(key):\n return key", "def key_id(self):\n return self._key_id", "def key(self):\n return str(self._id)", "def key(self) -> str:\n return pulumi.get(self, \"key\")", "def key(self) -> str:\n return pulumi.get(self, \"key\")", "def key(s...
[ "0.8199289", "0.8123676", "0.79820096", "0.79350626", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", "0.78921616", ...
0.0
-1
Returns the key's fingerprint, which is the first 4 bytes of its identifier.
def fingerprint(self): return self.identifier[:4]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fingerprint(public_key):\r\n\r\n return hashlib.new('ripemd160', hashlib.sha256(public_key).digest()).digest()[:4]", "def fingerprint(self, key):\n base64_pub = self.base64_pub_encode(key)\n return SHA256.new(base64_pub.encode('utf-8')).digest()", "def fingerprint(self):\n return se...
[ "0.77391666", "0.76859707", "0.7634195", "0.7514036", "0.7471615", "0.7366445", "0.7218066", "0.71334374", "0.70777875", "0.7041138", "0.68841106", "0.68285894", "0.6695113", "0.6680278", "0.66001993", "0.66001993", "0.66001993", "0.65500057", "0.6528393", "0.6461605", "0.642...
0.7981021
0
Generates a Base58Check encoding of this key.
def to_b58check(self, testnet=False): b = self.testnet_bytes if testnet else bytes(self) return base58.b58encode_check(b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_base58(self) -> str:\n return base58.b58encode(self.raw).decode('utf-8')", "def to_base58(self) -> str:\n return base58.b58encode(self.raw).decode('utf-8')", "def __str__(self):\n return gphBase58CheckEncode(self._hex)", "def forge_base58(value: str) -> bytes:\n return base58_d...
[ "0.7132694", "0.7132694", "0.69438237", "0.6799692", "0.676327", "0.66251224", "0.63663113", "0.6311434", "0.630213", "0.620253", "0.61336774", "0.61109304", "0.6091969", "0.60715467", "0.60662615", "0.60591286", "0.6051299", "0.60092396", "0.59555876", "0.5883445", "0.586220...
0.65914536
6
Serialization of the key for testnet.
def testnet_bytes(self): return self._serialize(True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_key(key: str) -> bytes:\n return key.encode(\"utf-8\")", "def _dumpKey(self, key):\n return self.serializer.dumpKey((self.path, self._internalNs, key))", "def raw(self) -> bytes:\n return bytes(self._signing_key)", "def save(self):\n if not self.fileKey:\n log...
[ "0.6948801", "0.6768897", "0.66655487", "0.65602565", "0.6537538", "0.64810574", "0.64295965", "0.6374775", "0.6282263", "0.6258551", "0.6218504", "0.61828756", "0.6135277", "0.6117363", "0.6116815", "0.610087", "0.608277", "0.607366", "0.6041598", "0.6024077", "0.5981999", ...
0.6667217
2
Get inventory list from config files builds a NetworkRunner inventory object and a mac_map dictionary according to ansible inventory file yaml definition
def __init__(self): self.inventory = {} self.mac_map = {} for conffile in CONF.config_file: # parse each config file sections = {} parser = cfg.ConfigParser(conffile, sections) try: parser.parse() except IOError as e: LOG.error(str(e)) # filter out sections that begin with the driver's tag hosts = {k: v for k, v in sections.items() if k.startswith(c.DRIVER_TAG)} # munge the oslo_config data removing the device tag and # turning lists with single item strings into strings for host in hosts: dev_id = host.partition(c.DRIVER_TAG)[2] dev_cfg = {k: v[0] for k, v in hosts[host].items()} for b in c.BOOLEANS: if b in dev_cfg: dev_cfg[b] = types.Boolean()(dev_cfg[b]) self.inventory[dev_id] = dev_cfg # If mac is defined add it to the mac_map if 'mac' in dev_cfg: self.mac_map[dev_cfg['mac'].upper()] = dev_id LOG.info('Ansible Host List: %s', ', '.join(self.inventory))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n\n # endpdoint = \"restconf/data/ietf-interfaces:interfaces\"\n # endpoint = f\"restconf/data/ietf-interfaces:interfaces/interface={name}\"\n\n if len(argv) > 1:\n try:\n inventory = load_inventory(argv[1])\n except FileExistsError as err:\n print(\"FileEx...
[ "0.57955146", "0.5357593", "0.5309615", "0.52972466", "0.52823687", "0.52815616", "0.5225071", "0.5193531", "0.51922613", "0.5180207", "0.5171256", "0.5163886", "0.51440394", "0.5126848", "0.5065334", "0.5064806", "0.5061558", "0.50566524", "0.5048825", "0.5046078", "0.503131...
0.6786082
0
read (tables, columns) from the table definition file
def table_col(file_name='tpch'): path = './data/' + file_name + "/sql/{}-create.sql".format("tpch") regex = re.compile(';\($') tbl_name = {} tbl = "" with open(path, 'r') as f: for line in f.readlines(): if "CREATE TABLE" in line: tbl = line.split()[2] tbl_name[tbl.lower()] = [] elif line != "\n" and ');' not in line and regex.search(line) == None: col = line.split()[0] tbl_name[tbl.lower()].append(col.lower()) return tbl_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tabdes(filename, body):\n # XXX checksums ignored\n head = Struct(\"!BiHBxxxB\")\n body = Struct(body)\n # foot = Struct(\"!4s\")\n\n data = []\n with open(filename, \"rb\") as f:\n buffer = f.read()\n _, _, count, length, _ = head.unpack_from(buffer, 0)\n offset = head.size\n ...
[ "0.6431829", "0.6404322", "0.6258304", "0.61863047", "0.6153", "0.61336774", "0.61302614", "0.6072644", "0.6022581", "0.60137993", "0.5962784", "0.59596694", "0.5934838", "0.5925993", "0.5887302", "0.58700204", "0.5861452", "0.5848875", "0.584234", "0.5839805", "0.5791649", ...
0.58154535
20
Check whether a line contains legal select/project/join (SPJ) predicate
def is_legal_prdicate(predicate): is_legal = 0 res = '' regex = re.compile('^.*\ (like|\=|\<\=|\>\=|\<|\>|in|\ between\ )\ .*$') if regex.search(predicate) is not None: predicate = predicate.split('\t') line = [x for x in predicate if x != ''][0] if '\n' in line: line = line[:-1] # remove logic ops (and/when/or) treg = re.compile('^and |^when |^or ') if treg.search(line): line = line[treg.search(line).end():] # remove nested rreg = re.compile('\($') # remove alias areg = re.compile('^.*(l1|l2|l3|n1|n2|n3).*$') if rreg.search(line) is None and areg.search(line) is None: is_legal = 1 res = line return is_legal,res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_candidate(line):\n line = line.lower()\n line = prepare_text_line(line)\n return (has_content(line) and any(s in line for s in copyrights_hint.statement_markers))", "def check_record(idline,nclline,sepline,qualiline):\n return check_idline(idline) and check_sepline(sepline)", "def line_is_va...
[ "0.64510995", "0.62487596", "0.6135062", "0.5924878", "0.58464956", "0.57694995", "0.56707954", "0.5648749", "0.55708396", "0.5511604", "0.54753846", "0.54356587", "0.5420101", "0.5379314", "0.5345371", "0.5341573", "0.5319152", "0.53119344", "0.5308702", "0.5283885", "0.5272...
0.5551145
9
Test case for get_liveness Get job service liveness
def test_get_liveness(self): response = self.client.open('/api/v1//liveness', method='GET', content_type='application/json') self.assert200(response, "Response body is : " + response.data.decode('utf-8'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def liveness():\n return '', 200", "def test_get_refresh_job_status(self):\n pass", "def liveness_probe():\n return \"I am still alive!\"", "def test_estimate_liveness_batch(self):\n detection = self.detector.detectOne(VLImage.load(filename=SPOOF), detect68Landmarks=True)\n estimat...
[ "0.6060957", "0.60050637", "0.5874817", "0.5739824", "0.56933695", "0.5687158", "0.5626335", "0.56105167", "0.560023", "0.55861163", "0.55428433", "0.5536615", "0.55124384", "0.54971635", "0.5488803", "0.5478777", "0.5478777", "0.54599184", "0.54395", "0.54195917", "0.5348092...
0.73525107
0
Test case for get_readiness Get job service readiness
def test_get_readiness(self): response = self.client.open('/api/v1//readiness', method='GET', content_type='application/json') self.assert200(response, "Response body is : " + response.data.decode('utf-8'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_refresh_job_status(self):\n pass", "def test_readiness_endpoint(self):\n url = f'{BASE_URL}/ready'\n response = requests.get(url)\n response_json = response.json()\n assert response.status_code == 503\n assert response_json['status'] == 503", "def test_sta...
[ "0.72830915", "0.6839322", "0.6632437", "0.65635777", "0.63915956", "0.63915956", "0.6313089", "0.6205987", "0.61734414", "0.61597115", "0.614555", "0.6124894", "0.6102056", "0.6053104", "0.604147", "0.60116535", "0.59794265", "0.59655803", "0.5928916", "0.5915668", "0.588532...
0.7425097
0
Retrieves the list of all User objects
def get_all_users(): users = [] for mv in storage.all("User").values(): users.append(mv.to_dict()) return jsonify(users)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_users():\n return Users.query.all()", "def get_all_users():", "def get_all_users():\n return User.query.all()", "def get_all_users(self):\n \n sql = \"select * from users\"\n return self._query_all(sql)", "def get_users(self):\n users = []\n page = 1...
[ "0.83742595", "0.828774", "0.8259821", "0.8236466", "0.8208948", "0.81540406", "0.81540406", "0.81540406", "0.81540406", "0.81478584", "0.8116875", "0.81126046", "0.80643564", "0.8059964", "0.8054353", "0.8028967", "0.8026462", "0.7979344", "0.79498196", "0.7948819", "0.79406...
0.7877465
27
Retrieves a User object
def get_user(user_id=None): user = storage.get("User", user_id) if user is None: abort(404) return jsonify(user.to_dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self):\n\n user_id = get_jwt_identity()\n user = user_crud.get(user_id)\n if not user:\n abort(404, message=\"User not Found\")\n\n return user", "def get(self, user_id):\n return User.get(user_id)", "def get_user(self, user, instance=None):\n instan...
[ "0.81341594", "0.8094171", "0.8086876", "0.7977499", "0.7955156", "0.7948816", "0.79354584", "0.7924837", "0.7887365", "0.78764534", "0.7852467", "0.7792065", "0.7780637", "0.77725995", "0.7761683", "0.7751996", "0.77192086", "0.7679085", "0.76748264", "0.766108", "0.76554185...
0.751007
40
Deletes a User object
def delete_user(user_id=None): user = storage.get("User", user_id) if user is None: abort(404) else: storage.delete(user) storage.save() return jsonify({}), 200
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user(self, user):\n self.delete(user)", "def delete_user():", "def delete_user():\n #TODO user delete\n pass", "def delete_user(self):\n\n User.user_list.remove(self)", "def delete_user(self):\n User.user_list.remove(self)", "def delete_user(self):\n User.user...
[ "0.8626425", "0.85164607", "0.83695376", "0.8364185", "0.8343344", "0.8343344", "0.8343344", "0.83141226", "0.82571805", "0.8212667", "0.82057565", "0.8198734", "0.8185502", "0.815266", "0.8147197", "0.8142381", "0.81233865", "0.80933213", "0.8089616", "0.7982235", "0.7977738...
0.7958771
24
Updates a User object
def update_user(user_id): user = storage.get("User", user_id) if user is None: abort(404) json_input = request.get_json() if json_input is None: abort(400, "Not a JSON") for key, value in json_input.items(): if key not in ['id', 'email', 'created_at', 'updated_at']: setattr(user, key, value) user.save() return jsonify(user.to_dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user():", "def update_user(cls, **kwargs):\n return cls._do_call(\n 'PUT', cls.api_endpoint + 'users', params=kwargs)", "def update_user():\n #TODO user update \n pass", "def update(self, user: U) -> None:\n ...", "def put(self, user_id):\r\n return update_u...
[ "0.8470099", "0.8341868", "0.817528", "0.81275237", "0.7892335", "0.7821547", "0.7795651", "0.77814746", "0.7775861", "0.7737184", "0.76707584", "0.76067144", "0.75910306", "0.7590645", "0.7536968", "0.74962765", "0.7480669", "0.74541986", "0.74528563", "0.7435805", "0.741409...
0.7520065
15
=============================================================== save_obj(obj, saved_name ) =============================================================== this function is used to save any python object to your hard desk
def save_obj(obj, saved_name ): with open( saved_name + '.pkl', 'wb') as f: pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_obj(obj, name):\r\n with open('../pickle/' + name + '.pkl', 'wb') as fout:\r\n pickle.dump(obj, fout, pickle.HIGHEST_PROTOCOL)\r\n # end with\r", "def save_obj(obj, name):\n \n with open(name + '.pkl', 'wb') as objec:\n pickle.dump(obj, objec)", "def save_obj(obj,...
[ "0.83799785", "0.83523476", "0.834026", "0.834026", "0.8322952", "0.8320533", "0.81125903", "0.805116", "0.80221593", "0.79732233", "0.7954794", "0.79475254", "0.790895", "0.78999376", "0.7857288", "0.7842152", "0.7814447", "0.7774819", "0.76592255", "0.7642796", "0.76062477"...
0.88148
0
=============================================================== load_obj(saved_name) =============================================================== this function is used to save any python object to your hard desk
def load_obj(saved_name): with open( saved_name + '.pkl', 'rb') as f: return pickle.load(f)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_obj(obj, saved_name ):\n with open( saved_name + '.pkl', 'wb') as f:\n pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)", "def save_obj(obj, name):\n with open('../../data/' + name + '.pkl', 'wb') as f:\n pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)", "def save_obj(obj, name):\n wit...
[ "0.81122315", "0.7685448", "0.7685448", "0.7588679", "0.75443125", "0.74489355", "0.74238276", "0.7387553", "0.730978", "0.730978", "0.7296159", "0.7197405", "0.71187323", "0.7099137", "0.7085125", "0.7082581", "0.70419323", "0.70103645", "0.70006555", "0.6940859", "0.6908531...
0.82277983
0
=========================================================== DateFormatedSQL(x) =========================================================== this function converts the the date read from a list to a datetime format
def DateFormatedSQL(x): x=[i[0] for i in x] x1=[] for i in x: if len(i)==19: x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(i[11:13]),int(i[14:16]),int(i[17:18]) )) # elif len(i)==13: # x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(i[11:13]),int(0),int(0) )) # else: # x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(0),int(0),int(0) )) # del i,x return x1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_format_from_input_to_datetime(list_d_t_t):\n data_output = []\n\n for row in list_d_t_t:\n data_output.append([datetime.datetime.strptime(row[0] + \" \" + row[1], \"%Y-%m-%d %H:%M:%S\"),\n datetime.datetime.strptime(row[0] + \" \" + row[2], \"%Y-%m-%d %H:%M:%S\")]...
[ "0.66734904", "0.65000284", "0.6259414", "0.59757656", "0.5600508", "0.5579302", "0.5578522", "0.5551475", "0.5513122", "0.54512274", "0.5435365", "0.52705914", "0.52298", "0.5214014", "0.5199284", "0.51939476", "0.5177129", "0.5144611", "0.51139647", "0.5111645", "0.5084982"...
0.7940835
0
=========================================================== dateformated(x) =========================================================== this function converts the the date read from a list to a datetime format
def DateFormated(x): x1=[] for i in x: if len(i)==19: x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(i[11:13]),int(i[14:16]),int(i[17:18]) )) # elif len(i)==13: # x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(i[11:13]),int(0),int(0) )) # else: # x1.append(datetime.datetime(int(i[:4]),int(i[5:7]),int(i[8:10]),int(0),int(0),int(0) )) # del i,x return x1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_format_from_input_to_datetime(list_d_t_t):\n data_output = []\n\n for row in list_d_t_t:\n data_output.append([datetime.datetime.strptime(row[0] + \" \" + row[1], \"%Y-%m-%d %H:%M:%S\"),\n datetime.datetime.strptime(row[0] + \" \" + row[2], \"%Y-%m-%d %H:%M:%S\")]...
[ "0.73220545", "0.6644235", "0.64673054", "0.63785565", "0.6323779", "0.63159305", "0.6256937", "0.6174311", "0.5986844", "0.58866596", "0.5878423", "0.58775616", "0.58339506", "0.579193", "0.57800907", "0.57769805", "0.5757611", "0.57572365", "0.57409817", "0.5732213", "0.572...
0.75249213
0
If there exists a record like dbsilomongomaster.alpha.xplain.io, returns the next number (4)
def get_new_service_num(route53_zone, service_name): # Match records belonging to the service for particular service and # environment. match_regex = "(?<={})\d+(?=\.{}\.?)" \ .format(service_name, route53_zone.name) # Initialize with 0 because we want 1-indexing service_nums = [0] for record in route53_zone.get_records(): match = re.search(match_regex, record.name) if match: service_num = int(match.group(0)) service_nums.append(service_num) return max(service_nums) + 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_next_match_id():\n conn = get_connect()\n cursor = conn.execute(\"SELECT matchId FROM match WHERE isSearched = 0 LIMIT 1\")\n result_list = cursor.fetchone()\n conn.close()\n if result_list is None:\n print(\"no more matchId to be searched\")\n return None\n else:\n m...
[ "0.6664259", "0.61382604", "0.60998386", "0.5928929", "0.5735149", "0.5713186", "0.5704618", "0.55747485", "0.5572003", "0.55479425", "0.55387664", "0.5533251", "0.5508651", "0.54968625", "0.5493598", "0.54908", "0.5483527", "0.5479922", "0.54581887", "0.5456278", "0.5432718"...
0.0
-1
Check if a record exists matching the service pattern with the current host's ip
def record_exists(route53_zone, service_name, ip): # Match records belonging to the service for particular service and # environment. match_regex = "{}\d+\.{}\.?".format(service_name, route53_zone.name) for record in route53_zone.get_records(): match = re.match(match_regex, record.name) if match and ip in record.resource_records: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cusip_exists(record):\n cusips = helper.query_db('instruments', 'cusip')\n assert record['cusip'] in cusips", "def name_matches_ip(name, ip, state):\n for client in state['clients']:\n if client['name'] == name:\n if client['ip'] == ip:\n return True\n el...
[ "0.6178328", "0.6014736", "0.59269434", "0.58188164", "0.56742144", "0.56725705", "0.56573004", "0.5653265", "0.56383586", "0.56271714", "0.5579105", "0.5578969", "0.55783236", "0.5542878", "0.55369085", "0.55349123", "0.5531589", "0.5526352", "0.5510327", "0.5509592", "0.548...
0.7733625
0
Creates record with record_name and ip; updates record if it already exists with different ip does nothing if record already exists with same ip
def upsert_record(route53_zone, record_name, ip): # Only upsert the dns record if it doesn't resolve to us. try: record_ip = socket.gethostbyname(record_name) except socket.error: # Ignore if we can't connect to the host pass else: if ip == record_ip: return print str(dt.now()), "Registering host as", record_name record = route53_zone.get_a(record_name) if record and ip not in record.resource_records: route53_zone.update_a(record_name, ip) elif not record: route53_zone.add_a(record_name, ip)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_record(self, record_name, ip):\n if ((not hasattr(self, '_current_zone')) or (not self._current_zone)) or ((not hasattr(self, '_new_zone_version_number')) or (not self._new_zone_version_number)):\n raise GandiApiException(\"Can't update record, no cloned zone available.\")\n \n...
[ "0.72148836", "0.66041684", "0.62076926", "0.6207673", "0.5900262", "0.58394516", "0.58283144", "0.57992715", "0.57729447", "0.5762532", "0.57310665", "0.5682131", "0.5672659", "0.5666608", "0.5655603", "0.5637485", "0.56220573", "0.56179416", "0.560817", "0.56004244", "0.559...
0.7590886
0
Terminate an ec2 instance
def terminateInstance(region,zone,instance_id): try: ec2 = boto.ec2.connect_to_region(region+'-'+zone) ec2.terminate_instances(instance_ids=[instance_id]) return True except Exception as e: logError(e) return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ec2_stop(resource, metadata):\n instances = resource.instances.filter(\n Filters=[{'Name': 'instance-state-name', 'Values': ['running']},\n {'Name': 'tag:Name', 'Values': [metadata['fqdn']]}, ])\n\n for instance in instances:\n print(\"Terminating vm id {0} name {1}\".format...
[ "0.80912846", "0.80731577", "0.79928845", "0.7745165", "0.7609396", "0.7455729", "0.74132353", "0.7362064", "0.7344869", "0.7302483", "0.72819716", "0.71319824", "0.711395", "0.7096879", "0.7086053", "0.7067986", "0.6984061", "0.6978721", "0.68962944", "0.6884447", "0.6829472...
0.7719454
4
Create a new EC2 instance with specific parameters SecurityGroup (sg) and KeyPair (key) have to be previously created (see cassandgo initSG and cassandgo initKP)
def createInstance(ec2,ami,nb_nodes,placement,instance_type,key,sg,user_data=None): reservation = ec2.run_instances(ami,min_count=nb_nodes,max_count=nb_nodes,placement = placement,key_name=key,security_groups=[sg],instance_type=instance_type,user_data=user_data) instance = reservation.instances[0] return instance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_instance(ami, sg_name):\n instance = None\n ec2 = boto3.resource('ec2',region_name=\"us-east-1\")\n # TODO: Create an EC2 instance\n # Wait for the instance to enter the running state\n # Reload the instance attributes\n\n try:\n instance = ec2.create_instances(\n ImageId...
[ "0.7219868", "0.68883014", "0.67771643", "0.6717516", "0.67171246", "0.66807824", "0.6674608", "0.66468847", "0.65976626", "0.6490849", "0.6442486", "0.63030493", "0.62883216", "0.6278427", "0.6269443", "0.61487126", "0.61450726", "0.61255866", "0.6090022", "0.6052359", "0.60...
0.7226294
0
Create a new SecurityGroup
def createSG(ec2,name,rules): # check if the security group exists group = None sgGroups = [sg for sg in ec2.get_all_security_groups() if sg.name == name] if sgGroups: group = sgGroups[0] ec2.delete_security_group(name=name, group_id=group) print "Creating %s Security Group" % name group = ec2.create_security_group(name, 'group for %s' % name) if group: # Set the inbound rules for rule in rules: if rule.src_group_name: group.authorize(ip_protocol=rule.ip_protocol,from_port=rule.from_port,to_port=rule.to_port,cidr_ip=rule.cidr_ip,src_group=group) else: group.authorize(ip_protocol=rule.ip_protocol,from_port=rule.from_port,to_port=rule.to_port,cidr_ip=rule.cidr_ip,src_group=None) return True else: logError('Error during '+name+' Security Group update') return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_security_group(self, body=None):\r\n return self.post(self.security_groups_path, body=body)", "def create(self, body: CloudSecurityGroup) -> Dict:\n\t\treturn self._post(route=AWSSecurityGroupConsts.CLOUD_SECURITY_GROUP.value, body=body)", "def security_group_create(auth=None, **kwargs):\n ...
[ "0.81746614", "0.8173531", "0.8123306", "0.8045393", "0.7995554", "0.7991185", "0.79661214", "0.7898956", "0.7896103", "0.7488821", "0.7426497", "0.7370995", "0.72724205", "0.7255197", "0.702857", "0.6984043", "0.6908669", "0.6881222", "0.68289787", "0.6826571", "0.6761301", ...
0.72574544
13
List all instances for a specific region and zone
def listInstancesRegionZone(region,zone): print "-"*80 print "# Region :",region," Zone", zone print "-"*80 instances = getInstancesRegionZone(region,zone) if instances: for instance in instances: print "[",instance.ami_launch_index,"]",instance.ip_address," (",instance.private_ip_address,") ",instance.instance_type," key=",instance.key_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_instances(self, region):\n try:\n conn = ec2.connect_to_region(region, **self.credentials)\n region_instances = []\n reservations = conn.get_all_reservations()\n for reservation in reservations:\n for instance in reservation.instances:\n ...
[ "0.73566705", "0.7152035", "0.69493294", "0.6796809", "0.67603457", "0.6752783", "0.6647198", "0.6643667", "0.64551127", "0.64104474", "0.6406182", "0.6393634", "0.63902986", "0.6389321", "0.63319427", "0.629142", "0.628562", "0.6270777", "0.6261531", "0.6253145", "0.621456",...
0.82746065
0
Create all Cassandra security groups in all regions
def createAllSG(): for info in conf_HVM: ec2 = boto.ec2.connect_to_region(info['region']+'-'+info['zone']) createSG(ec2,'SG-Cassandra-'+info['region']+'-'+info['zone'],CASSANDRA_RULES)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_groups():\n groups = [\"iDRAC-Administrators\", \"iDRAC-Operators\", \"iDRAC-Readonly\"]\n group_priviledges = [\"0x000001ff\", \"0x000000f9\", \"0x00000001\"]\n for host in online_hosts:\n for index in [1,2,3]:\n print index,\" \", groups[index-1]\n with settings(w...
[ "0.65404814", "0.641292", "0.6315235", "0.63037133", "0.62225246", "0.611194", "0.6016119", "0.589653", "0.58127975", "0.5788823", "0.57725734", "0.5730021", "0.571415", "0.56577706", "0.56387746", "0.55405027", "0.54687124", "0.5450472", "0.54221886", "0.5418091", "0.5405399...
0.71990424
0
Create all key pairs in all regions
def createAllKP(): if not os.path.exists(keysDir): os.makedirs(keysDir) for info in conf_HVM: keyName = 'Key-'+info['region']+'-'+info['zone'] try: os.remove(keysDir+'/'+keyName+'.pem') except OSError: pass print "Key creation :",keyName ec2 = boto.ec2.connect_to_region(info['region']+'-'+info['zone']) # check if the key pair exists kps = [kp for kp in ec2.get_all_key_pairs() if kp.name == keyName] if kps: ec2.delete_key_pair(keyName) key = ec2.create_key_pair(keyName) key.save(keysDir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_keys():", "def createAllSG():\n\tfor info in conf_HVM:\n\t\tec2 = boto.ec2.connect_to_region(info['region']+'-'+info['zone'])\n\t\tcreateSG(ec2,'SG-Cassandra-'+info['region']+'-'+info['zone'],CASSANDRA_RULES)", "def setup_space_keys(cls):\n if cls.KEYS:\n return\n\n from pkg_re...
[ "0.65445393", "0.6132496", "0.60415924", "0.5918604", "0.59134144", "0.587338", "0.5822073", "0.5657623", "0.5650972", "0.5635661", "0.5604821", "0.5563397", "0.5509014", "0.5504165", "0.5494566", "0.54587173", "0.5435119", "0.54258394", "0.54082614", "0.5393367", "0.5384728"...
0.7191877
0
Constructor for the ManagementAccessToken class
def __init__(self, access_token=None, token_type=None, error=None): # Initialize members of the class self.access_token = access_token self.token_type = token_type self.error = error
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, access_token):\n self.access_token = access_token", "def __init__(self, access_token=None):\n self.access_token = access_token", "def __init__(self, access_token):\n self._access_token = access_token", "def __init__(self, access_token_cache, account_id, credentials):\n...
[ "0.7636313", "0.7517129", "0.7437664", "0.72003037", "0.7027544", "0.6943499", "0.6889966", "0.68749976", "0.6788117", "0.6651019", "0.6641739", "0.6631", "0.66123813", "0.6594493", "0.65795815", "0.6572527", "0.6505966", "0.65004337", "0.64906555", "0.64870405", "0.64369303"...
0.7398528
3
Creates an instance of this model from a dictionary
def from_dictionary(cls, dictionary): if dictionary is None: return None # Extract variables from the dictionary access_token = dictionary.get('accessToken') token_type = dictionary.get('tokenType') error = cohesity_app_sdk.models.error.Error.from_dictionary(dictionary.get('error')) if dictionary.get('error') else None # Return an object of this model return cls(access_token, token_type, error)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction...
[ "0.8317533", "0.81689686", "0.81689686", "0.81188685", "0.808892", "0.7977596", "0.7949056", "0.79225504", "0.78983366", "0.7893884", "0.7887517", "0.7882494", "0.7881197", "0.7876339", "0.78581846", "0.78387725", "0.78037786", "0.78037786", "0.78037786", "0.78037786", "0.780...
0.7370376
100
Operator for single operand
def _arithmetize1(self, operand: Any, op: str) -> Any: op_func = getattr(operator, op) # Data length might be changed after evaluation # operand = recycle_value(operand, self.data.shape[0]) return op_func(operand)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def operator(self):\n return self.__operator", "def operator(self):\n col = self.pos\n operators = [\"||\", \"&&\", \">>\", \"<<\", \"!=\", \">=\", \"<=\", \"==\", \"##\"] + \\\n [\"-\", \"+\", \"!\", \"*\", \"/\", \"|\", \"&\", \"^\", \"<\", \">\", \"?\", \":\", \"~\", \"#\", \"=...
[ "0.7114677", "0.694391", "0.6853135", "0.6847471", "0.6837405", "0.6791744", "0.6742106", "0.6664682", "0.6664682", "0.657418", "0.6553492", "0.6541233", "0.6475368", "0.6475368", "0.64606273", "0.64198357", "0.64169806", "0.64141864", "0.64120305", "0.6401596", "0.6390579", ...
0.6933232
2
Operator for paired operands
def _arithmetize2(self, left: Any, right: Any, op: str) -> Any: op_func = getattr(operator, op) left, right = _recycle_left_right(left, right) return op_func(left, right)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def and_or_operator(cls, quad):\n\t\tleft_op = cls.get_address_value(quad.left_operand)\n\t\tright_op = cls.get_address_value(quad.right_operand)\n\t\t# TODO: The next set of lines will fail at a specific case\n\t\tif quad.operator == 10 :\n\t\t\tcls.set_address_value(quad.result, (left_op and right_op))\n\t\telif...
[ "0.70254517", "0.6778513", "0.6722453", "0.67095107", "0.6646131", "0.6616339", "0.6596597", "0.6542849", "0.6527473", "0.6483588", "0.64554465", "0.63938665", "0.6341946", "0.62985724", "0.62963104", "0.6284674", "0.6228084", "0.6228084", "0.6227012", "0.6224514", "0.6223301...
0.6676819
4
Mimic the & operator in R. This has to have Expression objects to be involved to work
def _op_and_(self, left: Any, right: Any) -> Any: if isinstance(left, list): # induce an intersect with Collection return Intersect(left, right) left, right = _recycle_left_right(left, right) left = Series(left).fillna(False) right = Series(right).fillna(False) return left & right
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AND(f, g):\n def _and(x):\n return f(x) & g(x)\n return _and", "def and_(a, b):", "def __and__(self, other):\n return self.fam.c_binop('and', self, other)", "def __and__(self, obj):\n return self._boolean_operation(obj, operator.__and__)", "def _and(cls, arg1, arg2):\n ...
[ "0.6913351", "0.6844835", "0.6834847", "0.68041515", "0.6614185", "0.6585983", "0.65602845", "0.65299505", "0.6528684", "0.6510841", "0.6501651", "0.64942497", "0.6466398", "0.6432646", "0.639087", "0.6376711", "0.6334177", "0.6331774", "0.63316846", "0.6288898", "0.62308896"...
0.62697506
20
Mimic the & operator in R. This has to have Expression objects to be involved to work
def _op_or_(self, left: Any, right: Any) -> Any: if isinstance(left, list): return Collection(left, right) left, right = _recycle_left_right(left, right) left = Series(left).fillna(False) right = Series(right).fillna(False) return left | right
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AND(f, g):\n def _and(x):\n return f(x) & g(x)\n return _and", "def and_(a, b):", "def __and__(self, other):\n return self.fam.c_binop('and', self, other)", "def __and__(self, obj):\n return self._boolean_operation(obj, operator.__and__)", "def _and(cls, arg1, arg2):\n ...
[ "0.6913351", "0.6844835", "0.6834847", "0.68041515", "0.6614185", "0.6585983", "0.65602845", "0.65299505", "0.6528684", "0.6510841", "0.6501651", "0.64942497", "0.6466398", "0.6432646", "0.639087", "0.6376711", "0.6334177", "0.6331774", "0.63316846", "0.6288898", "0.62697506"...
0.0
-1
Interpret for left != right
def _op_ne(self, left: Any, right: Any) -> BoolOrIter: out = self._op_eq(left, right) if isinstance(out, (numpy.ndarray, Series)): neout = ~out # neout[pandas.isna(out)] = numpy.nan return neout # out is always a numpy.ndarray return not out # pragma: no cover
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(left, right):\n return (not (left == right))", "def ne (x,y):\n\n return not (le(x,y) and le(y,x))", "def nexact(cls, lhs, rhs):\n return lhs != rhs", "def ne (self, other):\n return not (self == other) # opposite of eq", "def _isLeft(P0, P1, P2):\n return...
[ "0.8098229", "0.70341194", "0.6655749", "0.64999557", "0.64726496", "0.6470631", "0.64697796", "0.6455494", "0.6385901", "0.63324577", "0.6331694", "0.6274154", "0.6211507", "0.6198755", "0.61944705", "0.6193615", "0.6182596", "0.6180644", "0.6173583", "0.6173583", "0.6162615...
0.72011685
1
Recycle left right operands to each other
def _recycle_left_right(left: Any, right: Any) -> Tuple: try: left = recycle_value(left, length_of(right)) except DataUnrecyclable: right = recycle_value(right, length_of(left)) return left, right
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _arithmetize2(self, left: Any, right: Any, op: str) -> Any:\n op_func = getattr(operator, op)\n left, right = _recycle_left_right(left, right)\n return op_func(left, right)", "def RewriteOR(self, left, right):\n return None", "def __call__(self):\n return self._left() + self....
[ "0.68653905", "0.6566106", "0.6530686", "0.6372209", "0.6346159", "0.62722206", "0.6268917", "0.6268676", "0.6260108", "0.6258728", "0.6246955", "0.6224608", "0.62071043", "0.61998665", "0.6179604", "0.6081393", "0.6077263", "0.6012032", "0.5989172", "0.5984579", "0.59795463"...
0.6620655
1
returns the l2 penalty on (trainable) network parameters combined as sum
def get_l2_penalty(nnet, include_bias=False, pow=2): l2_penalty = 0 # do not include OC-SVM layer in regularization if Cfg.ocsvm_loss: if include_bias: for layer in nnet.trainable_layers: if not layer.issvm: if layer.b is not None: l2_penalty = (l2_penalty + T.sum(abs(layer.W) ** pow) + T.sum(abs(layer.b) ** pow)) else: l2_penalty = l2_penalty + T.sum(abs(layer.W) ** pow) else: for layer in nnet.trainable_layers: if not layer.issvm: l2_penalty = l2_penalty + T.sum(abs(layer.W) ** pow) else: if include_bias: for layer in nnet.trainable_layers: if layer.b is not None: l2_penalty = (l2_penalty + T.sum(abs(layer.W) ** pow) + T.sum(abs(layer.b) ** pow)) else: l2_penalty = l2_penalty + T.sum(abs(layer.W) ** pow) else: for layer in nnet.trainable_layers: l2_penalty = l2_penalty + T.sum(abs(layer.W) ** pow) return T.cast(l2_penalty, dtype='floatX')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_l2_reg(self) -> torch.Tensor:\n loss = 0\n for param in self.model.parameters():\n loss += (param ** 2).sum()\n return loss", "def l2_regularization_penalty(self):\n return self.l2 * (np.linalg.norm(self.weights)**2)", "def l2_training_penalty(batched_out: base.O...
[ "0.7453849", "0.7264303", "0.7145872", "0.70822954", "0.68864816", "0.68526465", "0.6803547", "0.6774062", "0.6762818", "0.67296004", "0.64906466", "0.647366", "0.64639264", "0.64553", "0.64553", "0.64553", "0.6427316", "0.64204615", "0.64127034", "0.6400128", "0.6380519", ...
0.7189708
2
returns the sparsity penalty on network activations combined as a sum
def get_sparsity_penalty(nnet, inputs, sparsity, mode="mean", deterministic=False): assert mode in ("mean", "l1") rho = sparsity penalty = 0 eps = 0.0001 # for numerical stability for layer in nnet.all_layers: if layer.isactivation: activation = lasagne.layers.get_output(layer, inputs=inputs, deterministic=deterministic) if mode == "mean": if layer.isrelu: avg_activation = T.mean(T.gt(activation, T.zeros_like(activation)), axis=0, dtype='floatX') if layer.issigmoid: avg_activation = T.mean(activation, axis=0, dtype='floatX') KL_div = T.sum((rho+eps) * (T.log(rho+eps) - T.log(avg_activation+eps)) + (1-rho+eps) * (T.log(1-rho+eps) - T.log(1-avg_activation+eps)), dtype='floatX') penalty = penalty + KL_div if mode == "l1": penalty = penalty + T.sum(abs(activation), dtype='floatX') return T.cast(penalty, dtype='floatX')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def s_penalty(self, triples, nodes):\n\n s_index, p_index, o_index = split_spo(triples)\n\n s, p, o = nodes[s_index, :], self.relations[p_index, :], nodes[o_index, :]\n\n return s.pow(2).mean() + p.pow(2).mean() + o.pow(2).mean()", "def penalty(self):\n assert len(self.weights) == len...
[ "0.67767024", "0.62359196", "0.6125899", "0.60773647", "0.5991481", "0.596333", "0.5899081", "0.58852255", "0.5814007", "0.57617986", "0.5758206", "0.57509667", "0.57433456", "0.57304865", "0.56787086", "0.56762224", "0.5659587", "0.5657149", "0.56555104", "0.5648981", "0.564...
0.6444512
1
returns the sum of squared spectral norms of network parameters (i.e. the sum of the largest Eigenvalues of dot(W, W.T))
def get_spectral_penalty(nnet, include_bias=False): penalty = 0 for layer in nnet.trainable_layers: if not layer.issvm: eigenvalues, eigvec = T.nlinalg.eigh(T.dot(layer.W, layer.W.T)) eig_max = T.max(eigenvalues) penalty = penalty + eig_max if include_bias: for layer in nnet.trainable_layers: if (not layer.issvm) and (layer.b is not None): penalty = penalty + T.sum(abs(layer.b) ** 2) return T.cast(penalty, dtype='floatX')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normsq(self):\n return sum(x**2 for x in self.data)", "def sumsquares(self):\n return np.dot((self.demeaned ** 2).T, self.weights)", "def normsq(self):\n return abs(sum(self._ar * self._ar))", "def spectral_norm_parallel(self):\n weights = {}\n for l in self.all_conv_la...
[ "0.7140227", "0.6941976", "0.67742", "0.65775263", "0.64593214", "0.6404113", "0.63714224", "0.63577896", "0.63157535", "0.62651175", "0.623166", "0.6196198", "0.61877424", "0.6176353", "0.6174241", "0.61738396", "0.61442685", "0.6121031", "0.60918915", "0.6082494", "0.607733...
0.5524715
93
returns the l2 penalty on (trainable) network parameters combined as tensor product.
def get_prod_penalty(nnet): assert Cfg.ocsvm_loss is True penalty = 0 layers = nnet.trainable_layers num_layers = len(layers) - 1 # do not regularize parameters of oc-svm layer assert num_layers > 0 W_norm_prod = 1.0 if layers[num_layers-1].b is not None: penalty += T.sum(layers[num_layers-1].b ** 2) for i in range(num_layers-1): W_norm_prod *= T.sum(layers[num_layers-1-i].W ** 2) if layers[num_layers-2-i].b is not None: penalty += W_norm_prod * T.sum(layers[num_layers-2-i].b ** 2) W_norm_prod *= T.sum(layers[0].W ** 2) penalty += W_norm_prod penalty *= T.sum(nnet.ocsvm_layer.W ** 2) return penalty
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_l2_reg(self) -> torch.Tensor:\n loss = 0\n for param in self.model.parameters():\n loss += (param ** 2).sum()\n return loss", "def l2_regularization_penalty(self):\n return self.l2 * (np.linalg.norm(self.weights)**2)", "def l2_training_penalty(batched_out: base.O...
[ "0.7459851", "0.73080754", "0.71070445", "0.7071918", "0.6722846", "0.6637411", "0.66100603", "0.6606142", "0.65346557", "0.64298236", "0.64298236", "0.64298236", "0.64195216", "0.6411184", "0.6407858", "0.6394501", "0.63773257", "0.634488", "0.63392335", "0.6293014", "0.6180...
0.66554886
5
returns the offset to balance the polynomial parameters possible by the bias terms of the network.
def get_bias_offset(nnet): offset = 0 L = len(nnet.trainable_layers) for l in range(L-1): layer = nnet.trainable_layers[l] if layer.b is not None: W_prod = T.eye(int(layer.b.shape.eval()[0])) for k in range(1, L-1): W_prod = T.dot(nnet.trainable_layers[k].W.T, W_prod) offset = offset + T.dot(W_prod, layer.b) offset = T.dot(nnet.ocsvm_layer.W.T, offset) return T.sum(offset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_bias(self) -> JTensor:\n p = self.params\n b = self.local_theta().b\n if p.forget_gate_bias != 0.0:\n b = b + self.get_adjustment()\n\n return b", "def get_bias(self):", "def bias(self):\n return self.mbmod.bias", "def bias(self):\n return self._bias", "def get_bias(...
[ "0.6315012", "0.6108197", "0.58673644", "0.5829149", "0.5699308", "0.5665857", "0.56237257", "0.56060565", "0.5575922", "0.55285054", "0.55088294", "0.54091525", "0.5405784", "0.5395721", "0.5392568", "0.53660536", "0.53445673", "0.5333317", "0.52875805", "0.52750427", "0.527...
0.70303106
0
create update for network given in argument
def create_update(nnet): if nnet.data._X_val.ndim == 2: inputs = T.matrix('inputs') elif nnet.data._X_val.ndim == 4: inputs = T.tensor4('inputs') targets = T.ivector('targets') # compile theano functions if Cfg.softmax_loss: compile_update_softmax(nnet, inputs, targets) elif Cfg.ocsvm_loss: if Cfg.rho_fixed: compile_update_ocsvm_rho_fixed(nnet, inputs, targets) else: compile_update_ocsvm(nnet, inputs, targets) elif Cfg.svdd_loss: compile_update_svdd(nnet, inputs, targets) elif Cfg.reconstruction_loss: create_autoencoder(nnet) else: compile_update_default(nnet, inputs, targets)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self, network_update_args, network_create_args=None):\n network = self.neutron.create_network(**(network_create_args or {}))\n self.neutron.update_network(network[\"id\"], **network_update_args)", "def update_target_network(self):\n\n\t\tprint \"Updating Target DQN...\"\n\t\t\n\t\tself.upda...
[ "0.7085726", "0.6553442", "0.6488986", "0.62651724", "0.6232808", "0.6232666", "0.61859524", "0.61575675", "0.61455834", "0.6119935", "0.6094648", "0.6091395", "0.6076523", "0.6069876", "0.60480976", "0.60480976", "0.60449016", "0.6043163", "0.60051495", "0.5985916", "0.59771...
0.6348753
3
create a SVM loss for network given in argument
def compile_update_default(nnet, inputs, targets): floatX = Cfg.floatX C = Cfg.C if len(nnet.all_layers) > 1: feature_layer = nnet.all_layers[-2] else: feature_layer = nnet.input_layer final_layer = nnet.svm_layer trainable_params = lasagne.layers.get_all_params(final_layer, trainable=True) # Regularization if Cfg.weight_decay: l2_penalty = (floatX(0.5) / C) * get_l2_penalty(nnet, Cfg.include_bias) else: l2_penalty = T.cast(0, dtype='floatX') # Backpropagation prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=False) objective, train_acc = final_layer.objective(prediction, targets) train_loss = T.cast((objective) / targets.shape[0], dtype='floatX') train_acc = T.cast(train_acc * 1. / targets.shape[0], dtype='floatX') train_obj = l2_penalty + train_loss updates = get_updates(nnet, train_obj, trainable_params, solver=nnet.solver) nnet.backprop = theano.function([inputs, targets], [train_obj, train_acc], updates=updates) # Hinge loss nnet.hinge_loss = theano.function([inputs, targets], [train_loss, train_acc]) # Forwardpropagation test_prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=True) if nnet.data.n_classes == 2: scores = test_prediction[:, 1] - test_prediction[:, 0] else: scores = T.zeros_like(targets) objective, test_acc = final_layer.objective(test_prediction, targets) test_loss = T.cast(objective / targets.shape[0], dtype='floatX') test_acc = T.cast(test_acc * 1. / targets.shape[0], dtype='floatX') test_obj = l2_penalty + test_loss # get network feature representation test_rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=True) test_rep_norm = test_rep.norm(L=2, axis=1) nnet.forward = theano.function([inputs, targets], [test_obj, test_acc, scores, l2_penalty, test_rep_norm, test_loss])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def svm_loss(W, X, y, classes, reg):\n # compute the loss and the gradient\n # num_classes = W.shape[1]\n num_train = X.shape[0]\n loss = 0.0\n dW = np.zeros(W.shape) # initialize the gradient as zero\n\n #############################################################################\n # Implementation of a S...
[ "0.6997603", "0.69757587", "0.6954347", "0.69388586", "0.6791079", "0.6756301", "0.6728832", "0.67196614", "0.66558504", "0.6613795", "0.6579743", "0.6554059", "0.6525655", "0.65236473", "0.64979446", "0.6477414", "0.6435054", "0.64005077", "0.6381835", "0.63708454", "0.63617...
0.0
-1
create a softmax loss for network given in argument
def compile_update_softmax(nnet, inputs, targets): floatX = Cfg.floatX C = Cfg.C final_layer = nnet.all_layers[-1] trainable_params = lasagne.layers.get_all_params(final_layer, trainable=True) # Regularization if Cfg.weight_decay: l2_penalty = (floatX(0.5) / C) * get_l2_penalty(nnet, Cfg.include_bias) else: l2_penalty = T.cast(0, dtype='floatX') # Backpropagation prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=False) if Cfg.ad_experiment: train_loss = T.mean(l_objectives.binary_crossentropy( prediction.flatten(), targets), dtype='floatX') train_acc = T.mean(l_objectives.binary_accuracy(prediction.flatten(), targets), dtype='floatX') else: train_loss = T.mean(l_objectives.categorical_crossentropy(prediction, targets), dtype='floatX') train_acc = T.mean(T.eq(T.argmax(prediction, axis=1), targets), dtype='floatX') train_obj = T.cast(train_loss + l2_penalty, dtype='floatX') updates = get_updates(nnet, train_obj, trainable_params, solver=nnet.solver) nnet.backprop = theano.function([inputs, targets], [train_obj, train_acc], updates=updates) # Forwardpropagation test_prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=True) if Cfg.ad_experiment: test_loss = T.mean(l_objectives.binary_crossentropy( test_prediction.flatten(), targets), dtype='floatX') test_acc = T.mean(l_objectives.binary_accuracy( test_prediction.flatten(), targets), dtype='floatX') else: test_loss = T.mean(l_objectives.categorical_crossentropy( test_prediction, targets), dtype='floatX') test_acc = T.mean(T.eq(T.argmax(test_prediction, axis=1), targets), dtype='floatX') test_obj = T.cast(test_loss + l2_penalty, dtype='floatX') nnet.forward = theano.function([inputs, targets], [test_obj, test_acc, test_prediction, l2_penalty, test_loss])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_loss(self, xs, y):\n \"*** YOUR CODE HERE question 4 ***\"\n return nn.SoftmaxLoss(self.run(xs), y)", "def get_loss(self, xs, y):\n \"*** YOUR CODE HERE ***\"\n y_pred = self.run(xs)\n return nn.SoftmaxLoss(y_pred,y)", "def softmax_loss_naive(W, X, y, reg):\n # Initi...
[ "0.74243444", "0.7283457", "0.72514814", "0.7247183", "0.71797806", "0.71731097", "0.7170593", "0.70910347", "0.7069629", "0.7036034", "0.70345086", "0.7027396", "0.70033365", "0.7002239", "0.700087", "0.69909036", "0.69491434", "0.69352823", "0.69285876", "0.6924547", "0.688...
0.6411446
63
create a OCSVM loss for network given in argument
def compile_update_ocsvm(nnet, inputs, targets): floatX = Cfg.floatX C = Cfg.C A = Cfg.A nu = Cfg.nu if len(nnet.all_layers) > 1: feature_layer = nnet.all_layers[-2] else: feature_layer = nnet.input_layer final_layer = nnet.ocsvm_layer trainable_params = lasagne.layers.get_all_params(final_layer, trainable=True) # Regularization (up to feature map) if Cfg.weight_decay: if Cfg.prod_penalty: l2_penalty = (1/C) * get_prod_penalty(nnet) elif Cfg.spec_penalty: l2_penalty = (1/C) * get_spectral_penalty(nnet, Cfg.include_bias) else: l2_penalty = ((1/C) * get_l2_penalty(nnet, include_bias=Cfg.include_bias, pow=Cfg.pow)) else: l2_penalty = T.cast(0, dtype='floatX') # Bias offset if Cfg.bias_offset: bias_offset = get_bias_offset(nnet) else: bias_offset = T.cast(0, dtype='floatX') # Backpropagation prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=False) objective, train_acc = final_layer.objective(prediction, targets) # Normalization rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=False) rep_norm = rep.norm(L=2, axis=1).dimshuffle((0, 'x')) if Cfg.ball_penalty: ball_penalty, _ = final_layer.objective( T.ones_like(rep_norm) - (rep_norm ** 2), targets) else: ball_penalty = T.cast(0, dtype='floatX') ball_penalty = (1/A) * T.cast(ball_penalty / targets.shape[0], dtype='floatX') # Output regularization if Cfg.output_penalty: l2_output = (1/C) * (T.sum(abs(final_layer.W) ** Cfg.pow) * T.sum(abs(rep) ** 2)) else: l2_output = T.cast(0, dtype='floatX') l2_output = T.cast(l2_output / targets.shape[0], dtype='floatX') # SVM parameter regularization if Cfg.Wsvm_penalty: Wsvm_penalty = T.sum(abs(final_layer.W) ** Cfg.pow) else: Wsvm_penalty = T.cast(0, dtype='floatX') # OC SVM loss has nu parameter and adds margin from origin to objective train_loss = T.cast(objective / (targets.shape[0] * nu), dtype='floatX') train_acc = T.cast(train_acc * 1. / targets.shape[0], dtype='floatX') train_obj = T.cast(floatX(0.5) * l2_penalty + floatX(0.5) * ball_penalty + floatX(0.5) * l2_output + floatX(0.5) * Wsvm_penalty + train_loss + T.sum(final_layer.b) + bias_offset, dtype='floatX') updates = get_updates(nnet, train_obj, trainable_params, solver=nnet.solver) nnet.backprop = theano.function([inputs, targets], [train_obj, train_acc], updates=updates) # Forwardpropagation test_prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=True) # get network feature representation test_rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=True) test_rep_norm = test_rep.norm(L=2, axis=1) if Cfg.ball_penalty: test_ball_penalty, _ = final_layer.objective( T.ones_like(test_rep_norm.dimshuffle((0, 'x'))) - (test_rep_norm.dimshuffle((0, 'x')) ** 2), targets) else: test_ball_penalty = T.cast(0, dtype='floatX') test_ball_penalty = ((1/A) * T.cast( test_ball_penalty / targets.shape[0], dtype='floatX')) # Output regularization if Cfg.output_penalty: test_l2_output = (1/C) * (T.sum(abs(final_layer.W) ** Cfg.pow) * T.sum(abs(test_rep) ** 2)) else: test_l2_output = T.cast(0, dtype='floatX') test_l2_output = T.cast(test_l2_output / targets.shape[0], dtype='floatX') objective, test_acc = final_layer.objective(test_prediction, targets) test_loss = T.cast(objective / (targets.shape[0] * nu), dtype='floatX') test_acc = T.cast(test_acc * 1. / targets.shape[0], dtype='floatX') test_obj = T.cast(floatX(0.5) * l2_penalty + floatX(0.5) * test_ball_penalty + floatX(0.5) * test_l2_output + floatX(0.5) * Wsvm_penalty + test_loss + T.sum(final_layer.b), dtype='floatX') nnet.forward = theano.function([inputs, targets], [test_obj, test_acc, test_prediction, floatX(0.5) * l2_penalty, floatX(0.5) * test_l2_output, test_rep, test_rep_norm, test_loss, floatX(0.5) * test_ball_penalty])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loss_fn(self, targets, outputs, model):", "def loss(self, **kwargs):\n pass", "def compute_loss(self, obs, returns):", "def compute_loss(self):", "def _create_loss(self):\n\n with tf.name_scope(\"loss\"):\n \n # gini=(tf.nn.l2_loss( self.score))/100000\n ...
[ "0.70169455", "0.6844153", "0.6804448", "0.6769743", "0.66364557", "0.6544467", "0.6499708", "0.64170283", "0.6415858", "0.64099944", "0.6390037", "0.63685757", "0.6367827", "0.6360576", "0.6336654", "0.6305561", "0.6284038", "0.6282407", "0.6270986", "0.62703526", "0.6265863...
0.0
-1
create a OCSVM loss for network given in argument with rho=1 fixed
def compile_update_ocsvm_rho_fixed(nnet, inputs, targets): floatX = Cfg.floatX C = Cfg.C nu = Cfg.nu if len(nnet.all_layers) > 1: feature_layer = nnet.all_layers[-2] else: feature_layer = nnet.input_layer final_layer = nnet.ocsvm_layer trainable_params = lasagne.layers.get_all_params(final_layer, trainable=True) # Regularization Wsvm_penalty = T.sum(abs(final_layer.W) ** Cfg.pow) l2_penalty = get_l2_penalty(nnet, include_bias=Cfg.include_bias, pow=Cfg.pow) l2_penalty += Wsvm_penalty l2_penalty *= (1/C) # Backpropagation prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=False) scores = T.ones_like(prediction) - prediction objective, train_acc = final_layer.objective(-scores, targets) # OC-SVM loss train_loss = T.cast(objective / (targets.shape[0] * nu), dtype='floatX') train_acc = T.cast(train_acc * 1. / targets.shape[0], dtype='floatX') train_obj = T.cast(floatX(0.5) * l2_penalty + train_loss, dtype='floatX') updates = get_updates(nnet, train_obj, trainable_params, solver=nnet.solver) nnet.backprop = theano.function([inputs, targets], [train_obj, train_acc], updates=updates) # Forwardpropagation test_prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=True) test_scores = T.ones_like(prediction) - test_prediction objective, test_acc = final_layer.objective(-test_scores, targets) # Get network feature representation test_rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=True) test_rep_norm = test_rep.norm(L=2, axis=1) test_ball_penalty = T.cast(0, dtype='floatX') test_l2_output = T.cast(0, dtype='floatX') # OC-SVM test loss test_loss = T.cast(objective / (targets.shape[0] * nu), dtype='floatX') test_acc = T.cast(test_acc * 1. / targets.shape[0], dtype='floatX') test_obj = T.cast(floatX(0.5) * l2_penalty + test_loss, dtype='floatX') nnet.forward = theano.function([inputs, targets], [test_obj, test_acc, -test_scores, floatX(0.5) * l2_penalty, floatX(0.5) * test_l2_output, test_rep, test_rep_norm, test_loss, floatX(0.5) * test_ball_penalty])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_loss(self):\n\n with tf.name_scope(\"loss\"):\n \n # gini=(tf.nn.l2_loss( self.score))/100000\n gini = tf.losses.softmax_cross_entropy(self.score, 0*self.score)\n \n promo_prob=tf.reduce_sum(tf.multiply(self.score, self.cohort_weight),\n ...
[ "0.6449017", "0.6109472", "0.605694", "0.5996417", "0.593703", "0.589075", "0.5883496", "0.58318764", "0.5773389", "0.5742824", "0.5693317", "0.569238", "0.56884587", "0.5637557", "0.56182146", "0.5615014", "0.55934024", "0.55804175", "0.55716777", "0.5567387", "0.5556932", ...
0.6604869
0
create a SVDD loss for network given in argument
def compile_update_svdd(nnet, inputs, targets): floatX = Cfg.floatX B = Cfg.B C = Cfg.C nu = Cfg.nu # initialize R if nnet.R_init > 0: nnet.Rvar = shared(floatX(nnet.R_init), name="R") else: nnet.Rvar = shared(floatX(1), name="R") # initialization with R=1 # Loss feature_layer = nnet.all_layers[-1] rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=False) # initialize c (0.5 in every feature representation dimension) rep_dim = feature_layer.num_units # nnet.cvar = shared(floatX(np.ones(rep_dim) * (1. / (rep_dim ** 0.5))), # name="c") nnet.cvar = shared(floatX(np.ones(rep_dim) * 0.5), name="c") dist = T.sum(((rep - nnet.cvar.dimshuffle('x', 0)) ** 2), axis=1, dtype='floatX') scores = dist - nnet.Rvar stack = T.stack([T.zeros_like(scores), scores], axis=1) loss = T.cast(T.sum(T.max(stack, axis=1)) / (inputs.shape[0] * nu), dtype='floatX') y_pred = T.argmax(stack, axis=1) acc = T.cast((T.sum(T.eq(y_pred.flatten(), targets), dtype='int32') * 1. / targets.shape[0]), 'floatX') # Network weight decay if Cfg.weight_decay: l2_penalty = (1/C) * get_l2_penalty(nnet, include_bias=Cfg.include_bias, pow=Cfg.pow) else: l2_penalty = T.cast(0, dtype='floatX') # Network activation sparsity regularization if Cfg.sparsity_penalty: sparsity_penalty = (1/B) * get_sparsity_penalty(nnet, inputs, Cfg.sparsity, mode=Cfg.sparsity_mode, deterministic=False) else: sparsity_penalty = T.cast(0, dtype='floatX') # Backpropagation (hard-margin: only minimizing everything to a ball # centered at c) trainable_params = lasagne.layers.get_all_params(feature_layer, trainable=True) if Cfg.gaussian_blob: avg_dist = T.mean(1-T.exp(-dist), dtype="floatX") else: avg_dist = T.mean(dist, dtype="floatX") obj_ball = T.cast(floatX(0.5) * l2_penalty + avg_dist + sparsity_penalty, dtype='floatX') updates_ball = get_updates(nnet, obj_ball, trainable_params, solver=nnet.solver) nnet.backprop_ball = theano.function([inputs, targets], [obj_ball, acc], updates=updates_ball) # Backpropagation (without training R) obj = T.cast(floatX(0.5) * l2_penalty + nnet.Rvar + loss + sparsity_penalty, dtype='floatX') updates = get_updates(nnet, obj, trainable_params, solver=nnet.solver) nnet.backprop_without_R = theano.function([inputs, targets], [obj, acc], updates=updates) # Backpropagation (with training R) trainable_params.append(nnet.Rvar) # add radius R to trainable parameters updates = get_updates(nnet, obj, trainable_params, solver=nnet.solver) nnet.backprop = theano.function([inputs, targets], [obj, acc], updates=updates) # Forwardpropagation test_rep = lasagne.layers.get_output(feature_layer, inputs=inputs, deterministic=True) test_rep_norm = test_rep.norm(L=2, axis=1) test_dist = T.sum(((test_rep - nnet.cvar.dimshuffle('x', 0)) ** 2), axis=1, dtype='floatX') test_scores = test_dist - nnet.Rvar test_stack = T.stack([T.zeros_like(test_scores), test_scores], axis=1) test_loss = T.cast(T.sum(T.max(test_stack, axis=1)) / (inputs.shape[0]*nu), dtype='floatX') test_y_pred = T.argmax(test_stack, axis=1) test_acc = T.cast((T.sum(T.eq(test_y_pred.flatten(), targets), dtype='int32') * 1. / targets.shape[0]), dtype='floatX') # Network activation sparsity regularization (with determinisitc=True) if Cfg.sparsity_penalty: test_sparsity_penalty = ((1 / B) * get_sparsity_penalty(nnet, inputs, Cfg.sparsity, mode=Cfg.sparsity_mode, deterministic=True)) else: test_sparsity_penalty = T.cast(0, dtype='floatX') test_obj = T.cast(floatX(0.5) * l2_penalty + nnet.Rvar + test_loss + test_sparsity_penalty, dtype='floatX') nnet.forward = theano.function([inputs, targets], [test_obj, test_acc, test_scores, floatX(0.5) * l2_penalty, test_sparsity_penalty, test_rep, test_rep_norm, test_loss, nnet.Rvar])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tv_loss(x, name='tv_loss'):\n raise NotImplementedError(\"Please use tensorflow total_variation loss.\")", "def loss_fn(self, targets, outputs, model):", "def tv_loss(input: th.Tensor):\n input = tf.pad(input, (0, 1, 0, 1), \"replicate\")\n x_diff = input[..., :-1, 1:] - input[..., :-1, :-1]\n ...
[ "0.63613164", "0.6158965", "0.6017301", "0.5997169", "0.590424", "0.5783352", "0.57639736", "0.5728302", "0.5715514", "0.5708102", "0.5672599", "0.56407714", "0.5635773", "0.5630035", "0.56168777", "0.5610483", "0.5603815", "0.55986285", "0.5573956", "0.5568347", "0.55591923"...
0.6577575
0
create autoencoder Theano update for network given in argument
def create_autoencoder(nnet): floatX = Cfg.floatX B = Cfg.ae_B C = Cfg.ae_C ndim = nnet.data._X_train.ndim if ndim == 2: inputs = T.matrix('inputs') elif ndim == 4: inputs = T.tensor4('inputs') final_layer = nnet.all_layers[-1] # Backpropagation trainable_params = lasagne.layers.get_all_params(final_layer, trainable=True) prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=False) # use l2 or binary crossentropy loss (features are scaled to [0,1]) if Cfg.ae_loss == "l2": loss = lasagne.objectives.squared_error(prediction, inputs) if Cfg.ae_loss == "ce": loss = lasagne.objectives.binary_crossentropy(prediction, inputs) scores = T.sum(loss, axis=range(1, ndim), dtype='floatX') loss = T.mean(scores) # Regularization if Cfg.ae_weight_decay: l2_penalty = (floatX(0.5) / C) * regularize_network_params(final_layer, l2) else: l2_penalty = T.cast(0, dtype='floatX') # Network activation sparsity regularization if Cfg.ae_sparsity_penalty: sparsity_penalty = ((1 / B) * get_sparsity_penalty(nnet, inputs, Cfg.ae_sparsity, mode=Cfg.ae_sparsity_mode, deterministic=False)) else: sparsity_penalty = T.cast(0, dtype='floatX') train_obj = loss + l2_penalty + sparsity_penalty updates = get_updates(nnet, train_obj, trainable_params, solver=nnet.ae_solver) nnet.ae_backprop = theano.function([inputs], [loss, l2_penalty, sparsity_penalty, scores], updates=updates) # Forwardpropagation test_prediction = lasagne.layers.get_output(final_layer, inputs=inputs, deterministic=True) # use l2 or binary crossentropy loss (features are scaled to [0,1]) if Cfg.ae_loss == "l2": test_loss = lasagne.objectives.squared_error(test_prediction, inputs) if Cfg.ae_loss == "ce": test_loss = lasagne.objectives.binary_crossentropy(test_prediction, inputs) test_scores = T.sum(test_loss, axis=range(1, ndim), dtype='floatX') test_loss = T.mean(test_scores) # Network activation sparsity regularization (with determinisitc=True) if Cfg.ae_sparsity_penalty: test_sparsity_penalty = ((1 / B) * get_sparsity_penalty(nnet, inputs, Cfg.ae_sparsity, mode=Cfg.ae_sparsity_mode, deterministic=True)) else: test_sparsity_penalty = T.cast(0, dtype='floatX') nnet.ae_forward = theano.function([inputs], [test_loss, l2_penalty, test_sparsity_penalty, test_scores, test_prediction])
{ "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.65535045", "0.6422185", "0.63456124", "0.6290219", "0.6285251", "0.6273079", "0.6235958", "0.6228888", "0.6139146", "0.6119213", "0.6110673", "0.61030644", "0.6072735", "0.60715985", "0.60660934", "0.6034425", "0.60192865", "0.5931092", "0.5930418", "0.59202427", "0.589814...
0.719997
0
Helper for running guider start tests.
def _guider_start(self, nCall, nInfo, nWarn, nErr, finish=False, didFail=False): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) result = masterThread.guider_start(self.cmd, cmdState, myGlobals.actorState, 'gotoField') self.assertEqual(result, not didFail) self._check_cmd(nCall, nInfo, nWarn, nErr, finish, didFail=didFail)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def startTestRun(self):", "def __main() :\n launchTests()", "def runTests(self):\n \n pass", "def test_run_started(self):", "def main():\n run_test_all()", "def startTestHook(self):", "def run_main(): # pragma: no cover\n RunTestsCLI.run()", "def startTest(asset):", "def run(con...
[ "0.78004026", "0.7614107", "0.7351775", "0.7290789", "0.7199481", "0.71878326", "0.70207834", "0.6993264", "0.6858419", "0.6842322", "0.6831787", "0.6791457", "0.6771266", "0.6755483", "0.670912", "0.6685418", "0.66745853", "0.66695005", "0.65984964", "0.6530515", "0.65222645...
0.0
-1
ffs open, 3x axis clear, guider on
def test_guider_start_ffsClosed(self): self._guider_start(6, 20, 0, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_crossfilter1(self):\n print ('Trigger clear')\n self.query_dict = {}\n self.plot_data = None\n self.create_figure_new()\n layout_doc.children[4].children[0] = self.p", "def clear_crossfilter2(self):\n print ('Trigger clear')\n self.query_dict = {}\n ...
[ "0.61160886", "0.6069212", "0.5878568", "0.5857923", "0.5843179", "0.58136004", "0.57567126", "0.57446754", "0.5731113", "0.57125556", "0.5617229", "0.55928105", "0.55445457", "0.5534347", "0.5533265", "0.55276537", "0.5508186", "0.549856", "0.5490645", "0.5472276", "0.540083...
0.0
-1
3x axis clear, guider on
def test_guider_start_ffsOpen(self): sopTester.updateModel('mcp', TestHelper.mcpState['boss_science']) self._guider_start(5, 17, 0, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_axes_selection(self):\n self.x_axis = ''\n self.y_axis = ''\n self.non_numeric_x_axis = False\n self.count_desired = False\n self.header_choices('x')", "def clean_axis(ax):\n ax.get_xaxis().set_ticks([])\n ax.get_yaxis().set_ticks([])\n for sp in ax.spines.va...
[ "0.65289444", "0.63922054", "0.6321609", "0.6298944", "0.6190664", "0.61035085", "0.60953176", "0.60531133", "0.6040696", "0.6023394", "0.6004292", "0.5933611", "0.58755267", "0.5860231", "0.58342767", "0.5827443", "0.5751592", "0.5682224", "0.5678112", "0.5671971", "0.566845...
0.0
-1
ffs open, he off, hgcd off, 3x axis clear, guider on
def test_guider_start_arcsOn(self): sopTester.updateModel('mcp', TestHelper.mcpState['arcs']) self._guider_start(8, 20, 0, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cehs():\n\tcloseEHShutter()", "def zguider():\n gzero.gxoff = camera.status.guider[0] + gzero.gxoff\n gzero.gyoff = camera.status.guider[1] + gzero.gyoff\n guider(0,0)\n f = open('/data/guidezero','w')\n cPickle.dump(gzero,f)\n f.close()", "def reset(self):\n self.position = np.zeros(self.ndeg...
[ "0.5735864", "0.5659085", "0.54460454", "0.5380752", "0.53681165", "0.5359119", "0.5346913", "0.53467923", "0.5345186", "0.53185624", "0.53087205", "0.5306554", "0.5283048", "0.5248694", "0.52321434", "0.5206659", "0.52050847", "0.51976866", "0.5184278", "0.5164785", "0.51638...
0.0
-1
ffs open, flat off, 3x axis clear, guider on
def test_guider_start_flatsOn(self): sopTester.updateModel('mcp', TestHelper.mcpState['flats']) self._guider_start(7, 20, 0, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n self.np.fill(OFF)\n self.np.show()\n return True", "def cerrar(self):\n self.x0 = np.array(self.x0, dtype=float)\n self.x = np.array(self.x, dtype=float)\n self.tipos = np.array(self.tipos, dtype=int)\n self.mask_fr = self.tipos == 1\n se...
[ "0.5862193", "0.5839169", "0.58179474", "0.5817385", "0.58068", "0.57821304", "0.5691695", "0.5675337", "0.5528641", "0.55042607", "0.5428167", "0.53599954", "0.5344104", "0.5337998", "0.5293606", "0.5292733", "0.5271016", "0.5258116", "0.5246498", "0.524269", "0.5237372", ...
0.0
-1
Helper for running guider flat tests.
def _guider_flat(self, nCall, nInfo, nWarn, nErr, finish=False, didFail=False): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) result = masterThread.guider_flat(self.cmd, cmdState, myGlobals.actorState, 'guider') self.assertEqual(result, not didFail) self._check_cmd(nCall, nInfo, nWarn, nErr, finish, didFail=didFail)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runTests(self):\n \n pass", "def main():\n run_test_all()", "def tests():", "def runtest(self):", "def test_single_test_case():\n pass", "def __main() :\n launchTests()", "def test_basic_execution(self):", "def test_generate_all_testing(self):\n pass", "def spec_tests(...
[ "0.7352913", "0.72175664", "0.7153499", "0.71123314", "0.69343376", "0.6914146", "0.68364465", "0.68047154", "0.67976254", "0.6754427", "0.6737129", "0.6672995", "0.666052", "0.662404", "0.6613215", "0.6601137", "0.6594231", "0.6594231", "0.65821177", "0.6561161", "0.65609705...
0.0
-1
Helper for running guider flat tests that check the APOGEE shutter.
def _guider_flat_apogeeShutter(self, nCall, nInfo, nWarn, nErr, finish=False, didFail=False): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) result = masterThread.guider_flat( self.cmd, cmdState, myGlobals.actorState, 'guider', apogeeShutter=True) self.assertEqual(result, not didFail) self._check_cmd(nCall, nInfo, nWarn, nErr, finish, didFail=didFail)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def runTest(self):\n E = main()\n self.assertInside(E, energy, 1e-5)", "def main():\n # run_test_go_straight_inches()\n # run_test_turn_degrees()\n # run_test_spin_degrees()\n beep_if_blob_is_bigger_than(3000)", "def test_01_lighting(self):", "def test_run(self):\n rig_analys...
[ "0.6602023", "0.65421003", "0.62224287", "0.62081254", "0.6206044", "0.5991344", "0.5950729", "0.59440666", "0.5933885", "0.5919975", "0.5912514", "0.5885823", "0.5882865", "0.5820897", "0.581793", "0.5800086", "0.5794324", "0.57891035", "0.578905", "0.57890207", "0.57865036"...
0.5492133
91
decenter off Will give cmd.error and stage=failed, but won't fail command.
def test_deactivate_guider_decenter_fails(self): sopTester.updateModel('guider', TestHelper.guiderState['guiderOnDecenter']) self.cmd.failOn = 'guider decenter off' self._deactivate_guider_decenter(1, 9, 0, 2, didFail=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def halt_cmd(ctx):\n pass", "def command_failed_error(cmd):\n\n output_1 = colored(' - Error: Failed to run command ', 'red')\n output_2 = command(cmd)\n return output_1 + output_2 + '\\n'", "def assert_cli_fails_properly(response, caplog):\n # don't exit successfully\n assert response.exit_c...
[ "0.63274103", "0.59832925", "0.58065456", "0.5717935", "0.57014954", "0.56815827", "0.56410784", "0.5618887", "0.5596389", "0.5563665", "0.55591875", "0.5529268", "0.5520761", "0.55194193", "0.550422", "0.54478794", "0.5444886", "0.54415536", "0.5407555", "0.5348784", "0.5331...
0.57412744
3
FF on, axis status, axis init, slew, FF on, guider flat, FF off, open FFS 3xguider axes off, guider on
def test_goto_field_apogee(self): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) self._goto_feld_apogee(13, 46, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup(self, flags):\n self.figure = pylab.figure(1)\n self.axes = {}\n self.stream_data = {}\n self.flags = flags", "def update_focal_axes(self):\n #self.update_sigma()\n self.updateGL()", "def update_flags(self):\n # view mode, filled vs wirefrom\n if self.view['wir...
[ "0.61186206", "0.5865818", "0.5800843", "0.5676216", "0.55347174", "0.55038637", "0.5467715", "0.54164624", "0.5378973", "0.5370552", "0.5300264", "0.52715015", "0.52276176", "0.521771", "0.5209924", "0.5208267", "0.520253", "0.5198544", "0.51961386", "0.519605", "0.5194642",...
0.0
-1
axis status, axis init, slew
def test_goto_field_apogee_no_guider(self): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doGuider = False self._goto_feld_apogee(3, 11, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, axis=-1):\n self.axis = axis", "def __init__(self, axes=()):\n self._axes = []\n self._dimension = 0\n for axis in axes:\n self.add_axis(axis)", "def _set_axes(self):\n self += helper.line(stroke=\"black\", x1=self.__dict__['x'], x2=self.__di...
[ "0.6245888", "0.621319", "0.6022292", "0.6020143", "0.5990214", "0.5969029", "0.59592175", "0.5930569", "0.59223", "0.59204257", "0.58473855", "0.58251107", "0.5787647", "0.5784954", "0.5752151", "0.5738153", "0.5714067", "0.5657952", "0.56545234", "0.56490576", "0.5624587", ...
0.0
-1
FF on, guider flat, FF off, open FFS 3xguider axes off, guider on
def test_goto_field_apogee_no_slew(self): cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False self._goto_feld_apogee(9, 37, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def f_fixed(self):\n self.fx_free = self.fy_free = self.fz_free = False\n return self", "def _show_feature_flags(graph: nx.DiGraph, mode='sorted'):\n #plt.figure(figsize=(15, 15))\n if mode == 'sorted':\n pos = nx.multipartite_layout(graph)\n nx.draw(graph, pos, with_labels=True...
[ "0.5923838", "0.5707589", "0.55777276", "0.54883665", "0.540146", "0.5344511", "0.533769", "0.5307722", "0.5219301", "0.52111065", "0.52089953", "0.52063096", "0.52039117", "0.5201414", "0.5189145", "0.5175825", "0.5149582", "0.51441306", "0.51224685", "0.50826716", "0.507198...
0.0
-1
FF on, guider flat, FF off, open FFS guider decenter off, 3xguider axes off, guider on
def test_goto_field_apogee_no_slew_decenter_off(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) sopTester.updateModel('guider', TestHelper.guiderState['guiderOnDecenter']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False self._goto_feld_apogee(9, 37, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def f_fixed(self):\n self.fx_free = self.fy_free = self.fz_free = False\n return self", "def zguider():\n gzero.gxoff = camera.status.guider[0] + gzero.gxoff\n gzero.gyoff = camera.status.guider[1] + gzero.gyoff\n guider(0,0)\n f = open('/data/guidezero','w')\n cPickle.dump(gzero,f)\n f.close...
[ "0.6021151", "0.5678602", "0.556794", "0.5545283", "0.54808503", "0.54380274", "0.5351072", "0.53036", "0.5298335", "0.529772", "0.5294927", "0.52931446", "0.52901006", "0.52764875", "0.5263691", "0.5190619", "0.51681143", "0.512835", "0.5121012", "0.511816", "0.51176304", ...
0.0
-1
Testing for a potential problem on SJD 56993, with gotoField not slewing when gang bypass had been set.
def test_goto_field_apogee_bypass_gangToCart(self): self._prep_bypass('gangToCart', clear=True) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) self._goto_feld_apogee(13, 44, 4, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_goto_field_apogee_no_guider(self):\n cmdState = self.actorState.gotoField\n cmdState.reinitialize(self.cmd)\n cmdState.doGuider = False\n self._goto_feld_apogee(3, 11, 0, 0, cmdState)", "def test_goto_field_apogee_no_slew(self):\n cmdState = self.actorState.gotoField\n...
[ "0.6839827", "0.674124", "0.66378564", "0.62783855", "0.62351984", "0.6205175", "0.6149223", "0.60777533", "0.6027441", "0.5959538", "0.5939859", "0.59033215", "0.58415735", "0.5746709", "0.5571056", "0.55030173", "0.54555553", "0.5397869", "0.5396254", "0.5367164", "0.529781...
0.59667176
9
shutter close, FF on, guider flat, FF off, open FFS 3xguider axes off, guider on
def test_goto_field_apogee_no_slew_shutter_open(self): sopTester.updateModel('apogee', TestHelper.apogeeState['B_open']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False self._goto_feld_apogee(10, 37, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zguider():\n gzero.gxoff = camera.status.guider[0] + gzero.gxoff\n gzero.gyoff = camera.status.guider[1] + gzero.gyoff\n guider(0,0)\n f = open('/data/guidezero','w')\n cPickle.dump(gzero,f)\n f.close()", "def f_fixed(self):\n self.fx_free = self.fy_free = self.fz_free = False\n return se...
[ "0.56922233", "0.54869103", "0.5327231", "0.5301241", "0.52902806", "0.52806854", "0.52649724", "0.5241042", "0.5236491", "0.52350116", "0.5205736", "0.5187515", "0.517721", "0.5160973", "0.5148137", "0.5135481", "0.51285934", "0.51083225", "0.5073106", "0.5068788", "0.505857...
0.0
-1
axis status, axis init, slew
def test_goto_field_boss_slew(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doGuider = False cmdState.doHartmann = False cmdState.doCalibs = False cmdState.arcTime = 0 cmdState.flatTime = 0 self._goto_field_boss(3, 26, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, axis=-1):\n self.axis = axis", "def __init__(self, axes=()):\n self._axes = []\n self._dimension = 0\n for axis in axes:\n self.add_axis(axis)", "def _set_axes(self):\n self += helper.line(stroke=\"black\", x1=self.__dict__['x'], x2=self.__di...
[ "0.6247041", "0.6213832", "0.6022709", "0.602028", "0.5989789", "0.59698653", "0.59595746", "0.5930603", "0.5922851", "0.5920339", "0.58486426", "0.5825133", "0.57882136", "0.5785074", "0.5751861", "0.57397544", "0.57143", "0.5657272", "0.56560445", "0.5648683", "0.56252724",...
0.0
-1
ne on, hgcd on, ff off, doHartmann, ne off, hgcd off
def test_goto_field_boss_hartmann(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False cmdState.doCalibs = False cmdState.arcTime = 0 cmdState.flatTime = 0 cmdState.doGuider = False self._goto_field_boss(5, 29, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def genfb_py(h, n, u, v, f, dt, dx, dy, du,dv,dn, gridu,gridv,gridn, threadblock, beta=0.281105, eps=0.013, gamma=0.0880, mu=0.3, nu=0, dudt_x=dudt, dvdt_x=dvdt, dndt_x=dndt, grav=True, cori=True, advx=True, advy=True, attn=True, ): # generalized forward backward fe...
[ "0.57660997", "0.56802636", "0.5665918", "0.5624264", "0.559748", "0.55954516", "0.5568438", "0.5507126", "0.5500543", "0.5387872", "0.53738797", "0.534831", "0.5345321", "0.53414637", "0.5333701", "0.5332214", "0.53233445", "0.53016967", "0.5296686", "0.5290382", "0.5285452"...
0.0
-1
see cmd_calls/TestGotoField.txt for command list.
def test_goto_field_boss_calibs(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False cmdState.doHartmann = False cmdState.doGuider = False self._goto_field_boss(10, 57, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_goto_field_apogee(self):\n cmdState = self.actorState.gotoField\n cmdState.reinitialize(self.cmd)\n self._goto_feld_apogee(13, 46, 0, 0, cmdState)", "def test_goto_field_apogee_no_guider(self):\n cmdState = self.actorState.gotoField\n cmdState.reinitialize(self.cmd)\n ...
[ "0.7691792", "0.64816624", "0.628449", "0.5856036", "0.58257854", "0.5754098", "0.56664455", "0.56335163", "0.5571063", "0.5469148", "0.54335827", "0.53827053", "0.52839625", "0.51585394", "0.5143092", "0.5104858", "0.5102512", "0.5086537", "0.50655967", "0.50533384", "0.5010...
0.47256958
57
Start with decentered guiding on, to check that we clear it. ff on, guider flat, ff off, ffs open 3xguider axes off, decenter off, guider on
def test_goto_field_boss_guider(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) sopTester.updateModel('guider', TestHelper.guiderState['guiderOnDecenter']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) cmdState.doSlew = False cmdState.doHartmann = False cmdState.doCalibs = False cmdState.arcTime = 0 cmdState.flatTime = 0 self._goto_field_boss(9, 37, 0, 0, cmdState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def f_fixed(self):\n self.fx_free = self.fy_free = self.fz_free = False\n return self", "def align(): # open EH and fast shutter\n\t#marAuxiliary.closeMarShield()\n\td2in()\n\td3in()\n\tsh('o')", "def test_DFT_rect(centering='FFTRECT', outdir=None, outname='DFT1R_', npix=None, sampling=...
[ "0.5788689", "0.56861943", "0.55636656", "0.54741186", "0.54616976", "0.5379296", "0.5328459", "0.5325154", "0.53217375", "0.52759594", "0.5238227", "0.52287537", "0.51961917", "0.5183579", "0.51768106", "0.51755387", "0.5134452", "0.5132298", "0.51291597", "0.5091773", "0.50...
0.0
-1
Fail on ff.on, but still readout the arc.
def test_goto_field_boss_flat_on_fails(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) self.cmd.failOn = 'mcp ff.on' self._goto_field_boss(16, 71, 0, 1, cmdState, didFail=True, finish=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friewallOn():\n pass", "def test_export_to_mff_no_device():\n pytest.importorskip(\"mffpy\", \"0.5.7\")\n evoked = read_evokeds_mff(egi_evoked_fname, condition=\"Category 1\")\n evoked.info[\"device_info\"] = None\n with pytest.raises(ValueError, match=\"No device type.\"):\n export_evo...
[ "0.53135496", "0.530685", "0.5285612", "0.5125348", "0.51056355", "0.50907296", "0.50692505", "0.50690484", "0.4983307", "0.49766693", "0.4912766", "0.4895812", "0.48652288", "0.48498195", "0.48497722", "0.48134395", "0.4810314", "0.4796255", "0.47883302", "0.47843057", "0.47...
0.51799893
3
Hartmann succeeds but the blue ring move is out of tolerance.
def test_goto_field_boss_hartmann_blue_fails(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) sopTester.updateModel('hartmann', TestHelper.hartmannState['blue_fails']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) self._goto_field_boss(12, 37, 0, 0, cmdState, didFail=True, finish=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_W_end(self):\t\t\n self.assertAlmostEqual(attempt.W[-1], 9.494852380803035)", "def steadyYet(newg, oldg, newe, olde, newh, oldh, newf, oldf, tolerance):\n steady_yet = True\n if oldg == 0 or (abs(newg-oldg)/oldg > tolerance or\n abs(newe-olde)/olde > tolerance or\n ...
[ "0.6039334", "0.5930424", "0.5919679", "0.5912854", "0.58305484", "0.5801236", "0.57621497", "0.5761265", "0.57383764", "0.57260656", "0.5721062", "0.5718691", "0.57167894", "0.5701574", "0.5683872", "0.56769484", "0.56751597", "0.56513155", "0.56409764", "0.5639347", "0.5600...
0.0
-1
Fail on ffs.open, but still readout flat.
def test_goto_field_boss_ffs_open_fails(self): sopTester.updateModel('mcp', TestHelper.mcpState['all_off']) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) self.cmd.failOn = 'mcp ffs.open' self._goto_field_boss(21, 102, 1, 1, cmdState, didFail=True, finish=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fileobj_not_closed(self):\n\n f = open(self.data('test0.fits'), 'rb')\n data = fits.getdata(f)\n assert not f.closed\n\n f.seek(0)\n header = fits.getheader(f)\n assert not f.closed", "def test_fileobj_not_closed(self):\n\n f = open(self.data(\"test0.fits...
[ "0.6067853", "0.59570915", "0.5916047", "0.5873482", "0.5731206", "0.57067436", "0.5683966", "0.5675375", "0.5667967", "0.5606461", "0.5593845", "0.557636", "0.556104", "0.5553911", "0.55134106", "0.5493101", "0.5419356", "0.5418688", "0.5415278", "0.5410945", "0.53708446", ...
0.48357132
92
Tests gotoField if there is a mismatch between MCP and guider.
def test_goto_field_cartridge_mismatch(self): sopTester.updateModel('guider', TestHelper.guiderState['bossLoaded']) mcpState = TestHelper.mcpState['boss_science'] mcpState.update({'instrumentNum': [15]}) sopTester.updateModel('mcp', mcpState) cmdState = self.actorState.gotoField cmdState.reinitialize(self.cmd) masterThread.goto_field(self.cmd, cmdState, myGlobals.actorState) self._check_cmd(0, 14, 0, 0, finish=True, didFail=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_goto_field_apogee_no_guider(self):\n cmdState = self.actorState.gotoField\n cmdState.reinitialize(self.cmd)\n cmdState.doGuider = False\n self._goto_feld_apogee(3, 11, 0, 0, cmdState)", "def test_goto_field_apogee(self):\n cmdState = self.actorState.gotoField\n ...
[ "0.67638075", "0.6552739", "0.6286361", "0.6170494", "0.6125492", "0.5995649", "0.59449685", "0.5715474", "0.5527284", "0.5455693", "0.5430143", "0.54134613", "0.530795", "0.530067", "0.5265416", "0.5247163", "0.52226955", "0.5134902", "0.5128405", "0.51222634", "0.5118506", ...
0.7532309
0
Helper for boss science tests
def _do_boss_science(self, nCall, nInfo, nWarn, nErr, nExp=1): self._update_cart(11, 'BOSS') cmdState = self.actorState.doBossScience cmdState.reinitialize(self.cmd) cmdState.nExp = nExp masterThread.do_boss_science(self.cmd, cmdState, myGlobals.actorState) self._check_cmd(2, nInfo, nWarn, nErr, True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testBeliefs1sk(self):", "def test_apply_endorsements(self):", "def test_theft_and_stealing(self):", "def healthcare():", "def testBeliefs2sk(self):", "def test_T01():", "def test_alien_data(self):", "def test_households_in_admin_unit(self):", "def unitary_test():", "def test_get_waivers(leagu...
[ "0.6812872", "0.6686834", "0.6662029", "0.66596895", "0.6609597", "0.655939", "0.6549792", "0.6543334", "0.65167713", "0.6514505", "0.6439195", "0.6439195", "0.6439195", "0.6439195", "0.6439195", "0.64386874", "0.63926923", "0.6362536", "0.632096", "0.6316661", "0.6280583", ...
0.0
-1
One call per requested exposure
def test_do_boss_science(self): sopTester.updateModel('mcp', TestHelper.mcpState['boss_science']) nExp = 2 self._do_boss_science(nExp, 35, 0, 0, nExp=nExp)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def endexposureloop(self):\n self.max_exposures = self.current_exposure", "def observeField(target, exposure):\n\n status = 2\n real_exposure = exposure + np.random.normal(0.0, 20.0)\n realSN2 = target['DESsn2'] + np.random.uniform(0.0, 1.0)\n\n return status, real_exposure, realSN2", "def e...
[ "0.6202363", "0.5730469", "0.5720542", "0.5674125", "0.5648648", "0.56126845", "0.55802995", "0.5563538", "0.55593634", "0.5544014", "0.5505167", "0.5467155", "0.54338604", "0.5406679", "0.53846276", "0.53846276", "0.53756344", "0.531871", "0.5311451", "0.5309933", "0.5305943...
0.0
-1
Helper for apogee science tests
def _do_apogee_science(self, nCall, nInfo, nWarn, nErr, ditherPairs=4): self._update_cart(1, 'APOGEE') cmdState = self.actorState.doApogeeScience cmdState.reinitialize(self.cmd) cmdState.ditherPairs = ditherPairs masterThread.do_apogee_science(self.cmd, cmdState, myGlobals.actorState) self._check_cmd(nCall, nInfo, nWarn, nErr, True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testBeliefs1sk(self):", "def test_alien_data(self):", "def test_art_from_taste_space(self):", "def test_theft_and_stealing(self):", "def test_T01():", "def testBeliefs2sk(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def _test(self):", "def test...
[ "0.6974807", "0.6933129", "0.6889396", "0.6887534", "0.6827801", "0.67861944", "0.67435616", "0.67435616", "0.67435616", "0.67435616", "0.67435616", "0.6690207", "0.6631977", "0.66018003", "0.66018003", "0.6595975", "0.6593147", "0.6593147", "0.65639585", "0.65451413", "0.653...
0.0
-1
open shutter, one call per exposure/dither moves
def test_do_apogee_science_4_pair_A_closed(self): sopTester.updateModel('mcp', TestHelper.mcpState['apogee_science']) sopTester.updateModel('apogee', TestHelper.apogeeState['A_closed']) self._do_apogee_science(13, 72, 0, 0, ditherPairs=4)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_line_scan_shutter_closed(self):\n scan = self.scan\n laser = self.devices[scan['laser']['name']]\n shutter = self.scan['shutter']\n ni_daq = self.devices['NI-DAQ']\n ni_daq.driver.digital_output(shutter['port'], False)\n if not isinstance(shutter['delay'], Q_):\n ...
[ "0.609327", "0.60517883", "0.6042764", "0.5937301", "0.58709234", "0.57097524", "0.5626163", "0.56135774", "0.5605713", "0.5569856", "0.5565318", "0.55331594", "0.5474416", "0.54720265", "0.546944", "0.546139", "0.5431014", "0.5417215", "0.5389273", "0.5385319", "0.53823715",...
0.0
-1
one call per exposure/dither move
def test_do_apogee_science_1_pair_B_open(self): sopTester.updateModel('mcp', TestHelper.mcpState['apogee_science']) sopTester.updateModel('apogee', TestHelper.apogeeState['B_open']) self._do_apogee_science(3, 30, 0, 0, ditherPairs=1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def opd_dither(cfg):\n \n setpoint_new = pi.getINDI('PLC.UBCSettings.PLSetpoint')\n file_number = pi.getINDI('NOMIC.CamInfo.FIndex') # Get initial file number\n offsets = np.array(cfg['nomic_dither_opd_pattern']) * 5.0 * 180.0 / np.pi # input in rad at 11um, but commandet offsets in deg in K band\n pi.setI...
[ "0.60497373", "0.5954956", "0.588953", "0.58547735", "0.5736053", "0.5712237", "0.56600004", "0.5645142", "0.56387717", "0.5601205", "0.56006426", "0.5587478", "0.5586383", "0.5524406", "0.55159074", "0.5505001", "0.5496937", "0.5476632", "0.54593825", "0.5451838", "0.5449247...
0.0
-1
Tests if expTime is set to 500s after a double length exposure.
def test_do_apogee_science_500s_after_1000s_cart7(self): sopTester.updateModel('platedb', TestHelper.platedbState['apogeeLead1000sCart7']) self._update_cart(7, 'APOGEE') cmdState = self.actorState.doApogeeScience cmdState.reinitialize(self.cmd) self.assertEqual(cmdState.expTime, 1000) self.assertEqual(cmdState.keywords['expTime'], 1000) sopTester.updateModel('platedb', TestHelper.platedbState['apogeeLeadCart7']) self._update_cart(7, 'APOGEE') cmdState = self.actorState.doApogeeScience cmdState.reinitialize(self.cmd) self.assertEqual(cmdState.expTime, 500) self.assertEqual(cmdState.keywords['expTime'], 500)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exp(self, exposure_time):\n print(f\"exp: {exposure_time}\")\n self.device_control.exposure = exposure_time\n yield", "def exposuretime(self) -> ErrorValue:\n return ErrorValue(self._data['ExpTime'], self._data.setdefault('ExpTimeError',0.0))", "def exptime(et=0.02):\n if et < ...
[ "0.6508764", "0.6255665", "0.62178487", "0.615677", "0.57449126", "0.5718129", "0.562681", "0.560696", "0.5600589", "0.5502671", "0.54754275", "0.54733014", "0.5451332", "0.5331526", "0.529389", "0.52561027", "0.5224857", "0.5195893", "0.5194161", "0.51847905", "0.51787597", ...
0.4705112
86
Tests if expTime is set to 1000s after a normal length exposure.
def test_do_apogee_science_1000s_after_500s_cart7(self): sopTester.updateModel('platedb', TestHelper.platedbState['apogeeLeadCart7']) self._update_cart(7, 'APOGEE') cmdState = self.actorState.doApogeeScience cmdState.reinitialize(self.cmd) self.assertEqual(cmdState.expTime, 500) self.assertEqual(cmdState.keywords['expTime'], 500) sopTester.updateModel('platedb', TestHelper.platedbState['apogeeLead1000sCart7']) self._update_cart(7, 'APOGEE') cmdState = self.actorState.doApogeeScience cmdState.reinitialize(self.cmd) self.assertEqual(cmdState.expTime, 1000) self.assertEqual(cmdState.keywords['expTime'], 1000)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exp(self, exposure_time):\n print(f\"exp: {exposure_time}\")\n self.device_control.exposure = exposure_time\n yield", "def setExposureTime(self, cmd, expTime):\n\n pass", "def exposuretime(self) -> ErrorValue:\n return ErrorValue(self._data['ExpTime'], self._data.setdefau...
[ "0.6262144", "0.6255858", "0.6163135", "0.61418873", "0.5915087", "0.5863674", "0.5856211", "0.57416385", "0.55517083", "0.5540617", "0.55379456", "0.5453827", "0.5453151", "0.54436797", "0.5430154", "0.5369838", "0.5325574", "0.5313959", "0.5313157", "0.53118265", "0.5288747...
0.0
-1