edsl 0.1.27.dev1__py3-none-any.whl → 0.1.28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. edsl/Base.py +99 -22
  2. edsl/BaseDiff.py +260 -0
  3. edsl/__init__.py +4 -0
  4. edsl/__version__.py +1 -1
  5. edsl/agents/Agent.py +26 -5
  6. edsl/agents/AgentList.py +62 -7
  7. edsl/agents/Invigilator.py +4 -9
  8. edsl/agents/InvigilatorBase.py +5 -5
  9. edsl/agents/descriptors.py +3 -1
  10. edsl/conjure/AgentConstructionMixin.py +152 -0
  11. edsl/conjure/Conjure.py +56 -0
  12. edsl/conjure/InputData.py +628 -0
  13. edsl/conjure/InputDataCSV.py +48 -0
  14. edsl/conjure/InputDataMixinQuestionStats.py +182 -0
  15. edsl/conjure/InputDataPyRead.py +91 -0
  16. edsl/conjure/InputDataSPSS.py +8 -0
  17. edsl/conjure/InputDataStata.py +8 -0
  18. edsl/conjure/QuestionOptionMixin.py +76 -0
  19. edsl/conjure/QuestionTypeMixin.py +23 -0
  20. edsl/conjure/RawQuestion.py +65 -0
  21. edsl/conjure/SurveyResponses.py +7 -0
  22. edsl/conjure/__init__.py +9 -4
  23. edsl/conjure/examples/placeholder.txt +0 -0
  24. edsl/conjure/naming_utilities.py +263 -0
  25. edsl/conjure/utilities.py +165 -28
  26. edsl/conversation/Conversation.py +238 -0
  27. edsl/conversation/car_buying.py +58 -0
  28. edsl/conversation/mug_negotiation.py +81 -0
  29. edsl/conversation/next_speaker_utilities.py +93 -0
  30. edsl/coop/coop.py +191 -12
  31. edsl/coop/utils.py +28 -1
  32. edsl/data/Cache.py +55 -17
  33. edsl/data/CacheHandler.py +10 -9
  34. edsl/inference_services/AnthropicService.py +1 -0
  35. edsl/inference_services/DeepInfraService.py +20 -13
  36. edsl/inference_services/GoogleService.py +7 -1
  37. edsl/inference_services/InferenceServicesCollection.py +33 -7
  38. edsl/inference_services/OpenAIService.py +17 -10
  39. edsl/inference_services/models_available_cache.py +69 -0
  40. edsl/inference_services/rate_limits_cache.py +25 -0
  41. edsl/inference_services/write_available.py +10 -0
  42. edsl/jobs/Jobs.py +240 -36
  43. edsl/jobs/buckets/BucketCollection.py +9 -3
  44. edsl/jobs/interviews/Interview.py +4 -1
  45. edsl/jobs/interviews/InterviewTaskBuildingMixin.py +24 -10
  46. edsl/jobs/interviews/retry_management.py +4 -4
  47. edsl/jobs/runners/JobsRunnerAsyncio.py +87 -45
  48. edsl/jobs/runners/JobsRunnerStatusData.py +3 -3
  49. edsl/jobs/tasks/QuestionTaskCreator.py +4 -2
  50. edsl/language_models/LanguageModel.py +37 -44
  51. edsl/language_models/ModelList.py +96 -0
  52. edsl/language_models/registry.py +14 -0
  53. edsl/language_models/repair.py +95 -24
  54. edsl/notebooks/Notebook.py +204 -0
  55. edsl/notebooks/__init__.py +1 -0
  56. edsl/questions/QuestionBase.py +109 -12
  57. edsl/questions/descriptors.py +5 -2
  58. edsl/questions/question_registry.py +7 -0
  59. edsl/results/Result.py +20 -8
  60. edsl/results/Results.py +85 -11
  61. edsl/results/ResultsDBMixin.py +3 -6
  62. edsl/results/ResultsExportMixin.py +47 -16
  63. edsl/results/ResultsToolsMixin.py +5 -5
  64. edsl/scenarios/Scenario.py +59 -5
  65. edsl/scenarios/ScenarioList.py +97 -40
  66. edsl/study/ObjectEntry.py +97 -0
  67. edsl/study/ProofOfWork.py +110 -0
  68. edsl/study/SnapShot.py +77 -0
  69. edsl/study/Study.py +491 -0
  70. edsl/study/__init__.py +2 -0
  71. edsl/surveys/Survey.py +79 -31
  72. edsl/surveys/SurveyExportMixin.py +21 -3
  73. edsl/utilities/__init__.py +1 -0
  74. edsl/utilities/gcp_bucket/__init__.py +0 -0
  75. edsl/utilities/gcp_bucket/cloud_storage.py +96 -0
  76. edsl/utilities/gcp_bucket/simple_example.py +9 -0
  77. edsl/utilities/interface.py +24 -28
  78. edsl/utilities/repair_functions.py +28 -0
  79. edsl/utilities/utilities.py +57 -2
  80. {edsl-0.1.27.dev1.dist-info → edsl-0.1.28.dist-info}/METADATA +43 -17
  81. {edsl-0.1.27.dev1.dist-info → edsl-0.1.28.dist-info}/RECORD +84 -54
  82. edsl-0.1.28.dist-info/entry_points.txt +3 -0
  83. edsl/conjure/RawResponseColumn.py +0 -327
  84. edsl/conjure/SurveyBuilder.py +0 -308
  85. edsl/conjure/SurveyBuilderCSV.py +0 -78
  86. edsl/conjure/SurveyBuilderSPSS.py +0 -118
  87. edsl/data/RemoteDict.py +0 -103
  88. {edsl-0.1.27.dev1.dist-info → edsl-0.1.28.dist-info}/LICENSE +0 -0
  89. {edsl-0.1.27.dev1.dist-info → edsl-0.1.28.dist-info}/WHEEL +0 -0
