Skip to content

Conversation

@GeneralOKC
Copy link

No description provided.

@GeneralOKC GeneralOKC changed the title Add files via upload Бородин Константин Oct 21, 2022
Copy link
Owner

@vongostev vongostev left a 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:
Copy link
Owner

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())
Copy link
Owner

Choose a reason for hiding this comment

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

Лучше использовать if __name__ == "__main__" для обертки кода, исполняемого при запуске (не импорте) скрипта.

@vongostev vongostev added this to the Ex.2 milestone Oct 28, 2022
Copy link
Owner

@vongostev vongostev left a 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
Copy link
Owner

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):
Copy link
Owner

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:
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

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

Тут хорошо бы исключение. Вообще, функция странная и странно используется. Объясните её необходимость.

@vongostev
Copy link
Owner

Внесите нормально изменения, неохота анализировать похожие файлы, и искать различия

@vongostev vongostev modified the milestones: Ex.2, Ex.3 Dec 7, 2022
Copy link
Owner

@vongostev vongostev left a 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):
Copy link
Owner

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)):
Copy link
Owner

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):
Copy link
Owner

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 = []
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

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

Тут лучше было бы, если была бы шапка, что есть что. Мне пришлось думать, какие параметры за что отвечают, а когда я поменял индексы считывания, то у меня все сломалось.

@vongostev vongostev modified the milestones: Ex.3, Ex.4 Dec 22, 2022
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.

2 participants