-
Notifications
You must be signed in to change notification settings - Fork 153
/
test_null_policy.py
113 lines (83 loc) · 3.82 KB
/
test_null_policy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import fnmatch
import numpy
import pytest
from lasio import read
from lasio import exceptions
test_dir = os.path.dirname(__file__)
egfn = lambda fn: os.path.join(os.path.dirname(__file__), "examples", fn)
stegfn = lambda vers, fn: os.path.join(
os.path.dirname(__file__), "examples", vers, fn)
def test_null_policy_NULL_default(): # should read as NaN
las = read(egfn("null_policy_-999.25.las"))
assert numpy.isnan(las['DT'][0])
def test_null_policy_NULL_strict(): # should read as NaN
las = read(egfn("null_policy_-999.25.las"), null_policy='strict')
assert numpy.isnan(las['DT'][0])
def test_null_policy_NULL_none():
las = read(egfn("null_policy_-999.25.las"), null_policy='none')
assert las['DT'][0] == -999.25
def test_null_policy_9999_none():
las = read(egfn("null_policy_9999.las"), null_policy='none')
assert las['DT'][1] == 9999
def test_null_policy_9999_strict():
las = read(egfn("null_policy_9999.las"), null_policy='strict')
assert las['DT'][1] == 9999
def test_null_policy_9999_common():
las = read(egfn("null_policy_9999.las"), null_policy='common')
assert las['DT'][1] == 9999
def test_null_policy_9999_aggressive():
las = read(egfn("null_policy_9999.las"), null_policy='aggressive')
assert numpy.isnan(las['DT'][1])
def test_null_policy_9999_all():
las = read(egfn("null_policy_9999.las"), null_policy='all')
assert numpy.isnan(las['DT'][1])
def test_null_policy_custom_1_caught_9998():
las = read(egfn("null_policy_9999.las"), null_policy=[9998, 'NULL'])
assert numpy.isnan(las['DT'][0])
def test_null_policy_custom_1_caught_NULL():
las = read(egfn("null_policy_9999.las"), null_policy=[9998, 'NULL'])
assert numpy.isnan(las['SFLA'][2])
def test_null_policy_custom_2():
las = read(egfn("null_policy_9999.las"), null_policy=[9998, ])
assert numpy.isnan(las['DT'][0])
assert las['SFLA'][2] == -999.25
def test_null_policy_ERR_strict():
with pytest.raises(exceptions.LASDataError):
las = read(egfn("null_policy_ERR.las"), null_policy='strict')
def test_null_policy_ERR_custom():
las = read(egfn("null_policy_ERR.las"), null_policy=[('ERR', ' NaN '), ])
assert numpy.isnan(las['RHOB'][2])
def test_null_policy_text_all_subs_ERR():
las = read(egfn("null_policy_ERR.las"), null_policy='all')
assert numpy.isnan(las['RHOB'][2])
def test_null_policy_text_all_keeps_data():
las = read(egfn("null_policy_ERR.las"), null_policy='all')
assert las['ILD'][2] == 105.6
def test_null_policy_text_all_subs_null():
las = read(egfn("null_policy_(null).las"), null_policy='aggressive')
assert numpy.isnan(las['RHOB'][2])
def test_null_policy_text_dashes_1():
las = read(egfn("null_policy_dashes.las"), null_policy=['-', ])
assert numpy.isnan(las['RHOB'][0])
def test_null_policy_text_dashes_2():
las = read(egfn("null_policy_dashes.las"), null_policy=['-', ])
assert numpy.isnan(las['RHOB'][2])
def test_null_policy_text_dashes_3():
las = read(egfn("null_policy_dashes.las"), null_policy=['-', ])
assert las['RHOB'][1] == -2550
def test_null_policy_runon_replaced_1():
las = read(egfn("null_policy_runon.las"), read_policy='default')
assert numpy.isnan(las['C04'][1])
def test_null_policy_runon_replaced_2():
las = read(egfn("null_policy_runon.las"), read_policy='default')
assert numpy.isnan(las['C05'][1])
def test_null_policy_runon_ok_1():
las = read(egfn("null_policy_runon.las"), read_policy='default')
assert las['C04'][2] == 7.33
def test_null_policy_runon_ok_2():
las = read(egfn("null_policy_runon.las"), read_policy='default')
assert las['C05'][2] == -19508.961
def test_null_policy_ind():
las = read(egfn('null_policy_ind.las'))
assert las.curves.keys() == ['DEPT', 'GR', 'CN', 'CD']