def test_lifeExpectancyRemaining_maxAge(self): self.assertAlmostEqual(1.12, lifeExpectancyRemaining( 'female', 'Afghanistan', date(1955, 1, 1), relativedelta(years=120)), places=0) self.assertAlmostEqual(1.12, lifeExpectancyRemaining( 'male', 'United Kingdom', date(2050, 1, 1), relativedelta(years=120)), places=0)
def test_lifeExpectancyRemaining(self): self.assertAlmostEqual(28.53, lifeExpectancyRemaining( 'female', 'World', date(2049, 3, 11), relativedelta(years=55, months=4)), places=0) self.assertAlmostEqual(32.80, lifeExpectancyRemaining( 'male', 'United Kingdom', date(2001, 5, 11), relativedelta(years=49)), places=0)
def calculate_remaining_life_expectancy(request, sex, country, date, age): """ Calculate remaining life expectancy of a person with given sex, country, and age at a given point in time.<p> Please see <a href="/">the full API browser</a> for more information. """ remaining_life_expectancy = lifeExpectancyRemaining( sex, country, date, age) return Response({ 'date': date, 'sex': sex, 'country': country, 'age': offset_to_str(age), 'remaining_life_expectancy': remaining_life_expectancy })
def calculate_remaining_life_expectancy(request, sex, country, date, age): """ Calculate remaining life expectancy of a person with given sex, country, and age at a given point in time.<p> Please see <a href="/">the full API browser</a> for more information. """ remaining_life_expectancy = lifeExpectancyRemaining(sex, country, date, age) return Response({'date': date, 'sex': sex, 'country': country, 'age': offset_to_str(age), 'remaining_life_expectancy': remaining_life_expectancy})
def test_lifeExpectancy(self): self.assertAlmostEqual(26.24, lifeExpectancyRemaining('unisex', 'World', date(2049, 3, 11), relativedelta(years=55, months=4)), places=0) self.assertAlmostEqual(28.05, lifeExpectancyRemaining('male', 'UK', date(2001, 5, 11), relativedelta(years=49)), places=0)
def test_lifeExpectancyRemaining_maxAge(self): self.assertAlmostEqual(1.12, lifeExpectancyRemaining('female', 'Afghanistan', date(1955, 1, 1), relativedelta(years=120)), places=0) self.assertAlmostEqual(1.12, lifeExpectancyRemaining('male', 'United Kingdom', date(2050, 1, 1), relativedelta(years=120)), places=0)
def test_lifeExpectancyRemaining(self): self.assertAlmostEqual(28.53, lifeExpectancyRemaining('female', 'World', date(2049, 3, 11), relativedelta(years=55, months=4)), places=0) self.assertAlmostEqual(32.80, lifeExpectancyRemaining('male', 'United Kingdom', date(2001, 5, 11), relativedelta(years=49)), places=0)
def rem_le(self, le_date, le_exact_age): return lifeExpectancyRemaining('male', self.CNTRY, le_date, le_exact_age)