(scale, copy=True)
Makes sure that whenever scale is zero, we handle it correctly.

    This happens in most scalers when we have constant features.
Makes sure that whenever scale is zero, we handle it correctly.
Makes sure that whenever scale is zero we handle it correctly .
def _handle_zeros_in_scale(scale, copy=True):
    ''' Makes sure that whenever scale is zero, we handle it correctly.

    This happens in most scalers when we have constant features.'''

    # if we are fitting on 1D arrays, scale might be a scalar
    if np.isscalar(scale):
        if scale == .0:
            scale = 1.
        return scale
    elif isinstance(scale, np.ndarray):
        if copy:
            # New array to avoid side-effects
            scale = scale.copy()
        scale[scale == 0.0] = 1.0
        return scale
def _handle_zeros_in_scale ( scale , copy = True ) : # if we are fitting on 1D arrays, scale might be a scalar if np . isscalar ( scale ) : if scale == .0 : scale = 1. return scale elif isinstance ( scale , np . ndarray ) : if copy : # New array to avoid side-effects scale = scale . copy ( ) scale [ scale == 0.0 ] = 1.0 return scale