gregmoille / pyLLE

Lugiato Lefever Equation Solver in Python/Julia
Other
65 stars 39 forks source link

Greek letter issue with debugger #9

Closed gregmoille closed 1 year ago

gregmoille commented 5 years ago

Describe the bug

Error with encoding on windows when using the debugger and greeks letters. Might need to write the letter in Latin alphabet instead to fix it

To Reproduce

Need to set the debug option to True on Windows

solver = pyLLE.LLEsolver(sim=sim, res=res, debug=True)
solver.Analyze(plot=True, plottype='all')
solver.Setup() 

Expected behavior

No error while setting up everything

Error or Screenshots

Traceback (most recent call last):
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyLLE\_llesolver.py", line 475, in Setup
    self._logger.info('LLEsovler.Setup', Info)
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyLLE\_llesolver.py", line 76, in info
    open(self.fname,'a').write(mess)
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\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 '\u03b3' in position 142: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\sje\Documents\NIST_files\Programs\Microcombs\Design\pyLLE_test\Example_pyLLE.py", line 25, in <module>
    solver.Setup() # this is where the error occurs
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyLLE\_llesolver.py", line 478, in Setup
    self._logger.info('LLEsovler.Setup', Info)
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyLLE\_llesolver.py", line 76, in info
    open(self.fname,'a').write(mess)
  File "C:\Users\sje\AppData\Local\Programs\Python\Python37-32\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 277: character maps to <undefined>

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

Desktop (please complete the following information):

Quick fix

Set the debugger to False:

solver = pyLLE.LLEsolver(sim=sim, res=res, debug=False)
DanHickstein commented 2 years ago

What's the motivation for the greek letters in the first place? It seems odd to use them, because most people (mysef included) have no idea how to type a gamma on the keyboard...

gregmoille commented 2 years ago

Well... there was literally no real reason to be honest and I went down the rabbit hole to make it prettier with greek letter and that turned into a whole issue. I think with the translator that is coded in the main python file, it doesn't matter, one could either use the "latin" version of the letter (gamma, kappa, etc...) and it should all be automatic. If you notice in the core I actually don't use the greek letter and this is only for the interface so technically we don't need them.

DanHickstein commented 2 years ago

Ha! Okay, I was curious. I had never seen greek letters in code before :). It does give the examples a distinctive look!

gregmoille commented 2 years ago

Interestingly people coding in Julia use a lot of non-standard UTF8 characters, with like the ½, underscript letters, and greek letters. I gave it a shot didn't think python would accept it but was curious that actually, python doesn't even care, even emoji work apparently.

DanHickstein commented 2 years ago

even emoji work apparently.

What?!? This is the best thing that I've learned this month 😊.