python: Apply Black formatter to Python files
The command executed was `black src configs tests util`. Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024 Maintainer: Bobby Bruce <bbruce@ucdavis.edu> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Giacomo Travaglini
parent
1cfaa8da83
commit
787204c92d
@@ -32,8 +32,10 @@ from m5.util import warn
|
||||
# fix the global frequency
|
||||
def fixGlobalFrequency():
|
||||
import _m5.core
|
||||
|
||||
_m5.core.fixClockFrequency()
|
||||
|
||||
|
||||
def setGlobalFrequency(ticksPerSecond):
|
||||
from m5.util import convert
|
||||
import _m5.core
|
||||
@@ -46,12 +48,15 @@ def setGlobalFrequency(ticksPerSecond):
|
||||
tps = round(convert.anyToFrequency(ticksPerSecond))
|
||||
else:
|
||||
raise TypeError(
|
||||
"wrong type '%s' for ticksPerSecond" % type(ticksPerSecond))
|
||||
"wrong type '%s' for ticksPerSecond" % type(ticksPerSecond)
|
||||
)
|
||||
_m5.core.setClockFrequency(int(tps))
|
||||
|
||||
|
||||
# how big does a rounding error need to be before we warn about it?
|
||||
frequency_tolerance = 0.001 # 0.1%
|
||||
|
||||
|
||||
def fromSeconds(value):
|
||||
import _m5.core
|
||||
|
||||
@@ -62,7 +67,8 @@ def fromSeconds(value):
|
||||
# had better be fixed
|
||||
if not _m5.core.clockFrequencyFixed():
|
||||
raise AttributeError(
|
||||
"In order to do conversions, the global frequency must be fixed")
|
||||
"In order to do conversions, the global frequency must be fixed"
|
||||
)
|
||||
|
||||
if value == 0:
|
||||
return 0
|
||||
@@ -71,12 +77,21 @@ def fromSeconds(value):
|
||||
value *= _m5.core.getClockFrequency()
|
||||
|
||||
int_value = int(
|
||||
decimal.Decimal(value).to_integral_value( decimal.ROUND_HALF_UP))
|
||||
decimal.Decimal(value).to_integral_value(decimal.ROUND_HALF_UP)
|
||||
)
|
||||
err = (value - int_value) / value
|
||||
if err > frequency_tolerance:
|
||||
warn("rounding error > tolerance\n %f rounded to %d", value,
|
||||
int_value)
|
||||
warn(
|
||||
"rounding error > tolerance\n %f rounded to %d",
|
||||
value,
|
||||
int_value,
|
||||
)
|
||||
return int_value
|
||||
|
||||
__all__ = [ 'setGlobalFrequency', 'fixGlobalFrequency', 'fromSeconds',
|
||||
'frequency_tolerance' ]
|
||||
|
||||
__all__ = [
|
||||
"setGlobalFrequency",
|
||||
"fixGlobalFrequency",
|
||||
"fromSeconds",
|
||||
"frequency_tolerance",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user