@@ -23,15 +23,15 @@ class Matrix:
2323 """Matrix class."""
2424
2525 def __init__ (
26- self ,
27- mat = None ,
28- rows_labels = None ,
29- cols_labels = None ,
30- graph = None ,
31- quadratic = False ,
32- name = '' ,
33- init_value = None ,
34- ** kwargs
26+ self ,
27+ mat = None ,
28+ rows_labels = None ,
29+ cols_labels = None ,
30+ graph = None ,
31+ quadratic = False ,
32+ name = '' ,
33+ init_value = None ,
34+ ** kwargs
3535 ):
3636 """Initialize matrix.
3737
@@ -87,7 +87,7 @@ def __str__(self):
8787 return f"\n matrix { self .name } \n { s } \n "
8888
8989 def __iter__ (self , ** kargs ):
90- """Helper method for the iteration of the Matrix."""
90+ """Help method for the iteration of the Matrix."""
9191 self .i = - 1
9292 self .j = 0
9393
@@ -99,7 +99,7 @@ def __iter__(self, **kargs):
9999 return self
100100
101101 def __next__ (self ):
102- """Helper method for the iteration of the Matrix."""
102+ """Help method for the iteration of the Matrix."""
103103 if self .i >= len (self .rows_labels ) - 1 and self .j >= len (self .cols_labels ) - 1 :
104104 self .get_labels = True
105105 self .get_indices = False
@@ -381,7 +381,7 @@ def match_mat(self, reference_matrix, match_quadratic=None):
381381
382382 return mat_match
383383
384- def match_missing_rows (self , reference_labels , missing_fill = 0 ):
384+ def match_missing_rows (self , reference_labels , missing_fill = 0 ):
385385 """Match method to set missing rows labels from reference labels with the missing_fill value."""
386386 if reference_labels == self .rows_labels :
387387 return self
@@ -482,7 +482,7 @@ def from_csv(self, csv_path):
482482
483483 """Export"""
484484
485- def to_dict (self , ordered = True ):
485+ def to_dict (self , ordered = True ):
486486 """Export/convert matrix as a dictionary data structure."""
487487 if ordered :
488488 mat = self .order_rows ()
@@ -496,15 +496,17 @@ def to_dict(self, ordered = True):
496496
497497 return d
498498
499- def to_csv (self , path , file_name = '_export.csv' , index = False , ordered = True ):
499+ def to_csv (self , path , file_name = '_export.csv' , index = False , ordered = True ):
500500 """Export matrix to csv file using the headers (row_labels, cols_labels) of the Matrix class."""
501501 # Generate dataframe
502- df = pd .DataFrame (data = self .to_dict (ordered ))
502+ df = pd .DataFrame (data = self .to_dict (ordered ))
503+
504+ df .to_csv (os .path .join (path , self .name , file_name ), index = index )
503505
504- df .to_csv (os .path .join (path , self .name , file_name ), index = index )
505506
506507class LaplacianMatrix (Matrix ):
507508 """Laplacian matrix class."""
509+
508510 def __init__ (self , graph , normalized = False , name = '' ):
509511 """Initialize laplacian."""
510512 l_mat = get_laplacian (graph , normalized )
0 commit comments