Skip to content

Comments

properly implemented seeding for BinaryFOVSensor (probably)#39

Merged
kenblu24 merged 2 commits intomainfrom
binaryfovsensor-seed
Sep 9, 2025
Merged

properly implemented seeding for BinaryFOVSensor (probably)#39
kenblu24 merged 2 commits intomainfrom
binaryfovsensor-seed

Conversation

@kenblu24
Copy link
Owner

@kenblu24 kenblu24 commented Sep 9, 2025

I didn't update BinaryFOVSensor to use the new seeding system back when I introduced in 6f0ab4c.

Now, BinaryFOVSensor should attempt to seed its own RNG in this order:

  1. seed arg in BinaryFOVSensor.__init__() (or seed in yaml config)
  2. BinaryFOVSensor.parent.rng
  3. BinaryFOVSensor.agent.rng
  4. System time (np.random.default_rng(None))

BinaryFOVSensor.rng is now the rng that should be used within the class/instance, rather than RandomState np.random.random which is now deprecated.

@rvega10
Copy link
Collaborator

rvega10 commented Sep 9, 2025

👍

@kenblu24 kenblu24 requested a review from Copilot September 9, 2025 14:55
@kenblu24 kenblu24 self-assigned this Sep 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements proper seeding for the BinaryFOVSensor class to align with a new seeding system introduced in a previous commit. The changes establish a consistent RNG hierarchy where sensors can inherit random number generators from their parent or agent, falling back to system time if neither is available.

  • Updates BinaryFOVSensor to use the new seeding system by passing seed parameter to parent constructor
  • Replaces deprecated numpy RandomState calls with modern Generator API
  • Adds seeding infrastructure to AbstractSensor base class with fallback hierarchy

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/swarmsim/sensors/BinaryFOVSensor.py Removes manual seed handling, passes seed to parent, updates RNG calls to use self.rng
src/swarmsim/sensors/AbstractSensor.py Adds seed parameter and set_seed method implementing the RNG hierarchy

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kenblu24 kenblu24 merged commit 2d0f679 into main Sep 9, 2025
2 checks passed
@kenblu24 kenblu24 deleted the binaryfovsensor-seed branch October 25, 2025 17:27
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