def test_tintseq_accessors(cursor, expected_tintseq): assert TIntSeq(expected_tintseq).tempSubtype() == 'Sequence' assert TIntSeq(expected_tintseq).getValues == [10, 20, 30] assert TIntSeq(expected_tintseq).startValue == 10 assert TIntSeq(expected_tintseq).endValue == 30 assert TIntSeq(expected_tintseq).minValue == 10 assert TIntSeq(expected_tintseq).maxValue == 30 assert TIntSeq(expected_tintseq).valueRange == intrange(10, 30, upper_inc=True) assert TIntSeq(expected_tintseq).getTime == PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}') assert TIntSeq(expected_tintseq).duration == timedelta(2) assert TIntSeq(expected_tintseq).timespan == timedelta(2) assert TIntSeq(expected_tintseq).period == Period( '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]') assert TIntSeq(expected_tintseq).numInstants == 3 assert TIntSeq(expected_tintseq).startInstant == TIntInst( '10@2019-09-01 00:00:00+01') assert TIntSeq(expected_tintseq).endInstant == TIntInst( '30@2019-09-03 00:00:00+01') assert TIntSeq(expected_tintseq).instantN(2) == TIntInst( '20@2019-09-02 00:00:00+01') assert TIntSeq(expected_tintseq).instants == \ [TIntInst('10@2019-09-01 00:00:00+01'), TIntInst('20@2019-09-02 00:00:00+01'), TIntInst('30@2019-09-03 00:00:00+01')] assert TIntSeq(expected_tintseq).numTimestamps == 3 assert TIntSeq(expected_tintseq).startTimestamp == parse( '2019-09-01 00:00:00+01') assert TIntSeq(expected_tintseq).endTimestamp == parse( '2019-09-03 00:00:00+01') assert TIntSeq(expected_tintseq).timestampN(2) == parse( '2019-09-02 00:00:00+01') assert TIntSeq(expected_tintseq).timestamps == [ parse('2019-09-01 00:00:00+01'), parse('2019-09-02 00:00:00+01'), parse('2019-09-03 00:00:00+01') ] assert TIntSeq(expected_tintseq).intersectsTimestamp( parse('2019-09-01 00:00:00+01')) == True assert TIntSeq(expected_tintseq).intersectsTimestamp( parse('2019-09-04 00:00:00+01')) == False assert TIntSeq(expected_tintseq).intersectsTimestampSet( TimestampSet( '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TIntSeq(expected_tintseq).intersectsTimestampSet( TimestampSet( '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False assert TIntSeq(expected_tintseq).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TIntSeq(expected_tintseq).intersectsPeriod( Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False assert TIntSeq(expected_tintseq).intersectsPeriodSet( PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TIntSeq(expected_tintseq).intersectsPeriodSet( PeriodSet( '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
def test_tintinst_accessors(cursor, expected_tintinst): assert TIntInst(expected_tintinst).tempSubtype() == 'Instant' assert TIntInst(expected_tintinst).getValue == 10 assert TIntInst(expected_tintinst).getValues == [10] assert TIntInst(expected_tintinst).startValue == 10 assert TIntInst(expected_tintinst).endValue == 10 assert TIntInst(expected_tintinst).minValue == 10 assert TIntInst(expected_tintinst).maxValue == 10 assert TIntInst(expected_tintinst).valueRange == intrange(10, 10, upper_inc=True) assert TIntInst(expected_tintinst).getTimestamp == parse('2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).getTime == PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}') assert TIntInst(expected_tintinst).duration == timedelta(0) assert TIntInst(expected_tintinst).timespan == timedelta(0) assert TIntInst(expected_tintinst).period == Period('[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]') assert TIntInst(expected_tintinst).numInstants == 1 assert TIntInst(expected_tintinst).startInstant == TIntInst('10@2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).endInstant == TIntInst('10@2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).instantN(1) == TIntInst('10@2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).instants == [TIntInst('10@2019-09-01 00:00:00+01')] assert TIntInst(expected_tintinst).numTimestamps == 1 assert TIntInst(expected_tintinst).startTimestamp == parse('2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).endTimestamp == parse('2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).timestampN(1) == parse('2019-09-01 00:00:00+01') assert TIntInst(expected_tintinst).timestamps == [parse('2019-09-01 00:00:00+01')] assert TIntInst(expected_tintinst).intersectsTimestamp(parse('2019-09-01 00:00:00+01')) == True assert TIntInst(expected_tintinst).intersectsTimestamp(parse('2019-09-02 00:00:00+01')) == False assert TIntInst(expected_tintinst).intersectsTimestampSet( TimestampSet('{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TIntInst(expected_tintinst).intersectsTimestampSet( TimestampSet('{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False assert TIntInst(expected_tintinst).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TIntInst(expected_tintinst).intersectsPeriod( Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False assert TIntInst(expected_tintinst).intersectsPeriod( Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False assert TIntInst(expected_tintinst).intersectsPeriodSet( PeriodSet('{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TIntInst(expected_tintinst).intersectsPeriodSet( PeriodSet('{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False assert TIntInst(expected_tintinst).intersectsPeriodSet( PeriodSet('{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
def valueRange(self): """ Range of values taken by the temporal value as defined by its minimum and maximum value """ return intrange(self.minValue, self.maxValue, True, True)