Skip to content

Commit b4cfae3

Browse files
Merge remote-tracking branch 'origin/HEAD' into energy_term_refactoring
2 parents a1b1ea5 + 40540ba commit b4cfae3

44 files changed

Lines changed: 806 additions & 606 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"C_Cpp.default.cppStandard": "c++11",
2+
"C_Cpp.default.cppStandard": "c++17",
33
"C_Cpp.default.includePath": [
44
"${workspaceFolder}/include",
55
"${workspaceFolder}/build/include",
6+
"${workspaceFolder:OpenGeode}/include",
67
"${workspaceFolder:OpenGeode}/build/opengeode/include",
78
"${workspaceFolder:OpenGeode}/build/third_party/abseil/install/include",
89
"${workspaceFolder:OpenGeode}/build/third_party/bitsery/install/include",
@@ -14,6 +15,7 @@
1415
"${workspaceFolder}/include",
1516
"${workspaceFolder}/src",
1617
"${workspaceFolder}/build/include",
18+
"${workspaceFolder:OpenGeode}/include",
1719
"${workspaceFolder:OpenGeode}/build/opengeode/include",
1820
"${workspaceFolder:OpenGeode}/build/third_party/abseil/install/include",
1921
"${workspaceFolder:OpenGeode}/build/third_party/bitsery/install/include",

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ option(OPENGEODE_STOCHASTIC_WITH_PYTHON "Compile Python bindings" OFF)
3131
# Get MyModule dependencies
3232
find_package(OpenGeode REQUIRED CONFIG)
3333

34+
install(
35+
FILES include/geode/stochastic/project.hpp
36+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/geode/stochastic
37+
COMPONENT public
38+
)
39+
3440
# ------------------------------------------------------------------------------------------------
3541
# Configure the OpenGeode-Stochastic libraries
3642
add_subdirectory(src/geode/stochastic)

bindings/python/src/stochastic/stochastic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
PYBIND11_MODULE( opengeode_stochastic_py_stochastic, module )
3939
{
4040
module.doc() = "OpenGeode-Stochastic Python binding";
41-
pybind11::class_< geode::StochasticLibrary >( module, "StochasticLibrary" )
42-
.def( "initialize", &geode::StochasticLibrary::initialize );
41+
pybind11::class_< geode::OpenGeodeStochasticStochasticLibrary >(
42+
module, "OpenGeodeStochasticStochasticLibrary" )
43+
.def( "initialize",
44+
&geode::OpenGeodeStochasticStochasticLibrary::initialize );
4345

4446
geode::define_spatial_domain( module );
4547

bindings/python/stochastic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
from opengeode_stochastic_py_stochastic import *
2424

25-
StochasticLibrary.initialize()
25+
OpenGeodeStochasticStochasticLibrary.initialize()

commitlint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Configuration = {
1414
"type-empty": [0],
1515
"type-enum": [2, "always", ["feat", "fix", "perf"]],
1616
},
17-
}
17+
defaultIgnores: false,
18+
};
1819

19-
export default Configuration
20+
export default Configuration;

include/geode/stochastic/common.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@
2323

2424
#pragma once
2525

26+
#include <limits>
27+
2628
#include <geode/basic/common.hpp>
2729
#include <geode/basic/library.hpp>
2830
#include <geode/basic/logger.hpp>
2931

3032
#include <geode/stochastic/opengeode_stochastic_stochastic_export.hpp>
33+
#include <geode/stochastic/project.hpp>
3134

3235
namespace geode
3336
{
34-
OPENGEODE_LIBRARY( opengeode_stochastic_stochastic_api, Stochastic );
37+
OPENGEODE_LIBRARY(
38+
opengeode_stochastic_stochastic_api, OpenGeodeStochastic, Stochastic );
3539

3640
static constexpr double LOG_PROB_INVALID =
3741
-std::numeric_limits< double >::infinity();

include/geode/stochastic/models/energy_terms/energy_term.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ namespace geode::detail
4040
{
4141
explicit EnergyScale( double param )
4242
{
43-
OPENGEODE_EXCEPTION( param >= 0.,
44-
"[Gibbs energy term] - The model parameter "
45-
"cannot be negative." );
43+
OpenGeodeStochasticStochasticException::check_exception(
44+
param >= 0., nullptr, OpenGeodeException::TYPE::data,
45+
"[Gibbs energy term] - The model parameter cannot be "
46+
"negative." );
4647

4748
if( param >= geode::GLOBAL_EPSILON )
4849
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2019 - 2026 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#pragma once
25+
26+
#include <geode/basic/assert.hpp>
27+
28+
namespace geode
29+
{
30+
class OpenGeodeStochasticException : public OpenGeodeException
31+
{
32+
protected:
33+
using OpenGeodeException::OpenGeodeException;
34+
};
35+
} // namespace geode

include/geode/stochastic/sampling/direct/object_set_sampler/point_set_sampler.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ namespace geode
4040
: ObjectSetSampler< Point< dimension > >{}, domain_( domain )
4141
{
4242
auto volume = domain_.extended_n_volume();
43-
OPENGEODE_EXCEPTION( volume != 0.,
43+
OpenGeodeStochasticStochasticException::check_exception(
44+
volume != 0., nullptr, OpenGeodeException::TYPE::data,
4445
"[PointSetSampler] - Undefined Extended Bounding "
4546
"Box (volume ==0)." );
4647
this->log_pdf_ = -std::log( volume );
4748
step_move_ = define_step_for_move();
48-
OPENGEODE_EXCEPTION( step_move_ > 0.,
49+
OpenGeodeStochasticStochasticException::check_exception(
50+
step_move_ > 0., nullptr, OpenGeodeException::TYPE::data,
4951
"[PointSetSampler] - Undefined step length for move (value == ",
5052
step_move_, ")." );
5153
}
@@ -73,10 +75,10 @@ namespace geode
7375
new_point =
7476
PointUniformSampler::sample< dimension >( engine, ball );
7577
}
76-
throw OpenGeodeException(
77-
absl::StrCat( "[PointSampler] - Cannot find a point in the "
78-
"extended domain" ) );
79-
return obj;
78+
throw OpenGeodeStochasticStochasticException{ nullptr,
79+
OpenGeodeException::TYPE::internal,
80+
"[PointSampler] - Cannot find a point in the "
81+
"extended domain" };
8082
}
8183

8284
private:

include/geode/stochastic/sampling/direct/object_set_sampler/segment_set_sampler.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ namespace geode
4545
azimuth_{ azimuth }
4646
{
4747
auto volume = domain_.extended_n_volume();
48-
OPENGEODE_EXCEPTION( volume != 0.,
48+
OpenGeodeStochasticStochasticException::check_exception(
49+
volume != 0., nullptr, OpenGeodeException::TYPE::data,
4950
"[SegmentSetSampler] - Undefined Extended Bounding "
5051
"Box (volume ==0)." );
5152
this->log_pdf_ = -std::log( volume );
@@ -83,8 +84,9 @@ namespace geode
8384
}
8485
new_point = PointUniformSampler::sample< 2 >( engine, ball );
8586
}
86-
throw OpenGeodeException( absl::StrCat(
87-
"[SegmentSetSampler] - Cannot find a point in the box" ) );
87+
throw OpenGeodeStochasticStochasticException{ nullptr,
88+
OpenGeodeException::TYPE::internal,
89+
"[SegmentSetSampler] - Cannot find a point in the box" };
8890
return obj;
8991
}
9092

0 commit comments

Comments
 (0)