Skip to content
New issue

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

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

Already on GitHub? # to your account

mypy fixes for boids example #563

Merged
merged 3 commits into from
Dec 27, 2024
Merged

Conversation

stevebachmeier
Copy link
Contributor

Mypy fixes: boids example

Description

Changes and notes

Testing

@@ -43,7 +43,7 @@ def on_time_step(self, event: Event) -> None:
# Pipeline sources and modifiers #
##################################

def get_neighbors(self, index: pd.Index) -> pd.Series:
def get_neighbors(self, index: pd.Index[int]) -> pd.Series[list[int]]: # type: ignore[type-var]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is that someone common pandas error where it doesn't list out the entire line of expected items:

Type argument "list[int]" of "Series" must be a subtype of "str | bytes | date | time | bool | <10 more items>"  [type-var]

s.set_offsets(frame_pops[i])

return FuncAnimation(fig, animate, frames=frames, interval=10)
return FuncAnimation(fig, animate, frames=frames, interval=10) # type: ignore[arg-type]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FuncAnimation has the 2nd arg type-hinted as a callable that returns some obscure thing (certainly not None). It didn't seem worth it for a contrived example like this.

CHANGELOG.rst Outdated
@@ -1,3 +1,7 @@
**3.2.12 - 12/27/24**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to merge from main again? I already released 3.2.12

plt.show()


def plot_boids_animated(simulation):
def plot_boids_animated(simulation: InteractiveContext) -> FuncAnimation:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an InteractiveContext or a SimulationContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure tbh. The example docs is all about interactive, but maybe it could be used in a simulation context?

@stevebachmeier stevebachmeier merged commit 8e6e3f9 into main Dec 27, 2024
8 checks passed
@stevebachmeier stevebachmeier deleted the sbachmei/mic-5650/mypy-boids branch December 27, 2024 18:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants