fix: aesthetics

This commit is contained in:
NunoSempere 2021-10-06 17:10:05 +02:00
parent 7d47a76d21
commit 9eeb35f998
4 changed files with 25 additions and 6 deletions

View File

@ -1,8 +1,18 @@
/* Imports*/
import React from "react";
import { toLocale, truncateValueForDisplay } from "../lib/utils.js"
/* Utilities */
let avg = arr => arr.reduce((a,b) => (a+b)) / arr.length
let formatLargeOrSmall = num => {
if(num > 1){
return toLocale(truncateValueForDisplay(num))
}else if(num != 0){
return num.toFixed(-Math.floor(Math.log(num)/Math.log(10)));
}else{
return "~0"
}
}
/* Main function */
@ -108,9 +118,9 @@ export function CreateTableWithDistances({isListOrdered, orderedList, listOfElem
<td>&nbsp;&nbsp;&nbsp;</td>
<td className="">{row.name}</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td className="">{JSON.stringify(row.distances, null, 2)}</td>
<td className="">{JSON.stringify(row.distances.map(d => formatLargeOrSmall(d)), null, 2).replaceAll(`"`, "")}</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td className="">{avg(row.distances).toFixed(2)}</td>
<td className="">{formatLargeOrSmall(avg(row.distances))}</td>
</tr>
)}
</tbody>

View File

@ -4,5 +4,13 @@ export const hashString = (string) => crypto.createHash('md5').update(string).di
export const transformSliderValueToActualValue = value => 10 ** value //>= 2 ? Math.round(10 ** value) : Math.round(10 * 10 ** value) / 10
export const toLocale = x => Number(x).toLocaleString()
export const truncateValueForDisplay = value => value > 10 ? Number(Math.round(value).toPrecision(2)) : Math.round(value * 10) / 10
export const truncateValueForDisplay = value => {
if(value > 10){
return Number(Math.round(value).toPrecision(2))
}else if(value > 1){
return Math.round(value * 10) / 10
} else if(value < 1){
}
}
export const transformSliderValueToPracticalValue = value => truncateValueForDisplay(transformSliderValueToActualValue(value))

View File

@ -14,7 +14,7 @@ import { DisplayAsMarkdown } from '../lib/displayAsMarkdown'
import { CreateTableWithDistances } from '../lib/findPaths'
import { TextAreaForJson } from "../lib/textAreaForJson"
import { pushToMongo } from "../lib/pushToMongo.js"
import { toLocale, transformSliderValueToPracticalValue } from "../lib/utils.js"
import { toLocale, transformSliderValueToPracticalValue, transformSliderValueToActualValue } from "../lib/utils.js"
/* Helpers */
let increasingList = (n) => Array.from(Array(n).keys())
@ -220,7 +220,7 @@ export default function Home({ listOfElementsDefault }) {
console.log(posList)
let successStatus = nextStepSimple(posList, binaryComparisons, element1, element2)
let newQuantitativeComparison = [element1, element2, transformSliderValueToPracticalValue(sliderValue)]
let newQuantitativeComparison = [element1, element2, transformSliderValueToActualValue(sliderValue)]
let newQuantitativeComparisons = [...quantitativeComparisons, newQuantitativeComparison]
setQuantitativeComparisons(newQuantitativeComparisons)

View File

@ -13,7 +13,8 @@
},
{
"name": "Categorizing Variants of Goodhart's Law",
"url": "https://arxiv.org/abs/1803.04585"
"url": "https://arxiv.org/abs/1803.04585",
"isReferenceValue": true
},
{
"name": "The Vulnerable World Hypothesis",