~jasper/type_stack_calc

a35324c4c2180e29e99614903deb1d82deab7123 — Jasper den Ouden 6 months ago d48f76e
Some variable name changes, comments and units added to fun_info
M type_stack_calc/ib/scope.py => type_stack_calc/ib/scope.py +8 -4
@@ 12,6 12,8 @@ from type_stack_calc.ib.plain_component import PlainComponent

class ScopeVariableSet(BaseComponentSet): pass

# TODO separate: what the variable might be, as set by different places,
#  from: what it is right now.
class ScopeVariable(BaseComponent):
    is_var = True



@@ 20,6 22,7 @@ class ScopeVariable(BaseComponent):
    def __init__(self, space, key):
        self.access_obj = space
        assert type(key) == str
        # Direct val is the stored value without logic about getting it from other scopes.
        self.key, self.direct_val = key, None

    @property


@@ 52,11 55,12 @@ class ScopeVariable(BaseComponent):
            self.direct_val = to
            return True
        else:
            val = self.direct_val.smoosh(to)  # Have to combine it.
            assert getattr(val, 'definitional', None) or val.is_const or obj.may_set, \
            changed_val = self.direct_val.smoosh(to)  # Have to combine it.
            assert getattr(changed_val, 'definitional', None) \
                or changed_val.is_const or obj.may_set, \
                f"""Scopes: only constants(/definitional)
{val} from {self.direct_val} set to {to}"""  # (still may need constant.)
            self.direct_val = val
{changed_val} from {self.direct_val} set to {to}"""  # (still may need constant.)
            self.direct_val = changed_val  # Remember the change.

    def sc_set(self, sc, to):
        sc.does.add('set_space') # Note that it defines something in space.

M type_stack_calc/tp/component_collection.py => type_stack_calc/tp/component_collection.py +1 -1
@@ 89,7 89,7 @@ class ComponentCollection(Named, dict, BaseType, Ided):
    def __init__(self, origin, space, name=None):
        self.origin = origin
        self.space = space
        if origin: origin.notify_cc(self)
        if origin: origin.notify_cc(self)  # Notifies this Component Collection was made there.
        self.tp_locked = False

        Named.__init__(self, name)

M type_stack_calc/util/fun_info.py => type_stack_calc/util/fun_info.py +12 -6
@@ 60,12 60,12 @@ fun_info = dict(

    abs = fi(abs, extrema=(0,pi), rising=[(0,None)], falling=[(None,0)]),
    cos = fi(math.cos, float=True, period=2*pi,
             extrema=(0, pi)),
             extrema=(0, pi), unit='radian'),
    sin = fi(math.sin, float=True, period=2*pi,
             extrema=(math.pi/2, 3*math.pi/2)),
             extrema=(math.pi/2, 3*math.pi/2), unit='radian'),
    cosh = fi(math.cosh, float=True, extrema=(0,),
              rising=[(0,None)], falling=[(None,0)]),
    sqrt = fi(math.sqrt, float=True, rising=[(0,None)]))
              rising=[(0,None)], falling=[(None,0)], unit='none'),
    sqrt = fi(math.sqrt, float=True, rising=[(0,None)], unit=(1,2)))

    # TODO erf, refc, gamma



@@ 75,11 75,17 @@ fun_info = dict(

for k in ['log', 'log2', 'log10']:  # Positive input only.
    fun_info[k] = fi(getattr(math, k), float=True, rising=[(0,None)],
                     n=1, holes=[0])
                     n=1, holes=[0], unit='none')

# Rising functions.
for k in ['exp', 'sinh', 'tanh', 'degrees', 'radians']:
    fun_info[k] = fi(getattr(math, k), float=True, rising=[(None,None)])
    fun_info[k] = fi(getattr(math, k), float=True, rising=[(None,None)],
                     unit='none')

fun_info['degrees'] = fi(math.degrees, float=True, rising=[(None,None)],
                         unit='radian', ret_unit='degree')
fun_info['radians'] = fi(math.radians, float=True, rising=[(None,None)],
                         unit='degree', ret_unit='radian')

for k,v in list(fun_info.items()):  #(list is against shenanigans happening..
    v.name = k