Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using InteractionType with an ExistType as interaction field leads to an Error #1198

Closed
ArVar opened this issue Jul 1, 2024 · 2 comments
Closed

Comments

@ArVar
Copy link
Contributor

ArVar commented Jul 1, 2024

When using an interaction field like:

(Interaction: ['street', 'house_num', 'house_num_e', 'city'])

where house_num_e is an ExistType, datamodel.DataModel.interactions() produces

(Interaction: ['((1, 1): Dummy)', 'street', 'house_num', 'city'])

based on the higher_vars. Which becomes also the name of the Interaction variable in columns as argument for interaction_indices(). There

interaction_indices = [var_names.index(f) for f in var.interaction_fields]

then runs into the error:

ValueError: '((1, 1): Dummy)' is not in list

I have no recommendation, where to change the code, but something between the naming of the interaction variable and the way the interaction indices are build might be incompatible.

@ArVar
Copy link
Contributor Author

ArVar commented Jul 1, 2024

After some research and deep dive into the code I got a question:
Could this be related to
columns += interactions(variable_definitions, self.field_variables)
in datamodel.py? Priviously, only the so called "primary_variables" were used for interactions, exluding Custom and Interaction variables.

@ArVar
Copy link
Contributor Author

ArVar commented Jul 1, 2024

I think, the cause is in a missing definition in the ExistType. By switching the parent class from CategoricalType to FieldType there is the standard len definition applied, which is 1.
Adding the following method to ExistType should fix this:

    def __len__(self) -> int:
        return len(self.higher_vars)

See #1196

@fgregg fgregg closed this as completed in 9f8e6f7 Jul 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant