Skip to content

fix: three code-review issues in analysis/satp-circe-notebook#131

Merged
MitchellAcoustics merged 2 commits intoanalysis/satp-circe-notebookfrom
copilot/code-review-satp-circe-notebook
Mar 1, 2026
Merged

fix: three code-review issues in analysis/satp-circe-notebook#131
MitchellAcoustics merged 2 commits intoanalysis/satp-circe-notebookfrom
copilot/code-review-satp-circe-notebook

Conversation

Copy link

Copilot AI commented Mar 1, 2026

Code review of the analysis/satp-circe-notebook branch introduces the SATP CircE analysis module, R session management, and SN wrappers. Three issues were identified and fixed.

Changes

Bug: install_r_packages() calls install.packages(character(0)) on empty list

After installing CircE from GitHub and removing it from packnames_to_install, utils.install_packages(StrVector([])) was unconditionally called — passing an empty character vector to R's install.packages. Added a if packnames_to_install: guard:

# Before: always called even after CircE removal emptied the list
utils.install_packages(StrVector(packnames_to_install))

# After: only called when CRAN packages remain
if packnames_to_install:
    utils.install_packages(StrVector(packnames_to_install))

Docstring format: _circe_wrapper.py used non-standard hybrid style

extract_bfgs_fit() and bfgs() used indented (type): parameter descriptions rather than the NumPy-style used everywhere else. Standardised to NumPy format.

Error message: fit_circe() empty-data message unconditionally mentioned participant

The ValueError raised for an empty DataFrame said "Check that data contains valid rows with PAQ1-PAQ8 and participant column" even when ipsatize_data=False (where no participant column is needed). Message updated to remove the unconditional participant reference.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…mat, error message

Co-authored-by: MitchellAcoustics <22335636+MitchellAcoustics@users.noreply.github.com>
Copilot AI changed the title [WIP] Conduct code review for analysis/satp-circe-notebook fix: three code-review issues in analysis/satp-circe-notebook Mar 1, 2026
@MitchellAcoustics MitchellAcoustics marked this pull request as ready for review March 1, 2026 15:40
@MitchellAcoustics MitchellAcoustics merged commit d594993 into analysis/satp-circe-notebook Mar 1, 2026
2 checks passed
@MitchellAcoustics MitchellAcoustics deleted the copilot/code-review-satp-circe-notebook branch March 1, 2026 15:42
MitchellAcoustics pushed a commit that referenced this pull request Mar 1, 2026
#1 — RRuntimeError added to fit_exceptions
  rpy2's RRuntimeError inherits from Exception, not RuntimeError, so
  R-level convergence failures were escaping the per-model except block
  and crashing the entire fit_circe() call. Added import and included it
  in the fit_exceptions tuple.

#2 — Guard p-value key access in extract_bfgs_fit
  Direct py_res["chisq"] / py_res["d"] bracket access replaced with
  .get() + None guard so a missing or None key raises a clear diagnostic
  rather than a bare KeyError or scipy TypeError.

#4 — dtype preservation for d and m in mixed error/success DataFrames
  numpy int64 cannot hold NaN, so any error row with "d": None promoted
  the entire column to float64. Fixed by casting n, d, m to
  pd.Int64Dtype() (pandas nullable integer) after building the DataFrame.
  Extended test_fit_circe_error_row_preserves_numeric_dtypes to assert
  integer dtype for all three columns (n, d, m), not just n.

Also: pandera participant field comment (| None vs nullable=True semantics)
and models=[] edge case noted in fit_circe docstring.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants