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

Use a consistent method for empty object creation process #761

Open
paulf81 opened this issue Dec 8, 2023 · 0 comments
Open

Use a consistent method for empty object creation process #761

paulf81 opened this issue Dec 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@paulf81
Copy link
Collaborator

paulf81 commented Dec 8, 2023

Use one process for empty object creation process

In the course of resolving the issue with mutable types as default parameters in attrs classes within FLORIS in pull request #759, @RHammond2 points out that we need to pick a consistent method for empty object creation. Currently, we are at risk that if in the future we implement type checking, we could fail tests.

@RHammond2 says:

For instances like this below, I would recommend modifying slightly to ensure the typing is valid (even if unchecked currently) to use the following paragdigm:

x: NDArrayFloat = field(init=False, factory=list, converter=floris_array_converter)

Essentially what will happen if typing is implemented, without converting to the array type, it will fail. Additionally it creates some confusion (though some already exists tbc) to create a list for an object indicated to be an array.

The only place this will cause issues is with non-float arrays, in which case I'd recommend having two variations of floris_array_converter such as float_array_converter and object_array_converter. I don't know that it needs to have floris_ at the front at this point, and might be a lingering (but dated) idea from early in the design process.

@paulf81 paulf81 added the bug Something isn't working label Dec 8, 2023
@rafmudaf rafmudaf changed the title Use one process for empty object creation process Use a consistent method for empty object creation process Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant