Skip to content

Commit 1ed996f

Browse files
committed
feat: edtech + gaming domains, null_if conditional nulls, py.typed, coverage CI
1 parent 5c7edb7 commit 1ed996f

5 files changed

Lines changed: 243 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ jobs:
2727
- name: Install dependencies
2828
run: |
2929
pip install -e ".[dev]"
30+
pip install pytest-cov
3031
31-
- name: Run tests
32+
- name: Run tests with coverage
3233
run: |
33-
pytest tests/ -q --tb=short
34+
pytest tests/ -q --tb=short --cov=misata --cov-report=xml --cov-report=term-missing
3435
3536
- name: Run scale test
3637
run: |
3738
pytest tests/test_integration_scale.py -v -m slow --tb=short
39+
40+
- name: Upload coverage to Codecov
41+
if: matrix.python-version == '3.11'
42+
uses: codecov/codecov-action@v4
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
files: coverage.xml
46+
fail_ci_if_error: false

misata/py.typed

Whitespace-only changes.

misata/simulator.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,9 @@ def generate_batches(self, table_name: str) -> Any:
13471347
# Apply formulas
13481348
df_batch = self._apply_formula_columns(df_batch, table_name)
13491349

1350+
# Apply conditional nulls (null_if)
1351+
df_batch = self._apply_null_if(df_batch, table_name)
1352+
13501353
# Post-process
13511354
df_batch = self._fix_correlated_columns(df_batch, table_name)
13521355

@@ -1683,6 +1686,27 @@ def _apply_single_constraint(self, df: pd.DataFrame, constraint: Any) -> pd.Data
16831686

16841687
return df
16851688

1689+
def _apply_null_if(self, df: pd.DataFrame, table_name: str) -> pd.DataFrame:
1690+
"""Set column to NaN/NaT where a sibling column matches a trigger value.
1691+
1692+
Reads ``null_if`` from each column's distribution_params:
1693+
null_if: {"column": "status", "values": ["cancelled", "refunded"]}
1694+
or the shorthand single-value form:
1695+
null_if: {"column": "status", "value": "cancelled"}
1696+
"""
1697+
columns = self.config.columns.get(table_name, [])
1698+
for col in columns:
1699+
spec = col.distribution_params.get("null_if")
1700+
if not spec:
1701+
continue
1702+
ref_col = spec.get("column")
1703+
trigger_values = spec.get("values") or ([spec["value"]] if "value" in spec else [])
1704+
if not ref_col or not trigger_values or ref_col not in df.columns or col.name not in df.columns:
1705+
continue
1706+
mask = df[ref_col].isin(trigger_values)
1707+
df.loc[mask, col.name] = np.nan
1708+
return df
1709+
16861710
def _apply_formula_columns(self, df: pd.DataFrame, table_name: str) -> pd.DataFrame:
16871711
"""Apply formula-based derived columns using context for lookups."""
16881712
try:

0 commit comments

Comments
 (0)