grim

An implementation of the GRIM test in python

https://github.com/phoughton/grim_test

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.9%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

An implementation of the GRIM test in python

Basic Info
  • Host: GitHub
  • Owner: phoughton
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 97.7 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 5
  • Releases: 0
Created almost 6 years ago · Last pushed 9 months ago
Metadata Files
Readme License Citation

README.md

The GRIM test

An implementation of the GRIM test, in python

Introduction

This package is based on the GRIM (Granularity-Related Inconsistency of Means) test first highlighted by Heathers & Brown in their 2016 paper.

The test makes use of a simple numerical property to identify if the mean of integer values has been correctly calculated.

You don't need the original integer values. You just need the mean and the number (n) of items.

What about rounding?

Often the mean you are testing has previously been rounded. You can check if the mean is consistent with a particular rounding type by including that as an argument.

This implementation supports all the rounding types found in the Python decimal implementation (at least between versions 3.8 and 3.11).

(They are: ROUNDCEILING, ROUNDDOWN, ROUNDFLOOR, ROUNDHALFDOWN, ROUNDHALFEVEN, ROUNDHALFUP, ROUNDUP, ROUND_05UP)

If no rounding type is included then the test assumes ROUNDHALFUP.

These examples are available as a Google Colab Notebook

How do I install it?

On the command line: bash pip install grim

In a google Colab/iPython/Jupyter notebook: bash !pip install grim

Example: Is this mean, n and rounding type consistent?

```python from grim import mean_tester import decimal

mean is 11.09 and n is 21

print(meantester.consistencycheck('11.09', '21', decimal.ROUNDHALFUP)) `` This will returnFalse` as the mean could not be correct given a list of 21 integers (and using ROUNDHALFUP rounding.)

Example: Is this mean & n consistent using any rounding type?

```python from grim import mean_tester import decimal

mean is 11.09 and n is 21

print(meantester.summaryconsistencycheck('11.09', '21')) This will return: python {'ROUNDCEILING': False, 'ROUNDDOWN': True, 'ROUNDFLOOR': True, 'ROUNDHALFDOWN': False, 'ROUNDHALFEVEN': False, 'ROUNDHALFUP': False, 'ROUNDUP': False, 'ROUND05UP': True} ``` As you can see, a given mean and n might be consistent using one form of rounding but not others.

You can pass in the numbers as Strings or Decimals, this avoids floating point accuracy issues that are more likely to occur when using a 'float'.

How do I see some logging about how the possible matches the algorithm has considered?

Add an extra argument, log_status=True. python print(mean_tester.summary_consistency_check('11.09', '21', log_status=True))

The output would look this: Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.05, Upper match: 11.10, Match status: False, Rounding method: ROUND_CEILING Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.04, Upper match: 11.09, Match status: True, Rounding method: ROUND_DOWN Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.04, Upper match: 11.09, Match status: True, Rounding method: ROUND_FLOOR Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.05, Upper match: 11.10, Match status: False, Rounding method: ROUND_HALF_DOWN Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.05, Upper match: 11.10, Match status: False, Rounding method: ROUND_HALF_EVEN Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.05, Upper match: 11.10, Match status: False, Rounding method: ROUND_HALF_UP Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.05, Upper match: 11.10, Match status: False, Rounding method: ROUND_UP Tue, 18 Apr 2023 18:02:00 +0000 : Target Mean: 11.09, Decimal places: 2, Lower match: 11.00, Middle match: 11.04, Upper match: 11.09, Match status: True, Rounding method: ROUND_05UP {'ROUND_CEILING': False, 'ROUND_DOWN': True, 'ROUND_FLOOR': True, 'ROUND_HALF_DOWN': False, 'ROUND_HALF_EVEN': False, 'ROUND_HALF_UP': False, 'ROUND_UP': False, 'ROUND_05UP': True}

A warning about floating point numbers & computers:

Beware of creating Decimals from floating point numbers as these may have floating point inaccuracies.

e.g.:

```python import decimal

print(decimal.Decimal(1.1)) 1.100000000000000088817841970012523233890533447265625 ```

Notice how the inaccurate representation of 1.1 from the floating point number has been preserved in the Decimal. Its better to create a decimal from a String E.g.:

```python import decimal

print(decimal.Decimal('1.1')) 1.1 ```

Many tools can be configured to read in text [that might be a number] as a string with out parsing. Some tools, such as Webdriver, only return a string (Which is useful!)

For more information on the origins of these issues in modern computer languages read this.

How can I find out more about the GRIM test?

James Heathers has published articles that explain how the technique works and how he used it to expose inconsistencies in scientific papers.

Citation file

There is a citation file included in the code repo.

Owner

  • Name: Peter Houghton
  • Login: phoughton
  • Kind: user
  • Location: Europe

A remote freelancer specialising in software devops, test engineering and architecture.

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Grim Test
message: >-
  The test makes use of a simple numerical property to
  identify if the mean of integer values has been correctly
  calculated.
type: software
authors:
  - given-names: Peter Johnathan
    family-names: Houghton
    email: pete@investigatingsoftware.co.uk
repository-code: 'https://github.com/phoughton/grim_test'
repository-artifact: 'https://pypi.org/project/grim/'
abstract: >-
  This package is based on the GRIM (Granularity-Related
  Inconsistency of Means) test first highlighted by Heathers
  & Brown in their 2016 paper.

  The test makes use of a simple numerical property to
  identify if the mean of integer values has been correctly
  calculated.

  You don't need the original integer values. You just need
  the mean and the number (n) of items.
keywords:
  - grim
  - statistics
  - python
  - mean
  - average
license: MIT

GitHub Events

Total
  • Push event: 1
  • Create event: 2
Last Year
  • Push event: 1
  • Create event: 2

Committers

Last synced: about 3 years ago

All Time
  • Total Commits: 37
  • Total Committers: 1
  • Avg Commits per committer: 37.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Peter Houghton p****e@i****k 37
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 2
  • Total pull requests: 10
  • Average time to close issues: 24 days
  • Average time to close pull requests: about 14 hours
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • karolszk (1)
  • r-barnes (1)
Pull Request Authors
  • phoughton (12)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 162 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 2
  • Total versions: 17
  • Total maintainers: 1
pypi.org: grim

An implementation of the GRIM test, in Python

  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 162 Last month
Rankings
Dependent packages count: 10.0%
Dependent repos count: 11.6%
Average: 23.1%
Forks count: 29.8%
Stargazers count: 31.9%
Downloads: 32.3%
Maintainers (1)
Last synced: 7 months ago

Dependencies

build_requirements.txt pypi
  • matplotlib *
  • pandas *
  • pytest *
  • seaborn *
  • setuptools *
  • twine *
  • wheel *
.github/workflows/ci.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • actions/checkout main composite
  • actions/setup-python v5 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.devcontainer/Dockerfile docker
  • phoughton/python-dev-main latest build
requirements.txt pypi
setup.py pypi