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 1500.0 : START DEPTH
STOP.M 1503.0 : STOP DEPTH
STEP.M 1.0 : STEP VALUE
NULL. -999.25 : NULL VALUE
COMP. IRONCLAD RESOURCES LTD : COMPANY
WELL. HAMMERHEAD-4 #1 : WELL NAME
~CURVE INFORMATION
DEPT .M : MEASURED DEPTH
GR .GAPI : GAMMA RAY
CBP1 .US : CEMENT BOND PEAK 1
CBP2 .US : CEMENT BOND PEAK 2
CBP3 .US : CEMENT BOND PEAK 3
~ASCII LOG DATA
1500.0 34.55 210.1 220.2 230.3
1501.0 47.88 215.5 225.6 235.7
1502.0 61.22 209.9 219.0 229.1
1503.0 53.11 212.3 222.4 232.5
"""
N_ROWS = 4
def _read():
return las_rs.read(_LAS_SRC)
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_no_args_raises_typeerror():
las = _read()
with pytest.raises(TypeError):
las.stack_curves()
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_list_with_empty_element_raises():
las = _read()
with pytest.raises(ValueError):
las.stack_curves(["CBP1", ""])
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_missing_in_list_keyerror_message():
las = _read()
with pytest.raises(KeyError) as exc_info:
las.stack_curves(["CBP1", "BOGUS"])
assert "BOGUS" in str(exc_info.value)
@pytest.mark.xfail(reason="not yet implemented")
def test_stack_single_match():
las = _read()
result = las.stack_curves("GR")
assert isinstance(result, np.ndarray)
assert result.ndim == 2
assert result.shape == (N_ROWS, 1)
np.testing.assert_array_almost_equal(result[:, 0], las["GR"])