refactor(_mf_class.py): improve code quality and fix potential issues#42
refactor(_mf_class.py): improve code quality and fix potential issues#42statmlben merged 4 commits intosoftmin:mainfrom
Conversation
DataboyUsen
commented
Apr 3, 2026
- Replace random_state handling with proper rng instance initialization
- Remove pandas dependency by using numpy-only operations
- Fix convergence check: apply abs() to obj_diff before comparison
- Porperly move the initialization of model parameters to fit() method
- Fix spelling errors in comments and docstrings
- Replace random_state handling with proper rng instance initialization - Remove pandas dependency by using numpy-only operations - Fix convergence check: apply abs() to obj_diff before comparison - Porperly move the initialization of model parameters to fit() method - Fix spelling errors in comments and docstrings
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thank you @DataboyUsen Let me just copy paste the suggestions generated by opus 4.6: most of the comments are valid, please check P4 very careful to see if it is correct or not. Thx! 1. BUG: Shared mutable list via
|
| # | Issue | Severity | Lines Affected |
|---|---|---|---|
| 1 | Shared mutable list bug | Critical | 278, 285 |
| 2a | Validation in __init__ |
Medium-High | 202-213 |
| 2b | Default param mutation | Medium-High | 220-221 |
| 2c | Derived self.rng in __init__ |
Medium-High | 231-234 |
| 2d | Pre-init fitted attributes | Medium-High | 235-238 |
| 3 | User/Item update duplication | Medium | 311-442 |
| 4 | obj() X parameter misuse |
Low-Medium | 515-516 |
| 5 | Missing input validation | Low-Medium | fit() top |
| 6 | Missing fitted check | Low | 458 |
| 7 | Minor style issues | Low | Various |
|
Sure, I'll check those potential issues. Thank you so much for the assitance. |
…s for OPUS 4.6 - Fix cold start users sharing mutable list bug (suggestions by opus 4.6, P1) - Further adhere to sklearn style: move all model parameter definitions from __init__ to fit(), transfer validation logic from __init__ to fit() with extended checks, and correct rng instance usage (suggestions by opus 4.6, P2&P5) - Clarify obj() loss computation logic: replace inappropriate direct X usage with meaningless X_dummy placeholder, explicitly indicating it as an intermediate variable not involved in loss calculation (suggestions by opus 4.6, P4) - Add comments and optimize low-efficiency code (suggestions by opus 4.6, P7)
Merge upstream/main: sync with Professor's latest updates
- Previously attempted to follow sklearn convention: set to None in __init__, initialize to [] in fit() - This caused CI failure because test accesses .constraint_user.append() before fit() is called - Reverted to original behavior (init as []) to maintain compatibility with existing tests - No impact on correctness: [] and None treated equivalently in fit()
|
I've made the revisions based on Opus 4.6's suggestions. Apologies for not running the CI tests locally before pushing, which led to one improper push. The code changes themselves are still aligned with the intended direction. Regarding the codecov error, perhaps we can discuss it together in our next meeting? |
|
@DataboyUsen Thx! You may check my commit here caaf4be. I will cherry-pick this time. |