def test_at3_and_ope_mul(self): self.assertEqual( self.cplx.at( [ 'b','c' ], mul(-1) ), -3.0 )
else: real_func = funct dst.build_path(*(list(coord.dst) + [real_func(src.at(coord.src))])) return dst if "__main__" == __name__: from VectorDict import convert_tree from Operation import identity, mul, cast a = convert_tree({"a": {"b": 1, "c": 2}, "b": 0}) a.pprint() print a.at(["a", "c"]) m = SparseMatrix( (tuple(["a", "b"]), tuple(["mul", "neg2"]), mul(-2)), (tuple(["a", "c"]), tuple(["mul", "misplaced"]), cast(float)), (tuple(["b"]), tuple(["a"]), lambda x: -4), (tuple(["a"]), tuple(["a_dict"]), identity), ) m.pprint() print "**************" print m(a) m(a).pprint() print "iiiiiiiiiiiiiiiiiiiiiiiiiiiii" w = SparseMatrix() w[Coordinates(src=tuple([]), dst=tuple(["a_copy"]))] = identity w[Coordinates(src=tuple([]), dst=tuple(["inception"]))] = m.copy() w(a).pprint()
# approach 1 import Operation Operation.add(10, 20) #30 Operation.mul(10, 30) #300 # approach 2 from Operation import add, mul add(10, 30) #40 mul(10, 40) #400 # approach 3 from Operation import * add(10, 30) #40 mul(10, 40) #400 print("-----------########------------") #appraoch 1 import Animal import Bird Animal.fly() #animal cant fly Animal.color() #animal is black Bird.fly() #bird cant fly Bird.color() #bird is green #approach 2 from Animal import *