Skip to content

Commit

Permalink
Fix compatibility issues with latest version of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed Jun 22, 2024
1 parent afe15b5 commit a33c5f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
hooks:
- id: remove-crlf
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.4.10
hooks:
- id: ruff-format
- id: ruff
Expand Down
8 changes: 4 additions & 4 deletions src/denspart/adapters/gpaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np
from ase.units import Bohr
from gpaw import restart
from gpaw.utilities import unpack2
from gpaw.utilities import unpack_density
from grid.atomgrid import AtomGrid
from grid.onedgrid import OneDGrid
from grid.rtransform import HyperbolicRTransform
Expand Down Expand Up @@ -216,11 +216,11 @@ def get_atomic_grid_data(calc):

atom_data = {}
if calc.wfs.nspins == 1:
atom_data["dm"] = unpack2(calc.density.D_asp.get(iatom)[0])[order][:, order]
atom_data["dm"] = unpack_density(calc.density.D_asp.get(iatom)[0])[order][:, order]
else:
# spin-summed and spin-difference atomic density matrices.
dma = unpack2(calc.density.D_asp.get(iatom)[0])[order][:, order]
dmb = unpack2(calc.density.D_asp.get(iatom)[1])[order][:, order]
dma = unpack_density(calc.density.D_asp.get(iatom)[0])[order][:, order]
dmb = unpack_density(calc.density.D_asp.get(iatom)[1])[order][:, order]
atom_data["dm"] = dma + dmb
atom_data["spindm"] = dma - dmb
assert atom_data["dm"].shape == (setup.ni, setup.ni)
Expand Down
15 changes: 5 additions & 10 deletions src/denspart/adapters/test/test_horton3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
"""Test the input preparation with HORTON3 modules."""

import os
from importlib import resources
from importlib.resources import as_file, files

import numpy as np
import pytest
from iodata.utils import FileFormatWarning
from numpy.testing import assert_allclose

from ..horton3 import main
Expand Down Expand Up @@ -118,12 +117,10 @@

@pytest.mark.parametrize("fn_wfn", FILENAMES)
def test_from_horton3_density(fn_wfn, tmpdir):
with resources.path("iodata.test.data", fn_wfn) as fn_full:
with as_file(files("iodata.test.data").joinpath(fn_wfn)) as fn_full:
fn_density = os.path.join(tmpdir, "density.npz")
with pytest.warns(None) as record:
with pytest.warns():
main([str(fn_full), fn_density])
if len(record) == 1:
assert issubclass(record[0].category, FileFormatWarning)
assert os.path.isfile(fn_density)
data = dict(np.load(fn_density))

Expand All @@ -133,12 +130,10 @@ def test_from_horton3_density(fn_wfn, tmpdir):

@pytest.mark.parametrize("fn_wfn", ["hf_sto3g.fchk", "water_sto3g_hf_g03.fchk"])
def test_from_horton3_all(fn_wfn, tmpdir):
with resources.path("iodata.test.data", fn_wfn) as fn_full:
with as_file(files("iodata.test.data").joinpath(fn_wfn)) as fn_full:
fn_density = os.path.join(tmpdir, "density.npz")
with pytest.warns(None) as record:
with pytest.warns():
main([str(fn_full), fn_density, "-s", "-g", "-o"])
if len(record) == 1:
assert issubclass(record[0].category, FileFormatWarning)
assert os.path.isfile(fn_density)
data = dict(np.load(fn_density))

Expand Down

0 comments on commit a33c5f3

Please sign in to comment.