Skip to content

Commit

Permalink
Conflicts merged
Browse files Browse the repository at this point in the history
  • Loading branch information
EleniSmyrniou committed Jan 13, 2025
2 parents 4ee41db + 35c59e3 commit db77340
Show file tree
Hide file tree
Showing 9 changed files with 2,325 additions and 1,455 deletions.
2,986 changes: 1,536 additions & 1,450 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pandas = "^2.1.3"
tqdm = "^4.66.1"
scipy = "^1.11.3"
lxml = "^4.9.3"
numpy = "^1.26.2"
numpy = "^1.26.2 || ^2.0.0"
matplotlib = "^3.8.1"
pyshp = "^2.3.1"
more-itertools = "^10.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,34 @@ def test_against_bro_results(self):
bro_test_file = TestUtils.get_local_test_data_dir(
Path("cpt", "bro_xml", "CPT000000003688_IMBRO_A.xml")
)
bro_test_file_new_version = TestUtils.get_local_test_data_dir(
Path("cpt", "bro_xml", "CPT000000003688_IMBRO_A_new_version.xml")
)
assert gef_test_file.is_file()
assert bro_test_file.is_file()
assert bro_test_file_new_version.is_file()
# initialise models
gef_cpt = GefCpt()
bro_cpt = BroXmlCpt()
bro_cpt_new_version = BroXmlCpt()
# test initial expectations
assert gef_cpt
assert bro_cpt
# read gef file
gef_cpt.read(filepath=gef_test_file)
bro_cpt.read(filepath=bro_test_file)
bro_cpt_new_version.read(filepath=bro_test_file_new_version)
# do pre-processing
gef_cpt.pre_process_data()
bro_cpt.pre_process_data()
bro_cpt_new_version.pre_process_data()
# initialise interpretation model
robertson = RobertsonCptInterpretation()
robertson.unitweightmethod = UnitWeightMethod.ROBERTSON
# interpet the results
gef_cpt.interpret_cpt(robertson)
bro_cpt.interpret_cpt(robertson)
bro_cpt_new_version.interpret_cpt(robertson)

values_to_test = [
"friction_nbr",
Expand Down Expand Up @@ -94,22 +102,32 @@ def test_against_bro_results(self):
"damping",
]

assert bro_cpt.name == gef_cpt.name
assert bro_cpt.coordinates == gef_cpt.coordinates
assert bro_cpt.pwp == gef_cpt.pwp
assert bro_cpt.lithology == gef_cpt.lithology
assert bro_cpt.name == gef_cpt.name == bro_cpt_new_version.name
assert (
bro_cpt.coordinates == gef_cpt.coordinates == bro_cpt_new_version.coordinates
)
assert bro_cpt.pwp == gef_cpt.pwp == bro_cpt_new_version.pwp
assert bro_cpt.lithology == gef_cpt.lithology == bro_cpt_new_version.lithology
assert np.allclose(bro_cpt.litho_points, gef_cpt.litho_points, atol=1e-2)
assert np.allclose(
bro_cpt_new_version.litho_points, gef_cpt.litho_points, atol=1e-2
)
for value in ["litho_NEN", "E_NEN", "cohesion_NEN", "fr_angle_NEN"]:
for i in range(len(gef_cpt.litho_NEN)):
assert set(getattr(bro_cpt, value)[i].split("/")) == set(
getattr(gef_cpt, value)[i].split("/")
)
assert set(getattr(bro_cpt_new_version, value)[i].split("/")) == set(
getattr(gef_cpt, value)[i].split("/")
)

for value in values_to_test:
print(value)
test = getattr(gef_cpt, value)
expected_data = getattr(bro_cpt, value)
expected_data_new_version = getattr(bro_cpt_new_version, value)
assert np.allclose(expected_data, test, atol=1e-2)
assert np.allclose(expected_data_new_version, test, atol=1e-2)


class TestInterpreter:
Expand Down
137 changes: 137 additions & 0 deletions tests/test_files/cpt/bro_xml/CPT000000003688_IMBRO_A_new_version.xml

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions tests/test_files/cpt/bro_xml/CPT000000063044_IMBRO_A_new_version.xml

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions tests/test_files/cpt/bro_xml/CPT000000063045_IMBRO_A_new_version.xml

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions tests/test_files/cpt/bro_xml/CPT000000064413_IMBRO_A_new_version.xml

Large diffs are not rendered by default.

163 changes: 163 additions & 0 deletions tests/test_files/cpt/bro_xml/CPT000000065880_IMBRO_A_new_version.xml

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions tests/test_geolib_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,32 @@ def test_that_values_gef_and_cpt_are_of_the_same_type(self):
Path("cpt", "bro_xml", "CPT000000003688_IMBRO_A.xml")
)
assert test_file_bro.is_file()
test_file_bro_new_version = TestUtils.get_local_test_data_dir(
Path("cpt", "bro_xml", "CPT000000003688_IMBRO_A_new_version.xml")
)
# initialise models
cpt_gef = GefCpt()
cpt_bro_xml = BroXmlCpt()
cpt_bro_xml_new_version = BroXmlCpt()
# test initial expectations
assert cpt_gef
assert cpt_bro_xml
# read gef file
cpt_gef.read(filepath=test_file_gef)
# read bro file
cpt_bro_xml.read(filepath=test_file_bro)
# read bro file new version
cpt_bro_xml_new_version.read(filepath=test_file_bro_new_version)

cpt_bro_xml = dict(cpt_bro_xml)
cpt_gef = dict(cpt_gef)
cpt_bro_xml_new_version = dict(cpt_bro_xml_new_version)
for key, value in cpt_bro_xml.items():
if key not in ["predrilled_z", "undefined_depth", "water_measurement_type"]:
assert type(cpt_bro_xml.get(key, None)) == type(cpt_gef.get(key, None))
assert type(cpt_bro_xml_new_version.get(key, None)) == type(
cpt_gef.get(key, None)
)

@pytest.mark.systemtest
def test_has_points_with_error(self):
Expand Down Expand Up @@ -214,9 +224,15 @@ def test_reading_bro(self):
bro_file = TestUtils.get_local_test_data_dir(
"cpt/bro_xml/CPT000000003688_IMBRO_A.xml"
)
bro_file_new_version = TestUtils.get_local_test_data_dir(
"cpt/bro_xml/CPT000000003688_IMBRO_A_new_version.xml"
)
assert bro_file.is_file()
assert bro_file_new_version.is_file()
cpt = BroXmlCpt()
cpt.read(bro_file)
cpt_new_version = BroXmlCpt()
cpt_new_version.read(bro_file_new_version)

test_coord = [91931.000, 438294.000]
test_depth = np.arange(0.0, 24.58, 0.02)
Expand Down Expand Up @@ -267,6 +283,24 @@ def test_reading_bro(self):
np.testing.assert_array_equal(
test_friction_nbr_last, cpt.friction_nbr[-10 : len(cpt.friction) - 5]
)
# do the same for the new version
np.testing.assert_array_equal("CPT000000003688", cpt_new_version.name)
np.testing.assert_array_equal(test_coord, cpt_new_version.coordinates)
np.testing.assert_array_almost_equal(test_depth, cpt_new_version.depth)
np.testing.assert_array_equal(test_tip_first, cpt_new_version.tip[0:10])
np.testing.assert_array_equal(test_tip_last, cpt_new_version.tip[-10:])
np.testing.assert_array_equal(test_friction_first, cpt_new_version.friction[6:13])
np.testing.assert_array_equal(
test_friction_last,
cpt_new_version.friction[-10 : len(cpt_new_version.friction) - 5],
)
np.testing.assert_array_equal(
test_friction_nbr_first, cpt_new_version.friction_nbr[7:10]
)
np.testing.assert_array_equal(
test_friction_nbr_last,
cpt_new_version.friction_nbr[-10 : len(cpt_new_version.friction) - 5],
)

# System Test for geolib_plus_read_GEF
@pytest.mark.systemtest
Expand Down Expand Up @@ -349,10 +383,17 @@ def test_pre_process_bro_data(self):
"cpt/bro_xml/CPT000000064413_IMBRO_A.xml"
)
assert test_file.is_file()
test_file_new_version = TestUtils.get_local_test_data_dir(
"cpt/bro_xml/CPT000000064413_IMBRO_A_new_version.xml"
)
assert test_file_new_version.is_file()

cpt = BroXmlCpt()
cpt.read(test_file)
cpt.pore_pressure_u2 = np.array(cpt.depth * 10)
cpt_new_version = BroXmlCpt()
cpt_new_version.read(test_file_new_version)
cpt_new_version.pore_pressure_u2 = np.array(cpt_new_version.depth * 10)

# check cpt before preprocess
assert cpt.depth.ndim == 1
Expand All @@ -371,6 +412,18 @@ def test_pre_process_bro_data(self):
)
np.testing.assert_array_almost_equal(cpt.depth[1:100], expected_depth[0:99])
np.testing.assert_array_almost_equal(cpt.water, cpt.pore_pressure_u2)
# do the same for the new version
cpt_new_version.pre_process_data()
np.testing.assert_array_almost_equal(
cpt_new_version.depth_to_reference,
cpt_new_version.local_reference_level - cpt_new_version.depth,
)
np.testing.assert_array_almost_equal(
cpt_new_version.depth[1:100], expected_depth[0:99]
)
np.testing.assert_array_almost_equal(
cpt_new_version.water, cpt_new_version.pore_pressure_u2
)

def test_pre_process_bro_data_without_friction_nbr(self):
"""
Expand Down

0 comments on commit db77340

Please sign in to comment.