ATLAS Offline Software
DataQuality
DQUtils
tests
test_iovtype.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
3
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4
5
from
DQUtils.sugar.iovtype
import
RANGEIOV_VAL, make_iov_type
6
from
DQUtils.sugar
import
RunLumi
7
from
DQUtils.sugar.runlumi
import
TimestampType
8
9
10
def
test_empty_is_boolean_false
():
11
"""
12
Check that "empty" IOV type evaluates to False
13
"""
14
empty = RANGEIOV_VAL.empty()
15
assert
not
empty
16
return
True
17
18
19
def
test_runs
():
20
iov =
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(3,1))
21
assert
list
(iov.runs) == [1,2,3]
22
assert
iov.run == 1
23
24
25
def
test_contains_point
():
26
iov =
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(3,1))
27
assert
iov.contains_point(
RunLumi
(2,1))
28
assert
not
iov.contains_point(
RunLumi
(4,1))
29
30
31
def
test_intersect
():
32
iov1 =
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(3,1))
33
iov2 =
RANGEIOV_VAL
(
RunLumi
(2,1),
RunLumi
(4,1))
34
iov3 =
RANGEIOV_VAL
(
RunLumi
(4,1),
RunLumi
(5,1))
35
assert
iov1.intersects(iov2)
36
assert
not
iov1.intersects(iov3)
37
assert
iov1.intersect(iov2) ==
RANGEIOV_VAL
(
RunLumi
(2,1),
RunLumi
(3,1))
38
assert
iov1.intersect(iov3)
is
None
39
assert
iov1.intersect_run(1) ==
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(1,0xffffffff))
40
assert
iov1.intersect_run(4)
is
None
41
42
43
def
test_length
():
44
iov1 =
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(3,1))
45
assert
iov1.length == 2 << 32
46
47
48
def
test_connected_to
():
49
CLS_VAL =
make_iov_type
(
'TESTIOV'
, [
'var'
])
50
iov1 = CLS_VAL(
RunLumi
(1,1),
RunLumi
(3,1), var=5)
51
iov2 = CLS_VAL(
RunLumi
(2,1),
RunLumi
(4,1), var=5)
52
iov3 = CLS_VAL(
RunLumi
(3,1),
RunLumi
(5,1), var=5)
53
iov4 = CLS_VAL(
RunLumi
(4,1),
RunLumi
(6,1), var=5)
54
iov5 = CLS_VAL(
RunLumi
(3,1),
RunLumi
(5,1), var=6)
55
assert
not
iov1.connected_to(iov2)
# false when overlapping
56
assert
not
iov1.connected_to(iov4)
# false when a gap
57
assert
not
iov1.connected_to(iov5)
# false when connected by contents different
58
assert
iov1.connected_to(iov3)
# this one yes
59
assert
iov1.merge(iov3) == CLS_VAL(
RunLumi
(1,1),
RunLumi
(5,1), var=5)
60
61
62
def
test_is_time_based
():
63
assert
RANGEIOV_VAL
(TimestampType.from_string(
'01/01/2020'
),
64
TimestampType.from_string(
'02/01/2020'
)).is_time_based
65
assert
not
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(3,1)).is_time_based
66
67
68
def
test_trimming
():
69
iov =
RANGEIOV_VAL
(
RunLumi
(1,0),
RunLumi
(1, 0xffffffff))
70
assert
iov.trimmed ==
RANGEIOV_VAL
(
RunLumi
(1,1),
RunLumi
(1, 0xffffffff))
71
72
73
if
__name__ ==
'__main__'
:
74
test_empty_is_boolean_false
()
75
test_runs
()
76
test_contains_point
()
77
test_intersect
()
78
test_length
()
79
test_connected_to
()
80
test_is_time_based
()
81
test_trimming
()
test_iovtype.test_runs
def test_runs()
Definition:
test_iovtype.py:19
test_iovtype.test_length
def test_length()
Definition:
test_iovtype.py:43
test_iovtype.test_connected_to
def test_connected_to()
Definition:
test_iovtype.py:48
python.sugar.iovtype.RANGEIOV_VAL
def RANGEIOV_VAL()
Definition:
iovtype.py:153
python.sugar.runlumi.RunLumi
RunLumi
Definition:
runlumi.py:131
test_iovtype.test_contains_point
def test_contains_point()
Definition:
test_iovtype.py:25
histSizes.list
def list(name, path='/')
Definition:
histSizes.py:38
test_iovtype.test_is_time_based
def test_is_time_based()
Definition:
test_iovtype.py:62
test_iovtype.test_empty_is_boolean_false
def test_empty_is_boolean_false()
Definition:
test_iovtype.py:10
python.sugar.iovtype.make_iov_type
def make_iov_type(name, variables, bases=(IOVType,), _memoized={})
Definition:
iovtype.py:114
test_iovtype.test_trimming
def test_trimming()
Definition:
test_iovtype.py:68
test_iovtype.test_intersect
def test_intersect()
Definition:
test_iovtype.py:31
Generated on Thu Jul 4 2024 21:28:15 for ATLAS Offline Software by
1.8.18