Skip to content

Commit

Permalink
Merge branch 'main' into feature-optional-hits
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloVarni authored Nov 19, 2024
2 parents a13c4ad + f2fbbdc commit 7619440
Show file tree
Hide file tree
Showing 65 changed files with 1,174 additions and 602 deletions.
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ DO NOT USE @-MENTIONS HERE!
--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

- Use a *conventional commits* prefix: [quick summary](https://www.conventionalcommits.org/en/v1.0.0/#summary)
- We mostly use `feat`, `fix`, `refactor`, `docs`, `chore` and `build` types.
- A milestone will be assigned by one of the maintainers
10 changes: 10 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ jobs:
- name: Check
run: >
CI/check_spelling
math_macros:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
CI/check_math_macros.py . --exclude "thirdparty/*"
missing_includes:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ clang_tidy:
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_COMPILER=clang
-DPython_EXECUTABLE=$(which python3)
-DACTS_RUN_CLANG_TIDY=ON
-DACTS_BUILD_ODD=OFF
# Main clang-tidy run during cmake compilation
- CI/clang_tidy/run_clang_tidy.sh clang-tidy build
Expand Down Expand Up @@ -168,7 +166,7 @@ build_exatrkx:
# - git clone $CLONE_URL src
# - cd src
# - git checkout $HEAD_SHA
# - pip3 install -r Examples/Python/tests/requirements_ubuntu2004.txt
# - pip3 install -r Examples/Python/tests/requirements.txt
# - nvidia-smi
# - pytest -rFsv -k test_exatrkx

Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ repos:
name: Leftover conflict markers
language: system
entry: git diff --staged --check

- repo: local
hooks:
- id: math_macros
name: math_macros
language: system
entry: CI/check_math_macros.py
files: \.(cpp|hpp|ipp|cu|cuh)$
6 changes: 5 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@
"affiliation": "CERN / University of Amsterdam",
"name": "Stephen Nicholas Swatman",
"orcid": "0000-0002-3747-3229"
}
},
{
"affiliation": "CERN / TU Wien",
"name": "Felix Russo",
"orcid": "0009-0005-8975-2245"
},
{
"affiliation": "UC Berkeley",
"name": "Carlo Varni"
}
],
"access_right": "open",
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ The following people have contributed to the project (in alphabetical order):
- Andreas Stefl, CERN, TU Wien
- Stephen Nicholas Swatman, CERN, University of Amsterdam
- Roman Urmanov, Weizmann Institute of Science
- Carlo Varni, UC Berkeley
120 changes: 120 additions & 0 deletions CI/check_math_macros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import argparse
from fnmatch import fnmatch
import re
import sys


math_constants = [
("M_PI", "std::numbers::pi"),
("M_PI_2", "std::numbers::pi / 2."),
("M_PI_4", "std::numbers::pi / 4."),
("M_1_PI", "std::numbers::inv_pi"),
("M_2_PI", "2. * std::numbers::inv_pi"),
("M_2_SQRTPI", "2. * std::numbers::inv_sqrtpi"),
("M_E", "std::numbers::e"),
("M_LOG2E", "std::numbers::log2e"),
("M_LOG10E", "std::numbers::log10e"),
("M_LN2", "std::numbers::ln2"),
("M_LN10", "std::numbers::ln10"),
("M_SQRT2", "std::numbers::sqrt2"),
("M_SQRT1_2", "1. / std::numbers::sqrt2"),
("M_SQRT3", "std::numbers::sqrt3"),
("M_INV_SQRT3", "std::numbers::inv_sqrt3"),
("M_EGAMMA", "std::numbers::egamma"),
("M_PHI", "std::numbers::phi"),
]


github = "GITHUB_ACTIONS" in os.environ


def handle_file(
file: Path, fix: bool, math_const: tuple[str, str]
) -> list[tuple[int, str]]:
ex = re.compile(rf"(?<!\w){math_const[0]}(?!\w)")

content = file.read_text()
lines = content.splitlines()

changed_lines = []

for i, oline in enumerate(lines):
line, n_subs = ex.subn(rf"{math_const[1]}", oline)
lines[i] = line
if n_subs > 0:
changed_lines.append((i, oline))

if fix and len(changed_lines) > 0:
file.write_text("\n".join(lines) + "\n")

return changed_lines


def main():
p = argparse.ArgumentParser()
p.add_argument("input", nargs="+")
p.add_argument("--fix", action="store_true", help="Attempt to fix M_* macros.")
p.add_argument("--exclude", "-e", action="append", default=[])

args = p.parse_args()

exit_code = 0

inputs = []

if len(args.input) == 1 and os.path.isdir(args.input[0]):
# walk over all files
for root, _, files in os.walk(args.input[0]):
root = Path(root)
for filename in files:
# get the full path of the file
filepath = root / filename
if filepath.suffix not in (
".hpp",
".cpp",
".ipp",
".h",
".C",
".c",
".cu",
".cuh",
):
continue

if any([fnmatch(str(filepath), e) for e in args.exclude]):
continue

inputs.append(filepath)
else:
for file in args.input:
inputs.append(Path(file))

for filepath in inputs:
for math_const in math_constants:
changed_lines = handle_file(
file=filepath, fix=args.fix, math_const=math_const
)
if len(changed_lines) > 0:
exit_code = 1
print()
print(filepath)
for i, oline in changed_lines:
print(f"{i}: {oline}")

if github:
print(
f"::error file={filepath},line={i+1},title=Do not use macro {math_const[0]}::Replace {math_const[0]} with std::{math_const[1]}"
)

if exit_code == 1 and github:
print(f"::info You will need in each flagged file #include <numbers>")

return exit_code


if "__main__" == __name__:
sys.exit(main())
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ authors:
family-names: Russo
affiliation: CERN / TU Wien
orcid: https://orcid.org/0009-0005-8975-2245
- given-names: Carlo
family-names: Varni
affiliation: UC Berkeley
version: 10.0.0
date-released: 2021-07-28
repository-code: https://github.com/acts-project/acts
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ if(ACTS_SETUP_BOOST)
endif()

