コード例 #1
0
ファイル: myredis.py プロジェクト: carloslucenah/fiware-facts
    def sum(self, lista):
        """ Calculate the sum of a list of data

        :param mylist lista:     The lists of lists which will be added.
        return mylist            The new mylist instance with the result of the operation.
        """
        if len(lista) > 1:
            return mylist.sum(lista)
        elif len(lista) == 1:
            r1 = mylist()
            r1.insert(lista)
            return r1
        else:
            return '[]'
コード例 #2
0
ファイル: myredis.py プロジェクト: Fiware/cloud.Facts
    def sum(self, lista):
        """ Calculate the sum of a list of data

        :param mylist lista:     The lists of lists which will be added.
        return mylist            The new mylist instance with the result of the operation.
        """
        if len(lista) > 1:
            return mylist.sum(lista)
        elif len(lista) == 1:
            r1 = mylist()
            r1.insert(lista)
            return r1
        else:
            return '[]'
コード例 #3
0
ファイル: myredis.py プロジェクト: carloslucenah/fiware-facts
    def media(self, lista, windowsize):
        """ Calculate the media of a list of data

         :param mylist lista     The mylist instance with the data to be added.
         :return mylist          The media of the data
        """
        if isinstance(windowsize, list) and len(windowsize) == 1:
            windowsize = int(windowsize[0])
        if len(lista) >= windowsize:
            return self.sum(lista) / len(lista)
        else:
            result = mylist()
            result.data = []
            return result
コード例 #4
0
ファイル: myredis.py プロジェクト: Fiware/cloud.Facts
    def media(self, lista, windowsize):
        """ Calculate the media of a list of data

         :param mylist lista     The mylist instance with the data to be added.
         :return mylist          The media of the data
        """
        if isinstance(windowsize, list) and len(windowsize) == 1:
            windowsize = int(windowsize[0])
        if len(lista) >= windowsize:
            return self.sum(lista) / len(lista)
        else:
            result = mylist()
            result.data = []
            return result