Skip to main content

A helper to compare two numbers generously

Project description

A helper for approximate comparison.

from almost import almost

def test_repeating_decimal():
    assert almost(1 / 3.) == 0.333
    assert almost(1 / 6.) == 0.167
    assert almost(3227 / 555., precision=6) == 5.814414

def test_irrational_number():
    import math
    assert almost(math.pi) == 3.142
    assert almost(math.sqrt(2)) == 1.414

def test_random_text():
    import random
    def gen_text_with_prefix(prefix):
        return prefix + str(random.random())[:-5]
    assert almost(gen_text_with_prefix('@')) == '@...'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

almost-0.1.4.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file almost-0.1.4.tar.gz.

File metadata

  • Download URL: almost-0.1.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for almost-0.1.4.tar.gz
Algorithm Hash digest
SHA256 50f92f0fc5a6f5a8669a695459b78f505e9cc07dfa941462f87a23ff89bf0155
MD5 2bbdb1aba1945a80fe93189ecde7b525
BLAKE2b-256 eeea26925a42e9b236d38e57a36e629faca28075922c63b3f786a36467883c82

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page