コード例 #1
0
ファイル: cpi.py プロジェクト: BackupTheBerlios/lino-svn
def indexed_price(base,target,basePrice,**kw):
    baseMonth=Month.parse(str(base))
    targetMonth=Month.parse(str(target))
    for i in SANTE:
        if i.start <= baseMonth:
            return FixedPoint(
                basePrice * i.coeff(baseMonth,targetMonth),**kw)
コード例 #2
0
ファイル: cpi.py プロジェクト: BackupTheBerlios/lino-svn
def indexed_price(base, target, basePrice, **kw):
    baseMonth = Month.parse(str(base))
    targetMonth = Month.parse(str(target))
    for i in SANTE:
        if i.start <= baseMonth:
            return FixedPoint(basePrice * i.coeff(baseMonth, targetMonth),
                              **kw)
コード例 #3
0
        self.values = values

    def coeff(self, baseMonth, newMonth):
        assert baseMonth >= self.start
        baseIndex = self.values[baseMonth - self.start]
        try:
            newIndex = self.values[newMonth - self.start]
        except IndexError, e:
            print newMonth, "-", self.start, "=", newMonth - self.start
            raise
        #print self.start,baseIndex, newIndex
        return newIndex / baseIndex


sante1988 = Index(
    Month.parse('198212'),
    (
        # 1982:
        82.53,
        # 1983:
        83.54,
        84.00,
        84.31,
        84.57,
        85.02,
        85.57,
        86.39,
        87.21,
        87.82,
        87.83,
        88.28,
コード例 #4
0
 def parse(self, s):
     assert len(s), ERR_PARSE_EMPTY
     return Month.parse(s)
コード例 #5
0
 def parse(self,s):
     assert len(s), ERR_PARSE_EMPTY
     return Month.parse(s)
コード例 #6
0
        self.start = start
        self.values=values

    def coeff(self,baseMonth,newMonth):
        assert baseMonth >= self.start
        baseIndex=self.values[baseMonth-self.start]
        try:
            newIndex=self.values[newMonth-self.start]
        except IndexError,e:
            print newMonth, "-", self.start, "=", newMonth-self.start
            raise
        #print self.start,baseIndex, newIndex
        return newIndex / baseIndex
        

sante1988 = Index(Month.parse('198212'), (
# 1982:    
82.53, 
# 1983:
83.54, 84.00, 84.31, 84.57, 85.02, 85.57,
86.39, 87.21, 87.82, 87.83, 88.28, 88.44, 
# 1984:
89.27, 89.94, 90.32, 90.91, 91.11, 91.37,
91.86, 92.22, 92.50, 92.92, 92.96, 93.17,

# 1985:
93.77, 94.74, 95.50, 95.87, 95.97, 95.99,
96.51, 96.51, 96.71, 96.66, 96.89, 96.92,

# 1986:
97.03, 97.11, 96.96, 97.26, 97.04, 97.17,
コード例 #7
0
    def test01(self):
        
        l = [str(m) for m in anyrange(Month(2003,10),Month(2004,02),1)]
        s=" ".join(l)
        #print s
        self.assertEqual(s,"10/2003 11/2003 12/2003 01/2004 02/2004")
        
        m0 = m = Month(2003,3)
        self.assertEqual(m,Month(2003,3))
        
        m += 1
        self.assertEqual(m,Month(2003,4))

        m2 = m+1
        self.assertEqual(m2,Month(2003,5))
        
        i = Month(2005,6) - Month(2003,6)
        self.assertEqual(i,24)
        
        i = Month(2005,6) - Month(2003,4)
        self.assertEqual(i,26)
        
        i = Month(2005,6) - Month(2003,7)
        self.assertEqual(i,23)
        
        i = Month(2005,6) - Month(2005,6)
        self.assertEqual(i,0)

        i = Month(2002,8) - Month(1994,1)
        self.assertEqual(i,103) # 103=8*12+7
        
        i = Month(2005,5) - Month(1994,1)
        self.assertEqual(i,136) # 136=11*12+4