-
Notifications
You must be signed in to change notification settings - Fork 244
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
Prvočíslo #213
base: master
Are you sure you want to change the base?
Prvočíslo #213
Conversation
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.
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
main.py
Outdated
# 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 |
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.
# 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 |
main.py
Outdated
assert HeurestickaMetoda(12) == False | ||
|
||
|
||
def Vstup(): |
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 Vstup(): | |
def Vstup(Napsanecislo): |
main.py
Outdated
""" | ||
Funkce získá vstup od uživatele proti chybám. | ||
""" | ||
Napsanecislo = input("Zadej číslo:") |
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.
Napsanecislo = input("Zadej číslo:") |
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.
Přidat test na metodu Vystup pro zvýšení pokrytí kódu testy
main.py
Outdated
assert Vstup([0,"kk"]) == False | ||
assert Vstup([3,7]) == True |
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.
Chyba v testu, funkce Vstup opravdu očekává pole?
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.
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.
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.
- 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)
main.py
Outdated
# omezující podmínky | ||
for i in range(2, cislo): | ||
if (cislo % i) == 0: | ||
break |
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.
break | |
return False |
main.py
Outdated
break | ||
else: | ||
print("Zadané číslo" , cislo , "PATŘÍ mezi prvočísla.") | ||
|
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.
return True | |
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.
- 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.
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.
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
test_prime.py
Outdated
'''def test_Vstup(): | ||
assert Vstup("1") is True | ||
assert Vstup("k") is False | ||
''' |
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 test_Vstup(): | |
assert Vstup("1") is True | |
assert Vstup("k") is False | |
''' | |
def test_Vstup(): | |
assert Vstup("1") == 1 | |
assert Vstup("k") == 0 |
test_prime.py
Outdated
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.' | ||
|
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.
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.' | |
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) |
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.
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.') |
test_prime.py
Outdated
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) |
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.
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ů
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.
nakonec upravit Website url na url vašich gh-pages s vygenerovanou dokumentací, v sekci About na hlavní stránce repa.
test_prime.py
Outdated
|
||
|
||
def test_Metody(): | ||
"""Test metod""" |
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.
"""Test metod""" | |
"""Test metod.""" |
test_prime.py
Outdated
assert Metody(8) == -3 | ||
assert Metody(50013) == -4 | ||
assert Metody(50011) == -4 | ||
print ('done') |
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.
print ('done') |
test_prime.py
Outdated
"""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.""" |
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.
"""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.""" |
test_prime.py
Outdated
|
||
|
||
def test_DeterministickaMetoda(): | ||
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo""" |
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.
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo""" | |
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo.""" |
test_prime.py
Outdated
|
||
|
||
def test_HeurestickaMetoda(): | ||
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo""" |
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.
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo""" | |
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo.""" |
test_prime.py
Outdated
|
||
|
||
def test_Vstup(): | ||
"""Správně pouze celá čísla 0-9 ne znaky a písmena)""" |
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.
"""Správně pouze celá čísla 0-9 ne znaky a písmena)""" | |
"""Správně pouze celá čísla 0-9 ne znaky a písmena.""" |
test_prime.py
Outdated
|
||
|
||
def Metody(cislo): | ||
"""použita metoda""" |
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.
"""použita metoda""" | |
"""použita metoda.""" |
No description provided.