Skip to content

Conversation

@suda-yuga
Copy link
Contributor

This PR refactors the simulate_workers function to follow Python best practices and enhance readability. The main changes include:

  • Replaced isinstance(..., type(None)) with is None checks for clarity.
  • Avoided unnecessary equality checks like diff == True in favor of direct boolean evaluation.
  • Used is None instead of == None for None comparisons.
  • Replaced unnecessary list unpacking like [y_hat_t[i]] = worker.G @ x_hat with scalar extraction using .item().
    The matrix multiplication returns a single-element array, so using .item() explicitly converts it to a scalar value, improving code clarity and avoiding the need for list unpacking.

@mmcky
Copy link
Contributor

mmcky commented Jul 21, 2025

thank you for this PR @suda-yuga

I really like these changes.

@HumphreyYang I think using .item() method is cleaner than the unpacking [] syntax on the LHS. What do you think?

@mmcky mmcky self-requested a review July 21, 2025 00:30
@HumphreyYang
Copy link
Member

@HumphreyYang I think using .item() method is cleaner than the unpacking [] syntax on the LHS. What do you think?

Thanks @mmcky! I agree. I think unpacking [] is more concise but probably less transparent to readers. Thanks @suda-yuga!

@mmcky mmcky merged commit 245e304 into QuantEcon:main Jul 21, 2025
6 checks passed
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.

3 participants