Changeset 1d56359 in sasview


Ignore:
Timestamp:
Mar 26, 2019 3:43:55 PM (6 months ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
ticket-1094-headless
Children:
7f5aa4f
Parents:
3f89c0e
Message:

code cleanup: move shared code to function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/fit/fitstate.py

    r3f89c0e r1d56359  
    7676        Summarize the fit pages in the state object. 
    7777        """ 
    78         for k, fit in enumerate(self.fits): 
    79             print("="*20, "Fit page", k+1) 
    80             #print(fit) 
    81             for attr, value in sorted(fit.__dict__.items()): 
     78        # Note: _dump_attrs isn't a closure, but putting it here anyway 
     79        # because it is specific to show and doesn't need to be efficient. 
     80        def _dump_attrs(obj, label=""): 
     81            #print(obj) 
     82            print("="*20, label) 
     83            for attr, value in sorted(obj.__dict__.items()): 
    8284                if isinstance(value, (list, tuple)): 
    8385                    print(attr) 
     
    8688                else: 
    8789                    print(attr, value) 
     90        for k, fit in enumerate(self.fits): 
     91            _dump_attrs(fit, label="Fit page "+str(k+1)) 
    8892        if self.simfit: 
    89             print("="*20, "Constraints") 
    90             #print(self.simfit) 
    91             for attr, value in sorted(self.simfit.__dict__.items()): 
    92                 if isinstance(value, (list, tuple)): 
    93                     print(attr) 
    94                     for item in value: 
    95                         print("   ", item) 
    96                 else: 
    97                     print(attr, value) 
     93            _dump_attrs(self.simfit, label="Constraints") 
    9894 
    9995    def make_fitproblem(self): 
Note: See TracChangeset for help on using the changeset viewer.