move nan defaulting out of ndarray to fielddata,tfdata#1160
move nan defaulting out of ndarray to fielddata,tfdata#1160PhilipDeegan wants to merge 1 commit intoPHAREHUB:masterfrom
Conversation
📝 WalkthroughWalkthroughThe PR refactors default value initialization patterns across core data structures by introducing NaN constants for field/tensor initialization, replacing direct value parameters with Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/amr/data/field/field_data.hpp (1)
36-38: Non-canonical declaration specifier order.
auto constexpr staticis valid but unconventional. The idiomatic C++ order isstatic constexpr auto. Same applies to the identical declaration intensor_field_data.hpp(line 44).Suggested fix
- using SetEqualOp = core::Equals<value_type>; - auto constexpr static NaN = std::numeric_limits<value_type>::quiet_NaN(); + using SetEqualOp = core::Equals<value_type>; + static constexpr auto NaN = std::numeric_limits<value_type>::quiet_NaN();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/amr/data/field/field_data.hpp` around lines 36 - 38, Change the non-idiomatic declaration order for the NaN constant: replace the declaration of NaN (currently declared as "auto constexpr static NaN") with the canonical "static constexpr auto NaN" in field_data.hpp, and make the identical change to the matching NaN declaration in tensor_field_data.hpp (the same symbol name NaN) so both use the conventional static constexpr order.src/core/data/grid/grid.hpp (1)
58-64: Dimension check could be unified into therequiresclause.The
requiresclause checks that allDimsare integral, whilestatic_assertchecks the count. Merging both intorequireswould reject mismatched calls at overload resolution rather than inside the body, yielding clearer diagnostics at call sites.Suggested consolidation
template<typename... Dims> Grid(std::string const& name, PhysicalQuantity qty, Dims... dims) - requires(std::is_integral_v<Dims> && ...) + requires(sizeof...(Dims) == dimension && (std::is_integral_v<Dims> && ...)) : Grid{name, qty, std::array{dims...}} { - static_assert(sizeof...(Dims) == dimension, "Invalid dimension"); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/data/grid/grid.hpp` around lines 58 - 64, Update the template constructor Grid(std::string const& name, PhysicalQuantity qty, Dims... dims) so the arity check is part of the requires expression: replace the current requires(std::is_integral_v<Dims> && ...) and remove the in-body static_assert(sizeof...(Dims) == dimension); instead use a combined requires such as requires((std::is_integral_v<Dims> && ...) && (sizeof...(Dims) == dimension)) so overload resolution rejects calls with wrong count or non-integral Dims; keep the delegating initializer : Grid{name, qty, std::array{dims...}} unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/amr/data/field/field_data.hpp`:
- Around line 36-38: Change the non-idiomatic declaration order for the NaN
constant: replace the declaration of NaN (currently declared as "auto constexpr
static NaN") with the canonical "static constexpr auto NaN" in field_data.hpp,
and make the identical change to the matching NaN declaration in
tensor_field_data.hpp (the same symbol name NaN) so both use the conventional
static constexpr order.
In `@src/core/data/grid/grid.hpp`:
- Around line 58-64: Update the template constructor Grid(std::string const&
name, PhysicalQuantity qty, Dims... dims) so the arity check is part of the
requires expression: replace the current requires(std::is_integral_v<Dims> &&
...) and remove the in-body static_assert(sizeof...(Dims) == dimension); instead
use a combined requires such as requires((std::is_integral_v<Dims> && ...) &&
(sizeof...(Dims) == dimension)) so overload resolution rejects calls with wrong
count or non-integral Dims; keep the delegating initializer : Grid{name, qty,
std::array{dims...}} unchanged.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/amr/data/field/field_data.hppsrc/amr/data/tensorfield/tensor_field_data.hppsrc/core/data/grid/grid.hppsrc/core/data/ndarray/ndarray_vector.hpp
configured in ndarrayvector is a bit heavy handed