Variable.diff has a couple bugs
See original GitHub issueSome 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:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in https://github.com/hoburg/gpkit/commit/8a3656b594d8f0146c238c758d2f1e8f25d3b320
+1 I’m guilty too… (for originally implementing the incorrect test that allowed this through)