Skip to content

Conversation

@megha-darda
Copy link

@megha-darda megha-darda commented Jan 16, 2026

This pull request adds a complete testing setup for the 2D diffusion solver.

What was added:

  • Assertions in the solver to enforce float input types for domain and physical parameters
  • Unit tests for below methods in SolveDiffusion2D:
    • initialize_domain
    • initialize_physical_parameters
    • set_initial_condition
  • Integration tests to verify that multiple methods work correctly together:
    • test_initialize_physical_parameters
    • test_set_initial_condition
  • Test coverage report generated using coverage
  • Tox configuration to automate running unit tests, integration tests, and coverage in isolated environments

Checks:
I tested if the test cases failed if I introduced breaking changes:

  1. When i changed self.w = w to self.w = h in initialize_domain,
    test_initialize_domain unit test and both the integration tests failed as expected
  FAILED tests/integration/test_diffusion2d.py::test_initialize_physical_parameters - assert 7.5 == 12.0
  FAILED tests/integration/test_diffusion2d.py::test_set_initial_condition - assert 5.0 == 10.0
  FAILED tests/unit/test_diffusion2d_functions.py::test_initialize_domain - assert 7.5 == 12.0
  1. When i changed self.T_cold = T_cold to self.T_cold = T_hot in initialize_physical_parameters,
    test_initialize_physical_parameters unit test and again both the integration tests failed as expected
FAILED tests/integration/test_diffusion2d.py::test_initialize_physical_parameters - assert 900.0 == 250.0
FAILED tests/integration/test_diffusion2d.py::test_set_initial_condition - assert 700.0 == 300.0
FAILED tests/unit/test_diffusion2d_functions.py::test_initialize_physical_parameters - assert 900.0 == 250.0
  1. When i changed if p2 < r2 to if p2 > r2 in set_initial_condition,
    test_set_initial_condition unit test and only the test_set_initial_condition integration test failed as expected
FAILED tests/integration/test_diffusion2d.py::test_set_initial_condition - assert False
FAILED tests/unit/test_diffusion2d_functions.py::test_set_initial_condition - assert False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant