tidy plots

This commit is contained in:
2026-02-03 21:51:29 +01:00
parent a35670aa72
commit f5b4c247b8
3 changed files with 224 additions and 117 deletions

View File

@@ -52,14 +52,14 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
combinations = []
# Add "All Respondents" run (no filters = all options selected)
if not category or category == 'all':
if not category or category in ['all_filters', 'all']:
combinations.append({
'name': 'All_Respondents',
'filters': {} # Empty = use defaults (all selected)
})
# Age groups - one at a time
if not category or category in ['all', 'age']:
if not category or category in ['all_filters', 'age']:
for age in survey.options_age:
combinations.append({
'name': f'Age-{age}',
@@ -67,7 +67,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Gender - one at a time
if not category or category in ['all', 'gender']:
if not category or category in ['all_filters', 'gender']:
for gender in survey.options_gender:
combinations.append({
'name': f'Gender-{gender}',
@@ -75,7 +75,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Ethnicity - grouped by individual values
if not category or category in ['all', 'ethnicity']:
if not category or category in ['all_filters', 'ethnicity']:
# Ethnicity options are comma-separated (e.g., "White or Caucasian, Hispanic or Latino")
# Create filters that include ALL options containing each individual ethnicity value
ethnicity_values = set()
@@ -96,7 +96,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Income - one at a time
if not category or category in ['all', 'income']:
if not category or category in ['all_filters', 'income']:
for income in survey.options_income:
combinations.append({
'name': f'Income-{income}',
@@ -104,7 +104,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Consumer segments - combine _A and _B options, and also include standalone
if not category or category in ['all', 'consumer']:
if not category or category in ['all_filters', 'consumer']:
# Group options by base name (removing _A/_B suffix)
consumer_groups = {}
for consumer in survey.options_consumer:
@@ -134,7 +134,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Business Owner - one at a time
if not category or category in ['all', 'business_owner']:
if not category or category in ['all_filters', 'business_owner']:
for business_owner in survey.options_business_owner:
combinations.append({
'name': f'BusinessOwner-{business_owner}',
@@ -142,7 +142,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# AI User - one at a time
if not category or category in ['all', 'ai_user']:
if not category or category in ['all_filters', 'ai_user']:
for ai_user in survey.options_ai_user:
combinations.append({
'name': f'AIUser-{ai_user}',
@@ -164,7 +164,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Investable Assets - one at a time
if not category or category in ['all', 'investable_assets']:
if not category or category in ['all_filters', 'investable_assets']:
for investable_assets in survey.options_investable_assets:
combinations.append({
'name': f'Assets-{investable_assets}',
@@ -172,7 +172,7 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
})
# Industry - one at a time
if not category or category in ['all', 'industry']:
if not category or category in ['all_filters', 'industry']:
for industry in survey.options_industry:
combinations.append({
'name': f'Industry-{industry}',
@@ -230,10 +230,9 @@ def main():
parser.add_argument('--dry-run', action='store_true', help='Preview combinations without running')
parser.add_argument(
'--category',
choices=['all', 'age', 'gender', 'ethnicity', 'income', 'consumer',
'business_owner', 'ai_user', 'investable_assets', 'industry'],
default='all',
help='Filter category to run combinations for (default: all)'
choices=['all_filters', 'all', 'age', 'gender', 'ethnicity', 'income', 'consumer', 'business_owner', 'ai_user', 'investable_assets', 'industry'],
default=['all_filters'],
help='Filter category to run combinations for (default: all_filters)'
)
args = parser.parse_args()