DAMO-DI-ML / AAAI2022-HCM

Source code of AAAI'22 paper: A Hybrid Causal Structure Learning Algorithm for Mixed-type Data
MIT License
37 stars 5 forks source link

A bug named UnicodeDecodeError ,cffi callback #1

Open Jiuyue213 opened 1 year ago

Jiuyue213 commented 1 year ago

Hello, I have two problems when I try to repeat your work. wish your help.

  1. when I try to run the run.py with the oraiginal code, I meet the bug below, and the program doesn't stop itself.

    Exception ignored from cffi callback <function _consolewrite_ex at 0x0000021A73A9EA70>:
    Traceback (most recent call last):
    File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
    s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
    File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
    s = ffi.string(c, maxlen).decode(encoding)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 91: invalid continuation byte
    R[write to console]: 2: 
    R[write to console]: In pgamma(quantile_vec, shape = alpha, scale = beta_vec[i]) :
    R[write to console]: 

    what's that mean? Can you give me some help?

  2. I see your work has used the R packages, so can you tell me how this program link the R packages I installed, should I specified the link_path for them? If yes ,how to do?

Thanks very much ! Looking forward to your reply.

yanlirock commented 1 year ago

Hello, I have two problems when I try to repeat your work. wish your help.

  1. when I try to run the run.py with the oraiginal code, I meet the bug below, and the program doesn't stop itself.
Exception ignored from cffi callback <function _consolewrite_ex at 0x0000021A73A9EA70>:
Traceback (most recent call last):
 File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
   s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
 File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
   s = ffi.string(c, maxlen).decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 91: invalid continuation byte
R[write to console]: 2: 
R[write to console]: In pgamma(quantile_vec, shape = alpha, scale = beta_vec[i]) :
R[write to console]: 

what's that mean? Can you give me some help?

  1. I see your work has used the R packages, so can you tell me how this program link the R packages I installed, should I specified the link_path for them? If yes ,how to do?

Thanks very much ! Looking forward to your reply.

The package use rpy2 to call a R package "momentchi2". You may search to check how to use rpy2 in your own system. And make sure the following code worked correctly first.

import rpy2.robjects.packages as rpackages
momentchi2 = rpackages.importr('momentchi2')

The package has been tested in MAC and Ubuntu but not Windows.

Jiuyue213 commented 1 year ago

Hello, I have two problems when I try to repeat your work. wish your help.

  1. when I try to run the run.py with the oraiginal code, I meet the bug below, and the program doesn't stop itself.
Exception ignored from cffi callback <function _consolewrite_ex at 0x0000021A73A9EA70>:
Traceback (most recent call last):
 File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
   s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
 File "D:\anaconda3\envs\HCM\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
   s = ffi.string(c, maxlen).decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 91: invalid continuation byte
R[write to console]: 2: 
R[write to console]: In pgamma(quantile_vec, shape = alpha, scale = beta_vec[i]) :
R[write to console]: 

what's that mean? Can you give me some help?

  1. I see your work has used the R packages, so can you tell me how this program link the R packages I installed, should I specified the link_path for them? If yes ,how to do?

Thanks very much ! Looking forward to your reply.

The package use rpy2 to call a R package "momentchi2". You may search to check how to use rpy2 in your own system. And make sure the following code worked correctly first.

import rpy2.robjects.packages as rpackages
momentchi2 = rpackages.importr('momentchi2')

The package has been tested in MAC and Ubuntu but not Windows.

Thanks for your code to let me test my environment !
After I reconfigure the environment with python==3.6.13 and download the correct packages_version of this project required, and lastly add the R_path to my system_env_variables. I succeed to run this project in windows! Again thanks very much for your time!