def test_tfloatseq_accessors(cursor, expected_tfloatseqseteq): assert TFloatSeq(expected_tfloatseqseteq).tempSubtype() == 'Sequence' # assert TFloatSeq(expected_tfloatseqseteq).getValues == [floatrange(10.0, 30.0, upper_inc=True)] assert TFloatSeq(expected_tfloatseqseteq).startValue == 10.0 assert TFloatSeq(expected_tfloatseqseteq).endValue == 30.0 assert TFloatSeq(expected_tfloatseqseteq).minValue == 10.0 assert TFloatSeq(expected_tfloatseqseteq).maxValue == 30.0 assert TFloatSeq(expected_tfloatseqseteq).valueRange == floatrange( 10.0, 30.0, upper_inc=True) assert TFloatSeq(expected_tfloatseqseteq).getTime == PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]}') assert TFloatSeq(expected_tfloatseqseteq).duration == timedelta(2) assert TFloatSeq(expected_tfloatseqseteq).timespan == timedelta(2) assert TFloatSeq(expected_tfloatseqseteq).period == Period( '[2019-09-01 00:00:00+01, 2019-09-03 00:00:00+01]') assert TFloatSeq(expected_tfloatseqseteq).numInstants == 3 assert TFloatSeq(expected_tfloatseqseteq).startInstant == TFloatInst( '10.0@2019-09-01 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).endInstant == TFloatInst( '30.0@2019-09-03 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).instantN(2) == TFloatInst( '20.0@2019-09-02 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).instants == \ [TFloatInst('10.0@2019-09-01 00:00:00+01'), TFloatInst('20.0@2019-09-02 00:00:00+01'), TFloatInst('30.0@2019-09-03 00:00:00+01')] assert TFloatSeq(expected_tfloatseqseteq).numTimestamps == 3 assert TFloatSeq(expected_tfloatseqseteq).startTimestamp == parse( '2019-09-01 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).endTimestamp == parse( '2019-09-03 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).timestampN(2) == parse( '2019-09-02 00:00:00+01') assert TFloatSeq(expected_tfloatseqseteq).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 TFloatSeq(expected_tfloatseqseteq).intersectsTimestamp( parse('2019-09-01 00:00:00+01')) == True assert TFloatSeq(expected_tfloatseqseteq).intersectsTimestamp( parse('2019-09-04 00:00:00+01')) == False assert TFloatSeq(expected_tfloatseqseteq).intersectsTimestampSet( TimestampSet( '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TFloatSeq(expected_tfloatseqseteq).intersectsTimestampSet( TimestampSet( '{2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01}')) == False assert TFloatSeq(expected_tfloatseqseteq).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TFloatSeq(expected_tfloatseqseteq).intersectsPeriod( Period('[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]')) == False assert TFloatSeq(expected_tfloatseqseteq).intersectsPeriodSet( PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TFloatSeq(expected_tfloatseqseteq).intersectsPeriodSet( PeriodSet( '{[2019-09-04 00:00:00+01, 2019-09-05 00:00:00+01]}')) == False
def getValues(self): """ List of ranges representing the values taken by the temporal value. """ min = self.minValue max = self.maxValue lower = self.startValue upper = self.endValue min_inc = min < lower or (min == lower and self.lower_inc) max_inc = max > upper or (max == upper and self.upper_inc) if not min_inc: min_inc = min in self._instantList[1:-1] if not max_inc: max_inc = max in self._instantList[1:-1] return [floatrange(min, max, min_inc, max_inc)]
def test_tfloatinst_accessors(cursor, expected_tfloatinst): assert TFloatInst(expected_tfloatinst).duration() == 'Instant' assert TFloatInst(expected_tfloatinst).getValue == 10.0 assert TFloatInst(expected_tfloatinst).getValues == [ floatrange(10.0, 10.0, upper_inc=True) ] assert TFloatInst(expected_tfloatinst).startValue == 10.0 assert TFloatInst(expected_tfloatinst).endValue == 10.0 assert TFloatInst(expected_tfloatinst).minValue == 10.0 assert TFloatInst(expected_tfloatinst).maxValue == 10.0 assert TFloatInst(expected_tfloatinst).valueRange == floatrange( 10.0, 10.0, upper_inc=True) assert TFloatInst(expected_tfloatinst).getTimestamp == parse( '2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).getTime == PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]}') assert TFloatInst(expected_tfloatinst).timespan == timedelta(0) assert TFloatInst(expected_tfloatinst).period == Period( '[2019-09-01 00:00:00+01, 2019-09-01 00:00:00+01]') assert TFloatInst(expected_tfloatinst).numInstants == 1 assert TFloatInst(expected_tfloatinst).startInstant == TFloatInst( '10.0@2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).endInstant == TFloatInst( '10.0@2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).instantN(1) == TFloatInst( '10.0@2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).instants == [ TFloatInst('10.0@2019-09-01 00:00:00+01') ] assert TFloatInst(expected_tfloatinst).numTimestamps == 1 assert TFloatInst(expected_tfloatinst).startTimestamp == parse( '2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).endTimestamp == parse( '2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).timestampN(1) == parse( '2019-09-01 00:00:00+01') assert TFloatInst(expected_tfloatinst).timestamps == [ parse('2019-09-01 00:00:00+01') ] assert TFloatInst(expected_tfloatinst).intersectsTimestamp( parse('2019-09-01 00:00:00+01')) == True assert TFloatInst(expected_tfloatinst).intersectsTimestamp( parse('2019-09-02 00:00:00+01')) == False assert TFloatInst(expected_tfloatinst).intersectsTimestampset( TimestampSet( '{2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01}')) == True assert TFloatInst(expected_tfloatinst).intersectsTimestampset( TimestampSet( '{2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01}')) == False assert TFloatInst(expected_tfloatinst).intersectsPeriod( Period('[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == True assert TFloatInst(expected_tfloatinst).intersectsPeriod( Period('(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]')) == False assert TFloatInst(expected_tfloatinst).intersectsPeriod( Period('[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]')) == False assert TFloatInst(expected_tfloatinst).intersectsPeriodset( PeriodSet( '{[2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == True assert TFloatInst(expected_tfloatinst).intersectsPeriodset( PeriodSet( '{(2019-09-01 00:00:00+01, 2019-09-02 00:00:00+01]}')) == False assert TFloatInst(expected_tfloatinst).intersectsPeriodset( PeriodSet( '{[2019-09-02 00:00:00+01, 2019-09-03 00:00:00+01]}')) == False
def getValues(self): """ List of ranges representing the values taken by the temporal value """ return [floatrange(self._value, self._value, True, True)]
def valueRange(self): """ Range of values taken by the temporal value as defined by its minimum and maximum value """ return floatrange(self.minValue, self.maxValue, True, True)
def getValues(self): """ List of ranges representing the values taken by the temporal value. """ values = super().getValues return [floatrange(value, value, True, True) for value in values]