Home>
I would like to prepare a list of 3 randomly generated hub stations and 25 randomly generated stations, and then generate a list excluding the stations included in a certain radius circle of 3 hub stations. Is calculated only for the last element.
I know that I'm a beginner and stumbling in a rudimentary place, but I'd appreciate it if someone could tell me.
Thank you.
def remove_station (station_list, hub_list, R_big):
X, Y = hub_list [0], hub_list [1]
x, y = station_list [0], station_list [1]
hub_size = len (hub_list [0])
station_size = len (station_list [0])
for i in range (hub_size):
for j in range (station_size):
Dx = X [i]-x [j]
Dy = Y [i]-y [j]
b = math.sqrt (Dx * Dx + Dy * Dy)
m = []
n = []
if b-R_big>= 0: # If the distance between the station and the base station is more than R_big, it will be adopted as a station
m.append (x [j])
n.append (y [j])
else:
pass
return [m, n]
-
Answer # 1
-
Answer # 2
Impressions I saw briefly.
I don't think it will work because there is no if statement in the for statement.
Related articles
- i'm having a problem because the result is not displayed in python
- python - assertionerror solution
- python heat map cannot be read because the axis scale interval is narrow
- solution for error unexpected indent (python)
- python - i don't know the solution and cause of the attribute error that occurred when using pillow
- python - please tell me the solution of gunicorn: command not found when deploying heroku (crying)
- getoldtweets-error solution for python
- python - i am in trouble because the cause of attributeerror is unknown
- python - i am in trouble because the cause of invalid syntax is unknown
- python - please let me know because there is something i don't understand
Related questions
- "openpyxl" cannot be imported in python
- python - launch jupyterlab/notebook from the terminal
- python - something went wrong in the jupiter lab
- python 3x - i want to resolve the error typeerror: loop of ufunc does not support argument 0 of type float which has no callable
- python - modelpredict() cannot be executed in tensorflow
- macos (osx) - sort_valus method error macos
- please add a python error
- i'm trying to create a scientific calculator with jupyter's python, but i want to add exponentiation, factorial, function, log,
- python - missing 1 required positional argument error
- python 3x - i want to display the importance extracted by evaluating with random forest as a column graph
Hello.
The list m, n has been initialized after exiting the double loop, so only the last entry can enter m, n.
It is before the double loop that m and n are initialized.
Need to determine if the distance between a station and all hub stations is more than R_big
Because there is a double loop, the list of normal stations is outside and the list of hub stations is inside.
If you use random data without knowing whether the program is written correctly,
It becomes difficult to verify the program.
I corrected it based on that point. Please see below.
The coordinates of the hub station are as follows.
(25,25)
(75,25)
(75,75)
The coordinates of a normal station are as follows.
(25,20)
(75,30)
(75,60)
(25,75)
(25,60)
The radius R_big is 25.
As you can see by writing a picture, the two stations (25,75) and (25,60) are far from any hub station.
The execution result is as follows.
I'm glad if you can use it as a reference.