This Python script, ss_calc.py
, automates sample size selection based on either the Die Size or Lead Count method. It provides a simple command-line interface for users to input the necessary parameters and determine the appropriate sample size.
- Calculates sample size based on Die Size or Lead Count.
- Input validation to ensure correct data types and prevent negative values.
- Uses constants for sample sizes and thresholds to improve readability and maintainability.
- Clear and concise output of the calculated sample size.
-
Clone the repository:
git clone <repository_url>
-
Run the script:
python ss_calc.py
-
Follow the prompts:
- Choose the method to determine sample size (Die Size or Lead Count).
- Enter the required parameters (Die Size X and Y dimensions in mm, or Lead Count).
- The script will display the calculated sample size.
get_sample_size_by_method(die_size_x_mm, die_size_y_mm, lead_count, method)
:- Calculates the sample size based on the chosen method and input values.
- Performs input validation to ensure correct data types and prevent negative values.
- Uses constants for sample sizes and thresholds.
- Returns the calculated sample size or
None
if the input is invalid.
get_user_input(prompt, data_type)
:- Gets user input and validates the data type.
- Prompts the user with the given message and attempts to convert the input to the specified data type.
- Handles
ValueError
exceptions if the input cannot be converted to the specified data type.
- Main loop:
- Presents a menu to the user to choose the sample size determination method.
- Gets the required input parameters from the user.
- Calls the
get_sample_size_by_method
function to calculate the sample size. - Displays the calculated sample size to the user.
SS_77
,SS_45
,SS_32
: Constants for sample sizes.DIE_AREA_THRESHOLD_1
,DIE_AREA_THRESHOLD_2
: Constants for die area thresholds (in sq mm).LEAD_COUNT_THRESHOLD_1
,LEAD_COUNT_THRESHOLD_2
: Constants for lead count thresholds.
Contributions are welcome! Please feel free to submit pull requests with bug fixes, new features, or improvements to the documentation.
This project is licensed under the MIT License.
Aldrin Cerezo