Salut les dev,
J'ai un script en matlab à convertir en Python:
Je bloque un peu dans la portion suivante:
ceci en matlab:
Code MATLAB : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
if mod(c.nim-c.nb,2) == 0
    nw = (c.nim - c.nb)/2;
    WhiteSegment = repmat(W,1,nw);
    BlackSegment = repmat(K,1,c.nb);
    lineb = [WhiteSegment BlackSegment WhiteSegment];
else
    nw = (c.nim - c.nb - 1)/2;
    G = uint8(127*ones(1,1,3));
    WhiteSegment = repmat(W,1,nw);
    BlackSegment = repmat(K,1,c.nb-1);
    lineb = [WhiteSegment G BlackSegment G WhiteSegment];
end

ceci en python:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
if (nim - nb % 2) == 0:
    nw = (nim - nb) /2;
    WhiteSegment = np.matlib.repmat(W, 1, nw)
    BlackSegment = np.tile(K, 1, nb)
    lineb = ([WhiteSegment, BlackSegment, WhiteSegment])
else:
    nw = (nim - nb - 1) / 2
    G = 127 * np.ones((1, 1, 3), dtype=np.int8)
    WhiteSegment =np.tile(W, int (nw))
    BlackSegment = np.tile(K, nb - 1)
    lineb = ([WhiteSegment, G, BlackSegment, G, WhiteSegment])
Au fait les lineb à l’intérieur des blocs if else, je ne sais pas comment les faire!

j'aimerais un coup de pousse svp.

merci