Skip to content

Commit 8732d32

Browse files
committed
print local dist info
1 parent 8b9fc9c commit 8732d32

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

src/pyprob_cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(libpyprob_cpp VERSION 0.1 LANGUAGES CXX)
22

3-
set (VERSION "0.1.13")
3+
set (VERSION "0.1.14")
44

55
add_library(pyprob_cpp SHARED src/pyprob_cpp.cpp)
66
target_link_libraries(pyprob_cpp "-ldl")

src/pyprob_cpp/include/pyprob_cpp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <zmq.hpp>
88
#include <random>
99

10-
#define VERSION "0.1.13"
10+
#define VERSION "0.1.14"
1111
#define GIT_BRANCH "master"
12-
#define GIT_COMMIT_HASH "063713e"
12+
#define GIT_COMMIT_HASH "8b9fc9c"
1313

1414
#define NONE_VALUE 17081023.17081023f
1515

src/pyprob_cpp/src/pyprob_cpp.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ namespace pyprob_cpp
4242

4343
if (!zmqSocketConnected)
4444
{
45-
printf("ppx (C++): Warning: Not connected, sampling locally.\n");
45+
printf("ppx (C++): Warning: Not connected. Sampling locally.\n");
46+
std::cout << "ppx (C++): Uniform(low: " << this->low << ", high: " << this->high << ")" << std::endl;
4647
auto n = this->low.size();
4748
xt::xtensor<double, 1> res(std::array<size_t, 1>{n});
4849
for (size_t i = 0; i < n; i++)
@@ -78,7 +79,8 @@ namespace pyprob_cpp
7879
{
7980
if (!zmqSocketConnected)
8081
{
81-
printf("ppx (C++): Warning: Not connected, observing locally.\n");
82+
printf("ppx (C++): Warning: Not connected. Observing locally.\n");
83+
std::cout << "ppx (C++): Uniform(low: " << this->low << ", high: " << this->high << "), value: " << value << std::endl;
8284
return;
8385
}
8486
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -106,7 +108,8 @@ namespace pyprob_cpp
106108
{
107109
if (!zmqSocketConnected)
108110
{
109-
printf("ppx (C++): Warning: Not connected, sampling locally.\n");
111+
printf("ppx (C++): Warning: Not connected. Sampling locally.\n");
112+
std::cout << "ppx (C++): Normal(mean: " << this->mean << ", stddev: " << this->stddev << ")" << std::endl;
110113
auto n = this->mean.size();
111114
xt::xtensor<double, 1> res(std::array<size_t, 1>{n});
112115
for (size_t i = 0; i < n; i++)
@@ -142,7 +145,8 @@ namespace pyprob_cpp
142145
{
143146
if (!zmqSocketConnected)
144147
{
145-
printf("ppx (C++): Warning: Not connected, observing locally.\n");
148+
printf("ppx (C++): Warning: Not connected. Observing locally.\n");
149+
std::cout << "ppx (C++): Normal(mean: " << this->mean << ", stddev: " << this->stddev << "), value: " << value << std::endl;
146150
return;
147151
}
148152
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -169,7 +173,8 @@ namespace pyprob_cpp
169173
{
170174
if (!zmqSocketConnected)
171175
{
172-
printf("ppx (C++): Warning: Not connected, sampling locally.\n");
176+
printf("ppx (C++): Warning: Not connected. Sampling locally.\n");
177+
std::cout << "ppx (C++): Categorical(probs: " << this->probs << ")" << std::endl;
173178
auto res = std::discrete_distribution<int>(this->probs.storage().begin(), this->probs.storage().end())(generator);
174179
return res;
175180
}
@@ -197,7 +202,8 @@ namespace pyprob_cpp
197202
{
198203
if (!zmqSocketConnected)
199204
{
200-
printf("ppx (C++): Warning: Not connected, observing locally.\n");
205+
printf("ppx (C++): Warning: Not connected. Observing locally.\n");
206+
std::cout << "ppx (C++): Categorical(probs: " << this->probs << "), value: " << value << std::endl;
201207
return;
202208
}
203209
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -223,7 +229,8 @@ namespace pyprob_cpp
223229
{
224230
if (!zmqSocketConnected)
225231
{
226-
printf("ppx (C++): Warning: Not connected, sampling locally.\n");
232+
printf("ppx (C++): Warning: Not connected. Sampling locally.\n");
233+
std::cout << "ppx (C++): Poisson(rate: " << this->rate << ")" << std::endl;
227234
auto n = this->rate.size();
228235
xt::xtensor<double, 1> res(std::array<size_t, 1>{n});
229236
for (size_t i = 0; i < n; i++)
@@ -257,7 +264,8 @@ namespace pyprob_cpp
257264
{
258265
if (!zmqSocketConnected)
259266
{
260-
printf("ppx (C++): Warning: Not connected, observing locally.\n");
267+
printf("ppx (C++): Warning: Not connected. Observing locally.\n");
268+
std::cout << "ppx (C++): Poisson(rate: " << this->rate << "), value: " << value << std::endl;
261269
return;
262270
}
263271
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -284,6 +292,7 @@ namespace pyprob_cpp
284292
if (!zmqSocketConnected)
285293
{
286294
printf("ppx (C++): Error: Not connected. Local sampling from Bernoulli not implemented.\n");
295+
std::cout << "ppx (C++): Bernoulli(probs: " << this->probs << ")" << std::endl;
287296
std::exit(EXIT_FAILURE);
288297
}
289298
auto probs = XTensorToTensor(builder, this->probs);
@@ -311,6 +320,7 @@ namespace pyprob_cpp
311320
if (!zmqSocketConnected)
312321
{
313322
printf("ppx (C++): Warning: Not connected, observing locally.\n");
323+
std::cout << "ppx (C++): Bernoulli(probs: " << this->probs << "), value: " << value << std::endl;
314324
return;
315325
}
316326
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -338,6 +348,7 @@ namespace pyprob_cpp
338348
if (!zmqSocketConnected)
339349
{
340350
printf("ppx (C++): Error: Not connected. Local sampling from Beta not implemented.\n");
351+
std::cout << "ppx (C++): Beta(concentration1: " << this->concentration1 << ", concentration0: " << this->concentration0 << ")" << std::endl;
341352
std::exit(EXIT_FAILURE);
342353
}
343354
auto concentration1 = XTensorToTensor(builder, this->concentration1);
@@ -366,6 +377,7 @@ namespace pyprob_cpp
366377
if (!zmqSocketConnected)
367378
{
368379
printf("ppx (C++): Warning: Not connected, observing locally.\n");
380+
std::cout << "ppx (C++): Beta(concentration1: " << this->concentration1 << ", concentration0: " << this->concentration0 << "), value: " << value << std::endl;
369381
return;
370382
}
371383
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -393,6 +405,7 @@ namespace pyprob_cpp
393405
if (!zmqSocketConnected)
394406
{
395407
printf("ppx (C++): Error: Not connected. Local sampling from Exponential not implemented.\n");
408+
std::cout << "ppx (C++): Exponential(rate: " << this->rate << ")" << std::endl;
396409
std::exit(EXIT_FAILURE);
397410
}
398411
auto rate = XTensorToTensor(builder, this->rate);
@@ -420,6 +433,7 @@ namespace pyprob_cpp
420433
if (!zmqSocketConnected)
421434
{
422435
printf("ppx (C++): Warning: Not connected, observing locally.\n");
436+
std::cout << "ppx (C++): Exponential(rate: " << this->rate << "), value: " << value << std::endl;
423437
return;
424438
}
425439
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -447,6 +461,7 @@ namespace pyprob_cpp
447461
if (!zmqSocketConnected)
448462
{
449463
printf("ppx (C++): Error: Not connected. Local sampling from Gamma not implemented.\n");
464+
std::cout << "ppx (C++): Gamma(concentration: " << this->concentration << ", rate: " << this->rate << ")" << std::endl;
450465
std::exit(EXIT_FAILURE);
451466
}
452467
auto concentration = XTensorToTensor(builder, this->concentration);
@@ -475,6 +490,7 @@ namespace pyprob_cpp
475490
if (!zmqSocketConnected)
476491
{
477492
printf("ppx (C++): Warning: Not connected, observing locally.\n");
493+
std::cout << "ppx (C++): Gamma(concentration: " << this->concentration << ", rate: " << this->rate << "), value: " << value << std::endl;
478494
return;
479495
}
480496
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -503,6 +519,7 @@ namespace pyprob_cpp
503519
if (!zmqSocketConnected)
504520
{
505521
printf("ppx (C++): Error: Not connected. Local sampling from LogNormal not implemented.\n");
522+
std::cout << "ppx (C++): LogNormal(loc: " << this->loc << ", scale: " << this->scale << ")" << std::endl;
506523
std::exit(EXIT_FAILURE);
507524
}
508525
auto loc = XTensorToTensor(builder, this->loc);
@@ -531,6 +548,7 @@ namespace pyprob_cpp
531548
if (!zmqSocketConnected)
532549
{
533550
printf("ppx (C++): Warning: Not connected, observing locally.\n");
551+
std::cout << "ppx (C++): LogNormal(loc: " << this->loc << ", scale: " << this->scale << "), value: " << value << std::endl;
534552
return;
535553
}
536554
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -559,6 +577,7 @@ namespace pyprob_cpp
559577
if (!zmqSocketConnected)
560578
{
561579
printf("ppx (C++): Error: Not connected. Local sampling from Binomial not implemented.\n");
580+
std::cout << "ppx (C++): Binomial(total_count: " << this->total_count << ", probs: " << this->probs << ")" << std::endl;
562581
std::exit(EXIT_FAILURE);
563582
}
564583
auto total_count = XTensorToTensor(builder, this->total_count);
@@ -587,6 +606,7 @@ namespace pyprob_cpp
587606
if (!zmqSocketConnected)
588607
{
589608
printf("ppx (C++): Warning: Not connected, observing locally.\n");
609+
std::cout << "ppx (C++): Binomial(total_count: " << this->total_count << ", probs: " << this->probs << "), value: " << value << std::endl;
590610
return;
591611
}
592612
flatbuffers::Offset<ppx::Tensor> val = 0;
@@ -615,6 +635,7 @@ namespace pyprob_cpp
615635
if (!zmqSocketConnected)
616636
{
617637
printf("ppx (C++): Error: Not connected. Local sampling from Weibull not implemented.\n");
638+
std::cout << "ppx (C++): Weibull(scale: " << this->scale << ", concentration: " << this->concentration << ")" << std::endl;
618639
std::exit(EXIT_FAILURE);
619640
}
620641
auto scale = XTensorToTensor(builder, this->scale);
@@ -643,6 +664,7 @@ namespace pyprob_cpp
643664
if (!zmqSocketConnected)
644665
{
645666
printf("ppx (C++): Warning: Not connected, observing locally.\n");
667+
std::cout << "ppx (C++): Weibull(scale: " << this->scale << ", concentration: " << this->concentration << "), value: " << value << std::endl;
646668
return;
647669
}
648670
flatbuffers::Offset<ppx::Tensor> val = 0;

0 commit comments

Comments
 (0)