diff --git a/dbdpy/__pycache__/__init__.cpython-39.pyc b/dbdpy/__pycache__/__init__.cpython-39.pyc index 0b6e4c8c..8c2830fb 100644 Binary files a/dbdpy/__pycache__/__init__.cpython-39.pyc and b/dbdpy/__pycache__/__init__.cpython-39.pyc differ diff --git a/dbdpy/__pycache__/device.cpython-39.pyc b/dbdpy/__pycache__/device.cpython-39.pyc index 7b79cfe7..c4799158 100644 Binary files a/dbdpy/__pycache__/device.cpython-39.pyc and b/dbdpy/__pycache__/device.cpython-39.pyc differ diff --git a/dbdpy/device.py b/dbdpy/device.py index 602244d3..4dff74b5 100644 --- a/dbdpy/device.py +++ b/dbdpy/device.py @@ -4,13 +4,39 @@ def __init__(self, brand, model): self.model = model def get_device_info(self): - return f"{self.brand} - {self.model}" + """Retrieve brand and model name of a device. - # def calculate_rescale_value(self, age, is_damaged): - # initial_value = 1000 - # depre_rate = 0.20 if self.brand == "Apple" else 0.15 - # rescale_value = initial_value * ((1 - depre_rate) ** age) - # if is_damaged: - # rescale_value *= 0.70 + Paramters + --------- + None - # return round(rescale_value, 2) + Returns + ------- + device_info : str + """ + device_info = f"{self.brand} - {self.model}" + return device_info + + def calculate_rescale_value(self, age, is_damaged): + """Short descreption + + Long description + + Parameters + ---------- + age : int + Description for parameter + is_damaged : bool + Description + + Return + ------ + + """ + initial_value = 1000 + depre_rate = 0.20 if self.brand == "Apple" else 0.15 + rescale_value = initial_value * ((1 - depre_rate) ** age) + if is_damaged: + rescale_value *= 0.70 + + return round(rescale_value, 2) diff --git a/setup.py b/setup.py index 28a4b77f..9325d1a6 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,8 @@ from setuptools import setup, find_packages VERSION = "0.0.1" -DESCRIPTION = "Python package for preprocessing and analyzing wearable device data" +DESCRIPTION = "Python package for preprocessing and \ + analyzing wearable device data" setup( name="dbdpy", diff --git a/tests/__pycache__/__init__.cpython-39.pyc b/tests/__pycache__/__init__.cpython-39.pyc index 2f1d4eef..935c7b29 100644 Binary files a/tests/__pycache__/__init__.cpython-39.pyc and b/tests/__pycache__/__init__.cpython-39.pyc differ diff --git a/tests/__pycache__/test_device.cpython-39-pytest-7.1.2.pyc b/tests/__pycache__/test_device.cpython-39-pytest-7.1.2.pyc index 4dfbad87..53159803 100644 Binary files a/tests/__pycache__/test_device.cpython-39-pytest-7.1.2.pyc and b/tests/__pycache__/test_device.cpython-39-pytest-7.1.2.pyc differ diff --git a/tests/test_device.py b/tests/test_device.py index 9b763188..9955dbe7 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -18,3 +18,16 @@ def test_get_device_info(): # def test_calculate_rescale_value(brand, age, is_damaged, expected): # dev = device.CommercialDevice(brand, "AnyModel") # assert dev.calculate_rescale_value(age, is_damaged) == expected + + +@pytest.mark.parametrize( + "brand, age, is_damaged, expected", + [ + ("Apple", 1, False, 800), + ("Apple", 2, False, 640), + ("Fitbit", 1, False, 850), + ], +) +def test_calculate_rescale_value(brand, age, is_damaged, expected): + dev = device.CommercialDevice(brand, "AnyModel") + assert dev.calculate_rescale_value(age, is_damaged) == expected