@@ -1,27 +1,41 @@
1
- edsl/Base.py,sha256=IlWEjQTnKbSPm9xqUqE7D6izBDnzARbrV_NHd7YJGeY,6601
2
- edsl/__init__.py,sha256=7UsuBUVcdmaz6je-0D1HvPG6X3ATtXud_hYpUrkU6H0,1182
3
- edsl/__version__.py,sha256=W5px3D8b9BN2pOYswec-dtjDZ-DG95Aqtxe0hW3KSz0,28
4
- edsl/agents/Agent.py,sha256=sPtYxD3ZJ3CqpsPV0nP0MaaqItqRTT787mcwtmxOrzg,25536
5
- edsl/agents/AgentList.py,sha256=CceqVJ-4sMJgOZ9YFODOaW-1hIthbMeNgi1NIbiiLuQ,7045
6
- edsl/agents/Invigilator.py,sha256=slNz5LTRAB53_DDhgR1WxU-6kBHivJZ6iNloGlLRSGs,10223
7
- edsl/agents/InvigilatorBase.py,sha256=jmmkco-YJPwXW8jQViDBU4n-qbrMynZ00qWvo9soMO0,7740
1
+ edsl/Base.py,sha256=7xc-2fmIGVx-yofU54w5eDU6WSl1AwgrNP2YncDd93M,8847
2
+ edsl/BaseDiff.py,sha256=RoVEh52UJs22yMa7k7jv8se01G62jJNWnBzaZngo-Ug,8260
3
+ edsl/__init__.py,sha256=p4GjE-YbPKoGhGY4YULtJ4N4Sb8hx2GVeLa2UIxj8_U,1347
4
+ edsl/__version__.py,sha256=MWZDdAHrdUZS0c3VlLqX4O1eaxPodI7irMtEvknKQ94,23
5
+ edsl/agents/Agent.py,sha256=_PvcQIjeJpyn-ZLOPl3d8f0UZ2AmW-PuHjl9nuhzOEY,25955
6
+ edsl/agents/AgentList.py,sha256=6zHzs7jQFBnNQIRz_zYGDyTGptyvqSqciVwr7kxwyEk,8479
7
+ edsl/agents/Invigilator.py,sha256=vUjNsQrE724Cepr1XvOp2CTER7GBGZ8XoVl6yzfbeP0,10061
8
+ edsl/agents/InvigilatorBase.py,sha256=IRk2aVSJM3cTXgyuuoc7Dc9oBs311UK0mjkTDmgCjbU,7282
8
9
  edsl/agents/PromptConstructionMixin.py,sha256=Yovq-7wZG8i95QLEee90Xi3AFp3TpbzGhM-kdKNLZNg,5129
9
10
  edsl/agents/__init__.py,sha256=a3H1lxDwu9HR8fwh79C5DgxPSFv_bE2rzQ6y1D8Ba5c,80
10
- edsl/agents/descriptors.py,sha256=FwyzM8gVgxxDjZhEPoNmR1xZYcjBYd8Lj8bTVLO_RKk,2861
11
+ edsl/agents/descriptors.py,sha256=T2OY6JvbPUC7GVBUKeLELcwPgjztTSi2bnbLfZqbaXY,2925
11
12
  edsl/config.py,sha256=0-do1zGqRF9VpvW---qlzkBvB70IHSQe2OH44ZdXOf8,5617
12
- edsl/conjure/RawResponseColumn.py,sha256=GEjkyEAI719RS-hYNhHkw7ShWv0XuMPY5i8Eyy_89eE,11608
13
- edsl/conjure/SurveyBuilder.py,sha256=0I4oEzNwS9W3sjKy2BdWElmqopIrKjir1LiOm1Iivzo,11173
14
- edsl/conjure/SurveyBuilderCSV.py,sha256=sZxR4vyqZ3PIkHXpWdd2EAaB53ygPv4eLq2ZmN4Pjws,2275
15
- edsl/conjure/SurveyBuilderSPSS.py,sha256=kdsToGgAQb2rc88K455geK-B3TtQtMVNKoPRuaiUGEM,3830
16
- edsl/conjure/__init__.py,sha256=3IyzMEQi9HFuB9JARG5MNlvoka6v06lBTah5l0EhYos,234
17
- edsl/conjure/utilities.py,sha256=rcKC5MabVqrTWTZ9nxHuRtopcyw6o_0fiNrNT7gbDxY,1712
13
+ edsl/conjure/AgentConstructionMixin.py,sha256=qLLYJH02HotVwBUYzaHs4QW0t5nsC3NX15qxQLzEwLI,5702
14
+ edsl/conjure/Conjure.py,sha256=KBmF3d6EjzTI5f-j_cZBowxWQx7jZqezHgfPMkh-h8M,1884
15
+ edsl/conjure/InputData.py,sha256=y2MOf0smzgG-KtDyL8PLygivspIXZuAaAJW_yzpTqHQ,20750
16
+ edsl/conjure/InputDataCSV.py,sha256=m4hHSQogxt7LNcGNxcGRkrbdGy8pIQu5KvXhIEt9i6k,1684
17
+ edsl/conjure/InputDataMixinQuestionStats.py,sha256=Jav5pqYCLSQ1pAbGV8O9VCBu0vL8Q6pteSEhRKrONuw,6256
18
+ edsl/conjure/InputDataPyRead.py,sha256=phGmzVi06jdbcxgngAp_lEawGkJr5dAC2B4ho5IrAy4,3064
19
+ edsl/conjure/InputDataSPSS.py,sha256=lv7NK8lpUfjsWh8h9MpqQrCjJX6Oyg3tIOrXcQYcS_4,223
20
+ edsl/conjure/InputDataStata.py,sha256=WbA7oUGHgHJgugKjakXzpFfzWxTI4bXGGSZLxM1-tEM,224
21
+ edsl/conjure/QuestionOptionMixin.py,sha256=RSLZ7AmA65MfwyxKKjqprR9FdkLP6MsCcmTbJoqu-MM,2870
22
+ edsl/conjure/QuestionTypeMixin.py,sha256=L2vU207aeezlI1OuJ4I4SdtFCWBZzE-mBk7VwnTghO8,892
23
+ edsl/conjure/RawQuestion.py,sha256=lo8k1aln4RfnfeS6OukzwC7P_cRe2LVZxcL6uwmim6A,2116
24
+ edsl/conjure/SurveyResponses.py,sha256=fdJNFasSXVf7S5KCsYE9WB6w17q7VRylzw0aD5zGO_M,191
25
+ edsl/conjure/__init__.py,sha256=1lPYFjV73GzYYSXiTyxopM4nKcXVHumEEo0fe06DbMo,535
26
+ edsl/conjure/examples/placeholder.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ edsl/conjure/naming_utilities.py,sha256=8uoGaCPZQKLwz2HudtsFSovivTGumQrFYxXxck5WUZQ,4964
28
+ edsl/conjure/utilities.py,sha256=yRdOJx9KIpWXMx41Bbfysx7Zd4v2ROwca5L4T1rmtQM,5539
29
+ edsl/conversation/Conversation.py,sha256=NdWH62XpcF6hoaG0ScMho_c3TO7PfBnbdlppUN-j07k,7627
30
+ edsl/conversation/car_buying.py,sha256=70nCXQNCc2kR-NBY6YOPHfkuZ5g7nww2r4GwlYosV4A,1948
31
+ edsl/conversation/mug_negotiation.py,sha256=mjvAqErD4AjN3G2za2c-X-3axOShW-zAJUeiJqTxVPA,2616
32
+ edsl/conversation/next_speaker_utilities.py,sha256=bqr5JglCd6bdLc9IZ5zGOAsmN2F4ERiubSMYvZIG7qk,3629
18
33
  edsl/coop/__init__.py,sha256=4iZCwJSzJVyjBYk8ggGxY2kZjq9dXVT1jhyPDNyew4I,115
19
- edsl/coop/coop.py,sha256=3JvGNDYicfb8P7Q6AX2kmCZuTUNlmWXfTUOaDCZXWHs,17781
20
- edsl/coop/utils.py,sha256=mXKx9b3L6i8FHBmnK-P6KjAmDXtzyw3FRwQ0filIOxM,3361
21
- edsl/data/Cache.py,sha256=Ux0Qu__ScFe_rgYW_zRV3fs9oaa4jvXZ4gpyFELoK4I,13610
34
+ edsl/coop/coop.py,sha256=JfcbOv487mG9rc5k_iXWTsrB60pwbj6eljtcDj_mY5A,24854
35
+ edsl/coop/utils.py,sha256=OVfVUIBCH5ATj0yFLe0Ui0_KYGwwzWsVHqyavVVaN_w,3773
36
+ edsl/data/Cache.py,sha256=f7tuzuA7T4C9qp8BP45UamcmJbvH8RGClr9lbf7PS1s,14880
22
37
  edsl/data/CacheEntry.py,sha256=AnZBUautQc19KhE6NkI87U_P9wDZI2eu-8B1XopPTOI,7235
23
- edsl/data/CacheHandler.py,sha256=rPWhQ-kzVq6WoSdst4c30wzQkNrwr9xuVapiLn360Ck,4776
24
- edsl/data/RemoteDict.py,sha256=GTm_m6S2I4ZO2QH6T-OIf9LymAZFdvl7tA7D3hrFFD4,3124
38
+ edsl/data/CacheHandler.py,sha256=DTr8nJnbl_SidhsDetqbshu1DV-njPFiPPosUWTIBok,4789
25
39
  edsl/data/SQLiteDict.py,sha256=2asiSJyQxWmIhbWuuPzWWOr3PZBRSKsJubNN7nrCdq4,8803
26
40
  edsl/data/__init__.py,sha256=KBNGGEuGHq--D-TlpAQmvv_If906dJc1Gsy028zOx78,170
27
41
  edsl/data/orm.py,sha256=Jz6rvw5SrlxwysTL0QI9r68EflKxeEBmf6j6himHDS8,238
@@ -39,35 +53,38 @@ edsl/exceptions/prompts.py,sha256=vD_reI-RVKWYHYozenEmhmB7Rb1sIiXghgNUtbVGBUo,24
39
53
  edsl/exceptions/questions.py,sha256=9z6RI7HRH-UMrnIlt28VTj9deCSbD1Frmpqi0H6YtF0,534
40
54
  edsl/exceptions/results.py,sha256=cn6Zb86Y648ulN3RYXb52HGv1NT3ykBfE6g2Xu8TeIw,325
41
55
  edsl/exceptions/surveys.py,sha256=lADtr-tvPmUYSfRy3TdkTV5SzZfShlMgCzm-ZGYRlGk,557
42
- edsl/inference_services/AnthropicService.py,sha256=sHpe3F3QhUo7c94j2nfgdgm8wrHpkS1ViAiE083Pd-g,2780
43
- edsl/inference_services/DeepInfraService.py,sha256=vRYfY-0TAdw3j6GZvCDIJ4OtdqZSLAEwHwA2X0gIeFI,3595
44
- edsl/inference_services/GoogleService.py,sha256=c_hG98wb94dpHSVIl7Or6Pgvtla8c-h-rXdze7dklD8,2498
56
+ edsl/inference_services/AnthropicService.py,sha256=tjYRJRIvQ7Z6uCYdqxm5ZlVjZdVZCnHtQ6QGHT59PXs,2822
57
+ edsl/inference_services/DeepInfraService.py,sha256=fpjLJl7gyUFWVdR6U7XwIspD_pH5x55f4LamKT01Et4,3853
58
+ edsl/inference_services/GoogleService.py,sha256=IwSwXr7khvHjpDzgiW5PRVKMhI2wQ9D1_H1MRnHjefU,2732
45
59
  edsl/inference_services/InferenceServiceABC.py,sha256=H6jW2gDKTLC3xgmqiSBdX4pGY1oauEO8VqGZoB3qvnQ,1790
46
- edsl/inference_services/InferenceServicesCollection.py,sha256=negjHM2Z8HZn9r-uyle2r7AEfQXliO4K5AolvSJr8sg,1337
47
- edsl/inference_services/OpenAIService.py,sha256=FMZt2JTEt0WGR1vwoFp8JsG_h3s2XFD244Nns48XrhE,5780
60
+ edsl/inference_services/InferenceServicesCollection.py,sha256=1ulvUYs2gaJsb7t8Mkua-6_3gff6rJmH72_BbItkaCE,2274
61
+ edsl/inference_services/OpenAIService.py,sha256=OvczbY2wlEehZdaaMq69yeqzkjdrbbXlP8uC9WjgHq0,6021
48
62
  edsl/inference_services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
+ edsl/inference_services/models_available_cache.py,sha256=ZT2pBGxJqTgwynthu-SqBjv8zl7ql44q3gA6xy7kqSU,2338
64
+ edsl/inference_services/rate_limits_cache.py,sha256=HYslviz7mxF9U4CUTPAkoyBsiXjSju-YCp4HHir6e34,1398
49
65
  edsl/inference_services/registry.py,sha256=-Yz86do-KZraunIrziVs9b95EbY-__JUnQb5Ulni7KI,483
66
+ edsl/inference_services/write_available.py,sha256=NNwhATlaMp8IYY635MSx-oYxt5X15acjAfaqYCo_I1Y,285
50
67
  edsl/jobs/Answers.py,sha256=mtSjlRbVJbqZKA6DBngEwDxIfloRAKkrsTRriMTPRD4,1493
51
- edsl/jobs/Jobs.py,sha256=k8WY2MNgVyrSW208sycFDtaG3U1kfG-mfFJS2ihvXyA,20142
68
+ edsl/jobs/Jobs.py,sha256=aCncdADfc834GLwUEWrOqqLWoqhqE31slZMoSu6sQ2c,27019
52
69
  edsl/jobs/__init__.py,sha256=aKuAyd_GoalGj-k7djOoVwEbFUE2XLPlikXaA1_8yAg,32
53
- edsl/jobs/buckets/BucketCollection.py,sha256=CJD-G4coDCXucrzVk_xHwvP0LpbuFkihy9VuT4d4xXU,1648
70
+ edsl/jobs/buckets/BucketCollection.py,sha256=LA8DBVwMdeTFCbSDI0S2cDzfi_Qo6kRizwrG64tE8S4,1844
54
71
  edsl/jobs/buckets/ModelBuckets.py,sha256=1_WPi1wV5k8kO9TuLEA7tDt9rF_myaC5XKyf4T0EmQ8,1969
55
72
  edsl/jobs/buckets/TokenBucket.py,sha256=IfzhtrQ6i3LlJ_PHmFN-OLIWEqr9n-2_FLbE5-fethU,5213
56
- edsl/jobs/interviews/Interview.py,sha256=ATzeg7cnHsFI6M6sggqXJwMbGuGQ-LvJqFWihhtdoac,9698
73
+ edsl/jobs/interviews/Interview.py,sha256=3gsNjM761lUsM7GT8b64psSzjyWgko1cSuR89e7mZz4,9855
57
74
  edsl/jobs/interviews/InterviewStatistic.py,sha256=hY5d2EkIJ96NilPpZAvZZzZoxLXM7ss3xx5MIcKtTPs,1856
58
75
  edsl/jobs/interviews/InterviewStatisticsCollection.py,sha256=_ZZ0fnZBQiIywP9Q_wWjpWhlfcPe2cn32GKut10t5RI,788
59
76
  edsl/jobs/interviews/InterviewStatusDictionary.py,sha256=MSyys4hOWe1d8gfsUvAPbcKrs8YiPnz8jpufBSJL7SU,2485
60
77
  edsl/jobs/interviews/InterviewStatusLog.py,sha256=6u0F8gf5tha39VQL-IK_QPkCsQAYVOx_IesX7TDDX_A,3252
61
78
  edsl/jobs/interviews/InterviewStatusMixin.py,sha256=VV0Pel-crUsLoGpTifeIIkXsLGj0bfuO--UtpRnH-dU,1251
62
- edsl/jobs/interviews/InterviewTaskBuildingMixin.py,sha256=L98ChYC57l1DjNK2POUxyvQHCZtSeQHnmcJkERcaG1s,11058
79
+ edsl/jobs/interviews/InterviewTaskBuildingMixin.py,sha256=0RabzKbMwc5Calr94bHDtzFqi8xQ1l2-DYHApEo5kEw,11606
63
80
  edsl/jobs/interviews/ReportErrors.py,sha256=RSzDU2rWwtjfztj7sqaMab0quCiY-X2bG3AEOxhTim8,1745
64
81
  edsl/jobs/interviews/interview_exception_tracking.py,sha256=tIcX92udnkE5fcM5_WXjRF9xgTq2P0uaDXxZf3NQGG0,3271
65
82
  edsl/jobs/interviews/interview_status_enum.py,sha256=KJ-1yLAHdX-p8TiFnM0M3v1tnBwkq4aMCuBX6-ytrI8,229
66
- edsl/jobs/interviews/retry_management.py,sha256=OKhI7yhFJuxDbOSAt-tKzwa5INgwVBTsql2Vv9BMk6E,1380
67
- edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=vk3VuflRIDgHiSRxXP7uVkhoEBJ-tubNa2A7w190Zwc,10224
68
- edsl/jobs/runners/JobsRunnerStatusData.py,sha256=5yIX-Kxu0G41OkahAIYF11HSbAjqeuousTs_B6yqfuU,10320
83
+ edsl/jobs/interviews/retry_management.py,sha256=9Efn4B3aV45vbocnF6J5WQt88i2FgFjoi5ALzGUukEE,1375
84
+ edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=hAsi7UJ8hV5K2a96RNIVzhjsYqYqAQp8uySYIzy6eBk,11843
85
+ edsl/jobs/runners/JobsRunnerStatusData.py,sha256=-mxcmX0a38GGO9DQ-ItTmj6mvCUk5uC-UudT77lXTG4,10327
69
86
  edsl/jobs/runners/JobsRunnerStatusMixin.py,sha256=yxnXuOovwHgfDokNuluH_qulBcM0gCcbpCQibqVKXFI,3137
70
- edsl/jobs/tasks/QuestionTaskCreator.py,sha256=CzsWaPTJz0Yog6bDOYVit_kKjc0Hlh5VVws2zMzrphk,10172
87
+ edsl/jobs/tasks/QuestionTaskCreator.py,sha256=SXO_ITNPAXh9oBvCh8rcbH9ln0VjOyuM_i2IrRDHnIo,10231
71
88
  edsl/jobs/tasks/TaskCreators.py,sha256=DbCt5BzJ0CsMSquqLyLdk8el031Wst7vCszVW5EltX8,2418
72
89
  edsl/jobs/tasks/TaskHistory.py,sha256=Dqzk-IQUMvf0U5TJQFXw7SxJbwPEkKtrB7QaU5HaF_k,10927
73
90
  edsl/jobs/tasks/TaskStatusLog.py,sha256=bqH36a32F12fjX-M-4lNOhHaK2-WLFzKE-r0PxZPRjI,546
@@ -75,12 +92,15 @@ edsl/jobs/tasks/task_management.py,sha256=KMToZuXzMlnHRHUF_VHL0-lHMTGhklf2GHVuwE
75
92
  edsl/jobs/tasks/task_status_enum.py,sha256=DOyrz61YlIS8R1W7izJNphcLrJ7I_ReUlfdRmk23h0Q,5333
76
93
  edsl/jobs/tokens/InterviewTokenUsage.py,sha256=u_6-IHpGFwZ6qMEXr24-jyLVUSSp4dSs_4iAZsBv7O4,1100
77
94
  edsl/jobs/tokens/TokenUsage.py,sha256=odj2-wDNEbHl9noyFAQ0DSKV0D9cv3aDOpmXufKZ8O4,1323
78
- edsl/language_models/LanguageModel.py,sha256=O7y_8NNoYS1WQ5yskWoFU5c8N7msWmuR4gK0PoyAxo8,19286
95
+ edsl/language_models/LanguageModel.py,sha256=QoltKz6IEK59jKPG3dEI1Si5_9UgqzIAmdTLz5q54nU,19039
96
+ edsl/language_models/ModelList.py,sha256=zRDbYQbG9guJl6o01Pv-BjTAAJIFgCZrSCEJVKUBvbs,2657
79
97
  edsl/language_models/RegisterLanguageModelsMeta.py,sha256=2bvWrVau2BRo-Bb1aO-QATH8xxuW_tF7NmqBMGDOfSg,8191
80
98
  edsl/language_models/__init__.py,sha256=bvY7Gy6VkX1gSbNkRbGPS-M1kUnb0EohL0FSagaEaTs,109
81
- edsl/language_models/registry.py,sha256=vUJIS89lJXg5OIlz7dq32SEOL7-OI6pRbTGE-2QRicM,2758
82
- edsl/language_models/repair.py,sha256=YJYo_PXrbqqOLB_lWYL4RQ0X2nYozl9IycYUi6rueLU,3336
99
+ edsl/language_models/registry.py,sha256=J7blAbRFHxr2nWSoe61G4p-6kOgzUlKclJ55xVldKWc,3191
100
+ edsl/language_models/repair.py,sha256=6KenPSbbQuS7YAhwQPECX1gD6o5E4eqEmIlrUi9UmuM,5926
83
101
  edsl/language_models/unused/ReplicateBase.py,sha256=J1oqf7mEyyKhRwNUomnptVqAsVFYCbS3iTW0EXpKtXo,3331
102
+ edsl/notebooks/Notebook.py,sha256=ozsSfmmfVSF3-2CwpK51i8cARSjOOOEGvZ_gGhqIAzE,6045
103
+ edsl/notebooks/__init__.py,sha256=VNUA3nNq04slWNbYaNrzOhQJu3AZANpvBniyCJSzJ7U,45
84
104
  edsl/prompts/Prompt.py,sha256=LIfM5RwnhyJFOAmVdd5GlgMtJNWcMjG0TszMTJfidFc,9554
85
105
  edsl/prompts/QuestionInstructionsBase.py,sha256=xico6ob4cqWsHl-txj2RbY_4Ny5u9UqvIjmoTVgjUhk,348
86
106
  edsl/prompts/__init__.py,sha256=Z0ywyJfnV0i-sR1SCdK4mHhgECT5cXpHVA-pKuBTifc,85
@@ -98,7 +118,7 @@ edsl/prompts/library/question_rank.py,sha256=WDgXyph0EKWJrSgsW2eqcx3xdU-WA1LEvB2
98
118
  edsl/prompts/prompt_config.py,sha256=O3Y5EvBsCeKs9m9IjXiRXOcHWlWvQV0yqsNb2oSR1ow,974
99
119
  edsl/prompts/registry.py,sha256=XOsqGsvNOmIG83jqoszqI72yNZkkszKR4FrEhwSzj_Q,8093
100
120
  edsl/questions/AnswerValidatorMixin.py,sha256=U5i79HoEHpSoevgtx68TSg8a9tELq3R8xMtYyK1L7DQ,12106
101
- edsl/questions/QuestionBase.py,sha256=WnzF06okPsZzJuTk1Am06OpEUBzf20k4kHjf-ndIZdg,14672
121
+ edsl/questions/QuestionBase.py,sha256=5EbRKXnQIt0TYSHzQcyAP2VV5OV5rrxPYTnDImNg37o,17928
102
122
  edsl/questions/QuestionBudget.py,sha256=JLp_vsdrJO7j6e9oztYvgZzrI-MzXNeWkYp5-H2S-gQ,6170
103
123
  edsl/questions/QuestionCheckBox.py,sha256=8myLLvSz7jNYuuarUnscGYAUVYOhLLo-XwGUv_YfTSk,6076
104
124
  edsl/questions/QuestionExtract.py,sha256=F3_gzXAYYSNOOA-SMwmWYLEZB3rxAVS9Er4GoS9B_zs,3975
@@ -117,33 +137,38 @@ edsl/questions/derived/QuestionLinearScale.py,sha256=7tybIaMaDTMkTFC6CymusW69so-
117
137
  edsl/questions/derived/QuestionTopK.py,sha256=TouXKZt_h6Jd-2rAjkEOCJOzzei4Wa-3hjYq9CLxWws,2744
118
138
  edsl/questions/derived/QuestionYesNo.py,sha256=KtMGuAPYWv-7-9WGa0fIS2UBxf6KKjFpuTk_h8FPZbg,2076
119
139
  edsl/questions/derived/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
120
- edsl/questions/descriptors.py,sha256=JKqIbn-ov3cVR1-tv01mmEPVFgvxKSMsdS3wuUoV7Cs,13226
121
- edsl/questions/question_registry.py,sha256=gM6YqmpIHOTwUXM09GK5oNbs39JwCQti0x7Yp25VDm4,5260
140
+ edsl/questions/descriptors.py,sha256=Fjaz8Kz-jMJ4B3VJ9yet9ixFQynLAYkjcXIRsmTVCG4,13283
141
+ edsl/questions/question_registry.py,sha256=7JvkwFzItwNTXjMwbdfpbZQT_WAXOBxjlSJGCIJ-c1c,5546
122
142
  edsl/questions/settings.py,sha256=Qk2imv_7N8uFGLoTEr163lbaKPbD2Begd17Hbh4GZKA,290
123
143
  edsl/results/Dataset.py,sha256=v_6e1khpfs5Ft-b7GgTKhitr4l9sys4rb_4z-dOdj68,7737
124
- edsl/results/Result.py,sha256=yDK1S09XprkfdVudOkXpapRx1NoXzFixCM0kcf50Uh4,13518
125
- edsl/results/Results.py,sha256=Drm4e__4UosGFyV0EUFK2668D9VeeUa-1hEqEDIPFXs,32216
126
- edsl/results/ResultsDBMixin.py,sha256=EZPxWgVF5aRTd12uAZHqRTC6jTvz6tJatQCF7HTThF4,8135
127
- edsl/results/ResultsExportMixin.py,sha256=dLLP7DXfm_A9kxdJMR4wN7BgIDaD3qmNdkNqFaPDdl0,19371
144
+ edsl/results/Result.py,sha256=IvUFq23LwlBP7JN1QDap1fPTTIPUC0QlYEE4lsiKRqI,13913
145
+ edsl/results/Results.py,sha256=xCAv6-azf9jdBuvGUAz8AdgaOjVINsPWqIkJqprecHw,34939
146
+ edsl/results/ResultsDBMixin.py,sha256=Dv34yBuF5tkeoYnzbN1YwuBwKh1T-Y77YOYcWlu-GLY,7883
147
+ edsl/results/ResultsExportMixin.py,sha256=KQ1GE2JDzrnl4XkyAGnCdgiFtF_mZrhFNDfkNPg_8C8,20501
128
148
  edsl/results/ResultsFetchMixin.py,sha256=VEa0TKDcXbnTinSKs9YaE4WjOSLmlp9Po1_9kklFvSo,848
129
149
  edsl/results/ResultsGGMixin.py,sha256=h5OBPdgUeNg6I_GizOvUvBe7CPz8wrZV9N7dk8W3gkU,4347
130
- edsl/results/ResultsToolsMixin.py,sha256=pUJNwv_s1gwxRfnovweJfQe-nUplmeP1P1do4obOx2I,2938
150
+ edsl/results/ResultsToolsMixin.py,sha256=EMfbhw4CuYVEJZ2xPJcCcaW0Dr-r9wpNJ0X-uF8UgS4,2939
131
151
  edsl/results/__init__.py,sha256=2YcyiVtXi-3vIV0ZzOy1PqBLm2gaziufJVi4fdNrAt8,80
132
- edsl/scenarios/Scenario.py,sha256=vJvlhfdF5J62teCPXXeOH-w9nsLzYmKOKfLM4VIawrs,13305
152
+ edsl/scenarios/Scenario.py,sha256=C2HPOcP8YypcWffay6AA4cSPlD35xeMywiDomLCRHcY,14768
133
153
  edsl/scenarios/ScenarioHtmlMixin.py,sha256=EmugmbPJYW5eZS30rM6pDMDQD9yrrvHjmgZWB1qBfq4,1882
134
154
  edsl/scenarios/ScenarioImageMixin.py,sha256=VJ5FqyPrL5-ieORlWMpnjmOAFIau8QFZCIZyEBKgb6I,3530
135
- edsl/scenarios/ScenarioList.py,sha256=i1Q4ByBnVV20XCshjthN1ZfxQHMgHJ8ngFC79hBlMcQ,15865
155
+ edsl/scenarios/ScenarioList.py,sha256=TGyV94T5FmIgYmdf8IjroY-gW8s6CtCsM4D7JJNvRVA,17606
136
156
  edsl/scenarios/ScenarioListPdfMixin.py,sha256=0xV033SMygr_ObamXwjbzfxEQ0zFEwAJ1w7Wq1ejjUY,3719
137
157
  edsl/scenarios/__init__.py,sha256=a2CIYQWh9bLeYY4qBJBz7ui7RfxpVd0WlYDf8TaT2D0,45
138
158
  edsl/shared.py,sha256=lgLa-mCk2flIhxXarXLtfXZjXG_6XHhC2A3O8yRTjXc,20
159
+ edsl/study/ObjectEntry.py,sha256=AX3HtPfYlEM1gaa5RIgKyoTxWALakL2yiY2r2Vmg0G4,3164
160
+ edsl/study/ProofOfWork.py,sha256=Rcf96Mch4qWersHNBq-vWUePGk1D4KmvNTSR2TfFjs8,3398
161
+ edsl/study/SnapShot.py,sha256=Q_4NPznB3rwOuIuUep1Bw7tenK3cnw-gctDrOq-2Qpk,2364
162
+ edsl/study/Study.py,sha256=gJEY_aYCu5JoxT836G4Zqm4M2IP_NeJ7-Poy6BI_I2w,16658
163
+ edsl/study/__init__.py,sha256=HzE6z2vgmY19NNOW2s9R_WkmNzqswtkw53XV5fiE6ws,94
139
164
  edsl/surveys/DAG.py,sha256=ozQuHo9ZQ8Eet5nDXtp7rFpiSocvvfxIHtyTnztvodg,2380
140
165
  edsl/surveys/Memory.py,sha256=-ikOtkkQldGB_BkPCW3o7AYwV5B_pIwlREw7aVCSHaQ,1113
141
166
  edsl/surveys/MemoryPlan.py,sha256=k65OP2oozG_d99OpkBqXXWH5iXxS-ois3hTf8_1iuj8,7786
142
167
  edsl/surveys/Rule.py,sha256=ddZyZSObs4gsKtFSmcXkPigXDX8rrh1NFvAplP02TcA,11092
143
168
  edsl/surveys/RuleCollection.py,sha256=sN7aYDQJG3HmE-WxohgpctcQbHewjwE6NAqEVTxvFP8,13359
144
- edsl/surveys/Survey.py,sha256=_chMrwjzDDfC0EfAQKqZjTXTayxWwdjDJJAIPnuoyMs,43778
169
+ edsl/surveys/Survey.py,sha256=Ao1AJpUCebmx30vLpNvUf524ENrmUzddiyfOiypbkV4,45526
145
170
  edsl/surveys/SurveyCSS.py,sha256=NjJezs2sTlgFprN6IukjGKwNYmNdXnLjzV2w5K4z4RI,8415
146
- edsl/surveys/SurveyExportMixin.py,sha256=egLqkqaDFW-bar0GaeEbEM3yQp4xWGJUejvqUiIaLCI,5775
171
+ edsl/surveys/SurveyExportMixin.py,sha256=jVdHVrsXZrKLX9rNsZkWU61kXiUUjlonK_CGqJ7rhbI,6537
147
172
  edsl/surveys/SurveyFlowVisualizationMixin.py,sha256=iPjtGeoVK9ObMVDxrLf4EMgbPl95LZ_IzVxgkk9B-WQ,3918
148
173
  edsl/surveys/__init__.py,sha256=vjMYVlP95fHVqqw2FfKXRuYbTArZkZr1nK4FnXzZWzs,129
149
174
  edsl/surveys/base.py,sha256=n5PBx0BF0powzBXCsufpUekfNK_9huf3rohtU1mMCq0,1001
@@ -155,16 +180,21 @@ edsl/tools/embeddings_plotting.py,sha256=fznAqLnjF_K8PkJy1C4hBRObm3f8ebDIxQzrqRX
155
180
  edsl/tools/plotting.py,sha256=fzDw5IebaKeYH70qMkoirPx8rRah_49WO9RQpl_It5c,3093
156
181
  edsl/tools/summarize.py,sha256=YcdB0IjZn92qv2zVJuxsHfXou810APWYKeaHknsATqM,656
157
182
  edsl/utilities/SystemInfo.py,sha256=qTP_aKwECPxtTnbEjJ7F1QqKU9U3rcEEbppg2ilQGuY,792
158
- edsl/utilities/__init__.py,sha256=SCDcBNtAeJrIrH4uGyE4OwQVm9IuQTFxN3JJR0zBEog,478
183
+ edsl/utilities/__init__.py,sha256=2AlIXF-iMS-vZyF8lUY7eGO671ONE4YCvX7iUfi2RPA,502
159
184
  edsl/utilities/ast_utilities.py,sha256=49KDDu-PHYpzDN5cCaDf-ReQH-1dzjT5EG3WVSa8THk,868
160
185
  edsl/utilities/data/Registry.py,sha256=q2DKc7CpG_7l47MxxsSi6DJOs4p1Z3qNx7PV-v8CUOE,176
161
186
  edsl/utilities/data/__init__.py,sha256=pDjGnzC11q4Za8qX5zcg6plcQ_8Qjpb-sAKPwOlKmCY,62
162
187
  edsl/utilities/data/scooter_results.json,sha256=tRtVAI5haLMh_-wjz9it_uk_I1bGe5qdFHsIRQMi_ks,250944
163
188
  edsl/utilities/decorators.py,sha256=rlTSMItwmWUxHQBIEUDxX3lFzgtiT8PnfNavakuf-2M,2319
164
- edsl/utilities/interface.py,sha256=GxEDMxmpnyxcy71yzdDNqdoh7GLrDEbTD0y9M81ZkZk,19084
189
+ edsl/utilities/gcp_bucket/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
190
+ edsl/utilities/gcp_bucket/cloud_storage.py,sha256=dStHsG181YP9ALW-bkyO-sgMWuLV5aaLsnsCOVD8jJw,3472
191
+ edsl/utilities/gcp_bucket/simple_example.py,sha256=pR_IH_Y640_-YnEyNpE7V_1MtBFC9nD3dg2NdSVcuXY,251
192
+ edsl/utilities/interface.py,sha256=U8iScZb4jB1npPwbndpjCove59ow2cbAST4fl-46FdI,19160
193
+ edsl/utilities/repair_functions.py,sha256=tftmklAqam6LOQQu_-9U44N-llycffhW8LfO63vBmNw,929
165
194
  edsl/utilities/restricted_python.py,sha256=5-_zUhrNbos7pLhDl9nr8d24auRlquR6w-vKkmNjPiA,2060
166
- edsl/utilities/utilities.py,sha256=YLzbA3kBFisy8fWpodrwi-CsKlMhbUwZ89RYyCNRq4Q,8708
167
- edsl-0.1.27.dev1.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
168
- edsl-0.1.27.dev1.dist-info/METADATA,sha256=guo5KBMnHbGrV5f105chU5YSR7trDyKGijyYrYcqTGc,3128
169
- edsl-0.1.27.dev1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
170
- edsl-0.1.27.dev1.dist-info/RECORD,,
195
+ edsl/utilities/utilities.py,sha256=7LOMa1ahhi2t3SRwEs3VjroAj0A-5Q-Cn83v0HESADQ,10113
196
+ edsl-0.1.28.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
197
+ edsl-0.1.28.dist-info/METADATA,sha256=jh2_asIb3GQcl89X7NdtesPTr1dLM8H7jQDZLjqOnlY,4097
198
+ edsl-0.1.28.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
199
+ edsl-0.1.28.dist-info/entry_points.txt,sha256=yqJs04hJLRusoLzIYXGv8tl4TH__0D5SDRwLKV9IJCg,56
200
+ edsl-0.1.28.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ postinstall=scripts.postinstall:main
3
+
@@ -1,327 +0,0 @@
1
- from collections import UserDict
2
- from typing import List, Dict, Optional
3
- import textwrap
4
- import re
5
-
6
- from edsl.questions.QuestionBase import QuestionBase
7
- from edsl.questions.QuestionFreeText import QuestionFreeText
8
-
9
- from edsl.conjure.utilities import convert_value, Missing
10
-
11
-
12
- class KeyValidator:
13
- """A class to represent a key validator.
14
-
15
- >>> k = KeyValidator()
16
- >>> k.validate_key("asdf")
17
- True
18
- >>> k.validate_key("ASDF")
19
- False
20
-
21
- """
22
-
23
- def __set_name__(self, owner, name):
24
- self.name = name
25
-
26
- def validate_key(self, key):
27
- if not isinstance(key, str):
28
- # "Key must be a string"
29
- return False
30
- if key.lower() != key:
31
- # "Key must be lowercase"
32
- return False
33
- if not key.isidentifier() or not re.match(r"^[a-zA-Z_][a-zA-Z0-9_]*$", key):
34
- # raise ValueError("Key must be a valid Python identifier")
35
- return False
36
- return True
37
-
38
-
39
- class ReplacementFinder:
40
- """This class finds a replacement name for a bad question name.
41
-
42
- >>> r = ReplacementFinder(lookup_dict = {'Poop ': 'poop'})
43
- >>> r('Poop ')
44
- 'poop'
45
-
46
- """
47
-
48
- def __init__(self, lookup_dict: Optional[dict] = None):
49
- if lookup_dict is None:
50
- lookup_dict = {}
51
-
52
- self.lookup_dict = lookup_dict
53
-
54
- def __call__(self, bad_question_name):
55
- """Finds a replacement name for a bad question name.
56
- TODO: We should add a check to see if the new name is already in use.
57
- """
58
- if bad_question_name in self.lookup_dict:
59
- return self.lookup_dict[bad_question_name]
60
-
61
- q = QuestionFreeText(
62
- question_text=f"""We have a survey with a question name: {bad_question_name}.
63
- The question name is not a valid Python identifier.
64
- We need a valid Python identifier to use as a column name in a dataframe.
65
- What would be a better name for this question?
66
- Shorter is better.
67
- Just return the proposed identifier with no other text.
68
- """,
69
- question_name="identifier",
70
- )
71
- new_identifer = q.run().select("identifier").first().lower()
72
- self.lookup_dict[bad_question_name] = new_identifer
73
- return new_identifer
74
-
75
- def __repr__(self):
76
- return f"ReplacementFinder({self.lookup_dict})"
77
-
78
- def to_json(self):
79
- return self.lookup_dict
80
-
81
- @classmethod
82
- def from_json(cls, json_dict):
83
- return cls(json_dict)
84
-
85
-
86
- get_replacement_name = ReplacementFinder({})
87
-
88
-
89
- class CustomDict(UserDict):
90
- """
91
- This class is a dictionary that only allows lowercase keys that are valid Python identifiers.
92
- If a key is not a valid Python identifier, it will be replaced with a valid Python identifier.
93
-
94
- >>> d = CustomDict()
95
- >>> d = CustomDict({"7asdf": 123, "FAMILY": 12})
96
- >>> d
97
- {'q7asdf': 123, 'family': 12}
98
- """
99
-
100
- key_validator = KeyValidator()
101
-
102
- def __init__(self, data=None, verbose=False):
103
- super().__init__()
104
- self.verbose = verbose
105
- if data:
106
- for key, value in data.items():
107
- self[key] = value
108
-
109
- def __setitem__(self, key, value):
110
- if key != key.lower():
111
- key = key.lower()
112
- while not self.key_validator.validate_key(key):
113
- if self.verbose:
114
- print(f"Column heading incapable of being a key: {key}")
115
- if key in get_replacement_name.lookup_dict:
116
- key = get_replacement_name.lookup_dict[key]
117
- else:
118
- key = get_replacement_name(key)
119
- if self.verbose:
120
- print(f"New key: {key}")
121
- super().__setitem__(key, value)
122
-
123
-
124
- class RawResponseColumn:
125
- """A class to represent a raw responses from a survey we are parsing.
126
-
127
- If the dataset was square, we would think of this as a column in a dataframe.
128
-
129
- """
130
-
131
- def __init__(
132
- self,
133
- question_name: str,
134
- raw_responses: List[str],
135
- answer_codebook: Dict[str, str],
136
- question_text: str,
137
- ):
138
- """
139
- :param question_name: The name of the question.
140
- :param raw_responses: A list of responses to the question.
141
- :param answer_codebook: A dictionary mapping the raw responses to the actual responses.
142
- :param question_text: The text of the question.
143
-
144
- >>> r = RawResponseColumn(question_name="Q1", raw_responses=["1", "2", "3"], answer_codebook={"1": "Yes", "2": "No"}, question_text="Do you like ice cream?")
145
- >>> r.responses
146
- ['Yes', 'No', '3']
147
- >>> r.question_name
148
- 'q1'
149
-
150
- >>> r = RawResponseColumn(question_name="Q1", raw_responses=["1", "2", "3"], answer_codebook={"1": "Yes", "2": "No"}, question_text="Do you like ice cream?")
151
- >>> r.inferred_question_type
152
- 'multiple_choice'
153
-
154
- """
155
- d = CustomDict(
156
- {question_name: ""}
157
- ) # if the question_name is not a valid Python identifier, it will be replaced with a valid Python identifier.
158
- self.question_name = list(d.keys())[0]
159
- self.raw_responses = raw_responses
160
- self.answer_codebook = answer_codebook
161
- if question_text is None or len(question_text) == 0:
162
- self.question_text = "Question text not available"
163
- else:
164
- self.question_text = question_text
165
-
166
- @staticmethod
167
- def edsl_question_inference(question_text, responses):
168
- """Infer the question type from the responses.
169
-
170
- TODO: Not currently used. We should use this to infer the question type.
171
-
172
- >>> from edsl import QuestionFreeText
173
- >>> q = QuestionFreeText(question_text="Tell me about your childhood.", question_name = 'color')
174
- >>> r = RawResponseColumn.edsl_question_inference(q.question_text, ["Rather not say", "Happy!", "luge lessons and meat helmets"])
175
- >>> r
176
- 'free_text'
177
-
178
- """
179
- from edsl.questions import QuestionMultipleChoice
180
-
181
- q = QuestionMultipleChoice(
182
- question_text="""We have a survey question and we are trying to infer its type.
183
- The question text is: '{{question_text}}'.
184
- The first few responses are: '{{responses}}'.
185
- """,
186
- question_name="infer_question_type",
187
- question_options=[
188
- "budget",
189
- "checkbox",
190
- "extract",
191
- "free_text",
192
- "likert_five",
193
- "linear_scale",
194
- "list",
195
- "multiple_choice",
196
- "numerical",
197
- "rank",
198
- "top_k",
199
- "yes_no",
200
- ],
201
- )
202
- response = (
203
- q.to_survey()(question_text=question_text, responses=responses)
204
- .select("infer_question_type")
205
- .first()
206
- )
207
- return response
208
-
209
- @property
210
- def responses(self):
211
- """Returns the responses, with the answer codebook applied."""
212
- if hasattr(self, "answer_codebook") is None:
213
- converted_responses = [convert_value(x) for x in self.raw_responses]
214
- return converted_responses
215
- else:
216
- return [self.answer_codebook.get(x, x) for x in self.raw_responses]
217
-
218
- @property
219
- def inferred_question_type(self):
220
- "Tries to infer the type of question from the responses and other information"
221
- max_items = 15
222
- options = list(self.unique_responses.keys())
223
- if len(options) > max_items or len(options) <= 1:
224
- return "free_text"
225
- else:
226
- cv = [convert_value(o) for o in options]
227
- return "multiple_choice"
228
-
229
- def get_ordering(self, options_list):
230
- """Returns a multiple choice question with the options in the correct order.
231
- For example, if the options are ["<10", "10-20", "30+", "20-30"], the question would be:
232
- """
233
- from edsl.questions.QuestionList import QuestionList
234
-
235
- q = QuestionList(
236
- question_text=textwrap.dedent(
237
- """\
238
- We have a survey question with the following options: '{{options_list}}'.
239
- The options might be out of order. Please put them in the correct order.
240
- If there is not natural order, just put then in order they were presented.
241
- """
242
- ),
243
- question_name="ordering",
244
- )
245
-
246
- return q.to_survey()(options_list=options_list).select("ordering").first()
247
-
248
- def to_question(self) -> QuestionBase:
249
- """Returns a Question object."""
250
- d = {}
251
- d["question_name"] = self.question_name
252
- d["question_text"] = self.question_text
253
- d["question_type"] = self.inferred_question_type
254
- if d["question_type"] == "multiple_choice":
255
- d["question_options"] = self.get_ordering(list(self.unique_responses))
256
- return QuestionBase.from_dict(d)
257
-
258
- @property
259
- def unique_responses(self) -> set:
260
- """Returns the unique responses for a given question; useful to build up mulitple choice questions.
261
-
262
- >>> r = RawResponseColumn(question_name="Q1", raw_responses=["1", "2", "3"], answer_codebook={"1": "Yes", "2": "No"}, question_text="Do you like ice cream?")
263
- >>> r.unique_responses
264
- {'Yes', 'No', '3'}
265
- """
266
- from collections import defaultdict
267
-
268
- s = defaultdict(int)
269
- for response in self.responses:
270
- if isinstance(response, Missing):
271
- continue
272
- else:
273
- s[str(response)] += 1
274
- return s
275
-
276
- def response_category(self):
277
- """Returns the inferred category of the question."""
278
- from edsl.questions import QuestionMultipleChoice
279
-
280
- q = QuestionMultipleChoice(
281
- question_text=textwrap.dedent(
282
- f"""\
283
- I have data from a survey. One of the column labels: {self.question_text}.
284
- I want to know what the data represents."""
285
- ),
286
- question_options=[
287
- "Something asked of the respondent that interested the survey company",
288
- "A fixed characteristic of the respondent, like gender or age",
289
- "Measured by survey company like an internal code or start of the interview",
290
- ],
291
- question_name="opinion_or_characteristic",
292
- )
293
- result = q.run().select("opinion_or_characteristic").first()
294
- return result
295
-
296
- def __repr__(self):
297
- raw_response_display = self.raw_responses[0 : min(len(self.responses), 5)]
298
- if len(self.responses) > 5:
299
- raw_response_display.append("...")
300
-
301
- raw_response_display = self.responses[0 : min(len(self.responses), 5)]
302
- if len(self.responses) > 5:
303
- raw_response_display.append("...")
304
-
305
- return f"""RawResponseColumn(question_name="{self.question_name}", question_text="{self.question_text}", raw_responses={raw_response_display}, responses={raw_response_display}, unqiue_responses={self.unique_responses}, answer_codebook={self.answer_codebook})"""
306
-
307
-
308
- if __name__ == "__main__":
309
- import doctest
310
-
311
- doctest.testmod()
312
- # d = CustomDict()
313
- # d = CustomDict({"7asdf": 123, "FAMILY": 12})
314
- # d["a"] = 123
315
- # d["#_family_members"] = 4
316
-
317
- # d["FAMILY_MEMBERS"] = 12
318
- # d["0x1389"] = 123
319
- # print(d)
320
- # r = RawResponseColumn(
321
- # question_name="_x family MeMbers",
322
- # raw_responses=["1", "2", "3"],
323
- # question_text="fake",
324
- # answer_codebook={},
325
- # )
326
-
327
- # get_replacement_name