Skip to content

Commit

Permalink
Merge pull request #2 from Lobooooooo14/development
Browse files Browse the repository at this point in the history
Added new conversion: Rankine
  • Loading branch information
Lobooooooo14 authored Dec 4, 2022
2 parents 907d5ce + cd6519e commit 1c28ed0
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
**/__pycache__/
.vscode
.pytest_cache/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='tempyrature',
version='1.0.1',
version='1.0.2',
description='A simple temperature converter.',
long_description=readme,
author='Lobooooooo14',
Expand Down
2 changes: 1 addition & 1 deletion tempyrature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__author__ = "Lobooooooo14"
__license__ = "Apache License 2.0"
__copyright__ = "Copyright 2022 - Lobooooooo14"
__version__ = "1.0.1"
__version__ = "1.0.2"

__path__ = __import__("pkgutil").extend_path(__path__, __name__)

Expand Down
180 changes: 168 additions & 12 deletions tempyrature/tempyrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def celsius2fahrenheit(celsius: float) -> float:
--------
>>> celsius2fahrenheit(25.0)
77.0
>>> celsius2fahrenheit(25.3)
77.53999999999999
Formula
-------
Expand Down Expand Up @@ -60,8 +58,6 @@ def fahrenheit2celsius(fahrenheit: float) -> float:
--------
>>> fahrenheit2celsius(77.0)
25.0
>>> fahrenheit2celsius(25.3)
25.299999999999994
Formula
-------
Expand Down Expand Up @@ -90,8 +86,6 @@ def celsius2kelvin(celsius: float) -> float:
--------
>>> celsius2kelvin(10.0)
283.15
>>> celsius2kelvin(10.7)
283.84999999999997
Formula
-------
Expand Down Expand Up @@ -120,8 +114,6 @@ def kelvin2celsius(kelvin: float) -> float:
--------
>>> kelvin2celsius(283.0)
9.850000000000023
>>> kelvin2celsius(283.84)
10.689999999999998
Formula
-------
Expand Down Expand Up @@ -150,8 +142,6 @@ def fahrenheit2kelvin(fahrenheit: float) -> float:
--------
>>> fahrenheit2kelvin(80.0)
299.81666666666666
>>> fahrenheit2kelvin(25.7)
300.2055555555555
Formula
-------
Expand Down Expand Up @@ -180,8 +170,6 @@ def kelvin2fahrenheit(kelvin: float) -> float:
--------
>>> kelvin2fahrenheit(299.81666666666666)
80.00000000000003
>>> kelvin2fahrenheit(300.2055555555555)
80.69999999999997
Formula
-------
Expand All @@ -190,3 +178,171 @@ def kelvin2fahrenheit(kelvin: float) -> float:

fahrenheit = (kelvin - 273.15) * 9.0/5.0 + 32
return fahrenheit


def celsius2rankine(celsius: float) -> float:
"""
Converts celsius to rankine.
Parameters
----------
celsius : float
The celsius temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> celsius2rankine(10.0)
509.66999999999996
Formula
-------
rankine = (celsius + 273.15) * 9/5
"""

rankine = (celsius + 273.15) * 9/5
return rankine


def rankine2celsius(rankine: float) -> float:
"""
Converts rankine to celsius.
Parameters
----------
rankine : float
The rankine temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> rankine2celsius(509.66999999999996)
10.0
Formula
-------
celsius = rankine * 5/9 - 273.15
"""

celsius = rankine * 5/9 - 273.15
return celsius


def fahrenheit2rankine(fahrenheit: float) -> float:
"""
Converts fahrenheit to rankine.
Parameters
----------
fahrenheit : float
The fahrenheit temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> fahrenheit2rankine(104.0)
563.6700000000001
Formula
-------
rankine = fahrenheit + 459.67
"""

rankine = fahrenheit + 459.67
return rankine


def rankine2fahrenheit(rankine: float) -> float:
"""
Converts rankine to fahrenheit.
Parameters
----------
rankine : float
The rankine temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> rankine2fahrenheit(563.6700000000001)
104.00000000000006
Formula
-------
fahrenheit = rankine - 459.67
"""

fahrenheit = rankine - 459.67
return fahrenheit


def kelvin2rankine(kelvin: float) -> float:
"""
Converts kelvin to rankine.
Parameters
----------
kelvin : float
The kelvin temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> kelvin2rankine(313.15000000000003)
563.6700000000001
Formula
-------
rankine = kelvin * 9/5
"""

rankine = kelvin * 9/5
return rankine


def rankine2kelvin(rankine: float) -> float:
"""
Converts rankine to kelvin.
Parameters
----------
rankine : float
The rankine temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> rankine2kelvin(563.6700000000001)
313.15000000000003
Formula
-------
kelvin = rankine * 5/9
"""

kelvin = rankine * 5/9
return kelvin
48 changes: 24 additions & 24 deletions tests/test_conversors.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import tempyrature


def test_float_celsius2fahrenheit():
assert type(tempyrature.Converter.celsius2fahrenheit(10.3)) == float


def test_correct_response_celsius2fahrenheit():
assert tempyrature.Converter.celsius2fahrenheit(10.3) == 50.540000000000006


def test_float_celsius2kelvin():
assert type(tempyrature.Converter.celsius2kelvin(10.3)) == float


def test_correct_response_celsius2kelvin():
assert tempyrature.Converter.celsius2kelvin(10.3) == 283.45


def test_float_fahrenheit2celsius():
assert type(tempyrature.Converter.fahrenheit2celsius(34.3)) == float


def test_correct_response_fahrenheit2celsius():
assert tempyrature.Converter.fahrenheit2celsius(34.3) == 1.2777777777777761


def test_float_fahrenheit2kelvin():
assert type(tempyrature.Converter.fahrenheit2kelvin(34.3)) == float


def test_correct_response_fahrenheit2kelvin():
assert tempyrature.Converter.fahrenheit2kelvin(34.3) == 274.42777777777775


def test_float_kelvin2celsius():
assert type(tempyrature.Converter.kelvin2celsius(280.2)) == float


def test_correct_response_kelvin2celsius():
assert tempyrature.Converter.kelvin2celsius(280.2) == 7.050000000000011


def test_float_kelvin2fahrenheit():
assert type(tempyrature.Converter.kelvin2fahrenheit(280.2)) == float


def test_correct_response_kelvin2fahrenheit():
assert tempyrature.Converter.kelvin2fahrenheit(280.2) == 44.69000000000002


def test_correct_response_rankine2celsius():
assert tempyrature.Converter.rankine2celsius(509.66999999999996) == 10.0


def test_correct_response_celsius2rankine():
assert tempyrature.Converter.celsius2rankine(10.0) == 509.66999999999996


def test_correct_response_rankine2fahrenheit():
assert tempyrature.Converter.rankine2fahrenheit(563.6700000000001) == 104.00000000000006


def test_correct_response_fahrenheit2rankine():
assert tempyrature.Converter.fahrenheit2rankine(104.0) == 563.6700000000001


def test_correct_response_rankine2kelvin():
assert tempyrature.Converter.rankine2kelvin(563.6700000000001) == 313.15000000000003


def test_correct_response_kelvin2rankine():
assert tempyrature.Converter.kelvin2rankine(313.15000000000003) == 563.6700000000001
Loading

0 comments on commit 1c28ed0

Please sign in to comment.