Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Nov 4, 2023
1 parent a7742b9 commit 3cbb17b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Solver variables are introduced by inheriting from the following abstract base c

.. automodule:: motile.variables

.. autoclass:: Variable
.. autoclass:: Variables
:members:

The following lists all variables that are already implemented in ``motile``.
Expand Down
12 changes: 6 additions & 6 deletions docs/source/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ graph:
Adding Variables
----------------

Variables in ``motile`` are added by subclassing the :class:`Variable
<motile.variables.Variable>` class. Subclasses need to implement at least a
static method :func:`instantiate <motile.variables.Variable.instantiate>`. This
Variables in ``motile`` are added by subclassing the :class:`Variables
<motile.variables.Variables>` class. Subclasses need to implement at least a
static method :func:`instantiate <motile.variables.Variables.instantiate>`. This
method should return keys for *what* kind of things we would like to create a
variable for. This should be a list of anything that is hashable (the keys will
be used in a dictionary).
Expand All @@ -255,12 +255,12 @@ measure the curvature of a track and put a cost on that.

To create our new variables, we simply return a list of all pairs of edges we
wish to have a variable for in :func:`instantiate
<motile.variables.Variable.instantiate>`. However, declaring those variables
<motile.variables.Variables.instantiate>`. However, declaring those variables
alone is not sufficient. To give them semantic meaning, we also have to make
sure that our edge-pair variables are set to 1 if the two edges they represent
have been selected, and 0 otherwise. To that end, we also add constraints that
are specific to our variables by overriding the :func:`instantiate_constraints
<motile.variables.Variable.instantiate_constraints>` method, such that our
<motile.variables.Variables.instantiate_constraints>` method, such that our
variables are linked to the already existing :class:`EdgeSelected
<motile.variables.EdgeSelected>` variables.

Expand All @@ -272,7 +272,7 @@ The complete variable declaration looks like this:
from motile.variables import EdgeSelected


class EdgePairs(motile.variables.Variable):
class EdgePairs(motile.variables.Variables):

@staticmethod
def instantiate(solver):
Expand Down
2 changes: 1 addition & 1 deletion motile/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def __int__(self) -> int:
__index__ = __int__

def __repr__(self) -> str:
return f"motile.Variable({self.id!r}, index={self.index!r})"
return f"motile.Variables({self.id!r}, index={self.index!r})"

Check warning on line 254 in motile/expressions.py

View check run for this annotation

Codecov / codecov/patch

motile/expressions.py#L254

Added line #L254 was not covered by tests


def _get_ilpy_relation(expr: Expression) -> ilpy.Relation | None:
Expand Down
8 changes: 4 additions & 4 deletions motile/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ def get_variables(self, cls: type[V]) -> V:
created.
Args:
cls (type of :class:`motile.variables.Variable`):
A subclass of :class:`motile.variables.Variable`.
cls (type of :class:`motile.variables.Variables`):
A subclass of :class:`motile.variables.Variables`.
Returns:
A singleton instance of :class:`~motile.variables.Variable` (of whatever
A singleton instance of :class:`~motile.variables.Variables` (of whatever
type was passed in as ``cls``), mimicking a dictionary that can be used to
look up variable indices by their keys. See
:class:`~motile.variables.Variable` for details.
:class:`~motile.variables.Variables` for details.
"""
if cls not in self.variables:
self._add_variables(cls)
Expand Down

0 comments on commit 3cbb17b

Please sign in to comment.