Skip to content

Commit

Permalink
Disable test for Structure.from_cod
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Aug 9, 2024
1 parent f06ec9a commit 8d201d1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
17 changes: 17 additions & 0 deletions abipy/core/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,23 @@ def test_mprester():
#raise unittest.SkipTest("MPRester tests have been disabled")
return True

def is_url_reachable(url: str) -> bool:
"""check if a URL is reachable:"""
import requests
try:
# Send a HEAD request to the URL
response = requests.head(url, timeout=5)

# Check if the response status code is 200 (OK)
if response.status_code == 200:
return True
else:
return False
except requests.exceptions.RequestException as e:
# Handle any request exceptions (e.g., connection errors)
#print(f"Error: {e}")
return False

@staticmethod
def has_matplotlib(version: Optional[str] = None, op: str = ">=") -> bool:
return has_matplotlib(version=version, op=op)
Expand Down
8 changes: 5 additions & 3 deletions abipy/core/tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ def test_utils(self):
d = llzo.abiget_spginfo(tolsym=0.001)
assert d["spg_number"] == 142

mgb2_cod = Structure.from_cod_id(1526507, primitive=True)
assert mgb2_cod.formula == "Mg1 B2"
assert mgb2_cod.spget_lattice_type() == "hexagonal"
# Temporarily disables ad webserver is down.
#if self.is_url_reachable("www.crystallography.net"):
# mgb2_cod = Structure.from_cod_id(1526507, primitive=True)
# assert mgb2_cod.formula == "Mg1 B2"
# assert mgb2_cod.spget_lattice_type() == "hexagonal"

mgb2 = abidata.structure_from_ucell("MgB2")
if self.has_ase():
Expand Down
2 changes: 1 addition & 1 deletion abipy/electrons/effmass_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def plot_all_segments(self, ax=None, colormap="viridis", fontsize=8, **kwargs) -
pad += 10

#title = "k: %s, spin: %s, nband: %d" % (repr(self.efm_kpoint), self.spin, segment.nb)
set_grid_legend(ax, fontsize, ylabel='Energy (eV)', title=title)
set_grid_legend(ax, fontsize, ylabel='Energy (eV)') #, title=title)

return fig

Expand Down
9 changes: 5 additions & 4 deletions abipy/electrons/tests/test_ebands.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,14 @@ def test_silicon_ebands(self):
with self.assertRaises(NotImplementedError):
si_ebands_kmesh.get_edos(method="tetrahedron")

si_edos = si_ebands_kmesh.get_edos(step=0.1, width=0.2)
edos_kwargs = dict(step=0.1, width=0.2)
si_edos = si_ebands_kmesh.get_edos(**edos_kwargs)
repr(si_edos); str(si_edos)
assert ElectronDos.as_edos(si_edos, {}) is si_edos
assert si_edos == si_edos and not (si_edos != si_edos)
edos_samevals = ElectronDos.as_edos(si_ebands_kmesh, {})
assert ElectronDos.as_edos(si_ebands_kmesh, {}) == si_edos
assert ElectronDos.as_edos(abidata.ref_file("si_scf_GSR.nc"), {}) == si_edos
edos_samevals = ElectronDos.as_edos(si_ebands_kmesh, edos_kwargs)
assert ElectronDos.as_edos(si_ebands_kmesh, edos_kwargs=edos_kwargs) == si_edos
assert ElectronDos.as_edos(abidata.ref_file("si_scf_GSR.nc"), edos_kwargs=edos_kwargs) == si_edos
with self.assertRaises(TypeError):
ElectronDos.as_edos({}, {})

Expand Down
2 changes: 2 additions & 0 deletions abipy/ml/aseml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,9 @@ def __init__(self, name: str, dftd3_args=None, **kwargs):
if ":" in name:
self.nn_type, last = name.split(":")
if last.endswith(".yaml") or last.endswith(".yml"):
print("Reading Calculator kwargs from file:", last)
self.calc_kwargs = yaml_safe_load_path(last)
print("calc_kwargs:", self.calc_kwargs)
else:
self.model_name = last

Expand Down

0 comments on commit 8d201d1

Please sign in to comment.