diff --git a/promis/estimators/filters/extended_gmphd.py b/promis/estimators/filters/extended_gmphd.py index 59f0d19..82d1069 100755 --- a/promis/estimators/filters/extended_gmphd.py +++ b/promis/estimators/filters/extended_gmphd.py @@ -22,7 +22,6 @@ class ExtendedGaussianMixturePhd(GaussianMixturePhd): - """The extended gaussian mixture PHD filter for non-linear multi-target tracking. The extended gaussian mixture PHD is a multi target tracker for non-linear state space models. diff --git a/promis/estimators/filters/extended_kalman.py b/promis/estimators/filters/extended_kalman.py index e6ef641..c5299c8 100755 --- a/promis/estimators/filters/extended_kalman.py +++ b/promis/estimators/filters/extended_kalman.py @@ -23,7 +23,6 @@ class ExtendedKalman: - """The extended Kalman filter for non-linear state estimation. This filter behaves similarly to the standard Kalman filter, but utilizes nonlinear diff --git a/promis/estimators/filters/gmphd.py b/promis/estimators/filters/gmphd.py index 023d90f..67ddd4b 100755 --- a/promis/estimators/filters/gmphd.py +++ b/promis/estimators/filters/gmphd.py @@ -22,7 +22,6 @@ class GaussianMixturePhd: - """The gaussian mixture PHD filter for linear multi-target tracking. The gaussian mixture PHD filter is a multi target tracker for linear state space models. diff --git a/promis/estimators/filters/kalman.py b/promis/estimators/filters/kalman.py index e1f4980..e2497fb 100755 --- a/promis/estimators/filters/kalman.py +++ b/promis/estimators/filters/kalman.py @@ -23,7 +23,6 @@ class Kalman: - """The Kalman filter for linear state estimation. The Kalman filter is a single target tracker for linear state space models, i.e. models that diff --git a/promis/estimators/filters/unscented_kalman.py b/promis/estimators/filters/unscented_kalman.py index 07d30f7..17dcd0f 100755 --- a/promis/estimators/filters/unscented_kalman.py +++ b/promis/estimators/filters/unscented_kalman.py @@ -24,7 +24,6 @@ class UnscentedKalman: - """The unscented Kalman filter for non-linear state estimation. This filter behaves similarly to the standard Kalman filter, but utilizes the so-called diff --git a/promis/estimators/smoothers/extended_rts.py b/promis/estimators/smoothers/extended_rts.py index 6877d22..dea333c 100755 --- a/promis/estimators/smoothers/extended_rts.py +++ b/promis/estimators/smoothers/extended_rts.py @@ -23,7 +23,6 @@ class ExtendedRts(ExtendedKalman): - """The Extended RTS smoother for non-linear state estimation. The Extended RTS smoother is a single target state estimator for non-linear diff --git a/promis/estimators/smoothers/rts.py b/promis/estimators/smoothers/rts.py index 0efdb3a..3a312f4 100755 --- a/promis/estimators/smoothers/rts.py +++ b/promis/estimators/smoothers/rts.py @@ -23,7 +23,6 @@ class Rts(Kalman): - """The RTS smoother for linear state estimation. The RTS smoother is a state estimator for linear state space models, i.e. models that diff --git a/promis/estimators/smoothers/unscented_rts.py b/promis/estimators/smoothers/unscented_rts.py index 43677eb..cbd3a94 100755 --- a/promis/estimators/smoothers/unscented_rts.py +++ b/promis/estimators/smoothers/unscented_rts.py @@ -23,7 +23,6 @@ class UnscentedRts(UnscentedKalman): - """The unscented Kalman filter for non-linear state estimation. This filter behaves similarly to the standard Rts smoother, but utilizes the so-called diff --git a/promis/geo/collection.py b/promis/geo/collection.py index cd43fbd..5d06850 100644 --- a/promis/geo/collection.py +++ b/promis/geo/collection.py @@ -76,7 +76,7 @@ def make_latin_hypercube( height: float, number_of_samples: int, number_of_values: int = 1, - include_corners: bool = False + include_corners: bool = False, ) -> "Collection": samples = LatinHypercube(d=2).random(n=number_of_samples) samples = scale(samples, [-width / 2, -height / 2], [width / 2, height / 2]) @@ -559,7 +559,6 @@ def to_cartesian(self) -> CartesianCollection: class HybridInterpolator: - def __init__(self, coordinates, values): self.linear = LinearNDInterpolator(coordinates, values) self.nearest = NearestNDInterpolator(coordinates, values) diff --git a/promis/geo/geospatial.py b/promis/geo/geospatial.py index 167d90b..8306154 100644 --- a/promis/geo/geospatial.py +++ b/promis/geo/geospatial.py @@ -19,7 +19,6 @@ class Geospatial(ABC): - """The common abstract base class for both polar and cartesian geospatial objects. See :meth:`~Geospatial.to_geo_json` on how this class can be used for visualizing geometries. @@ -124,7 +123,7 @@ def to_geo_json( ), ) - def send_to_gui(self, url: str ="http://localhost:8000/add_geojson", timeout: int = 1): + def send_to_gui(self, url: str = "http://localhost:8000/add_geojson", timeout: int = 1): """Send an HTTP POST-request to the GUI backend. Args: diff --git a/promis/geo/helpers.py b/promis/geo/helpers.py index 7cba5b4..96e6cc7 100644 --- a/promis/geo/helpers.py +++ b/promis/geo/helpers.py @@ -68,7 +68,6 @@ class Direction(float, Enum): - """A simple collection of named "compass" bearings in degrees for self-documenting code.""" NORTH = 0.0 diff --git a/promis/geo/location.py b/promis/geo/location.py index 39b8ccc..51a4189 100755 --- a/promis/geo/location.py +++ b/promis/geo/location.py @@ -408,7 +408,7 @@ def to_polar(self, origin: "PolarLocation | None" = None) -> PolarLocation: def distance(self, other: Any) -> float: return cast(float, self.geometry.distance(other.geometry)) - def send_to_gui(self, url = "http://localhost:8000/add_geojson", timeout = 1): + def send_to_gui(self, url="http://localhost:8000/add_geojson", timeout=1): raise NotImplementedError("Cartesian Location does not have geospatial feature to send to gui!") def __repr__(self) -> str: diff --git a/promis/geo/map.py b/promis/geo/map.py index ed771c9..84e3b1f 100755 --- a/promis/geo/map.py +++ b/promis/geo/map.py @@ -205,7 +205,7 @@ def to_cartesian(self) -> "CartesianMap": return CartesianMap(self.origin, cartesian_features) - def send_to_gui(self, url: str ="http://localhost:8000/add_geojson_map", timeout: int = 10): + def send_to_gui(self, url: str = "http://localhost:8000/add_geojson_map", timeout: int = 10): """Send an HTTP POST-request to the GUI backend to add all feature in the map to gui. Args: @@ -221,12 +221,13 @@ def send_to_gui(self, url: str ="http://localhost:8000/add_geojson_map", timeout data = "[" for feature in self.features: data += feature.to_geo_json() - data += ',' + data += "," data = data[:-1] - data += ']' + data += "]" r = post(url=url, data=data, timeout=timeout) r.raise_for_status() + class CartesianMap(Map): """A map containing geospatial objects based on local coordinates with a global reference point. diff --git a/promis/geo/polygon.py b/promis/geo/polygon.py index f818eb9..6b29551 100755 --- a/promis/geo/polygon.py +++ b/promis/geo/polygon.py @@ -435,7 +435,7 @@ def plot(self, axis, **kwargs) -> None: def distance(self, other: Any) -> float: return self.geometry.distance(other.geometry) - def send_to_gui(self, url = "http://localhost:8000/add_geojson", timeout = 1): + def send_to_gui(self, url="http://localhost:8000/add_geojson", timeout=1): raise NotImplementedError("Cartesian Polygon does not have geospatial feature to send to gui!") def __repr__(self) -> str: diff --git a/promis/geo/polyline.py b/promis/geo/polyline.py index 3b44b61..fe4d0b5 100755 --- a/promis/geo/polyline.py +++ b/promis/geo/polyline.py @@ -118,7 +118,6 @@ def to_numpy(self) -> ndarray: class PolarPolyLine(PolyLine): - """A polyline (line string) based on WGS84 coordinates. Note: @@ -211,7 +210,6 @@ def __repr__(self) -> str: class CartesianPolyLine(PolyLine): - """A Cartesian polyline (line string) in local coordinates. Args: @@ -316,7 +314,7 @@ def from_numpy(cls, data: ndarray, *args, **kwargs) -> "CartesianPolyLine": def distance(self, other: Any) -> float: return self.geometry.distance(other.geometry) - def send_to_gui(self, url = "http://localhost:8000/add_geojson", timeout = 1): + def send_to_gui(self, url="http://localhost:8000/add_geojson", timeout=1): raise NotImplementedError("Cartesian PolyLine does not have geospatial feature to send to gui!") def __repr__(self) -> str: diff --git a/promis/geo/raster_band.py b/promis/geo/raster_band.py index f020733..ca767fc 100755 --- a/promis/geo/raster_band.py +++ b/promis/geo/raster_band.py @@ -97,7 +97,7 @@ def search_path( start: tuple[float, float], goal: tuple[float, float], cost_model: Callable[[float], float], - value_filter: Callable[[float], float] + value_filter: Callable[[float], float], ) -> NDArray: """Search the shortest path through this RasterBand using A*. @@ -122,7 +122,7 @@ def heuristic(a, b): tuple(self.get_nearest_coordinate(start)), tuple(self.get_nearest_coordinate(goal)), heuristic=heuristic, - weight='weight' + weight="weight", ) return array(path) diff --git a/promis/loaders/osm_loader.py b/promis/loaders/osm_loader.py index 4697c19..b17a6db 100644 --- a/promis/loaders/osm_loader.py +++ b/promis/loaders/osm_loader.py @@ -28,7 +28,7 @@ def __init__( origin: PolarLocation, dimensions: tuple[float, float], feature_description: dict | None, - timeout: float = 5.0 + timeout: float = 5.0, ): # Initialize Overpass API self.overpass_api = Overpass() diff --git a/promis/logic/solver.py b/promis/logic/solver.py index 81b83ce..9e97158 100644 --- a/promis/logic/solver.py +++ b/promis/logic/solver.py @@ -17,7 +17,6 @@ class Solver: - """A solver for HPLP based ProMis. Args: diff --git a/promis/logic/spatial/relation.py b/promis/logic/spatial/relation.py index 1526ac2..05f87b5 100644 --- a/promis/logic/spatial/relation.py +++ b/promis/logic/spatial/relation.py @@ -241,10 +241,8 @@ def index_to_distributional_clause(self, index: int) -> str: else: relation = f"{self.problog_name}(x_{index}, {self.location_type})" - mean = self.parameters.data['v0'][index] - std = sqrt(clip(self.parameters.data['v1'][index], self.enforced_min_variance, None)) - distribution = ( - f"normal({mean}, {std})" - ) + mean = self.parameters.data["v0"][index] + std = sqrt(clip(self.parameters.data["v1"][index], self.enforced_min_variance, None)) + distribution = f"normal({mean}, {std})" return f"{relation} ~ {distribution}.\n" diff --git a/promis/models/gaussian.py b/promis/models/gaussian.py index 48eaca8..d236c82 100755 --- a/promis/models/gaussian.py +++ b/promis/models/gaussian.py @@ -17,7 +17,6 @@ class Gaussian: - """A weighted multivariate gaussian distribution. Examples: diff --git a/promis/models/gaussian_mixture.py b/promis/models/gaussian_mixture.py index 4b35c73..588027a 100644 --- a/promis/models/gaussian_mixture.py +++ b/promis/models/gaussian_mixture.py @@ -20,7 +20,6 @@ class GaussianMixture: - """The Gaussian Mixture Model (GMM) for representing multi-modal probability distribution. Args: diff --git a/promis/promis.py b/promis/promis.py index f6c7a20..88841c6 100644 --- a/promis/promis.py +++ b/promis/promis.py @@ -141,7 +141,7 @@ def adaptive_solve( batch_size: int = 10, scaler: float = 10.0, interpolation_method: str = "linear", - acquisition_method: str = "entropy" + acquisition_method: str = "entropy", ): """Automatically add support points at locations where the uncertainty is high. diff --git a/promis/star_map.py b/promis/star_map.py index 2efc24f..d2ab26b 100644 --- a/promis/star_map.py +++ b/promis/star_map.py @@ -184,7 +184,7 @@ def adaptive_sample( what: dict[str, Iterable[str | None]] | None = None, scaler: float = 10.0, value_index: int = 0, - acquisition_method: str = "entropy" + acquisition_method: str = "entropy", ): """Automatically add support points at locations where the uncertainty is high. @@ -224,7 +224,7 @@ def value_function(points): number_of_improvement_points=number_of_improvement_points, scaler=scaler, value_index=value_index, - acquisition_method=acquisition_method + acquisition_method=acquisition_method, ) def _make_r_trees(self, location_type: str, number_of_random_maps: int): @@ -242,7 +242,7 @@ def _compute_parameters( relation: str, location_type: str, r_trees: list, - random_maps: list[CartesianMap] + random_maps: list[CartesianMap], ) -> NDArray: # Get the class of the spatial relation relation_class = self.relation_name_to_class(relation) @@ -304,5 +304,5 @@ def sample( # Update collection of sample points self.relations[relation][location_type].parameters.append( coordinates, - self._compute_parameters(coordinates, relation, location_type, r_trees, random_maps) + self._compute_parameters(coordinates, relation, location_type, r_trees, random_maps), ) diff --git a/pyproject.toml b/pyproject.toml index 236c742..134a415 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,14 @@ target-version = "py310" # GitLab CI code quality report output-format = "grouped" +[tool.ruff.format] + +# Quote style for strings: "single" or "double" +quote-style = "double" + +# Automatically format docstrings +docstring-code-format = false + [tool.ruff.lint.pep8-naming] ignore-names = [ "i",