@@ -692,7 +692,6 @@ def _equal_length(lst):
692692 append_to = (Xcols , attrs )
693693
694694 cols , domain_vars = append_to
695- cols .append (col )
696695
697696 existing_var , new_var_name = None , None
698697 if domain_vars is not None :
@@ -707,10 +706,13 @@ def _equal_length(lst):
707706 var .attributes .update (flag .attributes )
708707 domain_vars .append (var )
709708
710- # Write back the changed data. This is needeed to pass the
711- # correct, converted values into Table.from_numpy below
709+ if isinstance (values , np .ndarray ) and not values .flags .owndata :
710+ values = values .copy () # might view `data` (string columns)
711+ cols .append (values )
712+
712713 try :
713- data [:, col ] = values
714+ # allow gc to reclaim memory used by string values
715+ data [:, col ] = None
714716 except IndexError :
715717 pass
716718
@@ -719,11 +721,21 @@ def _equal_length(lst):
719721 if not data .size :
720722 return Table .from_domain (domain , 0 )
721723
722- table = Table .from_numpy (domain ,
723- data [:, Xcols ].astype (float , order = 'C' ),
724- data [:, Ycols ].astype (float , order = 'C' ),
725- data [:, Mcols ].astype (object , order = 'C' ),
726- data [:, Wcols ].astype (float , order = 'C' ))
724+ X = Y = M = W = None
725+ if Xcols :
726+ X = np .c_ [tuple (Xcols )]
727+ assert X .dtype == np .float_
728+ else :
729+ X = np .empty ((data .shape [0 ], 0 ), dtype = np .float_ )
730+ if Ycols :
731+ Y = np .c_ [tuple (Ycols )]
732+ assert Y .dtype == np .float_
733+ if Mcols :
734+ M = np .c_ [tuple (Mcols )].astype (object )
735+ if Wcols :
736+ W = np .c_ [tuple (Wcols )].astype (float )
737+
738+ table = Table .from_numpy (domain , X , Y , M , W )
727739 return table
728740
729741 @staticmethod
0 commit comments