- Difficulty level: easy
- Time need to lean: 15 minutes or less
- Key points:
- There are intuitive corresponding data types between most Python (SoS) and Scilab datatypes
The convertion of datatype from SoS to Scilab is as followings:
Python | condition | Scilab |
---|---|---|
None |
Nan |
|
boolean |
boolean |
|
integer |
constant |
|
float |
constant |
|
complex |
complex |
|
str |
string |
|
char |
string |
|
Sequence (list , tuple , ...) |
homogenous type, all numeric | constant |
Sequence (list , tuple , ...) |
homogenous type, all char | string |
Sequence (list , tuple , ...) |
multiple types | list |
numpy.ndarray |
constant |
|
numpy.matrix |
constant |
Python objects in other datatypes are transferred as string "Unsupported datatype"
.
The convertion of datatype from Scilab to SoS is as followings:
Scilab | length (n) | Python |
---|---|---|
Nan |
None |
|
boolean |
1 |
boolean |
integer |
1 |
integer |
constant |
1 |
double |
string |
1 |
string |
complex |
1 |
complex |
boolean |
n > 1 |
list |
integer |
n > 1 |
list |
complex |
n > 1 |
list |
constant |
n > 1 |
list |
string |
n > 1 |
list |
struct |
n > 0 |
numpy.ndarray |
matrix |
n > 0 |
numpy.array |
cell |
n > 0 |
numpy.ndarray |
Most simple Python data types can be converted to Scilab types easily.
However, because Python allows integers of arbitrary precision which is not supported by Scilab, large integers would be presented in Scilab as float point numbers, which might not be able to keep the precision of the original number.
For example, if we put a large integer with 18 significant digits to Scilab
The integer would be considered a double-precision float number and be presented with a D
This is not a problem with SoS because you would get the same result if you enter this number in Scilab
Consequently, if you send large_int
back to SoS
, the number would be different
The one-dimension (vector) data is converted from SoS to Scilab as follows:
The multi-dimension data is converted from SoS to Scilab as follows:
The scalar data is converted from Scilab to SoS as follows:
The one-dimension (vector) data is converted from R to SoS as follows:
The multi-dimension data is converted from Scilab to SoS as follows: