Skip to content

Fix Range copy constructor buffer sizes - #104

Open
bagel786 wants to merge 2 commits into
Farama-Foundation:mainfrom
bagel786:fix/range-copy-size
Open

Fix Range copy constructor buffer sizes#104
bagel786 wants to merge 2 commits into
Farama-Foundation:mainfrom
bagel786:fix/range-copy-size

Conversation

@bagel786

Copy link
Copy Markdown

Summary

Copy the dx and dy integer buffers using sizeof(int) instead of sizeof(bool). The previous byte count truncated copied offsets and could corrupt copied range behavior.

Adds a CircleRange copy regression test covering dimensions, membership, count, and every index-to-offset mapping.

Addresses the Range.h copy-constructor item split out from #65 and tracked in #70. It intentionally makes no dependency or requirements.txt changes, following the maintainer note on #70.

Testing

  • Native CMake build completed successfully.
  • testlib passed.
  • pre-commit run --all-files passed.

Continues #98 — the fork repo backing that PR was accidentally deleted from this account, and GitHub blocks reopening a PR whose submitting repository was deleted (a restore request is being filed with GitHub Support). This PR resumes the identical work from the same commit (587ff2a28d434d531569fe1d7421d51f935c7f84); review discussion continues on the original PR.

Copilot AI lite review requested due to automatic review settings September 11, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The copy constructor still omits the relative-bound members, leaving copied ranges with invalid bounds.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes Range copy-constructor buffer sizing and adds regression coverage for copied ranges.

Changes:

  • Copies dx/dy buffers using sizeof(int).
  • Adds CircleRange copy regression tests.
  • Updates math calls and bumps version to 0.3.5.
File summaries
File Summary
src/gridworld/test.cc Adds copy-constructor regression coverage.
src/gridworld/Range.h Corrects buffer copying; relative-bound members remain omitted from the copy constructor.
magent2/__init__.py Bumps the package version.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/gridworld/Range.h
Comment on lines +31 to +32
memcpy(dx, other.dx, sizeof(int) * width * height);
memcpy(dy, other.dy, sizeof(int) * width * height);
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