Commit 6927767
committed
chg: improve choices handling and instances generation
- for choices, an Itemset class is introduced which allows calculating
and storing metadata about the choice list more consistently. In
particular, working out whether itext is required only once.
- the initial motivation was the if block in survey.py line 391, which
for a form with many choice lists resulted in a large slow down due
to something approaching O(n*m) + costs from string join/split.
- this allowed removing:
- "_itemset*" properties from MultipleChoiceQuestion
- _search_lists property from Survey
- functions is_label_dynamic and has_dynamic_label
- in the course of implementing this it became clear that actually
the Tag class never has choices so code for that is removed. The
Tag class is like an Option with respect to OsmUploadQuestion. Added
some OSM-related test cases to check it's not broken.
- similarly since choices/itext are handled by Survey, the
MultipleChoiceQuestion class doesn't need choices children either,
just a reference to the Itemset for XML and JSON output.
- for instances generation, the above choices changes allowed
simplification of _generate_static_instances, and otherwise the
changes are mainly to avoid repeating checks or using intermediate
lists by instead using generators/yield as much as possible.
- test_j2x_creation.py / test_j2x_question.py / strings.ini
- updated these tests since they are using internal APIs in a way that
diverges significantly from what xls2json currently emits
- For example test_select_one_question_multilingual had multi-lang
choice labels but the expected XML string had a reference like
"/test/qname/a:label" which implies choice itemsets aren't shared
which has not been the case for a while.
- tried to make these tests more useful by adding xpath assertions,
and unlike other tests using ss_structure they may be useful for
validating/showing what dict structure xlsforms can be provided as.
- test_j2x_xform_build_preparation.py
- removed this test since it's not clear what the expectation is. If
it was intended to check that identical choice lists from separate
questions are merged, then that functionality doesn't exist, and
the choices should not be provided separately per question anyway.
- test_dynamic_default.py / test_translations.py
- updated performance test figures.
- translation test benefits most from the choices changes because it
has lots of choice lists. Increase in memory most likely due to
Itemset instances that now wrap each choice list.
- dynamic_default slightly faster due to the instances changes and
earlier commits today (e.g. not calling xml_label_or_hint twice for
input/text questions, etc).1 parent d5ba008 commit 6927767
File tree
12 files changed
+603
-550
lines changed- pyxform
- tests
- fixtures
12 files changed
+603
-550
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
| 56 | + | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
| |||
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
68 | | - | |
| 66 | + | |
69 | 67 | | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
| |||
291 | 286 | | |
292 | 287 | | |
293 | 288 | | |
294 | | - | |
| 289 | + | |
295 | 290 | | |
296 | 291 | | |
297 | 292 | | |
298 | 293 | | |
299 | 294 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | 295 | | |
311 | 296 | | |
312 | 297 | | |
313 | 298 | | |
314 | 299 | | |
315 | 300 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | 301 | | |
322 | 302 | | |
323 | 303 | | |
324 | 304 | | |
325 | 305 | | |
326 | 306 | | |
327 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
328 | 343 | | |
329 | 344 | | |
330 | 345 | | |
| |||
335 | 350 | | |
336 | 351 | | |
337 | 352 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
342 | 357 | | |
343 | 358 | | |
344 | | - | |
| 359 | + | |
345 | 360 | | |
346 | 361 | | |
347 | 362 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
361 | 366 | | |
362 | 367 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | 368 | | |
386 | 369 | | |
387 | 370 | | |
| |||
403 | 386 | | |
404 | 387 | | |
405 | 388 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | 389 | | |
410 | 390 | | |
411 | 391 | | |
412 | 392 | | |
413 | | - | |
| 393 | + | |
414 | 394 | | |
| 395 | + | |
415 | 396 | | |
416 | 397 | | |
417 | | - | |
418 | 398 | | |
419 | 399 | | |
420 | | - | |
| 400 | + | |
421 | 401 | | |
422 | 402 | | |
423 | 403 | | |
| |||
460 | 440 | | |
461 | 441 | | |
462 | 442 | | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
471 | 469 | | |
472 | 470 | | |
473 | 471 | | |
474 | 472 | | |
475 | 473 | | |
476 | | - | |
477 | | - | |
478 | 474 | | |
479 | 475 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 476 | + | |
511 | 477 | | |
512 | 478 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
| 479 | + | |
520 | 480 | | |
521 | 481 | | |
522 | 482 | | |
| |||
0 commit comments