Skip to content

Commit

Permalink
fixed bug in mock netCDF4
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Nov 26, 2024
1 parent cc750c6 commit 6fedebb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/sisl/io/siesta/tests/test_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
@pytest.mark.parametrize("read_dtype", [np.float64, np.complex128])
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex128])
def test_non_colinear(sisl_tmp, sort, matrix, ext, dtype, read_dtype):
if ext == "nc":
pytest.importorskip("netCDF4")

M = getattr(sisl, matrix)(sisl.geom.graphene(), spin=sisl.Spin("NC"), dtype=dtype)
if np.issubdtype(dtype, np.complexfloating):
onsite = [0.1 + 0j, 0.2 + 0j, 0.3 + 0.4j]
Expand Down Expand Up @@ -73,6 +76,9 @@ def test_non_colinear(sisl_tmp, sort, matrix, ext, dtype, read_dtype):
@pytest.mark.parametrize("read_dtype", [np.float64, np.complex128])
@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex128])
def test_spin_orbit(sisl_tmp, sort, matrix, ext, dtype, read_dtype):
if ext == "nc":
pytest.importorskip("netCDF4")

M = getattr(sisl, matrix)(sisl.geom.graphene(), spin=sisl.Spin("SO"), dtype=dtype)
if np.issubdtype(dtype, np.complexfloating):
onsite = [0.1 + 0j, 0.2 + 0j, 0.3 + 0.4j, 0.3 - 0.4j]
Expand Down
2 changes: 1 addition & 1 deletion src/sisl/io/sile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ def __getattr__(self, attr):

exe = Path(sys.executable).name
msg = f"Could not import netCDF4. Please install it using '{exe} -m pip install netCDF4'"
raise SileError(msg) from e
raise SileError(msg)

netCDF4 = _mock_netCDF4()

Expand Down

0 comments on commit 6fedebb

Please sign in to comment.