convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

solar sankey example gives UniCodeError #1409

Closed 1ozturkbe closed 5 years ago

1ozturkbe commented 5 years ago

I was refreshing myself on Sankey while thinking about sensitivities by using the code from the documentation and latest of solar, and got a bug.

from gpkit.interactive.sankey import Sankey
Sankey(M).diagram(M.aircraft.Wtotal)

## -- End pasted text --
(objective) adds +1 to the sensitivity of Wtotal_Aircraft
(objective) is Wtotal_Aircraft [lbf]

---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-2-65d24799f665> in <module>()
      1 from gpkit.interactive.sankey import Sankey
----> 2 Sankey(M).diagram(M.aircraft.Wtotal)

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in diagram(self, variables, flowright, width, height, top, bottom, left, right, printing)
    133                 variables = [variables]
    134             for var in variables:
--> 135                 self.varlinks(self.gp[0], var.key, printing=printing)
    136             # if var_eqs were found, label them on the diagram
    137             lookup = {key: i for i, key in

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
     92                     self.varlinks(constr, key, source, printing)
     93                 else:
---> 94                     self.varlinks(constr, key, target, printing)
     95             else:
     96                 if constr not in self.constr_name:

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
     92                     self.varlinks(constr, key, source, printing)
     93                 else:
---> 94                     self.varlinks(constr, key, target, printing)
     95             else:
     96                 if constr not in self.constr_name:

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
     92                     self.varlinks(constr, key, source, printing)
     93                 else:
---> 94                     self.varlinks(constr, key, target, printing)
     95             else:
     96                 if constr not in self.constr_name:

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
     92                     self.varlinks(constr, key, source, printing)
     93                 else:
---> 94                     self.varlinks(constr, key, target, printing)
     95             else:
     96                 if constr not in self.constr_name:

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
     92                     self.varlinks(constr, key, source, printing)
     93                 else:
---> 94                     self.varlinks(constr, key, target, printing)
     95             else:
     96                 if constr not in self.constr_name:

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\interactive\sankey.pyc in varlinks(self, constrset, key, target, printing)
    102                 if printing:
    103                     print ("%s adds %+.3g to the overall sensitivity of %s"
--> 104                            % (source, value, key))
    105                     print source, "is", constr.str_without("units"), "\n"
    106                 if ((isinstance(constr, MonomialEquality)

C:\Users\Berk\Anaconda2\lib\encodings\cp437.pyc in encode(self, input, errors)
     10
     11     def encode(self,input,errors='strict'):
---> 12         return codecs.charmap_encode(input,errors,encoding_map)
     13
     14     def decode(self,input,errors='strict'):

UnicodeEncodeError: 'charmap' codec can't encode character u'\u24b6' in position 0: character maps to <undefined>

Will need to check this out.

bqpd commented 5 years ago

Huh, this works here. Can you reproduce this?

bqpd commented 5 years ago

(1 week ping)

1ozturkbe commented 5 years ago

Hmm, I can't replicate the issue, but my calls for sankey.diagram list the constraints but no figure... very odd. It's likely a local issue on my new machine, since you don't seem to have this problem...

1ozturkbe commented 5 years ago

I confirmed this is the issue with other models as well. Odd...

bqpd commented 5 years ago

yeah. i think i figured out a way to add this to tests, hopefully that'll be done soon

bqpd commented 5 years ago

might be a version thing :(

On Thu, Aug 29, 2019, 14:43 Berk Ozturk notifications@github.com wrote:

I confirmed this is the issue with other models as well. Odd...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/issues/1409?email_source=notifications&email_token=AALKAGGYCMJBORZBCUXGXATQHAKCJA5CNFSM4H4T73OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5POD6A#issuecomment-526311928, or mute the thread https://github.com/notifications/unsubscribe-auth/AALKAGFGTKZKOAM5XGVVV3LQHAKCJANCNFSM4H4T73OA .

1ozturkbe commented 5 years ago

Ugh it's a nightmare...