Another batch of Pyrefly fixes#35332
Conversation
Summary of ChangesHello @superbobry, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing the type-checking compliance of the JAX codebase, particularly in relation to the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a batch of fixes for the Pyrefly static analysis tool. Most changes involve adding # pyrefly: ignore comments to suppress warnings or improving type hints, which are reasonable. However, I've identified one change in jax/_src/internal_test_util/test_harnesses.py that appears to introduce a bug by using an incorrect dtype for an initial value in a lax.reduce call within a test harness. I've provided a specific comment and a suggested fix for this issue.
| init_values = [init_val] | ||
| if nr_operands == 2: | ||
| init_values.append(np.int32(0.)) | ||
| init_values.append(np.zeros((), dtype=dtype)) |
There was a problem hiding this comment.
The initial value for the second operand in this lax.reduce call should have a dtype of np.int32, as the second operand is always an int32 array in this test harness. The current implementation uses dtype, which is the dtype of the first operand and can be a float. This will cause a type mismatch when dtype is not an integer type.
The previous implementation np.int32(0.) was correct. To fix this, you should use a hardcoded np.int32 dtype for the second initial value.
| init_values.append(np.zeros((), dtype=dtype)) | |
| init_values.append(np.zeros((), dtype=np.int32)) |
| elements: Sequence[T], | ||
| elements: Iterable[T], | ||
| ) -> int: | ||
| element_offsets = [serialize_one(builder, e) for e in elements] |
There was a problem hiding this comment.
Since elements is now an interable rather than a sequence, I'd consider adding del elements in the next line to emphasize that it may be consumed by this iteration.
There was a problem hiding this comment.
Good idea, done.
37b4965 to
3aa1911
Compare
No description provided.