Skip to content

Commit

Permalink
Merge pull request #63 from uit-cosmo/fix_typeerror
Browse files Browse the repository at this point in the history
Fix t#62
  • Loading branch information
Sosnowsky authored May 27, 2023
2 parents 56803b3 + 5bad688 commit e6ef74b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blobmodel/blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _single_blob(

def _drain(self, t: NDArray) -> NDArray:
if isinstance(self.t_drain, (int, float)):
return np.exp(-(t - self.t_init) / self.t_drain)
return np.exp(-(t - self.t_init) / float(self.t_drain))
return np.exp(-(t - self.t_init) / self.t_drain[np.newaxis, :, np.newaxis])

def _propagation_direction_shape(
Expand Down
30 changes: 30 additions & 0 deletions tests/test_drain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from blobmodel import Blob, BlobShapeImpl
import numpy as np


def test_high_t_drain():
blob_sp = Blob(
blob_id=0,
blob_shape=BlobShapeImpl("gauss"),
amplitude=1,
width_prop=1,
width_perp=1,
velocity_x=1,
velocity_y=1,
pos_x=0,
pos_y=6,
t_init=0,
t_drain=10**100,
)

x = 0
y = 0
times = np.arange(1, 5, 0.01)

mesh_x, mesh_y, mesh_t = np.meshgrid(x, y, times)
blob_values = blob_sp.discretize_blob(
x=mesh_x, y=mesh_y, t=mesh_t, periodic_y=False, Ly=10
)


test_high_t_drain()

0 comments on commit e6ef74b

Please sign in to comment.