Skip to content

Commit

Permalink
Merge pull request #159 from ubermag/explicit_time_function
Browse files Browse the repository at this point in the history
enforce float
  • Loading branch information
samjrholt committed Aug 9, 2024
2 parents 6aa977c + 43c9ed4 commit 9f14f5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions oommfc/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ def _time_dependence(term, **kwargs):
"used with time driver."
) from None
ts = np.arange(0, tmax + term.dt, term.dt)
try: # vector output from term.func
tlist = [list(term.func(t)) for t in ts]
if isinstance(term.func(ts[0]), (list, tuple, np.ndarray)):
tlist = [[float(x) for x in term.func(t)] for t in ts]
dtlist = (np.gradient(tlist)[0] / term.dt).tolist()
except TypeError: # scalar output from term.func
tlist = [term.func(t) for t in ts]
else: # scalar output from term.func
tlist = [float(term.func(t)) for t in ts]
dtlist = list(np.gradient(tlist) / term.dt)
term.tlist = tlist
term.dtlist = dtlist
Expand Down

0 comments on commit 9f14f5e

Please sign in to comment.