From d43c73f7805b0bc949fd123cdfe18bd6cd3f2b4a Mon Sep 17 00:00:00 2001 From: nsubiron Date: Thu, 31 Jan 2019 17:23:45 +0100 Subject: [PATCH] Fix NaN display for FPS --- PythonAPI/manual_control.py | 6 +++--- PythonAPI/no_rendering_mode.py | 11 +++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/PythonAPI/manual_control.py b/PythonAPI/manual_control.py index 5f66d7b41..a3f0e9d54 100755 --- a/PythonAPI/manual_control.py +++ b/PythonAPI/manual_control.py @@ -336,7 +336,7 @@ class HUD(object): def on_world_tick(self, timestamp): self._server_clock.tick() - self.server_fps = np.nan_to_num(self._server_clock.get_fps()) + self.server_fps = self._server_clock.get_fps() self.frame_number = timestamp.frame_count self.simulation_time = timestamp.elapsed_seconds @@ -356,8 +356,8 @@ class HUD(object): collision = [x / max_col for x in collision] vehicles = world.world.get_actors().filter('vehicle.*') self._info_text = [ - 'Server: % 16d FPS' % self.server_fps, - 'Client: % 16d FPS' % clock.get_fps(), + 'Server: % 16s FPS' % round(self.server_fps), + 'Client: % 16s FPS' % round(clock.get_fps()), '', 'Vehicle: % 20s' % get_actor_display_name(world.player, truncate=20), 'Map: % 20s' % world.world.map_name, diff --git a/PythonAPI/no_rendering_mode.py b/PythonAPI/no_rendering_mode.py index cbf51435c..eeecf4262 100755 --- a/PythonAPI/no_rendering_mode.py +++ b/PythonAPI/no_rendering_mode.py @@ -52,11 +52,6 @@ try: except ImportError: raise RuntimeError('cannot import pygame, make sure pygame package is installed') -try: - import numpy as np -except ImportError: - raise RuntimeError('cannot import numpy, make sure numpy package is installed') - # ============================================================================== # -- Constants ----------------------------------------------------------------- # ============================================================================== @@ -824,10 +819,10 @@ class ModuleWorld(object): else: hero_mode_text = ['Hero Mode: OFF'] - self.server_fps = np.nan_to_num(self.server_clock.get_fps()) + self.server_fps = self.server_clock.get_fps() module_info_text = [ - 'Server: % 16d FPS' % self.server_fps, - 'Client: % 16d FPS' % clock.get_fps(), + 'Server: % 16s FPS' % round(self.server_fps), + 'Client: % 16s FPS' % round(clock.get_fps()), 'Map Name: %10s' % self.world.map_name, ]