From df21468622fc01036ddc31f2be0be35327c34600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Sat, 14 Mar 2020 17:29:47 +0100 Subject: [PATCH] Add assertions --- static/js/data.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/static/js/data.js b/static/js/data.js index 50413b08..dbee3d55 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -235,6 +235,7 @@ class dataFileBase { return (JSON.stringify(e.initial)===JSON.stringify(ex.initial)) && (JSON.stringify(e.final)===JSON.stringify(ex.final)) }) if(ex2!==undefined){ + console.assert(ex.type==0 || (ex2.type^(excitationTypes.RYDBERG | excitationTypes.VALENCE)==ex.type^(excitationTypes.RYDBERG | excitationTypes.VALENCE)),"Excitation type error",[ex,ex2,data.sourceFile]) ex.type=ex2.type } } @@ -326,6 +327,18 @@ class dataFileBase { } } } + var stfy=dat.excitations.map(e=>JSON.stringify([e.initial,e.final])) + var double=[] + stfy.forEach(function(element, i) { + // Find if there is a duplicate or not + if (stfy.indexOf(element, i + 1) >= 0) { + // Find if the element is already in the result array or not + if (result.indexOf(element) === -1) { + double.push(dat.excitations[i]) + } + } + }); + console.assert(double.length===0,"Double found",double,dat.sourceFile) return dat } }