From 8925a1942e02c1982c0d9528728ff459f3b9b231 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Thu, 13 Jun 2024 22:02:19 -0300 Subject: [PATCH] MNT: singleton-comparison != None --- rocketpy/environment/environment.py | 10 +++++----- rocketpy/prints/environment_prints.py | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index cbf939c5c..cb414d610 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -363,7 +363,7 @@ def __init__( self.set_atmospheric_model("standard_atmosphere") # Save date - if date != None: + if date is not None: self.set_date(date, timezone) else: self.date = None @@ -378,7 +378,7 @@ def __init__( # Save latitude and longitude self.latitude = latitude self.longitude = longitude - if latitude != None and longitude != None: + if latitude is not None and longitude is not None: self.set_location(latitude, longitude) else: self.latitude, self.longitude = None, None @@ -664,7 +664,7 @@ def set_elevation(self, elevation="Open-Elevation"): """ if elevation != "Open-Elevation" and elevation != "SRTM": self.elevation = elevation - # elif elevation == "SRTM" and self.latitude != None and self.longitude != None: + # elif elevation == "SRTM" and self.latitude is not None and self.longitude is not None: # # Trigger the authentication flow. # #ee.Authenticate() # # Initialize the library. @@ -3325,9 +3325,9 @@ def all_info_returned(self): surface_air_density=self.density(self.elevation), surface_speed_of_sound=self.speed_of_sound(self.elevation), ) - if self.datetime_date != None: + if self.datetime_date is not None: info["launch_date"] = self.datetime_date.strftime("%Y-%d-%m %H:%M:%S") - if self.latitude != None and self.longitude != None: + if self.latitude is not None and self.longitude is not None: info["lat"] = self.latitude info["lon"] = self.longitude if info["model_type"] in ["Forecast", "Reanalysis", "Ensemble"]: diff --git a/rocketpy/prints/environment_prints.py b/rocketpy/prints/environment_prints.py index 75c3a1e15..2a9e97b43 100644 --- a/rocketpy/prints/environment_prints.py +++ b/rocketpy/prints/environment_prints.py @@ -52,7 +52,7 @@ def launch_site_details(self): print("\nLaunch Site Details\n") time_format = "%Y-%m-%d %H:%M:%S" if ( - self.environment.datetime_date != None + self.environment.datetime_date is not None and "UTC" not in self.environment.timezone ): print( @@ -62,13 +62,16 @@ def launch_site_details(self): self.environment.local_date.strftime(time_format), self.environment.timezone, ) - elif self.environment.datetime_date != None: + elif self.environment.datetime_date is not None: print( "Launch Date:", self.environment.datetime_date.strftime(time_format), "UTC", ) - if self.environment.latitude != None and self.environment.longitude != None: + if ( + self.environment.latitude is not None + and self.environment.longitude is not None + ): print("Launch Site Latitude: {:.5f}°".format(self.environment.latitude)) print("Launch Site Longitude: {:.5f}°".format(self.environment.longitude)) print("Reference Datum: " + self.environment.datum)