convexengineering / gplibrary

Useful subsystem models
MIT License
10 stars 11 forks source link

test() problem with variable definition #18

Closed mjburton11 closed 8 years ago

mjburton11 commented 8 years ago

While trying to write a test function for Breguet Range

    def test(self):
        sol = self.solve()
        R = sol('R')
        M = sol('M')
        LoverD = sol('LoverD')
        TSFC = sol('TSFC')
        W_init = sol('W_{init}')
        W_fuel = sol('W_{fuel}')
        z_bre = sol('z_{bre}')
        t = sol('t')
        g = sol('g')
        a0 = sol('a0')

I got this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-604234e6f176> in <module>()
----> 1 BreguetRange().test()

/Users/mjburton11/Documents/SuperUROP/gpkit/gpkit/models/aircraft/breguet_range.pyc in test(self)
     53         LoverD = sol('LoverD')
     54         TSFC = sol('TSFC')
---> 55         W_init = sol('W_{init}')
     56         W_fuel = sol('W_{fuel}')
     57         z_bre = sol('z_{bre}')

/Users/mjburton11/Documents/SuperUROP/gpkit/gpkit/solution_array.pyc in __call__(self, p)
     58 
     59     def __call__(self, p):
---> 60         return mag(self.subinto(p).c)
     61 
     62     def subinto(self, p):

/Users/mjburton11/Documents/SuperUROP/gpkit/gpkit/solution_array.pyc in subinto(self, p)
     68                              for i in range(len(self))])
     69         else:
---> 70             return p.sub(self["variables"])
     71 
     72     def sens(self, p):

AttributeError: 'str' object has no attribute 'sub'
bqpd commented 8 years ago

Hmm, one of those names might be wrong? This error would occur if a string is not found.

mjburton11 commented 8 years ago

That fixed it! Thanks!