Skip to content

Commit 7124900

Browse files
committed
Code cleanup
1 parent 4eea2c6 commit 7124900

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

libecole/tests/src/observation/test-nodebipartite.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@ TEST_CASE("NodeBipartite return correct observation", "[obs]") {
4444
}
4545

4646
SECTION("Variable features are not all nan") {
47-
auto const& var_feat = optional_obs.value().variable_features;
48-
for (std::size_t i = 0; i < var_feat.shape()[1]; ++i) {
49-
REQUIRE_FALSE(xt::all(xt::isnan(xt::col(var_feat, static_cast<std::ptrdiff_t>(i)))));
50-
}
47+
auto const& obs = optional_obs.value();
48+
REQUIRE_FALSE(xt::all(xt::isnan(obs.variable_features)));
5149
}
5250

5351
SECTION("Row features are not all nan") {
54-
auto const& row_feat = optional_obs.value().row_features;
55-
for (std::size_t i = 0; i < row_feat.shape()[1]; ++i) {
56-
REQUIRE_FALSE(xt::all(xt::isnan(xt::col(row_feat, static_cast<std::ptrdiff_t>(i)))));
57-
}
52+
auto const& obs = optional_obs.value();
53+
REQUIRE_FALSE(xt::all(xt::isnan(obs.row_features)));
5854
}
5955
}

python/src/ecole/core/observation.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void bind_submodule(py::module_ const& m) {
8585
8686
The optimization problem is represented as an heterogenous bipartite graph.
8787
On one side, a node is associated with one variable, on the other side a node is
88-
associated with one constraint.
88+
associated with one LP row.
8989
There exist an edge between a variable and a constraint if the variable exists in the
9090
constraint with a non-zero coefficient.
9191
@@ -236,13 +236,13 @@ void bind_submodule(py::module_ const& m) {
236236
Strong branching score observation function on branch-and bound node.
237237
238238
This observation obtains scores for all LP or pseudo candidate variables at a
239-
branch-and-bound node. The strong branching score measures the quality of branching
240-
for each variable. This observation can be used as an expert for imitation
241-
learning algorithms.
239+
branch-and-bound node.
240+
The strong branching score measures the quality of branching for each variable.
241+
This observation can be used as an expert for imitation learning algorithms.
242242
243243
This observation function extracts an array containing the strong branching score for
244-
each variable in the problem which can be indexed by the action set. Variables for which
245-
a strong branching score is not applicable are filled with NaN.
244+
each variable in the problem which can be indexed by the action set.
245+
Variables for which a strong branching score is not applicable are filled with ``NaN``.
246246
)");
247247
strong_branching_scores.def(py::init<bool>(), py::arg("pseudo_candidates") = true, R"(
248248
Constructor for StrongBranchingScores.
@@ -269,8 +269,8 @@ void bind_submodule(py::module_ const& m) {
269269
pseudocost branching (also known as hybrid branching).
270270
271271
This observation function extracts an array containing the pseudocost for
272-
each variable in the problem which can be indexed by the action set. Variables for which
273-
a pseudocost is not applicable are filled with NaN.
272+
each variable in the problem which can be indexed by the action set.
273+
Variables for which a pseudocost is not applicable are filled with ``NaN``.
274274
)");
275275
pseudocosts.def(py::init<>());
276276
def_before_reset(pseudocosts, R"(Do nothing.)");
@@ -283,8 +283,8 @@ void bind_submodule(py::module_ const& m) {
283283
284284
The observation is a matrix where rows represent all variables and columns represent features related
285285
to these variables.
286-
Only rows representing pseudo branching candidate contain meaningful observation, other rows are filled with
287-
``NaN``.
286+
Only rows representing pseudo branching candidate contain meaningful observation, other rows are filled
287+
with ``NaN``.
288288
See [Khalil2016]_ for a complete reference on this observation function.
289289
290290
The first :py:attr:`Khalil2016Obs.n_static_features` are static (they do not change through the solving

0 commit comments

Comments
 (0)