From 4fa25e988345466d2bbfb9aa4dd666b802e48f6e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 6 Jul 2018 19:28:20 +0200 Subject: [PATCH] rogueviz::kohonen:: better diagnostic messages --- rogueviz-kohonen.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/rogueviz-kohonen.cpp b/rogueviz-kohonen.cpp index cd6bbd58..07f136f6 100644 --- a/rogueviz-kohonen.cpp +++ b/rogueviz-kohonen.cpp @@ -79,10 +79,14 @@ vector samples_to_show; void loadsamples(const string& fname) { FILE *f = fopen(fname.c_str(), "rt"); if(!f) { - fprintf(stderr, "Could not load samples\n"); + fprintf(stderr, "Could not load samples: %s\n", fname.c_str()); return; } - if(fscanf(f, "%d", &cols) != 1) { fclose(f); return; } + if(fscanf(f, "%d", &cols) != 1) { + printf("Bad format: %s\n", fname.c_str()); + fclose(f); return; + } + printf("Loading samples: %s\n", fname.c_str()); while(true) { sample s; bool shown = false; @@ -880,10 +884,14 @@ void kload(const string& fname) { int xcells; FILE *f = fopen(fname.c_str(), "rt"); if(!f) { - fprintf(stderr, "Could not load the network\n"); + fprintf(stderr, "Could not load the network: %s\n", fname.c_str()); return; } - if(fscanf(f, "%d%d\n", &xcells, &t) != 2) return; + if(fscanf(f, "%d%d\n", &xcells, &t) != 2) { + fprintf(stderr, "Bad network format: %s\n", fname.c_str()); + return; + } + printf("Loading the network %s...\n", fname.c_str()); if(xcells != cells) { fprintf(stderr, "Error: bad number of cells (x=%d c=%d)\n", xcells, cells); exit(1); @@ -899,9 +907,10 @@ void ksavew(const string& fname) { sominit(1); FILE *f = fopen(fname.c_str(), "wt"); if(!f) { - fprintf(stderr, "Could not save the weights\n"); + fprintf(stderr, "Could not save the weights: %s\n", fname.c_str()); return; } + printf("Saving the network to %s...\n", fname.c_str()); for(int i=0; i