Skip to content
Snippets Groups Projects
Commit 8cf3013c authored by u214892's avatar u214892
Browse files

#169 random guess

parent 39b1a409
No related branches found
No related tags found
No related merge requests found
......@@ -24,13 +24,12 @@ def profile(resource, entry):
cProfile.run('my_func()', sort='time')
if __name__ == '__main__':
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'DELETE' not in entry
# TODO temporarily excluded simple_example_1.py since it hangs in ci - no idea why
and 'simple_example_1.py' not in entry
]:
profile('examples', entry)
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'DELETE' not in entry
# TODO temporarily excluded simple_example_1.py since it hangs in ci - no idea why
and 'simple_example_1.py' not in entry
]:
profile('examples', entry)
......@@ -8,33 +8,25 @@ from importlib_resources import path
from benchmarks.benchmark_utils import swap_attr
# https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python
def str2bool(v):
return v.lower() in ("yes", "true", "t", "1")
if __name__ == '__main__':
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'DELETE' not in entry
# TODO temporarily excluded simple_example_1.py since it hangs in ci - no idea why
and 'simple_example_1.py' not in entry
]:
with path('examples', entry) as file_in:
print("")
print("")
print("")
print("*****************************************************************")
print("Running {}".format(entry))
print("*****************************************************************")
with swap_attr(sys, "stdin", StringIO("q")):
runpy.run_path(file_in, run_name="__main__", init_globals={
'argv': ['--sleep-for-animation=False']
})
print("runpy done.")
print("Done with {}".format(entry))
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'DELETE' not in entry
# TODO temporarily excluded simple_example_1.py since it hangs in ci - no idea why
and 'simple_example_1.py' not in entry
]:
with path('examples', entry) as file_in:
print("")
print("")
print("")
print("*****************************************************************")
print("Running {}".format(entry))
print("*****************************************************************")
with swap_attr(sys, "stdin", StringIO("q")):
runpy.run_path(file_in, run_name="__main__", init_globals={
'argv': ['--sleep-for-animation=False']
})
print("runpy done.")
print("Done with {}".format(entry))
......@@ -5,12 +5,12 @@ import time
import numpy as np
from benchmarks.run_all_examples import str2bool
from flatland.core.grid.grid4_utils import get_new_position
from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import complex_rail_generator
from flatland.envs.schedule_generators import complex_schedule_generator
from flatland.utils.misc import str2bool
from flatland.utils.rendertools import RenderTool
random.seed(100)
......
......@@ -5,13 +5,13 @@ import time
import numpy as np
from benchmarks.run_all_examples import str2bool
from flatland.core.grid.grid_utils import coordinate_to_position
from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.predictions import ShortestPathPredictorForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import complex_rail_generator
from flatland.envs.schedule_generators import complex_schedule_generator
from flatland.utils.misc import str2bool
from flatland.utils.ordered_set import OrderedSet
from flatland.utils.rendertools import RenderTool
......
# https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python
def str2bool(v):
return v.lower() in ("yes", "true", "t", "1")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment