# for x in range(10.0):
# NumberStats.getInstance().add(x)
# NumberStats.getInstance().add(-x)
# NumberStats.getInstance().report()
Utilities
SingletonObjects
SingletonObjects
SingletonObjects ()
A utility for refrencing objects that should only be declared once.
UniqueNamer
UniqueNamer
UniqueNamer ()
A utility for ensuring the names of functions are unique.
FunctionsList
FunctionsList
FunctionsList ()
A utility for storing functions created, keyed on the function name.
Memory
Memory
Memory ()
A utility for recording global values.
NumberStats
NumberStats
NumberStats ()
A utility for calculating the statistice of a number.
FunctionsData
FunctionsData ()
Data collected for a set of functions
from pct.functions import Proportional
= Proportional() prop
UniqueNamer.getInstance().report()
FunctionsList.getInstance().report()
--- functions report
dynamic_module_import
dynamic_module_import (modulename, package=None)
dynamic_class_load
dynamic_class_load (modulename, classname)
#import importlib
#importlib.import_module('pct.functions', 'Constant')
get_drive
get_drive ()
loadjson
loadjson (file)
= loadjson("ws.json")
var print(var)
{'type': 'WeightedSum', 'name': 'weighted_sum', 'value': 35, 'links': {'0': 'constant', '1': 'constant1', '2': 'constant2'}, 'weights': [1, 1, 1]}
Counter
Counter
Counter (limit=1000, init=0, step=1, print=100, pause=False, display=10)
Initialize self. See help(type(self)) for accurate signature.
Functions
set_dirs
set_dirs (dirs)
stringIntListToListOfInts
stringIntListToListOfInts (strList, delimiter)
stringFloatListToListOfFloats
stringFloatListToListOfFloats (strList, delimiter)
stringListToListOfStrings
stringListToListOfStrings (strList, delimiter=',')
listNumsToString
listNumsToString (list)
round_lists
round_lists (alist, formatted, places)
floatListsToString
floatListsToString (alist, places)
limit_large_float
limit_large_float (val, limit=10000000)
sigmoid
sigmoid (x, range, slope)
smooth
smooth (new_val, old_val, smooth_factor)
sigmoid_array
sigmoid_array (x, range, slope)
dot
dot (inputs, weights)
list_of_ones
list_of_ones (num)
print(list_of_ones(3))
[1, 1, 1]
limit_to_range
limit_to_range (num, lower, upper)
wrap_env
wrap_env (env)
show_video
show_video ()
import matplotlib.pyplot as plt
= 2 #np.linspace(-5, 5, 11)
x #x = -10000001
range=2
=2
scale= sigmoid(x, range, scale)
y 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
is_in_notebooks ()
printtime
printtime (msg)
clip_value
clip_value (val, range)
get_abs_tol
get_abs_tol
get_abs_tol (key)
get_rel_tol
get_rel_tol
get_rel_tol (key)
map_to_int_even_range
map_to_int_even_range (val=None, inrange=None, outrange=None)
map_to_int_odd_range
map_to_int_odd_range (val=None, inrange=None, outrange=None)
= [-2, 2]
limits = [1, 5]
mapped = [-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 ]
vals 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]
= [-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 ]
vals = [-2, 2]
limits = [1, 4]
mapped 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
Timer ()
Initialize self. See help(type(self)) for accurate signature.
TimerError
A custom exception used to report errors in use of Timer class
= Timer()
timer
timer.start()1)
time.sleep(
timer.stop()
timer.start()1)
time.sleep(
timer.stop()
print(timer.mean())
print(timer.total())
print(timer.count())
1.0111035999999998
2.0222071999999995
2
PCTRunProperties
PCTRunProperties
PCTRunProperties ()
Initialize self. See help(type(self)) for accurate signature.
= 'ga-000.000-s001-1x1-m007-ARC0010-9ddcf52416e60d65f19007957d07262d-consolidated.properties'
property_file = ''
property_dir print(property_dir, property_file)
= PCTRunProperties.get_environment_properties(root='testfiles', env='ARC', property_dir=property_dir, property_file=property_file)
ep print(ep)
ga-000.000-s001-1x1-m007-ARC0010-9ddcf52416e60d65f19007957d07262d-consolidated.properties
({'code': '007bbfb7', 'index': 0, 'dataset': 'train', 'control_set': ['dims'], 'input_set': ['env'], 'history': 5, 'initial': 100}, 'ARC')
get_ram_mb
get_ram_mb ()