Closed SaganBolliger closed 8 years ago
Can we just stick with one or the other? (I don't really care which one.) I don't want the complexity of having both.
I'm inclined to choose simplejson. Would this mean adding it to the nupic.research requirements.txt?
I'm inclined to choose simplejson. Would this mean adding it to the nupic.research requirements.txt?
Yes, that's fine. Not a big deal - you can just install it manually too (which is what I usually prefer).
Okay @SaganBolliger will you please change the imports to simplejson, add simplejson to the requirements, and test?
Yes, sure.
It really seems like a bug in bindings. It should be able to work with either type of strings. simplejson vs. json is too much of an implementation-dependent subtlety.
What do you think, @scottpurdy ?
@vitaly-krugl @scottpurdy Relevant information from the SWIG documentation:
At this time, SWIG provides limited support for Unicode and wide-character strings (the C wchar_t type). Some languages provide typemaps for wchar_t, but bear in mind these might not be portable across different operating systems. This is a delicate topic that is poorly understood by many programmers and not implemented in a consistent manner across languages. For those scripting languages that provide Unicode support, Unicode strings are often available in an 8-bit representation such as UTF-8 that can be mapped to the char * type (in which case the SWIG interface will probably work). If the program you are wrapping uses Unicode, there is no guarantee that Unicode characters in the target language will use the same internal representation (e.g., UCS-2 vs. UCS-4). You may need to write some special conversion functions.
If I recall correctly, python is a utf-8 shop, so
such as UTF-8 that can be mapped to the char * type (in which case the SWIG interface will probably work)"
should apply
In classification_network.py and several other places
json
is imported ifsimplejson
fails to import. However,json
returns a dict with keys/values that are unicode strings, whereassimplejson
returns a dict with standard str key/value pairs. The nupic bindings fail when given unicode strings.Either
json
should not be included as a fallback forsimplejson
, or additional configuration/conversion must be included so that the behavior matches.Here is the stracktrace when I create a
ClassificationModelHTM
usingjson
.