Skip to content

Commit

Permalink
closing some todos
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Mar 4, 2020
1 parent cdf59fd commit f0bf06d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions gpkit/nomials/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
def nomial_latex_helper(c, pos_vars, neg_vars):
"""Combines (varlatex, exponent) tuples,
separated by positive vs negative exponent, into a single latex string."""
# TODO this is awkward due to sensitivity_map, which needs a refactor
pvarstrs = ['%s^{%.2g}' % (varl, x) if "%.2g" % x != "1" else varl
for (varl, x) in pos_vars]
nvarstrs = ['%s^{%.2g}' % (varl, -x) if "%.2g" % -x != "1" else varl
Expand Down Expand Up @@ -68,9 +67,8 @@ def str_without(self, excluded=()):
mstrs.append(MUL.join(cstr + varstrs))
return " + ".join(sorted(mstrs)) + units

def latex(self, excluded=()):
def latex(self, excluded=()): # TODO: add ast parsing here
"Latex representation, parsing `excluded` just as .str_without does"
# TODO: add ast parsing here
mstrs = []
for exp, c in self.hmap.items():
pos_vars, neg_vars = [], []
Expand Down
7 changes: 1 addition & 6 deletions gpkit/nomials/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,7 @@ def __init__(self, left, right):

def as_hmapslt1(self, substitutions=None):
"Returns the posys <= 1 representation of this constraint."
# TODO: check if it would be a monomial equality after substitutions
raise InvalidGPConstraint("SignomialEquality could not simplify"
" to a PosynomialInequality; try calling"
"`.localsolve` instead of `.solve` to"
" form your Model as a"
" SequentialGeometricProgram")
raise InvalidGPConstraint("SignomialEquality is not GP compatible.")

def as_gpconstr(self, x0):
"Returns GP approximation of an SP constraint at x0"
Expand Down
5 changes: 2 additions & 3 deletions gpkit/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ def of_division(self, numerator, denominator):

def of_product(self, thing1, thing2):
"Cached unit division. Requires united inputs."
# TODO: qty shouldn't be necessary below
mul_units = qty((thing1*thing2).units)
key = id(mul_units)
key = (thing1.units, thing2.units)
try:
return self.multiplication_cache[key]
except KeyError:
mul_units = qty((thing1*thing2).units)
try:
self.multiplication_cache[key] = (None, float(mul_units))
except DimensionalityError:
Expand Down

0 comments on commit f0bf06d

Please sign in to comment.