Skip to main content

Tempera

Description

Create temperature objects which return their value in a set 'global' unit scale - either Celsius, Fahrenheit, or Kelvin - using the method getTemperature(). When the Global temperature scale is changed, all temperature objects are returned in that scale.

I created this module to easily convert multiple temperatures displayed on a GUI when a user selects a different scale. I imagine it could be useful any time one has multiple persistant temperatures that need to undergo unit conversion at will.

Using this Module

The Global temperature scale can be set with the method self.setGlobalScale(). All Temperature objects will return in this scale with self.getTemperature().

Set or return from a specific scale using self.c for Celsius, self.f for Fahrenheit, and self.k for Kelvin.

Local Scales

If you want a specific Temperature object to return self.getTemperature() in a different scale regardless of the current global scale, use self.setLocalScale(). Can return to using global scale with self.setLocalScale(False) or self.useGlobalScale().

Rounding

Set the number of decimal places with the decimal_place keyword argument:

from tempera import Temperature

temp1 = Temperature(12, decimal_place=2)

Or with self.setDecimalPlace(int), where int is an integer. The default decimal place is 2. Setting to None will always return a rounded integer.

Intervals

Temperature objects can also represent intervals instead of actual temperatures with the keyword argument isinterval=True. For example, if you wanted to represent an interval of 3 celsius units:

temp_interval = Temperature(3, isinterval=True)

print(temp1.C + temp_interval.C)  # Adds 3 celsius to temp1 and prints

How it functions

The temperature is stored internally in Celsius. All setting and getting of the temperature in different scales is a conversion from this 'private' celsius attribute. This attribute is not rounded. Any rounding is done when getTemperature() (or a similar method) is called, so setting a decimal place does not affect the internally stored temperature.

Release files for tempera 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tempera 1.0.1
File Size Uploaded
tempera-1.0.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tempera 1.0.1
File Interpreter ABI Platform
tempera-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / tempera-1.0.1.tar.gz

Download URL tempera-1.0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d6b3c52c3ae051e2fe09499b701420bf89dda5c81fa91b70ec355a256c1e924
BLAKE2b-256 checksum
How to use checksums
72b49f52c488bd66c4d600a048846917510b3458a76fd5ae7c79ac1b16fe5d28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.7.4

Release files / tempera-1.0.1-py3-none-any.whl

Download URL tempera-1.0.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
627a5f140734d13411174b72f458c6aebf4c9b8822088cfd7e8926239c67e556
BLAKE2b-256 checksum
How to use checksums
bf129548c423e989e9a05f776b0449efdec139d7450342d20067bceb3f49b14d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page