question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variable.diff has a couple bugs

See original GitHub issue

Some example behaviour:

In [1]: from gpkit import Variable, Model

In [2]: x = Variable('x')

In [3]: y = Variable('y')

In [4]: c = x + y**2

In [5]: c.diff(x) # works great
Out[5]: gpkit.Monomial(1)

In [6]: c.diff(y) # also works great
Out[6]: gpkit.Monomial(2*y)

In [7]: x.diff(x) # whoops
Out[7]: gpkit.Variable(\fbox{0})

In [8]: x.diff(y) # also whoops
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-169f90b43c09> in <module>()
----> 1 x.diff(y) # also whoops

/Users/philippekirschen/Documents/MIT/Research/GPkit/gpkit/gpkit/nomials/nomial_core.pyc in diff(self, wrt)
    146         Signomial (or Posynomial or Monomial)
    147         """
--> 148         deriv = super(Nomial, self).diff(wrt)
    149         # pylint: disable=unexpected-keyword-arg
    150         return self.__class__(deriv.exps, deriv.cs, require_positive=False)

/Users/philippekirschen/Documents/MIT/Research/GPkit/gpkit/gpkit/nomials/data.pyc in diff(self, var)
     97         NomialData
     98         """
---> 99         var, = self.varkeys[var]
    100         exps, cs = [], []
    101         # var.units may be str if units disabled

ValueError: need more than 0 values to unpack

In [9]: m = Model(x, [x >= 1])

In [10]: m.cost.diff(x) # same problem as before
Out[10]: gpkit.Variable(\fbox{1})

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
whoburgcommented, Apr 7, 2016

+1 I’m guilty too… (for originally implementing the incorrect test that allowed this through)

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug or Not?] Variable and VarHandleOp has different initial ...
Describe the problem. Variable and ResourceVariable has different initial value here. Is it a bug or expect action? # For variables: to lower ......
Read more >
VS2019 Debugger Confused by multiple variables with same ...
I have a C project in VS2019 16.0.1 that includes several source modules that all originated from a single source. They all operate...
Read more >
Doesn't "always initialize variables" lead to important bugs ...
To fix the bug, one has to change the my_read function internally. But there is a different point of view, which is at...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
Defining a covariant equals method for an enumeration value is exceptionally bad practice, since it would likely result in having two different enumeration ......
Read more >
5 common bugs in C programming and how to fix them
Even the best programmers can create programming bugs. ... Consider a sample program that uses a few variables and two arrays:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found