satisfy linter and type checker in many places
This commit is contained in:
parent
9d21f8c933
commit
fb4da7c768
16 changed files with 38 additions and 26 deletions
|
@ -213,7 +213,7 @@ class AccessPermission(models.Model):
|
|||
access_restriction_ids = set(permissions.keys())
|
||||
|
||||
expire_date = min((e for e in permissions.values() if e), default=timezone.now()+timedelta(seconds=120))
|
||||
cache.set(cache_key, access_restriction_ids, max(0, (expire_date-timezone.now()).total_seconds()))
|
||||
cache.set(cache_key, access_restriction_ids, max(0.0, (expire_date-timezone.now()).total_seconds()))
|
||||
return set(access_restriction_ids)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -343,8 +343,10 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
|
|||
csgraph[area.tmpid, connected_tmpid] = True
|
||||
|
||||
repeat = True
|
||||
|
||||
while repeat:
|
||||
repeat = False
|
||||
# noinspection PyTupleAssignmentBalance
|
||||
distances, predecessors = dijkstra(csgraph, directed=False, return_predecessors=True, unweighted=True)
|
||||
np_areas_with_altitude = np.array(areas_with_altitude, dtype=np.uint32)
|
||||
relevant_distances = distances[np_areas_with_altitude[:, None], np_areas_with_altitude]
|
||||
|
|
|
@ -19,7 +19,7 @@ class AbstractOpenScadElem(ABC):
|
|||
raise NotADirectoryError
|
||||
|
||||
|
||||
class AbstractOpenScadBlock(AbstractOpenScadElem, UserList):
|
||||
class AbstractOpenScadBlock(AbstractOpenScadElem, UserList, ABC):
|
||||
def render_children(self):
|
||||
return '\n'.join(child.render() for child in self.data if child is not None)
|
||||
|
||||
|
@ -290,6 +290,7 @@ class OpenSCADEngine(Base3DEngine):
|
|||
main_building_block.append(obstacles_block)
|
||||
|
||||
if self.min_width and geoms.on_top_of_id is None:
|
||||
# noinspection PyUnboundLocalVariable
|
||||
main_building_block_inner.append(
|
||||
self._add_polygon('min width',
|
||||
self._satisfy_min_width(buildings).intersection(self.bbox).buffer(0),
|
||||
|
|
|
@ -32,7 +32,7 @@ class MapRenderer:
|
|||
|
||||
def render(self, engine_cls, center=True):
|
||||
# add no access restriction to “unlocked“ access restrictions so lookup gets easier
|
||||
access_permissions = self.access_permissions | set([None])
|
||||
access_permissions = self.access_permissions | {None}
|
||||
|
||||
bbox = prepared.prep(self.bbox)
|
||||
|
||||
|
|
4
src/c3nav/mapdata/utils/cache/indexed.py
vendored
4
src/c3nav/mapdata/utils/cache/indexed.py
vendored
|
@ -75,7 +75,7 @@ class GeometryIndexed:
|
|||
self._write_metadata(f)
|
||||
f.write(self.data.tobytes('C'))
|
||||
|
||||
def _write_metadata(cls, f):
|
||||
def _write_metadata(self, f):
|
||||
pass
|
||||
|
||||
def _get_geometry_bounds(self, geometry):
|
||||
|
@ -180,7 +180,9 @@ class GeometryIndexed:
|
|||
int(math.ceil((maxx-minx)/self.resolution))), dtype=np.uint8)
|
||||
|
||||
if self.data.size:
|
||||
# noinspection PyArgumentList
|
||||
minval = min(self.data.min(), 0)
|
||||
# noinspection PyArgumentList
|
||||
maxval = max(self.data.max(), minval+0.01)
|
||||
visible_data = ((self.data.astype(float)-minval)*255/(maxval-minval)).clip(0, 255).astype(np.uint8)
|
||||
image_data[self.y:self.y+height, self.x:self.x+width] = visible_data
|
||||
|
|
21
src/c3nav/mapdata/utils/cache/stats.py
vendored
21
src/c3nav/mapdata/utils/cache/stats.py
vendored
|
@ -59,16 +59,17 @@ fake_request = FakeRequest()
|
|||
|
||||
def convert_stats(stats):
|
||||
stats = [(name.split('__')[1:], value) for name, value in stats['data'].items()]
|
||||
result = {}
|
||||
result['locate'] = convert_locate(_filter_stats('locate', stats))
|
||||
result['location_retrieve'] = convert_location(_filter_stats('location_retrieve', stats))
|
||||
result['location_geometry'] = convert_location(_filter_stats('location_geometry', stats))
|
||||
result['route_origin'] = convert_location(
|
||||
(['pk']+name, value) for name, value in _filter_stats('route_origin_', stats, startswith=True)
|
||||
)
|
||||
result['route_destination'] = convert_location(
|
||||
(['pk'] + name, value) for name, value in _filter_stats('route_destination_', stats, startswith=True)
|
||||
)
|
||||
result = {
|
||||
'locate': convert_locate(_filter_stats('locate', stats)),
|
||||
'location_retrieve': convert_location(_filter_stats('location_retrieve', stats)),
|
||||
'location_geometry': convert_location(_filter_stats('location_geometry', stats)),
|
||||
'route_origin': convert_location(
|
||||
(['pk'] + name, value) for name, value in _filter_stats('route_origin_', stats, startswith=True)
|
||||
),
|
||||
'route_destination': convert_location(
|
||||
(['pk'] + name, value) for name, value in _filter_stats('route_destination_', stats, startswith=True)
|
||||
),
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ def triangulate_rings(rings, holes=None):
|
|||
|
||||
# remove triangles with no area
|
||||
facets = np.dstack((np.zeros(mesh_elements.shape), mesh_points[mesh_elements]))
|
||||
# noinspection PyArgumentList
|
||||
ok_index = np.cross(facets[:, 1] - facets[:, 0], facets[:, 2] - facets[:, 1]).max(axis=1) != 0
|
||||
mesh_elements = mesh_elements[ok_index]
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class MplPolygonPath(MplPathProxy):
|
|||
def shapely_to_mpl(geometry):
|
||||
"""
|
||||
convert a shapely Polygon or Multipolygon to a matplotlib Path
|
||||
:param polygon: shapely Polygon or Multipolygon
|
||||
:param geometry: shapely Polygon or Multipolygon
|
||||
:return: MplPathProxy
|
||||
"""
|
||||
if isinstance(geometry, Polygon):
|
||||
|
|
|
@ -81,7 +81,7 @@ def tile(request, level, zoom, x, y, access_permissions=None):
|
|||
access_permissions = parse_tile_access_cookie(cookie, settings.SECRET_TILE_KEY)
|
||||
access_permissions &= set(level_data.restrictions[minx:maxx, miny:maxy])
|
||||
else:
|
||||
access_permissions = set(int(i) for i in access_permissions.split('-')) - set([0])
|
||||
access_permissions = set(int(i) for i in access_permissions.split('-')) - {0}
|
||||
|
||||
# build cache keys
|
||||
last_update = level_data.history.last_update(minx, miny, maxx, maxy)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue