mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Use default argument of max() in capi bindings
This commit is contained in:
parent
b053e05415
commit
cba083103c
4 changed files with 4 additions and 16 deletions
|
|
@ -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 '
|
||||
|
|
|
|||
|
|
@ -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 '
|
||||
|
|
|
|||
|
|
@ -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 '
|
||||
|
|
|
|||
|
|
@ -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 '
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue