# pylint: disable=pointless-statementUtilities
SingletonObjects
SingletonObjects
def SingletonObjects(
):
A utility for refrencing objects that should only be declared once.
UniqueNamer
UniqueNamer
def UniqueNamer(
):
A utility for ensuring the names of functions are unique.
FunctionsList
FunctionsList
def FunctionsList(
):
A utility for storing functions created, keyed on the function name.
Memory
Memory
def Memory(
):
A utility for recording global values.
NumberStats
NumberStats
def NumberStats(
):
A utility for calculating the statistics of a number.
FunctionsData
FunctionsData
def FunctionsData(
):
Data collected for a set of functions
# for x in range(10.0):
# NumberStats.getInstance().add(x)
# NumberStats.getInstance().add(-x)
# NumberStats.getInstance().report()# from pct.functions import Proportional# prop = Proportional()# UniqueNamer.getInstance().report()# FunctionsList.getInstance().report()dynamic_module_import
def dynamic_module_import(
modulename, package:NoneType=None
):
dynamic_class_load
def dynamic_class_load(
modulename, classname
):
#import importlib
#importlib.import_module('pct.functions', 'Constant')get_drive
def get_drive(
):
loadjson
def loadjson(
file
):
var = loadjson("ws.json")
print(var){'type': 'WeightedSum', 'name': 'weighted_sum', 'value': 35, 'links': {'0': 'constant', '1': 'constant1', '2': 'constant2'}, 'weights': [1, 1, 1]}
Counter
Counter
def Counter(
limit:int=1000, init:int=0, step:int=1, print:int=100, pause:bool=False, display:int=10
):
Initialize self. See help(type(self)) for accurate signature.
Functions
set_dirs
set_dirs
def set_dirs(
dirs
):
stringIntListToListOfInts
def stringIntListToListOfInts(
strList, delimiter
):
stringFloatListToListOfFloats
def stringFloatListToListOfFloats(
strList, delimiter
):
stringListToListOfStrings
def stringListToListOfStrings(
strList, delimiter:str=','
):
listNumsToString
def listNumsToString(
list
):
round_lists
def round_lists(
alist, formatted, places
):
floatListsToString
def floatListsToString(
alist, places
):
limit_large_float
def limit_large_float(
val, limit:int=10000000
):
sigmoid
def sigmoid(
x, range, slope
):
smooth
def smooth(
new_val, old_val, smooth_factor
):
sigmoid_array
def sigmoid_array(
x, range, slope
):
dot
def dot(
inputs, weights
):
list_of_ones
def list_of_ones(
numx
):
# li = list_of_ones(3)
# print(li)limit_to_range
def limit_to_range(
num, lower, upper
):
wrap_env
def wrap_env(
env
):
show_video
def show_video(
):
import matplotlib.pyplot as plt
x = 2 #np.linspace(-5, 5, 11)
#x = -10000001
range=2
scale=2
y = sigmoid(x, range, scale)
print(y)
# plt.plot(x, y)
# plt.grid()
# plt.xlim(-6, 6)
# plt.xlabel('x')
# plt.title('expit(x)')
# plt.show()0.7615941559557646
is_in_notebooks
def is_in_notebooks(
):
printtime
def printtime(
msg
):
clip_value
def clip_value(
val, range
):
get_abs_tol
get_abs_tol
def get_abs_tol(
key
):
get_rel_tol
get_rel_tol
def get_rel_tol(
key
):
map_to_int_even_range
def map_to_int_even_range(
val:NoneType=None, inrange:NoneType=None, outrange:NoneType=None
):
map_to_int_odd_range
def map_to_int_odd_range(
val:NoneType=None, inrange:NoneType=None, outrange:NoneType=None
):
limits = [-2, 2]
mapped = [1, 5]
vals = [-3.1, -2.1, -1.51, -1.5, -1.4, -0.9,-0.5, -0.1, 0, 0.1, 0.6, 1.1, 2.1, 210.1 ]
for val in vals:
print(val, map_to_int_odd_range(val, limits, mapped))-3.1 1
-2.1 1
-1.51 1
-1.5 1
-1.4 2
-0.9 2
-0.5 3
-0.1 3
0 3
0.1 3
0.6 4
1.1 4
2.1 5
210.1 5
#vals = [0.6]
vals = [-3.1, -2.1, -1.51, -1.5, -1.4, -0.9, -0.5, -0.1, 0, 0.1, 0.6, 1.1, 2.1, 210.1 ]
limits = [-2, 2]
mapped = [1, 4]
for val in vals:
print(val, map_to_int_even_range(val, limits, mapped))-3.1 1
-2.1 1
-1.51 1
-1.5 1
-1.4 1
-0.9 2
-0.5 2
-0.1 2
0 3
0.1 3
0.6 3
1.1 4
2.1 4
210.1 4
Timer
def Timer(
):
Initialize self. See help(type(self)) for accurate signature.
TimerError
def TimerError(
args:VAR_POSITIONAL, kwargs:VAR_KEYWORD
):
A custom exception used to report errors in use of Timer class
timer = Timer()
timer.start()
time.sleep(1)
timer.stop()
timer.start()
time.sleep(1)
timer.stop()
print(timer.mean())
print(timer.total())
print(timer.count())1.0116276999469846
2.0232553998939693
2
PCTRunProperties
PCTRunProperties
def PCTRunProperties(
args:VAR_POSITIONAL, kwargs:VAR_KEYWORD
):
Initialize self. See help(type(self)) for accurate signature.
# property_file = 'ga-000.000-s001-1x1-m007-ARC0010-9ddcf52416e60d65f19007957d07262d-consolidated.properties'
# property_dir = ''
# print(property_dir, property_file)
# ep = PCTRunProperties.get_environment_properties(root='testfiles', env='ARC', property_dir=property_dir, property_file=property_file)
# print(ep)get_ram_mb
def get_ram_mb(
):