Skip to content

Commit

Permalink
Merge pull request #1 from Lobooooooo14/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Lobooooooo14 authored Oct 24, 2022
2 parents 992c986 + b2cbe70 commit 6e83f90
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 8 deletions.
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,53 @@
# Tempyrature
# Tempyrature

Tempyrature is a simple Python module to convert temperature scales easily.

***

## Scales

Tempyrature currently supports 3 temperature ranges:

- Celcius
- Fahrenheit
- Kelvin

## Installation

You can install tempyrature in two main ways:

1. [***Pypi***](https://pypi.org/project/tempyrature/):

Through the command:
```
pip install tempyrature
```
> This command may vary depending on your device.
2. Cloning this repository:

If you have GIT installed, you can:

```
git clone https://github.com/Lobooooooo14/tempyrature.git
```
This will download this repository to your device, enter the downloaded folder (make sure it is in the same directory as the `setup.py` file) and use the command:
```
pip install .
```

## How to use

After you have done the installation, you can use the tempyrature as follows:

```python
from tempyrature import Converter


print(Converter.celsius2fahrenheit(30.5)) #30.5°C
#>>> 86.0
```

## Documentation

You can see the full documentation [***here***](https://github.com/Lobooooooo14/tempyrature/wiki/Documentation)
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.0',
version='1.0.1',
description='A simple temperature converter.',
long_description=readme,
author='Lobooooooo14',
Expand Down
15 changes: 14 additions & 1 deletion tempyrature/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
"""
A simple temperature converter
tempyrature
-----------
A simple temperature converter.
:copyright: (c) 2022 - Lobooooooo14
:license: see LICENSE for more details.
"""

__title__ = "tempyrature"
__author__ = "Lobooooooo14"
__license__ = "Apache License 2.0"
__copyright__ = "Copyright 2022 - Lobooooooo14"
__version__ = "1.0.1"

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


from .tempyrature import Converter
164 changes: 160 additions & 4 deletions tempyrature/tempyrature.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,192 @@
__all__ = [
'Converter'
]


class Converter:
"""
A simple temperature converter.
"""

def __init__(self) -> None:
"""
A simple temperature converter.
"""
pass


def celsius2fahrenheit(celsius: float) -> float:
"""
Converts celsius to fahrenheit.
Parameters
----------
celsius : float
The celsius temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> celsius2fahrenheit(25.0)
77.0
>>> celsius2fahrenheit(25.3)
77.53999999999999
Formula
-------
fahrenheit = 1.8 * celsius + 32
"""

fahrenheit = 1.8 * celsius + 32
return fahrenheit


def fahrenheit2celsius(fahrenheit: float) -> float:
"""
Converts fahrenheit to celsius.
Parameters
----------
fahrenheit : float
The fahrenheit temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> fahrenheit2celsius(77.0)
25.0
>>> fahrenheit2celsius(25.3)
25.299999999999994
Formula
-------
celsius = (fahrenheit - 32) / 1.8
"""

celsius = (fahrenheit - 32) / 1.8
return celsius


def celsius2kelvin(celsius: float) -> float:
"""
Converts celsius to kelvin.
Parameters
----------
celsius : float
The celsius temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> celsius2kelvin(10.0)
283.15
>>> celsius2kelvin(10.7)
283.84999999999997
Formula
-------
kelvin = celsius + 273.15
"""

kelvin = celsius + 273.15
return kelvin


def kelvin2celsius(kelvin: float) -> float:
"""
Converts kelvin to celsius.
Parameters
----------
kelvin : float
The kelvin temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> kelvin2celsius(283.0)
9.850000000000023
>>> kelvin2celsius(283.84)
10.689999999999998
Formula
-------
celsius = kelvin - 273.15
"""

celsius = kelvin - 273.15
return celsius


def fahrenheit2kelvin(fahrenheit: float) -> float:
"""
Converts fahrenheit to kelvin.
Parameters
----------
fahrenheit : float
The fahrenheit temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> fahrenheit2kelvin(80.0)
299.81666666666666
>>> fahrenheit2kelvin(25.7)
300.2055555555555
Formula
-------
kelvin = 273.15 + ((fahrenheit - 32.0) * (5.0/9.0))
"""

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


def kelvin2fahrenheit(kelvin: float) -> float:
fahrenheit = 1.8 * (kelvin - 273.15) - 32
"""
Converts kelvin to fahrenheit.
Parameters
----------
kelvin : float
The kelvin temperature to convert.
Returns
-------
float
The converted temperature.
Examples
--------
>>> kelvin2fahrenheit(299.81666666666666)
80.00000000000003
>>> kelvin2fahrenheit(300.2055555555555)
80.69999999999997
Formula
-------
fahrenheit = (kelvin - 273.15) * 9/5 + 32
"""

fahrenheit = (kelvin - 273.15) * 9.0/5.0 + 32
return fahrenheit
2 changes: 1 addition & 1 deletion tests/test_conversors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def test_float_kelvin2fahrenheit():


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

0 comments on commit 6e83f90

Please sign in to comment.