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 a MemorySource.

Parameters:
  • seed (int) – The seed of the draws. The same seed gives the same Project.

  • impressions (bool) – Whether the Project records which Revisions were shown.

  • exposure (Exposure | str) – The level of detail: "pseudonymised" (the default here) or "aggregated".

Return type:

Project

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-demo and one Project pr-demo (slug demo-project); 48 Actants m-001 to m-048; 14 Proposals p-01 to p-14 with one Revision each; a Proposal p-15 with two Revisions, the second produced by the adopted Amendment p-16; an open Amendment p-17 to p-02; six Arguments on p-01, in two threads; and the votes on p-01 to p-14, drawn for each Actant and each Proposal from the planted structure (see make_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]]