From 81f63bf5398ca72d18f0bf90dfdd8baf49c23e7b Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 11 Aug 2019 04:01:55 -0500 Subject: [PATCH] showScore configuration --- README.md | 14 ++++++++++---- config.json | 6 ++++-- fusion.py | 11 ++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aff56e2..21332d0 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The `elements` portion refers to the scores of each element, each being the atom --- -`reverseIndividualOrder` refers to whether or not the program should reverse the output of the lists so that individual list printouts should have elements with higher scores +`reverseIndividualOrder` refers to whether or not the program should reverse the output of the lists so that individual list printouts should have elements with higher scores. --- @@ -37,14 +37,20 @@ The `elements` portion refers to the scores of each element, each being the atom --- -`noNegatives` refers to whether it should filter out elements that have a negative score (ie. while using default configs, filter out elements without a score set) +`noNegatives` refers to whether it should filter out elements that have a negative score (ie. while using default configs, filter out elements without a score set). A set of elements with the score (-1, 5) would get filtered out, while a set with the scores (78, 12) would not. --- -`fullPrint` refers to whether it should print out the Symbol or the Name of the Element +`fullPrint` refers to whether it should print out the Symbol or the Name of the Element. --- -`eliminateEmpty` refers to whether the program should remove specified elements if they contained no matching tuples. \ No newline at end of file +`eliminateEmpty` refers to whether the program should remove specified elements if they contained no matching tuples. + +--- + +`showScore` refers to whether or not the program shows the score calculated alongside each element. + +`showScoreZFill` refers to whether or not to apply applicable ZFill arguments to the score display. \ No newline at end of file diff --git a/config.json b/config.json index 0403b8e..323e7a2 100644 --- a/config.json +++ b/config.json @@ -92,7 +92,7 @@ "90": -1, "91": -1, "92": -1, - "93": -1, + "93": 9999, "94": -1, "95": -1, "96": -1, @@ -124,5 +124,7 @@ "reverseOrder" : false, "noNegatives" : true, "fullPrint" : true, - "eliminateEmpty" : false + "eliminateEmpty" : false, + "showScore" : true, + "showScoreZFill" : true } \ No newline at end of file diff --git a/fusion.py b/fusion.py index 38a4648..9f0ea83 100644 --- a/fusion.py +++ b/fusion.py @@ -12,10 +12,19 @@ score = lambda element : config['elements'][str(element)] scoreSum = lambda item : ((score(item[0]) + score(item[1])), item) hasNegatives = lambda item : score(item[0]) < 0 or score(item[1]) < 0 +def getScoreFormat(item): + score = str(scoreSum(item)[0]) + if config['showScoreZFill']: + largest = len(str(max(config['elements'].values()))) + score = score.zfill(largest) + return '{{{}}} '.format(score) + # Formatting for a single element report line def formatting(e1, e2): e1, e2 = mdv.element(e1), mdv.element(e2) - return '\t[{} {}] + [{} {}]'.format(e1.symbol if not config['fullPrint'] else e1.name, + return '\t{}[{} {}] + [{} {}]'.format( + getScoreFormat((e1.atomic_number, e2.atomic_number)) if config['showScore'] else '', + e1.symbol if not config['fullPrint'] else e1.name, e1.atomic_number, e2.symbol if not config['fullPrint'] else e2.name, e2.atomic_number)