Fix D15: match Clojure moderation handling (zero out columns, don't remove)#2523
Open
jucor wants to merge 1 commit into
Open
Fix D15: match Clojure moderation handling (zero out columns, don't remove)#2523jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Mar 30, 2026
ae240ea to
6be5051
Compare
ballPointPenguin
approved these changes
Apr 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes discrepancy D15 between Python and Clojure: Python's _apply_moderation() previously removed moderated-out comment columns from rating_mat entirely, while Clojure's zero-out-columns zeros them in place. Changing to zeroing preserves matrix structure (same shape as raw_rating_mat), which downstream consumers (tids, PCA, repness) expect.
Changes:
_apply_moderation()now removes only moderated-out participant rows and zeros out moderated-out comment columns instead of dropping them.- Adds a new
TestD15SyntheticModerationclass (5 small synthetic tests) plus enhanced real-data D15 tests that apply mod-out from the Clojure blob and verify column counts and zero values. - Updates pre-existing tests in
test_conversation.pyandtest_discrepancy_fixes.pyto expect zeroed (not removed) moderated columns. Plan/journal docs updated.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
delphi/polismath/conversation/conversation.py |
Core fix: zero moderated comment columns in _apply_moderation() instead of dropping them. |
delphi/tests/test_discrepancy_fixes.py |
Expands D15 real-data tests and adds 5 synthetic tests; updates D2c assertion to expect equal raw/filtered column counts. |
delphi/tests/test_conversation.py |
Updates moderation tests to assert moderated columns remain present and are zeroed. |
delphi/docs/PLAN_DISCREPANCY_FIXES.md |
Marks D8 and D15 as done; adds K-divergence investigation section. |
delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md |
Adds session notes documenting the D15 fix, rationale, tests, and impact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…emove) ## Summary Python's `_apply_moderation()` removed moderated-out comment columns entirely from `rating_mat`. Clojure's `zero-out-columns` (named_matrix.clj:214-230) sets all values in moderated columns to 0, preserving matrix structure. This fix changes Python to match: - Moderated-out comment columns are **zeroed** (values set to 0.0), not removed - `rating_mat` retains the same column count as `raw_rating_mat` - Moderated-out participants (rows) are still removed — unchanged ### Why zeroing matters - **Matrix dimensions**: Clojure's `rating-mat` has the same shape as `raw-rating-mat`. Downstream code (PCA, repness) processes the same-shaped matrix. - **tids list**: Column indices stay stable. Consumers depend on this. - **Practical impact**: Zeroed columns have no signal (na=0, nd=0), so they fail significance tests and are excluded from repness/consensus. PCA sees zero variance. ## Changes - `conversation.py`: `_apply_moderation()` — zero out columns instead of removing - `test_discrepancy_fixes.py`: 5 new synthetic tests + 2 enhanced real-data tests - `test_conversation.py`: Updated to expect zeroed columns ## Test plan - [x] Synthetic tests: zeroing preserves columns, values are 0, non-moderated unchanged - [x] Real-data test: biodiversity-incremental (169 mod-out comments) - [x] Full public test suite: 328 passed, 0 failed - [x] TDD cycle: RED (2 failures) → GREEN (all pass) 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Squashed commits - Fix D15: match Clojure moderation handling (zero out columns, don't remove) commit-id:c3450b9a
Delphi Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Python's
_apply_moderation()removed moderated-out comment columns entirelyfrom
rating_mat. Clojure'szero-out-columns(named_matrix.clj:214-230) setsall values in moderated columns to 0, preserving matrix structure.
This fix changes Python to match:
rating_matretains the same column count asraw_rating_matWhy zeroing matters
rating-mathas the same shape asraw-rating-mat.Downstream code (PCA, repness) processes the same-shaped matrix.
significance tests and are excluded from repness/consensus. PCA sees zero variance.
Changes
conversation.py:_apply_moderation()— zero out columns instead of removingtest_discrepancy_fixes.py: 5 new synthetic tests + 2 enhanced real-data teststest_conversation.py: Updated to expect zeroed columnsTest plan
🤖 Generated with Claude Code
Squashed commits
commit-id:c3450b9a
Stack: