Skip to content

Commit

Permalink
Add tests for Diffusion class
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpiper committed Sep 5, 2023
1 parent f8450af commit dd4cd41
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lessons/python/ivy-diffusion/tests/test_diffusion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Tests for the diffusion module."""
import numpy as np

from ivy_diffusion.diffusion import Diffusion

SHAPE = 10
SPACING = 1.0
DIFFUSIVITY = 1.0
ZMAX = 5.0


def test_defaults():
m = Diffusion()
assert type(m) == Diffusion
assert m.shape == SHAPE
assert m.spacing == SPACING
assert m.diffusivity == DIFFUSIVITY
assert m.time == 0.0
assert m.time_step > 0.0
assert type(m.concentration) == np.ndarray
assert len(m.concentration) == SHAPE


def test_update():
m = Diffusion()
m.concentration = np.zeros(SHAPE)
m.concentration[SHAPE//2] = ZMAX
m.update()
assert m.time > 0.0
assert m.concentration.max() < ZMAX
assert m.concentration.sum() == ZMAX

0 comments on commit dd4cd41

Please sign in to comment.