18: #line 30 "felix_fincat.ipk" 19: def get_nonobjects(self): 20: """return a list of all non-identity arrows 21: """ 22: return self.arrows.keys() 23: 24: def get_objects(self): 25: 'return a list of all identity arrows' 26: return self.objects.keys() 27: 28: def get_arrows(self): 29: """return a list of all arrows 30: """ 31: return self.objects.keys() + self.arrows.keys() 32: 33: def domain(self, arrow): 34: """get the domain/tail/source object of an arrow 35: """ 36: if arrow in self.objects.keys(): return arrow 37: else: return self.arrows[arrow][0] 38: 39: def codomain(self, arrow): 40: """return the codomain/head/destination object of an arrow 41: """ 42: if arrow in self.objects.keys(): return arrow 43: else: return self.arrows[arrow][1] 44: 45: def get_arrows_outof(self, arrow): 46: """return a list of all the arrows which can be appended to this arrow 47: """ 48: return self.objects[self.codomain(arrow)][0] 49: 50: def get_arrows_into(self, object): 51: """return a list of all the arrows which can be prepended to this arrow 52: """ 53: return self.objects[self.domain(arrow)][1] 54: 55: def can_compose(self,a,b): 56: """return 1 if arrows can be composed (left to right), 57: else return 0 58: """ 59: return self.codomain(a) == self.domain(b) 60: 61: def compose(self, a, b): 62: """return the composition of two arrows, 63: raise exception if not composable 64: """ 65: if not self.can_compose(a,b): 66: raise 'cannot compose arrows in "compose"' 67: if a in self.get_objects(): return b 68: elif b in self.get_objects(): return a 69: else: return self.rules[(a,b)] 70: