Skip to content

Commit

Permalink
Altering the escaped data filename in AutoAnalyser to be properly esc…
Browse files Browse the repository at this point in the history
…aped using non-regex replace, and also rolling back the use of escaping to only Java (Matlab and Python on windows seem fine with the non-escaped filenames, for e.g. the paths earlier in the generated code)
  • Loading branch information
jlizier committed Nov 26, 2017
1 parent 3bfbaa7 commit 589d516
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions java/source/infodynamics/demos/autoanalysis/AutoAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ protected void compute() {

// Code to read in data:
String loadDataComment = "0. Load/prepare the data:\n";
String filenameAsEscapedString = dataFile.getAbsolutePath().replaceAll("\\", "\\\\");
String filenameAsEscapedString = dataFile.getAbsolutePath().replace("\\", "\\\\");
// 1. Java
javaCode.append(" // " + loadDataComment);
javaCode.append(" String dataFile = \"" + filenameAsEscapedString + "\";\n");
Expand Down Expand Up @@ -902,9 +902,9 @@ protected void compute() {
// 2. Python
pythonCode.append("# " + loadDataComment);
if (selectedCalcType.equalsIgnoreCase(CALC_TYPE_DISCRETE)) {
pythonCode.append("dataRaw = readIntsFile.readIntsFile(\"" + filenameAsEscapedString + "\")\n");
pythonCode.append("dataRaw = readIntsFile.readIntsFile(\"" + dataFile.getAbsolutePath() + "\")\n");
} else {
pythonCode.append("dataRaw = readFloatsFile.readFloatsFile(\"" + filenameAsEscapedString + "\")\n");
pythonCode.append("dataRaw = readFloatsFile.readFloatsFile(\"" + dataFile.getAbsolutePath() + "\")\n");
}
pythonCode.append("# As numpy array:\n");
pythonCode.append("data = numpy.array(dataRaw)\n");
Expand All @@ -930,7 +930,7 @@ protected void compute() {
}
// 3. Matlab
matlabCode.append("% " + loadDataComment);
matlabCode.append("data = load('" + filenameAsEscapedString + "');\n");
matlabCode.append("data = load('" + dataFile.getAbsolutePath() + "');\n");
if (! allCombosCheckBox.isSelected()) {
matlabCode.append("% Column indices start from 1 in Matlab:\n");
if (selectedCalcType.equalsIgnoreCase(CALC_TYPE_DISCRETE)) {
Expand Down

0 comments on commit 589d516

Please sign in to comment.