fixes graphics

This commit is contained in:
2026-07-01 05:04:47 +00:00
parent 1313a12a20
commit 3e48b3a41c
9 changed files with 543 additions and 50 deletions
+8 -17
View File
@@ -6,10 +6,6 @@ def _is_female(sex: str) -> bool:
return sex.lower() in ("f", "female", "ж", "женский", "woman")
def _cm_to_inches(cm: float) -> float:
return cm / 2.54
def _clamp_bf(value: float) -> float:
return round(max(3.0, min(50.0, value)), 1)
@@ -25,30 +21,25 @@ def navy_body_fat_pct(
if height_cm <= 0 or neck_cm <= 0 or waist_cm <= 0:
return None
height_in = _cm_to_inches(height_cm)
neck_in = _cm_to_inches(neck_cm)
waist_in = _cm_to_inches(waist_cm)
if _is_female(sex):
if hip_cm is None or hip_cm <= 0:
return None
hip_in = _cm_to_inches(hip_cm)
sum_in = waist_in + hip_in - neck_in
if sum_in <= 0:
measurement_sum_cm = waist_cm + hip_cm - neck_cm
if measurement_sum_cm <= 0:
return None
denom = (
1.29579
- 0.35004 * math.log10(sum_in)
+ 0.22100 * math.log10(height_in)
- 0.35004 * math.log10(measurement_sum_cm)
+ 0.22100 * math.log10(height_cm)
)
else:
diff_in = waist_in - neck_in
if diff_in <= 0:
measurement_diff_cm = waist_cm - neck_cm
if measurement_diff_cm <= 0:
return None
denom = (
1.0324
- 0.19077 * math.log10(diff_in)
+ 0.15456 * math.log10(height_in)
- 0.19077 * math.log10(measurement_diff_cm)
+ 0.15456 * math.log10(height_cm)
)
if denom <= 0: