Aide pour traduction
jhon_Smith31
Messages postés
2
Date d'inscription
Statut
Membre
Dernière intervention
-
jhon_Smith31 Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
jhon_Smith31 Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis débutant en python et j'ai entre les mains un src python que je dois traduire en language algorithmique et cela fait un bout de temps que je n'y arrive pas surtout pour les deux fonctions dessous : sachant que la fonction "free_line" retourne 1x2 numpy_array
1 :
def LF_BF(P, Q, p, q, eps):
Parameters
----------
param P : px2 numpy_array,
param Q : qx2 numpy_array,
param p : float, number of points in P
param q : float, number of points in Q
param eps : float,
Returns
-------
LF : dict,
BF : dict,
LF = {}
for j in range(q):
for i in range(p - 1):
LF.update({(i, j): free_line(Q[j], eps, P[i:i + 2])})
BF = {}
for j in range(q - 1):
for i in range(p):
BF.update({(i, j): free_line(P[i], eps, Q[j:j + 2])})
return LF, BF
"""
2:
Parameters
----------
LF : dict,
BF : dict
param p : float,
param q : float,
Returns
-------
rep : bool,
LR : dict,
BR : dict,
"""
if not (LF[(0, 0)][0] <= 0 and BF[(0, 0)][0] <= 0 and LF[(p - 2, q - 1)][1] >= 1 and BF[(p - 1, q - 2)][1] >= 1 ):
rep = False
BR={}
LR={}
else:
LR = {(0, 0): True}
BR = {(0, 0): True}
for i in range(1, p - 1):
if LF[(i, 0)] != [-1, -1] and LF[(i - 1, 0)] == [0, 1]:
LR[(i, 0)] = True
else:
LR[(i, 0)] = False
for j in range(1, q - 1):
if BF[(0, j)] != [-1, -1] and BF[(0, j - 1)] == [0, 1]:
BR[(0, j)] = True
else:
BR[(0, j)] = False
for i in range(p - 1):
for j in range(q - 1):
if LR[(i, j)] or BR[(i, j)]:
if LF[(i, j + 1)] != [-1, -1]:
LR[(i, j + 1)] = True
else:
LR[(i, j + 1)] = False
if BF[(i + 1, j)] != [-1, -1]:
BR[(i + 1, j)] = True
else:
BR[(i + 1, j)] = False
else:
LR[(i, j + 1)] = False
BR[(i + 1, j)] = False
rep = BR[(p - 2, q - 2)] or LR[(p - 2, q - 2)]
return rep, LR, BR
Pourriez vous m'aidez la dessus S'il Vous Plait ?!
Je suis débutant en python et j'ai entre les mains un src python que je dois traduire en language algorithmique et cela fait un bout de temps que je n'y arrive pas surtout pour les deux fonctions dessous : sachant que la fonction "free_line" retourne 1x2 numpy_array
1 :
def LF_BF(P, Q, p, q, eps):
Parameters
----------
param P : px2 numpy_array,
param Q : qx2 numpy_array,
param p : float, number of points in P
param q : float, number of points in Q
param eps : float,
Returns
-------
LF : dict,
BF : dict,
LF = {}
for j in range(q):
for i in range(p - 1):
LF.update({(i, j): free_line(Q[j], eps, P[i:i + 2])})
BF = {}
for j in range(q - 1):
for i in range(p):
BF.update({(i, j): free_line(P[i], eps, Q[j:j + 2])})
return LF, BF
"""
2:
Parameters
----------
LF : dict,
BF : dict
param p : float,
param q : float,
Returns
-------
rep : bool,
LR : dict,
BR : dict,
"""
if not (LF[(0, 0)][0] <= 0 and BF[(0, 0)][0] <= 0 and LF[(p - 2, q - 1)][1] >= 1 and BF[(p - 1, q - 2)][1] >= 1 ):
rep = False
BR={}
LR={}
else:
LR = {(0, 0): True}
BR = {(0, 0): True}
for i in range(1, p - 1):
if LF[(i, 0)] != [-1, -1] and LF[(i - 1, 0)] == [0, 1]:
LR[(i, 0)] = True
else:
LR[(i, 0)] = False
for j in range(1, q - 1):
if BF[(0, j)] != [-1, -1] and BF[(0, j - 1)] == [0, 1]:
BR[(0, j)] = True
else:
BR[(0, j)] = False
for i in range(p - 1):
for j in range(q - 1):
if LR[(i, j)] or BR[(i, j)]:
if LF[(i, j + 1)] != [-1, -1]:
LR[(i, j + 1)] = True
else:
LR[(i, j + 1)] = False
if BF[(i + 1, j)] != [-1, -1]:
BR[(i + 1, j)] = True
else:
BR[(i + 1, j)] = False
else:
LR[(i, j + 1)] = False
BR[(i + 1, j)] = False
rep = BR[(p - 2, q - 2)] or LR[(p - 2, q - 2)]
return rep, LR, BR
Pourriez vous m'aidez la dessus S'il Vous Plait ?!
A voir également:
- Aide pour traduction
- Google traduction photo - Guide
- Hibiki traduction telecharger - Accueil - Intelligence artificielle
- Display name traduction ✓ - Forum Mail
- Traduction créole martinique français reverso ✓ - Forum Loisirs / Divertissements
- Bible hébreu traduction mot à mot pdf - Télécharger - Vie quotidienne
Tout d'abord je tiens à dire que ce n'est pas un exercice. pour étre plus précis je ne comprends pas la ligne suivante :
if not (LF[(0, 0)][0] <= 0 and BF[(0, 0)][0] <= 0 and LF[(p - 2, q - 1)][1] >= 1 and BF[(p - 1, q - 2)][1] >= 1 ):
je suis habitué à java et je l'ecriture suivante je ne l'est jamais rencontré : LF[(0, 0)][0] ?
Voila j'ai posté deux fonction du projet juste pour connaitre la declaration et ce qu'il en suit. Merci pour votre aide