Skip to content
Snippets Groups Projects
Select Git revision
  • 404b7fb2e4fd1539bdeb18b30101b085d401ccbb
  • master default protected
2 results

test_fsig.py

Blame
    • Daniel Brown's avatar
      4d173029
      adding in fsig command (not parsing yet). See example test_fsig.py in bin... · 4d173029
      Daniel Brown authored
      adding in fsig command (not parsing yet). See example test_fsig.py in bin folder. Also made component variable an optional argument for xaxis and x2axis which will break previous scripts. Did this as when setting the parameter to tune, the Param object contains whatever component owns that parameter so no need to pass it twice. Also stops someone passing a parameter not for the component stated.
      4d173029
      History
      adding in fsig command (not parsing yet). See example test_fsig.py in bin...
      Daniel Brown authored
      adding in fsig command (not parsing yet). See example test_fsig.py in bin folder. Also made component variable an optional argument for xaxis and x2axis which will break previous scripts. Did this as when setting the parameter to tune, the Param object contains whatever component owns that parameter so no need to pass it twice. Also stops someone passing a parameter not for the component stated.
    test_property.py 699 B
    class Param(float):
        def __new__(self,name,value):
            return float.__new__(self,value)
             
        def __init__(self,name,value):
            self.__name = name
            
        name = property(lambda self: self.__name)
        
        
    class Beer(object):
        def __init__(self, temp):
            self.__T = temp
            
        @property
        def temp(self):
            return Param('Beer Temperature', self.__T)
        
        @temp.setter
        def temp(self,value):
            self.__T = float(value) 
            
    
    b = Beer(100)
    
    print b.temp.name, b.temp.__class__
    
    print b.temp * 4.5
    
    print b.temp.name, b.temp.__class__
    
    b.temp = 101
    
    print b.temp.name, b.temp.__class__
    
    print b.temp