Skip to content

Commit

Permalink
MORE linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanwm committed Jul 26, 2024
1 parent 28c684e commit 358ce11
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion nuTens/logging.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <stddef.h>
#include <cstddef>

/*! \file logging.hpp
\brief Define the logging utilities for nuTens
Expand Down
4 changes: 2 additions & 2 deletions nuTens/propagator/propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Tensor Propagator::_calculateProbs(const Tensor &energies, const Tensor &massesS
weightMatrix.ones({energies.getBatchDim(), _nGenerations, _nGenerations}, NTdtypes::kComplexFloat)
.requiresGrad(false);

Tensor weightVector =
Tensor::exp(Tensor::div(Tensor::scale(massesSq, -1.0J * _baseline), Tensor::scale(energies, 2.0)));
Tensor weightVector = Tensor::exp(
Tensor::div(Tensor::scale(massesSq, std::complex<float>(-1.0J) * _baseline), Tensor::scale(energies, 2.0)));

for (int i = 0; i < _nGenerations; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions nuTens/propagator/propagator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Propagator

/// @brief Calculate the oscillation probabilities
/// @param energies The energies of the neutrinos
Tensor calculateProbs(const Tensor &energies) const;
[[nodiscard]] Tensor calculateProbs(const Tensor &energies) const;

/// @name Setters
/// @{
Expand Down Expand Up @@ -99,7 +99,7 @@ class Propagator
private:
// For calculating with alternate masses and PMNS, e.g. if using effective
// values from massSolver
Tensor _calculateProbs(const Tensor &energies, const Tensor &masses, const Tensor &PMNS) const;
[[nodiscard]] Tensor _calculateProbs(const Tensor &energies, const Tensor &masses, const Tensor &PMNS) const;

private:
Tensor _PMNSmatrix;
Expand Down
28 changes: 14 additions & 14 deletions nuTens/tensors/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,23 @@ class Tensor
/// @}

/// @brief Get the real part of a complex tensor
Tensor real() const;
[[nodiscard]] Tensor real() const;
/// @brief Get the imaginary part of a complex tensor
Tensor imag() const;
[[nodiscard]] Tensor imag() const;
/// @brief Get the complex conjugate of this tensor. If the underlying tensor
/// is not complex, this will just return the tensor.
Tensor conj() const;
[[nodiscard]] Tensor conj() const;
/// @brief Get elementwise absolute magnitude of a complex tensor
Tensor abs() const;
[[nodiscard]] Tensor abs() const;
/// @brief Get elementwise phases of a complex tensor
Tensor angle() const;
[[nodiscard]] Tensor angle() const;

/// @brief Get the result of summing this tensor over some dimension
/// @param dim The dimension to sum over
Tensor cumsum(int dim) const;
[[nodiscard]] Tensor cumsum(int dim) const;

/// @brief Get the result of summing this tensor over all dimensions
Tensor sum() const;
[[nodiscard]] Tensor sum() const;

/// @name Gradients
/// @{
Expand All @@ -221,7 +221,7 @@ class Tensor

/// @brief Return a tensor containing the accumulated gradients calculated
/// for this tensor after calling backward()
Tensor grad() const;
[[nodiscard]] Tensor grad() const;

/// @}

Expand All @@ -246,7 +246,7 @@ class Tensor
};

/// Print this object to a summary string
std::string toString() const;
[[nodiscard]] std::string toString() const;

/// @brief Set the value at a particular index of the tensor
/// @arg indices The indices of the value to set
Expand All @@ -258,16 +258,16 @@ class Tensor

/// @brief Get the value at a certain entry in the tensor
/// @param indices The index of the entry to get
Tensor getValue(const std::vector<std::variant<int, std::string>> &indices) const;
[[nodiscard]] Tensor getValue(const std::vector<std::variant<int, std::string>> &indices) const;

/// @brief Get the number of dimensions in the tensor
size_t getNdim() const;
[[nodiscard]] size_t getNdim() const;

/// @brief Get the batch dimension size of the tensor
int getBatchDim() const;
[[nodiscard]] int getBatchDim() const;

/// @brief Get the shape of the tensor
std::vector<int> getShape() const;
[[nodiscard]] std::vector<int> getShape() const;

// Defining this here as it has to be in a header due to using template :(
#if USE_PYTORCH
Expand Down Expand Up @@ -297,7 +297,7 @@ class Tensor

#if USE_PYTORCH
public:
inline const torch::Tensor &getTensor() const
[[nodiscard]] inline const torch::Tensor &getTensor() const
{
return _tensor;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/barger-propagator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ class TwoFlavourBarger
};

// characteristic length in vacuum
inline float lv(float energy) const
[[nodiscard]] inline float lv(float energy) const
{
return 4.0 * M_PI * energy / (_m1 * _m1 - _m2 * _m2);
}

// characteristic length in matter
inline float lm() const
[[nodiscard]] inline float lm() const
{
return 2.0 * M_PI / (Constants::Groot2 * _density);
}

// calculate the modified rotation angle
inline float calculateEffectiveAngle(float energy)
[[nodiscard]] inline float calculateEffectiveAngle(float energy) const
{
float ret = NAN;

Expand All @@ -64,7 +64,7 @@ class TwoFlavourBarger
}

// calculate the modified delta M^2
inline float calculateEffectiveDm2(float energy) const
[[nodiscard]] inline float calculateEffectiveDm2(float energy) const
{
float ret = NAN;

Expand Down

1 comment on commit 358ce11

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 18 concern(s)
  • tests/two-flavour-const-matter.cpp:32:5: warning: [cppcoreguidelines-pro-type-member-init]

    uninitialized record type: 'bargerProp'

        TwoFlavourBarger bargerProp;
        ^
                                   {}
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:36:26: warning: 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        for (int i = 0; i <= 20; i++)
                             ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:38:23: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                          ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:38:31: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                  ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:38:48: warning: 20.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                                   ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:38:56: warning: 0.49 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:40:59: warning: 999.9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            bargerProp.setParams(m1, m2, theta, /*baseline=*/-999.9, density);
                                                              ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:66:24: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float effDm2 = (calcV1 - calcV2) * 2.0 * energy;
                           ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:66:44: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float effDm2 = (calcV1 - calcV2) * 2.0 * energy;
                                               ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:69:79: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "effective dM^2 for theta == " + std::to_string(theta), 0.00001)
                                                                                  ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:77:74: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "PMNS[0,0] for theta == " + std::to_string(theta), 0.00001)
                                                                             ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:80:74: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "PMNS[1,1] for theta == " + std::to_string(theta), 0.00001)
                                                                             ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:83:74: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "PMNS[0,1] for theta == " + std::to_string(theta), 0.00001)
                                                                             ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-const-matter.cpp:86:74: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "PMNS[1,0] for theta == " + std::to_string(theta), 0.00001)
                                                                             ^
  • tests/barger.cpp:13:5: warning: [cppcoreguidelines-pro-type-member-init]

    uninitialized record type: 'bargerProp'

        TwoFlavourBarger bargerProp;
        ^
                                   {}
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:21:45: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.0, /*m2=*/2.0, /*theta=*/0.0, baseline);
                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:22:25: warning: 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        for (int i = 0; i < 100; i++)
                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:24:24: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float energy = (float)i * 10.0;
                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:24:35: warning: 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float energy = (float)i * 10.0;
                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:26:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            if (relativeDiff(bargerProp.calculateProb(energy, 0, 0), 1.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:27:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 1, 1), 1.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:28:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 0, 1), 0.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:29:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 1, 0), 0.0) > 0.00001)
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:42:67: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.0, /*m2=*/1.0, /*theta=*/M_PI / 3.0, baseline);
                                                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:43:25: warning: 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        for (int i = 0; i < 100; i++)
                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:45:24: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float energy = (float)i * 10.0;
                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:45:35: warning: 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float energy = (float)i * 10.0;
                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:47:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            if (relativeDiff(bargerProp.calculateProb(energy, 0, 0), 1.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:48:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 1, 1), 1.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:49:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 0, 1), 0.0) > 0.00001 ||
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:50:73: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                relativeDiff(bargerProp.calculateProb(energy, 1, 0), 0.0) > 0.00001)
                                                                            ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:65:45: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.0, /*m2=*/2.0, /*theta=*/M_PI / 8.0,
                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:65:67: warning: 8.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.0, /*m2=*/2.0, /*theta=*/M_PI / 8.0,
                                                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:66:39: warning: 4.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                             /*baseline=*/4.0);
                                          ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:68:44: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 0), 0.64596329086, "probability for alpha == beta == 0", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:68:56: warning: 0.64596329086 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 0), 0.64596329086, "probability for alpha == beta == 0", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:68:109: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 0), 0.64596329086, "probability for alpha == beta == 0", 0.00001)
                                                                                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:70:44: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 1), 0.64596329086, "probability for alpha == beta == 1", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:70:56: warning: 0.64596329086 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 1), 0.64596329086, "probability for alpha == beta == 1", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:70:109: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 1), 0.64596329086, "probability for alpha == beta == 1", 0.00001)
                                                                                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:72:44: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 1), 0.35403670913, "probability for alpha == 0, beta == 1", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:72:56: warning: 0.35403670913 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 1), 0.35403670913, "probability for alpha == 0, beta == 1", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:72:112: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 0, 1), 0.35403670913, "probability for alpha == 0, beta == 1", 0.00001)
                                                                                                                   ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:74:44: warning: 3.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 0), 0.35403670913, "probability for alpha == 1, beta == 0", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:74:56: warning: 0.35403670913 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 0), 0.35403670913, "probability for alpha == 1, beta == 0", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:74:112: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(3.0, 1, 0), 0.35403670913, "probability for alpha == 1, beta == 0", 0.00001)
                                                                                                                   ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:92:33: warning: 1.7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.7, /*m2=*/1.5, /*theta=*/0.24 * M_PI,
                                    ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:92:45: warning: 1.5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.7, /*m2=*/1.5, /*theta=*/0.24 * M_PI,
                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:92:60: warning: 0.24 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        bargerProp.setParams(/*m1=*/1.7, /*m2=*/1.5, /*theta=*/0.24 * M_PI,
                                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:93:39: warning: 6.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                             /*baseline=*/6.0, /*density=*/7.0);
                                          ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:93:56: warning: 7.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                             /*baseline=*/6.0, /*density=*/7.0);
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:95:33: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.lv(5.0), 98.1747704247, "vacuum osc length", 0.00001)
                                    ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:95:39: warning: 98.1747704247 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.lv(5.0), 98.1747704247, "vacuum osc length", 0.00001)
                                          ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:95:75: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.lv(5.0), 98.1747704247, "vacuum osc length", 0.00001)
                                                                              ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:97:36: warning: 5882.49338759 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.lm(), 5882.49338759, "matter osc length", 0.00001)
                                       ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:97:72: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.lm(), 5882.49338759, "matter osc length", 0.00001)
                                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:99:54: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveAngle(5.0), 0.762318391, "effective mixing angle", 0.00001)
                                                         ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:99:60: warning: 0.762318391 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveAngle(5.0), 0.762318391, "effective mixing angle", 0.00001)
                                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:99:99: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveAngle(5.0), 0.762318391, "effective mixing angle", 0.00001)
                                                                                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:101:52: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveDm2(5.0), 0.63941819056, "effective m^2 diff", 0.00001)
                                                       ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:101:58: warning: 0.63941819056 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveDm2(5.0), 0.63941819056, "effective m^2 diff", 0.00001)
                                                             ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:101:95: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateEffectiveDm2(5.0), 0.63941819056, "effective m^2 diff", 0.00001)
                                                                                                  ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:103:44: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 0), 0.96372951684, "probability for alpha == beta == 0", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:103:56: warning: 0.96372951684 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 0), 0.96372951684, "probability for alpha == beta == 0", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:103:109: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 0), 0.96372951684, "probability for alpha == beta == 0", 0.00001)
                                                                                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:105:44: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 1), 0.96372951684, "probability for alpha == beta == 1", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:105:56: warning: 0.96372951684 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 1), 0.96372951684, "probability for alpha == beta == 1", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:105:109: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 1), 0.96372951684, "probability for alpha == beta == 1", 0.00001)
                                                                                                                ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:107:44: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 1), 0.03627048316, "probability for alpha == 0, beta == 1", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:107:56: warning: 0.03627048316 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 1), 0.03627048316, "probability for alpha == 0, beta == 1", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:107:112: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 0, 1), 0.03627048316, "probability for alpha == 0, beta == 1", 0.00001)
                                                                                                                   ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:109:44: warning: 5.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 0), 0.03627048316, "probability for alpha == 1, beta == 0", 0.00001)
                                               ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:109:56: warning: 0.03627048316 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 0), 0.03627048316, "probability for alpha == 1, beta == 0", 0.00001)
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/barger.cpp:109:112: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        TEST_EXPECTED(bargerProp.calculateProb(5.0, 1, 0), 0.03627048316, "probability for alpha == 1, beta == 0", 0.00001)
                                                                                                                   ^
  • tests/two-flavour-vacuum.cpp:29:5: warning: [cppcoreguidelines-pro-type-member-init]

    uninitialized record type: 'bargerProp'

        TwoFlavourBarger bargerProp;
        ^
                                   {}
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:33:25: warning: 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        for (int i = 0; i < 20; i++)
                            ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:35:23: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                          ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:35:31: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                  ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:35:48: warning: 20.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                                   ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:35:56: warning: 0.49 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                                                           ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:53:61: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "probability for alpha == beta == 0", 0.00001)
                                                                ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:56:61: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "probability for alpha == beta == 1", 0.00001)
                                                                ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:59:64: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "probability for alpha == 0, beta == 1", 0.00001)
                                                                   ^
    /home/runner/work/nuTens/nuTens/tests/two-flavour-vacuum.cpp:62:64: warning: 0.00001 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
                          "probability for alpha == 1, beta == 0", 0.00001)
                                                                   ^
  • tests/barger-propagator.hpp:85:18: warning: [readability-make-member-function-const]

    method 'getPMNSelement' can be made const

        inline float getPMNSelement(float energy, int alpha, int beta)
                     ^
                                                                       const
  • tests/barger-propagator.hpp:104:9: warning: [bugprone-branch-clone]

    repeated branch in conditional chain

            {
            ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:106:10: note: end of the original
            }
             ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:108:9: note: clone 1 starts here
            {
            ^
  • tests/barger-propagator.hpp:131:18: warning: [readability-make-member-function-const]

    method 'calculateProb' can be made const

        inline float calculateProb(float energy, int alpha, int beta)
                     ^
                                                                      const
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:152:27: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float sin2Gamma = std::sin(2.0 * gamma);
                              ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:152:36: warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float sin2Gamma = std::sin(2.0 * gamma);
                                       ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:153:24: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float sinPhi = std::sin(dM2 * _baseline / (4.0 * energy));
                           ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:153:52: warning: 4.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
            float sinPhi = std::sin(dM2 * _baseline / (4.0 * energy));
                                                       ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:156:24: warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
            float onAxis = 1.0 - offAxis;
                           ^
  • tests/test-utils.hpp:28:9: warning: [cppcoreguidelines-macro-usage]

    function-like macro 'TEST_EXPECTED' used; consider a 'constexpr' template function

    #define TEST_EXPECTED(value, expectation, varName, threshold)                                                          \
            ^
  • nuTens/logging.hpp:23:9: warning: [cppcoreguidelines-macro-usage]

    macro 'SPDLOG_ACTIVE_LEVEL' used to declare a constant; consider using a 'constexpr' constant

    #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
            ^
  • nuTens/logging.hpp:43:10: error: [clang-diagnostic-error]

    'spdlog/spdlog.h' file not found

    #include "spdlog/spdlog.h"
             ^
  • nuTens/logging.hpp:69:23: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'once' is non-const and globally accessible, consider making it const

    static std::once_flag once;
                          ^
  • nuTens/logging.hpp:86:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_TRACE' used; consider using a 'constexpr' variadic template function

    #define NT_TRACE(...)                                                                                                  \
            ^
  • nuTens/logging.hpp:94:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_DEBUG' used; consider using a 'constexpr' variadic template function

    #define NT_DEBUG(...)                                                                                                  \
            ^
  • nuTens/logging.hpp:102:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_INFO' used; consider using a 'constexpr' variadic template function

    #define NT_INFO(...)                                                                                                   \
            ^
  • nuTens/logging.hpp:110:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_WARN' used; consider using a 'constexpr' variadic template function

    #define NT_WARN(...)                                                                                                   \
            ^
  • nuTens/logging.hpp:118:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_ERROR' used; consider using a 'constexpr' variadic template function

    #define NT_ERROR(...)                                                                                                  \
            ^
  • nuTens/tensors/tensor.hpp:40:5: warning: [modernize-use-using]

    use 'using' instead of 'typedef'

        typedef std::variant<int, std::string> indexType;
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        using indexType = std::variant<int, std::string>
  • nuTens/tensors/tensor.hpp:306:19: warning: [cppcoreguidelines-non-private-member-variables-in-classes]

    member variable '_tensor' has protected visibility

        torch::Tensor _tensor;
                      ^
  • nuTens/propagator/propagator.hpp:105:12: warning: [bugprone-reserved-identifier]

    declaration uses identifier '_PMNSmatrix', which is a reserved identifier

        Tensor _PMNSmatrix;
               ^~~~~~~~~~~
               PMNSmatrix

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.