params.py (5451:01b4c909afc6) | params.py (5468:786868ff3058) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 365 unchanged lines hidden (view full) --- 374class TcpPort(CheckedInt): cxx_type = 'uint16_t'; size = 16; unsigned = True 375class UdpPort(CheckedInt): cxx_type = 'uint16_t'; size = 16; unsigned = True 376 377class Percent(CheckedInt): cxx_type = 'int'; min = 0; max = 100 378 379class Float(ParamValue, float): 380 cxx_type = 'double' 381 | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 365 unchanged lines hidden (view full) --- 374class TcpPort(CheckedInt): cxx_type = 'uint16_t'; size = 16; unsigned = True 375class UdpPort(CheckedInt): cxx_type = 'uint16_t'; size = 16; unsigned = True 376 377class Percent(CheckedInt): cxx_type = 'int'; min = 0; max = 100 378 379class Float(ParamValue, float): 380 cxx_type = 'double' 381 |
382 def __init__(self, value): 383 if isinstance(value, (int, long, float, NumericParamValue, Float)): 384 self.value = float(value) 385 else: 386 raise TypeError, "Can't convert object of type %s to Float" \ 387 % type(value).__name__ 388 |
|
382 def getValue(self): 383 return float(self.value) 384 385class MemorySize(CheckedInt): 386 cxx_type = 'uint64_t' 387 size = 64 388 unsigned = True 389 def __init__(self, value): --- 500 unchanged lines hidden (view full) --- 890 val = convert.toMemoryBandwidth(value) 891 return super(cls, MemoryBandwidth).__new__(cls, val) 892 893 def __str__(self): 894 return str(self.val) 895 896 def getValue(self): 897 # convert to seconds per byte | 389 def getValue(self): 390 return float(self.value) 391 392class MemorySize(CheckedInt): 393 cxx_type = 'uint64_t' 394 size = 64 395 unsigned = True 396 def __init__(self, value): --- 500 unchanged lines hidden (view full) --- 897 val = convert.toMemoryBandwidth(value) 898 return super(cls, MemoryBandwidth).__new__(cls, val) 899 900 def __str__(self): 901 return str(self.val) 902 903 def getValue(self): 904 # convert to seconds per byte |
898 value = 1.0 / float(self) | 905 value = float(self) 906 if value: 907 value = 1.0 / float(self) |
899 # convert to ticks per byte 900 value = ticks.fromSeconds(value) 901 return float(value) 902 903 def ini_str(self): 904 return '%f' % self.getValue() 905 906# --- 264 unchanged lines hidden --- | 908 # convert to ticks per byte 909 value = ticks.fromSeconds(value) 910 return float(value) 911 912 def ini_str(self): 913 return '%f' % self.getValue() 914 915# --- 264 unchanged lines hidden --- |