Skip to content

Commit

Permalink
move imports to top
Browse files Browse the repository at this point in the history
  • Loading branch information
whoburg committed Jan 5, 2024
1 parent 384047d commit dd9a776
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gpkit/constraints/set.py
Expand Up @@ -4,9 +4,11 @@
from itertools import chain
import numpy as np
from ..keydict import KeySet, KeyDict
from ..nomials import NomialArray
from ..small_scripts import try_str_without
from ..repr_conventions import ReprMixin
from .single_equation import SingleEquationConstraint
from ..nomials import Variable


def add_meq_bounds(bounded, meq_bounded): #TODO: collapse with GP version?
Expand Down Expand Up @@ -137,9 +139,8 @@ def _choosevar(self, key, variables):
if veckey is None or any(v.key.veckey != veckey for v in othervars):
if not othervars:
return firstvar
raise ValueError("multiple variables are called '%s'; show them"
" with `.variables_byname('%s')`" % (key, key))
from ..nomials import NomialArray # all one vector!
raise ValueError(f"multiple variables are called '{key}'; show them"
f" with `.variables_byname('{key}')`")
arr = NomialArray(np.full(veckey.shape, np.nan, dtype="object"))
for v in variables:
arr[v.key.idx] = v
Expand All @@ -148,7 +149,6 @@ def _choosevar(self, key, variables):

def variables_byname(self, key):
"Get all variables with a given name"
from ..nomials import Variable
return sorted([Variable(k) for k in self.varkeys[key]],
key=_sort_by_name_and_idx)

Expand Down

0 comments on commit dd9a776

Please sign in to comment.