GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - fastats/reasonable: Reasonable float handling for Hypothesis testing

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
reasonable
reasonable
 
 
tests
tests
 
 
.coveragerc
.coveragerc
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pytest.ini
pytest.ini
 
 
releases.md
releases.md
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 

Repository files navigation

reasonable

Build Status codecov Codacy Badge Documentation Status

Reasonable float handling for Hypothesis testing

Hypothesis is an excellent package, however sometimes we want to trade the purist approach towards floating-point numbers for a more pragmatic approach.

reasonable complements hypothesis by limiting the range and precision of generated floats, defaulting to 8d.p.

As a result, reasonable does not generate very small (10^-300) floats, which makes approximate comparisons (of the sort used in unit-tests) much easier to perform.

For example, by replacing floats with the version in reasonable, you can perform approximate comparisons:

from hypothesis import given
from pytest import approx
from reasonable import floats, x

@given(floats(x < 0.0))
def test_minimizer(n):
    result = minimize(my_func, x0=n)
    assert result == approx(0.23456789)

Documentation

reasonable.readthedocs.io

Installation

Requirements: You will need hypothesis installed (obviously) -

pip install hypothesis

then install reasonable with

pip install reasonable

Contributing

All contributions are welcome :)

If you would like to contribute anything, open a PR (issues are turned off):

  • To report a bug, open a PR with a unit-test that fails.
  • To request an API change/new functionality, open a PR with a unit-test that fails showing your preferred API.
  • To submit a fix, open a PR with passing unit-tests and doctests.

Doctests should be minimal and serve as API docs for the most common use cases.

Unit-tests should be exhaustive, and include basic sanity tests as well as generative tests using hypothesis.

How to report a bug

  • Create a new python file in the tests folder, make sure the filename starts with test_.
  • Create a single function in the file which replicates the bug. Make sure the function name starts with test_.
  • Open a PR with the new file and a brief description - the unit-tests should fail.

At that point either the reporter or a fastats developer can commit on that PR to fix the bug.

About

Reasonable float handling for Hypothesis testing

Topics

hypothesispythontesting

Resources

Readme
Unlicense
Activity
Custom properties

Stars

3 stars

Watchers

4 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.