statistical tests

This commit is contained in:
2026-02-02 21:47:37 +01:00
parent 29df6a4bd9
commit f2c659c266
9 changed files with 1679 additions and 47 deletions

View File

@@ -48,13 +48,12 @@ Check if an existing `transform_<descriptive_name>` function exists in `utils.py
def transform_<descriptive_name>(self, df: pl.LazyFrame | pl.DataFrame) -> tuple[pl.LazyFrame, dict | None]:
"""Transform <input_description> to <output_description>.
Original request: "<paste user's original question here>"
Original use-case: "<paste user's original question here>"
This function <concise 1-2 sentence explanation of what it does>.
Args:
df: Pre-fetched data (e.g., from get_character_refine()).
Do NOT call get_*() methods inside this function.
df: Pre-fetched data as a Polars LazyFrame or DataFrame.
Returns:
tuple: (LazyFrame with columns [...], Optional metadata dict)
@@ -96,19 +95,11 @@ chart = S.plot_character_trait_frequency(trait_freq)
```
### Step 5: Create Temporary Test File
Create `debug_plot_temp.py` for testing. **You MUST ask the user to provide:**
Create `debug_plot_temp.py` for testing. **Prefer using the data snippet already provided by the user.**
1. **The exact code snippet to create the test data** - Do NOT generate or assume file paths
2. **Confirmation of which notebook they're working in** (so you can read it for context if needed)
**Option A: Use provided data snippet (preferred)**
If the user provided a `df.head()` or sample data output, create inline test data from it:
Example prompt to user:
> "To create the test file, please provide:
> 1. The exact code snippet that produces the dataframe you shared (copy from your notebook)
> 2. Which notebook are you working in? (I may read it for context, but won't modify it)
>
> I will NOT attempt to load any data without your explicit code."
**Test file structure using user-provided data:**
```python
"""Temporary test file for <plot_name>.
Delete after testing.
@@ -118,15 +109,32 @@ from theme import ColorPalette
import altair as alt
# ============================================================
# USER-PROVIDED TEST DATA (paste from user's snippet)
# TEST DATA (reconstructed from user's df.head() output)
# ============================================================
# <user's code goes here>
test_data = pl.DataFrame({
"Column1": ["value1", "value2", ...],
"Column2": [1, 2, ...],
# ... recreate structure from provided sample
})
# ============================================================
# Test the plot function
# ...
from plots import QualtricsPlotsMixin
# ... test code
```
**Option B: Ask user (only if necessary)**
Only ask the user for additional code if:
- The provided sample is insufficient to test the plot logic
- You need to understand complex data relationships not visible in the sample
- The transformation requires understanding the full data pipeline
If you must ask:
> "The sample data you provided should work for basic testing. However, I need [specific reason]. Could you provide:
> 1. [specific information needed]
>
> If you'd prefer, I can proceed with a minimal test using the sample data you shared."
### Step 6: Create Plot Function
Add a new method to `QualtricsPlotsMixin` in `plots.py`: