Ejemplo n.º 1
0
 def deriv(self, du: 'Variable') -> ('ValuedObj', Undefined):
     assert not inloop()
     if __debug__:
         from .variable import Variable
     assert isinstance(
         du, Variable
     ), 'Can only take derivative with regards to Variable, not {}'.format(
         type(du))
     return complete(self._aderiv(du))
Ejemplo n.º 2
0
 def d(self, du: 'Variable') -> 'UnseededFunction':
     assert not inloop()
     if __debug__:
         from .variable import Variable
     assert isinstance(
         du, Variable
     ), 'Can only take derivative with regards to Variable, not {}'.format(
         type(du))
     from .derivative import Derivative
     return complete(Derivative._a_get_deriv(self, du))
Ejemplo n.º 3
0
 def fget(self) -> (Any, Undefined):
     assert not inloop()
     return complete(self._avalue)
Ejemplo n.º 4
0
 def __round__(self, digits: int) -> (int, float):
     assert not inloop()
     return complete(self.__around__())
Ejemplo n.º 5
0
 def __invert__(self) -> 'SeededOperator':
     assert not inloop()
     return complete(self.__ainvert__())
Ejemplo n.º 6
0
		def fget(self):
			assert False, "don't use non-async functions!"
			return complete(self._afunc)
Ejemplo n.º 7
0
 def __int__(self) -> int:
     assert not inloop()
     return complete(self.__aint__())
Ejemplo n.º 8
0
 def hasvalue(self) -> bool:
     assert not inloop()
     return complete(self._ahasvalue)
Ejemplo n.º 9
0
 def __delattr__(self, name):
     assert not inloop()
     return complete(self.__adelattr__(name))
Ejemplo n.º 10
0
 def __call__(self, *args, **kwargs):
     assert not inloop()
     return complete(self.__acall__(*args, **kwargs))
Ejemplo n.º 11
0
 def __eq__(self, other: Any) -> bool:
     assert not inloop()
     return complete(self.__aeq__(other))
Ejemplo n.º 12
0
 def __repr__(self) -> str:
     assert not inloop()
     return complete(self.__arepr__())
Ejemplo n.º 13
0
 def __truediv__(self, other: 'Derivative') -> 'UnseededFunction':
     assert not inloop()
     if not isinstance(other, Derivative):
         return super().__truediv__(self, other)
     return complete(self.__atruediv__(other))
Ejemplo n.º 14
0
 def isconst(self, du: 'Variable') -> bool:
     assert not inloop()
     return complete(self._aisconst(du))
Ejemplo n.º 15
0
 def fset(self, val: Any) -> None:
     assert not inloop()
     return complete(self._avalue_setter(val))
Ejemplo n.º 16
0
 def fdel(self) -> None:
     assert not inloop()
     return complete(self._avalue_deleter())
Ejemplo n.º 17
0
 def __new__(cls, *args, **kwargs):
     assert not inloop()
     assert isinstance(cls, type)
     return complete(cls.__anew__(cls, *args, **kwargs))
Ejemplo n.º 18
0
 def __bool__(self) -> bool:
     assert not inloop()
     return complete(self.__aabs__())
Ejemplo n.º 19
0
 def __init__(self, *args, **kwargs):
     assert not inloop()
     return complete(self.__ainit__(*args, **kwargs))
Ejemplo n.º 20
0
 def __float__(self) -> float:
     assert not inloop()
     return complete(self.__afloat__())
Ejemplo n.º 21
0
            rv = f.future(r.value)
        return await _domethod('__le__', lv.result(), rv.result())

    await opers['__ale__']._afunc_setter(wrap_func)

    async def wrap_func(l, r):
        async with finish() as f:
            lv = f.future(l.value)
            rv = f.future(r.value)
        return await _domethod('__gt__', lv.result(), rv.result())

    await opers['__agt__']._afunc_setter(wrap_func)

    async def wrap_func(x):
        return await _domethod('__neg__', await x._avalue)

    await opers['__aneg__']._afunc_setter(wrap_func)

    async def wrap_func(x):
        return await _domethod('__pos__', await x._avalue)

    await opers['__apos__']._afunc_setter(wrap_func)

    async def wrap_func(x):
        return await _domethod('__invert__', await x._avalue)

    await opers['__ainvert__']._afunc_setter(wrap_func)


complete(main())
Ejemplo n.º 22
0
		def fset(self, val):
			assert False, "don't use non-async functions!"
			return complete(self._afunc_setter(val))
Ejemplo n.º 23
0
    csc.deriv_w_args = derive

    # ensure_future: async lambda
    async def derive(du, a):
        return sec(a) * tan(a) * await a._aderiv(du)  #await

    sec.deriv_w_args = derive

    # ensure_future: async lambda
    async def derive(du, a):
        return -csc(a)**2 * await a._aderiv(du)  #await

    cot.deriv_w_args = derive

    # ensure_future: async lambda
    async def derive(du, a):
        return await a._aderiv(du) / a  #await

    ln.deriv_w_args = derive

    async def derive(du, a):
        return .5 * a**-.5 * await a._aderiv(du)

    sqrt.deriv_w_args = derive
    del derive
    return locals()


__all__ = tuple(str(x) for x in complete(main()))
Ejemplo n.º 24
0
 def __rsub__(self, other: Any) -> 'SeededOperator':
     assert not inloop()
     return complete(self.__arsub__(other))
Ejemplo n.º 25
0
 def __complex__(self) -> complex:
     assert not inloop()
     return complete(self.__acomplex__())