コード例 #1
0
ファイル: metadict.py プロジェクト: theProphet/Pangaia
    def __add__(self, other):
        """Add together, with recursion.  The basic idea is that the set of keys
        should be added together and then recurse the addition to the values where keys are shared
        otherwise just add the value.

        >>> m, m2 = Mdict('a'), Mdict('abb')
        >>> m + m2 == {'a':2, 'b':2}
        True
        >>> m + 1 == {None:1, 'a':1}
        True
        >>> m['a'] = m2  #now fractal
        >>> m == {'a': {'a':1, 'b':2}}
        True
        >>> m + m + 1 == {'a': {'a':2, 'b':4}, None: 1}
        True
        """
        try: # need to add (union) of keys, and then recurse into values of common keys
            return Mdict(Counter.__add__(self, other)) #Counter.__add__(self, other)
        except TypeError: #must've been an integer for other
            return Mdict(Counter.__add__(self, Counter({None: other})))
コード例 #2
0
    def __add__(self, other):
        """Add together, with recursion.  The basic idea is that the set of keys
        should be added together and then recurse the addition to the values where keys are shared
        otherwise just add the value.

        >>> m, m2 = Mdict('a'), Mdict('abb')
        >>> m + m2 == {'a':2, 'b':2}
        True
        >>> m + 1 == {None:1, 'a':1}
        True
        >>> m['a'] = m2  #now fractal
        >>> m == {'a': {'a':1, 'b':2}}
        True
        >>> m + m + 1 == {'a': {'a':2, 'b':4}, None: 1}
        True
        """
        try:  # need to add (union) of keys, and then recurse into values of common keys
            return Mdict(Counter.__add__(self,
                                         other))  #Counter.__add__(self, other)
        except TypeError:  #must've been an integer for other
            return Mdict(Counter.__add__(self, Counter({None: other})))
コード例 #3
0
ファイル: masking.py プロジェクト: xysun/jax
 def __add__(p1, p2):
     return Poly(Counter.__add__(p1, p2))
コード例 #4
0
 def __add__(self, other):
     return Factorization(Counter.__add__(self, other))
コード例 #5
0
ファイル: __init__.py プロジェクト: sankethkatta/tpro
 def __add__(self, other):
     return Vector(Counter.__add__(self, other))