gama-platform / gama

Main repository for developing the 2024+ versions of GAMA
https://gama-platform.org
GNU General Public License v3.0
12 stars 5 forks source link

matrix constructor over some csv file defaults on a matrix of boolean instead of string #142

Closed lesquoyb closed 2 months ago

lesquoyb commented 3 months ago

Describe the bug

As the title says, when casting some csv file into an untyped matrix, it sometimes is converted into a matrix of bool instead of the normal matrix of string.

In addition to this, the operator type_of says the variable is a matrix<string> but the content is clearly booleans and if we try affect that matrix into a real matrix<string> the linter gives us a warning that they are not the same type and the first one contains booleans.

If we force the casting to a type matrix<string> directly then everything works as expected.

This seems to happen only with the csv_file constructor with 4 parameters (file, separator, type and header)

To Reproduce Steps to reproduce the behavior:

  1. Run this model:
    
    model mat

experiment a { init { file f <- csv_file('test.csv',",",string,false); matrix m <- matrix(f); write type_of(m); matrix m2 <- m;

    write m;
    write matrix<string>(f);
    write matrix<string>(m);

}

}


3. The content of the csv file doesn't matter
5. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
This used to work as expected in 1.8.1.