Skip to content
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

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open

Prvočíslo #213

wants to merge 53 commits into from

Conversation

tomassigmund
Copy link

No description provided.

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

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

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


def Vstup():
Copy link
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):

main.py Outdated
"""
Funkce získá vstup od uživatele proti chybám.
"""
Napsanecislo = input("Zadej číslo:")
Copy link
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:")

Copy link
Owner

@turecekt turecekt left a 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
Comment on lines 52 to 53
assert Vstup([0,"kk"]) == False
assert Vstup([3,7]) == True
Copy link
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?

Copy link
Owner

@turecekt turecekt left a 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.

Copy link
Owner

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

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

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

Copy link
Owner

@turecekt turecekt left a 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.

Copy link
Owner

@turecekt turecekt left a 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
Comment on lines 43 to 46
'''def test_Vstup():
assert Vstup("1") is True
assert Vstup("k") is False
'''
Copy link
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

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
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.'

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
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.')

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
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ů

Copy link
Owner

@turecekt turecekt left a 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"""
Copy link
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."""

test_prime.py Outdated
assert Metody(8) == -3
assert Metody(50013) == -4
assert Metody(50011) == -4
print ('done')
Copy link
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')

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
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."""

test_prime.py Outdated


def test_DeterministickaMetoda():
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""
Copy link
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."""

test_prime.py Outdated


def test_HeurestickaMetoda():
"""Funkce zjistuje u téhle metody,jestli je číslo prvočíslo"""
Copy link
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."""

test_prime.py Outdated


def test_Vstup():
"""Správně pouze celá čísla 0-9 ne znaky a písmena)"""
Copy link
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."""

test_prime.py Outdated


def Metody(cislo):
"""použita metoda"""
Copy link
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.

None yet

2 participants