初始化提交

This commit is contained in:
王立帮
2024-07-19 10:16:00 +08:00
parent 4c7b571f20
commit 4a2d56dcc4
7084 changed files with 741212 additions and 63 deletions

View File

@@ -0,0 +1,26 @@
<style>
div[m-id="{{d.mId}}"] {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
overflow-y: auto;
}
html[data-bs-theme=light] div[m-id="{{d.mId}}"] {
background-color: #ffffff;
}
html[data-bs-theme=dark] div[m-id="{{d.mId}}"] {
background-color: #1e1e1e;
}
div[m-id="{{d.mId}}"] > #output-img {
width: 500px;
height: 500px;
position: relative;
}
</style>
<div m-id="{{d.mId}}" class="page-item mixly-scrollbar">
<div id="output-img"></div>
</div>

View File

@@ -0,0 +1,59 @@
import math
def math_map(v, al, ah, bl, bh):
return bl + (bh - bl) * (v - al) / (ah - al)
def math_mean(myList):
localList = [e for e in myList if type(e) == int or type(e) == float]
if not localList: return
return float(sum(localList)) / len(localList)
def math_median(myList):
localList = sorted([e for e in myList if type(e) == int or type(e) == float])
if not localList: return
if len(localList) % 2 == 0:
return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0
else:
return localList[(len(localList) - 1) // 2]
def math_modes(some_list):
modes = []
# Using a lists of [item, count] to keep count rather than dict
# to avoid "unhashable" errors when the counted item is itself a list or dict.
counts = []
maxCount = 1
for item in some_list:
found = False
for count in counts:
if count[0] == item:
count[1] += 1
maxCount = max(maxCount, count[1])
found = True
if not found:
counts.append([item, 1])
for counted_item, item_count in counts:
if item_count == maxCount:
modes.append(counted_item)
return modes
def math_standard_deviation(numbers):
n = len(numbers)
if n == 0: return
mean = float(sum(numbers)) / n
variance = sum((x - mean) ** 2 for x in numbers) / n
return math.sqrt(variance)
def lists_sort(my_list, type, reverse):
def try_float(s):
try:
return float(s)
except:
return 0
key_funcs = {
"NUMERIC": try_float,
"TEXT": str,
"IGNORE_CASE": lambda s: str(s).lower()
}
key_func = key_funcs[type]
list_cpy = list(my_list)
return sorted(list_cpy, key=key_func, reverse=reverse)