Skip to content

Commit

Permalink
Lazily load scipy.io in SimulationData.to_mat_file() to speed up …
Browse files Browse the repository at this point in the history
…overall module import time
  • Loading branch information
yaugenst-flex authored and momchil-flex committed Jul 9, 2024
1 parent 120ef72 commit f4b87ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tidy3d/components/data/sim_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import numpy as np
import pydantic.v1 as pd
import xarray as xr
from scipy.io import savemat

from ...exceptions import DataError, FileError, Tidy3dKeyError
from ...log import log
Expand Down Expand Up @@ -1041,6 +1040,8 @@ def to_mat_file(self, fname: str, **kwargs):
modified_sim_dict = replace_values(sim_dict, None, [])

try:
from scipy.io import savemat

savemat(fname, modified_sim_dict, **kwargs)
except Exception as e:
raise ValueError(
Expand Down

0 comments on commit f4b87ca

Please sign in to comment.