if(Boost_VERSION VERSION_EQUAL "1.85.0")
set(_boost_version_severity WARNING)
if(ACTS_BUILD_EXAMPLES)
set(_boost_version_severity FATAL_ERROR)
endif()
message(
WARNING
${_boost_version_severity}
"Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
)
endif()
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/ProxyAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ProxyAccessorBase {
/// Create the accessor from a string key
/// @param _key the key
constexpr ProxyAccessorBase(const std::string& _key)
: key{hashString(_key)} {}
: key{hashStringDynamic(_key)} {}

/// Access the stored key on the proxy given as an argument. Mutable version
/// @tparam proxy_t the type of the proxy
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/TrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class TrackContainer {
/// Check if this track container has a specific dynamic column
/// @param key the key to check for
constexpr bool hasColumn(const std::string& key) const {
return m_container->hasColumn_impl(hashString(key));
return m_container->hasColumn_impl(hashStringDynamic(key));
}

/// Check if a this track container has a specific dynamic column
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/TrackProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class TrackProxy {
constexpr T& component(std::string_view key)
requires(!ReadOnly)
{
return m_container->template component<T>(hashString(key), m_index);
return m_container->template component<T>(hashStringDynamic(key), m_index);
}

/// Retrieve a const reference to a component
Expand Down Expand Up @@ -738,7 +738,7 @@ class TrackProxy {
/// @return Const reference to the component given by @p key
template <typename T>
constexpr const T& component(std::string_view key) const {
return m_container->template component<T>(hashString(key), m_index);
return m_container->template component<T>(hashStringDynamic(key), m_index);
}

/// @}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ class TrackStateProxy {
/// @note This might hash the @p key at runtime instead of compile-time
/// @return true if the component exists, false if not
constexpr bool has(std::string_view key) const {
return has(hashString(key));
return has(hashStringDynamic(key));
}

/// Retrieve a mutable reference to a component
Expand Down Expand Up @@ -1135,7 +1135,7 @@ class TrackStateProxy {
constexpr T& component(std::string_view key)
requires(!ReadOnly)
{
return m_traj->template component<T>(hashString(key), m_istate);
return m_traj->template component<T>(hashStringDynamic(key), m_istate);
}

/// Retrieve a const reference to a component
Expand Down Expand Up @@ -1163,7 +1163,7 @@ class TrackStateProxy {
/// @return Const reference to the component given by @p key
template <typename T>
constexpr const T& component(std::string_view key) const {
return m_traj->template component<T>(hashString(key), m_istate);
return m_traj->template component<T>(hashStringDynamic(key), m_istate);
}

/// @}
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/VectorMultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class VectorMultiTrajectory final

template <typename T>
void addColumn_impl(std::string_view key) {
HashedString hashedKey = hashString(key);
HashedString hashedKey = hashStringDynamic(key);
m_dynamic.insert({hashedKey, std::make_unique<detail::DynamicColumn<T>>()});
}

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/VectorTrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class VectorTrackContainer final : public detail_vtc::VectorTrackContainerBase {

template <typename T>
constexpr void addColumn_impl(const std::string_view& key) {
HashedString hashedKey = hashString(key);
HashedString hashedKey = hashStringDynamic(key);
m_dynamic.insert({hashedKey, std::make_unique<detail::DynamicColumn<T>>()});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ class MultiTrajectoryTestsCommon {
auto test = [&](const std::string& col, auto value) {
using T = decltype(value);
std::string col2 = col + "_2";
HashedString h{hashString(col)};
HashedString h2{hashString(col2)};
HashedString h{hashStringDynamic(col)};
HashedString h2{hashStringDynamic(col2)};

trajectory_t traj = m_factory.create();
BOOST_CHECK(!traj.hasColumn(h));
Expand Down Expand Up @@ -1188,7 +1188,7 @@ class MultiTrajectoryTestsCommon {
}
};

runTest([](const std::string& c) { return hashString(c.c_str()); });
runTest([](const std::string& c) { return hashStringDynamic(c.c_str()); });
// runTest([](const std::string& c) { return c.c_str(); });
// runTest([](const std::string& c) { return c; });
// runTest([](std::string_view c) { return c; });
Expand Down
5 changes: 2 additions & 3 deletions Core/include/Acts/EventData/detail/TestSourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ void testSourceLinkCalibratorReturn(
trackState.allocateCalibrated(2);
trackState.template calibrated<2>() = sl.parameters;
trackState.template calibratedCovariance<2>() = sl.covariance;
trackState.template setSubspaceIndices(
std::array{sl.indices[0], sl.indices[1]});
trackState.setSubspaceIndices(std::array{sl.indices[0], sl.indices[1]});
} else if (sl.indices[0] != Acts::eBoundSize) {
trackState.allocateCalibrated(1);
trackState.template calibrated<1>() = sl.parameters.head<1>();
trackState.template calibratedCovariance<1>() =
sl.covariance.topLeftCorner<1, 1>();
trackState.template setSubspaceIndices(std::array{sl.indices[0]});
trackState.setSubspaceIndices(std::array{sl.indices[0]});
} else {
throw std::runtime_error(
"Tried to extract measurement from invalid TestSourceLink");
Expand Down
7 changes: 4 additions & 3 deletions Core/include/Acts/Navigation/TryAllNavigationPolicy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ class TryAllNavigationPolicy final : public INavigationPolicy {
};

/// Constructor from a volume
/// @param config The configuration for the policy
/// @param gctx is the geometry context
/// @param volume is the volume to navigate
/// @param logger is the logger
TryAllNavigationPolicy(const Config& config, const GeometryContext& gctx,
const TrackingVolume& volume, const Logger& logger);
/// @param config The configuration for the policy
TryAllNavigationPolicy(const GeometryContext& gctx,
const TrackingVolume& volume, const Logger& logger,
const Config& config);

/// Constructor from a volume
/// @param gctx is the geometry context
Expand Down
Loading

0 comments on commit 7619440

Please sign in to comment.