From 8824a70a084bac62f00dc6f2865fea378559eb3f Mon Sep 17 00:00:00 2001
From: Rahil Doshi <rahil.doshi@fau.de>
Date: Wed, 20 Nov 2024 16:27:08 +0100
Subject: [PATCH] Add tests for models.py in test_models.py

---
 src/pymatlib/core/data_handler.py  |  51 ---------
 src/pymatlib/core/interpolators.py |  54 ---------
 src/pymatlib/core/models.py        | 140 -----------------------
 tests/create_test_files.py         | 142 -----------------------
 tests/test_models.py               | 177 +++++++++++++++++++++++++++++
 tests/tests.py                     |  14 +--
 6 files changed, 184 insertions(+), 394 deletions(-)
 delete mode 100644 tests/create_test_files.py
 create mode 100644 tests/test_models.py

diff --git a/src/pymatlib/core/data_handler.py b/src/pymatlib/core/data_handler.py
index e683028..23ad6bd 100644
--- a/src/pymatlib/core/data_handler.py
+++ b/src/pymatlib/core/data_handler.py
@@ -123,54 +123,3 @@ def check_equidistant(temp: np.ndarray, tolerance: float = 1.0e-3) -> Union[floa
             return float(unique_diffs[0])
 
     return False
-
-def run_tests() -> None:
-    """
-    Runs predefined tests to validate data reading and processing functions.
-    """
-    test_cases = [
-        {"name": "Normal Case", "file_path": "test_files/test_data_normal.txt"},
-        {"name": "Normal Case 1", "file_path": "test_files/test_data_normal1.txt"},
-        {"name": "Case with Variable Spacing", "file_path": "test_files/test_data_variable_spacing.txt"},
-        {"name": "Case with Sparse Data", "file_path": "test_files/test_data_sparse.txt"},
-        {"name": "Case with Missing Values", "file_path": "test_files/test_data_missing_values.txt"},
-        {"name": "Case with Descending Data", "file_path": "test_files/test_data_descending.txt"},
-        {"name": "Case with Duplicates", "file_path": "test_files/test_data_duplicates.txt"},
-        {"name": "Empty File", "file_path": "test_files/test_data_empty.txt"},
-        {"name": "File with Only Header", "file_path": "test_files/test_data_header.txt"},
-        {"name": "Invalid Data Entries", "file_path": "test_files/test_data_invalid_data.txt"},
-        {"name": "Mismatched Columns", "file_path": "test_files/test_data_mismatched_columns.txt"},
-        {"name": "Missing Data Entries", "file_path": "test_files/test_data_missing_data.txt"},
-        {"name": "Ascending density_temperature values", "file_path": "test_files/test_data_density_temperature_ascending.txt"},
-        {"name": "Descending density_temperature values", "file_path": "test_files/test_data_density_temperature_descending.txt"}
-    ]
-
-    for case in test_cases:
-        print(f"Running test: {case['name']}")
-
-        # Read cleaned data
-        cleaned_temp, cleaned_prop = read_data(case['file_path'], header=case.get("header", True))
-
-        if cleaned_temp.size == 0 or cleaned_prop.size == 0:
-            print(f"Skipping test: {case['name']} due to data read error.")
-            continue
-
-        print(f"Cleaned Temperatures: {cleaned_temp}")
-
-        # Convert temperatures to Kelvin
-        temp_kelvin = celsius_to_kelvin(cleaned_temp)
-        print(f"Converted Temperatures to Kelvin: {temp_kelvin}")
-
-        # Check if temperatures are equidistant
-        dtemp = check_equidistant(temp_kelvin)
-        if not dtemp:
-            print("Temperatures are not equidistant")
-        else:
-            print(f"Temperatures are equidistant with increment {dtemp}")
-
-        # Print results
-        print_results(case['file_path'], cleaned_temp, cleaned_prop)
-
-
-if __name__ == "__main__":
-    run_tests()
diff --git a/src/pymatlib/core/interpolators.py b/src/pymatlib/core/interpolators.py
index 077d628..a5094ee 100644
--- a/src/pymatlib/core/interpolators.py
+++ b/src/pymatlib/core/interpolators.py
@@ -187,57 +187,3 @@ def interpolate_property(
         print('interpolate_equidistant')
         return interpolate_equidistant(
             T, float(temp_array[0]), incr, prop_array)
-
-
-if __name__ == '__main__':
-    # Example usage and consistency tests for the interpolation functions
-    Temp = sp.Symbol('Temp')
-    density_temp_array1 = np.flip(np.asarray([600.0, 500.0, 400.0, 300.0, 200.0]))
-    density_v_array1 = np.flip(np.asarray([10.0, 20.0, 30.0, 40.0, 50.0]))
-    density_temp_array2 = [1878.0, 1884.2, 1894.7, 1905.3, 1915.8, 1926.3, 1928.0]
-    density_v_array2 = [4236.3, 4234.9, 4233.6, 4232.3, 4230.9, 4229.7, 4227.0]
-    Temp_base = 200.0
-    Temp_incr = 100.0
-
-    # Interpolation Lookup Tests
-    print("Interpolate Lookup Tests:")
-    symbolic_result = interpolate_lookup(Temp, density_temp_array1, density_v_array1)
-    print("Symbolic interpolation result with interpolate_lookup (arrays):", symbolic_result.expr)
-    symbolic_result_list = interpolate_lookup(Temp, density_temp_array2, density_v_array2)
-    print("Symbolic interpolation result with interpolate_lookup (lists):", symbolic_result_list.expr)
-    numeric_result = interpolate_lookup(1894.7, density_temp_array2, density_v_array2)
-    print("Numeric interpolation result with interpolate_lookup (arrays):", numeric_result.expr)
-    numeric_result_list = interpolate_lookup(1900.2, [200.0, 300.0, 400.0, 500.0, 600.0], [50.0, 40.0, 30.0, 20.0, 10.0])
-    print("Numeric interpolation result with interpolate_lookup (lists):", numeric_result_list.expr)
-
-    # Interpolation Equidistant Tests
-    print("\nInterpolate Equidistant Tests:")
-    symbolic_result_eq = interpolate_equidistant(Temp, Temp_base, Temp_incr, density_v_array1)
-    print("Symbolic interpolation result with interpolate_equidistant (numpy arrays):", symbolic_result_eq.expr)
-    symbolic_result_eq_list = interpolate_equidistant(Temp, Temp_base, Temp_incr, density_v_array2)
-    print("Symbolic interpolation result with interpolate_equidistant (lists):", symbolic_result_eq_list.expr)
-    numeric_result_eq = interpolate_equidistant(1900.2, Temp_base, Temp_incr, density_v_array1)
-    print("Numeric interpolation result with interpolate_equidistant (numpy arrays):", numeric_result_eq.expr)
-    numeric_result_eq_list = interpolate_equidistant(1900.2, Temp_base, Temp_incr, density_v_array2)
-    print("Numeric interpolation result with interpolate_equidistant (lists):", numeric_result_eq_list.expr)
-
-    # Consistency Test
-    print("\nConsistency Test between interpolate_lookup and interpolate_equidistant:")
-    test_temps = [150.0, 200.0, 350.0, 450.0, 550.0, 650.0]
-    for TT in test_temps:
-        lookup_result = interpolate_lookup(TT, np.flip(np.asarray([600.0, 500.0, 400.0, 300.0, 200.0])), np.asarray([10.0, 20.0, 30.0, 40.0, 50.0]))
-        equidistant_result = interpolate_equidistant(TT, 200.0, 100.0, np.asarray([10.0, 20.0, 30.0, 40.0, 50.0]))
-        print(f"Temperature {TT}:")
-        print(f"interpolate_lookup result: {lookup_result.expr}")
-        print(f"interpolate_equidistant result: {equidistant_result.expr}")
-        if isinstance(lookup_result.expr, (int, float)) and isinstance(equidistant_result.expr, (int, float)):
-            assert np.isclose(lookup_result.expr, equidistant_result.expr), f"Inconsistent results for T = {TT}"
-        else:
-            print(f"Skipping comparison for symbolic or non-numeric result at T = {TT}")
-
-    symbolic_lookup_result = interpolate_lookup(Temp, density_temp_array1, density_v_array1)
-    symbolic_equidistant_result = interpolate_equidistant(Temp, Temp_base, Temp_incr, density_v_array1)
-    print("\nSymbolic interpolation results for consistency check:")
-    print(f"interpolate_lookup (symbolic): {symbolic_lookup_result.expr}")
-    print(f"interpolate_equidistant (symbolic): {symbolic_equidistant_result.expr}")
-    print(f"interpolate_equidistant (symbolic): {symbolic_equidistant_result.assignments}")
diff --git a/src/pymatlib/core/models.py b/src/pymatlib/core/models.py
index 4e144fc..eb04608 100644
--- a/src/pymatlib/core/models.py
+++ b/src/pymatlib/core/models.py
@@ -207,143 +207,3 @@ def thermal_diffusivity_by_heat_conductivity(
         return MaterialProperty(_result, sub_assignments)
     except ZeroDivisionError:
         raise ValueError("Division by zero encountered in thermal diffusivity calculation")
-
-
-if __name__ == '__main__':
-    # Test 1: Single temperature value for density calculation
-    T_0 = 800.
-    T_1 = 1000.
-    tec = 1e-6
-    rho = 8000.
-    print(f"Test 1 - Single temperature value: {T_1}, Density: {density_by_thermal_expansion(T_1, T_0, rho, tec)}")
-    # Expected output: Density value at T_1 = 1000
-
-    # Test 2: Temperature array for density calculation with constant TEC
-    T_a = np.linspace(1000, 2000, 3)
-    tec_a = np.ones(T_a.shape) * tec
-    print("-----", type(wrapper(tec_a)))
-    print(f"Test 2a - Temperature array with constant TEC: {T_a}, Density: {density_by_thermal_expansion(T_a, T_0, rho, tec)}")
-    # Expected output: Array of densities for temperatures in T_a
-
-    # Test 3: Temperature array for density calculation with array TEC
-    print(f"Test 2b - Temperature array with array TEC: {T_a}, Density: {density_by_thermal_expansion(T_a, T_0, rho, tec)}")
-    # Expected output: Array of densities with temperature-dependent TEC
-
-    # Test 4: Thermal diffusivity calculation with scalar values
-    k = 30.
-    c_p = 600.
-    print(f"Test 3 - Thermal diffusivity with scalar values: {thermal_diffusivity_by_heat_conductivity(k, rho, c_p)}")
-    # Expected output: Scalar value of thermal diffusivity
-
-    # Test 5: Thermal diffusivity calculation with array values for heat conductivity
-    k_a = np.linspace(30, 40, 3)
-    print(f"Test 4a - Thermal diffusivity with array of heat conductivity: {thermal_diffusivity_by_heat_conductivity(k, rho, c_p)}")
-    # Expected output: Array of thermal diffusivity
-
-    # Test 6: Thermal diffusivity with density calculated by thermal expansion
-    calculated_densities = density_by_thermal_expansion(T_a, T_0, rho, tec)
-    print(f"Test 4b - Thermal diffusivity with calculated densities: {thermal_diffusivity_by_heat_conductivity(k, calculated_densities, c_p)}")
-    # Expected output: Array of thermal diffusivity considering temperature-dependent density
-
-    # Test 7: Symbolic computation for density with sympy Symbol temperature
-    T_symbolic = sp.Symbol('T')
-    print(f"Test 5 - Symbolic density computation: {density_by_thermal_expansion(T_symbolic, T_0, rho, tec)}")
-    # Expected output: Sympy expression for density as a function of temperature
-
-    # Test 8: Symbolic computation for thermal diffusivity
-    k_symbolic = sp.Symbol('k')
-    c_p_symbolic = sp.Symbol('c_p')
-    rho_symbolic = sp.Symbol('rho')
-    print(f"Test 6 - Symbolic thermal diffusivity computation: {thermal_diffusivity_by_heat_conductivity(k_symbolic, rho_symbolic, c_p_symbolic)}")
-
-    # New test case for mixed input types
-    print("\nTest 9: Mixed input types")
-
-    # For density_by_thermal_expansion
-    T_mixed = np.linspace(800, 1000, 3)  # numpy array
-    T_base = 293.15  # float
-    rho_base = 8000.0  # float
-    tec_symbolic = sp.Symbol('alpha')  # symbolic
-
-    try:
-        result_density = density_by_thermal_expansion(T_mixed, T_base, rho_base, tec_symbolic)
-        print(f"Density with mixed inputs: {result_density}")
-    except Exception as e:
-        print(f"Error in density calculation with mixed inputs: {str(e)}")
-
-    # For thermal_diffusivity_by_heat_conductivity
-    k_mixed = np.linspace(20, 30, 3)  # numpy array
-    rho_symbolic = sp.Symbol('rho')  # symbolic
-    cp_float = 500.0  # float
-
-    try:
-        result_diffusivity = thermal_diffusivity_by_heat_conductivity(k_mixed, rho_symbolic, cp_float)
-        print(f"Thermal diffusivity with mixed inputs: {result_diffusivity}")
-    except Exception as e:
-        print(f"Error in thermal diffusivity calculation with mixed inputs: {str(e)}")
-
-    # Test 11: Edge cases with zero and negative values
-    print("\nTest 11: Edge cases with zero and negative values")
-    try:
-        print(density_by_thermal_expansion(-273.15, T_0, rho, tec))  # Absolute zero
-    except ValueError as e:
-        print(f"Handled error for negative temperature: {e}")
-
-    try:
-        print(density_by_thermal_expansion(T_1, T_0, rho, -1e-6))  # Negative TEC
-    except ValueError as e:
-        print(f"Handled error for negative TEC: {e}")
-
-    # Test 12: Large arrays
-    print("\nTest 12: Large arrays")
-    large_T = np.linspace(1000, 2000, 1000)
-    large_k = np.linspace(30, 40, 10000)
-    try:
-        large_density = density_by_thermal_expansion(large_T, T_0, rho, tec)
-        print(f"Large density array: {large_density}")
-    except Exception as e:
-        print(f"Error with large density array: {e}")
-
-    try:
-        large_diffusivity = thermal_diffusivity_by_heat_conductivity(large_k, rho, c_p)
-        print(f"Large diffusivity array: {large_diffusivity}")
-    except Exception as e:
-        print(f"Error with large diffusivity array: {e}")
-
-    # Test 13: Complex numbers (if applicable)
-    print("\nTest 13: Complex numbers")
-    complex_T = sp.Symbol('T') + sp.I
-    try:
-        complex_density = density_by_thermal_expansion(complex_T, T_0, rho, tec)
-        print(f"Complex density: {complex_density}")
-    except Exception as e:
-        print(f"Error with complex density: {e}")
-
-    try:
-        complex_diffusivity = thermal_diffusivity_by_heat_conductivity(k_symbolic, rho_symbolic + sp.I, c_p_symbolic)
-        print(f"Complex diffusivity: {complex_diffusivity}")
-    except Exception as e:
-        print(f"Error with complex diffusivity: {e}")
-
-    # Additional test for division by zero
-    print("\nTest 14: Division by zero")
-    try:
-        zero_density = material_property_wrapper(0)
-        result = thermal_diffusivity_by_heat_conductivity(1.0, zero_density, 1.0)
-        print(f"Result with zero density: {result}")
-    except ValueError as e:
-        print(f"Handled error for zero density: {e}")
-
-    # Test for negative values
-    print("\nTest 15: Negative values")
-    try:
-        result = density_by_thermal_expansion(1000, 20, -1000, 1e-6)
-        print(f"Result with negative density: {result}")
-    except ValueError as e:
-        print(f"Handled error for negative density: {e}")
-
-    try:
-        result = thermal_diffusivity_by_heat_conductivity(-1.0, 1000, 500)
-        print(f"Result with negative heat conductivity: {result}")
-    except ValueError as e:
-        print(f"Handled error for negative heat conductivity: {e}")
\ No newline at end of file
diff --git a/tests/create_test_files.py b/tests/create_test_files.py
deleted file mode 100644
index 862ac18..0000000
--- a/tests/create_test_files.py
+++ /dev/null
@@ -1,142 +0,0 @@
-import os
-
-
-def create_test_files() -> None:
-    """
-    Creates a folder named 'test_files' and generates test files with predefined contents.
-    """
-    # Create the test_files directory if it doesn't exist
-    os.makedirs("test_files", exist_ok=True)
-
-    files_content = {
-        "test_files/test_data_normal.txt": """Temp    Density
-3405 58.05
-3300 57.0
-3250 56.5
-3100 55.0
-3000 54.0
-2905 53.05
-""",
-        "test_files/test_data_normal1.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3050 54.5
-3000 54.0
-2900 53.0
-2800 52.0
-""",
-        "test_files/test_data_variable_spacing.txt": """Temp    Density
-3400 58.0
-3250 56.5
-3150 55.5
-3050 54.5
-2950 53.5
-2850 52.5
-2750 51.5
-2650 50.5
-""",
-        "test_files/test_data_sparse.txt": """Temp    Density
-3400 58.0
-3000 54.0
-2600 50.0
-2200 46.0
-""",
-        "test_files/test_data_missing_values.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3000 NaN
-2900 53.0
-2800 52.1
-""",
-        "test_files/test_data_descending.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3000 54.0
-2900 53.0
-2800 52.1
-""",
-        "test_files/test_data_duplicates.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3050 54.5
-3000 54.0
-3000 53.5
-2900 53.0
-""",
-        "test_files/test_data_empty.txt": """
-""",
-        "test_files/test_data_header.txt": """Temp    Density
-
-""",
-        "test_files/test_data_invalid_data.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3000 Invalid
-2900 53.0
-2800 52.1
-""",
-        "test_files/test_data_mismatched_columns.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0 1
-3100 55.0
-3050 54.5 2 3
-3000 54.0
-3000 53.5
-2900 53.0 4
-""",
-        "test_files/test_data_missing_data.txt": """Temp    Density
-3400 58.0
-3300 57.0
-3200 56.0
-3100 55.0
-3050 
-3000 54.0
-3000 53.5
-2900 53
-""",
-        "test_files/test_data_density_temperature_ascending.txt": """Temp    Density
-1500.0	7.008098755
-1490.0	7.015835416
-1480.0	7.023544996
-1470.0	7.031227258
-1460.0	7.038881969
-1459.63	7.039161939
-1450.0	7.101066042
-1440.0	7.134387853
-1434.71	7.147271626
-1430.0	7.177458788
-1420.0	7.211193546
-1410.0	7.228319303
-1400.0	7.239681101
-""",
-        "test_files/test_data_density_temperature_descending.txt": """Temp    Density
-1500.0	7.008098755
-1490.0	7.015835416
-1480.0	7.023544996
-1470.0	7.031227258
-1460.0	7.038881969
-1459.63	7.039161939
-1450.0	7.101066042
-1440.0	7.134387853
-1434.71	7.147271626
-1430.0	7.177458788
-1420.0	7.211193546
-1410.0	7.228319303
-1400.0	7.239681101
-""",
-    }
-
-    for filename, content in files_content.items():
-        with open(filename, 'w') as file:
-            file.write(content)
diff --git a/tests/test_models.py b/tests/test_models.py
new file mode 100644
index 0000000..eeb4850
--- /dev/null
+++ b/tests/test_models.py
@@ -0,0 +1,177 @@
+import pytest
+import numpy as np
+import sympy as sp
+from pymatlib.core.models import (
+    validate_density_parameters,
+    validate_thermal_diffusivity_parameters,
+    wrapper,
+    material_property_wrapper,
+    density_by_thermal_expansion,
+    thermal_diffusivity_by_heat_conductivity
+)
+from pymatlib.core.typedefs import MaterialProperty
+
+def test_validate_density_parameters():
+    """Test density parameter validation."""
+    # Valid parameters
+    validate_density_parameters(300.0, 8000.0, 1e-6)
+
+    # Test temperature validation
+    with pytest.raises(ValueError, match="Temperature cannot be below absolute zero"):
+        validate_density_parameters(-274.0, 8000.0, 1e-6)
+
+    # Test density validation
+    with pytest.raises(ValueError, match="Base density must be positive"):
+        validate_density_parameters(300.0, -8000.0, 1e-6)
+
+    # Test thermal expansion coefficient validation
+    with pytest.raises(ValueError, match="Thermal expansion coefficient must be greater than -1"):
+        validate_density_parameters(300.0, 8000.0, -1.5)
+
+def test_validate_thermal_diffusivity_parameters():
+    """Test thermal diffusivity parameter validation."""
+    # Valid parameters
+    validate_thermal_diffusivity_parameters(30.0, 8000.0, 500.0)
+
+    # Test positive value validation
+    with pytest.raises(ValueError, match="heat_conductivity must be positive"):
+        validate_thermal_diffusivity_parameters(-30.0, 8000.0, 500.0)
+
+    with pytest.raises(ValueError, match="density must be positive"):
+        validate_thermal_diffusivity_parameters(30.0, -8000.0, 500.0)
+
+    with pytest.raises(ValueError, match="heat_capacity must be positive"):
+        validate_thermal_diffusivity_parameters(30.0, 8000.0, -500.0)
+
+def test_wrapper():
+    """Test wrapper function."""
+    # Test numeric values
+    assert isinstance(wrapper(1.0), sp.Float)
+    assert isinstance(wrapper(0.0), sp.Float)
+
+    # Test symbolic expressions
+    T = sp.Symbol('T')
+    assert wrapper(T) == T
+
+    # Test arrays
+    assert isinstance(wrapper([1.0, 2.0]), list)
+    assert all(isinstance(x, sp.Float) for x in wrapper([1.0, 2.0]))
+
+    # Test invalid input
+    with pytest.raises(ValueError):
+        wrapper("invalid")
+
+def test_material_property_wrapper():
+    """Test material property wrapper function."""
+    # Test numeric value
+    result = material_property_wrapper(1.0)
+    assert isinstance(result, MaterialProperty)
+
+    # Test symbolic expression
+    T = sp.Symbol('T')
+    result = material_property_wrapper(T)
+    assert isinstance(result, MaterialProperty)
+
+    # Test array
+    result = material_property_wrapper([1.0, 2.0])
+    assert isinstance(result, MaterialProperty)
+
+def test_density_by_thermal_expansion():
+    """Test density calculation by thermal expansion."""
+    # Test numeric calculation
+    result = density_by_thermal_expansion(1000.0, 293.15, 8000.0, 1e-6)
+    assert isinstance(result, MaterialProperty)
+
+    # Test symbolic calculation
+    T = sp.Symbol('T')
+    result = density_by_thermal_expansion(T, 293.15, 8000.0, 1e-6)
+    assert isinstance(result, MaterialProperty)
+
+    # Test error cases
+    with pytest.raises(ValueError):
+        density_by_thermal_expansion(-274.0, 293.15, 8000.0, 1e-6)
+
+def test_thermal_diffusivity_by_heat_conductivity():
+    """Test thermal diffusivity calculation."""
+    # Test numeric calculation
+    result = thermal_diffusivity_by_heat_conductivity(30.0, 8000.0, 500.0)
+    assert isinstance(result, MaterialProperty)
+
+    # Test symbolic calculation
+    k = sp.Symbol('k')
+    result = thermal_diffusivity_by_heat_conductivity(k, 8000.0, 500.0)
+    assert isinstance(result, MaterialProperty)
+
+    # Test error cases
+    with pytest.raises(ValueError):
+        thermal_diffusivity_by_heat_conductivity(-30.0, 8000.0, 500.0)
+
+def test_models():
+    """Test all model functions comprehensively."""
+    # Test wrapper function edge cases
+    def test_wrapper_edge_cases():
+        # Test very small numbers (close to tolerance)
+        assert wrapper(1e-11) == sp.Float(0.0)
+        # Test array with mixed types
+        with pytest.raises(ValueError):
+            wrapper([1.0, "invalid"])
+        # Test unsupported type
+        with pytest.raises(ValueError):
+            wrapper(complex(1, 1))
+
+    # Test material_property_wrapper validation
+    def test_material_property_wrapper_validation():
+        # Test with invalid input types
+        with pytest.raises(ValueError):
+            material_property_wrapper("invalid")
+        # Test with None
+        with pytest.raises(ValueError):
+            material_property_wrapper(None)
+
+    # Test density parameter validation
+    def test_density_validation():
+        # Test temperature validation at exactly absolute zero
+        with pytest.raises(ValueError):
+            validate_density_parameters(-273.15, 8000.0, 1e-6)
+        # Test array with mixed valid/invalid temperatures
+        with pytest.raises(ValueError):
+            validate_density_parameters(np.array([100.0, -274.0]), 8000.0, 1e-6)
+        # Test zero density
+        with pytest.raises(ValueError):
+            validate_density_parameters(300.0, 0.0, 1e-6)
+        # Test thermal expansion coefficient edge cases
+        with pytest.raises(ValueError):
+            validate_density_parameters(300.0, 8000.0, -1.0)
+
+    # Test thermal diffusivity parameter validation
+    def test_thermal_diffusivity_validation():
+        # Test zero values
+        with pytest.raises(ValueError):
+            validate_thermal_diffusivity_parameters(0.0, 8000.0, 500.0)
+        # Test incompatible types
+        with pytest.raises(TypeError):
+            validate_thermal_diffusivity_parameters(np.array([30.0]), 8000.0, 500.0)
+
+    # Test density calculation with various input combinations
+    def test_density_calculations():
+        # Test with MaterialProperty as thermal expansion coefficient
+        tec = material_property_wrapper(1e-6)
+        result = density_by_thermal_expansion(300.0, 293.15, 8000.0, tec)
+        assert isinstance(result, MaterialProperty)
+
+        # Test with array temperatures and MaterialProperty TEC
+        temps = np.linspace(300, 400, 5)
+        with pytest.raises(TypeError):
+            density_by_thermal_expansion(temps, 293.15, 8000.0, tec)
+
+    # Test thermal diffusivity calculations
+    def test_thermal_diffusivity_calculations():
+        # Test with all MaterialProperty inputs
+        k = material_property_wrapper(30.0)
+        rho = material_property_wrapper(8000.0)
+        cp = material_property_wrapper(500.0)
+        result = thermal_diffusivity_by_heat_conductivity(k, rho, cp)
+        assert isinstance(result, MaterialProperty)
+
+        # Test assignment combination
+        assert hasattr(result, 'assignments')
diff --git a/tests/tests.py b/tests/tests.py
index b992286..75c5aa3 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -8,7 +8,7 @@ from src.pymatlib.data.alloys.SS316L.SS316L import create_SS316L
 from src.pymatlib.core.assignment_converter import type_mapping, assignment_converter
 from src.pymatlib.data.element_data import Fe, Cr, Mn, Ni
 from src.pymatlib.core.interpolators import interpolate_property, interpolate_lookup, interpolate_equidistant, \
-    test_equidistant
+    check_equidistant
 from src.pymatlib.core.models import density_by_thermal_expansion, thermal_diffusivity_by_heat_conductivity
 from src.pymatlib.core.typedefs import MaterialProperty, Assignment
 
@@ -17,16 +17,16 @@ def test_alloy_creation():
     # Test creating an alloy with valid elemental composition and phase transition temperatures
     alloy = Alloy(elements=[Fe, Cr, Mn, Ni], composition=[0.7, 0.2, 0.05, 0.05], temperature_solidus=1700, temperature_liquidus=1800)
     assert np.allclose(alloy.composition, [0.7, 0.2, 0.05, 0.05])
-    assert alloy.temperature_solidus == 1700
-    assert alloy.temperature_liquidus == 1800
+    assert alloy.temperature_solidus == 1700.
+    assert alloy.temperature_liquidus == 1800.
 
     # Test creating an alloy with invalid elemental composition
     with pytest.raises(ValueError):
-        Alloy(elements=[Fe, Cr], composition=[0.6, 0.5], temperature_solidus=1700, temperature_liquidus=1800)
+        Alloy(elements=[Fe, Cr], composition=[0.6, 0.5], temperature_solidus=1700., temperature_liquidus=1800.)
 
     # Test creating an alloy with invalid phase transition temperatures
     with pytest.raises(ValueError):
-        Alloy(elements=[Fe, Cr, Mn, Ni], composition=[0.7, 0.2, 0.05, 0.05], temperature_solidus=1900, temperature_liquidus=1800)
+        Alloy(elements=[Fe, Cr, Mn, Ni], composition=[0.7, 0.2, 0.05, 0.05], temperature_solidus=1900., temperature_liquidus=1800.)
 
 def test_create_SS316L():
     # Test creating SS316L alloy with a float temperature input
@@ -208,11 +208,11 @@ def temp():
 
 def test_test_equidistant(temp):
     # Test with equidistant temperature array
-    assert test_equidistant(temp) == 100.0
+    assert check_equidistant(temp) == 100.0
 
     # Test with non-equidistant temperature array
     temp_non_equidistant = np.array([100.0, 150.0, 300.0, 450.0, 500.0])
-    assert test_equidistant(temp_non_equidistant) == 0.0
+    assert check_equidistant(temp_non_equidistant) == 0.0
 
 def test_density_by_thermal_expansion():
     # Test calculating density with float temperature and thermal expansion coefficient inputs
-- 
GitLab