Bonjour,
Je suis développeur Python et je dois transcoder du code R en Python. Mais voilà R je n'y connais rien donc je débute
Pour le coup, je suis bloqué avec cette fonction pour laquelle je ne comprend pas son fonctionnement.
J'ai donc du mal à la transcoder de R en Python

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
  if (!is_connected(cbind(team1, team2))) {
    wm_tmp <- "The data contains two or more separate clusters of teams that are not comparable. The results may be unreliable."
    warning_messages <- append(warning_messages, wm_tmp)
    warning(wm_tmp)
Pour comprendre la fonction, j'ai fait quelques tests mais ca ne m'avance pas plus sur ca compréhension, voici les tests en R
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
a<-c(1,2,3,4)
b<-c(10,10,20,20)
is_connected(cbind(a,b))#return FALSE
 
b<-c(10,10,20,2)
is_connected(cbind(a,b))#return FALSE
 
b<-c(1,4,3,2)
is_connected(cbind(a,b))#return FALSE
 
b<-c(1,1,2,2)
is_connected(cbind(a,b))#return TRUE
 
b<-c(2,2,2,2)
is_connected(cbind(a,b))#return TRUE
 
b<-c(2,2,2,4)
is_connected(cbind(a,b))#return FALSE
 
b<-c(6,6,6,6)
is_connected(cbind(a,b))#return TRUE
 
b<-c(2,2,6,6)
is_connected(cbind(a,b))#return TRUE