Ensure that the timesteps in a timeseries are equal. If a restriction
        is provided, they must be equal to the specified restriction.

        Value is a pandas dataframe.
177682
def validate_EQUALTIMESTEPS(value, restriction):
    
    if len(value) == 0:
        return

    if type(value) == pd.DataFrame:
        if str(value.index[0]).startswith('9999'):
            tmp_val = value.to_json().replace('9999', '1900')
            value = pd.read_json(tmp_val)


    #If the timeseries is not datetime-based, check for a consistent timestep
    if type(value.index) == pd.Int64Index:
        timesteps = list(value.index)
        timestep = timesteps[1] - timesteps[0]
        for i, t in enumerate(timesteps[1:]):
            if timesteps[i] - timesteps[i-1] != timestep:
                raise ValidationError("Timesteps not equal: %s"%(list(value.index)))


    if not hasattr(value.index, 'inferred_freq'):
        raise ValidationError("Timesteps not equal: %s"%(list(value.index),))

    if restriction is None:
        if value.index.inferred_freq is None:
            raise ValidationError("Timesteps not equal: %s"%(list(value.index),))
    else:
        if value.index.inferred_freq != restriction:
            raise ValidationError("Timesteps not equal: %s"%(list(value.index),))
377824
private boolean isEqual(Object fld1, Object fld2)
    {
        if (fld1 == null || fld2 == null)
        {
            return (fld1 == fld2);
        }
        else if ((fld1 instanceof BigDecimal) && (fld2 instanceof BigDecimal))
        {
            return (((BigDecimal) fld1).compareTo((BigDecimal) fld2) == 0);
        }
        else if ((fld1 instanceof Date) && (fld2 instanceof Date))
        {
            return (((Date) fld1).getTime() == ((Date) fld2).getTime());
        }
        else
        {
            return fld1.equals(fld2);
        }
    }
1249863
def equal(self, other, delta=0.0):
        
        if (other is None):
            return False
        if (self.uri != other.uri):
            return(False)
        if (self.timestamp is not None or other.timestamp is not None):
            # not equal if only one timestamp specified
            if (self.timestamp is None or
                    other.timestamp is None or
                    abs(self.timestamp - other.timestamp) >= delta):
                return(False)
        if ((self.md5 is not None and other.md5 is not None) and
                self.md5 != other.md5):
            return(False)
        if ((self.length is not None and other.length is not None) and
                self.length != other.length):
            return(False)
        return(True)
1242682
def almost_equal(f: DataFrame, g: DataFrame) -> bool:
    
    if f.empty or g.empty:
        return f.equals(g)
    else:
        # Put in canonical order
        F = (
            f.sort_index(axis=1)
            .sort_values(list(f.columns))
            .reset_index(drop=True)
        )
        G = (
            g.sort_index(axis=1)
            .sort_values(list(g.columns))
            .reset_index(drop=True)
        )
        return F.equals(G)
1203032
def isdatetime(value):
    
    if isinstance(value, np.ndarray):
        return (value.dtype.kind == "M" or
                (value.dtype.kind == "O" and len(value) and
                 isinstance(value[0], datetime_types)))
    else:
        return isinstance(value, datetime_types)
651371
def fit(self, col):
        
        dates = self.safe_datetime_cast(col)
        self.default_val = dates.groupby(dates).count().index[0].timestamp() * 1e9
970165
def _validate(self, val):
        
        if self.allow_None and val is None:
            return

        if not isinstance(val, dt_types) and not (self.allow_None and val is None):
            raise ValueError("Date '%s' only takes datetime types."%self.name)

        if self.step is not None and not isinstance(self.step, dt_types):
            raise ValueError("Step parameter can only be None or a datetime type")

        self._checkBounds(val)
1271968
def timetopythonvalue(time_val):
    ""
    if isinstance(time_val, sequence):
        return map(timetopythonvalue, time_val)
    elif isinstance(time_val, numeric):
        return datetime.datetime(*(time.gmtime(time_val))[:6])
    elif isinstance(time_val, numeric):
        values = []
        try:
            values = map(long, time_val.split(","))
        except:
            pass
        if values:
            return map(timetopythonvalue, values)
    raise ValueError(repr(time_val))
474843
def _check_values(self, values):
        """"""
        assert isinstance(values, Iterable) and not isinstance(
            values, (str, dict, bytes, bytearray)), \
            'values should be a list or tuple. Got {}'.format(type(values))
        if self.header.analysis_period.is_annual:
            a_period_len = 8760 * self.header.analysis_period.timestep
            if self.header.analysis_period.is_leap_year is True:
                a_period_len = a_period_len + 24 * self.header.analysis_period.timestep
        else:
            a_period_len = len(self.header.analysis_period.moys)
        assert len(values) == a_period_len, \
            'Length of values does not match that expected by the '\
            'header analysis_period. {} != {}'.format(len(values), a_period_len)
197079
def value_validate(self, value):
        
        if not isinstance(value, datetime.date):
            raise tldap.exceptions.ValidationError("is invalid date")
        # a datetime is also a date but they are not compatable
        if isinstance(value, datetime.datetime):
            raise tldap.exceptions.ValidationError("should be a date, not a datetime")
579729
def _check_time_series(self, other):
        
        if not isinstance(other, TimeSeries):
            msg = "unsupported operand types(s) for +: %s and %s" % \
                  (type(self), type(other))
            raise TypeError(msg)
210891
def _validate_type_scalar(self, value):
        
        if isinstance(
            value, _int_types + (_str_type, float, date, datetime, bool)
        ):
            return True
856862
def is_missing(data, missing_value):
    
    if is_float(data) and isnan(missing_value):
        return isnan(data)
    elif is_datetime(data) and isnat(missing_value):
        return isnat(data)
    return (data == missing_value)
528598
def tick(self, unit_value):
    
    total_secs = round(time.time() - self.__prev_tick)
    if total_secs >= 1:
      self.__unit_per_sec = unit_value / total_secs - self.__unit_per_sec_prev
      self.__unit_per_sec_prev = unit_value
      self.__prev_tick = time.time()
760040
def check_timeseries_id(self, dataset):
        '''
        
        '''
        timeseries_ids = dataset.get_variables_by_attributes(cf_role='timeseries_id')
        # No need to check
        if not timeseries_ids:
            return
        test_ctx = TestCtx(BaseCheck.MEDIUM, 'Recommended attributes for the timeSeries variable')
        timeseries_variable = timeseries_ids[0]
        test_ctx.assert_true(
            getattr(timeseries_variable, 'long_name', '') != "",
            "long_name attribute should exist and not be empty"
        )
        return test_ctx.to_result()
1285768
def is_equal(self, other):
        
        other = IntervalCell.coerce(other)
        return other.low == self.low and other.high == self.high
184544
def _validate_series_dtype(self, series: pd.Series) -> pd.Series:
        """"""
        return series.apply(lambda i: isinstance(i, self.dtype))