Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode error in pyspinw #42

Open
mincentatties opened this issue Aug 11, 2017 · 6 comments
Open

Unicode error in pyspinw #42

mincentatties opened this issue Aug 11, 2017 · 6 comments

Comments

@mincentatties
Copy link

mincentatties commented Aug 11, 2017

{system: MacOS Sierra 10.12.6}

Hi Sandor

After installing pyspinw and trying your sample script I get the following:

Last login: Fri Aug 11 11:31:29 on ttys000
[rosss-imac:~] rossstewart% python3
Python 3.6.2 (default, Jul 17 2017, 16:44:45) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> spinw='/Applications/pyspinw.app/pyspinw.sh'
>>> from transplant import Matlab
>>> from transplant import MatlabStruct
>>> import numpy as np
>>> m=Matlab(spinw)
SpinW process is running...
>>> tri = m.sw_model('triAF',1.)
Preparing 'triAF' model ...
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/site-packages/transplant/transplant_master.py", line 124, in reader
    print(line.decode(), end='')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 41: invalid continuation byte

>>> 

Cheers
Ross

@tsdev tsdev changed the title pyspinw error Unicode error in pyspinw Aug 11, 2017
@tsdev
Copy link
Owner

tsdev commented Aug 11, 2017

This is a problem with the communication between Python and pyspinw. Please download the updated release from here (and remove the original executable from your machine):
https://github.com/tsdev/spinw/releases/tag/v3.0.2py
Now run the code:

tri = m.sw_model('triAF',1.)
m.swpref.setpref('fid',1.)
tri = m.sw_model('triAF',1.)

What did you get? The setting of fid to 1 switches on the text output in pyspinw which caused your problem. It should be 0 by default which removes all text output from pyspinw.

@mincentatties
Copy link
Author

That has fixed the problem. The first time I ran
tri = m.sw_model('triAF',1.)
I got the same error. Then after the fid setting it went away.

Thanks

@tsdev
Copy link
Owner

tsdev commented Aug 11, 2017

Strange, it should have been the opposite way. fid is zero by default, so the first run should be fine, but the second after setting fid to 1 should produce the error. Can you check what is the value of fid right after pyspinw is started by using the command:

m.swpref.getpref('fid')

Thanks!

@mincentatties
Copy link
Author

mincentatties commented Aug 11, 2017 via email

@mincentatties
Copy link
Author

Ok so I now get:

>>> m.swpref.getpref('fid')
{'label': 'file identifier for text output, default value is 1 (Command Window)', 'name': 'fid', 'val': 0.0}

@tsdev
Copy link
Owner

tsdev commented Aug 17, 2017

Thanks! I didn't really solved the problem, just switched of the text output in pyspinw that caused it. I will do some tests to figure out what caused it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants