Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6f3fa62
test
CAANASUUCRE Sep 15, 2020
ec214ec
First commit
CAANASUUCRE Sep 15, 2020
09ac361
Fonction average_above_zero ajouté
CAANASUUCRE Sep 15, 2020
76f72e8
Fonction maximum_value ajouté
CAANASUUCRE Sep 15, 2020
07c84ab
Fonction reversed_table ajouté
CAANASUUCRE Sep 15, 2020
088631f
Gestion d'erreur ajouté
CAANASUUCRE Sep 15, 2020
563e3b8
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
CAANASUUCRE Sep 16, 2020
b43f1d7
Fonction roi_bbox ajouté
CAANASUUCRE Sep 16, 2020
ea2f081
Fonction remove_whitespace ajouté
CAANASUUCRE Sep 16, 2020
2c1b4c9
Fonction shuffle ajouté
CAANASUUCRE Sep 16, 2020
a447c53
Fonction a_dice_game ajouté PAS ERMINE
CAANASUUCRE Sep 16, 2020
4a554b6
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
CAANASUUCRE Sep 16, 2020
2319fcf
nouvelle arborescence
CAANASUUCRE Sep 16, 2020
52bed77
Fichier test_S2.py ajouté
CAANASUUCRE Sep 16, 2020
3311742
Test de test unitaire
CAANASUUCRE Sep 16, 2020
c44e421
Autre test unitaire
CAANASUUCRE Sep 16, 2020
f22ab57
Autre test unitaire
CAANASUUCRE Sep 16, 2020
eebed90
Coverall
CAANASUUCRE Sep 16, 2020
d5b0db1
Coverall
CAANASUUCRE Sep 16, 2020
9acb801
ficier inutile supprimé
CAANASUUCRE Sep 16, 2020
823a22a
Fonctions et test séparés
CAANASUUCRE Sep 16, 2020
82f0e0e
Test unitaire average_above_zero
CAANASUUCRE Sep 16, 2020
d82434f
Test unitaire average_above_zero
CAANASUUCRE Sep 16, 2020
3e8471b
Test unitaire average_above_zero
CAANASUUCRE Sep 16, 2020
ce34021
Test unitaire average_above_zero
CAANASUUCRE Sep 16, 2020
75fa8aa
Test unitaire average_above_zero
CAANASUUCRE Sep 16, 2020
e79a187
Test unitaire
CAANASUUCRE Sep 16, 2020
7ec4273
Test unitaire
CAANASUUCRE Sep 16, 2020
c52cae9
Test unitaire
CAANASUUCRE Sep 16, 2020
e678c15
Test unitaire
CAANASUUCRE Sep 16, 2020
2ce80bd
Test unitaire average above zero
CAANASUUCRE Sep 16, 2020
0af3e87
Test unitaire average above zero
CAANASUUCRE Sep 16, 2020
3a38c95
Test unitaire maximum value
CAANASUUCRE Sep 16, 2020
767ce13
Test unitaire reverse_table et roi_bbox
CAANASUUCRE Sep 16, 2020
f6e60b8
Test unitaire remove_whitespace
CAANASUUCRE Sep 16, 2020
c4741b9
merge readme
CAANASUUCRE Sep 29, 2020
8bbd131
invert color function
CAANASUUCRE Sep 29, 2020
c6471b4
invert color numpy function
CAANASUUCRE Sep 29, 2020
22f944f
invert color opencv function
CAANASUUCRE Sep 29, 2020
e27e628
Commentaire fonctions
CAANASUUCRE Sep 29, 2020
add3442
Fichier test
CAANASUUCRE Sep 29, 2020
cbe8958
Test amélioré
CAANASUUCRE Sep 29, 2020
696876a
threshold manuelle
CAANASUUCRE Sep 29, 2020
c970bbd
test gitignore
CAANASUUCRE Oct 13, 2020
d030b40
Ajout du publisher et du reader
CAANASUUCRE Oct 13, 2020
422f06e
Ajout queue_publisher_read.py
CAANASUUCRE Oct 13, 2020
5c1f17d
test
CAANASUUCRE Nov 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
[![Coverage Status](https://coveralls.io/repos/github/albenoit/BachelorDIM-Lectures-Algorithms-2020/badge.svg?branch=master)](https://coveralls.io/github/albenoit/BachelorDIM-Lectures-Algorithms-2020?branch=master)

# BachelorDIM-Lectures-Algorithms-2020
Algorithms, code writing and continuous integration @ DIM Bachelor, Université Savoie Mont Blanc, France


Those lessons are addressed to the "Développeur Informatique Multisupports" (DIM) Bachelor proposed at Université Savoie Mont Blanc in France.
Students are expected to be familiar with programming. The aim is to get more familiar with code quality, maintainability and efficacy... and Python.

**Lessons organisation draft :**

1. Get familiar with maintainable codes using git, sonarcloud and doxygen. *Introduction* slides [here](https://docs.google.com/presentation/d/1xXrdokfxOUP-3b1fEPRfieUhOEez7FJeUtauMpjV4bk/edit?usp=sharing)

2. Get familiar with unit testing and continuous integration using pytest and TravisCI. *Introduction* slides [here](https://docs.google.com/presentation/d/1wb93gyr6JuIDfeDvqTkMBxoLulL_yOXDeYp9qR5EaFI/edit?usp=sharing)

3. Get sensible to performance concerns. Hand crafted codes vs libraries

4. Get familiar with queues using RabbitMQ and CloudAMQP. *Introduction slides* [here](https://docs.google.com/presentation/d/1e-KtztT1KN91ynFhzSfDrdF8qvuYPadKe04ifyxtvrg/edit?usp=sharing)

Evaluation will consist in continuous control and a mid term test.


Evaluation will take into account your code quality and assignements coverage but also github pull request and commits naming conventions and code comments...

Prefer better quality code, ready to be shared and enhanced by others, instead of too rapidly written code, unreadable, un-commented that people will throw to trash and completely rewrite !
.
183 changes: 183 additions & 0 deletions assignements/Session_1/S1_algotools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 15:26:05 2020

@author: vanhouta
"""

import numpy as np
import random

Tab = [10,10,19]

## Documentation for average_above_zero
# @param _table table with number above zero
def average_above_zero(table:list):
Som = 0
## @var _Som
# Sum of all number
N = 0
## @var _N
# Length of the table
for i in range (1,len(table)):
if(table[i] > 0):
Som += table[i]
N += 1
if(N > 0):
Moy = Som/N
else:
raise ValueError("no positive value in the table")
return Moy

print(average_above_zero(Tab))

# 1. Si Som n'est pas défini, le programme ne fonctionne plus
# 2. Si toutes les valeus sont en dessous de 0, N restera à 0 et donc une
# erreur apparaitra à "Moy = Som/N"

def maximum_value(table:list):
'''
This function find the highest value in the list
Args:
table: list of number
Returns the maximum value of a list
'''
maxValue = 0
index = 0
for i in range (1,len(table)):
if(table[i] > maxValue):
maxValue = table[i]
index = i+1
return maxValue,index

(maxi,index) = maximum_value(Tab)
print("Valeur Max : {} , index de la valeur max : {}".format(maxi,index))

def reverse_table(table:list):
'''
This funcion return a reversed list
Args:
table: list of number you want to reverse
Returns the reversed list
'''
return table[::-1]

print("Tableau inversé : {}".format(reverse_table(Tab)))

W=150
H=200
W2 = 12
H2 = 10

Xin = np.zeros((H,W),dtype=float)
Xin2 = np.zeros((H2,W2),dtype=float)

for yXin in range(45,56):
for xXin in range(70,91):
Xin[xXin,yXin]=1

for yXin2 in range(7,10):
for xXin2 in range(6,9):
Xin2[xXin2,yXin2]=1
Xin2[5,8]=1
Xin2[7,10]=1
Xin2[9,8]=1
def roi_bbox(img):
'''
This funcion compute bounding box coordinates of an object
Args:
img: Binary image
Returns the bounding box in numpy array
'''
(y,x)=img.shape
x1 = x
y1 = y
x2 = 0
y2 = 0
for yImg in range(0,y):
for xImg in range(0,x):
if(img[yImg,xImg] == 1):
# null = 0
# elif(img[yImg,xImg] == 1 and null == 0):
if(xImg < x1):
x1 = xImg
if(yImg < y1):
y1 = yImg
if(xImg > x2):
x2 = xImg
if(yImg > y2):
y2 = yImg


return np.array([x1,y1,x2,y2])

print(roi_bbox(Xin))
print(Xin2)
print(roi_bbox(Xin2))

chaine = "Ace Of Spades"
def remove_whitespace(string):
'''
This funcion romeve whitespace in a string
Args:
string: String with character
Returns the string without whitespace
'''
strFinal = ""
for i in string:
if(i != " "):
strFinal += i
return strFinal
#return string.replace(" ","")

print(remove_whitespace(chaine))

listshuffle = [1,2,3,4,5,6,7]
def shuffle(list_in):
for i in range(len(list_in)-1, 0, -1):
randIndex = random.randint(0, i + 1)
list_in[i], list_in[randIndex] = list_in[randIndex], list_in[i]
return list_in

print(shuffle(listshuffle))

def a_dice_game():
userscore = 0
computerscore = 0
maxDice = 6
randChoiceComputer = 2
winScore = 100
turn = 0 #0 = user 1 = computer
sumDiceScore = 0
decision = ""

while(userscore <= winScore or computerscore <= winScore):
if(turn == 0):
print("Votre score total est de {}".format(userscore))
print("Votre score sur ce tour est de {}".format(sumDiceScore))
print("Voulez vous lancer un dé ? (O/N)")
decision = input()
print(decision)
while(decision != 'N' or decision != 'n' or decision != 'O' or decision != 'o'):
print("Erreur. Voulez vous rejouez ? (O/N)")
decision = input()

if(decision == "N" or decision == "n"):
userscore += sumDiceScore
elif(decision == "O" or decision == "o"):
dice = random.randint(1,maxdice)
print("Vous avez fait un lancé de {}".format(dice))
if(dice == 1):
print("Votre score sur ce tout est perdu")
sumDiceScore = 0
turn = 1
else:
sumDiceScore =+ dice


#a_dice_game()





Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
117 changes: 117 additions & 0 deletions assignements/Session_2/func.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 15:15:49 2020

@author: vanhouta
"""
import numpy as np

def plusone(x):
return x+1

def addition(a,b):
return a+b

def average_above_zero(table:list):
Som = 0
## @var _Som
# Sum of all number
N = 0
## @var _N
# Length of the table
for i in range (1,len(table)):
if(table[i] > 0):
Som += table[i]
N += 1
if(N > 0):
Moy = Som/N
else:
raise ValueError("no positive value in the table")
return Moy

def maximum_value(table:list):
'''
This function find the highest value in the list
Args:
table: list of number
Returns the maximum value of a list
'''
maxValue = float('-inf')
index = 0
for i in range (1,len(table)):
if(table[i] > maxValue):
maxValue = table[i]
index = i+1
return maxValue,index

def reverse_table(table:list):
'''
This funcion return a reversed list
Args:
table: list of number you want to reverse
Returns the reversed list
'''
return table[::-1]

def roi_bbox(img):
'''
This funcion compute bounding box coordinates of an object
Args:
img: Binary image
Returns the bounding box in numpy array
'''
(y,x)=img.shape
x1 = x
y1 = y
x2 = 0
y2 = 0
for yImg in range(0,y):
for xImg in range(0,x):
if(img[yImg,xImg] == 1):
# null = 0
# elif(img[yImg,xImg] == 1 and null == 0):
if(xImg < x1):
x1 = xImg
if(yImg < y1):
y1 = yImg
if(xImg > x2):
x2 = xImg
if(yImg > y2):
y2 = yImg


return np.array([x1,y1,x2,y2])


def remove_whitespace(string):
'''
This funcion romeve whitespace in a string
Args:
string: String with character
Returns the string without whitespace
'''
strFinal = ""
for i in string:
if(i != " "):
strFinal += i
return strFinal
#return string.replace(" ","")



















Loading