submodel reuse of tables cause numeric type and datatype inconsistencies
There is inconsistent behavior when one reuses a Table object from some source model, and then retrieves a column, from within the target model, to build another Table in the target model.
This can be observed following these steps:
-
Start an interactive session with
texts session -w -r
-
Input a table with two columns, and get the uuid of the source model:
Input > table1 = ((temperature: 0, 1, 3) [kelvin], (pressure: 4., 5., 6.) [bar])
Input > %uuid
uuids: uuid_of_model_1 ('uuid_of_model_1')
- Start a new model (target) and add a new series, for example:
Input > %new
Started new session with uuids ('uuid_of_model_2')
Input > ser1 = (volume: 7., 8., 9.)[cm**3]
- Reuse the table from the source model, and assign it to a new variable in the target model:
Input > reusedtab = table1@uuid_from_model_1
Input > %hist
COMPLETED 2024-06-28T19:09:09+02:00 ser1 = (volume: 7., 8., 9.)[cm**3]
COMPLETED 2024-06-28T19:09:47+02:00 table1 = ((temperature: 0, 1, 3) [kelvin], (pressure: 4., 5., 6.) [bar])
COMPLETED 2024-06-28T19:09:47+02:00 reusedtab = table1
- Retrieve the
temperature
column (sub-series) from both the new variable and the reusedtable1
, and make two new variables out of them:
Input > tmp1 = table1.temperature
Input > print(tmp1)
Output > (temperature: 0, 1, 3) [kelvin]
Input >
Input > tmp2 = reusedtab.temperature
Input > print(tmp2)
Output > (temperature: 0, 1, 3) [kelvin]
- Create two new tables, one using the series
ser1
andtmp1
, and the other usingser1
andtmp2
:
Input > newtab1 = Table (ser1, tmp1)
Input > newtab2 = Table (ser1, tmp2)
Value error: None:7:11 --> Table (ser1, tmp2) <--
Table columns must have one size but 2 sizes were found
The tmp2
series cannot be used as column for a new table, due to some hidden(?) size compatibility problem.
As observed in step No.5, printing both tmp1
and tmp2
shows no difference.
- Compare the type/properties of the
tmp1
andtmp2
Series (retrieved columns):
Input > print(type(tmp1))
Output > ((name: 'tmp1'), (type: 'Series'), (scalar: false), (numeric: true), (datatype: 'int'), (dimensionality: '[temperature]'), (units: 'kelvin'), (node ID: 9), (node UUID: '5e9d0bb1447c47d297c0f0c29da86c1d'), (node state: 'COMPLETED'), (number of launches: 1), (created on: '2024-06-28T19:10:51+02:00'), (updated on: '2024-06-28T19:10:51+02:00'), (parent IDs: (7)), (model UUID: '44aef27070884a578639d8b71d055064'), (group UUID: '4abbf2a68c6e47a9b1b1a1e20105d20f'))
Input > print(type(tmp2))
Output > ((name: 'tmp2'), (type: 'Series'), (scalar: false), (numeric: null), (datatype: null), (node ID: 10), (node UUID: '2faaef1f9e724c4590527e2f25d0c236'), (node state: 'COMPLETED'), (number of launches: 1), (created on: '2024-06-28T19:11:18+02:00'), (updated on: '2024-06-28T19:11:18+02:00'), (parent IDs: (8)), (model UUID: '44aef27070884a578639d8b71d055064'), (group UUID: '4abbf2a68c6e47a9b1b1a1e20105d20f'))
Both are still Series, but for some reason, assigning the reused table to a new variable and then retrieving the column causes changes from
numeric: true, and
datatype: 'int'to
numeric: null, and
datatype: null`
Interestingly both can still be used in methods such as the map
function without apparent issues:
Input > mult1 = map((x: x*2), tmp1)
Input > mult2 = map((x: x*2), tmp2)
Input > print(mult1)
Output > (mult1: 0, 2, 6) [kelvin]
Input > print(mult2)
Output > (mult2: 0, 2, 6) [kelvin]
The type changes are carried over to the mult1
and mult2
variables:
Input > print(type(mult1))
Output > ((name: 'mult1'), (type: 'Series'), (scalar: false), (numeric: true), (datatype: 'int'), (dimensionality: '[temperature]'), (units: 'kelvin'), (node ID: 12), (node UUID: '152e4a7ffdb84cd7a44402bbe4f48548'), (node state: 'COMPLETED'), (number of launches: 1), (created on: '2024-06-28T19:29:43+02:00'), (updated on: '2024-06-28T19:29:43+02:00'), (parent IDs: (9)), (model UUID: '44aef27070884a578639d8b71d055064'), (group UUID: '4abbf2a68c6e47a9b1b1a1e20105d20f'))
Input > print(type(mult2))
Output > ((name: 'mult2'), (type: 'Series'), (scalar: false), (numeric: null), (datatype: null), (node ID: 13), (node UUID: 'a51fabcbcac04fb19c0e6b792e5e9017'), (node state: 'COMPLETED'), (number of launches: 1), (created on: '2024-06-28T19:30:05+02:00'), (updated on: '2024-06-28T19:30:05+02:00'), (parent IDs: (10)), (model UUID: '44aef27070884a578639d8b71d055064'), (group UUID: '4abbf2a68c6e47a9b1b1a1e20105d20f'))