Skip to content

Prvočíslo - #213

Open
tomassigmund wants to merge 53 commits into
turecekt:masterfrom
tomassigmund:master
Open

Prvočíslo#213
tomassigmund wants to merge 53 commits into
turecekt:masterfrom
tomassigmund:master

Conversation

@tomassigmund

Copy link
Copy Markdown

No description provided.

@tomassigmund tomassigmund changed the title Final Prvočíslo Feb 9, 2022

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Upravit dle navržených změn, přidat test na funkci Vstup, doplnit docstringy do test funkcí, povolit workflow python_checker.yml v actions zde: https://github.com/tomassigmund/vs_project-1/actions

Comment thread main.py Outdated
Comment on lines +180 to +186
# MAIN
moznePrvocislo = Vstup() # Získá vstup od uživatele

if(moznePrvocislo > 0): # Otestuje chybový vstup
Vystup(Metody(moznePrvocislo)) # Vystup s řešením
else:
Vystup() # Vystup s chybovou hláškou No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
# MAIN
moznePrvocislo = Vstup() # Získá vstup od uživatele
if(moznePrvocislo > 0): # Otestuje chybový vstup
Vystup(Metody(moznePrvocislo)) # Vystup s řešením
else:
Vystup() # Vystup s chybovou hláškou
if __name__ == "__main__":
# MAIN
moznePrvocislo = Vstup(input("Zadej číslo:")) # Získá vstup od uživatele
if(moznePrvocislo > 0): # Otestuje chybový vstup
Vystup(Metody(moznePrvocislo)) # Vystup s řešením
else:
Vystup() # Vystup s chybovou hláškou

Comment thread main.py Outdated
assert HeurestickaMetoda(12) == False


def Vstup():

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
def Vstup():
def Vstup(Napsanecislo):

Comment thread main.py Outdated
"""
Funkce získá vstup od uživatele proti chybám.
"""
Napsanecislo = input("Zadej číslo:")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Napsanecislo = input("Zadej číslo:")

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Přidat test na metodu Vystup pro zvýšení pokrytí kódu testy

Comment thread main.py Outdated
Comment on lines +52 to +53
assert Vstup([0,"kk"]) == False
assert Vstup([3,7]) == True

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Chyba v testu, funkce Vstup opravdu očekává pole?

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Stále chyby v testech viz:
FAILED main.py::test_DeterministickaMetoda - assert None == False
Do funkce výsput přidejte nějaké návratové hodnoty a napište na ti test pro zvýšení pokrytí kódu testy.

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  • opravit funkci DeterministickaMetoda viz code review
  • refaktorovat kód ve funkci Vystup - opakované volání funkce print nahraďte jedním voláním printu s multiline stringem, tím se dosáhne na požadované pokrytí kódu testy
  • vyčistit kód a dokumentační řetězce aby prošlo nástrojem flake8
  • přijet změny z upstream repozitáře (viz zadání projektu na moodlu)

Comment thread main.py Outdated
# omezující podmínky
for i in range(2, cislo):
if (cislo % i) == 0:
break

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
break
return False

Comment thread main.py Outdated
break
else:
print("Zadané číslo" , cislo , "PATŘÍ mezi prvočísla.")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
return True

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

  • smazat soubor example.py
  • main.py přejmenovat na test_prime.py
  • následně opravit chyby flake8
  • sledujte automatické testy po odjetí do repozitáře viz: https://github.com/tomassigmund/vs_project-1/actions
  • nastavit gh-pages a build and deployment source na actions v nastavení repozitáře, sekce Pages viz zadání projektu na moodlu.
  • nakonec upravit Website url na url vašich gh-pages s vygenerovanou dokumentací, v sekci About na hlavní stránce repa.

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Testy už prochází, tak teď ještě ty chyby statické analýzy viz: https://github.com/tomassigmund/vs_project-1/actions/runs/4081714027/jobs/7035350549

Comment thread test_prime.py Outdated
Comment on lines +43 to +46
'''def test_Vstup():
assert Vstup("1") is True
assert Vstup("k") is False
'''

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
'''def test_Vstup():
assert Vstup("1") is True
assert Vstup("k") is False
'''
def test_Vstup():
assert Vstup("1") == 1
assert Vstup("k") == 0

Comment thread test_prime.py Outdated
Comment on lines +65 to +67
my_str1 ='CHYBA při zadávání. Zadaná hodnota neopodívá formátu,který'
my_str2 ='se dá přečíst.Restartuj a zadej přirozené číslo.'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
my_str1 ='CHYBA při zadávání. Zadaná hodnota neopodívá formátu,který'
my_str2 ='se dá přečíst.Restartuj a zadej přirozené číslo.'

Comment thread test_prime.py Outdated
my_str2 ='se dá přečíst.Restartuj a zadej přirozené číslo.'

if (pouzitaMetoda == 0):
print(my_str1 + my_str2)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
print(my_str1 + my_str2)
print('CHYBA při zadávání. Zadaná hodnota neopodívá formátu,který' +
'se dá přečíst.Restartuj a zadej přirozené číslo.')

Comment thread test_prime.py Outdated
Comment on lines +82 to +98
my_str3 ='HEURISTICKÁ metoda-Rozpozná číslici 1 a vyřadí ji, číslo není.'
my_str4 ='prvočíslo.(číslo musí být dělitelné DVĚMA čísly, samosebou a jedničkou)'
my_str5 ='HEURISTICKÁ metoda-pravidla dělitelnosti.Určí neprvočísla, pomocí toho, že číslo '
my_str6 ='končí určitým číslem podle,pravidel dělitelnosti, lze vydělit prvočíslem.'
my_str7='HEURISTICKÁ metoda-Wilsonova věta. Používá matematický vztah ((n - 1)! + 1) % n'
my_str8 ='DETERMINISTICKÁ metoda-Zkouší pokud je číslo dělitelné některým'
my_str9 ='z předtím nalezených prvočísel do maximální hodnoty odmocniny'
my_str10 ='ze zadaného čísla.Pokud není dělitelné,je to prvočíslo.'

if (pouzitaMetoda == 1):
print(my_str3 + my_str4)
elif (pouzitaMetoda == 2):
print(my_str5 + my_str6)
elif (pouzitaMetoda == 3):
print(my_str7)
elif (pouzitaMetoda == 4):
print(my_str8 + my_str9 + my_str10)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

upravit stejně jako u my_str1 a my_str2, tedy zrušit definici proměnné a dát do printu jako řetězce z vícero řádků

@turecekt turecekt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nakonec upravit Website url na url vašich gh-pages s vygenerovanou dokumentací, v sekci About na hlavní stránce repa.

Comment thread test_prime.py Outdated


def test_Metody():
"""Test metod"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""Test metod"""
"""Test metod."""

Comment thread test_prime.py Outdated
assert Metody(8) == -3
assert Metody(50013) == -4
assert Metody(50011) == -4
print ('done')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
print ('done')

Comment thread test_prime.py Outdated
Comment on lines +16 to +17
"""Funkce určí některá neprvočísla,pomocí toho, že je číslo končí"""
"""určitým číslem,které podle pravidel,lze vydělit již prvočíslem."""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""Funkce určí některá neprvočísla,pomocí toho, že je číslo končí"""
"""určitým číslem,které podle pravidel,lze vydělit již prvočíslem."""
"""Test funkce MetodaPravidelDelitelnosti."""

Comment thread test_prime.py Outdated


def test_DeterministickaMetoda():
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo."""

Comment thread test_prime.py Outdated


def test_HeurestickaMetoda():
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo."""

Comment thread test_prime.py Outdated


def test_Vstup():
"""Správně pouze celá čísla 0-9 ne znaky a písmena)"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""Správně pouze celá čísla 0-9 ne znaky a písmena)"""
"""Správně pouze celá čísla 0-9 ne znaky a písmena."""

Comment thread test_prime.py Outdated


def Metody(cislo):
"""použita metoda"""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
"""použita metoda"""
"""použita metoda."""

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