project_name stringlengths 6 104 | file_name stringlengths 4 89 | full_name stringlengths 1 102 | func_name stringlengths 1 85 | docstring stringlengths 13 836 | docstring_tokens listlengths 4 122 | code stringlengths 23 39.7k | code_tokens stringlengths 29 44.6k | url int64 3 986k |
|---|---|---|---|---|---|---|---|---|
LucasAlegre/sumo-rl | env.py | SumoEnvironment.close | close | Close the environment and stop the SUMO simulation. | [
"Close",
"the",
"environment",
"and",
"stop",
"the",
"SUMO",
"simulation."
] | def close(self):
if self.sumo is None:
return
if not LIBSUMO:
traci.switch(self.label)
traci.close()
if self.disp is not None:
self.disp.stop()
self.disp = None
self.sumo = None | ['def', 'close(self):', 'if', 'self.sumo', 'is', 'None:', 'return', 'if', 'not', 'LIBSUMO:', 'traci.switch(self.label)', 'traci.close()', 'if', 'self.disp', 'is', 'not', 'None:', 'self.disp.stop()', 'self.disp', '=', 'None', 'self.sumo', '=', 'None'] | 910,450 |
LucasAlegre/sumo-rl | env.py | SumoEnvironmentPZ.seed | seed | Set the seed for the environment. | [
"Set",
"the",
"seed",
"for",
"the",
"environment."
] | def seed(self, seed=None):
(self.randomizer, seed) = seeding.np_random(seed) | ['def', 'seed(self,', 'seed=None):', '(self.randomizer,', 'seed)', '=', 'seeding.np_random(seed)'] | 910,454 |
LucasAlegre/sumo-rl | env.py | SumoEnvironmentPZ.compute_info | compute_info | Compute the info for the current step. | [
"Compute",
"the",
"info",
"for",
"the",
"current",
"step."
] | def compute_info(self):
self.infos = {a: {} for a in self.agents}
infos = self.env._compute_info()
for a in self.agents:
for (k, v) in infos.items():
if k.startswith(a) or k.startswith('system'):
self.infos[a][k] = v | ['def', 'compute_info(self):', 'self.infos', '=', '{a:', '{}', 'for', 'a', 'in', 'self.agents}', 'infos', '=', 'self.env._compute_info()', 'for', 'a', 'in', 'self.agents:', 'for', '(k,', 'v)', 'in', 'infos.items():', 'if', 'k.startswith(a)', 'or', "k.startswith('system'):", 'self.infos[a][k]', '=', 'v'] | 910,455 |
LucasAlegre/sumo-rl | env.py | SumoEnvironmentPZ.observation_space | observation_space | Return the observation space for the agent. | [
"Return",
"the",
"observation",
"space",
"for",
"the",
"agent."
] | def observation_space(self, agent):
return self.observation_spaces[agent] | ['def', 'observation_space(self,', 'agent):', 'return', 'self.observation_spaces[agent]'] | 910,456 |
LucasAlegre/sumo-rl | env.py | SumoEnvironmentPZ.observe | observe | Return the observation for the agent. | [
"Return",
"the",
"observation",
"for",
"the",
"agent."
] | def observe(self, agent):
obs = self.env.observations[agent].copy()
return obs | ['def', 'observe(self,', 'agent):', 'obs', '=', 'self.env.observations[agent].copy()', 'return', 'obs'] | 910,458 |
LucasAlegre/sumo-rl | traffic_signal.py | TrafficSignal.time_to_act | time_to_act | Returns True if the traffic signal should act in the current step. | [
"Returns",
"True",
"if",
"the",
"traffic",
"signal",
"should",
"act",
"in",
"the",
"current",
"step."
] | def time_to_act(self):
return self.next_action_time == self.env.sim_step | ['def', 'time_to_act(self):', 'return', 'self.next_action_time', '==', 'self.env.sim_step'] | 910,471 |
LucasAlegre/sumo-rl | traffic_signal.py | TrafficSignal.register_reward_fn | register_reward_fn | Registers a reward function. | [
"Registers",
"a",
"reward",
"function."
] | def register_reward_fn(cls, fn: Callable):
if fn.__name__ in cls.reward_fns.keys():
raise KeyError(f'Reward function {fn.__name__} already exists')
cls.reward_fns[fn.__name__] = fn | ['def', 'register_reward_fn(cls,', 'fn:', 'Callable):', 'if', 'fn.__name__', 'in', 'cls.reward_fns.keys():', 'raise', "KeyError(f'Reward", 'function', '{fn.__name__}', 'already', "exists')", 'cls.reward_fns[fn.__name__]', '=', 'fn'] | 910,483 |
LucasAlegre/sumo-rl | epsilon_greedy.py | EpsilonGreedy.choose | choose | Choose action based on epsilon greedy strategy. | [
"Choose",
"action",
"based",
"on",
"epsilon",
"greedy",
"strategy."
] | def choose(self, q_table, state, action_space):
if np.random.rand() < self.epsilon:
action = int(action_space.sample())
else:
action = np.argmax(q_table[state])
self.epsilon = max(self.epsilon * self.decay, self.min_epsilon)
return action | ['def', 'choose(self,', 'q_table,', 'state,', 'action_space):', 'if', 'np.random.rand()', '<', 'self.epsilon:', 'action', '=', 'int(action_space.sample())', 'else:', 'action', '=', 'np.argmax(q_table[state])', 'self.epsilon', '=', 'max(self.epsilon', '*', 'self.decay,', 'self.min_epsilon)', 'return', 'action'] | 910,484 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | pool.py | ApplyResult.wait | wait | Waits until the result is available or until timeout seconds pass. | [
"Waits",
"until",
"the",
"result",
"is",
"available",
"or",
"until",
"timeout",
"seconds",
"pass."
] | def wait(self, timeout=None):
self._event.wait(timeout)
return self._event.isSet() | ['def', 'wait(self,', 'timeout=None):', 'self._event.wait(timeout)', 'return', 'self._event.isSet()'] | 910,501 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | base_modules.py | BaseModule.nb_params | nb_params | This property is used to return the number of trainable parameters for a given layer It is useful for debugging and reproducibility. | [
"This",
"property",
"is",
"used",
"to",
"return",
"the",
"number",
"of",
"trainable",
"parameters",
"for",
"a",
"given",
"layer",
"It",
"is",
"useful",
"for",
"debugging",
"and",
"reproducibility."
] | def nb_params(self):
model_parameters = filter(lambda p: p.requires_grad, self.parameters())
self._nb_params = sum([np.prod(p.size()) for p in model_parameters])
return self._nb_params | ['def', 'nb_params(self):', 'model_parameters', '=', 'filter(lambda', 'p:', 'p.requires_grad,', 'self.parameters())', 'self._nb_params', '=', 'sum([np.prod(p.size())', 'for', 'p', 'in', 'model_parameters])', 'return', 'self._nb_params'] | 910,639 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | lr_schedulers.py | collect_params | collect_params | This function enable to handle if params contains on_epoch and on_iter or not. | [
"This",
"function",
"enable",
"to",
"handle",
"if",
"params",
"contains",
"on_epoch",
"and",
"on_iter",
"or",
"not."
] | def collect_params(params, update_scheduler_on):
on_epoch_params = params.get('on_epoch')
on_batch_params = params.get('on_num_batch')
on_sample_params = params.get('on_num_sample')
def check_params(params):
if params is not None:
return params
else:
raise Except... | ['def', 'collect_params(params,', 'update_scheduler_on):', 'on_epoch_params', '=', "params.get('on_epoch')", 'on_batch_params', '=', "params.get('on_num_batch')", 'on_sample_params', '=', "params.get('on_num_sample')", 'def', 'check_params(params):', 'if', 'params', 'is', 'not', 'None:', 'return', 'params', 'else:', 'r... | 910,655 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | base_siamese_dataset.py | GeneralFragment.get_name | get_name | get the name of the scene and the name of the fragments. | [
"get",
"the",
"name",
"of",
"the",
"scene",
"and",
"the",
"name",
"of",
"the",
"fragments."
] | def get_name(self, idx):
match = np.load(osp.join(self.path_match, 'matches{:06d}.npy'.format(idx)), allow_pickle=True).item()
source = match['name_source']
target = match['name_target']
scene = match['scene']
return (scene, source, target) | ['def', 'get_name(self,', 'idx):', 'match', '=', 'np.load(osp.join(self.path_match,', "'matches{:06d}.npy'.format(idx)),", 'allow_pickle=True).item()', 'source', '=', "match['name_source']", 'target', '=', "match['name_target']", 'scene', '=', "match['scene']", 'return', '(scene,', 'source,', 'target)'] | 910,695 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | fusion.py | rigid_transform | rigid_transform | Applies a rigid transform to an (N, 3) pointcloud. | [
"Applies",
"a",
"rigid",
"transform",
"to",
"an",
"(N,",
"3)",
"pointcloud."
] | def rigid_transform(xyz, transform):
xyz_h = np.hstack([xyz, np.ones((len(xyz), 1), dtype=np.float32)])
xyz_t_h = np.dot(transform, xyz_h.T).T
return xyz_t_h[:, :3] | ['def', 'rigid_transform(xyz,', 'transform):', 'xyz_h', '=', 'np.hstack([xyz,', 'np.ones((len(xyz),', '1),', 'dtype=np.float32)])', 'xyz_t_h', '=', 'np.dot(transform,', 'xyz_h.T).T', 'return', 'xyz_t_h[:,', ':3]'] | 910,696 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | fusion.py | TSDFVolume.cam2pix | cam2pix | Convert camera coordinates to pixel coordinates. | [
"Convert",
"camera",
"coordinates",
"to",
"pixel",
"coordinates."
] | def cam2pix(cam_pts, intr):
intr = intr.astype(np.float32)
(fx, fy) = (intr[0, 0], intr[1, 1])
(cx, cy) = (intr[0, 2], intr[1, 2])
pix = np.empty((cam_pts.shape[0], 2), dtype=np.int64)
for i in prange(cam_pts.shape[0]):
pix[i, 0] = int(np.round(cam_pts[i, 0] * fx / cam_pts[i, 2] + cx))
... | ['def', 'cam2pix(cam_pts,', 'intr):', 'intr', '=', 'intr.astype(np.float32)', '(fx,', 'fy)', '=', '(intr[0,', '0],', 'intr[1,', '1])', '(cx,', 'cy)', '=', '(intr[0,', '2],', 'intr[1,', '2])', 'pix', '=', 'np.empty((cam_pts.shape[0],', '2),', 'dtype=np.int64)', 'for', 'i', 'in', 'prange(cam_pts.shape[0]):', 'pix[i,', '0... | 910,699 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | pair.py | Pair.make_pair | make_pair | add in a Data object the source elem, the target elem. | [
"add",
"in",
"a",
"Data",
"object",
"the",
"source",
"elem,",
"the",
"target",
"elem."
] | def make_pair(cls, data_source, data_target):
batch = cls()
for key in data_source.keys:
batch[key] = data_source[key]
for key_target in data_target.keys:
batch[key_target + '_target'] = data_target[key_target]
if batch.x is None:
batch['x_target'] = None
return batch.contigu... | ['def', 'make_pair(cls,', 'data_source,', 'data_target):', 'batch', '=', 'cls()', 'for', 'key', 'in', 'data_source.keys:', 'batch[key]', '=', 'data_source[key]', 'for', 'key_target', 'in', 'data_target.keys:', 'batch[key_target', '+', "'_target']", '=', 'data_target[key_target]', 'if', 'batch.x', 'is', 'None:', "batch[... | 910,705 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | utils.py | rgbd2fragment_fine | rgbd2fragment_fine | fuse rgbd frame with a tsdf volume and get the mesh using marching cube. | [
"fuse",
"rgbd",
"frame",
"with",
"a",
"tsdf",
"volume",
"and",
"get",
"the",
"mesh",
"using",
"marching",
"cube."
] | def rgbd2fragment_fine(list_path_img, path_intrinsic, list_path_trans, out_path, num_frame_per_fragment=5, voxel_size=0.01, pre_transform=None, depth_thresh=6, save_pc=True, limit_size=600):
ind = 0
begin = 0
end = num_frame_per_fragment
vol_bnds = get_3D_bound(list_path_img[begin:end], path_intrinsic, ... | ['def', 'rgbd2fragment_fine(list_path_img,', 'path_intrinsic,', 'list_path_trans,', 'out_path,', 'num_frame_per_fragment=5,', 'voxel_size=0.01,', 'pre_transform=None,', 'depth_thresh=6,', 'save_pc=True,', 'limit_size=600):', 'ind', '=', '0', 'begin', '=', '0', 'end', '=', 'num_frame_per_fragment', 'vol_bnds', '=', 'get... | 910,717 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | registration.py | get_matrix_system | get_matrix_system | Build matrix of size 3N x 6 and b of size 3N xyz size N x 3 xyz_target size N x 3 weight size N the matrix is minus cross product matrix concatenate with the identity (rearanged). | [
"Build",
"matrix",
"of",
"size",
"3N",
"x",
"6",
"and",
"b",
"of",
"size",
"3N",
"xyz",
"size",
"N",
"x",
"3",
"xyz_target",
"size",
"N",
"x",
"3",
"weight",
"size",
"N",
"the",
"matrix",
"is",
"minus",
"cross",
"product",
"matrix",
"concatenate",
"w... | def get_matrix_system(xyz, xyz_target, weight):
assert xyz.shape == xyz_target.shape
A_x = torch.zeros(xyz.shape[0], 6, device=xyz.device)
A_y = torch.zeros(xyz.shape[0], 6, device=xyz.device)
A_z = torch.zeros(xyz.shape[0], 6, device=xyz.device)
b_x = weight.view(-1) * (xyz_target[:, 0] - xyz[:, 0]... | ['def', 'get_matrix_system(xyz,', 'xyz_target,', 'weight):', 'assert', 'xyz.shape', '==', 'xyz_target.shape', 'A_x', '=', 'torch.zeros(xyz.shape[0],', '6,', 'device=xyz.device)', 'A_y', '=', 'torch.zeros(xyz.shape[0],', '6,', 'device=xyz.device)', 'A_z', '=', 'torch.zeros(xyz.shape[0],', '6,', 'device=xyz.device)', 'b_... | 910,866 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | pointnet.py | CloudEmbedder.run_full | run_full | Simply evaluates all clouds in a differentiable way, assumes that all pointnet's feature maps fit into mem. | [
"Simply",
"evaluates",
"all",
"clouds",
"in",
"a",
"differentiable",
"way,",
"assumes",
"that",
"all",
"pointnet's",
"feature",
"maps",
"fit",
"into",
"mem."
] | def run_full(self, model, clouds_meta, clouds_flag, clouds, clouds_global):
idx_valid = torch.nonzero(clouds_flag.eq(0)).squeeze()
if self.args.cuda:
(clouds, clouds_global, idx_valid) = (clouds.cuda(), clouds_global.cuda(), idx_valid.cuda())
(clouds, clouds_global) = (Variable(clouds, volatile=not ... | ['def', 'run_full(self,', 'model,', 'clouds_meta,', 'clouds_flag,', 'clouds,', 'clouds_global):', 'idx_valid', '=', 'torch.nonzero(clouds_flag.eq(0)).squeeze()', 'if', 'self.args.cuda:', '(clouds,', 'clouds_global,', 'idx_valid)', '=', '(clouds.cuda(),', 'clouds_global.cuda(),', 'idx_valid.cuda())', '(clouds,', 'clouds... | 911,650 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | pointnet.py | CloudEmbedder.run_full_monger | run_full_monger | Evaluates all clouds in forward pass, but uses memory mongering to compute backward pass. | [
"Evaluates",
"all",
"clouds",
"in",
"forward",
"pass,",
"but",
"uses",
"memory",
"mongering",
"to",
"compute",
"backward",
"pass."
] | def run_full_monger(self, model, clouds_meta, clouds_flag, clouds, clouds_global):
idx_valid = torch.nonzero(clouds_flag.eq(0)).squeeze()
if self.args.cuda:
(clouds, clouds_global, idx_valid) = (clouds.cuda(), clouds_global.cuda(), idx_valid.cuda())
with torch.no_grad():
out = model.ptn(Vari... | ['def', 'run_full_monger(self,', 'model,', 'clouds_meta,', 'clouds_flag,', 'clouds,', 'clouds_global):', 'idx_valid', '=', 'torch.nonzero(clouds_flag.eq(0)).squeeze()', 'if', 'self.args.cuda:', '(clouds,', 'clouds_global,', 'idx_valid)', '=', '(clouds.cuda(),', 'clouds_global.cuda(),', 'idx_valid.cuda())', 'with', 'tor... | 911,651 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | spg.py | loader | loader | Prepares a superpoint graph (potentially subsampled in training) and associated superpoints. | [
"Prepares",
"a",
"superpoint",
"graph",
"(potentially",
"subsampled",
"in",
"training)",
"and",
"associated",
"superpoints."
] | def loader(entry, train, args, db_path, test_seed_offset=0):
(G, fname) = entry
if train:
if 0 < args.spg_augm_hardcutoff < G.vcount():
perm = list(range(G.vcount()))
random.shuffle(perm)
G = G.permute_vertices(perm)
if 0 < args.spg_augm_nneigh < G.vcount():
... | ['def', 'loader(entry,', 'train,', 'args,', 'db_path,', 'test_seed_offset=0):', '(G,', 'fname)', '=', 'entry', 'if', 'train:', 'if', '0', '<', 'args.spg_augm_hardcutoff', '<', 'G.vcount():', 'perm', '=', 'list(range(G.vcount()))', 'random.shuffle(perm)', 'G', '=', 'G.permute_vertices(perm)', 'if', '0', '<', 'args.spg_a... | 911,663 |
tudelft3d/SUMS-Semantic-Urban-Mesh--public | my_supervized_partition.py | resume | resume | Loads model and optimizer state from a previous checkpoint. | [
"Loads",
"model",
"and",
"optimizer",
"state",
"from",
"a",
"previous",
"checkpoint."
] | def resume(args):
print("=> loading checkpoint '{}'".format(args.resume))
checkpoint = torch.load(args.resume)
model = create_model(checkpoint['args'])
if not args.cuda:
model = model.cpu()
optimizer = create_optimizer(args, model)
model.load_state_dict(checkpoint['state_dict'])
if '... | ['def', 'resume(args):', 'print("=>', 'loading', 'checkpoint', '\'{}\'".format(args.resume))', 'checkpoint', '=', 'torch.load(args.resume)', 'model', '=', "create_model(checkpoint['args'])", 'if', 'not', 'args.cuda:', 'model', '=', 'model.cpu()', 'optimizer', '=', 'create_optimizer(args,', 'model)', "model.load_state_d... | 911,736 |
pokaxpoka/sunrise | gps_utils.py | linear_gauss_fit_joint_prior | linear_gauss_fit_joint_prior | Perform Gaussian fit to data with a prior. | [
"Perform",
"Gaussian",
"fit",
"to",
"data",
"with",
"a",
"prior."
] | def linear_gauss_fit_joint_prior(train_data, prior_mean, prior_cov, niw_prior_m, niw_prior_n0, cov_reg_matrix):
prior_cov *= niw_prior_m
(num_data, vec_size) = train_data.shape
empirical_mean = train_data.mean(axis=0)
normalized_data = train_data - empirical_mean
empirical_cov = 1.0 / num_data * nor... | ['def', 'linear_gauss_fit_joint_prior(train_data,', 'prior_mean,', 'prior_cov,', 'niw_prior_m,', 'niw_prior_n0,', 'cov_reg_matrix):', 'prior_cov', '*=', 'niw_prior_m', '(num_data,', 'vec_size)', '=', 'train_data.shape', 'empirical_mean', '=', 'train_data.mean(axis=0)', 'normalized_data', '=', 'train_data', '-', 'empiri... | 911,776 |
pokaxpoka/sunrise | fisher_blocks.py | FullFB.full_fisher_block | full_fisher_block | Explicitly constructs the full Fisher block. | [
"Explicitly",
"constructs",
"the",
"full",
"Fisher",
"block."
] | def full_fisher_block(self):
return self._factor.get_cov() | ['def', 'full_fisher_block(self):', 'return', 'self._factor.get_cov()'] | 911,797 |
pokaxpoka/sunrise | fisher_blocks.py | FullFB.register_additional_minibatch | register_additional_minibatch | Register an additional minibatch. | [
"Register",
"an",
"additional",
"minibatch."
] | def register_additional_minibatch(self, batch_size):
self._batch_sizes.append(batch_size) | ['def', 'register_additional_minibatch(self,', 'batch_size):', 'self._batch_sizes.append(batch_size)'] | 911,798 |
pokaxpoka/sunrise | fisher_blocks.py | FullyConnectedDiagonalFB.multiply_inverse | multiply_inverse | Approximate damped inverse Fisher-vector product. | [
"Approximate",
"damped",
"inverse",
"Fisher-vector",
"product."
] | def multiply_inverse(self, vector):
reshaped_vect = utils.layer_params_to_mat2d(vector)
reshaped_out = reshaped_vect / (self._factor.get_cov() + self._damping)
return utils.mat2d_to_layer_params(vector, reshaped_out) | ['def', 'multiply_inverse(self,', 'vector):', 'reshaped_vect', '=', 'utils.layer_params_to_mat2d(vector)', 'reshaped_out', '=', 'reshaped_vect', '/', '(self._factor.get_cov()', '+', 'self._damping)', 'return', 'utils.mat2d_to_layer_params(vector,', 'reshaped_out)'] | 911,800 |
pokaxpoka/sunrise | fisher_blocks.py | FullyConnectedDiagonalFB.multiply | multiply | Approximate damped Fisher-vector product. | [
"Approximate",
"damped",
"Fisher-vector",
"product."
] | def multiply(self, vector):
reshaped_vect = utils.layer_params_to_mat2d(vector)
reshaped_out = reshaped_vect * (self._factor.get_cov() + self._damping)
return utils.mat2d_to_layer_params(vector, reshaped_out) | ['def', 'multiply(self,', 'vector):', 'reshaped_vect', '=', 'utils.layer_params_to_mat2d(vector)', 'reshaped_out', '=', 'reshaped_vect', '*', '(self._factor.get_cov()', '+', 'self._damping)', 'return', 'utils.mat2d_to_layer_params(vector,', 'reshaped_out)'] | 911,801 |
pokaxpoka/sunrise | fisher_blocks.py | FullyConnectedDiagonalFB.tensors_to_compute_grads | tensors_to_compute_grads | Tensors to compute derivative of loss with respect to. | [
"Tensors",
"to",
"compute",
"derivative",
"of",
"loss",
"with",
"respect",
"to."
] | def tensors_to_compute_grads(self):
return self._outputs | ['def', 'tensors_to_compute_grads(self):', 'return', 'self._outputs'] | 911,802 |
pokaxpoka/sunrise | fisher_blocks.py | FullyConnectedDiagonalFB.register_additional_minibatch | register_additional_minibatch | Registers an additional minibatch to the FisherBlock. | [
"Registers",
"an",
"additional",
"minibatch",
"to",
"the",
"FisherBlock."
] | def register_additional_minibatch(self, inputs, outputs):
self._inputs.append(inputs)
self._outputs.append(outputs) | ['def', 'register_additional_minibatch(self,', 'inputs,', 'outputs):', 'self._inputs.append(inputs)', 'self._outputs.append(outputs)'] | 911,803 |
pokaxpoka/sunrise | fisher_blocks.py | FullyConnectedKFACBasicFB.instantiate_factors | instantiate_factors | Instantiate Kronecker Factors for this FisherBlock. | [
"Instantiate",
"Kronecker",
"Factors",
"for",
"this",
"FisherBlock."
] | def instantiate_factors(self, grads_list, damping):
inputs = _concat_along_batch_dim(self._inputs)
grads_list = tuple((_concat_along_batch_dim(grads) for grads in grads_list))
self._input_factor = self._layer_collection.make_or_get_factor(fisher_factors.FullyConnectedKroneckerFactor, ((inputs,), self._has_b... | ['def', 'instantiate_factors(self,', 'grads_list,', 'damping):', 'inputs', '=', '_concat_along_batch_dim(self._inputs)', 'grads_list', '=', 'tuple((_concat_along_batch_dim(grads)', 'for', 'grads', 'in', 'grads_list))', 'self._input_factor', '=', 'self._layer_collection.make_or_get_factor(fisher_factors.FullyConnectedKr... | 911,806 |
pokaxpoka/sunrise | fisher_factors.py | FisherFactor.instantiate_covariance | instantiate_covariance | Instantiates the covariance Variable as the instance member _cov. | [
"Instantiates",
"the",
"covariance",
"Variable",
"as",
"the",
"instance",
"member",
"_cov."
] | def instantiate_covariance(self):
with variable_scope.variable_scope(self._var_scope):
self._cov = variable_scope.get_variable('cov', initializer=self._cov_initializer, shape=self._cov_shape, trainable=False, dtype=self._dtype) | ['def', 'instantiate_covariance(self):', 'with', 'variable_scope.variable_scope(self._var_scope):', 'self._cov', '=', "variable_scope.get_variable('cov',", 'initializer=self._cov_initializer,', 'shape=self._cov_shape,', 'trainable=False,', 'dtype=self._dtype)'] | 911,811 |
pokaxpoka/sunrise | fisher_factors.py | InverseProvidingFactor.make_inverse_update_ops | make_inverse_update_ops | Create and return update ops corresponding to registered computations. | [
"Create",
"and",
"return",
"update",
"ops",
"corresponding",
"to",
"registered",
"computations."
] | def make_inverse_update_ops(self):
ops = []
num_inverses = len(self._inverses_by_damping)
matrix_power_registered = bool(self._matpower_by_exp_and_damping)
use_eig = self._eigendecomp or matrix_power_registered or num_inverses >= EIGENVALUE_DECOMPOSITION_THRESHOLD
if use_eig:
self.register_e... | ['def', 'make_inverse_update_ops(self):', 'ops', '=', '[]', 'num_inverses', '=', 'len(self._inverses_by_damping)', 'matrix_power_registered', '=', 'bool(self._matpower_by_exp_and_damping)', 'use_eig', '=', 'self._eigendecomp', 'or', 'matrix_power_registered', 'or', 'num_inverses', '>=', 'EIGENVALUE_DECOMPOSITION_THRESH... | 911,817 |
pokaxpoka/sunrise | layer_collection.py | LayerCollection.losses | losses | LossFunctions registered with this LayerCollection. | [
"LossFunctions",
"registered",
"with",
"this",
"LayerCollection."
] | def losses(self):
return list(self._loss_dict.values()) | ['def', 'losses(self):', 'return', 'list(self._loss_dict.values())'] | 911,818 |
pokaxpoka/sunrise | layer_collection.py | LayerCollection.registered_variables | registered_variables | A tuple of all of the variables currently registered. | [
"A",
"tuple",
"of",
"all",
"of",
"the",
"variables",
"currently",
"registered."
] | def registered_variables(self):
tuple_of_tuples = (ensure_sequence(key) for (key, block) in six.iteritems(self.fisher_blocks))
flat_tuple = tuple((item for tuple_ in tuple_of_tuples for item in tuple_))
return flat_tuple | ['def', 'registered_variables(self):', 'tuple_of_tuples', '=', '(ensure_sequence(key)', 'for', '(key,', 'block)', 'in', 'six.iteritems(self.fisher_blocks))', 'flat_tuple', '=', 'tuple((item', 'for', 'tuple_', 'in', 'tuple_of_tuples', 'for', 'item', 'in', 'tuple_))', 'return', 'flat_tuple'] | 911,819 |
pokaxpoka/sunrise | loss_functions.py | CategoricalLogitsNegativeLogProbLoss.register_additional_minibatch | register_additional_minibatch | Register an additiona minibatch's worth of parameters. | [
"Register",
"an",
"additiona",
"minibatch's",
"worth",
"of",
"parameters."
] | def register_additional_minibatch(self, logits, targets=None):
self._logits_components.append(logits)
self._targets_components.append(targets) | ['def', 'register_additional_minibatch(self,', 'logits,', 'targets=None):', 'self._logits_components.append(logits)', 'self._targets_components.append(targets)'] | 911,840 |
pokaxpoka/sunrise | utils.py | tensors_to_column | tensors_to_column | Converts a tensor or list of tensors to a column vector. | [
"Converts",
"a",
"tensor",
"or",
"list",
"of",
"tensors",
"to",
"a",
"column",
"vector."
] | def tensors_to_column(tensors):
if isinstance(tensors, (tuple, list)):
return array_ops.concat(tuple((array_ops.reshape(tensor, [-1, 1]) for tensor in tensors)), axis=0)
else:
return array_ops.reshape(tensors, [-1, 1]) | ['def', 'tensors_to_column(tensors):', 'if', 'isinstance(tensors,', '(tuple,', 'list)):', 'return', 'array_ops.concat(tuple((array_ops.reshape(tensor,', '[-1,', '1])', 'for', 'tensor', 'in', 'tensors)),', 'axis=0)', 'else:', 'return', 'array_ops.reshape(tensors,', '[-1,', '1])'] | 911,842 |
pokaxpoka/sunrise | utils.py | kronecker_product | kronecker_product | Computes the Kronecker product two matrices. | [
"Computes",
"the",
"Kronecker",
"product",
"two",
"matrices."
] | def kronecker_product(mat1, mat2):
(m1, n1) = mat1.get_shape().as_list()
mat1_rsh = array_ops.reshape(mat1, [m1, 1, n1, 1])
(m2, n2) = mat2.get_shape().as_list()
mat2_rsh = array_ops.reshape(mat2, [1, m2, 1, n2])
return array_ops.reshape(mat1_rsh * mat2_rsh, [m1 * m2, n1 * n2]) | ['def', 'kronecker_product(mat1,', 'mat2):', '(m1,', 'n1)', '=', 'mat1.get_shape().as_list()', 'mat1_rsh', '=', 'array_ops.reshape(mat1,', '[m1,', '1,', 'n1,', '1])', '(m2,', 'n2)', '=', 'mat2.get_shape().as_list()', 'mat2_rsh', '=', 'array_ops.reshape(mat2,', '[1,', 'm2,', '1,', 'n2])', 'return', 'array_ops.reshape(ma... | 911,844 |
pokaxpoka/sunrise | utils.py | mat2d_to_layer_params | mat2d_to_layer_params | Converts a canonical 2D matrix representation back to a vector. | [
"Converts",
"a",
"canonical",
"2D",
"matrix",
"representation",
"back",
"to",
"a",
"vector."
] | def mat2d_to_layer_params(vector_template, mat2d):
if isinstance(vector_template, (tuple, list)):
(w_part, b_part) = (mat2d[:-1], mat2d[-1])
return (array_ops.reshape(w_part, vector_template[0].shape), b_part)
else:
return array_ops.reshape(mat2d, vector_template.shape) | ['def', 'mat2d_to_layer_params(vector_template,', 'mat2d):', 'if', 'isinstance(vector_template,', '(tuple,', 'list)):', '(w_part,', 'b_part)', '=', '(mat2d[:-1],', 'mat2d[-1])', 'return', '(array_ops.reshape(w_part,', 'vector_template[0].shape),', 'b_part)', 'else:', 'return', 'array_ops.reshape(mat2d,', 'vector_templa... | 911,846 |
pokaxpoka/sunrise | utils.py | posdef_inv | posdef_inv | Computes the inverse of tensor + damping * identity. | [
"Computes",
"the",
"inverse",
"of",
"tensor",
"+",
"damping",
"*",
"identity."
] | def posdef_inv(tensor, damping):
identity = linalg_ops.eye(tensor.shape.as_list()[0], dtype=tensor.dtype)
damping = math_ops.cast(damping, dtype=tensor.dtype)
return posdef_inv_functions[POSDEF_INV_METHOD](tensor, identity, damping) | ['def', 'posdef_inv(tensor,', 'damping):', 'identity', '=', 'linalg_ops.eye(tensor.shape.as_list()[0],', 'dtype=tensor.dtype)', 'damping', '=', 'math_ops.cast(damping,', 'dtype=tensor.dtype)', 'return', 'posdef_inv_functions[POSDEF_INV_METHOD](tensor,', 'identity,', 'damping)'] | 911,847 |
pokaxpoka/sunrise | utils.py | posdef_inv_matrix_inverse | posdef_inv_matrix_inverse | Computes inverse(tensor + damping * identity) directly. | [
"Computes",
"inverse(tensor",
"+",
"damping",
"*",
"identity)",
"directly."
] | def posdef_inv_matrix_inverse(tensor, identity, damping):
return linalg_ops.matrix_inverse(tensor + damping * identity) | ['def', 'posdef_inv_matrix_inverse(tensor,', 'identity,', 'damping):', 'return', 'linalg_ops.matrix_inverse(tensor', '+', 'damping', '*', 'identity)'] | 911,848 |
pokaxpoka/sunrise | utils.py | posdef_inv_cholesky | posdef_inv_cholesky | Computes inverse(tensor + damping * identity) with Cholesky. | [
"Computes",
"inverse(tensor",
"+",
"damping",
"*",
"identity)",
"with",
"Cholesky."
] | def posdef_inv_cholesky(tensor, identity, damping):
chol = linalg_ops.cholesky(tensor + damping * identity)
return linalg_ops.cholesky_solve(chol, identity) | ['def', 'posdef_inv_cholesky(tensor,', 'identity,', 'damping):', 'chol', '=', 'linalg_ops.cholesky(tensor', '+', 'damping', '*', 'identity)', 'return', 'linalg_ops.cholesky_solve(chol,', 'identity)'] | 911,849 |
pokaxpoka/sunrise | utils.py | posdef_eig | posdef_eig | Computes the eigendecomposition of a positive semidefinite matrix. | [
"Computes",
"the",
"eigendecomposition",
"of",
"a",
"positive",
"semidefinite",
"matrix."
] | def posdef_eig(mat):
return posdef_eig_functions[POSDEF_EIG_METHOD](mat) | ['def', 'posdef_eig(mat):', 'return', 'posdef_eig_functions[POSDEF_EIG_METHOD](mat)'] | 911,851 |
pokaxpoka/sunrise | utils.py | generate_random_signs | generate_random_signs | Generate a random tensor with {-1, +1} entries. | [
"Generate",
"a",
"random",
"tensor",
"with",
"{-1,",
"+1}",
"entries."
] | def generate_random_signs(shape, dtype=dtypes.float32):
ints = random_ops.random_uniform(shape, maxval=2, dtype=dtypes.int32)
return 2 * math_ops.cast(ints, dtype=dtype) - 1 | ['def', 'generate_random_signs(shape,', 'dtype=dtypes.float32):', 'ints', '=', 'random_ops.random_uniform(shape,', 'maxval=2,', 'dtype=dtypes.int32)', 'return', '2', '*', 'math_ops.cast(ints,', 'dtype=dtype)', '-', '1'] | 911,854 |
NREL/sup3r | abstract.py | AbstractInterface.output_features | output_features | Get the list of output feature names that the generative model outputs and that the discriminator predicts on. | [
"Get",
"the",
"list",
"of",
"output",
"feature",
"names",
"that",
"the",
"generative",
"model",
"outputs",
"and",
"that",
"the",
"discriminator",
"predicts",
"on."
] | def output_features(self):
return self.meta.get('output_features', None) | ['def', 'output_features(self):', 'return', "self.meta.get('output_features',", 'None)'] | 911,964 |
NREL/sup3r | abstract.py | AbstractInterface.smoothed_features | smoothed_features | Get the list of smoothed input feature names that the generative model was trained on. | [
"Get",
"the",
"list",
"of",
"smoothed",
"input",
"feature",
"names",
"that",
"the",
"generative",
"model",
"was",
"trained",
"on."
] | def smoothed_features(self):
return self.meta.get('smoothed_features', None) | ['def', 'smoothed_features(self):', 'return', "self.meta.get('smoothed_features',", 'None)'] | 911,966 |
NREL/sup3r | linear.py | LinearInterp.training_features | training_features | Get the list of input feature names that the generative model was trained on. | [
"Get",
"the",
"list",
"of",
"input",
"feature",
"names",
"that",
"the",
"generative",
"model",
"was",
"trained",
"on."
] | def training_features(self):
return self._features | ['def', 'training_features(self):', 'return', 'self._features'] | 912,026 |
NREL/sup3r | multi_step.py | MultiStepGan.training_features | training_features | Get the list of input feature names that the first generative model in this MultiStepGan requires as input. | [
"Get",
"the",
"list",
"of",
"input",
"feature",
"names",
"that",
"the",
"first",
"generative",
"model",
"in",
"this",
"MultiStepGan",
"requires",
"as",
"input."
] | def training_features(self):
return self.models[0].meta.get('training_features', None) | ['def', 'training_features(self):', 'return', "self.models[0].meta.get('training_features',", 'None)'] | 912,037 |
NREL/sup3r | multi_step.py | MultiStepGan.output_features | output_features | Get the list of output feature names that the last generative model in this MultiStepGan outputs. | [
"Get",
"the",
"list",
"of",
"output",
"feature",
"names",
"that",
"the",
"last",
"generative",
"model",
"in",
"this",
"MultiStepGan",
"outputs."
] | def output_features(self):
return self.models[-1].meta.get('output_features', None) | ['def', 'output_features(self):', 'return', "self.models[-1].meta.get('output_features',", 'None)'] | 912,038 |
NREL/sup3r | multi_step.py | SolarMultiStepGan.preflight | preflight | Run some preflight checks to make sure the loaded models can work together. | [
"Run",
"some",
"preflight",
"checks",
"to",
"make",
"sure",
"the",
"loaded",
"models",
"can",
"work",
"together."
] | def preflight(self):
s_enh = [model.s_enhance for model in self.spatial_solar_models.models]
w_enh = [model.s_enhance for model in self.spatial_wind_models.models]
msg = 'Solar and wind spatial enhancements must be equivalent but received models that do spatial enhancements of {} (solar) and {} (wind)'.form... | ['def', 'preflight(self):', 's_enh', '=', '[model.s_enhance', 'for', 'model', 'in', 'self.spatial_solar_models.models]', 'w_enh', '=', '[model.s_enhance', 'for', 'model', 'in', 'self.spatial_wind_models.models]', 'msg', '=', "'Solar", 'and', 'wind', 'spatial', 'enhancements', 'must', 'be', 'equivalent', 'but', 'receive... | 912,044 |
NREL/sup3r | multi_step.py | SolarMultiStepGan.spatial_models | spatial_models | Alias for spatial_solar_models to preserve MultiStepGan interface. | [
"Alias",
"for",
"spatial_solar_models",
"to",
"preserve",
"MultiStepGan",
"interface."
] | def spatial_models(self):
return self.spatial_solar_models | ['def', 'spatial_models(self):', 'return', 'self.spatial_solar_models'] | 912,045 |
NREL/sup3r | multi_step.py | SolarMultiStepGan.output_features | output_features | Get the list of output feature names that the last solar spatiotemporal generative model in this SolarMultiStepGan outputs. | [
"Get",
"the",
"list",
"of",
"output",
"feature",
"names",
"that",
"the",
"last",
"solar",
"spatiotemporal",
"generative",
"model",
"in",
"this",
"SolarMultiStepGan",
"outputs."
] | def output_features(self):
return self.temporal_solar_models.output_features | ['def', 'output_features(self):', 'return', 'self.temporal_solar_models.output_features'] | 912,052 |
NREL/sup3r | surface.py | SurfaceSpatialMetModel.feature_inds_temp | feature_inds_temp | Get the feature index values for the temperature features. | [
"Get",
"the",
"feature",
"index",
"values",
"for",
"the",
"temperature",
"features."
] | def feature_inds_temp(self):
inds = [i for (i, name) in enumerate(self._features) if fnmatch(name, 'temperature_*')]
return inds | ['def', 'feature_inds_temp(self):', 'inds', '=', '[i', 'for', '(i,', 'name)', 'in', 'enumerate(self._features)', 'if', 'fnmatch(name,', "'temperature_*')]", 'return', 'inds'] | 912,060 |
NREL/sup3r | surface.py | SurfaceSpatialMetModel.feature_inds_pres | feature_inds_pres | Get the feature index values for the pressure features. | [
"Get",
"the",
"feature",
"index",
"values",
"for",
"the",
"pressure",
"features."
] | def feature_inds_pres(self):
inds = [i for (i, name) in enumerate(self._features) if fnmatch(name, 'pressure_*')]
return inds | ['def', 'feature_inds_pres(self):', 'inds', '=', '[i', 'for', '(i,', 'name)', 'in', 'enumerate(self._features)', 'if', 'fnmatch(name,', "'pressure_*')]", 'return', 'inds'] | 912,061 |
NREL/sup3r | forward_pass.py | ForwardPassSlicer.s2_lr_slices | s2_lr_slices | List of low resolution spatial slices for second spatial dimension considering padding on all sides of the spatial raster. | [
"List",
"of",
"low",
"resolution",
"spatial",
"slices",
"for",
"second",
"spatial",
"dimension",
"considering",
"padding",
"on",
"all",
"sides",
"of",
"the",
"spatial",
"raster."
] | def s2_lr_slices(self):
ind = slice(0, self.grid_shape[1])
slices = get_chunk_slices(self.grid_shape[1], self.chunk_shape[1], index_slice=ind)
return slices | ['def', 's2_lr_slices(self):', 'ind', '=', 'slice(0,', 'self.grid_shape[1])', 'slices', '=', 'get_chunk_slices(self.grid_shape[1],', 'self.chunk_shape[1],', 'index_slice=ind)', 'return', 'slices'] | 912,086 |
NREL/sup3r | forward_pass.py | ForwardPassSlicer.spatial_chunk_lookup | spatial_chunk_lookup | Get a 2D array with shape (n_spatial_1_chunks, n_spatial_2_chunks) where each value is the spatial chunk index. | [
"Get",
"a",
"2D",
"array",
"with",
"shape",
"(n_spatial_1_chunks,",
"n_spatial_2_chunks)",
"where",
"each",
"value",
"is",
"the",
"spatial",
"chunk",
"index."
] | def spatial_chunk_lookup(self):
n_s1 = len(self.s1_lr_slices)
n_s2 = len(self.s2_lr_slices)
return np.arange(self.n_spatial_chunks).reshape((n_s1, n_s2)) | ['def', 'spatial_chunk_lookup(self):', 'n_s1', '=', 'len(self.s1_lr_slices)', 'n_s2', '=', 'len(self.s2_lr_slices)', 'return', 'np.arange(self.n_spatial_chunks).reshape((n_s1,', 'n_s2))'] | 912,090 |
NREL/sup3r | forward_pass.py | ForwardPass.meta | meta | Meta data dictionary for the forward pass run (to write to output files). | [
"Meta",
"data",
"dictionary",
"for",
"the",
"forward",
"pass",
"run",
"(to",
"write",
"to",
"output",
"files)."
] | def meta(self):
meta_data = {'chunk_meta': self.chunk_specific_meta, 'gan_meta': self.model.meta, 'model_kwargs': self.model_kwargs, 'model_class': self.model_class, 'spatial_enhance': int(self.s_enhance), 'temporal_enhance': int(self.t_enhance), 'input_files': self.file_paths, 'input_features': self.features, 'out... | ['def', 'meta(self):', 'meta_data', '=', "{'chunk_meta':", 'self.chunk_specific_meta,', "'gan_meta':", 'self.model.meta,', "'model_kwargs':", 'self.model_kwargs,', "'model_class':", 'self.model_class,', "'spatial_enhance':", 'int(self.s_enhance),', "'temporal_enhance':", 'int(self.t_enhance),', "'input_files':", 'self.... | 912,121 |
NREL/sup3r | forward_pass.py | ForwardPass.temporal_pad_slice | temporal_pad_slice | Get the low resolution temporal slice including padding. | [
"Get",
"the",
"low",
"resolution",
"temporal",
"slice",
"including",
"padding."
] | def temporal_pad_slice(self):
ti_pad_slice = self.ti_pad_slice
if self.single_ts_files:
ti_pad_slice = slice(None)
return ti_pad_slice | ['def', 'temporal_pad_slice(self):', 'ti_pad_slice', '=', 'self.ti_pad_slice', 'if', 'self.single_ts_files:', 'ti_pad_slice', '=', 'slice(None)', 'return', 'ti_pad_slice'] | 912,124 |
NREL/sup3r | forward_pass.py | ForwardPass.run_chunk | run_chunk | Run a forward pass on single spatiotemporal chunk. | [
"Run",
"a",
"forward",
"pass",
"on",
"single",
"spatiotemporal",
"chunk."
] | def run_chunk(self):
msg = f'Running forward pass for chunk_index={self.chunk_index}, node_index={self.node_index}, file_paths={self.file_paths}. Starting forward pass on chunk_shape={self.chunk_shape} with spatial_pad={self.strategy.spatial_pad} and temporal_pad={self.strategy.temporal_pad}.'
logger.info(msg)
... | ['def', 'run_chunk(self):', 'msg', '=', "f'Running", 'forward', 'pass', 'for', 'chunk_index={self.chunk_index},', 'node_index={self.node_index},', 'file_paths={self.file_paths}.', 'Starting', 'forward', 'pass', 'on', 'chunk_shape={self.chunk_shape}', 'with', 'spatial_pad={self.strategy.spatial_pad}', 'and', "temporal_p... | 912,146 |
NREL/sup3r | forward_pass_cli.py | from_config | from_config | Run sup3r forward pass from a config file. | [
"Run",
"sup3r",
"forward",
"pass",
"from",
"a",
"config",
"file."
] | def from_config(ctx, config_file, verbose):
config = BaseCLI.from_config_preflight(ModuleName.FORWARD_PASS, ctx, config_file, verbose)
exec_kwargs = config.get('execution_control', {})
hardware_option = exec_kwargs.pop('option', 'local')
node_index = config.get('node_index', None)
basename = config.... | ['def', 'from_config(ctx,', 'config_file,', 'verbose):', 'config', '=', 'BaseCLI.from_config_preflight(ModuleName.FORWARD_PASS,', 'ctx,', 'config_file,', 'verbose)', 'exec_kwargs', '=', "config.get('execution_control',", '{})', 'hardware_option', '=', "exec_kwargs.pop('option',", "'local')", 'node_index', '=', "config.... | 912,147 |
NREL/sup3r | pipeline_cli.py | from_config | from_config | Run sup3r pipeline from a config file. | [
"Run",
"sup3r",
"pipeline",
"from",
"a",
"config",
"file."
] | def from_config(ctx, config_file, cancel, monitor, background, verbose):
ctx.ensure_object(dict)
verbose = any([verbose, ctx.obj.get('VERBOSE', False)])
if cancel:
Pipeline.cancel_all(config_file)
elif monitor and background:
pipeline_monitor_background(config_file, verbose=verbose)
... | ['def', 'from_config(ctx,', 'config_file,', 'cancel,', 'monitor,', 'background,', 'verbose):', 'ctx.ensure_object(dict)', 'verbose', '=', 'any([verbose,', "ctx.obj.get('VERBOSE',", 'False)])', 'if', 'cancel:', 'Pipeline.cancel_all(config_file)', 'elif', 'monitor', 'and', 'background:', 'pipeline_monitor_background(conf... | 912,151 |
NREL/sup3r | file_handling.py | RexOutputs.set_version_attr | set_version_attr | Set the version attribute to the h5 file. | [
"Set",
"the",
"version",
"attribute",
"to",
"the",
"h5",
"file."
] | def set_version_attr(self):
self.h5.attrs['version'] = __version__
self.h5.attrs['full_version_record'] = json.dumps(self.full_version_record)
self.h5.attrs['package'] = 'sup3r' | ['def', 'set_version_attr(self):', "self.h5.attrs['version']", '=', '__version__', "self.h5.attrs['full_version_record']", '=', 'json.dumps(self.full_version_record)', "self.h5.attrs['package']", '=', "'sup3r'"] | 912,162 |
NREL/sup3r | batch_handling.py | Batch.low_res | low_res | Get the low-resolution data for the batch. | [
"Get",
"the",
"low-resolution",
"data",
"for",
"the",
"batch."
] | def low_res(self):
return self._low_res | ['def', 'low_res(self):', 'return', 'self._low_res'] | 912,177 |
NREL/sup3r | batch_handling.py | Batch.high_res | high_res | Get the high-resolution data for the batch. | [
"Get",
"the",
"high-resolution",
"data",
"for",
"the",
"batch."
] | def high_res(self):
return self._high_res | ['def', 'high_res(self):', 'return', 'self._high_res'] | 912,178 |
NREL/sup3r | batch_handling.py | BatchHandler.parallel_normalization | parallel_normalization | Normalize data in all data handlers in parallel. | [
"Normalize",
"data",
"in",
"all",
"data",
"handlers",
"in",
"parallel."
] | def parallel_normalization(self):
logger.info(f'Normalizing {len(self.data_handlers)} data handlers.')
max_workers = self.load_workers
if max_workers == 1:
for d in self.data_handlers:
d.normalize(self.means, self.stds)
else:
with ThreadPoolExecutor(max_workers=max_workers) a... | ['def', 'parallel_normalization(self):', "logger.info(f'Normalizing", '{len(self.data_handlers)}', 'data', "handlers.')", 'max_workers', '=', 'self.load_workers', 'if', 'max_workers', '==', '1:', 'for', 'd', 'in', 'self.data_handlers:', 'd.normalize(self.means,', 'self.stds)', 'else:', 'with', 'ThreadPoolExecutor(max_w... | 912,196 |
NREL/sup3r | conditional_moment_batch_handling.py | BatchMom1.mask | mask | Get the mask for the batch. | [
"Get",
"the",
"mask",
"for",
"the",
"batch."
] | def mask(self):
return self._mask | ['def', 'mask(self):', 'return', 'self._mask'] | 912,213 |
NREL/sup3r | feature_handling.py | TempNC.inputs | inputs | Get list of inputs needed for compute method. | [
"Get",
"list",
"of",
"inputs",
"needed",
"for",
"compute",
"method."
] | def inputs(cls, feature):
height = Feature.get_height(feature)
features = [f'PotentialTemp_{height}m', f'Pressure_{height}m']
return features | ['def', 'inputs(cls,', 'feature):', 'height', '=', 'Feature.get_height(feature)', 'features', '=', "[f'PotentialTemp_{height}m',", "f'Pressure_{height}m']", 'return', 'features'] | 912,233 |
NREL/sup3r | base.py | DataHandler.norm_workers | norm_workers | Get upper bound on workers used for normalization. | [
"Get",
"upper",
"bound",
"on",
"workers",
"used",
"for",
"normalization."
] | def norm_workers(self):
if self.data is not None:
norm_workers = estimate_max_workers(self._norm_workers, 2 * self.feature_mem, self.shape[-1])
else:
norm_workers = self._norm_workers
return norm_workers | ['def', 'norm_workers(self):', 'if', 'self.data', 'is', 'not', 'None:', 'norm_workers', '=', 'estimate_max_workers(self._norm_workers,', '2', '*', 'self.feature_mem,', 'self.shape[-1])', 'else:', 'norm_workers', '=', 'self._norm_workers', 'return', 'norm_workers'] | 912,299 |
NREL/sup3r | base.py | DataHandler.output_features | output_features | Get a list of features that should be output by the generative model corresponding to the features in the high res batch array. | [
"Get",
"a",
"list",
"of",
"features",
"that",
"should",
"be",
"output",
"by",
"the",
"generative",
"model",
"corresponding",
"to",
"the",
"features",
"in",
"the",
"high",
"res",
"batch",
"array."
] | def output_features(self):
out = []
for feature in self.features:
ignore = any((fnmatch(feature.lower(), pattern.lower()) for pattern in self.train_only_features))
if not ignore:
out.append(feature)
return out | ['def', 'output_features(self):', 'out', '=', '[]', 'for', 'feature', 'in', 'self.features:', 'ignore', '=', 'any((fnmatch(feature.lower(),', 'pattern.lower())', 'for', 'pattern', 'in', 'self.train_only_features))', 'if', 'not', 'ignore:', 'out.append(feature)', 'return', 'out'] | 912,313 |
NREL/sup3r | base.py | DataHandler.load_cached_data | load_cached_data | Load data from cache files and split into training and validation Parameters ---------- with_split : bool Whether to split into training and validation data or not. | [
"Load",
"data",
"from",
"cache",
"files",
"and",
"split",
"into",
"training",
"and",
"validation",
"Parameters",
"----------",
"with_split",
":",
"bool",
"Whether",
"to",
"split",
"into",
"training",
"and",
"validation",
"data",
"or",
"not."
] | def load_cached_data(self, with_split=True):
if self.data is not None:
logger.info('Called load_cached_data() but self.data is not None')
elif self.data is None:
msg = 'Found {} cache files but need {} for features {}! These are the cache files that were found: {}'.format(len(self.cache_files), ... | ['def', 'load_cached_data(self,', 'with_split=True):', 'if', 'self.data', 'is', 'not', 'None:', "logger.info('Called", 'load_cached_data()', 'but', 'self.data', 'is', 'not', "None')", 'elif', 'self.data', 'is', 'None:', 'msg', '=', "'Found", '{}', 'cache', 'files', 'but', 'need', '{}', 'for', 'features', '{}!', 'These'... | 912,330 |
NREL/sup3r | base.py | DataHandler.run_data_extraction | run_data_extraction | Run the raw dataset extraction process from disk to raw un-manipulated datasets. | [
"Run",
"the",
"raw",
"dataset",
"extraction",
"process",
"from",
"disk",
"to",
"raw",
"un-manipulated",
"datasets."
] | def run_data_extraction(self):
if self.extract_features:
logger.info(f'Starting extraction of {self.extract_features} using {len(self.time_chunks)} time_chunks.')
if self.extract_workers == 1:
self._raw_data = self.serial_extract(self.file_paths, self.raster_index, self.time_chunks, self... | ['def', 'run_data_extraction(self):', 'if', 'self.extract_features:', "logger.info(f'Starting", 'extraction', 'of', '{self.extract_features}', 'using', '{len(self.time_chunks)}', "time_chunks.')", 'if', 'self.extract_workers', '==', '1:', 'self._raw_data', '=', 'self.serial_extract(self.file_paths,', 'self.raster_index... | 912,332 |
NREL/sup3r | base.py | DataHandler.run_data_compute | run_data_compute | Run the data computation / derivation from raw features to desired features. | [
"Run",
"the",
"data",
"computation",
"/",
"derivation",
"from",
"raw",
"features",
"to",
"desired",
"features."
] | def run_data_compute(self):
if self.derive_features:
logger.info(f'Starting computation of {self.derive_features}')
if self.compute_workers == 1:
self._raw_data = self.serial_compute(self._raw_data, self.file_paths, self.raster_index, self.time_chunks, self.derive_features, self.noncache... | ['def', 'run_data_compute(self):', 'if', 'self.derive_features:', "logger.info(f'Starting", 'computation', 'of', "{self.derive_features}')", 'if', 'self.compute_workers', '==', '1:', 'self._raw_data', '=', 'self.serial_compute(self._raw_data,', 'self.file_paths,', 'self.raster_index,', 'self.time_chunks,', 'self.derive... | 912,333 |
NREL/sup3r | mixin.py | InputMixIn.target | target | Get lower left corner of raster Returns ------- _target: tuple (lat, lon) lower left corner of raster. | [
"Get",
"lower",
"left",
"corner",
"of",
"raster",
"Returns",
"-------",
"_target:",
"tuple",
"(lat,",
"lon)",
"lower",
"left",
"corner",
"of",
"raster."
] | def target(self):
if self._target is None:
lat_lon = self.lat_lon
if not self.lats_are_descending(lat_lon):
self._target = tuple(lat_lon[0, 0, :])
else:
self._target = tuple(lat_lon[-1, 0, :])
return self._target | ['def', 'target(self):', 'if', 'self._target', 'is', 'None:', 'lat_lon', '=', 'self.lat_lon', 'if', 'not', 'self.lats_are_descending(lat_lon):', 'self._target', '=', 'tuple(lat_lon[0,', '0,', ':])', 'else:', 'self._target', '=', 'tuple(lat_lon[-1,', '0,', ':])', 'return', 'self._target'] | 912,438 |
NREL/sup3r | qa_cli.py | from_config | from_config | Run the sup3r QA module from a config file. | [
"Run",
"the",
"sup3r",
"QA",
"module",
"from",
"a",
"config",
"file."
] | def from_config(ctx, config_file, verbose):
BaseCLI.from_config(ModuleName.QA, Sup3rQa, ctx, config_file, verbose) | ['def', 'from_config(ctx,', 'config_file,', 'verbose):', 'BaseCLI.from_config(ModuleName.QA,', 'Sup3rQa,', 'ctx,', 'config_file,', 'verbose)'] | 912,477 |
NREL/sup3r | stats_cli.py | from_config | from_config | Run the sup3r WindStats module from a config file. | [
"Run",
"the",
"sup3r",
"WindStats",
"module",
"from",
"a",
"config",
"file."
] | def from_config(ctx, config_file, verbose):
BaseCLI.from_config(ModuleName.STATS, Sup3rStatsMulti, ctx, config_file, verbose) | ['def', 'from_config(ctx,', 'config_file,', 'verbose):', 'BaseCLI.from_config(ModuleName.STATS,', 'Sup3rStatsMulti,', 'ctx,', 'config_file,', 'verbose)'] | 912,508 |
NREL/sup3r | visual_qa_cli.py | from_config | from_config | Run the sup3r visual QA module from a config file. | [
"Run",
"the",
"sup3r",
"visual",
"QA",
"module",
"from",
"a",
"config",
"file."
] | def from_config(ctx, config_file, verbose):
BaseCLI.from_config(ModuleName.VISUAL_QA, Sup3rVisualQa, ctx, config_file, verbose) | ['def', 'from_config(ctx,', 'config_file,', 'verbose):', 'BaseCLI.from_config(ModuleName.VISUAL_QA,', 'Sup3rVisualQa,', 'ctx,', 'config_file,', 'verbose)'] | 912,516 |
NREL/sup3r | solar.py | Solar.preflight | preflight | Run preflight checks on source data to make sure everything will work together. | [
"Run",
"preflight",
"checks",
"on",
"source",
"data",
"to",
"make",
"sure",
"everything",
"will",
"work",
"together."
] | def preflight(self):
assert 'clearsky_ratio' in self.gan_data.dsets
assert 'clearsky_ghi' in self.nsrdb.dsets
assert 'clearsky_dni' in self.nsrdb.dsets
assert 'solar_zenith_angle' in self.nsrdb.dsets
assert 'surface_pressure' in self.nsrdb.dsets
assert isinstance(self.nsrdb_tslice, slice)
ti... | ['def', 'preflight(self):', 'assert', "'clearsky_ratio'", 'in', 'self.gan_data.dsets', 'assert', "'clearsky_ghi'", 'in', 'self.nsrdb.dsets', 'assert', "'clearsky_dni'", 'in', 'self.nsrdb.dsets', 'assert', "'solar_zenith_angle'", 'in', 'self.nsrdb.dsets', 'assert', "'surface_pressure'", 'in', 'self.nsrdb.dsets', 'assert... | 912,517 |
NREL/sup3r | solar.py | Solar.nsrdb_tslice | nsrdb_tslice | Get the time slice of the NSRDB data corresponding to the sup3r GAN output. | [
"Get",
"the",
"time",
"slice",
"of",
"the",
"NSRDB",
"data",
"corresponding",
"to",
"the",
"sup3r",
"GAN",
"output."
] | def nsrdb_tslice(self):
if self._nsrdb_tslice is None:
doy_nsrdb = self.nsrdb.time_index.day_of_year
doy_gan = self.time_index.day_of_year
mask = doy_nsrdb.isin(doy_gan)
if mask.sum() == 0:
msg = 'Time index intersection of the NSRDB time index and sup3r GAN output has on... | ['def', 'nsrdb_tslice(self):', 'if', 'self._nsrdb_tslice', 'is', 'None:', 'doy_nsrdb', '=', 'self.nsrdb.time_index.day_of_year', 'doy_gan', '=', 'self.time_index.day_of_year', 'mask', '=', 'doy_nsrdb.isin(doy_gan)', 'if', 'mask.sum()', '==', '0:', 'msg', '=', "'Time", 'index', 'intersection', 'of', 'the', 'NSRDB', 'tim... | 912,523 |
NREL/sup3r | era_downloader.py | EraDownloader.download_process_combine | download_process_combine | Run the download routine. | [
"Run",
"the",
"download",
"routine."
] | def download_process_combine(self):
sfc_check = len(self.sfc_file_variables) > 0
level_check = len(self.level_file_variables) > 0 and self.levels is not None
if self.level_file_variables:
msg = f'{self.level_file_variables} requested but no levels were provided.'
if self.levels is None:
... | ['def', 'download_process_combine(self):', 'sfc_check', '=', 'len(self.sfc_file_variables)', '>', '0', 'level_check', '=', 'len(self.level_file_variables)', '>', '0', 'and', 'self.levels', 'is', 'not', 'None', 'if', 'self.level_file_variables:', 'msg', '=', "f'{self.level_file_variables}", 'requested', 'but', 'no', 'le... | 912,553 |
NREL/sup3r | era_downloader.py | EraDownloader.process_level_file | process_level_file | Convert geopotential to geopotential height. | [
"Convert",
"geopotential",
"to",
"geopotential",
"height."
] | def process_level_file(self):
dims = ('time', 'level', 'latitude', 'longitude')
tmp_file = self.get_tmp_file(self.level_file)
with Dataset(self.level_file, 'r') as old_ds:
with Dataset(tmp_file, 'w') as ds:
ds = self.init_dims(old_ds, ds, dims)
ds = self.convert_z('zg', 'Geop... | ['def', 'process_level_file(self):', 'dims', '=', "('time',", "'level',", "'latitude',", "'longitude')", 'tmp_file', '=', 'self.get_tmp_file(self.level_file)', 'with', 'Dataset(self.level_file,', "'r')", 'as', 'old_ds:', 'with', 'Dataset(tmp_file,', "'w')", 'as', 'ds:', 'ds', '=', 'self.init_dims(old_ds,', 'ds,', 'dims... | 912,558 |
NREL/sup3r | execution.py | DistributedProcess.chunks | chunks | Get the number of process chunks for this distributed routine. | [
"Get",
"the",
"number",
"of",
"process",
"chunks",
"for",
"this",
"distributed",
"routine."
] | def chunks(self):
if self._n_chunks is None:
return self._max_chunks
else:
return min(self._n_chunks, self._max_chunks) | ['def', 'chunks(self):', 'if', 'self._n_chunks', 'is', 'None:', 'return', 'self._max_chunks', 'else:', 'return', 'min(self._n_chunks,', 'self._max_chunks)'] | 912,575 |
NREL/sup3r | regridder.py | Regridder.cache_exists | cache_exists | Check if cache exists before building tree. | [
"Check",
"if",
"cache",
"exists",
"before",
"building",
"tree."
] | def cache_exists(self):
cache_exists_check = self.index_file is not None and os.path.exists(self.index_file) and (self.distance_file is not None) and os.path.exists(self.distance_file)
return cache_exists_check | ['def', 'cache_exists(self):', 'cache_exists_check', '=', 'self.index_file', 'is', 'not', 'None', 'and', 'os.path.exists(self.index_file)', 'and', '(self.distance_file', 'is', 'not', 'None)', 'and', 'os.path.exists(self.distance_file)', 'return', 'cache_exists_check'] | 912,611 |
NREL/sup3r | test_data_handling_h5.py | test_no_val_data | test_no_val_data | Test that the data handler can work with zero validation data. | [
"Test",
"that",
"the",
"data",
"handler",
"can",
"work",
"with",
"zero",
"validation",
"data."
] | def test_no_val_data():
data_handlers = []
for input_file in input_files:
data_handler = DataHandler(input_file, features, val_split=0, **dh_kwargs)
data_handlers.append(data_handler)
batch_handler = BatchHandler(data_handlers, **bh_kwargs)
n = 0
for _ in batch_handler.val_data:
... | ['def', 'test_no_val_data():', 'data_handlers', '=', '[]', 'for', 'input_file', 'in', 'input_files:', 'data_handler', '=', 'DataHandler(input_file,', 'features,', 'val_split=0,', '**dh_kwargs)', 'data_handlers.append(data_handler)', 'batch_handler', '=', 'BatchHandler(data_handlers,', '**bh_kwargs)', 'n', '=', '0', 'fo... | 912,718 |
NREL/sup3r | test_data_handling_h5.py | test_solar_spatial_h5 | test_solar_spatial_h5 | Test solar spatial batch handling with NaN drop. | [
"Test",
"solar",
"spatial",
"batch",
"handling",
"with",
"NaN",
"drop."
] | def test_solar_spatial_h5():
input_file_s = os.path.join(TEST_DATA_DIR, 'test_nsrdb_co_2018.h5')
features_s = ['clearsky_ratio']
target_s = (39.01, -105.13)
dh_nan = DataHandler(input_file_s, features_s, target=target_s, shape=(20, 20), sample_shape=(10, 10, 12), mask_nan=False)
dh = DataHandler(inp... | ['def', 'test_solar_spatial_h5():', 'input_file_s', '=', 'os.path.join(TEST_DATA_DIR,', "'test_nsrdb_co_2018.h5')", 'features_s', '=', "['clearsky_ratio']", 'target_s', '=', '(39.01,', '-105.13)', 'dh_nan', '=', 'DataHandler(input_file_s,', 'features_s,', 'target=target_s,', 'shape=(20,', '20),', 'sample_shape=(10,', '... | 912,720 |
NREL/sup3r | test_data_handling_h5_cc.py | test_solar_ancillary_vars | test_solar_ancillary_vars | Test the handling of the "final" feature set from the NSRDB including windspeed components and air temperature near the surface. | [
"Test",
"the",
"handling",
"of",
"the",
"\"final\"",
"feature",
"set",
"from",
"the",
"NSRDB",
"including",
"windspeed",
"components",
"and",
"air",
"temperature",
"near",
"the",
"surface."
] | def test_solar_ancillary_vars():
features = ['clearsky_ratio', 'U', 'V', 'air_temperature', 'ghi', 'clearsky_ghi']
dh_kwargs_new = dh_kwargs.copy()
dh_kwargs_new['val_split'] = 0.001
handler = DataHandlerH5SolarCC(INPUT_FILE_S, features, **dh_kwargs_new)
assert handler.data.shape[-1] == 4
assert... | ['def', 'test_solar_ancillary_vars():', 'features', '=', "['clearsky_ratio',", "'U',", "'V',", "'air_temperature',", "'ghi',", "'clearsky_ghi']", 'dh_kwargs_new', '=', 'dh_kwargs.copy()', "dh_kwargs_new['val_split']", '=', '0.001', 'handler', '=', 'DataHandlerH5SolarCC(INPUT_FILE_S,', 'features,', '**dh_kwargs_new)', '... | 912,727 |
NREL/sup3r | test_data_handling_h5_cc.py | test_wind_batching | test_wind_batching | Test the wind climate change data batching object. | [
"Test",
"the",
"wind",
"climate",
"change",
"data",
"batching",
"object."
] | def test_wind_batching():
dh_kwargs_new = dh_kwargs.copy()
dh_kwargs_new['target'] = TARGET_W
dh_kwargs_new['sample_shape'] = (20, 20, 72)
dh_kwargs_new['val_split'] = 0
handler = DataHandlerH5WindCC(INPUT_FILE_W, FEATURES_W, **dh_kwargs_new)
batcher = BatchHandlerCC([handler], batch_size=1, n_b... | ['def', 'test_wind_batching():', 'dh_kwargs_new', '=', 'dh_kwargs.copy()', "dh_kwargs_new['target']", '=', 'TARGET_W', "dh_kwargs_new['sample_shape']", '=', '(20,', '20,', '72)', "dh_kwargs_new['val_split']", '=', '0', 'handler', '=', 'DataHandlerH5WindCC(INPUT_FILE_W,', 'FEATURES_W,', '**dh_kwargs_new)', 'batcher', '=... | 912,731 |
NREL/sup3r | test_data_handling_nc.py | test_single_site_extraction | test_single_site_extraction | Make sure single location can be extracted from ERA data without error. | [
"Make",
"sure",
"single",
"location",
"can",
"be",
"extracted",
"from",
"ERA",
"data",
"without",
"error."
] | def test_single_site_extraction():
height = 10
features = [f'windspeed_{height}m']
with tempfile.TemporaryDirectory() as td:
input_files = make_fake_era_files(td, INPUT_FILE, 8)
kwargs = dh_kwargs.copy()
kwargs['shape'] = [1, 1]
data_handler = DataHandler(input_files, feature... | ['def', 'test_single_site_extraction():', 'height', '=', '10', 'features', '=', "[f'windspeed_{height}m']", 'with', 'tempfile.TemporaryDirectory()', 'as', 'td:', 'input_files', '=', 'make_fake_era_files(td,', 'INPUT_FILE,', '8)', 'kwargs', '=', 'dh_kwargs.copy()', "kwargs['shape']", '=', '[1,', '1]', 'data_handler', '=... | 912,736 |
NREL/sup3r | test_dual_data_handling.py | test_dual_data_handler | test_dual_data_handler | Test basic spatial model training with only gen content loss. | [
"Test",
"basic",
"spatial",
"model",
"training",
"with",
"only",
"gen",
"content",
"loss."
] | def test_dual_data_handler(log=False, full_shape=(20, 20), sample_shape=(10, 10, 1), plot=True):
if log:
init_logger('sup3r', log_level='DEBUG')
hr_handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, sample_shape=sample_shape, temporal_slice=slice(None, None, 10), worker_kwa... | ['def', 'test_dual_data_handler(log=False,', 'full_shape=(20,', '20),', 'sample_shape=(10,', '10,', '1),', 'plot=True):', 'if', 'log:', "init_logger('sup3r',", "log_level='DEBUG')", 'hr_handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'shape=full_shape,', 'sample_shape=sample_shape,', 'tempo... | 912,756 |
NREL/sup3r | test_dual_data_handling.py | test_st_dual_batch_handler | test_st_dual_batch_handler | Test spatiotemporal dual batch handler. | [
"Test",
"spatiotemporal",
"dual",
"batch",
"handler."
] | def test_st_dual_batch_handler(log=False, full_shape=(20, 20), sample_shape=(10, 10, 4)):
t_enhance = 2
s_enhance = 2
if log:
init_logger('sup3r', log_level='DEBUG')
hr_handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, sample_shape=sample_shape, temporal_slice=slic... | ['def', 'test_st_dual_batch_handler(log=False,', 'full_shape=(20,', '20),', 'sample_shape=(10,', '10,', '4)):', 't_enhance', '=', '2', 's_enhance', '=', '2', 'if', 'log:', "init_logger('sup3r',", "log_level='DEBUG')", 'hr_handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'shape=full_shape,', ... | 912,759 |
NREL/sup3r | test_dual_data_handling.py | test_spatial_dual_batch_handler | test_spatial_dual_batch_handler | Test spatial dual batch handler. | [
"Test",
"spatial",
"dual",
"batch",
"handler."
] | def test_spatial_dual_batch_handler(log=False, full_shape=(20, 20), sample_shape=(10, 10, 1), plot=True):
if log:
init_logger('sup3r', log_level='DEBUG')
hr_handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, hr_spatial_coarsen=2, sample_shape=sample_shape, temporal_slice=sl... | ['def', 'test_spatial_dual_batch_handler(log=False,', 'full_shape=(20,', '20),', 'sample_shape=(10,', '10,', '1),', 'plot=True):', 'if', 'log:', "init_logger('sup3r',", "log_level='DEBUG')", 'hr_handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'shape=full_shape,', 'hr_spatial_coarsen=2,', 's... | 912,760 |
NREL/sup3r | test_forward_pass.py | test_fwp_single_ts_vs_multi_ts_input_files | test_fwp_single_ts_vs_multi_ts_input_files | Test forward pass handler output for spatial only model. | [
"Test",
"forward",
"pass",
"handler",
"output",
"for",
"spatial",
"only",
"model."
] | def test_fwp_single_ts_vs_multi_ts_input_files():
fp_gen = os.path.join(CONFIG_DIR, 'spatial/gen_2x_2f.json')
fp_disc = os.path.join(CONFIG_DIR, 'spatial/disc.json')
Sup3rGan.seed()
model = Sup3rGan(fp_gen, fp_disc, learning_rate=0.0001)
_ = model.generate(np.ones((4, 10, 10, len(FEATURES))))
mo... | ['def', 'test_fwp_single_ts_vs_multi_ts_input_files():', 'fp_gen', '=', 'os.path.join(CONFIG_DIR,', "'spatial/gen_2x_2f.json')", 'fp_disc', '=', 'os.path.join(CONFIG_DIR,', "'spatial/disc.json')", 'Sup3rGan.seed()', 'model', '=', 'Sup3rGan(fp_gen,', 'fp_disc,', 'learning_rate=0.0001)', '_', '=', 'model.generate(np.ones... | 912,775 |
NREL/sup3r | test_forward_pass.py | test_fwp_nc | test_fwp_nc | Test forward pass handler output for netcdf write. | [
"Test",
"forward",
"pass",
"handler",
"output",
"for",
"netcdf",
"write."
] | def test_fwp_nc():
fp_gen = os.path.join(CONFIG_DIR, 'spatiotemporal/gen_3x_4x_2f.json')
fp_disc = os.path.join(CONFIG_DIR, 'spatiotemporal/disc.json')
Sup3rGan.seed()
model = Sup3rGan(fp_gen, fp_disc, learning_rate=0.0001)
_ = model.generate(np.ones((4, 10, 10, 6, len(FEATURES))))
model.meta['t... | ['def', 'test_fwp_nc():', 'fp_gen', '=', 'os.path.join(CONFIG_DIR,', "'spatiotemporal/gen_3x_4x_2f.json')", 'fp_disc', '=', 'os.path.join(CONFIG_DIR,', "'spatiotemporal/disc.json')", 'Sup3rGan.seed()', 'model', '=', 'Sup3rGan(fp_gen,', 'fp_disc,', 'learning_rate=0.0001)', '_', '=', 'model.generate(np.ones((4,', '10,', ... | 912,777 |
NREL/sup3r | test_forward_pass_exo.py | test_fwp_single_step_wind_hi_res_topo | test_fwp_single_step_wind_hi_res_topo | Test the forward pass with a single spatiotemporal Sup3rGan model requiring high-resolution topography input from the exogenous_data feature. | [
"Test",
"the",
"forward",
"pass",
"with",
"a",
"single",
"spatiotemporal",
"Sup3rGan",
"model",
"requiring",
"high-resolution",
"topography",
"input",
"from",
"the",
"exogenous_data",
"feature."
] | def test_fwp_single_step_wind_hi_res_topo(plot=False):
Sup3rGan.seed()
gen_model = [{'class': 'FlexiblePadding', 'paddings': [[0, 0], [3, 3], [3, 3], [3, 3], [0, 0]], 'mode': 'REFLECT'}, {'class': 'Conv3D', 'filters': 64, 'kernel_size': 3, 'strides': 1}, {'class': 'Cropping3D', 'cropping': 2}, {'class': 'Spatio... | ['def', 'test_fwp_single_step_wind_hi_res_topo(plot=False):', 'Sup3rGan.seed()', 'gen_model', '=', "[{'class':", "'FlexiblePadding',", "'paddings':", '[[0,', '0],', '[3,', '3],', '[3,', '3],', '[3,', '3],', '[0,', '0]],', "'mode':", "'REFLECT'},", "{'class':", "'Conv3D',", "'filters':", '64,', "'kernel_size':", '3,', "... | 912,788 |
NREL/sup3r | test_forward_pass_exo.py | test_fwp_wind_hi_res_topo_plus_linear | test_fwp_wind_hi_res_topo_plus_linear | Test the forward pass with a Sup3rGan model requiring high-res topo input from exo data for spatial enhancement and a linear interpolation model for temporal enhancement. | [
"Test",
"the",
"forward",
"pass",
"with",
"a",
"Sup3rGan",
"model",
"requiring",
"high-res",
"topo",
"input",
"from",
"exo",
"data",
"for",
"spatial",
"enhancement",
"and",
"a",
"linear",
"interpolation",
"model",
"for",
"temporal",
"enhancement."
] | def test_fwp_wind_hi_res_topo_plus_linear():
Sup3rGan.seed()
gen_model = [{'class': 'FlexiblePadding', 'paddings': [[0, 0], [3, 3], [3, 3], [0, 0]], 'mode': 'REFLECT'}, {'class': 'Conv2DTranspose', 'filters': 64, 'kernel_size': 3, 'strides': 1}, {'class': 'Cropping2D', 'cropping': 4}, {'class': 'FlexiblePadding... | ['def', 'test_fwp_wind_hi_res_topo_plus_linear():', 'Sup3rGan.seed()', 'gen_model', '=', "[{'class':", "'FlexiblePadding',", "'paddings':", '[[0,', '0],', '[3,', '3],', '[3,', '3],', '[0,', '0]],', "'mode':", "'REFLECT'},", "{'class':", "'Conv2DTranspose',", "'filters':", '64,', "'kernel_size':", '3,', "'strides':", '1... | 912,790 |
NREL/sup3r | test_out_conditional_moments.py | test_out_s_mom2 | test_out_s_mom2 | Test basic spatial model outputing. | [
"Test",
"basic",
"spatial",
"model",
"outputing."
] | def test_out_s_mom2(FEATURES, TRAIN_FEATURES, plot=False, full_shape=(20, 20), sample_shape=(10, 10, 1), batch_size=4, n_batches=4, s_enhance=2, model_dir=None, model_mom1_dir=None):
handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, train_only_features=TRAIN_FEATURES, shape=full_shape, sample_shape=sam... | ['def', 'test_out_s_mom2(FEATURES,', 'TRAIN_FEATURES,', 'plot=False,', 'full_shape=(20,', '20),', 'sample_shape=(10,', '10,', '1),', 'batch_size=4,', 'n_batches=4,', 's_enhance=2,', 'model_dir=None,', 'model_mom1_dir=None):', 'handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'train_only_feat... | 912,803 |
NREL/sup3r | test_out_conditional_moments.py | test_out_st_mom1 | test_out_st_mom1 | Test basic spatiotemporal model outputing for first conditional moment. | [
"Test",
"basic",
"spatiotemporal",
"model",
"outputing",
"for",
"first",
"conditional",
"moment."
] | def test_out_st_mom1(plot=False, full_shape=(20, 20), sample_shape=(12, 12, 24), batch_size=4, n_batches=4, s_enhance=3, t_enhance=4, end_t_padding=False, model_dir=None):
handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, sample_shape=sample_shape, temporal_slice=slice(None, None, 1),... | ['def', 'test_out_st_mom1(plot=False,', 'full_shape=(20,', '20),', 'sample_shape=(12,', '12,', '24),', 'batch_size=4,', 'n_batches=4,', 's_enhance=3,', 't_enhance=4,', 'end_t_padding=False,', 'model_dir=None):', 'handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'shape=full_shape,', 'sample_s... | 912,808 |
NREL/sup3r | test_out_conditional_moments.py | test_out_st_mom2 | test_out_st_mom2 | Test basic spatiotemporal model outputing for second conditional moment. | [
"Test",
"basic",
"spatiotemporal",
"model",
"outputing",
"for",
"second",
"conditional",
"moment."
] | def test_out_st_mom2(plot=False, full_shape=(20, 20), sample_shape=(12, 12, 24), batch_size=4, n_batches=4, s_enhance=3, t_enhance=4, end_t_padding=False, model_dir=None, model_mom1_dir=None):
handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, sample_shape=sample_shape, temporal_slice=... | ['def', 'test_out_st_mom2(plot=False,', 'full_shape=(20,', '20),', 'sample_shape=(12,', '12,', '24),', 'batch_size=4,', 'n_batches=4,', 's_enhance=3,', 't_enhance=4,', 'end_t_padding=False,', 'model_dir=None,', 'model_mom1_dir=None):', 'handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,', 'target=TARGET_COORD,', 'shape... | 912,810 |
NREL/sup3r | test_out_conditional_moments.py | test_out_st_mom2_sf | test_out_st_mom2_sf | Test basic spatiotemporal model outputing for second conditional moment of subfilter velocity. | [
"Test",
"basic",
"spatiotemporal",
"model",
"outputing",
"for",
"second",
"conditional",
"moment",
"of",
"subfilter",
"velocity."
] | def test_out_st_mom2_sf(plot=False, full_shape=(20, 20), sample_shape=(12, 12, 24), batch_size=4, n_batches=4, s_enhance=3, t_enhance=4, end_t_padding=False, t_enhance_mode='constant', model_dir=None, model_mom1_dir=None):
handler = DataHandlerH5(FP_WTK, FEATURES, target=TARGET_COORD, shape=full_shape, sample_shape... | ['def', 'test_out_st_mom2_sf(plot=False,', 'full_shape=(20,', '20),', 'sample_shape=(12,', '12,', '24),', 'batch_size=4,', 'n_batches=4,', 's_enhance=3,', 't_enhance=4,', 'end_t_padding=False,', "t_enhance_mode='constant',", 'model_dir=None,', 'model_mom1_dir=None):', 'handler', '=', 'DataHandlerH5(FP_WTK,', 'FEATURES,... | 912,811 |
NREL/sup3r | test_solar_module.py | test_chunk_file_parser | test_chunk_file_parser | Test the solar utility that retrieves the fwp chunked output file sets to be run. | [
"Test",
"the",
"solar",
"utility",
"that",
"retrieves",
"the",
"fwp",
"chunked",
"output",
"file",
"sets",
"to",
"be",
"run."
] | def test_chunk_file_parser():
id_temporal = [str(i).zfill(6) for i in range(4, 7)]
id_spatial = [str(i).zfill(6) for i in range(6, 10)]
all_st_ids = []
all_fps = []
with tempfile.TemporaryDirectory() as td:
for idt in id_temporal:
for ids in id_spatial:
fn = 'sup3... | ['def', 'test_chunk_file_parser():', 'id_temporal', '=', '[str(i).zfill(6)', 'for', 'i', 'in', 'range(4,', '7)]', 'id_spatial', '=', '[str(i).zfill(6)', 'for', 'i', 'in', 'range(6,', '10)]', 'all_st_ids', '=', '[]', 'all_fps', '=', '[]', 'with', 'tempfile.TemporaryDirectory()', 'as', 'td:', 'for', 'idt', 'in', 'id_temp... | 912,816 |
NREL/sup3r | test_surface_model.py | get_inputs | get_inputs | Get various inputs for the surface model. | [
"Get",
"various",
"inputs",
"for",
"the",
"surface",
"model."
] | def get_inputs(s_enhance):
with Resource(INPUT_FILE_W) as res:
ti = res.time_index
meta = res.meta
temp = res[FEATURES[0]]
rh = res[FEATURES[1]]
pres = res[FEATURES[2]]
shape = (len(ti), 100, 100)
temp = np.expand_dims(temp.reshape(shape), -1)
rh = np.expand_dims(... | ['def', 'get_inputs(s_enhance):', 'with', 'Resource(INPUT_FILE_W)', 'as', 'res:', 'ti', '=', 'res.time_index', 'meta', '=', 'res.meta', 'temp', '=', 'res[FEATURES[0]]', 'rh', '=', 'res[FEATURES[1]]', 'pres', '=', 'res[FEATURES[2]]', 'shape', '=', '(len(ti),', '100,', '100)', 'temp', '=', 'np.expand_dims(temp.reshape(sh... | 912,818 |
NREL/sup3r | test_surface_model.py | test_train_rh_model | test_train_rh_model | Test the train method of the RH linear regression model. | [
"Test",
"the",
"train",
"method",
"of",
"the",
"RH",
"linear",
"regression",
"model."
] | def test_train_rh_model(s_enhance=10):
(_, true_hi_res, _, topo_hr) = get_inputs(s_enhance)
true_hr_temp = np.transpose(true_hi_res[..., 0], axes=(1, 2, 0))
true_hr_rh = np.transpose(true_hi_res[..., 1], axes=(1, 2, 0))
model = SurfaceSpatialMetModel(FEATURES, s_enhance=s_enhance)
(w_delta_temp, w_d... | ['def', 'test_train_rh_model(s_enhance=10):', '(_,', 'true_hi_res,', '_,', 'topo_hr)', '=', 'get_inputs(s_enhance)', 'true_hr_temp', '=', 'np.transpose(true_hi_res[...,', '0],', 'axes=(1,', '2,', '0))', 'true_hr_rh', '=', 'np.transpose(true_hi_res[...,', '1],', 'axes=(1,', '2,', '0))', 'model', '=', 'SurfaceSpatialMetM... | 912,820 |
NREL/sup3r | test_surface_model.py | test_multi_step_surface | test_multi_step_surface | Test the multi step surface met model. | [
"Test",
"the",
"multi",
"step",
"surface",
"met",
"model."
] | def test_multi_step_surface(s_enhance=2, t_enhance=2):
config_gen = [{'class': 'FlexiblePadding', 'paddings': [[0, 0], [3, 3], [3, 3], [3, 3], [0, 0]], 'mode': 'REFLECT'}, {'class': 'Conv3D', 'filters': 64, 'kernel_size': 3, 'strides': 1}, {'class': 'Cropping3D', 'cropping': 2}, {'alpha': 0.2, 'class': 'LeakyReLU'}... | ['def', 'test_multi_step_surface(s_enhance=2,', 't_enhance=2):', 'config_gen', '=', "[{'class':", "'FlexiblePadding',", "'paddings':", '[[0,', '0],', '[3,', '3],', '[3,', '3],', '[3,', '3],', '[0,', '0]],', "'mode':", "'REFLECT'},", "{'class':", "'Conv3D',", "'filters':", '64,', "'kernel_size':", '3,', "'strides':", '1... | 912,821 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.