Skip to content

Commit

Permalink
update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Nov 2, 2023
1 parent 8ef7d40 commit 108c79e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ ci:
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"

repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.267
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff
args: [--fix]
args: [--fix, --unsafe-fixes]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.6.1
hooks:
- id: mypy
files: "^motile/"
2 changes: 1 addition & 1 deletion docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Do I have to use ``conda``?
---------------------------

Kinda. ``motile`` uses `ilpy <https://github.com/funkelab/ilpy>`_ to solve the
optimzation problem. Conda packages for ``ilpy`` are available for all major
optimization problem. Conda packages for ``ilpy`` are available for all major
platforms, linking against the conda packages for SCIP and Gurobi.

It is possible to not use ``conda``: If you have SCIP or Gurobi installed
Expand Down
2 changes: 1 addition & 1 deletion docs/source/learning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ to the solver.

In the example above, the :class:`motile.variables.EdgeSelected` variable
(which is the target of the cost :class:`motile.costs.EdgeSelection`), has the
follwing weights and features:
following weights and features:

.. math::
\vct{w}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Variables are instantiated and managed by the solver. All we have to do is to
ask the solver for the kind of variables we are interested in via
:func:`Solver.get_variables`. The returned value (e.g., ``node_selected``) is a
dictionary that maps *what* to *where*: in the case of node variables, the
dictionary keys are the nodes themselves (an integer) and the dictionay values
dictionary keys are the nodes themselves (an integer) and the dictionary values
are the indices in the ``solution`` vector where we can find the value of the
variable. Both node and edge indicators are binary variables (one if selected,
zero otherwise).
Expand Down
1 change: 0 additions & 1 deletion motile/costs/disappear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Disappear(Costs):
"""Costs for :class:`motile.variables.NodeDisappear` variables.
Args:
constant (float):
A constant cost for each node that ends a track.
"""
Expand Down
12 changes: 6 additions & 6 deletions motile/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def draw_track_graph(
if position_func is None:

def position_func(node: NodeId) -> float:
return float(graph.nodes[node][position_attribute]) # type: ignore
return float(graph.nodes[node][position_attribute])

alpha_node_func: ReturnsFloat
alpha_edge_func: ReturnsFloat
Expand All @@ -113,10 +113,10 @@ def position_func(node: NodeId) -> float:
if alpha_attribute is not None:

def alpha_node_func(node):
return graph.nodes[node].get(alpha_attribute, 1.0) # type: ignore
return graph.nodes[node].get(alpha_attribute, 1.0)

def alpha_edge_func(edge):
return graph.edges[edge].get(alpha_attribute, 1.0) # type: ignore
return graph.edges[edge].get(alpha_attribute, 1.0)

elif alpha_func is None:

Expand All @@ -135,10 +135,10 @@ def alpha_edge_func(_):
if label_attribute is not None:

def label_node_func(node):
return graph.nodes[node].get(label_attribute, "") # type: ignore
return graph.nodes[node].get(label_attribute, "")

def label_edge_func(edge):
return graph.edges[edge].get(label_attribute, "") # type: ignore
return graph.edges[edge].get(label_attribute, "")

elif label_func is None:

Expand Down Expand Up @@ -339,6 +339,6 @@ def _to_rgba(
return [_to_rgba(color, a) for a in alpha]

# we fake alpha by mixing with white(ish)
# transparancy is tricky...
# transparency is tricky...
r, g, b = tuple(int(c * alpha + 220 * (1.0 - alpha)) for c in color)
return f"rgb({r},{g},{b})"
5 changes: 3 additions & 2 deletions motile/track_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from collections import defaultdict
from typing import TYPE_CHECKING, Any, DefaultDict, Hashable, Iterator

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -45,8 +46,8 @@ def __init__(

self.nodes: dict[NodeId, GraphObject] = {}
self.edges: dict[EdgeId, GraphObject] = {}
self.prev_edges: DefaultDict[NodeId, list[EdgeId]] = DefaultDict(list)
self.next_edges: DefaultDict[NodeId, list[EdgeId]] = DefaultDict(list)
self.prev_edges: defaultdict[NodeId, list[EdgeId]] = DefaultDict(list)
self.next_edges: defaultdict[NodeId, list[EdgeId]] = DefaultDict(list)

if nx_graph:
self.add_from_nx_graph(nx_graph)
Expand Down
7 changes: 4 additions & 3 deletions motile/variables/node_disappear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@


class NodeDisappear(Variable["NodeId"]):
r"""A binary variable for each node that indicates whether the node is the
end of a track (i.e., the node is selected and has no selected outgoing
edges).
r"""Binary variable to indicate whether a node disappears.
This variable indicates whether the node is the end of a track (i.e., the node is
selected and has no selected outgoing edges).
This variable is coupled to the node and edge selection variables through
the following linear constraints:
Expand Down

0 comments on commit 108c79e

Please sign in to comment.