Use default argument of max() in capi bindings

This commit is contained in:
Paul Romano 2018-02-06 07:29:39 -05:00
parent b053e05415
commit cba083103c
4 changed files with 4 additions and 16 deletions

View file

@ -65,10 +65,7 @@ class Cell(_FortranObjectWithID):
if new:
# Determine ID to assign
if uid is None:
try:
uid = max(mapping) + 1
except ValueError:
uid = 1
uid = max(mapping, default=0) + 1
else:
if uid in mapping:
raise AllocationError('A cell with ID={} has already '

View file

@ -66,10 +66,7 @@ class Filter(_FortranObjectWithID):
if new:
# Determine ID to assign
if uid is None:
try:
uid = max(mapping) + 1
except ValueError:
uid = 1
uid = max(mapping, default=0) + 1
else:
if uid in mapping:
raise AllocationError('A filter with ID={} has already '

View file

@ -78,10 +78,7 @@ class Material(_FortranObjectWithID):
if new:
# Determine ID to assign
if uid is None:
try:
uid = max(mapping) + 1
except ValueError:
uid = 1
uid = max(mapping, default=0) + 1
else:
if uid in mapping:
raise AllocationError('A material with ID={} has already '

View file

@ -155,10 +155,7 @@ class Tally(_FortranObjectWithID):
if new:
# Determine ID to assign
if uid is None:
try:
uid = max(mapping) + 1
except ValueError:
uid = 1
uid = max(mapping, default=0) + 1
else:
if uid in mapping:
raise AllocationError('A tally with ID={} has already '