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

Odb.FieldValue.data is typed only as tuple, but should be typed as tuple[float] #5731

Closed
sebastianvitterso opened this issue Aug 27, 2024 · 4 comments · Fixed by #5732
Closed
Labels
bug Something isn't working

Comments

@sebastianvitterso
Copy link

Describe the bug
A clear and concise description of what the bug is.
In abqpy/Odb/FieldValue.py:144-152:

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: double precision an exception will be thrown.
    data: tuple = ()

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: single precision, an exception will be thrown.
    dataDouble: tuple = ()

The docstrings say that these are tuples of floats, so the typing could reflect this.

Proposed solution is simple:

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: double precision an exception will be thrown.
    data: tuple[float] = ()

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: single precision, an exception will be thrown.
    dataDouble: tuple[float] = ()
@haiiliin
Copy link
Owner

There is too much work to do about this kind of typing error.

@sebastianvitterso
Copy link
Author

Hm, I see. 1655 cases are a lot, and many of them are more complicated than this one (with tuples of tuples of enum values). I don't think I'll be able to help with the more complex cases, but I could attempt the simpler ones, and spend some time on that, if that is helpful. But if consistency is a higher priority than having precision in certain places, which I would understand, then I won't be able to assist, given that I won't reach over the whole project.

Thoughts?

@haiiliin
Copy link
Owner

Any small fixes are welcome

@haiiliin
Copy link
Owner

Proposed solution is simple:

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: double precision an exception will be thrown.
    data: tuple[float] = ()

    #: A tuple of Floats specifying data in the form described by **type**. If **type** = TENSOR or
    #: VECTOR, **data** is a sequence containing the components. If the underlying data are in
    #: single precision, an exception will be thrown.
    dataDouble: tuple[float] = ()

tuple[float, ...] should be better because tuple[float] represents a tuple with exactly one float.

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

Successfully merging a pull request may close this issue.

2 participants