Comments (10)
Yeah - seeding the RNG is a good idea. I'll push something to master.
from asciimatics.
Interesting... I completely agree that future stability is important, but will struggle to test this as I don't have an openSUSE build env.
First thing to check here is how reproducible this failure is... These tests are for deliberately randomized effects and so sometimes hit failures due to the random seed. If so, I can tweak the warm up for this test to let it run a little before checking output.
Does this always fail like this, or was it a one off?
from asciimatics.
Hmm. I cannot reproduce it anymore, so it probably really is more of a random failure, independent of the date.
Maybe use a fixed random seed then or let the test retry on failure?
from asciimatics.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from asciimatics.
Naughty stalebot! I'll fix this...
from asciimatics.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from asciimatics.
I added random.seed(42)
in various places but still get random failures in TestParticles.test_drop_screen
and test_rain
, unless I do it there:
--- asciimatics-1.14.0.orig/asciimatics/effects.py
+++ asciimatics-1.14.0/asciimatics/effects.py
@@ -12,7 +12,7 @@ from builtins import object
from builtins import range
from future.utils import with_metaclass
from abc import ABCMeta, abstractmethod, abstractproperty
-from random import randint, random, choice
+from random import randint, random, choice, seed
from math import sin, cos, pi
from asciimatics.paths import DynamicPath
from asciimatics.screen import Screen
@@ -54,6 +54,7 @@ class Effect(with_metaclass(ABCMeta, obj
:param stop_frame: Stop index for the effect.
:param delete_count: Number of frames before this effect is deleted.
"""
+ seed(42)
self._screen = screen
self._start_frame = start_frame
self._stop_frame = stop_frame
from asciimatics.
Interesting... Given that the random numbers are deterministic once the seed is set, the only reason it wouldn't follow the same path is because of some systemic difference. Are you running the test with multiple threads, or something like that?
from asciimatics.
My guess is that randomness is used before tests run random.seed(42)
e.g. in
asciimatics/asciimatics/effects.py
Line 509 in 31b3fe5
Which is why it became deterministic when adding it early in asciimatics/effects.py
from asciimatics.
That doesn't quite make sense. Those should only get invoked once the class is constructed (i.e. in the test). I'd also like to avoid seeding inside the real code...
Did you try using the setUp() method of the unittest class to set the seed? Something like this:
class TestParticles(unittest.TestCase):
def setUp(self):
seed(42)
from asciimatics.
Related Issues (20)
- Fatal Error when Multiple Frames in a scene with widgets HOT 3
- Better docs for callbacks
- RadioButton value equals None when set to False HOT 1
- Asciimatics doesn't print anything. HOT 3
- Custom subprocess integration HOT 2
- Load another form after initialization HOT 5
- RayCaster sample "swallows" key when commenting out RayCaster effect HOT 6
- DarkGray access on Windows/Powershell? HOT 7
- Automate user inputs HOT 4
- Leave and re-enter asciimatics mode? HOT 2
- Emojis with "hidden characters"? HOT 11
- particles HOT 4
- Mouse Events in Win11 HOT 4
- Implementing Widget's Custom Color Palettes HOT 4
- Can we donate to the project via Paypal? HOT 3
- New release? HOT 3
- Incompatible with Python 3.12 (imp module removed)
- Support multi-line text rolling in a rect HOT 3
- The effect of selecting the check box in version 1.15.0 is different from that in version 1.14.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciimatics.