Skip to content

Fix bugs identified in code review#63

Merged
virgesmith merged 3 commits into
mainfrom
fix/review-issues
Jun 10, 2026
Merged

Fix bugs identified in code review#63
virgesmith merged 3 commits into
mainfrom
fix/review-issues

Conversation

@virgesmith

Copy link
Copy Markdown
Owner

Summary

  • NDArrayUtils.h: max() was computing the minimum due to a copy-paste error from min() — used std::min and std::numeric_limits<T>::max() (sentinel for a minimum search). Fixed to use std::numeric_limits<T>::lowest() and std::max.
  • module.cpp: fromNDArray() returned a non-owning numpy view into an NDArray whose lifetime ends at the return site, causing a potential use-after-free. Now allocates an owning array and explicitly copies the data.
  • rcpp_api.cpp: Removed duplicate indices.size() != marginals.size() checks in ipf(), qis(), and qisi() — each had the same check twice, with the second being dead code.
  • Log.h: Removed static from the local char buf[] in to_string_impl<T*> to eliminate shared mutable state across calls (not thread-safe).
  • humanleague.R: Fixed two malformed Roxygen \itemize entries where a stray - outside \item{} would render incorrectly in the package documentation.
  • pyproject.toml: Moved pandas-stubs from runtime dependencies to [dependency-groups].dev — it is a typing-only package not needed by end users.

Test plan

  • Run uv run pytest — Python test suite should pass unchanged (no logic changes to algorithms)
  • Run R CMD check — Roxygen fix should produce clean docs; no R logic changed
  • Verify fromNDArray fix: existing Python tests exercise all return paths (qis, qisi, ipf) and would catch memory corruption

🤖 Generated with Claude Code

virgesmith and others added 3 commits May 18, 2026 19:22
- NDArrayUtils.h: max() was computing the minimum (copy-paste from min());
  corrected to use std::numeric_limits<T>::lowest() and std::max
- module.cpp: fromNDArray() returned a non-owning numpy view into a
  soon-to-be-destroyed NDArray; now allocates an owning array and copies
- rcpp_api.cpp: removed duplicate indices/marginals size checks in ipf(),
  qis() and qisi() (first check already throws)
- Log.h: removed static from the local char buffer in to_string_impl<T*>
  to avoid shared mutable state across calls
- humanleague.R: fixed two malformed Roxygen \itemize entries where a
  stray '-' outside \item{} would render incorrectly
- pyproject.toml: moved pandas-stubs to dev dependencies (it is a
  typing-only package and not needed by end users at runtime)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
numpy 2.4.1 -> 2.4.5
pandas 2.3.3 -> 3.0.3
pybind11 3.0.0 -> 3.0.4
pytest 8.1.4 -> 9.0.3
ruff 0.12.9 -> 0.15.13
build 1.2.2.post1 -> 1.5.0
ty 0.0.31 -> 0.0.37
pre-commit 4.5.1 -> 4.6.0
pandas-stubs 2.2.3.250308 -> 3.0.0.260204

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@virgesmith virgesmith merged commit 9ff352d into main Jun 10, 2026
16 checks passed
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.

1 participant