def _maybe_upcast(values, fill_value=np.nan, dtype=None, copy=False):
 if is_extension_type(values):
  if copy:
   values = values.copy()
 else:
  if (dtype is None):
   dtype = values.dtype
  (new_dtype, fill_value) = _maybe_promote(dtype, fill_value)
  if (new_dtype != values.dtype):
   values = values.astype(new_dtype)
  elif copy:
   values = values.copy()
 return (values, fill_value)

def _maybe_upcast ( values , fill_value = np . nan , dtype = None , copy = False ) : if is_extension_type ( values ) : if copy : values = values . copy ( ) else : if ( dtype is None ) : dtype = values . dtype ( new_dtype , fill_value ) = _maybe_promote ( dtype , fill_value ) if ( new_dtype != values . dtype ) : values = values . astype ( new_dtype ) elif copy : values = values . copy ( ) return ( values , fill_value )
provide explict type promotion and coercion parameters values : the ndarray that we want to maybe upcast fill_value : what we want to fill with dtype : if none .