repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
iharm3d | iharm3d-master/script/analysis/luminosity_study.py | ################################################################################
# #
# LUMINOSITY COMPARISON #
# ... | 4,229 | 36.433628 | 123 | py |
iharm3d | iharm3d-master/script/analysis/util.py | ################################################################################
# #
# UTILITY FUNCTIONS #
# ... | 4,311 | 30.474453 | 114 | py |
iharm3d | iharm3d-master/script/analysis/quickplot_thphi.py | ################################################################################
# #
# PLOT ONE PRIMITIVE #
# ... | 3,047 | 31.774194 | 115 | py |
iharm3d | iharm3d-master/script/analysis/eht_unify.py | #!/usr/bin/env python3
import os, sys
import pickle
import numpy as np
import hdf5_to_dict as io
avgs = []
for fname in sys.argv[1:-1]:
print("Loading {}".format(fname))
avgs.append(pickle.load(open(fname, "rb")))
avgs[-1]['fname'] = fname
#for avg in avgs:
# print("Name: {}, contents: {}".format(avg['fname'... | 1,937 | 31.3 | 127 | py |
iharm3d | iharm3d-master/script/analysis/coordinates.py |
import numpy as np
from defs import Met
def coord_to_KS(X, mtype):
pass
def vec_to_KS(vec, X, mtype):
"""Translate a vector from """
return np.einsum("i...,ij...", vec, dxdX_KS_to(X, mtype))
def dxdX_to_KS(X, mtype, met_params, koral_rad=False):
"""Get transformation matrix to Kerr-Schild from severa... | 4,284 | 50.626506 | 166 | py |
iharm3d | iharm3d-master/script/analysis/plot.py | ################################################################################
# #
# UTILITIES FOR PLOTTING #
# ... | 12,865 | 31.004975 | 114 | py |
iharm3d | iharm3d-master/script/analysis/initial_cuts.py | ## Initial conditions cuts
from __future__ import print_function, division
import hdf5_to_dict as io
import sys
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from pylab import *
COMPARE = False
dump_dir = sys.argv[1]
init_file = io.get_dumps_list(dump_dir)[0]
hdr, geom,... | 2,156 | 21.705263 | 112 | py |
iharm3d | iharm3d-master/script/analysis/hdf5_to_dict.py | ################################################################################
# #
# READ HARM OUTPUT #
# ... | 11,123 | 32.709091 | 105 | py |
iharm3d | iharm3d-master/script/analysis/eht_image_analysis.py | ################################################################################
# #
# CALCULATE TIME-AVERAGED QUANTITIES FROM IPOLE IMAGES #
# ... | 5,965 | 29.131313 | 132 | py |
iharm3d | iharm3d-master/script/analysis/plot_init.py | ################################################################################
# #
# GENERATE PLOT OF INITIAL CONDITIONS #
# ... | 2,954 | 28.257426 | 108 | py |
iharm3d | iharm3d-master/script/analysis/simple/basic_analysis.py | ######################################################################
#
# Simple analysis and plotting script to process problem output
# Plots mhdmodes, bondi and torus problem (2D and 3D)
#
######################################################################
import numpy as np
import matplotlib
matplotlib.use('A... | 19,206 | 39.521097 | 193 | py |
iharm3d | iharm3d-master/script/analysis/misc/find-dt.py | #!/usr/bin/env python
from hdf5_to_dict import load_geom, load_hdr
import sys
import math
import numpy as np
hdr = load_hdr(sys.argv[1])
geom = load_geom(sys.argv[2])
nnodes = int(sys.argv[3])
tf = float(sys.argv[4])
SMALL = 1e-20
dt_light_min = 1./SMALL;
N1, N2, N3 = hdr['n1'], hdr['n2'], hdr['n3']
dx = [ 0, hdr... | 1,852 | 26.656716 | 61 | py |
iharm3d | iharm3d-master/script/analysis/misc/ana_from_log.py | # Pass along HARM's own diagnostics for comparison
# TODO implement
#diag = io.load_log(path)
#out_full['t_d'] = diag['t']
#out_full['Mdot_d'] = diag['mdot']
#out_full['Phi_d'] = diag['Phi']
#out_full['Ldot_d'] = diag['ldot']
#out_full['Edot_d'] = diag['edot']
#out_full['Lum_d'] = diag['lum_eht']
#out_full['divbmax_... | 341 | 25.307692 | 50 | py |
CTDL | CTDL-master/RunGridWorld.py | from GridWorld.Functions.RandomSeedSweep import RunRandomSeedSweep
from GridWorld.Functions.MazeTypeSweep import RunMazeTypeSweep
from GridWorld.Functions.RevaluationSweep import RunRevaluationSweep
RunRandomSeedSweep() | 220 | 43.2 | 68 | py |
CTDL | CTDL-master/RunGym.py | from Gym.Functions.RunTask import RunTask
RunTask()
| 54 | 10 | 41 | py |
CTDL | CTDL-master/Utilities.py | import os
import numpy as np
import shutil
def RecordSettings(directory, maze_params, agent_params):
file = open(directory + 'Settings.txt', 'w')
for key, value in maze_params.items():
file.write(key + ': ' + str(value) + '\n')
for key, value in agent_params.items():
file.write(key + ': '... | 538 | 23.5 | 57 | py |
CTDL | CTDL-master/Gym/Parameters.py | from Gym.Enums.Enums import EnvType, AgentType
env_params = {'env': EnvType.MountainCarContinuous,
'num_trials': 200,
'max_steps': 1000,
'num_repeats': 50
}
agent_params = {'agent_type': AgentType.CTDL_A2C,
'bSOM': True,
'SOM_alph... | 575 | 29.315789 | 51 | py |
CTDL | CTDL-master/Gym/AnalyseResults.py | from Gym.Functions.Parsers import ParseIntoDataframes
from Gym.Functions.Plotters import PlotComparisons
dir = 'ContinuousMountainCar'
to_compare = ['CTDL_A2C', 'A2C']
data_frames, labels = ParseIntoDataframes(dir, to_compare)
PlotComparisons(data_frames, labels)
| 267 | 25.8 | 58 | py |
CTDL | CTDL-master/Gym/Agents/A2C/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
import sklearn.preprocessing
from Gym.Agents.A2C.ACGraph import ACGraph
class Agent(object):
def __init__(self, directory, env_params, agent_params):
self.directory = directory
self.action_maxs = env_params['action_maxs']
... | 3,046 | 26.7 | 99 | py |
CTDL | CTDL-master/Gym/Agents/A2C/ACGraph.py | import os
import tensorflow as tf
import numpy as np
class ACGraph(object):
def __init__(self, input_dim, action_mins, action_maxs, directory):
self.ti = 0
self.input_dim = input_dim
self.action_mins = action_mins
self.action_maxs = action_maxs
self.action_dim = action_mins... | 4,390 | 40.819048 | 165 | py |
CTDL | CTDL-master/Gym/Agents/DQN/Minibatch.py |
class MiniBatch(object):
def __init__(self):
self.prev_states = []
self.actions = []
self.rewards = []
self.states = []
self.bTrial_over = [] | 187 | 19.888889 | 29 | py |
CTDL | CTDL-master/Gym/Agents/DQN/Memory.py | import numpy as np
from Gym.Agents.DQN.Minibatch import MiniBatch
class Memory(object):
def __init__(self):
self.capacity = 100000
self.prev_states = []
self.states = []
self.actions = []
self.rewards = []
self.bTrial_over = []
return
def RecordExpe... | 1,704 | 26.063492 | 89 | py |
CTDL | CTDL-master/Gym/Agents/DQN/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
from Gym.Agents.DQN.Memory import Memory
from Gym.Agents.DQN.QTargetGraph import QTargetGraph
from Gym.Agents.DQN.QGraph import QGraph
class Agent(object):
def __init__(self, directory, env_params, agent_params):
self.directory = director... | 3,692 | 27.627907 | 120 | py |
CTDL | CTDL-master/Gym/Agents/DQN/QTargetGraph.py | import tensorflow as tf
import numpy as np
class QTargetGraph(object):
def __init__(self, directory):
tf.reset_default_graph()
self.graph = tf.Graph()
with self.graph.as_default():
saver = tf.train.import_meta_graph(directory + ".meta")
self.logits = tf.get_collec... | 563 | 15.588235 | 67 | py |
CTDL | CTDL-master/Gym/Agents/DQN/QGraph.py | import os
import tensorflow as tf
import numpy as np
class QGraph(object):
def __init__(self, input_dim, num_actions, directory):
self.ti = 0
self.input_dim = input_dim
self.num_actions = num_actions
self.directory = directory
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
... | 3,036 | 33.123596 | 138 | py |
CTDL | CTDL-master/Gym/Agents/CTDL_A2C/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
import sklearn.preprocessing
from Gym.Agents.A2C.ACGraph import ACGraph
from Gym.Agents.CTDL_A2C.SOM import DeepSOM
class Agent(object):
def __init__(self, directory, env_params, agent_params):
self.bSOM = agent_params['bSOM']
sel... | 5,266 | 28.757062 | 99 | py |
CTDL | CTDL-master/Gym/Agents/CTDL_A2C/SOM.py |
from Gym.Agents.CTDL.SOMLayer import SOMLayer
class DeepSOM(object):
def __init__(self, directory, input_dim, map_size, learning_rate, sigma, sigma_const):
self.directory = directory
self.SOM_layer = SOMLayer(input_dim, map_size, learning_rate, sigma, sigma_const)
return
def Updat... | 553 | 22.083333 | 90 | py |
CTDL | CTDL-master/Gym/Agents/CTDL_A2C/ACGraph.py | import os
import tensorflow as tf
import numpy as np
class ACGraph(object):
def __init__(self, input_dim, action_mins, action_maxs, directory):
self.ti = 0
self.input_dim = input_dim
self.action_mins = action_mins
self.action_maxs = action_maxs
self.action_dim = action_mins... | 4,408 | 40.990476 | 165 | py |
CTDL | CTDL-master/Gym/Agents/CTDL_A2C/SOMLayer.py | import numpy as np
class SOMLayer():
def __init__(self, input_dim, size, learning_rate, sigma, sigma_const):
self.size = size
self.num_units = size * size
self.num_weights = input_dim
self.learning_rate = learning_rate
self.sigma = sigma
self.sigma_const = sigma_c... | 1,562 | 26.421053 | 128 | py |
CTDL | CTDL-master/Gym/Agents/CTDL/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
from Gym.Agents.CTDL.QGraph import QGraph
from Gym.Agents.CTDL.SOM import DeepSOM
from Gym.Agents.CTDL.QTargetGraph import QTargetGraph
class Agent(object):
def __init__(self, directory, env_params, agent_params):
self.bSOM = agent_params[... | 6,788 | 29.039823 | 134 | py |
CTDL | CTDL-master/Gym/Agents/CTDL/SOM.py |
from Gym.Agents.CTDL.SOMLayer import SOMLayer
class DeepSOM(object):
def __init__(self, directory, input_dim, map_size, learning_rate, sigma, sigma_const):
self.directory = directory
self.SOM_layer = SOMLayer(input_dim, map_size, learning_rate, sigma, sigma_const)
return
def Updat... | 553 | 22.083333 | 90 | py |
CTDL | CTDL-master/Gym/Agents/CTDL/QTargetGraph.py | import tensorflow as tf
import numpy as np
class QTargetGraph(object):
def __init__(self, directory):
tf.reset_default_graph()
self.graph = tf.Graph()
with self.graph.as_default():
saver = tf.train.import_meta_graph(directory + ".meta")
self.logits = tf.get_collec... | 563 | 15.588235 | 67 | py |
CTDL | CTDL-master/Gym/Agents/CTDL/QGraph.py | import os
import tensorflow as tf
import numpy as np
class QGraph(object):
def __init__(self, input_dim, num_actions, directory):
self.ti = 0
self.num_actions = num_actions
self.directory = directory
self.input_dim = input_dim
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
... | 3,005 | 33.159091 | 138 | py |
CTDL | CTDL-master/Gym/Agents/CTDL/SOMLayer.py | import numpy as np
class SOMLayer():
def __init__(self, input_dim, size, learning_rate, sigma, sigma_const):
self.size = size
self.num_units = size * size
self.num_weights = input_dim
self.learning_rate = learning_rate
self.sigma = sigma
self.sigma_const = sigma_c... | 1,561 | 26.403509 | 128 | py |
CTDL | CTDL-master/Gym/Enums/Enums.py | from enum import Enum
class EnvType(Enum):
CartPole = 0
MountainCarContinuous = 1
class AgentType(Enum):
DQN = 0
CTDL = 1
A2C = 2
CTDL_A2C = 3 | 170 | 12.153846 | 29 | py |
CTDL | CTDL-master/Gym/Functions/RunTask.py | from Gym.Parameters import env_params, agent_params
from Gym.Functions.Run import Run
def RunTask():
for i in range(env_params['num_repeats']):
Run(env_params, agent_params)
return
| 200 | 19.1 | 51 | py |
CTDL | CTDL-master/Gym/Functions/Run.py | import os
import gym
from datetime import datetime
from Utilities import RecordSettings
from Gym.Enums.Enums import EnvType, AgentType
def Run(env_params, agent_params):
results_dir = CreateResultsDirectory()
# Setup envrionment
if (env_params['env'] == EnvType.CartPole):
env = gym.make('CartPo... | 2,734 | 27.489583 | 84 | py |
CTDL | CTDL-master/Gym/Functions/Plotters.py | import numpy as np
import matplotlib.pyplot as plt
def PlotComparisons(data_frames, labels):
fig, axes = plt.subplots(1, 2, figsize=(6, 3))
axes[0].set_xlabel('Episode')
axes[0].set_ylabel('Episode Reward')
axes[1].set_xlabel('Episode')
axes[1].set_ylabel('Cumulative Episode Reward')
axes[1... | 1,654 | 29.648148 | 77 | py |
CTDL | CTDL-master/Gym/Functions/Parsers.py | import os
import pickle
import numpy as np
import pandas as pd
def ParseIntoDataframes(dir, to_compare):
folders = os.listdir('Results/' + dir)
data_frames = []
labels = []
sorted_folders = [[] for i in range(to_compare.__len__())]
for folder in folders:
if (folder == '.DS_Store' or folder... | 2,256 | 28.697368 | 91 | py |
CTDL | CTDL-master/GridWorld/Parameters.py | from GridWorld.Enums.Enums import MazeType, AgentType
maze_params = {'type': MazeType.random,
'width': 10,
'height': 10,
'num_rewards': 1,
'num_trials': 1000,
'random_seed': 0,
'max_steps': 1000,
'num_repeats': 30... | 694 | 27.958333 | 53 | py |
CTDL | CTDL-master/GridWorld/AnalyseMazeTypeSweep.py | from GridWorld.Functions.Parsers import ParseIntoDataframes
from GridWorld.Functions.Plotters import PlotComparisons, PlotMeanSOMLocations
dir = 'MazeTypeSweep'
to_compare = ['CTDL', 'DQN']
data_frames, labels = ParseIntoDataframes(dir, to_compare)
PlotComparisons('type', data_frames, labels)
PlotMeanSOMLocations('R... | 360 | 26.769231 | 78 | py |
CTDL | CTDL-master/GridWorld/AnalyseRevaluationSweep.py | from GridWorld.Functions.Parsers import ParseIntoDataframes
from GridWorld.Functions.Plotters import PlotRevaluationComparisons, PlotMeanSOMLocations
dir = 'RevaluationSweep'
to_compare = ['CTDL', 'DQN']
data_frames, labels = ParseIntoDataframes(dir, to_compare)
PlotRevaluationComparisons(data_frames, labels)
PlotMe... | 377 | 28.076923 | 89 | py |
CTDL | CTDL-master/GridWorld/AnalyseRandomSeedSweep.py | from GridWorld.Functions.Parsers import ParseIntoDataframes
from GridWorld.Functions.Plotters import PlotComparisons, PlotPairwiseComparison
dir = 'RandomSeedSweep'
to_compare = ['CTDL', 'DQN']
data_frames, labels = ParseIntoDataframes(dir, to_compare)
PlotComparisons('random_seed', data_frames, labels)
PlotPairwise... | 371 | 32.818182 | 80 | py |
CTDL | CTDL-master/GridWorld/Agents/DQN/Minibatch.py |
class MiniBatch(object):
def __init__(self):
self.prev_states = []
self.actions = []
self.rewards = []
self.states = []
self.bTrial_over = [] | 187 | 19.888889 | 29 | py |
CTDL | CTDL-master/GridWorld/Agents/DQN/Memory.py | import numpy as np
from GridWorld.Agents.DQN.Minibatch import MiniBatch
class Memory(object):
def __init__(self):
self.capacity = 100000
self.prev_states = []
self.states = []
self.actions = []
self.rewards = []
self.bTrial_over = []
return
def Reco... | 1,706 | 26.095238 | 89 | py |
CTDL | CTDL-master/GridWorld/Agents/DQN/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
from GridWorld.Agents.DQN.Memory import Memory
from GridWorld.Agents.DQN.QTargetGraph import QTargetGraph
from GridWorld.Agents.DQN.QGraph import QGraph
class Agent(object):
def __init__(self, directory, maze_params, agent_params):
self.d... | 6,066 | 29.796954 | 120 | py |
CTDL | CTDL-master/GridWorld/Agents/DQN/QTargetGraph.py | import tensorflow as tf
import numpy as np
class QTargetGraph(object):
def __init__(self, directory, maze_size):
self.maze_size = maze_size
tf.reset_default_graph()
self.graph = tf.Graph()
with self.graph.as_default():
saver = tf.train.import_meta_graph(directory + ".... | 626 | 16.914286 | 81 | py |
CTDL | CTDL-master/GridWorld/Agents/DQN/QGraph.py | import os
import tensorflow as tf
import numpy as np
class QGraph(object):
def __init__(self, num_actions, directory, maze_size):
self.ti = 0
self.num_actions = num_actions
self.directory = directory
self.maze_size = maze_size
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
... | 3,057 | 33.359551 | 138 | py |
CTDL | CTDL-master/GridWorld/Agents/CTDL/Agent.py | import matplotlib.pyplot as plt
import numpy as np
import pickle
from GridWorld.Agents.CTDL.QGraph import QGraph
from GridWorld.Agents.CTDL.SOM import SOM
from GridWorld.Agents.CTDL.QTargetGraph import QTargetGraph
class Agent(object):
def __init__(self, directory, maze_params, agent_params):
self.bSOM ... | 9,074 | 30.078767 | 134 | py |
CTDL | CTDL-master/GridWorld/Agents/CTDL/SOM.py | import numpy as np
import matplotlib.pyplot as plt
from GridWorld.Agents.CTDL.SOMLayer import SOMLayer
class SOM(object):
def __init__(self, directory, maze_width, maze_height, input_dim, map_size, learning_rate, sigma, sigma_const):
self.directory = directory
self.maze_width = maze_width
... | 2,484 | 28.939759 | 125 | py |
CTDL | CTDL-master/GridWorld/Agents/CTDL/QTargetGraph.py | import tensorflow as tf
class QTargetGraph(object):
def __init__(self, directory, maze_size):
self.maze_size = maze_size
tf.reset_default_graph()
self.graph = tf.Graph()
with self.graph.as_default():
saver = tf.train.import_meta_graph(directory + ".meta")
... | 607 | 16.882353 | 81 | py |
CTDL | CTDL-master/GridWorld/Agents/CTDL/QGraph.py | import os
import tensorflow as tf
import numpy as np
class QGraph(object):
def __init__(self, num_actions, directory, maze_size):
self.ti = 0
self.num_actions = num_actions
self.directory = directory
self.maze_size = maze_size
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
... | 2,986 | 33.333333 | 138 | py |
CTDL | CTDL-master/GridWorld/Agents/CTDL/SOMLayer.py | import numpy as np
class SOMLayer():
def __init__(self, maze_dim, input_dim, size, learning_rate, sigma, sigma_const):
self.size = size
self.num_units = size * size
self.num_dims = input_dim
self.num_weights = input_dim
self.learning_rate = learning_rate
self.sigm... | 1,615 | 26.862069 | 100 | py |
CTDL | CTDL-master/GridWorld/Enums/Enums.py | from enum import Enum
class MazeType(Enum):
random = 1
direct = 2
obstacle1 = 3
obstacle2 = 4
class AgentType(Enum):
CTDL = 1
DQN = 2
| 160 | 12.416667 | 22 | py |
CTDL | CTDL-master/GridWorld/Classes/Maze.py | import numpy as np
import matplotlib.pyplot as plt
from GridWorld.Enums.Enums import MazeType
class Maze(object):
def __init__(self, directory, maze_params):
np.random.seed(maze_params['random_seed'])
self.type = maze_params['type']
self.width = maze_params['width']
self.height... | 3,846 | 25.902098 | 109 | py |
CTDL | CTDL-master/GridWorld/Functions/MazeTypeSweep.py | from GridWorld.Parameters import maze_params, agent_params
from GridWorld.Functions.Run import Run
from GridWorld.Classes.Maze import MazeType
def RunMazeTypeSweep():
maze_types = [MazeType.direct, MazeType.obstacle1, MazeType.obstacle2]
for i in range(maze_params['num_repeats']):
for maze_type in ma... | 429 | 27.666667 | 74 | py |
CTDL | CTDL-master/GridWorld/Functions/RevaluationSweep.py | from GridWorld.Parameters import maze_params, agent_params
from GridWorld.Functions.Run import RunSequentially, AgentType
from GridWorld.Classes.Maze import MazeType
def RunRevaluationSweep():
maze_types = [MazeType.direct, MazeType.obstacle1]
for i in range(maze_params['num_repeats']):
RunSequential... | 374 | 27.846154 | 62 | py |
CTDL | CTDL-master/GridWorld/Functions/Run.py | import os
from datetime import datetime
from Utilities import RecordSettings
from GridWorld.Classes.Maze import Maze
from GridWorld.Enums.Enums import AgentType
def Run(maze_params, agent_params):
results_dir = CreateResultsDirectory()
maze_params['num_hazards'] = int((maze_params['width'] * maze_params['hei... | 2,789 | 28.0625 | 88 | py |
CTDL | CTDL-master/GridWorld/Functions/Plotters.py | import numpy as np
import matplotlib.pyplot as plt
def PlotComparisons(var, data_frames, labels):
vals = np.array([])
for df in data_frames:
vals = np.concatenate([vals, df[var].values])
vals = np.unique(vals)
num_plots = vals.shape[0]
figs = []
axes = []
for i in range(num_plot... | 10,187 | 31.037736 | 113 | py |
CTDL | CTDL-master/GridWorld/Functions/RandomSeedSweep.py | import numpy as np
from GridWorld.Parameters import maze_params, agent_params
from GridWorld.Functions.Run import Run
def RunRandomSeedSweep():
random_seeds = np.arange(0, 50).tolist()
for i in range(maze_params['num_repeats']):
for random_seed in random_seeds:
maze_params['random_seed']... | 390 | 23.4375 | 58 | py |
CTDL | CTDL-master/GridWorld/Functions/Parsers.py | import os
import pickle
import numpy as np
import pandas as pd
def ParseIntoDataframes(dir, to_compare):
folders = os.listdir('Results/' + dir)
data_frames = []
labels = []
sorted_folders = [[] for i in range(to_compare.__len__())]
for folder in folders:
if (folder == '.DS_Store' or folde... | 2,346 | 29.089744 | 95 | py |
doc2vec | doc2vec-master/infer_test.py | #python example to infer document vectors from trained doc2vec model
import gensim.models as g
import codecs
#parameters
model="toy_data/model.bin"
test_docs="toy_data/test_docs.txt"
output_file="toy_data/test_vectors.txt"
#inference hyper-parameters
start_alpha=0.01
infer_epoch=1000
#load model
m = g.Doc2Vec.load(m... | 632 | 25.375 | 110 | py |
doc2vec | doc2vec-master/train_model.py | #python example to train doc2vec model (with or without pre-trained word embeddings)
import gensim.models as g
import logging
#doc2vec parameters
vector_size = 300
window_size = 15
min_count = 1
sampling_threshold = 1e-5
negative_size = 5
train_epoch = 100
dm = 0 #0 = dbow; 1 = dmpv
worker_count = 1 #number of parall... | 1,031 | 29.352941 | 244 | py |
rancher | rancher-master/tests/integration/setup.py | from distutils.core import setup
setup(
name='IntegrationTests',
version='0.1',
packages=[
'suite',
],
license='ASL 2.0',
long_description=open('README.txt').read(),
)
| 201 | 15.833333 | 47 | py |
rancher | rancher-master/tests/integration/suite/test_node.py | import os
import tempfile
import pytest
from rancher import ApiError
from kubernetes.client import CoreV1Api
from .common import auth_check, random_str, string_to_encoding
from .conftest import wait_for, wait_for_condition
import time
def test_node_fields(admin_mc):
cclient = admin_mc.client
fields = {
... | 15,616 | 33.550885 | 81 | py |
rancher | rancher-master/tests/integration/suite/test_logging.py | import pytest
from rancher import ApiError
from .common import random_str
def test_logging_test_action(admin_mc, admin_pc, user_mc, remove_resource):
"""Tests that a user with read-only access is not
able to perform a logging test.
"""
prtb = admin_mc.client.create_project_role_template_binding(
... | 858 | 32.038462 | 75 | py |
rancher | rancher-master/tests/integration/suite/test_password_store.py | from kubernetes.client import CustomObjectsApi
from kubernetes.client import CoreV1Api
from kubernetes.client.rest import ApiException
from .common import random_str
import base64
group = 'management.cattle.io'
version = 'v3'
namespace = 'local'
plural = 'clusterloggings'
clusterId = "local"
globalNS = "cattle-global-... | 8,759 | 33.085603 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_istio.py | import os
import pytest
import subprocess
from .common import random_str
from .conftest import cluster_and_client, ClusterContext
kube_fname = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"k8s_kube_config")
istio_crd_url = "https://raw.githubusercontent.com/istio/istio/1.1.5" \
... | 5,190 | 27.521978 | 71 | py |
rancher | rancher-master/tests/integration/suite/test_namespaced_secrets.py | from .common import random_str
from .test_secrets import CERT, KEY
UPDATED_CERT = """-----BEGIN CERTIFICATE-----
MIIDEDCCAfgCCQC+HwE8rpMN7jANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJV
UzEQMA4GA1UECBMHQXJpem9uYTEVMBMGA1UEChMMUmFuY2hlciBMYWJzMRIwEAYD
VQQDEwlsb2NhbGhvc3QwHhcNMTYwNjMwMDExMzMyWhcNMjYwNjI4MDExMzMyWjBK
MQswCQYDVQQ... | 8,568 | 32.869565 | 76 | py |
rancher | rancher-master/tests/integration/suite/test_system_project.py | import pytest
from rancher import ApiError
from kubernetes.client import CoreV1Api
from .conftest import wait_for
systemProjectLabel = "authz.management.cattle.io/system-project"
defaultProjectLabel = "authz.management.cattle.io/default-project"
initial_system_namespaces = set(["kube-node-lease",
... | 3,932 | 36.103774 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_clustertemplate.py | from .common import random_str, check_subject_in_rb
from rancher import ApiError
from .conftest import wait_until, wait_for, DEFAULT_TIMEOUT
import pytest
import time
import kubernetes
rb_resource = 'rolebinding'
def test_create_cluster_template_with_revision(admin_mc, remove_resource):
cluster_template = creat... | 41,302 | 36.99724 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_persistent_volume.py | from .common import random_str
def test_persistent_volume_update(admin_cc, remove_resource):
client = admin_cc.client
name = random_str()
pv = client.create_persistent_volume(
clusterId="local",
name=name,
accessModes=["ReadWriteOnce"],
capacity={"storage": "10Gi"},
... | 940 | 33.851852 | 69 | py |
rancher | rancher-master/tests/integration/suite/conftest.py | import os
import pytest
import requests
import time
import urllib3
import yaml
import socket
import subprocess
import json
import rancher
from sys import platform
from .common import random_str, wait_for_template_to_be_created
from kubernetes.client import ApiClient, Configuration, CustomObjectsApi, \
Apiextensions... | 21,251 | 31.545176 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_pipeline.py | import pytest
import time
from rancher import ApiError
from .pipeline_common import MockGithub
from .conftest import ProjectContext, rancher, \
wait_until_available, user_project_client
from .common import random_str
MOCK_GITHUB_PORT = 4016
MOCK_GITHUB_HOST = "localhost:4016"
MOCK_GITHUB_REPO_URL = 'https://githu... | 6,127 | 31.08377 | 79 | py |
rancher | rancher-master/tests/integration/suite/alert_common.py | import requests
from flask import request
from threading import Thread
class MockServer(Thread):
def __init__(self, port=5000):
super().__init__()
from flask import Flask
self.port = port
self.app = Flask(__name__)
self.url = "http://127.0.0.1:%s" % self.port
self... | 1,877 | 29.290323 | 75 | py |
rancher | rancher-master/tests/integration/suite/cluster_common.py | import subprocess
import os
import re
import yaml
from .common import random_str
from jinja2 import Template
def generate_cluster_config(request, dind_rke_node_num):
# generate a random and kube_config file
dind_name = 'dind-' + random_str()
dind_cluster_config_file = dind_name + '.yml'
dind_kube_conf... | 3,399 | 28.824561 | 72 | py |
rancher | rancher-master/tests/integration/suite/test_cluster_scan.py | from .common import random_str
from .conftest import cluster_and_client
def test_run_scan_not_available_on_not_ready_cluster(admin_mc,
remove_resource):
client = admin_mc.client
cluster = client.create_cluster(
name=random_str(),
rancherKube... | 533 | 30.411765 | 70 | py |
rancher | rancher-master/tests/integration/suite/test_cluster_role_template_bindings.py | import pytest
from .common import random_str
from .conftest import wait_for
from rancher import ApiError
def test_cannot_target_users_and_group(admin_mc, remove_resource):
"""Asserts that a clusterroletemplatebinding cannot target both
user and group subjects"""
admin_client = admin_mc.client
with p... | 2,526 | 36.161765 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_kontainer_drivers.py | import platform
import pytest
import sys
import requests
from rancher import ApiError
from .conftest import wait_for_condition, wait_until, random_str, \
wait_for, BASE_URL
NEW_DRIVER_URL = "https://github.com/rancher/kontainer-engine-driver-" \
"example/releases/download/v0.2.2/k... | 13,034 | 33.302632 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_globaldns.py | from .common import random_str
from rancher import ApiError
from kubernetes.client import CustomObjectsApi
from kubernetes.client import CoreV1Api
import pytest
import time
import kubernetes
import base64
def test_dns_fqdn_unique(admin_mc):
client = admin_mc.client
provider_name = random_str()
access = ra... | 12,409 | 35.824926 | 77 | py |
rancher | rancher-master/tests/integration/suite/test_pod_security_policies.py | import kubernetes
from .conftest import kubernetes_api_client, wait_for, set_cluster_psp
from .common import random_str
from rancher import ApiError
import pytest
from kubernetes.client.rest import ApiException
def cleanup_pspt(client, request, cluster):
def remove_pspt_from_cluster_and_delete(cluster):
p... | 12,543 | 35.254335 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_system_app_creator.py | from .common import random_str
import time
def test_system_app_creator(admin_mc, admin_system_pc, remove_resource):
client = admin_mc.client
provider_name = random_str()
access = random_str()
secret = random_str()
globaldns_provider = \
client.create_global_dns_provider(
... | 1,308 | 34.378378 | 72 | py |
rancher | rancher-master/tests/integration/suite/test_deployment.py | from .common import random_str
import kubernetes
from .conftest import kubernetes_api_client, user_project_client
def test_dep_creation_kubectl(admin_mc, admin_cc, remove_resource):
name = random_str()
project = admin_mc.client.create_project(name=random_str(),
cl... | 3,384 | 31.238095 | 75 | py |
rancher | rancher-master/tests/integration/suite/test_secrets.py | from .common import random_str
import kubernetes
from .conftest import kubernetes_api_client, user_project_client
CERT = """-----BEGIN CERTIFICATE-----
MIIDEDCCAfgCCQC+HwE8rpMN7jANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJV
UzEQMA4GA1UECBMHQXJpem9uYTEVMBMGA1UEChMMUmFuY2hlciBMYWJzMRIwEAYD
VQQDEwlsb2NhbGhvc3QwHhcNMTYwNjMwMDExM... | 11,788 | 33.775811 | 72 | py |
rancher | rancher-master/tests/integration/suite/test_cluster_catalog.py | from .conftest import wait_until, wait_until_available
from rancher import ApiError
from .common import random_str
import time
def test_cluster_catalog_creation(admin_mc, remove_resource,
user_factory):
client = admin_mc.client
# When cluster-owner tries to create cluster ca... | 8,948 | 36.2875 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_features.py | import pytest
from rancher import ApiError
# no one should be able to create features via the api
def test_cannot_create(admin_mc, user_mc, remove_resource):
admin_client = admin_mc.client
user_client = user_mc.client
with pytest.raises(ApiError) as e:
admin_client.create_feature(name="testfeatur... | 795 | 25.533333 | 67 | py |
rancher | rancher-master/tests/integration/suite/test_auth_configs.py | import pytest
from rancher import ApiError
from kubernetes.client import CoreV1Api, CustomObjectsApi
from .conftest import wait_for
def test_auth_configs(admin_mc):
client = admin_mc.client
with pytest.raises(AttributeError) as e:
client.list_github_config()
with pytest.raises(AttributeError) as... | 4,366 | 27.174194 | 75 | py |
rancher | rancher-master/tests/integration/suite/test_global_role_bindings.py | import pytest
from rancher import ApiError
from kubernetes.client.rest import ApiException
from kubernetes.client import RbacAuthorizationV1Api
from .conftest import wait_for
from .common import random_str, string_to_encoding
def test_cannot_update_global_role(admin_mc, remove_resource):
"""Asserts that globalR... | 4,522 | 30.852113 | 77 | py |
rancher | rancher-master/tests/integration/suite/test_node_templates.py | import pytest
import time
from .common import random_str
from .conftest import wait_for
from rancher import ApiError
from rancher import RestObject
from kubernetes.client import CustomObjectsApi
from kubernetes.client.rest import ApiException
def test_legacy_template_migrate_and_delete(admin_mc, admin_cc,
... | 6,655 | 35.571429 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_etcdbackups.py | from .conftest import wait_until
import kubernetes
role_template = "backups-manage"
def test_backups_manage_role(admin_mc, user_factory, remove_resource):
client = admin_mc.client
restricted_user = user_factory(globalRoleId='user-base')
# add user to local cluster with "Manage cluster backups" role
... | 1,269 | 30.75 | 72 | py |
rancher | rancher-master/tests/integration/suite/test_persistent_volume_claim.py | import pytest
import kubernetes
from .conftest import random_str, kubernetes_api_client
from rancher import ApiError
def test_cannot_create_azure_no_accountstoragetype(admin_pc, admin_cc,
admin_mc, remove_resource):
"""Tests that a PVC referencing a storage class... | 3,968 | 29.530769 | 81 | py |
rancher | rancher-master/tests/integration/suite/test_global_roles.py | import pytest
from rancher import ApiError
from .common import random_str
from .conftest import wait_for
@pytest.mark.nonparallel
def test_builtin_default_can_be_edited(admin_mc, revert_gr):
"""Asserts admins can only edit a builtin global role's newUserDefault
field"""
admin_client = admin_mc.client
... | 4,610 | 31.935714 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_multi_cluster_app.py | from .common import random_str, check_subject_in_rb
from rancher import ApiError
from .conftest import (
wait_until, wait_for, set_server_version, wait_until_available,
user_project_client
)
import time
import pytest
import kubernetes
roles_resource = 'roles'
projects_resource = 'projects'
members_resource = '... | 29,292 | 38.746269 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_cluster_auth_tokens.py | import subprocess
import pytest
from .conftest import create_kubeconfig, wait_for
from sys import platform
from kubernetes.client import CustomObjectsApi
from rancher import ApiError
# test if the kubeconfig works to list api-resources for the fqdn context
def exec_kubectl(request, dind_cc, client, cmd='api-resources... | 3,736 | 35.637255 | 76 | py |
rancher | rancher-master/tests/integration/suite/test_project_role_template_bindings.py | import pytest
from .common import random_str
from .conftest import wait_for
from rancher import ApiError
def test_cannot_target_users_and_group(admin_mc, remove_resource):
"""Asserts that a projectroletemplatebinding cannot target both
user and group subjects"""
admin_client = admin_mc.client
projec... | 2,704 | 35.554054 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_dns.py | from .common import random_str, auth_check
from rancher import ApiError
import pytest
def test_dns_fields(admin_pc_client):
auth_check(admin_pc_client.schema, 'dnsRecord', 'crud', {
'namespaceId': 'cr',
'projectId': 'cr',
'hostname': 'cru',
'allocateLoadBalancerNodePorts': 'cru',
... | 4,132 | 32.064 | 78 | py |
rancher | rancher-master/tests/integration/suite/test_kontainer_engine_validation.py | from .common import random_str
from .conftest import wait_until
def assert_has_error_message(admin_mc, remove_resource, eks, message):
cluster = admin_mc.client.create_cluster(
name=random_str(), amazonElasticContainerServiceConfig=eks)
remove_resource(cluster)
def get_provisioned_type(cluster):
... | 3,401 | 33.02 | 77 | py |
rancher | rancher-master/tests/integration/suite/common.py | import base64
import hashlib
import random
import time
def random_str():
return 'random-{0}-{1}'.format(random_num(), int(time.time()))
def random_num():
return random.randint(0, 1000000)
def find_one(method, *args, **kw):
return find_count(1, method, *args, **kw)[0]
def find_count(count, method, *a... | 4,472 | 25.467456 | 77 | py |
rancher | rancher-master/tests/integration/suite/test_cluster_defaults.py | import json
import pytest
from rancher import ApiError
from .common import random_str
from .conftest import wait_for
@pytest.mark.skip(reason="cluster-defaults disabled")
def test_generic_initial_defaults(admin_mc):
cclient = admin_mc.client
schema_defaults = {}
setting_defaults = {}
data = cclient.s... | 8,500 | 37.817352 | 79 | py |
rancher | rancher-master/tests/integration/suite/test_app.py | import time
import pytest
from rancher import ApiError
from .test_catalog import wait_for_template_to_be_created
from .common import random_str
from .conftest import set_server_version, wait_for, wait_for_condition, \
wait_until, user_project_client, DEFAULT_CATALOG
def test_app_mysql(admin_pc, admin_mc):
cli... | 35,472 | 36.144503 | 80 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.