Skip to content

unexpected behavior: convert delta_degC to degC and vice versa #577

@Cpp87

Description

@Cpp87

Converting delta_degC to degC implicitly assumes the base value 0 Kelvin. Example:

>>> (3*unyt.delta_degC).to(unyt.degC)
unyt_quantity(-270.15, 'degC')

The offset of 273.15 is suprising to me. I would rather expect an error.

How did I encounter this:
I did not know about the delta_degC. My code calculates in Celcius and I perform x.to(unyt.degC) in case the user inputs Kelvin.
This would have produced terribly wrong results. Hence, I suggest to raise an error and tell the user "provide base temperture for converting delta_degC to degC". Implicit assumption of 0K as base temperature is dangerous.

The same issue happens vice versa:

>>> (3*unyt.degC).to(unyt.delta_degC)
unyt_quantity(276.15, 'delta_degC')

Side note:
Substracting two temperatures in Celcius yields delta_degC as unit.
Substracting two temperatures in Kelving yields Kelvin - seems inconsistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions