Closed tlambert03 closed 1 year ago
I wonder if we shouldn't make the return value of variables[key]
an ilpy.Variable
right away instead of returning the index?
ilpy.Variable
s have an index, and that is precisely the one we need. This would make writing constraints a bit easier, but most importantly
for node, selection_indicator in selection_indicators.items():
# use selection_indicator here
assumes less familiarity with the internals than
for node, index in selection_indicators.items():
# know what to do with an index
Merging #30 (db64ba6) into main (624d903) will decrease coverage by
0.30%
. The diff coverage is100.00%
.
:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.
@@ Coverage Diff @@
## main #30 +/- ##
==========================================
- Coverage 92.77% 92.47% -0.30%
==========================================
Files 30 30
Lines 747 718 -29
==========================================
- Hits 693 664 -29
Misses 54 54
Impacted Files | Coverage Δ | |
---|---|---|
motile/constraints/constraint.py | 100.00% <100.00%> (ø) |
|
motile/constraints/max_children.py | 100.00% <100.00%> (ø) |
|
motile/constraints/max_parents.py | 100.00% <100.00%> (ø) |
|
motile/constraints/select_edge_nodes.py | 100.00% <100.00%> (ø) |
|
motile/costs/features.py | 82.85% <100.00%> (+1.03%) |
:arrow_up: |
motile/solver.py | 96.96% <100.00%> (ø) |
|
motile/variables/node_appear.py | 100.00% <100.00%> (ø) |
|
motile/variables/variable.py | 63.88% <100.00%> (+1.03%) |
:arrow_up: |
This is now ready for review @funkey
Perfect, looks all good. Thanks a lot!
This updates most of the motile constraints and costs to use
ilpy.Expression
introduced in https://github.com/funkelab/ilpy/pull/9 and released in ilpy v0.3.0Another notable (API breaking) change is that indexing into a Variable (i.e.
Variable.__get_item__
) now returns anilpy.Variable
instance, rather than an integer, as per https://github.com/funkelab/motile/pull/30#issuecomment-1483333393. In many cases, thatVariable
can be used exactly as the integer could before (it can be cast to an int withint()
, it can be used as an index in aSolution
, etc...), but it can also be used to create expressions.