iblrig.pydantic_definitions.TrialDataModel

Inheritance diagram of TrialDataModel

class iblrig.pydantic_definitions.TrialDataModel[source]

A data model for trial data that extends BaseModel.

This model allows for the addition of extra fields beyond those defined in the model.

classmethod preallocate_dataframe(n_rows)[source]

Preallocate a DataFrame with specified number of rows, using default values or pandas.NA.

This method creates a pandas DataFrame with the same columns as the fields defined in the Pydantic model. Each column is initialized with the field’s default value if available, otherwise with pandas.NA.

We use Pandas.NA for default values rather than NaN, None or Zero. This allows us to clearly indicate missing values - which will raise a Pydantic ValidationError.

Parameters:

n_rows (int) – The number of rows to create in the DataFrame.

Returns:

A DataFrame with n_rows rows and columns corresponding to the model’s fields.

Return type:

pd.DataFrame

Parameters:

n_rows (int)

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.