Skip to content

[Tut] Solve various problems#22828

Open
dpiparo wants to merge 1 commit into
root-project:masterfrom
dpiparo:roostatsTut
Open

[Tut] Solve various problems#22828
dpiparo wants to merge 1 commit into
root-project:masterfrom
dpiparo:roostatsTut

Conversation

@dpiparo

@dpiparo dpiparo commented Jul 16, 2026

Copy link
Copy Markdown
Member

due to shadowing of variables, erroneous logical conditions, and type mismatch

due to shadowing of variables, erroneous logical conditions, and type mismatch
@dpiparo
dpiparo requested a review from guitargeek July 16, 2026 06:48
@dpiparo dpiparo self-assigned this Jul 16, 2026
@dpiparo
dpiparo requested a review from couet as a code owner July 16, 2026 06:48
assert hhc

hhc.SetToys(ntoys, ntoys / self.mNToysRatio) # can use less ntoys for b hypothesis
hhc.SetToys(ntoys, int(ntoys / self.mNToysRatio)) # can use less ntoys for b hypothesis

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
hhc.SetToys(ntoys, int(ntoys / self.mNToysRatio)) # can use less ntoys for b hypothesis
hhc.SetToys(ntoys, ntoys // self.mNToysRatio) # can use less ntoys for b hypothesis

Instead of converting the result to int, I'd prefer integer division directly

elif type == 0:
hc.SetToys(ntoys, ntoys / self.mNToysRatio)
elif Type == 0:
hc.SetToys(ntoys, int(ntoys / self.mNToysRatio))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
hc.SetToys(ntoys, int(ntoys / self.mNToysRatio))
hc.SetToys(ntoys, ntoys // self.mNToysRatio)

elif type == 1:
hc.SetToys(ntoys, ntoys / self.mNToysRatio)
elif Type == 1:
hc.SetToys(ntoys, int(ntoys / self.mNToysRatio))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
hc.SetToys(ntoys, int(ntoys / self.mNToysRatio))
hc.SetToys(ntoys, ntoys // self.mNToysRatio)

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Just some suggestions for cleaner integer divisions

@dpiparo

dpiparo commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

I fully agree. Sorry for not having thought to integer division in the first place ...

@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 19h 54m 36s ⏱️
 3 870 tests  3 870 ✅ 0 💤 0 ❌
78 747 runs  78 747 ✅ 0 💤 0 ❌

Results for commit 80dcbb0.

@dpiparo

dpiparo commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

The problem here is that for better or worse, self.mNToysRatio is a floating point and the integer division will result anyway in an floating point, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants