hifis_surveyval package¶
Subpackages¶
- hifis_surveyval.core package
- hifis_surveyval.models package
- hifis_surveyval.plotting package
- hifis_surveyval.printing package
Submodules¶
hifis_surveyval.cli module¶
hifis_surveyval.data_container module¶
This module provides the definitions for a data container.
The container is meant to serve as the data source for the individual analysis functions.
- class hifis_surveyval.data_container.DataContainer(settings: hifis_surveyval.core.settings.Settings)[source]¶
Bases:
object
The data container holds the data read from the command line.
All data is grouped into question collections, which in turn hold the questions. During the loading, the DataContainer will keep track of answer sets which contradict the validation rules set in the metadata (e.g. no answer being given despite being mandatory.
- __init__(settings: hifis_surveyval.core.settings.Settings)[source]¶
Set up an empty data container.
- Args:
- settings:
An object representing the current application settings.
- collection_for_id(full_id: str) hifis_surveyval.models.question_collection.QuestionCollection [source]¶
Query for a given question collection given by its full ID.
- Args:
- full_id:
The full ID of the question collection to be returned.
- Returns:
The question collection for the given ID.
- Raises:
KeyError - if the collection for the given ID could not be found.
- data_frame_for_ids(requested_ids: List[str]) <MagicMock id=’140330723815376’> [source]¶
Compose a Data Frame form a list of question (collection) IDs.
IDs for which no question or question collection can be found will be skipped. These will be logged at debug level.
- Args:
- requested_ids:
A list of full question or question collection IDs, which are to be composed by participant into a single data frame.
- Returns:
A single data frame containing the answers of all participants for the given questions / question collections.
- property invalid_answer_sets: Set[str]¶
Get all participants who gave invalid answers.
- Returns:
A set with the IDs of participants who had their answers marked as invalid.
- load_metadata(yaml: Union[List[Union[str, Dict[str, Union[str, List[Union[str, YamlDict]], YamlDict]]]], Dict[str, Union[str, List[Union[str, Dict[str, Union[str, YamlList, YamlDict]]]], Dict[str, Union[str, List[Union[str, YamlDict]], YamlDict]]]]]) None [source]¶
Load additional metadata from YAML data.
If the given yaml is valid, the received metadata will be added to the known survey questions. QuestionCollections that fail to parse will not be added to the survey questions and the exception will instead be logged as a warning. It is safe to repeatedly call this function, if multiple sources for metadata need to be processed.
- Args:
- yaml:
Either a list of YamlDictionaries or a single YamlDictionary. Each YamlDictionary is expected to hold a QuestionCollection, Otherwise parsing will fail.
- load_survey_data(csv_data: List[List[str]]) None [source]¶
Load survey data as given in a CSV file.
The data is expected to be given in such a way that the outer list represents the rows and the inner list the columns within each row
- mark_answers_invalid(participant_ids: Set[str]) None [source]¶
Mark the answers given by participants as invalid.
- Args:
- participant_ids:
The IDs of participants who gave invalid answers.
- mark_answers_valid(participant_ids: Set[str]) None [source]¶
Mark the answers given by participants as valid.
NOTE: This does not restore previously removed invalid answers. Invalid IDs are silently ignored.
- Args:
- participant_ids:
The IDs of participants for whom answers are to be marked as valid.
- property question_collection_ids: List[str]¶
Get the IDs of all question collections.
- Returns:
A list of question collection IDs as strings.
- question_for_id(full_id: str) hifis_surveyval.models.question.Question [source]¶
Query for a given question given by its full ID.
This is a shorthand for querying questions directly.
- Args:
- full_id:
The full ID of the question to be returned.
- Returns:
The question for the given ID.
- Raises:
- KeyError:
If either the collection or the question for the given ID could not be found.
- remove_invalid_answer_sets() None [source]¶
Remove answer sets that were marked as invalid.
The answers are removed on a per-participant basis.
- property survey_questions: List[hifis_surveyval.models.question_collection.QuestionCollection]¶
Obtain all survey questions stored in the data container.
- Returns:
A list of QuestionCollections that contain all the survey questions.
hifis_surveyval.hifis_surveyval module¶
This project is used to develop analysis scripts for surveys.
- class hifis_surveyval.hifis_surveyval.HIFISSurveyval(settings: hifis_surveyval.core.settings.Settings)[source]¶
Bases:
object
Main class for all functionalities.
Also serves as data storage.
- __init__(settings: hifis_surveyval.core.settings.Settings)[source]¶
Initialize HIFISSurveyval.
- Args:
- settings:
A Settings container to store the setup configuration in. It will be populated with the related settings during the initialization of the HIFISSurveyval object.
- settings: hifis_surveyval.core.settings.Settings¶
The settings storage
Module contents¶
This project is used to develop analysis scripts for the surveys.