Changeset 7d8094b in sasview for DataLoader/data_info.py


Ignore:
Timestamp:
Jun 5, 2009 8:56:17 PM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1abcb04
Parents:
1b69256
Message:

dataloader: allow for input to write to be child class. Modify clone_without_data to receive a Data1D (or child of Data1D) as an input.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/data_info.py

    rde5c813 r7d8094b  
    565565        return _str 
    566566 
    567     def clone_without_data(self, length=0): 
     567    def clone_without_data(self, length=0, clone=None): 
    568568        """ 
    569569            Clone the current object, without copying the data (which 
     
    572572             
    573573            @param length: length of the data array to be initialized 
     574            @param clone: if provided, the data will be copied to clone 
    574575        """ 
    575576        from copy import deepcopy 
    576577         
    577         x  = numpy.zeros(length)  
    578         dx = numpy.zeros(length)  
    579         y  = numpy.zeros(length)  
    580         dy = numpy.zeros(length)  
    581          
    582         clone = Data1D(x, y, dx=dx, dy=dy) 
     578        if clone is None or not issubclass(clone.__class__, Data1D): 
     579            x  = numpy.zeros(length)  
     580            dx = numpy.zeros(length)  
     581            y  = numpy.zeros(length)  
     582            dy = numpy.zeros(length)  
     583            clone = Data1D(x, y, dx=dx, dy=dy) 
     584         
    583585        clone.title       = self.title 
    584586        clone.run         = self.run 
     
    694696        return _str 
    695697   
    696     def clone_without_data(self, length=0): 
     698    def clone_without_data(self, length=0, clone=None): 
    697699        """ 
    698700            Clone the current object, without copying the data (which 
     
    701703             
    702704            @param length: length of the data array to be initialized 
     705            @param clone: if provided, the data will be copied to clone 
    703706        """ 
    704707        from copy import deepcopy 
    705708         
    706         data     = numpy.zeros(length)  
    707         err_data = numpy.zeros(length)  
    708          
    709         clone = Data2D(data, err_data) 
     709        if clone is None or not issubclass(clone.__class__, Data2D):   
     710            data     = numpy.zeros(length)  
     711            err_data = numpy.zeros(length)  
     712            clone = Data2D(data, err_data) 
     713             
    710714        clone.title       = self.title 
    711715        clone.run         = self.run 
Note: See TracChangeset for help on using the changeset viewer.