Skip to content

Commit 4eea2c6

Browse files
committed
Add deprecated NodeBipartite column features
1 parent 1297ea7 commit 4eea2c6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

python/src/ecole/core/observation.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ void bind_submodule(py::module_ const& m) {
102102
"row_features",
103103
&NodeBipartiteObs::row_features,
104104
"A matrix where each row is represents a constraint, and each column a feature of the constraints.")
105+
// FIXME remove in version >0.8
106+
.def_property(
107+
"column_features",
108+
[](py::handle self) {
109+
PyErr_WarnEx(PyExc_DeprecationWarning, "column_features is deprecated, use variable_features.", 1);
110+
return self.attr("variable_features");
111+
},
112+
[](py::handle self, py::handle const val) {
113+
PyErr_WarnEx(PyExc_DeprecationWarning, "column_features is deprecated, use variable_features.", 1);
114+
self.attr("variable_features") = val;
115+
},
116+
"A matrix where each row is represents a variable, and each column a feature of the variables.")
105117
.def_readwrite(
106118
"edge_features",
107119
&NodeBipartiteObs::edge_features,
@@ -129,6 +141,12 @@ void bind_submodule(py::module_ const& m) {
129141
.value("is_basis_upper", NodeBipartiteObs::VariableFeatures::is_basis_upper)
130142
.value("is_basis_zero", NodeBipartiteObs::VariableFeatures ::is_basis_zero);
131143

144+
// FIXME remove in Ecole >0.8
145+
node_bipartite_obs.def_property_readonly_static("ColumnFeatures", [](py::handle self) {
146+
PyErr_WarnEx(PyExc_DeprecationWarning, "ColumnFeatures is deprecated, use VariableFeatures.", 1);
147+
return self.attr("VariableFeatures");
148+
});
149+
132150
py::enum_<NodeBipartiteObs::RowFeatures>(node_bipartite_obs, "RowFeatures")
133151
.value("bias", NodeBipartiteObs::RowFeatures::bias)
134152
.value("objective_cosine_similarity", NodeBipartiteObs::RowFeatures::objective_cosine_similarity)

python/tests/test_observation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def test_Nothing_observation(model):
8787
assert make_obs(ecole.observation.Nothing(), model) is None
8888

8989

90+
# FIXME remove in Ecole >0.8
91+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
9092
def test_NodeBipartite_observation(model):
9193
"""Observation of NodeBipartite is a type with array attributes."""
9294
obs = make_obs(ecole.observation.NodeBipartite(), model)
@@ -100,6 +102,10 @@ def test_NodeBipartite_observation(model):
100102
assert len(obs.VariableFeatures.__members__) == obs.variable_features.shape[1]
101103
assert len(obs.RowFeatures.__members__) == obs.row_features.shape[1]
102104

105+
# FIXME remove in Ecole >0.8
106+
assert_array(obs.column_features, ndim=2)
107+
assert len(obs.ColumnFeatures.__members__) == obs.variable_features.shape[1]
108+
103109

104110
def test_MilpBipartite_observation(model):
105111
"""Observation of MilpBipartite is a type with array attributes."""

0 commit comments

Comments
 (0)