mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-07 08:02:46 +00:00
scripts: csv.py: Fixed divide-by-zero, return +-inf
This may make some mathematician mad, but these are informative scripts. Returning +-inf is much more useful than erroring when dealing with several hundred rows of results. And hey, if it's good enough for IEEE 754, it's good enough for us :) Also fixed a division operator mismatch in RFrac that was causing problems.
This commit is contained in:
@@ -120,6 +120,11 @@ class RInt(co.namedtuple('RInt', 'x')):
|
||||
return self.__class__(self.x * other.x)
|
||||
|
||||
def __truediv__(self, other):
|
||||
if not other:
|
||||
if self >= self.__class__(0):
|
||||
return self.__class__(+mt.inf)
|
||||
else:
|
||||
return self.__class__(-mt.inf)
|
||||
return self.__class__(self.x // other.x)
|
||||
|
||||
def __mod__(self, other):
|
||||
|
||||
Reference in New Issue
Block a user