@@ -174,8 +174,7 @@ def fine_like(self, N):
174174
175175 def __str__ (self ):
176176 """ print out some basic information about the grid object """
177- return "2-d grid: nx = {}, ny = {}, ng = {}" .format (
178- self .nx , self .ny , self .ng )
177+ return f"2-d grid: nx = { self .nx } , ny = { self .ny } , ng = { self .ng } "
179178
180179 def __eq__ (self , other ):
181180 """ are two grids equivalent? """
@@ -336,19 +335,15 @@ def __str__(self):
336335 my_str = "CellCenterData2d object not yet initialized"
337336 return my_str
338337
339- my_str = "cc data: nx = {}, ny = {}, ng = {}\n " .format (
340- self .grid .nx , self .grid .ny , self .grid .ng )
338+ my_str = f"cc data: nx = { self .grid .nx } , ny = { self .grid .ny } , ng = { self .grid .ng } \n "
341339 my_str += f" nvars = { self .nvar } \n "
342340 my_str += " variables:\n "
343341
344342 for n in range (self .nvar ):
345- my_str += "%16s: min: %15.10f max: %15.10f\n " % \
346- (self .names [n ], self .min (self .names [n ]), self .max (self .names [n ]))
347- my_str += "%16s BCs: -x: %-12s +x: %-12s -y: %-12s +y: %-12s\n " % \
348- (" " , self .BCs [self .names [n ]].xlb ,
349- self .BCs [self .names [n ]].xrb ,
350- self .BCs [self .names [n ]].ylb ,
351- self .BCs [self .names [n ]].yrb )
343+ name = self .names [n ]
344+ my_str += f"{ name :>16s} : min: { self .min (name ):15.10f} max: { self .max (name ):15.10f} \n "
345+ my_str += f"{ ' ' :>16s} BCs: -x: { self .BCs [name ].xlb :12s} +x: { self .BCs [name ].xrb :12s} "
346+ my_str += f" -y: { self .BCs [name ].ylb :12s} +y: { self .BCs [name ].yrb :12s} \n "
352347
353348 return my_str
354349
@@ -434,7 +429,7 @@ def get_aux(self, keyword):
434429 The value corresponding to the keyword
435430
436431 """
437- if keyword in self .aux . keys () :
432+ if keyword in self .aux :
438433 return self .aux [keyword ]
439434
440435 return None
@@ -482,22 +477,22 @@ def fill_BC(self, name):
482477
483478 # that will handle the standard type of BCs, but if we asked
484479 # for a custom BC, we handle it here
485- if self .BCs [name ].xlb in bnd .ext_bcs . keys () :
480+ if self .BCs [name ].xlb in bnd .ext_bcs :
486481 try :
487482 bnd .ext_bcs [self .BCs [name ].xlb ](self .BCs [name ].xlb , "xlb" , name , self , self .ivars )
488483 except TypeError :
489484 bnd .ext_bcs [self .BCs [name ].xlb ](self .BCs [name ].xlb , "xlb" , name , self )
490- if self .BCs [name ].xrb in bnd .ext_bcs . keys () :
485+ if self .BCs [name ].xrb in bnd .ext_bcs :
491486 try :
492487 bnd .ext_bcs [self .BCs [name ].xrb ](self .BCs [name ].xrb , "xrb" , name , self )
493488 except TypeError :
494489 bnd .ext_bcs [self .BCs [name ].xrb ](self .BCs [name ].xrb , "xrb" , name , self , self .ivars )
495- if self .BCs [name ].ylb in bnd .ext_bcs . keys () :
490+ if self .BCs [name ].ylb in bnd .ext_bcs :
496491 try :
497492 bnd .ext_bcs [self .BCs [name ].ylb ](self .BCs [name ].ylb , "ylb" , name , self )
498493 except TypeError :
499494 bnd .ext_bcs [self .BCs [name ].ylb ](self .BCs [name ].ylb , "ylb" , name , self , self .ivars )
500- if self .BCs [name ].yrb in bnd .ext_bcs . keys () :
495+ if self .BCs [name ].yrb in bnd .ext_bcs :
501496 try :
502497 bnd .ext_bcs [self .BCs [name ].yrb ](self .BCs [name ].yrb , "yrb" , name , self )
503498 except TypeError :
@@ -725,19 +720,15 @@ def __str__(self):
725720 my_str = "FaceCenterData2d object not yet initialized"
726721 return my_str
727722
728- my_str = "fc data: idir = {}, nx = {}, ny = {}, ng = {}\n " .format (
729- self .idir , self .grid .nx , self .grid .ny , self .grid .ng )
723+ my_str = f"fc data: idir = { self .idir } , nx = { self .grid .nx } , ny = { self .grid .ny } , ng = { self .grid .ng } \n "
730724 my_str += f" nvars = { self .nvar } \n "
731725 my_str += " variables:\n "
732726
733727 for n in range (self .nvar ):
734- my_str += "%16s: min: %15.10f max: %15.10f\n " % \
735- (self .names [n ], self .min (self .names [n ]), self .max (self .names [n ]))
736- my_str += "%16s BCs: -x: %-12s +x: %-12s -y: %-12s +y: %-12s\n " % \
737- (" " , self .BCs [self .names [n ]].xlb ,
738- self .BCs [self .names [n ]].xrb ,
739- self .BCs [self .names [n ]].ylb ,
740- self .BCs [self .names [n ]].yrb )
728+ name = self .names [n ]
729+ my_str += f"{ name :>16s} : min: { self .min (name ):15.10f} max: { self .max (name ):15.10f} \n "
730+ my_str += f"{ ' ' :>16s} BCs: -x: { self .BCs [name ].xlb :12s} +x: { self .BCs [name ].xrb :12s} "
731+ my_str += f" -y: { self .BCs [name ].ylb :12s} +y: { self .BCs [name ].yrb :12s} \n "
741732
742733 return my_str
743734
@@ -794,10 +785,10 @@ def fill_BC(self, name):
794785 n = self .names .index (name )
795786 self .data .fill_ghost (n = n , bc = self .BCs [name ])
796787
797- if self .BCs [name ].xlb in bnd .ext_bcs . keys () or \
798- self .BCs [name ].xrb in bnd .ext_bcs . keys () or \
799- self .BCs [name ].ylb in bnd .ext_bcs . keys () or \
800- self .BCs [name ].yrb in bnd .ext_bcs . keys () :
788+ if self .BCs [name ].xlb in bnd .ext_bcs or \
789+ self .BCs [name ].xrb in bnd .ext_bcs or \
790+ self .BCs [name ].ylb in bnd .ext_bcs or \
791+ self .BCs [name ].yrb in bnd .ext_bcs :
801792 raise NotImplementedError ("custom boundary conditions not supported for FaceCenterData2d" )
802793
803794 def restrict (self , varname , N = 2 ):
0 commit comments