Skip to content

commit Mathieu Chicoine #34

Open
Matchico86 wants to merge 8 commits intobcalou:mainfrom
Matchico86:main
Open

commit Mathieu Chicoine #34
Matchico86 wants to merge 8 commits intobcalou:mainfrom
Matchico86:main

Conversation

@Matchico86
Copy link
Copy Markdown

No description provided.

@Matchico86 Matchico86 marked this pull request as draft November 15, 2023 14:33
@Matchico86 Matchico86 marked this pull request as ready for review November 17, 2023 10:21
@Matchico86 Matchico86 marked this pull request as draft November 17, 2023 10:24
@Matchico86 Matchico86 marked this pull request as ready for review November 17, 2023 13:48
Copy link
Copy Markdown
Owner

@bcalou bcalou left a comment

Choose a reason for hiding this comment

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

Quelques amélirations possibles mais bonne direction

doomsday/date.py Outdated
Comment on lines +35 to +38
# Vérifier si le nombre de caractère est bon (voir ci-haut)
if len(year) < 4:
print("Year must have 4 or more characters")
return 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.

Si l'année est supérieure à 1583, il y a forcément 4 caractères ou plus, n'est ce pas ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fait

doomsday/date.py Outdated
Comment on lines +56 to +58
if len(month) < 1 or len(month) > 2:
print("Month must have 1 or 2 characters")
return 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.

Dans la même logique, on peut directement regarder la valeur du mois pour s'assurer que le nombre de caractères est correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

on peut en effet vérifier que le mois est compris entre 1 et 12 (donc 1 ou 2 caractères), cependant "0001" sera accepté alors qu'il y a 4 caractères. je mets en commentaires la partie correspondante

Comment on lines +10 to +18
days_of_week = (
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
)
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.

Généralement le genre de choses qu'on met en constante (DAYS_OF_WEEK) en haut du fichier plutôt que dans une fonction

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fait

Comment on lines +84 to +85
while multiple_of_7 % 7 != 0:
multiple_of_7 += 1
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.

Possible à calculer sans boucle while

Comment on lines +88 to +96
match (century % 4):
case 0: # Dates 1600, 2000, etc.
century_value = 2
case 1: # Dates 1700, 2100, etc.
century_value = 0
case 2: # Dates 1800, 2200, etc.
century_value = 5
case 3: # Dates 1500, 1900, etc.
century_value = 3
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.

Un match dont les cases sont des chiffres allant de 0 à 3 ressemble fortement à simple recherche dans un tableau [2, 0, 5, 3]

case 11:
return days_of_week[(day + anchor_day) % 7]
case 12:
return days_of_week[(day - 5 + anchor_day) % 7]
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.

Cette opération est effectuée une douzaine de fois, or seul le chiffre au milieu change ! Il faut éviter cela et d'abord obtenir le chiffre, puis faire l'opération une seule fois.
Le match est une structure très utile mais pas forcément efficace ici

@bcalou
Copy link
Copy Markdown
Owner

bcalou commented Nov 24, 2023

Code soigné mais 2 tests sur 3 ne passent pas, ce qui est essentiel.
Attention à bien lancer les tests pour vérifier le fonctionnement.
C'est partiellement compensé par le soin apporté au code mais attention pour la suite.

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