Commit 1b256135 authored by LIGNEUL CLEMENT's avatar LIGNEUL CLEMENT
Browse files

correction of the end of the runs

parent 3e89448c
......@@ -9,7 +9,7 @@ from math import ceil
if len(sys.argv) != 4:
print(
"Usage : " + sys.argv[0] + " <nb of generations> <nb of plots>", file=sys.stderr
"Usage : " + sys.argv[0] + " <nb of generations> <nb of plots> <title>", file=sys.stderr
)
exit(1)
......
......@@ -65,7 +65,6 @@ export function write_in_file(buffer: string) {
}
var init_buf = 'GEN,TIME,PLAN_EVAL,ACTU_EVAL,BEST_FIT,AVG_FIT,WORST_FIT,STD_DEV';
fs.writeFileSync(fd, init_buf);
fs.writeFileSync(fd, '\n' + buffer);
fs.writeFileSync(fd, init_buf + '\n' + buffer);
fs.closeSync(fd);
}
\ No newline at end of file
......@@ -185,9 +185,10 @@ export class Plot_result {
try {
fs.copyFileSync('/tmp/plotting/fig.svg', path_file);
} catch (e) {
if (e)
new Win_alert(e, 'Save Static Plot');
return;
if (e){
new Win_alert(e + "", 'Save Static Plot');
return;
}
}
new Win_alert('Plot Saved', 'Save Static Plot');
}
......@@ -209,7 +210,7 @@ export class Plot_result {
fs.copyFileSync('/tmp/plotting/fig.html', path_file);
} catch (e) {
if (e)
new Win_alert(e, 'Save Interactive Plot');
new Win_alert(e + "", 'Save Interactive Plot');
return;
}
new Win_alert('Plot Saved', 'Save Interactive Plot');
......
......@@ -7,6 +7,7 @@ import { Win_alert } from './win_alert';
import * as plot_generation from './plot_generation';
import { plot_obj, run_obj } from './index';
import { initial_proc } from './run_tab';
import * as util from './utilities'
require('child_process').spawn('node', ['--version'], {
......@@ -227,6 +228,7 @@ export class Pseudo_term {
run_obj.running_label.setText('Plotting results ...');
run_obj.running_label.show();
// util.fix_csv(); // file correction
plot_obj.update_plot('/tmp/plotting/fig.svg', plot_size, type, run_obj.dir_path + '/objectives', '', '', '', '');
......
......@@ -80,4 +80,46 @@ export function get_best_fitness(text: string): number {
}
return res
}
// correct errors in csv file
export function fix_csv(){
var updated = 0;
var data = fs.readFileSync('/tmp/plotting/data.csv', 'utf8');
var rows = data.split('\n');
var index = rows[0].length + 1; // position in the text
for(var i = 1; i < rows.length; i++){
var sub_str = rows[i].split(',');
if(sub_str.length > 8){
updated = 1;
var p = 0;
var id = 0;
while(id != rows[i].length){
if(rows[i][id] === ',' && p === 7){
rows[i] = rows[i].substr(0,id) + '\n' + rows[i].substr(id + 1);
console.log('new row = ' + rows[i])
// break;
} else if (rows[i][id] === ','){
p++;
}
id++;
}
}
}
if(updated){
rows[0] += '\n';
var t = '';
for(var j = 0; j < rows.length; j++){
// rows[j] = rows[j].substr(1);
rows[j] += '\n';
t += rows[j];
}
fs.unlinkSync('/tmp/plotting/data.csv');
fs.writeFileSync('/tmp/plotting/data.csv', t);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment