From 60c940d25ef719b7a015394dd68fbab86ffd7d74 Mon Sep 17 00:00:00 2001
From: Dipam Chakraborty <dipamc77@gmail.com>
Date: Tue, 7 Sep 2021 17:42:14 +0530
Subject: [PATCH] city positions generator remove extra assert

---
 flatland/envs/rail_generators.py | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/flatland/envs/rail_generators.py b/flatland/envs/rail_generators.py
index 9c65c6d6..cdd700ce 100644
--- a/flatland/envs/rail_generators.py
+++ b/flatland/envs/rail_generators.py
@@ -323,8 +323,6 @@ class SparseRailGen(RailGen):
         # Borders have to be not allowed from the start
         # allowed_grid == 1 indicates locations that are allowed
         allowed_grid[city_radius_pad1:-city_radius_pad1, city_radius_pad1:-city_radius_pad1] = 1
-        # This tracks the actual city borders
-        city_grid = np.ones((height, width), dtype=np.uint8)
         for _ in range(num_cities):
             allowed_indexes = np.where(allowed_grid == 1)
             num_allowed_points = len(allowed_indexes[0])
@@ -334,10 +332,6 @@ class SparseRailGen(RailGen):
             point_index = np_random.randint(num_allowed_points)
             row = int(allowed_indexes[0][point_index])
             col = int(allowed_indexes[1][point_index])
-            # # All points in the radius of the allowed point should be 1
-            assert np.all(city_grid[row - city_radius_pad1 : row + city_radius_pad1 + 1, 
-                                    col - city_radius_pad1 : col + city_radius_pad1 + 1]), \
-                                    "Sampling Error, Cities overlap"
                                     
                 # Need to block city radius and extra margin so that next sampling is correct                                    
             # Clipping handles the case for negative indexes being generated
@@ -347,13 +341,6 @@ class SparseRailGen(RailGen):
             col_end = col + 2 * city_radius_pad1 + 1
 
             allowed_grid[row_start : row_end, col_start : col_end] = 0
-            
-            # City grids is needed for redundant assertion check above
-            row_start = max(0, row - city_radius_pad1)                
-            col_start = max(0, col - city_radius_pad1)
-            row_end = row + city_radius_pad1 + 1
-            col_end = col + city_radius_pad1 + 1
-            city_grid[row_start : row_end, col_start : col_end] = 0
 
             city_positions.append((row, col))
 
-- 
GitLab