// argument, so unpack them
if h is None:
w, h = w
if not all(np.isfinite(_) for _ in (w, h)):
raise ValueError("figure size must be finite not "
"({}, {})".format(w, h))
self.bbox_inches.p1 = w, h
After Change
if h is None:
w, h = w
size = w, h
if not np.isfinite(size).all() or (np.array(size) <= 0).any():
raise ValueError(f"figure size must be positive finite not {size}")
self.bbox_inches.p1 = w, h