Skip to content

Commit

Permalink
Auto-format code using Clang-Format (#212)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
github-actions[bot] and actions-user authored Aug 29, 2024
1 parent 7ebb513 commit b72b649
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
8 changes: 5 additions & 3 deletions include/musica/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#define MUSICA_ERROR_CODE_PARSING_FAILED 4

#ifdef __cplusplus
#include <system_error>
#include <yaml-cpp/yaml.h>

#include <system_error>

namespace musica
{

Expand Down Expand Up @@ -62,7 +63,7 @@ namespace musica
{
std::size_t source_;
std::size_t target_;
double scale_factor_ = 1.0; // Scaling factor applied to the source data
double scale_factor_ = 1.0; // Scaling factor applied to the source data
};

/// @brief A struct to represent an array of IndexMappings
Expand Down Expand Up @@ -122,7 +123,8 @@ namespace musica
/// @param target The target array of name-index Mappings
/// @param error The Error to populate if a Mapping is not found
/// @return The array of IndexMappings
IndexMappings CreateIndexMappings(const Configuration configuration, const Mappings source, const Mappings target, Error* error);
IndexMappings
CreateIndexMappings(const Configuration configuration, const Mappings source, const Mappings target, Error* error);

/// @brief Copies data from one array to another using IndexMappings
/// @param mappings The array of IndexMappings
Expand Down
6 changes: 2 additions & 4 deletions src/test/unit/micm/micm_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ void TestSingleGridCell(MICM* micm)
ASSERT_EQ(reaction_rates_ordering.size_, num_user_defined_reaction_rates);
std::size_t jO2_index = FindMappingIndex(reaction_rates_ordering, "PHOTO.jO2", &error);
ASSERT_TRUE(IsSuccess(error));
std::size_t jO3_O_index =
FindMappingIndex(reaction_rates_ordering, "PHOTO.jO3->O", &error);
std::size_t jO3_O_index = FindMappingIndex(reaction_rates_ordering, "PHOTO.jO3->O", &error);
ASSERT_TRUE(IsSuccess(error));
std::size_t jO3_O1D_index =
FindMappingIndex(reaction_rates_ordering, "PHOTO.jO3->O1D", &error);
std::size_t jO3_O1D_index = FindMappingIndex(reaction_rates_ordering, "PHOTO.jO3->O1D", &error);
ASSERT_TRUE(IsSuccess(error));
DeleteMappings(&reaction_rates_ordering);

Expand Down
11 changes: 6 additions & 5 deletions src/test/unit/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ TEST(Util, IndexMappingFromString)
{
Error error = NoError();
Configuration config = LoadConfigurationFromString(
"- source: Test\n"
" target: Test2\n"
"- source: Test2\n"
" target: Test3\n"
" scale factor: 0.82\n", &error);
"- source: Test\n"
" target: Test2\n"
"- source: Test2\n"
" target: Test3\n"
" scale factor: 0.82\n",
&error);
EXPECT_TRUE(IsSuccess(error));
Mappings source_map;
Mappings target_map;
Expand Down
15 changes: 9 additions & 6 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace
{
YAML::Node node_;
};
}
} // namespace

namespace musica
{
Expand Down Expand Up @@ -99,7 +99,7 @@ namespace musica
config.data_ = new YAML::Node(YAML::Load(data));
*error = NoError();
}
catch(const std::exception& e)
catch (const std::exception& e)
{
config.data_ = nullptr;
*error = ToError(MUSICA_ERROR_CATEGORY, MUSICA_ERROR_CODE_PARSING_FAILED, e.what());
Expand All @@ -116,7 +116,7 @@ namespace musica
config.data_ = new YAML::Node(YAML::LoadFile(filename));
*error = NoError();
}
catch(const std::exception& e)
catch (const std::exception& e)
{
config.data_ = nullptr;
*error = ToError(MUSICA_ERROR_CATEGORY, MUSICA_ERROR_CODE_PARSING_FAILED, e.what());
Expand Down Expand Up @@ -170,15 +170,17 @@ namespace musica

void DeleteMappings(Mappings* mappings)
{
if (mappings->mappings_ == nullptr) return;
if (mappings->mappings_ == nullptr)
return;
for (std::size_t i = 0; i < mappings->size_; i++)
{
DeleteMapping(&(mappings->mappings_[i]));
}
delete[] mappings->mappings_;
}

IndexMappings CreateIndexMappings(const Configuration configuration, const Mappings source, const Mappings target, Error* error)
IndexMappings
CreateIndexMappings(const Configuration configuration, const Mappings source, const Mappings target, Error* error)
{
DeleteError(error);
std::size_t size = configuration.data_->size();
Expand Down Expand Up @@ -227,7 +229,8 @@ namespace musica

void DeleteIndexMappings(IndexMappings* mappings)
{
if (mappings->mappings_ == nullptr) return;
if (mappings->mappings_ == nullptr)
return;
for (std::size_t i = 0; i < mappings->size_; i++)
{
DeleteIndexMapping(&(mappings->mappings_[i]));
Expand Down

0 comments on commit b72b649

Please sign in to comment.