Git Product home page Git Product logo

hypothesis-tests's Introduction

Hypothesis tests for dataframes

Running the tests (which is really all there is to this)

pip install poetry
poetry install
pytest -s

What it does...

Property-based testing (see below) with hypothesis. The 'main' package code merges two dataframes, drops duplicates and any value where the id <= 0. The tests are set up to create two pandas DataFrames, one with id and a cat_name, one with an id and a human_name.

Different set up for different considerations

  • Creating values from Regex (all files)

    • Hypothesis allows to create values that match a particular regular expression. This is neat for well-behaved defaults that can then be overwritten with one test at a time.
  • Deterministic structure (test_one_row and test_full_df)

    • This allows for the greatest control when we have lots of tables that need to be merged. Ids can explicitly be set up to be the same across different tables and the same would be true for any other values we use to join tables. Returning these values also allows to construct the expected output data.
  • Random lenghts of dataframes (test_pandas_df)

    • Introducing the ability to test along the dimension of the length of a dataframe, but sacrificing some control over joins.
    • This setup is similar to how it would be done with Pandera.

Why might this be valuable

Instead of passing in a whole dataframe and testing with that, hypothesis allows us to set up a default dataframe (from regex for example) to then only change the values we want to test for, one at a time.

hypothesis-tests's People

Contributors

isakiko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.