Skip to content

Commit

Permalink
Update two_proportion.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoopy1866 committed Sep 13, 2024
1 parent 27ad900 commit ed70736
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/pystatpower/procedures/two_proportion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
from enum import Enum


class SolvableParameter(Enum):
"""求解目标"""

N = 1
ALPHA = 2
POWER = 3
TREATMENT_PROPORTION = 4
REFERENCE_PROPORTION = 5


class Alternative(Enum):
"""假设检验的备择假设类型"""

Expand Down Expand Up @@ -32,25 +42,20 @@ class GroupAllocation(Enum):


class TwoProportionDesigner:
def __init__(self, solve_for: str):
if not isinstance(solve_for, str):
raise TypeError("solve_for must be a string")

self._solve_for = solve_for.lower()
if self._solve_for not in ["n", "alpha", "power", "treatment_proportion", "reference_proportion"]:
raise ValueError(
"solve_for must be either 'n', 'alpha', 'power', 'treatment_proportion', or 'reference_proportion'"
)
match self._solve_for:
case "n":
def __init__(self, solve_for: SolvableParameter):
if not isinstance(solve_for, SolvableParameter):
raise TypeError("solve_for must be an instance of SolvableParameter")

match solve_for:
case SolvableParameter.N:
return TwoProportionSolveForNDesigner()
case "alpha":
case SolvableParameter.ALPHA:
return TwoProportionSolveForAlphaDesigner()
case "power":
case SolvableParameter.POWER:
return TwoProportionSolveForPowerDesigner()
case "treatment_proportion":
case SolvableParameter.TREATMENT_PROPORTION:
return TwoProportionSolveForTreatmentProportionDesigner()
case "reference_proportion":
case SolvableParameter.REFERENCE_PROPORTION:
return TwoProportionSolveForReferenceProportionDesigner()


Expand Down

0 comments on commit ed70736

Please sign in to comment.