original_docstring:  Build filename list from single dir
  			list_index: number in index list (or alternatively label list)
  		
docstring: Build filename list from single dir
  list_index: number in index list (or alternatively label list)
docstring_tokens: Build filename list from single dir list_index : number in index list ( or alternatively label list )
code: def collectFilenamesFromDir(self, list_index): 
  		""" Build filename list from single dir
  			list_index: number in index list (or alternatively label list)
  		"""
  
  		sim_index = self.indices[list_index] # get simulation directory index from list
  		labelstr = "" # debug info only
  		foundCnt = 0
  
  		if self.wildcard is not None:
  			search_dir = os.path.join( self.base_path, (self.simdirname % sim_index) )
  			os.chdir(search_dir)
  			allFiles = [f for f in glob.glob("*") if os.path.isfile(f)] # list all files
  			files = []
  			for f in allFiles:
  				match = re.search(self.wildcard, f) # note, matched again below...
  				if match:
  					files.append(f)
  	
  			if len(files)<1:
  				raise FluidDataLoaderError("Error - no files found in directory '%s' with wildcard '%s' " %(search_dir, self.wildcard) )
  
  			files = sorted(files) # sort by name
  
  			n  = max(1, int(len(files)*self.data_fraction))
  			tf = float(len(files))/n # spread over time range (eg 200 frames) 
  			fcnt = 0
  			for t in range(0,n):
  				filelist_index = int(t*tf) # full range
  				fn = files[filelist_index]
  				self.xfn.append(os.path.join(search_dir, fn))
  				foundCnt += 1
  
  				# construct label, closely follows index version below
  				if self.filename_y is not None:
  					mx = re.search(self.wildcard, fn) 
  					listy = self.filename_y.split("$")
  					if(len(listy)!=2):
  						raise FluidDataLoaderError("Error - when using a wildcard for x, filename_y needs to contain exactly one '$' where the file id string from x will be inserted to build the filename for y. Current, invalid, filename_y is '%s' " %(self.filename_y) )
  					fny = listy[0] + mx.group(1) + listy[1]
  	
  					if not os.path.isfile(fny): # make sure file for y exists
  						raise FluidDataLoaderError("Error - y file '%s' for x file '%s' doesnt exist in search dir '%s' " %(fny, fn, search_dir ) )
  
  					fny = os.path.join(search_dir, fny) 
  					self.yfn.append(fny)
  					self.have_y_npz = True # flag to indicate we have np arrays in y
  
  				if self.array_y is not None:
  					if self.y is None:
  						self.y = []
  					self.y.append( self.array_y[list_index] )
  					labelstr = " with label " + format( self.array_y[list_index] )
  
  				if self.func_y is not None:
  					print("NYI! test...")
  
  		else:
  			# "simple" index range 
  			n  = max(1, int((self.filename_index_max-self.filename_index_min)*self.data_fraction))
  			tf = float(self.filename_index_max-self.filename_index_min)/n
  			for t in range(0,n):
  				filelist_index = int(self.filename_index_min + t*tf) # full range
  
  				fn = self.getFilename(sim_index, self.filename, filelist_index)
  				self.xfn.append(fn)
  				foundCnt += 1
  
  				if self.filename_y is not None:
  					fny = self.getFilename(sim_index, self.filename_y, filelist_index)
  					self.yfn.append(fny)
  					self.have_y_npz = True # flag to indicate we have np arrays in y
  
  				if self.array_y is not None:
  					if self.y is None:
  						self.y = []
  					self.y.append( self.array_y[list_index] )
  					labelstr = " with label " + format( self.array_y[list_index] )
  
  				if self.func_y is not None:
  					print("NYI! test...")
  					if self.y is None:
  						self.y = []
  					self.y.append( self.func_y(list_index, sim_index, t, fn) )
  
  		if self.print_info:
  			print("Found " +format(foundCnt) +" files from sim ID "+format(sim_index) + labelstr )
code_tokens: def collectFilenamesFromDir ( self , list_index ) : sim_index = self . indices [ list_index ] labelstr = "" foundCnt = 0 if self . wildcard is not None : search_dir = os . path . join ( self . base_path , ( self . simdirname % sim_index ) ) os . chdir ( search_dir ) allFiles = [ f for f in glob . glob ( "*" ) if os . path . isfile ( f ) ] files = [ ] for f in allFiles : match = re . search ( self . wildcard , f ) if match : files . append ( f ) if len ( files ) < 1 : raise FluidDataLoaderError ( "Error - no files found in directory '%s' with wildcard '%s' " % ( search_dir , self . wildcard ) ) files = sorted ( files ) n = max ( 1 , int ( len ( files ) * self . data_fraction ) ) tf = float ( len ( files ) ) / n fcnt = 0 for t in range ( 0 , n ) : filelist_index = int ( t * tf ) fn = files [ filelist_index ] self . xfn . append ( os . path . join ( search_dir , fn ) ) foundCnt += 1 if self . filename_y is not None : mx = re . search ( self . wildcard , fn ) listy = self . filename_y . split ( "$" ) if ( len ( listy ) != 2 ) : raise FluidDataLoaderError ( "Error - when using a wildcard for x, filename_y needs to contain exactly one '$' where the file id string from x will be inserted to build the filename for y. Current, invalid, filename_y is '%s' " % ( self . filename_y ) ) fny = listy [ 0 ] + mx . group ( 1 ) + listy [ 1 ] if not os . path . isfile ( fny ) : raise FluidDataLoaderError ( "Error - y file '%s' for x file '%s' doesnt exist in search dir '%s' " % ( fny , fn , search_dir ) ) fny = os . path . join ( search_dir , fny ) self . yfn . append ( fny ) self . have_y_npz = True if self . array_y is not None : if self . y is None : self . y = [ ] self . y . append ( self . array_y [ list_index ] ) labelstr = " with label " + format ( self . array_y [ list_index ] ) if self . func_y is not None : print ( "NYI! test..." ) else : n = max ( 1 , int ( ( self . filename_index_max - self . filename_index_min ) * self . data_fraction ) ) tf = float ( self . filename_index_max - self . filename_index_min ) / n for t in range ( 0 , n ) : filelist_index = int ( self . filename_index_min + t * tf ) fn = self . getFilename ( sim_index , self . filename , filelist_index ) self . xfn . append ( fn ) foundCnt += 1 if self . filename_y is not None : fny = self . getFilename ( sim_index , self . filename_y , filelist_index ) self . yfn . append ( fny ) self . have_y_npz = True if self . array_y is not None : if self . y is None : self . y = [ ] self . y . append ( self . array_y [ list_index ] ) labelstr = " with label " + format ( self . array_y [ list_index ] ) if self . func_y is not None : print ( "NYI! test..." ) if self . y is None : self . y = [ ] self . y . append ( self . func_y ( list_index , sim_index , t , fn ) ) if self . print_info : print ( "Found " + format ( foundCnt ) + " files from sim ID " + format ( sim_index ) + labelstr )
short_docstring: Build filename list from single dir
  list_index: number in index list (or alternatively label list)
short_docstring_tokens: Build filename list from single dir list_index : number in index list ( or alternatively label list )
comment: """ Build filename list from single dir
  			list_index: number in index list (or alternatively label list)
  		"""$SEP$# get simulation directory index from list
  $SEP$# debug info only
  $SEP$# list all files
  $SEP$# note, matched again below...
  $SEP$# sort by name
  $SEP$# spread over time range (eg 200 frames) 
  $SEP$# full range
  $SEP$# construct label, closely follows index version below
  $SEP$# make sure file for y exists
  $SEP$# flag to indicate we have np arrays in y
  $SEP$# "simple" index range 
  $SEP$# full range
  $SEP$# flag to indicate we have np arrays in y
  