civiqhub.synthetic¶
A synthetic Project, made up from a seed, to test, document and show the SDK.
The data are synthetic: they describe nobody. The Project has a planted structure,
which make_truth() gives: three opinion groups of Actants (the first 20, the next
16, the last 12) and two blocks of Proposals (p-01 to p-07, then p-08 to
p-14). Each opinion group votes in its own way on each block.
Everything is drawn from random.Random(seed), in a fixed order: the same seed gives
the same rows on every system. Neither the engine nor NumPy is needed.
- civiqhub.synthetic.make_project(*, seed=0, impressions=False, exposure=Exposure.PSEUDONYMISED)[source]¶
Return a synthetic Project, to try the SDK without a token and without network.
The data are synthetic and describe nobody: they are the rows of
make_rows(), read through aMemorySource.
- civiqhub.synthetic.make_rows(*, seed=0, impressions=False)[source]¶
Return the rows of a synthetic Project, at the pseudonymised level.
The data are synthetic and describe nobody. The rows hold one Group
g-demoand one Projectpr-demo(slugdemo-project); 48 Actantsm-001tom-048; 14 Proposalsp-01top-14with one Revision each; a Proposalp-15with two Revisions, the second produced by the adopted Amendmentp-16; an open Amendmentp-17top-02; six Arguments onp-01, in two threads; and the votes onp-01top-14, drawn for each Actant and each Proposal from the planted structure (seemake_truth()).- Parameters:
seed (int) – The seed of the draws. The same seed gives the same rows.
impressions (bool) – Whether the rows say which Revisions were shown to which Actants. Every vote is an impression, and a Revision without a vote was shown with the probability 0.5.
- Returns:
Rows in the format
FORMAT.- Raises:
ValidationError – The seed is not an integer.
- Return type:
dict[str, Any]
- civiqhub.synthetic.make_truth()[source]¶
Return the planted structure of the synthetic Project, to test what finds it.
- Returns:
{"opinion_groups": {pseudonym: index}, "proposal_blocks": {id: index}}– the opinion group (0, 1 or 2) of each Actant, and the block (0 or 1) of each Proposal that has votes.- Return type:
dict[str, dict[str, int]]