-
Notifications
You must be signed in to change notification settings - Fork 39
Бородин Константин #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\u0411\u043E\u0440\u043E\u0434\u0438\u043D"
Conversation
vongostev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом неплохо. Проследите за выполнением PEP8 и учтите в будущем мои замечания.
| def poisson(sr, a): | ||
| if sr<0: | ||
| return 0 | ||
| else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В таких ситуациях else не нужен, так как после return в любом случае идет выход из функции.
| p = poisson(sr, n) | ||
| return (a*p).sum() | ||
|
|
||
| N = float(input()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше использовать if __name__ == "__main__" для обертки кода, исполняемого при запуске (не импорте) скрипта.
vongostev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправьте мои замечания
| s += num/fact | ||
| return +s | ||
|
|
||
| @np.vectorize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А можно использовать рекурсию и lru_cache, будет быстрее.
| a = (np.arange(np.size(n), 1)-moment(n, 1))**2 | ||
| return (n*a).sum() | ||
|
|
||
| def exp(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В decimal есть экспонента. Можно так сделать:
def exp(x):
return x.exp()| return c.sum() | ||
|
|
||
| def disp(n): | ||
| if np.size(np.array(n))<1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это исключение обрабатывается в функции moment.
Тут лучше будет написать
def disp(n):
return moment(n, 2) - moment(n, 1) ** 2Иначе зачем нужна функция moment? И почему n?
|
|
||
| def poisson_uni(sr, a): | ||
| if sr<0: | ||
| return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут хорошо бы исключение. Вообще, функция странная и странно используется. Объясните её необходимость.
|
Внесите нормально изменения, неохота анализировать похожие файлы, и искать различия |
vongostev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом хорошая реализация, но есть недочеты. Зачет.
| dt = 5e-2 | ||
| eps = 10e-1 | ||
|
|
||
| def remove_arr(arr, a): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем так делать? Что-то странное...
| syst = np.loadtxt(path, delimiter=' ', dtype=float) | ||
| bodys1 = [] | ||
| bodys2 = [] | ||
| for i in range(1, len(syst)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут лучше использовать for body in syst[1:]
| self.t = syst[0][0] | ||
| self.dt = syst[0][1] | ||
|
|
||
| def add(self, t): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем копировать, а потом удалять?
| def animation(self): | ||
| fig = plt.figure(figsize=(10, 10)) | ||
| ax = fig.add_subplot(111, projection='3d') | ||
| x = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут лучше использовать двухмерный массив размерности (-1, 3), а далее -- трехмерный массив для линий
| @@ -0,0 +1,4 @@ | |||
| 2500 10 0 0 0 0 0 0 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут лучше было бы, если была бы шапка, что есть что. Мне пришлось думать, какие параметры за что отвечают, а когда я поменял индексы считывания, то у меня все сломалось.
No description provided.