Checks if the tensor's elements are all near multiples of the period.

    Args:
        a: Tensor of elements that could all be near multiples of the period.
        period: The period, e.g. 2 pi when working in radians.
        atol: Absolute tolerance.
487524
def all_near_zero_mod(a: Union[float, complex, Iterable[float], np.ndarray],
                      period: float,
                      *,
                      atol: float = 1e-8) -> bool:
    
    b = (np.asarray(a) + period / 2) % period - period / 2
    return np.all(np.less_equal(np.abs(b), atol))
20328
def _check_not_tuple_of_2_elements(obj, obj_name='obj'):
    """"""
    if not isinstance(obj, tuple) or len(obj) != 2:
        raise TypeError('%s must be a tuple of 2 elements.' % obj_name)
202549
public void elemMultiply(Tensor other) {
        checkEqualSize(this, other);
        for (int c = 0; c < this.values.length; c++) {
            multiplyValue(c, other.values[c]);
        }     
    }
127032
def operator_is(u):
    """"""
    global _aux
    if np.ndim(u) == 2:
        P = _P2
    elif np.ndim(u) == 3:
        P = _P3
    else:
        raise ValueError("u has an invalid number of dimensions "
                         "(should be 2 or 3)")
    
    if u.shape != _aux.shape[1:]:
        _aux = np.zeros((len(P),) + u.shape)
    
    for _aux_i, P_i in zip(_aux, P):
        _aux_i[:] = binary_dilation(u, P_i)
    
    return _aux.min(0)
516376
def _at_least_x_are_true(a, b, x):
  """"""
  match = tf.equal(a, b)
  match = tf.cast(match, tf.int32)
  return tf.greater_equal(tf.reduce_sum(match), x)
1157869
def contains(self, other):
        
        if not isinstance(other, Period):
            other = period(other)
        return self.start <= other.start and self.stop >= other.stop
1325756
def diff(self, dt=None, abs=True):
        
        if dt is None:
            dt = self.now(self.tz)

        return Period(self, dt, absolute=abs)
363082
def validate_minmax_axis(axis):
    
    ndim = 1  # hard-coded for Index
    if axis is None:
        return
    if axis >= ndim or (axis < 0 and ndim + axis < 0):
        raise ValueError("`axis` must be fewer than the number of "
                         "dimensions ({ndim})".format(ndim=ndim))
816894
def wrap_lons(lons, base, period):
    
    lons = lons.astype(np.float64)
    return ((lons - base + period * 2) % period) + base
767827
def min(self, axis=None, skipna=True, *args, **kwargs):
        
        nv.validate_min(args, kwargs)
        nv.validate_minmax_axis(axis)

        result = nanops.nanmin(self.asi8, skipna=skipna, mask=self.isna())
        if isna(result):
            # Period._from_ordinal does not handle np.nan gracefully
            return NaT
        return self._box_func(result)
585555
def _check_r(self, r):
        """"""
        if abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
            abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
            abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
            np.dot(r[:, 0], r[:, 1]) > eps or \
            np.dot(r[:, 1], r[:, 2]) > eps or \
            np.dot(r[:, 2], r[:, 0]) > eps:
            raise ValueError("The rotation matrix is significantly non-orthonormal.")
970609
def conflicts_with(self, period):
        ""
        if self.tba or period.tba:
            return False
        same_day = False
        for i in self.int_days:
            if i in period.int_days:
                same_day = True

        if not same_day:
            return False

        return self.start <= period.start <= self.end or \
            period.start <= self.start <= period.end or \
            self.start <= period.end <= self.end or \
            period.start <= self.end <= period.end
240648
def subtract_vectors(a, b, periodic):
    '''

    '''
    r = a - b
    delta = np.abs(r)
    sign = np.sign(r)
    return np.where(delta > 0.5 * periodic, sign * (periodic - delta), r)
281814
def triangular_moving_average(data, period):
    
    catch_errors.check_for_period_error(data, period)

    tma = sma(sma(data, period), period)
    return tma
835992
def is_in_interval(n, l, r, border = 'included'):
        
        if 'included' == border:
            return (n >= l) and (n <= r)
        elif 'excluded' == border:
            return (n > l) and (n < r)
        else:
            raise ValueError('borders must be either \'included\' or \'excluded\'')
1093157
def aroon_down(data, period):
    
    catch_errors.check_for_period_error(data, period)
    period = int(period)

    a_down = [((period -
            list(reversed(data[idx+1-period:idx+1])).index(np.min(data[idx+1-period:idx+1]))) /
            float(period)) * 100 for idx in range(period-1, len(data))]
    a_down = fill_for_noncomputable_vals(data, a_down)
    return a_down
958531
def mode_in_range(a, axis=0, tol=1E-3):
    """"""
    a_trunc = a // tol
    vals, counts = mode(a_trunc, axis)
    mask = (a_trunc == vals)
    # mean of each row
    return np.sum(a * mask, axis) / np.sum(mask, axis)