Skip to content

Commit

Permalink
Avoid unspecified evaluation order of arguments in as_array
Browse files Browse the repository at this point in the history
  • Loading branch information
jameseh96 committed Jan 28, 2024
1 parent a36c76d commit f9a256c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pypdu/pypdu_conversion_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ void def_conversions(py::module m, py::class_<SampleSource>& cls) {
[](const SampleSource& ss,
TimestampUnits units,
bool filterNaNValues) {
auto samples = std::make_unique<std::vector<Sample>>();
*samples = to_samples(ss);
auto samples = to_samples(ss);

maybeConvertOrFilter(*samples, units, filterNaNValues);
maybeConvertOrFilter(samples, units, filterNaNValues);

return py::array_t(samples->size(),
samples->data(),
py::cast(std::move(samples)));
auto size = samples.size();
auto data = samples.data();

return py::array_t(
size, data, py::cast(std::move(samples)));
},
"timestamp_units"_a = TimestampUnits::Milliseconds,
"filter_nan_values"_a = false);
Expand Down

0 comments on commit f9a256c

Please sign in to comment.