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

Fix return hint for EnumerableSpace.get_elements() and simplify implementations #450

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

nhuet
Copy link
Contributor

@nhuet nhuet commented Dec 16, 2024

In code, the result of EnumerableSpace.get_elements() is used for:

  • for a in elements
  • if a in elements
  • elements[i]
  • len(elements)
  • random.sample(elements, 2)

So this is actually expected to be a Sequence (see https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes).
We fix the annotation and simplify the implementations by removing the wrapping in numpy.array() as it is not required and even sometimes re-wrapped in a numpy.array() elsewhere in the code.

@nhuet nhuet force-pushed the simplify-get-elements branch from eb191a0 to d3fff1a Compare December 20, 2024 16:59
…mentations

In code, the result of `EnumerableSpace.get_elements()` is used for:
- `for a in elements`
- `if a in elements`
- `elements[i]`
- `len(elements)`
- `random.sample(elements, 2)`

So this is actually expected to be `Sequence`.
We fix the annotation and simplify the implementation by removing the
wrapping in numpy.array() as it is not expected and even sometimes
re-wrap in a numpy.array() in the code.
@nhuet nhuet force-pushed the simplify-get-elements branch from d3fff1a to 27d3883 Compare January 8, 2025 16:08
@fteicht fteicht merged commit 8401554 into airbus:master Jan 10, 2025
32 of 33 checks passed
@nhuet nhuet deleted the simplify-get-elements branch January 20, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants