Completed
Push — master ( 2d79b0...39c744 )
by Kent
03:41
created

tests.test_data_array_slice()   A

Complexity

Conditions 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 3
rs 10
1
import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
2
3
import fnmatch
4
5
import numpy as np
6
import pytest
7
8
from lasio import read, las
9
10
test_dir = os.path.dirname(__file__)
11
12
egfn = lambda fn: os.path.join(os.path.dirname(__file__), "examples", fn)
13
stegfn = lambda vers, fn: os.path.join(
14
    os.path.dirname(__file__), "examples", vers, fn)
15
16
def test_keys_curve_mnemonics():
17
    l = read(egfn("sample.las"))
18
     # DEPT.M                      :  1  DEPTH
19
     # DT  .US/M               :  2  SONIC TRANSIT TIME
20
     # RHOB.K/M3                   :  3  BULK DENSITY
21
     # NPHI.V/V                    :  4   NEUTRON POROSITY
22
     # SFLU.OHMM                   :  5  RXO RESISTIVITY
23
     # SFLA.OHMM                   :  6  SHALLOW RESISTIVITY
24
     # ILM .OHMM                   :  7  MEDIUM RESISTIVITY
25
     # ILD .OHMM                   :  8  DEEP RESISTIVITY
26
    assert l.keys() == ['DEPT', 'DT', 'RHOB', 'NPHI', 'SFLU', 'SFLA', 'ILM', 'ILD']
27
28
def test_LASFile_getitem():
29
    l = read(egfn("sample.las"))
30
    assert np.all(l['DT'] == [123.45, 123.45, 123.45])
31
32
def test_LASFile_getitem_int():
33
    l = read(egfn("sample.las"))
34
    assert np.all(l[1] == [123.45, 123.45, 123.45])
35
36
def test_LASFile_getitem_int_negative():
37
    l = read(egfn("sample.las"))
38
    assert np.all(l[-2] == [110.2, 110.2, 110.2])
39
40
def test_data_array_slice():
41
    l = read(egfn("sample.las"))
42
    assert np.all(l[1] == l.data[:, 1])
43
44
def test_curves_attribute():
45
    l = read(egfn("sample.las"))
46
    assert isinstance(l.curves[1], las.CurveItem)
47
48
def test_get_curves_method():
49
    l = read(egfn("sample.las"))
50
    assert l.get_curve('DT') == l.curves[1]
51
52
53