wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.21k stars 509 forks source link

TST: Integer division for randint() in makeRandomRectangles() #2508

Closed bnavigator closed 4 months ago

bnavigator commented 4 months ago

Python 3.12 does not accept floats for random.randint() anymore. Use integer division instead.

Fixes #2507

bnavigator commented 4 months ago

You don't seem to run unit tests in your own CI?

swt2c commented 4 months ago

You don't seem to run unit tests in your own CI?

Unfortunately, not. It's something I've been wanting to do for a while, but there's unfortunately some flakiness where some tests randomly fail in CI.

Metallicow commented 4 months ago

round(pos[x], pos[y]) is effectively a particle emitter so to speak..., yes in the GUI sense it should be a integer, but often is a floating point value.

Metallicow commented 4 months ago

BTW random isn't "random" ... also uniform means "missile" ... just a bit of the logic here ...

bnavigator commented 4 months ago

Your remarks are totally irrelevant here. The API of the random module of Python has become stricter and the test code needed an adjustment.

https://docs.python.org/3.12/library/random.html#random.randrange

Metallicow commented 4 months ago

Ah... I see they are using 10. Disregard my comments for py 3.12 since 3.7. I see the comment.

See also

M. Matsumoto and T. Nishimura, “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator”, ACM Transactions on Modeling and Computer Simulation Vol. 8, No. 1, January pp.3–30 1998.

[Complementary-Multiply-with-Carry recipe](https://code.activestate.com/recipes/576707/) for a compatible alternative random number generator with a long period and comparatively simple update operations.
bnavigator commented 4 months ago

I still don't get what you are talking about. This is only a unit test creating pseudo-random rectangles. No need for truly random test data.

Metallicow commented 4 months ago

Your probably right, so disregard.

But yes it is a "pondering" many will cross their minds. Don't disregard that fact.

Thanks

On Tue, Jan 16, 2024, 3:21 PM Ben Greiner @.***> wrote:

I still don't get what you are talking about. This is only a unit test creating pseudo-random rectangles. No need for truly random test data.

— Reply to this email directly, view it on GitHub https://github.com/wxWidgets/Phoenix/pull/2508#issuecomment-1894532104, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDTXRFRUEG2AJPAOKXVISLYO3VOZAVCNFSM6AAAAABBPZTQRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJUGUZTEMJQGQ . You are receiving this because you commented.Message ID: @.***>