pygacity.generate.answerset module

A class for handling answer sets in pygacity

class pygacity.generate.answerset.AnswerSet(data: dict = {}, serial: int = 0, serialstr: str = None)[source]

Bases: UserDict

display(index: any, element: int = 0)[source]
classmethod from_yaml(filename: str, delete: bool = False)[source]

Create an AnswerSet instance by loading from a YAML file of the same format as that generated by the to_yaml() method.

Parameters:
  • filename (str) – the YAML filename to load

  • delete (bool, optional) – whether to delete the YAML file after loading (default is False)

Returns:

An AnswerSet instance populated with data from the YAML file.

Return type:

AnswerSet

register(index: any, label: str = None, value: any = None, units: str = None, formatter: str = None, group: int = None)[source]

Register an answer entry for a particular question index.

Parameters:
  • index (any) – the question index

  • label (str, optional) – the label for the answer entry

  • value (any, optional) – the value of the answer entry

  • units (str, optional) – the units of the answer entry

  • formatter (str, optional) – a format string for displaying the value

  • group (int, optional) – a group identifier for the answer entry

set_source(index: any, source: str)[source]

Record the source filename for a question index.

to_yaml()[source]

Dumps the AnswerSet to a YAML file.

class pygacity.generate.answerset.AnswerSuperSet(initial: list[AnswerSet] = [])[source]

Bases: UserList[AnswerSet]

A collection of AnswerSet instances with methods to convert to pandas DataFrames and LaTeX tables.

classmethod from_dumpfiles(files: list[str] = [], delete: bool = False)[source]

Create an AnswerSuperSet instance by loading multiple AnswerSet instances from YAML files.

Parameters:
  • files (list[str]) – list of YAML filenames to load

  • delete (bool, optional) – whether to delete the YAML files after loading (default is False)

Returns:

An AnswerSuperSet instance populated with AnswerSet instances from the YAML files.

Return type:

AnswerSuperSet

to_latex()[source]

Converts the AnswerSuperSet to a LaTeX formatted string.

Returns:

LaTeX formatted string representing the AnswerSuperSet

Return type:

str