Skip to content
Snippets Groups Projects
Commit 9687611d authored by hagrid67's avatar hagrid67
Browse files

Merge branch 'rendering' into 'master'

Rendering

See merge request flatland/flatland!4
parents 5b64aba3 a42aed45
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -12,3 +12,7 @@ pytest-runner==4.2
sphinx-rtd-theme==0.4.3
numpy==1.16.2
recordtype==1.3
xarray==0.11.3
matplotlib==3.0.2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flatland.core.env import RailEnv
#from flatland.core.transitions import GridTransitions
import numpy as np
import random
import os
from recordtype import recordtype
import numpy as np
from numpy import array
import xarray as xr
import matplotlib.pyplot as plt
from flatland.core.transitions import RailEnvTransitions
#import flatland.core.env
from flatland.utils import rail_env_generator
from flatland.core.env import RailEnv
import flatland.utils.rendertools as rt
"""Tests for `flatland` package."""
def checkFrozenImage(sFileImage):
sTmpFileImage = "images/test/" + sFileImage
if os.path.exists(sTmpFileImage):
os.remove(sTmpFileImage)
plt.savefig(sTmpFileImage)
bytesFrozenImage = None
for sDir in [ "images/", "images/test/" ]:
sfPath = sDir + sFileImage
with open(sfPath, "rb") as fIn:
bytesImage = fIn.read()
if bytesFrozenImage == None:
bytesFrozenImage = bytesImage
else:
assert(bytesFrozenImage == bytesImage)
def test_render_env():
random.seed(100)
oRail = rail_env_generator.generate_random_rail(10,10)
type(oRail), len(oRail)
oEnv = RailEnv(oRail, number_of_agents=2)
oEnv.reset()
oRT = rt.RenderTool(oEnv)
plt.figure(figsize=(10,10))
oRT.renderEnv()
checkFrozenImage("basic-env.png")
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