import os
import numpy as np
import pytest
import las_rs
test_dir = os.path.dirname(__file__)
def fixture(*parts):
return os.path.join(test_dir, "fixtures", *parts)
_LAS_SRC = """\
~VERSION INFORMATION
VERS. 2.0 : LAS VERSION 2.0
WRAP. NO : ONE LINE PER DEPTH STEP
~WELL INFORMATION
STRT.M 3000.0 : START DEPTH
STOP.M 3003.0 : STOP DEPTH
STEP.M 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. RIDGELINE PETROLEUM : COMPANY
WELL. MESA-ALTA-1 #5 : WELL NAME
~CURVE INFORMATION
DEPT .M : MEASURED DEPTH
GR .GAPI : GAMMA RAY
CBP1 .US : CHANNEL BOND PEAK 1
CBP2 .US : CHANNEL BOND PEAK 2
CBP3 .US : CHANNEL BOND PEAK 3
CBP4 .US : CHANNEL BOND PEAK 4
CBP10.US : CHANNEL BOND PEAK 10
~ASCII LOG DATA
3000.0 45.11 120.1 130.2 140.3 150.4 200.10
3001.0 58.77 121.5 131.6 141.7 151.8 201.50
3002.0 72.33 119.9 129.0 139.1 149.2 199.90
3003.0 50.22 122.3 132.4 142.5 152.6 202.30
"""
N_ROWS = 4
def _read():
return las_rs.read(_LAS_SRC)
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_by_stub():
las = _read()
result = las.stack_curves("CBP")
assert isinstance(result, np.ndarray)
assert result.ndim == 2
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_by_stub_shape():
las = _read()
result = las.stack_curves("CBP")
assert result.shape == (N_ROWS, 5)
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_by_list():
las = _read()
result = las.stack_curves(["CBP2", "CBP4"])
assert result.shape == (N_ROWS, 2)
np.testing.assert_array_almost_equal(result[:, 0], las["CBP2"])
np.testing.assert_array_almost_equal(result[:, 1], las["CBP4"])
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_sorts_naturally():
las = _read()
result = las.stack_curves("CBP")
cbp10_data = las["CBP10"]
np.testing.assert_array_almost_equal(result[:, 4], cbp10_data)
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_no_sort():
las = _read()
result = las.stack_curves("CBP", sort_curves=False)
np.testing.assert_array_almost_equal(result[:, 0], las["CBP1"])
np.testing.assert_array_almost_equal(result[:, 4], las["CBP10"])
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_empty_raises():
las = _read()
with pytest.raises(ValueError):
las.stack_curves("")
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_empty_list_raises():
las = _read()
with pytest.raises(ValueError):
las.stack_curves([])
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_missing_raises():
las = _read()
with pytest.raises(KeyError):
las.stack_curves("NONEXIST")
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_ndarray_input():
las = _read()
names = np.array(["CBP1", "CBP2"])
result = las.stack_curves(names)
assert result.shape == (N_ROWS, 2)
np.testing.assert_array_almost_equal(result[:, 0], las["CBP1"])
np.testing.assert_array_almost_equal(result[:, 1], las["CBP2"])