Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
68 stars 23 forks source link

Verbose mode shows incoherent data regarding final result #76

Closed bpetit closed 2 years ago

bpetit commented 2 years ago

Bug description

GWP manufacturing impact is 67 for 2 RAM sticks, but verbose shows 33 for 1 RAM stick.

{'impacts': {'adp': {'manufacture': 0.005,
                     'unit': 'kgSbeq',
                     'use': 'not implemented'},
             'gwp': {'manufacture': 67.0,
                     'unit': 'kgCO2eq',
                     'use': 'not implemented'},
             'pe': {'manufacture': 850.0,
                    'unit': 'MJ',
                    'use': 'not implemented'}},
 'verbose': {'capacity': {'input_value': 8,
                          'status': 'UNCHANGED',
                          'used_value': 8},
             'density': {'input_value': None,
                         'status': 'SET',
                         'used_value': 0.625},
             'impacts': {'adp': {'unit': 'kgSbeq', 'value': 0.0025},
                         'gwp': {'unit': 'kgCO2eq', 'value': 33.0},
                         'pe': {'unit': 'MJ', 'value': 420.0}},
             'manufacturer': {'input_value': 'Hynix/Hyundai',
                              'status': 'UNCHANGED',
                              'used_value': 'Hynix/Hyundai'},
             'model': {'input_value': 'HMT41GS6MFR8C-PB',
                       'status': 'UNCHANGED',
                       'used_value': 'HMT41GS6MFR8C-PB'},
             'units': 2}}

To Reproduce

Send this request :

{'capacity': 8,
 'manufacturer': 'Hynix/Hyundai',
 'model': 'HMT41GS6MFR8C-PB',
 'units': 2}

Expected behavior

Final impact of 2 ram sticks is equal to 2x (impact of 1 ram stick).

da-ekchajzer commented 2 years ago

@odelcroi I think it is related to roundit. IMHO I think that it's a normal behavior.

Explanation through an example

Significant figure : 2 Impact of 1 ram stick : ram_stick_impact = 33,4

Round(ram_stick_impact) = 33 Round(2 ram_stick_impact) = Round(2 33,4) = Round(66.8) = 67

This behavior is due to the fact that each value is rounded only after the last calculation to avoid any lost of information. We won't reuse a rounded value in a calculation.

@odelcroi, @bpetit does it make sense to you ? Should we change this behavior ?