<commit_before>import * as io from '../io/cgd';
import * as pgr from '../pgraphs/periodic';
import * as sym from '../pgraphs/symmetries';
import * as inv from '../pgraphs/invariant';


const fs = require('fs');

Array.prototype.toString = function() {
  return `${this.map(x => x.toString()).join(' ')}`;
};


process.argv.slice(2).forEach(file => {
  const text = fs.readFileSync(file, { encoding: 'utf8' });

  for (const b of io.structures(text)) {
    console.log(b.name);

    const G = b.graph;

    if (!pgr.isConnected(G)) {
      console.log(`  Error: net '${b.name}' is not connected`);
    }
    else if (!pgr.isLocallyStable(G)) {
      console.log(`  Error: net '${b.name}' is not locally stable`);
    }
    else {
      try {
        const key = inv.invariant(sym.minimalImage(G));
        for (const [head, tail, shift] of key) {
          console.log(`  ${head} ${tail} ${shift}`);
        }
      } catch(ex) {
        console.log(ex.stack);
      }
    }

    console.log();
  }
});<commit_msg>extend the try-catch block around all the net computations<commit_after>import * as io from '../io/cgd';
import * as pgr from '../pgraphs/periodic';
import * as sym from '../pgraphs/symmetries';
import * as inv from '../pgraphs/invariant';


const fs = require('fs');

Array.prototype.toString = function() {
  return `${this.map(x => x.toString()).join(' ')}`;
};


process.argv.slice(2).forEach(file => {
  const text = fs.readFileSync(file, { encoding: 'utf8' });

  for (const b of io.structures(text)) {
    console.log(b.name);

    const G = b.graph;

    try {
      if (!pgr.isConnected(G)) {
        console.log(`  Error: net '${b.name}' is not connected`);
      }
      else if (!pgr.isLocallyStable(G)) {
        console.log(`  Error: net '${b.name}' is not locally stable`);
      }
      else {
        const key = inv.invariant(sym.minimalImage(G));
        for (const [head, tail, shift] of key) {
          console.log(`  ${head} ${tail} ${shift}`);
        }
      }
    } catch(ex) {
      console.log(ex.stack);
    }

    console.log();
  }
});
{'fraction_non_alphanumeric': 0.18903318903318903, 'fraction_numerical': 0.001924001924001924, 'mean_word_length': 2.5738831615120277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '206068', 'n_tokens_mistral': 724, 'n_tokens_neox': 708, 'n_words': 172}