Skip to content

Commit

Permalink
only add gradients if there's truthy tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bqpd committed Apr 27, 2021
1 parent 9bb3990 commit 7f95279
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gpkit/constraints/prog_factories.py
Expand Up @@ -52,8 +52,10 @@ def evaluate_linked(constants, linked):
constants[v] = out
continue # a new fixed variable, not a calculated one
constants[v] = out.x
v.descr["gradients"] = {adn.tag: grad
for adn, grad in out.d().items()}
gradients = {adn.tag:
grad for adn, grad in out.d().items() if adn.tag}
if gradients:
v.descr["gradients"] = gradients
except Exception as exception: # pylint: disable=broad-except
from .. import settings
if settings.get("ad_errors_raise", None):
Expand Down

0 comments on commit 7f95279

Please sign in to comment.