Registry / data / pygrinder

pygrinder

JSON →
library0.7pypypi✓ verified 87d ago

A Python toolkit for introducing missing values into datasets under various missingness mechanisms (MCAR, MAR, MNAR) and patterns (point, sequential, block). Current version: 0.7. Requires Python >=3.8. Released quarterly.

pip install pygrinder
INSTALL
IMPORT
SIG · PYGRINDER
P
pygrinder
datapythonv0.7
Install
81.7s avg
Import
12845ms
Disk
5248MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 90.3s
py 3.11
✕ build_error
✓ 87.3s
py 3.12
✕ build_error
✓ 77s
py 3.13
✕ build_error
✓ 72.3s
py 3.9
✕ build_error
✕ timeout
5248MB installed
● package 5248MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mcar
from pygrinder import mcar
Earlier versions (pre-0.4) returned masks; now returns only corrupted data.
mar_logistic
from pygrinder import mar_logistic
Renamed from mar_logistic (always existed).
mnar_x
from pygrinder import mnar_x
Renamed from mnar_x (always existed).
mnar_t
from pygrinder import mnar_t
Renamed from mnar_t (always existed).
mnar_nonuniform
from pygrinder import mnar_nonuniform
Added in v0.7, replaces mnar_num.
seq_missing
from pygrinder import seq_missing
Added in v0.6.
block_missing
from pygrinder import block_missing
Added in v0.6.
rdo
from pygrinder import rdo
Added in v0.5.
fill_and_get_mask
from pygrinder import fill_and_get_mask
Added in v0.4.
little_mcar_test
from pygrinder import little_mcar_test
Added in v0.2.
calc_missing_rate
from pygrinder import calc_missing_rate
from pygrinder import calc_misssing_rate
Typo in v0.6.1 used 'calc_misssing_rate' (extra 's'), corrected to 'calc_missing_rate' from v0.6.2 onwards.

Basic usage: create MCAR missingness, then fill NaNs and get mask.

import numpy as np from pygrinder import mcar, fill_and_get_mask X = np.random.randn(100, 10) corrupted_X = mcar(X, rate=0.2) X_filled, mask = fill_and_get_mask(corrupted_X, fill_value=0) print(f"Original shape: {X.shape}, missing rate: {1 - mask.mean():.2f}")
Debug
Known issues
breakingIn v0.4, all missingness-creating functions (mcar, mar_logistic, mnar_x, mnar_t) changed to return only the corrupted data (with NaN), not a tuple (X_intact, X, mask). Use fill_and_get_mask to get the mask.
fix
Update code: data = mcar(X, rate=0.2) instead of X_intact, data, mask = mcar(X, rate=0.2). Use fill_and_get_mask(data) to get mask.
affects: <0.4
deprecatedIn v0.7, mnar_num has been renamed to mnar_nonuniform. The old name mnar_num is removed.
fix
Replace mnar_num with mnar_nonuniform.
affects: <=0.6.4
gotchaFunctions seq_missing and block_missing require seq_len argument; setting seq_len equal to n_steps can cause an empty step_idx list bug (fixed in v0.6.4). Verify that seq_len < n_steps to avoid errors.
fix
Upgrade to >=0.6.4 or ensure seq_len < n_steps.
affects: <=0.6.3
gotchaMar_logistic had a bug in argument order (v0.6.2 and earlier) that could produce incorrect missingness. Fixed in v0.6.3.
fix
Upgrade to >=0.6.3.
affects: <=0.6.2
deprecatedIn v0.4, the parameter 'return_masks' was available to return masks alongside corrupted data; it was removed in later versions. Use fill_and_get_mask instead.
fix
Switch to fill_and_get_mask to retrieve the mask.
affects: 0.3-0.4
Errors
Common errors & fixes
AttributeError: module 'pygrinder' has no attribute 'calc_misssing_rate'
Typo in function name; the correct name is calc_missing_rate (single 's' after 'miss').
fix
Use from pygrinder import calc_missing_rate
TypeError: mcar() got multiple values for argument 'rate'
Passing both positional and keyword argument for 'rate', or duplicate keyword.
fix
Call mcar(X, rate=0.2) with only one rate specification.
ValueError: seq_len must be less than n_steps
In seq_missing, seq_len equals or exceeds the number of time steps, causing an empty index list.
fix
Set seq_len < n_steps, or upgrade to pygrinder >=0.6.4 where this condition is handled.
Upgrade
Version history
0.7latest on PyPI · released Feb 3, 2025
Audit
Dependencies
numpyrequiredCore dependency for array operations
torchrequiredUsed for random number generation and tensor operations
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
pygrinder — pip install pygrinder · libregistry