mesa icon indicating copy to clipboard operation
mesa copied to clipboard

model: Move random seed and random to __init__

Open rht opened this issue 2 years ago • 12 comments

Given that super().__init__() is now necessary for user's model class __init__(), the main motivation: this simplifies the Model construct. And model.random can be initialized with other RNG objects (np.random.default_rng(...), or any other RNG).

Prior discussion https://github.com/projectmesa/mesa/discussions/1938.

This is a breaking change and should wait until Mesa 3.0.

rht avatar Jan 07 '24 00:01 rht

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (0bd4429) 79.87% compared to head (ed9b5aa) 79.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1940      +/-   ##
==========================================
- Coverage   79.87%   79.82%   -0.05%     
==========================================
  Files          15       15              
  Lines        1267     1264       -3     
  Branches      277      277              
==========================================
- Hits         1012     1009       -3     
  Misses        216      216              
  Partials       39       39              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 07 '24 00:01 codecov[bot]

Why would this have to wait for 3.0? I am not sure I understand how this is a breaking change?

quaquel avatar Feb 16 '24 09:02 quaquel

Because this PR requires mandatory model super().__init__, which is an API breaking change. Mesa 2.2.x recommends having model super().__init__(), but is not necessary.

I forgot that #2026 hasn't been released as a patch release. cc: @EwoutH we need #2026 in a patch release so that 2.2.x is backward compatible with 2.1.x.

rht avatar Feb 16 '24 10:02 rht

2.3 is released, so we can start with 3.0 development work, including moving this PR forward!

EwoutH avatar Apr 23 '24 19:04 EwoutH

@jackiekazil This PR looks good; the ruff failure appears to be outside the code change and I assume it will go away once main is merged into it.

catherinedevlin avatar May 20 '24 22:05 catherinedevlin