Ignore:
Timestamp:
Jun 7, 2010 8:26:43 AM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
b94945d
Parents:
79ac6f8
Message:

working on documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/pagestate.py

    r35b556d r5062bbf  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2009, University of Tennessee 
    9 """ 
     1 
     2 
     3################################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7# 
     8#See the license text in license.txt 
     9# 
     10#copyright 2009, University of Tennessee 
     11################################################################################ 
     12 
    1013import time 
    1114import os 
     
    8790class PageState(object): 
    8891    """ 
    89         Contains information to reconstruct a page of the fitpanel. 
     92    Contains information to reconstruct a page of the fitpanel. 
    9093    """ 
    9194    def __init__(self, parent=None, model=None, data=None): 
    9295         
    9396        """  
    94             Initialize the current state 
    95             @param model: a selected model within a page 
    96             @param data:  
     97        Initialize the current state 
     98         
     99        :param model: a selected model within a page 
     100        :param data:  
     101         
    97102        """ 
    98103        self.file = None 
     
    201206    def clone(self): 
    202207        """ 
    203             Create a new copy of the current object 
     208        Create a new copy of the current object 
    204209        """ 
    205210        model = None 
     
    271276    def _repr_helper(self, list, rep): 
    272277        """ 
    273             Helper method to print a state 
     278        Helper method to print a state 
    274279        """ 
    275280        for item in list: 
     
    288293    def __repr__(self): 
    289294        """  
    290             output string for printing 
     295        output string for printing 
    291296        """ 
    292297        rep = "\nState name: %s\n"%self.file 
     
    321326    def _toXML_helper(self, list, element, newdoc): 
    322327        """ 
    323             Helper method to create xml file for saving state 
     328        Helper method to create xml file for saving state 
    324329        """ 
    325330        for item in list: 
     
    339344    def toXML(self, file="fitting_state.fitv", doc=None, entry_node=None): 
    340345        """ 
    341             Writes the state of the InversionControl panel to file, as XML. 
    342              
    343             Compatible with standalone writing, or appending to an 
    344             already existing XML document. In that case, the XML document 
    345             is required. An optional entry node in the XML document may also be given. 
    346              
    347             @param file: file to write to 
    348             @param doc: XML document object [optional] 
    349             @param entry_node: XML node within the XML document at which we will append the data [optional] 
     346        Writes the state of the InversionControl panel to file, as XML. 
     347         
     348        Compatible with standalone writing, or appending to an 
     349        already existing XML document. In that case, the XML document 
     350        is required. An optional entry node in the XML document may also be given. 
     351         
     352        :param file: file to write to 
     353        :param doc: XML document object [optional] 
     354        :param entry_node: XML node within the XML document at which we will append the data [optional] 
     355         
    350356        """ 
    351357        from xml.dom.minidom import getDOMImplementation 
     
    430436    def _fromXML_helper(self, node, list): 
    431437        """ 
    432             Helper function to write state to xml 
     438        Helper function to write state to xml 
    433439        """ 
    434440        for item in node: 
     
    448454    def fromXML(self, file=None, node=None): 
    449455        """ 
    450             Load fitting state from a file 
    451              
    452             @param file: .fitv file 
    453             @param node: node of a XML document to read from 
     456        Load fitting state from a file 
     457         
     458        :param file: .fitv file 
     459        :param node: node of a XML document to read from 
     460         
    454461        """ 
    455462       
     
    512519class Reader(CansasReader): 
    513520    """ 
    514         Class to load a .fitv fitting file 
     521    Class to load a .fitv fitting file 
    515522    """ 
    516523    ## File type 
     
    524531    def __init__(self, call_back=None, cansas=True): 
    525532        """ 
    526             Initialize the call-back method to be called 
    527             after we load a file 
    528             @param call_back: call-back method 
    529             @param cansas:  True = files will be written/read in CanSAS format 
    530                             False = write CanSAS format 
     533        Initialize the call-back method to be called 
     534        after we load a file 
     535         
     536        :param call_back: call-back method 
     537        :param cansas:  True = files will be written/read in CanSAS format 
     538                        False = write CanSAS format 
    531539             
    532540        """ 
     
    538546    def read(self, path): 
    539547        """  
    540             Load a new P(r) inversion state from file 
    541              
    542             @param path: file path 
    543             @return: None 
     548        Load a new P(r) inversion state from file 
     549         
     550        :param path: file path 
     551         
    544552        """ 
    545553        if self.cansas == True: 
     
    548556    def _data2d_to_xml_doc(self, datainfo): 
    549557        """ 
    550             Create an XML document to contain the content of a Data2D 
    551              
    552             @param datainfo: Data2D object 
     558        Create an XML document to contain the content of a Data2D 
     559         
     560        :param datainfo: Data2D object 
     561         
    553562        """ 
    554563        if not issubclass(datainfo.__class__, Data2D): 
     
    722731            for note in item.notes: 
    723732                write_node(doc, node, "SASprocessnote", note) 
    724          
    725733        # Return the document, and the SASentry node associated with 
    726734        # the data we just wrote 
    727735        return doc, entry_node 
    728736    
    729      
    730737    def _parse_state(self, entry): 
    731738        """ 
    732             Read a fit result from an XML node 
    733             @param entry: XML node to read from  
    734             @return: PageState object 
     739        Read a fit result from an XML node 
     740         
     741        :param entry: XML node to read from  
     742         
     743        :return: PageState object 
    735744        """ 
    736745        # Create an empty state 
     
    747756    def _parse_entry_2d(self, dom): 
    748757        """ 
    749             Parse a SASentry 
    750              
    751             @param node: SASentry node 
    752             @return: Data2D object 
    753         """ 
    754        
     758        Parse a SASentry 
     759         
     760        :param node: SASentry node 
     761         
     762        :return: Data2D object 
     763         
     764        """ 
    755765        data_info = Data2D() 
    756766         
     
    10831093    def _read_cansas(self, path): 
    10841094        """  
    1085             Load data and P(r) information from a CanSAS XML file. 
    1086              
    1087             @param path: file path 
    1088             @return: Data1D object if a single SASentry was found,  
    1089                         or a list of Data1D objects if multiple entries were found, 
    1090                         or None of nothing was found 
    1091             @raise RuntimeError: when the file can't be opened 
    1092             @raise ValueError: when the length of the data vectors are inconsistent 
     1095        Load data and P(r) information from a CanSAS XML file. 
     1096         
     1097        :param path: file path 
     1098         
     1099        :return: Data1D object if a single SASentry was found,  
     1100                    or a list of Data1D objects if multiple entries were found, 
     1101                    or None of nothing was found 
     1102                     
     1103        :raise RuntimeError: when the file can't be opened 
     1104        :raise ValueError: when the length of the data vectors are inconsistent 
     1105         
    10931106        """ 
    10941107        output = [] 
     
    11551168    def write(self, filename, datainfo=None, fitstate=None): 
    11561169        """ 
    1157             Write the content of a Data1D as a CanSAS XML file 
    1158              
    1159             @param filename: name of the file to write 
    1160             @param datainfo: Data1D object 
    1161             @param fitstate: PageState object 
     1170        Write the content of a Data1D as a CanSAS XML file 
     1171         
     1172        :param filename: name of the file to write 
     1173        :param datainfo: Data1D object 
     1174        :param fitstate: PageState object 
     1175         
    11621176        """ 
    11631177        # Sanity check 
     
    11821196            fitstate.toXML(file=filename) 
    11831197         
    1184          
    1185 if __name__ == "__main__": 
    1186     state = PageState(parent=None) 
    1187     state.toXML() 
    1188     print "state", state 
     1198"""      
     1199Example: :: 
     1200   
     1201    if __name__ == "__main__": 
     1202        state = PageState(parent=None) 
     1203        state.toXML() 
     1204        print "state", state 
     1205     
     1206""" 
Note: See TracChangeset for help on using the changeset viewer.