Skip to content

Conversation

@henrikmidtiby
Copy link
Contributor

Overview: What does this pull request change?

This PR adds type annotations to three_d_camera.py.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

def z_key(mob: Mobject) -> float:
if not (hasattr(mob, "shade_in_3d") and mob.shade_in_3d):
return np.inf
return np.inf # type: ignore[no-any-return]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently np.inf is not considered a float by mypy.

@henrikmidtiby henrikmidtiby marked this pull request as ready for review July 28, 2025 12:34
Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! I left some few suggestions:


def modified_rgbas(self, vmobject, rgbas):
# TODO: Find a better way
def modified_rgbas(self, vmobject: VMobject, rgbas: MatrixMN) -> MatrixMN:
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment rather than a suggestion for this PR.

MatrixMN seems like the most fit alias for now, but we should actually make a new alias specifically for RGBA arrays, since MatrixMN is more fit for matrices representing linear maps which are applied on vectors. This was actually part of a larger proposal I wrote a long time ago in a #development post on Discord.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then I suggest to continue to use MatrixMN for now, and then when we also can type check on the dimensions of the matrices it would be a suitable time to change the typing.

@github-project-automation github-project-automation bot moved this from 🆕 New to 👀 In review in Dev Board Jul 28, 2025
@henrikmidtiby
Copy link
Contributor Author

Thanks for the input and comments. I have addressed all of them.

Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-project-automation github-project-automation bot moved this from 👀 In review to 👍 To be merged in Dev Board Jul 29, 2025
@chopan050 chopan050 changed the title Adding type annotations to three_d_camera.py Add type annotations to three_d_camera.py Jul 29, 2025
@chopan050 chopan050 enabled auto-merge (squash) July 29, 2025 12:09
@chopan050 chopan050 merged commit dba6fa8 into ManimCommunity:main Jul 29, 2025
20 of 21 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Jul 29, 2025
@henrikmidtiby henrikmidtiby deleted the TypingThreeDCamera branch July 29, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants