Skip to content

Update 15.py - #12

Open
stanley6716 wants to merge 1 commit into
OpenMCL:masterfrom
stanley6716:patch-4
Open

Update 15.py#12
stanley6716 wants to merge 1 commit into
OpenMCL:masterfrom
stanley6716:patch-4

Conversation

@stanley6716

Copy link
Copy Markdown

No description provided.

@StephLinStephLin 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.

Many thanks for your contribution!

The code is almost correct, while there are some programming issues. Please fix them accordingly.

We format our code with Black and lint them with Flake8 in this project. Please checkout here (offline code linting) and here (coding style) for details. Thank you!

Comment threadsrc/ch05/15.py
@@ -0,0 +1,36 @@
import pylab
import numpy as np
from random import *

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.

Prevent using from ... import *.

Suggested change
fromrandomimport*
fromrandomimportrandom

Comment threadsrc/ch05/15.py
map=[[0x8,0x8,0x7f,0x49,0x7f,0x8,0x8],[0x8,0x8,0x3e,0x2a,0x7f,0x14,0x63]]
R,C=7,7
ds=5
#m=int(input("> "))

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.

Remove unused code.

Comment threadsrc/ch05/15.py
a=2*pi*random()
sina=np.sin(a)
cosa=np.cos(a)
ra=(1/m)*(0.8+0.2*random())

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
ra=(1/m)*(0.8+0.2*random())
ra=(1/m)*(2.0+0.2*random())

The radius $0.8 + X \sim \mathcal{U}_{[0, 0.2)}$ seems to be too small 🤔:

image

I think the radius should be enlarged. Like $2.0 + X \sim \mathcal{U}_{[0, 0.2)}$:

image

Comment threadsrc/ch05/15.py
#m=int(input("> "))
m = 1
ds=20
pylab.axis("off")

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.

Suggest adding pylab.axis("equal") for isometric scaling.

Suggested change
pylab.axis("off")
pylab.axis("off")
pylab.axis("equal")

@StephLinStephLin mentioned this pull request Jan 14, 2023
4 tasks
@StephLinStephLin linked an issue Jan 14, 2023 that may be closed by this pull request
4 tasks
Sign up for freeto 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.

Unfinished questions

2 participants

@stanley6716@StephLin