Skip to content

Replace magic numbers with named constants #16

Description

@cnicholas

Statistical constants are hard-coded throughout the code with no explanation or source citations.

Examples

  • Line 1697: 2.66 (IMR limit multiplier)
  • Line 1705: 3.268 (R chart limit multiplier)
  • Line 299-300: beyond_limits calculation logic
  • Various uses of 3 for sigma multipliers

Impact

  • Hard to verify correctness
  • No documentation of where constants come from
  • Hard to modify if different sigma levels needed

Fix

Define named constants at module level with docstrings:

# Statistical constants based on d2 and d3 tables
IMR_LIMIT_MULTIPLIER = 2.66  # E2 constant for n=2 (individuals)
R_LIMIT_MULTIPLIER = 3.268   # D4 constant for n=2 (moving range)
SIGMA_MULTIPLIER = 3         # Standard 3-sigma control limits

Files

  • analysis_dataset.py
  • objects.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions