From e8500344c1b7212df7a639f41d24a915c629590c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BRIOL?= Date: Wed, 23 Oct 2024 17:29:59 +0200 Subject: [PATCH] Apply pre-commit hooks. --- .pre-commit-config.yaml | 10 +++++----- include/fes/angle/astronomic.hpp | 24 +++++++++++++---------- include/fes/detail/geometry/algorithm.hpp | 4 ++-- include/fes/detail/grid.hpp | 8 ++++---- include/fes/detail/isviewstream.hpp | 4 ++-- include/fes/detail/math.hpp | 4 ++-- include/fes/detail/serialize.hpp | 4 ++-- include/fes/geometry/ecef.hpp | 8 ++++---- include/fes/geometry/triangle.hpp | 8 ++++---- include/fes/mesh/index.hpp | 4 ++-- include/fes/tide.hpp | 12 +++++++----- include/fes/wave/table.hpp | 10 ++++++---- 12 files changed, 54 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8831a3..94c0ab9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-case-conflict - id: check-docstring-first @@ -14,13 +14,13 @@ repos: exclude: docs/make.bat - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: "v3.16.0" + rev: "v3.19.0" hooks: - id: pyupgrade args: [--py310-plus] exclude: setup.py - repo: https://github.com/PyCQA/flake8 - rev: 7.1.0 + rev: 7.1.1 hooks: - id: flake8 exclude: tests @@ -58,12 +58,12 @@ repos: exclude: "leap-seconds.txt" args: [-L inout] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 + rev: v19.1.2 hooks: - id: clang-format exclude: "(dataset.*json)$" - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.13.0 hooks: - id: mypy exclude: docs diff --git a/include/fes/angle/astronomic.hpp b/include/fes/angle/astronomic.hpp index 9f6e8af..faa91a6 100644 --- a/include/fes/angle/astronomic.hpp +++ b/include/fes/angle/astronomic.hpp @@ -365,16 +365,18 @@ class Astronomic { /// @param[in] epoch Desired UTC time in seconds since 1970-01-01T00:00:00Z. /// @param[in] leap_seconds The number of leap seconds since /// 1970-01-01T00:00:00Z. - FES_MATH_CONSTEXPR auto schureman_order1( - const double epoch, const uint16_t leap_seconds) noexcept -> void; + FES_MATH_CONSTEXPR auto schureman_order1(const double epoch, + const uint16_t leap_seconds) noexcept + -> void; /// Calculates the astronomic angles using the Schureman formulae. /// /// @param[in] epoch Desired UTC time in seconds since 1970-01-01T00:00:00Z. /// @param[in] leap_seconds The number of leap seconds since /// 1970-01-01T00:00:00Z. - FES_MATH_CONSTEXPR auto schureman_order3( - const double epoch, const uint16_t leap_seconds) noexcept -> void; + FES_MATH_CONSTEXPR auto schureman_order3(const double epoch, + const uint16_t leap_seconds) noexcept + -> void; /// Calculates the astronomic angles using the Meeus formulae. /// @@ -396,8 +398,8 @@ class Astronomic { /// @param[in] epoch UTC epoch /// @param[in] leap_seconds The number of leap seconds since /// 1970-01-01T00:00:00Z. -constexpr auto utc_2_tdt(const double epoch, - const uint16_t leap_seconds) -> double { +constexpr auto utc_2_tdt(const double epoch, const uint16_t leap_seconds) + -> double { // Number of seconds to add to TAI to get Terrestrial Dynamical Time (TDT) constexpr auto dynamic_time = 32.184; return epoch + static_cast(leap_seconds) + dynamic_time; @@ -474,8 +476,9 @@ auto FES_MATH_CONSTEXPR Astronomic::schureman_order3( } // ///////////////////////////////////////////////////////////////////////////// -FES_MATH_CONSTEXPR auto Astronomic::meeus( - const double epoch, const uint16_t leap_seconds) noexcept -> void { +FES_MATH_CONSTEXPR auto Astronomic::meeus(const double epoch, + const uint16_t leap_seconds) noexcept + -> void { // Number of seconds elapsed since 2000-01-01T12:00:00Z (J2000) to epoch constexpr auto j2000 = 946728000.0; // Julian Ephemeris Millennium @@ -518,8 +521,9 @@ FES_MATH_CONSTEXPR auto Astronomic::meeus( -1.0 / 80053.0, 1.0 / 18999000.0); } -auto FES_MATH_CONSTEXPR Astronomic::update( - const double epoch, const uint16_t leap_seconds) noexcept -> void { +auto FES_MATH_CONSTEXPR Astronomic::update(const double epoch, + const uint16_t leap_seconds) noexcept + -> void { ((*this).*update_)(epoch, leap_seconds); // T mean solar angle relative to Greenwich diff --git a/include/fes/detail/geometry/algorithm.hpp b/include/fes/detail/geometry/algorithm.hpp index a15648b..071fab9 100644 --- a/include/fes/detail/geometry/algorithm.hpp +++ b/include/fes/detail/geometry/algorithm.hpp @@ -19,8 +19,8 @@ namespace geometry { /// @param[in] geometry2 The second geometry. /// @return The distance between the two geometries. template -inline auto distance(const Geometry1& geometry1, - const Geometry2& geometry2) -> double { +inline auto distance(const Geometry1& geometry1, const Geometry2& geometry2) + -> double { return boost::geometry::distance(geometry1, geometry2); } diff --git a/include/fes/detail/grid.hpp b/include/fes/detail/grid.hpp index 77ca32f..f13793d 100644 --- a/include/fes/detail/grid.hpp +++ b/include/fes/detail/grid.hpp @@ -74,15 +74,15 @@ class Grid { /// The index of the element at the given row and column if the grid is /// stored in row-major order. - constexpr auto index_xy(const Eigen::Index x, - const Eigen::Index y) const -> Eigen::Index { + constexpr auto index_xy(const Eigen::Index x, const Eigen::Index y) const + -> Eigen::Index { return x * ny_ + y; } /// The index of the element at the given row and column if the grid is /// stored in column-major order. - constexpr auto index_yx(const Eigen::Index x, - const Eigen::Index y) const -> Eigen::Index { + constexpr auto index_yx(const Eigen::Index x, const Eigen::Index y) const + -> Eigen::Index { return y * nx_ + x; } }; diff --git a/include/fes/detail/isviewstream.hpp b/include/fes/detail/isviewstream.hpp index 1955d84..6641b14 100644 --- a/include/fes/detail/isviewstream.hpp +++ b/include/fes/detail/isviewstream.hpp @@ -60,8 +60,8 @@ class sviewbuf : public std::streambuf { /// @param[in] sp The position to seek to. /// @param[in] which The open mode. /// @return The position in the buffer. - auto seekpos(pos_type sp, - std::ios_base::openmode which) -> pos_type override { + auto seekpos(pos_type sp, std::ios_base::openmode which) + -> pos_type override { return seekoff(sp - pos_type(static_cast(0)), std::ios_base::beg, which); } diff --git a/include/fes/detail/math.hpp b/include/fes/detail/math.hpp index 462d011..8582b63 100644 --- a/include/fes/detail/math.hpp +++ b/include/fes/detail/math.hpp @@ -180,8 +180,8 @@ constexpr auto sincosd(const T& x) noexcept -> std::tuple { template ::value, T>::type* = nullptr> constexpr auto is_almost_zero( - const T& a, - const T& epsilon = std::numeric_limits::epsilon()) noexcept -> bool { + const T& a, const T& epsilon = std::numeric_limits::epsilon()) noexcept + -> bool { return std::fabs(a) < epsilon; } diff --git a/include/fes/detail/serialize.hpp b/include/fes/detail/serialize.hpp index 7ac442d..9671f1d 100644 --- a/include/fes/detail/serialize.hpp +++ b/include/fes/detail/serialize.hpp @@ -38,8 +38,8 @@ auto read_data(detail::isviewstream& ss) -> T { /// @brief Write a string to a stringstream /// @param[in] ss The stringstream to write to /// @param[in] data The string to write -inline auto write_string(std::stringstream& ss, - const std::string& data) -> void { +inline auto write_string(std::stringstream& ss, const std::string& data) + -> void { auto size = data.size(); write_data(ss, size); ss.write(data.data(), data.size()); diff --git a/include/fes/geometry/ecef.hpp b/include/fes/geometry/ecef.hpp index dcd7ac0..75851ca 100644 --- a/include/fes/geometry/ecef.hpp +++ b/include/fes/geometry/ecef.hpp @@ -58,8 +58,8 @@ class EarthCenteredEarthFixed : public ecef_t { inline auto z(const double z) { set<2>(z); } /// Write the ECEF point to a stream. - friend auto operator<<(std::ostream& os, - const EarthCenteredEarthFixed& ecef) -> std::ostream&; + friend auto operator<<(std::ostream& os, const EarthCenteredEarthFixed& ecef) + -> std::ostream&; /// Convert the point to a string representation. explicit inline operator std::string() const { @@ -143,8 +143,8 @@ namespace geometry { /// @param[in,out] os The stream. /// @param[in] ecef The ECEF point. /// @return The stream. -inline auto operator<<(std::ostream& os, - const EarthCenteredEarthFixed& ecef) -> std::ostream& { +inline auto operator<<(std::ostream& os, const EarthCenteredEarthFixed& ecef) + -> std::ostream& { os << "ECEF(" << ecef.x() << " " << ecef.y() << " " << ecef.z() << ")"; return os; } diff --git a/include/fes/geometry/triangle.hpp b/include/fes/geometry/triangle.hpp index 8033a38..63ffc98 100644 --- a/include/fes/geometry/triangle.hpp +++ b/include/fes/geometry/triangle.hpp @@ -111,8 +111,8 @@ class Triangle : public triangle_t { inline auto area() const -> double { return detail::geometry::area(*this); } /// Write the triangle to a stream. - friend auto operator<<(std::ostream &os, - const Triangle &triangle) -> std::ostream &; + friend auto operator<<(std::ostream &os, const Triangle &triangle) + -> std::ostream &; /// Convert the triangle to a string representation. explicit operator std::string() const; @@ -236,8 +236,8 @@ namespace geometry { /// @param[in,out] os The stream. /// @param[in] triangle The triangle. /// @return The stream. -inline auto operator<<(std::ostream &os, - const Triangle &triangle) -> std::ostream & { +inline auto operator<<(std::ostream &os, const Triangle &triangle) + -> std::ostream & { os << boost::geometry::wkt(triangle); return os; } diff --git a/include/fes/mesh/index.hpp b/include/fes/mesh/index.hpp index 39e5d1d..94e84da 100644 --- a/include/fes/mesh/index.hpp +++ b/include/fes/mesh/index.hpp @@ -73,8 +73,8 @@ class Index : public std::enable_shared_from_this { /// @param[in] point The point. /// @param[in] max_distance The maximum distance to the nearest triangle. /// @return The selected triangle. - auto search(const geometry::Point& point, - const double max_distance) const -> SelectedTriangle; + auto search(const geometry::Point& point, const double max_distance) const + -> SelectedTriangle; /// Get the number of positions in the index inline auto n_positions() const noexcept -> size_t { return lon_.size(); } diff --git a/include/fes/tide.hpp b/include/fes/tide.hpp index f67d109..31480c2 100644 --- a/include/fes/tide.hpp +++ b/include/fes/tide.hpp @@ -110,11 +110,13 @@ static auto build_wave_table(const AbstractTidalModel* const tidal_model, /// spectrum (same units as the constituents). /// - The quality of the interpolation (see Quality) template -inline auto evaluate_tide( - const AbstractTidalModel* const tidal_model, const double epoch, - const uint16_t leap_seconds, const double longitude, const double latitude, - wave::Table& wave_table, wave::LongPeriodEquilibrium& long_period, - Accelerator* acc) -> std::tuple { +inline auto evaluate_tide(const AbstractTidalModel* const tidal_model, + const double epoch, const uint16_t leap_seconds, + const double longitude, const double latitude, + wave::Table& wave_table, + wave::LongPeriodEquilibrium& long_period, + Accelerator* acc) + -> std::tuple { // Update the astronomic angle used to evaluate the tidal constituents. const auto& angles = acc->calculate_angle(epoch, leap_seconds); // Adjusts nodal corrections to the tidal estimate date. diff --git a/include/fes/wave/table.hpp b/include/fes/wave/table.hpp index 331df9f..cfe4a15 100644 --- a/include/fes/wave/table.hpp +++ b/include/fes/wave/table.hpp @@ -64,8 +64,9 @@ class TableIterator : public std::iterator_traits { /// @param[in] rhs iterator to compare /// @returns true if the two iterators are equal template - constexpr auto operator==(const TableIterator& - rhs) const noexcept -> bool { + constexpr auto operator==( + const TableIterator& rhs) const noexcept + -> bool { return it_ == rhs.base(); } @@ -73,8 +74,9 @@ class TableIterator : public std::iterator_traits { /// @param[in] rhs iterator to compare /// @returns true if the two iterators are different template - constexpr auto operator!=(const TableIterator& - rhs) const noexcept -> bool { + constexpr auto operator!=( + const TableIterator& rhs) const noexcept + -> bool { return !(*this == rhs); }