convexengineering / gpkit

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

UnicodeEncodeError and pretty printing issues #1453

Closed 1ozturkbe closed 4 years ago

1ozturkbe commented 4 years ago

@bqpd In py3, gpkit has issues for two basic reasons. (easy to see while running tests for py3 on #1452) One is completely to do with pretty printing of exponentials

FAIL: test_repr (gpkit.tests.t_nomials.TestMonomial)
Simple tests for __repr__, which prints more than str
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\Code\gpkit\gpkit\tests\t_nomials.py", line 78, in test_repr
    self.assertEqual(repr(m), 'gpkit.Monomial(5*x^2/y)')
AssertionError: 'gpkit.Monomial(5*x²/y)' != 'gpkit.Monomial(5*x^2/y)'
- gpkit.Monomial(5*x²/y)
?                   ^
+ gpkit.Monomial(5*x^2/y)
?                   ^^

The other is less straightforward, but has to do with pretty printing on small superscripted numbers and of pi.

======================================================================
ERROR: test_sp_to_gp_sweep_mosek_conif (gpkit.tests.t_examples.TestExamples)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\Code\gpkit\gpkit\tests\helpers.py", line 64, in test
    testfn(name, import_dict, path)(self)
  File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\Code\gpkit\gpkit\tests\helpers.py", line 99, in test
    imported[name] = importlib.import_module(name)
  File "C:\Users\Berk\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\Code\gpkit\docs\source\examples\sp_to_gp_sweep.py", line 107, in <module>
    print(sol.summary())
  File "C:\Users\Berk\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03c0' in position 2330: character maps to <undefined>

It seems like pretty printing is a pain in the neck right now, and gets in the way of testing real issues.

bqpd commented 4 years ago

It's been working great so far on https://github.com/convexengineering/gpkit/pull/1463 with macys_vm and reynolds! here's hoping Windows goes okay as well...