Skip to content

Commit

Permalink
Use of black magic to fix #3267 (genstar)
Browse files Browse the repository at this point in the history
Hum...  with the previous commit, it seems to work, but I have no idea of what I am doing....
Note for GAMA 2.0: a refactoring of the Genstar could be a good idea.
  • Loading branch information
ptaillandier committed Mar 16, 2022
1 parent 6e3e9b7 commit 750b85c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
Expand Up @@ -139,6 +139,7 @@ public void generate(IScope scope, List<Map<String, Object>> inits, Integer max,
.map(s -> GenStarGamaUtils.toSurveyWrapper(scope, s, gsAttributes))
.collect(Collectors.toList());


// Set Genstar random engine to be the one of Gama for seed purpose consistancy !
GenstarRandom.setInstance(scope.getRandom().getGenerator());

Expand Down
Expand Up @@ -215,7 +215,7 @@ public Double getTotalData() {
}
}

System.out.println("Total value is " + total);
//System.out.println("Total value is " + total);

} catch (final IOException e) {}
reader.close();
Expand Down
Expand Up @@ -122,6 +122,7 @@ public static GSSurveyWrapper toSurveyWrapper(IScope scope, GamaCSVFile survey,
GenStarGamaSurveyUtils gsg = null;
try {
gsg = new GenStarGamaSurveyUtils(scope,survey,atts);

} catch (FileNotFoundException e) {
GamaRuntimeException.create(e, scope);
}
Expand Down
Expand Up @@ -128,7 +128,7 @@ public void buildDataTables() throws IOException, InvalidSurveyFormatException,
GosplSurveyFactory sf = new GosplSurveyFactory();
this.inputData = new HashSet<>();
for (final GSSurveyWrapper wrapper : this.configuration.getSurveyWrappers())
if (!wrapper.getSurveyType().equals(GSSurveyType.Sample))
if (!wrapper.getSurveyType().equals(GSSurveyType.Sample)) {
this.inputData.addAll(
getDataTables(
sf.getSurvey(
Expand All @@ -137,6 +137,7 @@ public void buildDataTables() throws IOException, InvalidSurveyFormatException,
),
this.configuration.getDictionary()
));
}
}

/**
Expand Down
Expand Up @@ -156,6 +156,14 @@ protected CsvInputHandler(File file, boolean storeInMemory, String charset, char
}
reader.close();

if (dataTable != null) {
for (String[] str : dataTable) {
for (int i = 0; i < str.length; i++) {
if (str[i].isBlank())
str[i] = "";
}
}
}
this.firstRowDataIndex = firstRowDataIndex;
this.firstColumnDataIndex = firstColumnDataIndex;

Expand Down

0 comments on commit 750b85c

Please sign in to comment.