From 6f0cf5273a2452f0982f3c60551c66df15bb1efd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:26:41 +0000 Subject: [PATCH] pre-commit auto-fixes --- examples/neb_idpp_solver.ipynb | 9 +- examples/neb_path_mapping.ipynb | 22 ++--- examples/probability_analysis.ipynb | 11 +-- examples/radial_distribution_function.ipynb | 43 ++++----- examples/van_hove.ipynb | 17 ++-- .../analysis/diffusion/aimd/clustering.py | 15 +--- .../diffusion/aimd/tests/test_clustering.py | 4 +- .../diffusion/aimd/tests/test_pathway.py | 20 ++--- .../analysis/diffusion/aimd/tests/test_rdf.py | 12 +-- .../diffusion/aimd/tests/test_van_hove.py | 30 ++----- .../neb/tests/test_full_path_mapper.py | 87 +++++-------------- .../diffusion/neb/tests/test_pathfinder.py | 68 ++++----------- .../analysis/diffusion/tests/test_analyzer.py | 62 ++++--------- .../utils/tests/test_edge_data_from_sc.py | 15 +--- .../diffusion/utils/tests/test_maggma.py | 4 +- .../utils/tests/test_parse_entries.py | 44 +++------- 16 files changed, 126 insertions(+), 337 deletions(-) diff --git a/examples/neb_idpp_solver.ipynb b/examples/neb_idpp_solver.ipynb index 940db400..04017afd 100644 --- a/examples/neb_idpp_solver.ipynb +++ b/examples/neb_idpp_solver.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -20,13 +20,6 @@ " sort_tol=1.0)\n", "new_path = obj.run(maxiter=5000, tol=1e-5, gtol=1e-3, species=[\"Li\"])" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/neb_path_mapping.ipynb b/examples/neb_path_mapping.ipynb index a8eec3f0..59c4aec9 100644 --- a/examples/neb_path_mapping.ipynb +++ b/examples/neb_path_mapping.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -228,7 +228,7 @@ " 21 23 (0, 0, -1) " ] }, - "execution_count": 3, + "execution_count": null, "metadata": {}, "output_type": "execute_result" } @@ -239,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -266,7 +266,7 @@ " 'hop_distance': 2.36387070814374}" ] }, - "execution_count": 4, + "execution_count": null, "metadata": {}, "output_type": "execute_result" } @@ -278,7 +278,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -297,7 +297,7 @@ " 'cost': 2.36387070814374}" ] }, - "execution_count": 5, + "execution_count": null, "metadata": {}, "output_type": "execute_result" } @@ -310,7 +310,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -322,7 +322,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -383,7 +383,7 @@ " 'cost': 2.36387070814374}]" ] }, - "execution_count": 7, + "execution_count": null, "metadata": {}, "output_type": "execute_result" } diff --git a/examples/probability_analysis.ipynb b/examples/probability_analysis.ipynb index 836ef9b3..d673aca9 100644 --- a/examples/probability_analysis.ipynb +++ b/examples/probability_analysis.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -87,13 +87,6 @@ "# \\int P(r)d^3r = 1\n", "print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/radial_distribution_function.ipynb b/examples/radial_distribution_function.ipynb index 7ee0b173..99684ee4 100644 --- a/examples/radial_distribution_function.ipynb +++ b/examples/radial_distribution_function.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -68,7 +68,7 @@ "Text(0.5, 1.0, 'Old RDF implementation')" ] }, - "execution_count": 5, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -101,7 +101,7 @@ "Text(0.5, 1.0, 'Old coordination number')" ] }, - "execution_count": 6, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -125,7 +125,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -134,7 +134,7 @@ "Text(0.5, 1.0, 'New RDF implementation')" ] }, - "execution_count": 7, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -168,7 +168,7 @@ "Text(0.5, 1.0, 'New coordination number')" ] }, - "execution_count": 8, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -193,7 +193,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -202,7 +202,7 @@ "" ] }, - "execution_count": 9, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -236,7 +236,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -245,7 +245,7 @@ "(-0.2, 6.2)" ] }, - "execution_count": 10, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -273,7 +273,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -294,7 +294,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -311,13 +311,6 @@ "rdf_func_faster = RadialDistributionFunctionFast(structures=structure_list, \n", " ngrid=101, rmax=10.0, sigma=0.2)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/van_hove.ipynb b/examples/van_hove.ipynb index c606a2f0..d83ba50b 100644 --- a/examples/van_hove.ipynb +++ b/examples/van_hove.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -26,7 +26,7 @@ "" ] }, - "execution_count": 1, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -82,7 +82,7 @@ "" ] }, - "execution_count": 2, + "execution_count": null, "metadata": {}, "output_type": "execute_result" }, @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -145,13 +145,6 @@ "obj = RadialDistributionFunction(structure_list, ngrid=101, rmax=10.0, sigma=0.1, indices=[0], reference_indices=[2, 3])\n", "plt = obj.get_rdf_plot(label=\"RDF\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/pymatgen/analysis/diffusion/aimd/clustering.py b/pymatgen/analysis/diffusion/aimd/clustering.py index 3de6ea90..80935a40 100644 --- a/pymatgen/analysis/diffusion/aimd/clustering.py +++ b/pymatgen/analysis/diffusion/aimd/clustering.py @@ -45,11 +45,7 @@ def cluster(self, points, k, initial_centroids=None): provide the index for each point, and ss in the final sum squared distances. """ - centroids = ( - np.array(random.sample(list(points), k)) - if initial_centroids is None - else initial_centroids - ) + centroids = np.array(random.sample(list(points), k)) if initial_centroids is None else initial_centroids # Initialize book keeping vars. iterations = 0 @@ -173,9 +169,7 @@ def get_centroids(self, points, labels, k, centroids): if len(ind) > 0: c = np.zeros(n) for j in ind: - dist, image = self.lattice.get_distance_and_image( - centroids[i], points[j] - ) + dist, image = self.lattice.get_distance_and_image(centroids[i], points[j]) c += points[j] + image c /= len(ind) c = np.mod(c, 1) @@ -199,10 +193,7 @@ def should_stop(self, old_centroids, centroids, iterations): return True if old_centroids is None: return False - return all( - np.allclose(pbc_diff(c1, c2), [0, 0, 0]) - for c1, c2 in zip(old_centroids, centroids) - ) + return all(np.allclose(pbc_diff(c1, c2), [0, 0, 0]) for c1, c2 in zip(old_centroids, centroids)) def get_random_centroid(points): diff --git a/pymatgen/analysis/diffusion/aimd/tests/test_clustering.py b/pymatgen/analysis/diffusion/aimd/tests/test_clustering.py index 264cb4a1..3db9e16c 100644 --- a/pymatgen/analysis/diffusion/aimd/tests/test_clustering.py +++ b/pymatgen/analysis/diffusion/aimd/tests/test_clustering.py @@ -45,9 +45,7 @@ def test_cluster(self): initial = [[0, 0, 0], [0.5, 0.5, 0.5], [0.25, 0.25, 0.25], [0.5, 0, 0]] for c in initial: for _i in range(100): - pts.append( - np.array(c) + np.random.randn(3) * 0.01 + np.random.randint(3) - ) + pts.append(np.array(c) + np.random.randn(3) * 0.01 + np.random.randint(3)) pts = np.array(pts) k = KmeansPBC(lattice) centroids, labels, ss = k.cluster(pts, 4) diff --git a/pymatgen/analysis/diffusion/aimd/tests/test_pathway.py b/pymatgen/analysis/diffusion/aimd/tests/test_pathway.py index d57ed8bd..8afc88bd 100644 --- a/pymatgen/analysis/diffusion/aimd/tests/test_pathway.py +++ b/pymatgen/analysis/diffusion/aimd/tests/test_pathway.py @@ -42,9 +42,7 @@ def test_probability_classmethod(self): diff_analyzer = DiffusionAnalyzer.from_dict(data) # ProbabilityDensityAnalysis object - pda = ProbabilityDensityAnalysis.from_diffusion_analyzer( - diffusion_analyzer=diff_analyzer, interval=0.5 - ) + pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diffusion_analyzer=diff_analyzer, interval=0.5) dV = pda.structure.lattice.volume / pda.lens[0] / pda.lens[1] / pda.lens[2] Pr_tot = np.sum(pda.Pr) * dV @@ -58,9 +56,7 @@ def test_generate_stable_sites(self): diff_analyzer = DiffusionAnalyzer.from_dict(data) # ProbabilityDensityAnalysis object - pda = ProbabilityDensityAnalysis.from_diffusion_analyzer( - diffusion_analyzer=diff_analyzer, interval=0.1 - ) + pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diffusion_analyzer=diff_analyzer, interval=0.1) pda.generate_stable_sites(p_ratio=0.25, d_cutoff=1.5) assert len(pda.stable_sites) == 50 @@ -79,9 +75,7 @@ def test_to_chgcar(self): diff_analyzer = DiffusionAnalyzer.from_dict(data) # ProbabilityDensityAnalysis object - pda = ProbabilityDensityAnalysis.from_diffusion_analyzer( - diffusion_analyzer=diff_analyzer, interval=0.1 - ) + pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diffusion_analyzer=diff_analyzer, interval=0.1) pda.to_chgcar("CHGCAR.PDA") chgcar = Chgcar.from_file("CHGCAR.PDA") assert pda.structure.species == chgcar.structure.species @@ -99,9 +93,7 @@ def test_site_occupancy(self): coords_ref = [ss.frac_coords for ss in structure if ss.specie.symbol == "Na"] # SiteOccupancyAnalyzer object - socc = SiteOccupancyAnalyzer( - structure, coords_ref, trajectories, species=("Li", "Na") - ) + socc = SiteOccupancyAnalyzer(structure, coords_ref, trajectories, species=("Li", "Na")) site_occ = socc.site_occ self.assertAlmostEqual(np.sum(site_occ), len(coords_ref), 12) self.assertAlmostEqual(site_occ[11], 0.98, 12) @@ -117,9 +109,7 @@ def test_site_occupancy_classmethod(self): coords_ref = [ss.frac_coords for ss in structure if ss.specie.symbol == "Na"] # SiteOccupancyAnalyzer object - socc = SiteOccupancyAnalyzer.from_diffusion_analyzer( - coords_ref, diffusion_analyzer=diff_analyzer - ) + socc = SiteOccupancyAnalyzer.from_diffusion_analyzer(coords_ref, diffusion_analyzer=diff_analyzer) site_occ = socc.site_occ self.assertAlmostEqual(np.sum(site_occ), len(coords_ref), 12) self.assertAlmostEqual(site_occ[1], 0.98, 12) diff --git a/pymatgen/analysis/diffusion/aimd/tests/test_rdf.py b/pymatgen/analysis/diffusion/aimd/tests/test_rdf.py index 9a157283..eb0b30d6 100644 --- a/pymatgen/analysis/diffusion/aimd/tests/test_rdf.py +++ b/pymatgen/analysis/diffusion/aimd/tests/test_rdf.py @@ -24,9 +24,7 @@ def test_rdf(self): break # Test from_species - obj = RadialDistributionFunctionFast( - structures=structure_list, ngrid=101, rmax=10.0, sigma=0.1 - ) + obj = RadialDistributionFunctionFast(structures=structure_list, ngrid=101, rmax=10.0, sigma=0.1) r, s_na_rdf = obj.get_rdf("S", "Na") assert s_na_rdf.shape == (101,) @@ -37,11 +35,7 @@ def test_rdf_coordination_number(self): # create a simple cubic lattice coords = np.array([[0.5, 0.5, 0.5]]) atom_list = ["S"] - lattice = Lattice.from_parameters( - a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90 - ) + lattice = Lattice.from_parameters(a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90) structure = Structure(lattice, atom_list, coords) - rdf = RadialDistributionFunctionFast( - structures=[structure], rmax=5.0, sigma=0.01, ngrid=500 - ) + rdf = RadialDistributionFunctionFast(structures=[structure], rmax=5.0, sigma=0.01, ngrid=500) assert np.round(rdf.get_coordination_number("S", "S")[1][110], 2) == 6.0 diff --git a/pymatgen/analysis/diffusion/aimd/tests/test_van_hove.py b/pymatgen/analysis/diffusion/aimd/tests/test_van_hove.py index 28ca3970..ad011bc3 100644 --- a/pymatgen/analysis/diffusion/aimd/tests/test_van_hove.py +++ b/pymatgen/analysis/diffusion/aimd/tests/test_van_hove.py @@ -118,9 +118,7 @@ def test_rdf_coordination_number(self): # create a simple cubic lattice coords = np.array([[0.5, 0.5, 0.5]]) atom_list = ["S"] - lattice = Lattice.from_parameters( - a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90 - ) + lattice = Lattice.from_parameters(a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90) structure = Structure(lattice, atom_list, coords) rdf = RadialDistributionFunction.from_species( structures=[structure], species=["S"], rmax=5.0, sigma=0.1, ngrid=500 @@ -131,9 +129,7 @@ def test_rdf_two_species_coordination_number(self): # create a structure with interpenetrating simple cubic lattice coords = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]]) atom_list = ["S", "Zn"] - lattice = Lattice.from_parameters( - a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90 - ) + lattice = Lattice.from_parameters(a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90) structure = Structure(lattice, atom_list, coords) rdf = RadialDistributionFunction.from_species( structures=[structure], @@ -148,28 +144,20 @@ def test_rdf_two_species_coordination_number(self): def setUp(self): coords = np.array([[0.5, 0.5, 0.5]]) atom_list = ["S"] - lattice = Lattice.from_parameters( - a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90 - ) + lattice = Lattice.from_parameters(a=1.0, b=1.0, c=1.0, alpha=90, beta=90, gamma=90) self.structure = Structure(lattice, atom_list, coords) def test_raises_valueerror_if_ngrid_is_less_than_2(self): with pytest.raises(ValueError): - RadialDistributionFunction.from_species( - structures=[self.structure], ngrid=1 - ) + RadialDistributionFunction.from_species(structures=[self.structure], ngrid=1) def test_raises_ValueError_if_sigma_is_not_positive(self): with pytest.raises(ValueError): - RadialDistributionFunction.from_species( - structures=[self.structure], sigma=0 - ) + RadialDistributionFunction.from_species(structures=[self.structure], sigma=0) def test_raises_ValueError_if_species_not_in_structure(self): with pytest.raises(ValueError): - RadialDistributionFunction.from_species( - structures=[self.structure], species=["Cl"] - ) + RadialDistributionFunction.from_species(structures=[self.structure], species=["Cl"]) def test_raises_ValueError_if_reference_species_not_in_structure(self): with pytest.raises(ValueError): @@ -191,10 +179,6 @@ def test_get_df(self): eva = EvolutionAnalyzer(structure_list, rmax=10, step=1, time_step=2) rdf = eva.get_df(EvolutionAnalyzer.rdf, pair=("Na", "Na")) atom_dist = eva.get_df(EvolutionAnalyzer.atom_dist, specie="Na", direction="c") - check = ( - np.shape(rdf) == (10, 101) - and np.shape(atom_dist) == (10, 101) - and ("Na", "Na") in eva.pairs - ) + check = np.shape(rdf) == (10, 101) and np.shape(atom_dist) == (10, 101) and ("Na", "Na") in eva.pairs assert check self.assertAlmostEqual(max(np.array(rdf)[0]), 1.772465, 4) diff --git a/pymatgen/analysis/diffusion/neb/tests/test_full_path_mapper.py b/pymatgen/analysis/diffusion/neb/tests/test_full_path_mapper.py index 55a5e918..d0c5d38e 100644 --- a/pymatgen/analysis/diffusion/neb/tests/test_full_path_mapper.py +++ b/pymatgen/analysis/diffusion/neb/tests/test_full_path_mapper.py @@ -29,18 +29,14 @@ class MigrationGraphSimpleTest(unittest.TestCase): def setUp(self): struct = Structure.from_file(f"{dir_path}/full_path_files/MnO2_full_Li.vasp") - self.fpm = MigrationGraph.with_distance( - structure=struct, migrating_specie="Li", max_distance=4 - ) + self.fpm = MigrationGraph.with_distance(structure=struct, migrating_specie="Li", max_distance=4) def test_get_pos_and_migration_hop(self): """ Make sure that we can populate the graph with MigrationHop Objects """ self.fpm._get_pos_and_migration_hop(0, 1, 1) - self.assertAlmostEqual( - self.fpm.m_graph.graph[0][1][1]["hop"].length, 3.571248, 4 - ) + self.assertAlmostEqual(self.fpm.m_graph.graph[0][1][1]["hop"].length, 3.571248, 4) def test_get_summary_dict(self): summary_dict = self.fpm.get_summary_dict() @@ -50,12 +46,8 @@ def test_get_summary_dict(self): class MigrationGraphFromEntriesTest(unittest.TestCase): def setUp(self): - self.test_ents_MOF = loadfn( - f"{dir_path}/full_path_files/Mn6O5F7_cat_migration.json" - ) - self.aeccar_MOF = Chgcar.from_file( - f"{dir_path}/full_path_files/AECCAR_Mn6O5F7.vasp" - ) + self.test_ents_MOF = loadfn(f"{dir_path}/full_path_files/Mn6O5F7_cat_migration.json") + self.aeccar_MOF = Chgcar.from_file(f"{dir_path}/full_path_files/AECCAR_Mn6O5F7.vasp") self.li_ent = loadfn(f"{dir_path}/full_path_files/li_ent.json")["li_ent"] entries = [self.test_ents_MOF["ent_base"]] + self.test_ents_MOF["one_cation"] self.full_struct = MigrationGraph.get_structure_from_entries( @@ -79,34 +71,26 @@ def test_m_graph_from_entries_failed(self): def test_m_graph_construction(self): assert self.full_struct.composition["Li"] == 8 - mg = MigrationGraph.with_distance( - self.full_struct, migrating_specie="Li", max_distance=4.0 - ) + mg = MigrationGraph.with_distance(self.full_struct, migrating_specie="Li", max_distance=4.0) assert len(mg.m_graph.structure) == 8 class MigrationGraphComplexTest(unittest.TestCase): def setUp(self): struct = Structure.from_file(f"{dir_path}/full_path_files/MnO2_full_Li.vasp") - self.fpm_li = MigrationGraph.with_distance( - structure=struct, migrating_specie="Li", max_distance=4 - ) + self.fpm_li = MigrationGraph.with_distance(structure=struct, migrating_specie="Li", max_distance=4) # Particularity difficult path finding since both the starting and ending # positions are outside the unit cell struct = Structure.from_file(f"{dir_path}/full_path_files/Mg_2atom.vasp") - self.fpm_mg = MigrationGraph.with_distance( - structure=struct, migrating_specie="Mg", max_distance=2 - ) + self.fpm_mg = MigrationGraph.with_distance(structure=struct, migrating_specie="Mg", max_distance=2) def test_group_and_label_hops(self): """ Check that the set of end points in a group of similarly labeled hops are all the same. """ - edge_labs = np.array( - [d["hop_label"] for u, v, d in self.fpm_li.m_graph.graph.edges(data=True)] - ) + edge_labs = np.array([d["hop_label"] for u, v, d in self.fpm_li.m_graph.graph.edges(data=True)]) site_labs = np.array( [ @@ -128,11 +112,7 @@ def test_unique_hops_dict(self): Check that the unique hops are inequivalent """ unique_list = [v for k, v in self.fpm_li.unique_hops.items()] - all_pairs = [ - (mg1, mg2) - for i1, mg1 in enumerate(unique_list) - for mg2 in unique_list[i1 + 1 :] - ] + all_pairs = [(mg1, mg2) for i1, mg1 in enumerate(unique_list) for mg2 in unique_list[i1 + 1 :]] for migration_hop in all_pairs: assert migration_hop[0]["hop"] != migration_hop[1]["hop"] @@ -146,9 +126,7 @@ def test_add_data_to_similar_edges(self): # passing ordered list data migration_hop = self.fpm_li.unique_hops[1]["hop"] - self.fpm_li.add_data_to_similar_edges( - 1, {"key1": [1, 2, 3]}, m_hop=migration_hop - ) + self.fpm_li.add_data_to_similar_edges(1, {"key1": [1, 2, 3]}, m_hop=migration_hop) for _u, _v, d in self.fpm_li.m_graph.graph.edges(data=True): if d["hop_label"] == 1: assert d["key1"] == [1, 2, 3] @@ -159,9 +137,7 @@ def test_add_data_to_similar_edges(self): esite=migration_hop.isite, symm_structure=migration_hop.symm_structure, ) - self.fpm_li.add_data_to_similar_edges( - 2, {"key2": [1, 2, 3]}, m_hop=migration_hop_reversed - ) + self.fpm_li.add_data_to_similar_edges(2, {"key2": [1, 2, 3]}, m_hop=migration_hop_reversed) for _u, _v, d in self.fpm_li.m_graph.graph.edges(data=True): if d["hop_label"] == 2: assert d["key2"] == [3, 2, 1] @@ -186,44 +162,30 @@ def test_periodic_dijkstra(self): for v in conn_dict[u]: for d in conn_dict[u][v].values(): neg_image = tuple(-dim_ for dim_ in d["to_jimage"]) - opposite_connections = [ - d2_["to_jimage"] for k2_, d2_ in conn_dict[v][u].items() - ] + opposite_connections = [d2_["to_jimage"] for k2_, d2_ in conn_dict[v][u].items()] assert neg_image in opposite_connections def test_get_path(self): self.fpm_li.assign_cost_to_graph() # use 'hop_distance' paths = [*self.fpm_li.get_path(flip_hops=False)] - p_strings = { - "->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) - for u, ipath in paths - } + p_strings = {"->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) for u, ipath in paths} assert "5->7->5" in p_strings # convert each pathway to a string representation paths = [*self.fpm_li.get_path(max_val=2.0, flip_hops=False)] - p_strings = { - "->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) - for u, ipath in paths - } + p_strings = {"->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) for u, ipath in paths} # After checking trimming the graph more hops are needed for the same path assert "5->3->7->2->5" in p_strings self.fpm_mg.assign_cost_to_graph() # use 'hop_distance' paths = [*self.fpm_mg.get_path(flip_hops=False)] - p_strings = { - "->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) - for u, ipath in paths - } + p_strings = {"->".join(map(str, get_hop_site_sequence(ipath, start_u=u))) for u, ipath in paths} assert "1->0->1" in p_strings def test_get_key_in_path(self): self.fpm_li.assign_cost_to_graph() # use 'hop_distance' paths = [*self.fpm_li.get_path(flip_hops=False)] - hop_seq_info = [ - get_hop_site_sequence(ipath, start_u=u, key="hop_distance") - for u, ipath in paths - ] + hop_seq_info = [get_hop_site_sequence(ipath, start_u=u, key="hop_distance") for u, ipath in paths] hop_distances = {} for u, ipath in paths: @@ -266,12 +228,8 @@ def test_order_path(self): class ChargeBarrierGraphTest(unittest.TestCase): def setUp(self): - self.full_sites_MOF = loadfn( - f"{dir_path}/full_path_files/LixMn6O5F7_full_sites.json" - ) - self.aeccar_MOF = Chgcar.from_file( - f"{dir_path}/full_path_files/AECCAR_Mn6O5F7.vasp" - ) + self.full_sites_MOF = loadfn(f"{dir_path}/full_path_files/LixMn6O5F7_full_sites.json") + self.aeccar_MOF = Chgcar.from_file(f"{dir_path}/full_path_files/AECCAR_Mn6O5F7.vasp") self.cbg = ChargeBarrierGraph.with_distance( structure=self.full_sites_MOF, migrating_specie="Li", @@ -303,9 +261,7 @@ def test_integration(self): epos = [0.33587514, -0.3461259, 1.15269302] isite = PeriodicSite("Li", ipos, self.cbg.structure.lattice) esite = PeriodicSite("Li", epos, self.cbg.structure.lattice) - ref_hop = MigrationHop( - isite=isite, esite=esite, symm_structure=self.cbg.symm_structure - ) + ref_hop = MigrationHop(isite=isite, esite=esite, symm_structure=self.cbg.symm_structure) hop_idx = -1 for k, d in self.cbg.unique_hops.items(): if d["hop"] == ref_hop: @@ -323,10 +279,7 @@ def test_populate_edges_with_chg_density_info(self): this will not always be true, but it valid in this Mn6O5F7 """ self.cbg.populate_edges_with_chg_density_info() - length_vs_chg = sorted( - (d["hop"].length, d["chg_total"]) - for u, v, d in self.cbg.m_graph.graph.edges(data=True) - ) + length_vs_chg = sorted((d["hop"].length, d["chg_total"]) for u, v, d in self.cbg.m_graph.graph.edges(data=True)) prv = None for length, chg in length_vs_chg: if prv is None: diff --git a/pymatgen/analysis/diffusion/neb/tests/test_pathfinder.py b/pymatgen/analysis/diffusion/neb/tests/test_pathfinder.py index bff2120f..3eeeb0b4 100644 --- a/pymatgen/analysis/diffusion/neb/tests/test_pathfinder.py +++ b/pymatgen/analysis/diffusion/neb/tests/test_pathfinder.py @@ -27,14 +27,10 @@ def get_path(path_str, dirname="./"): class IDPPSolverTest(unittest.TestCase): init_struct = Structure.from_file(get_path("CONTCAR-0", dirname="pathfinder_files")) - final_struct = Structure.from_file( - get_path("CONTCAR-1", dirname="pathfinder_files") - ) + final_struct = Structure.from_file(get_path("CONTCAR-1", dirname="pathfinder_files")) def test_idpp_from_ep(self): - obj = IDPPSolver.from_endpoints( - [self.init_struct, self.final_struct], nimages=3, sort_tol=1.0 - ) + obj = IDPPSolver.from_endpoints([self.init_struct, self.final_struct], nimages=3, sort_tol=1.0) new_path = obj.run( maxiter=5000, tol=1e-5, @@ -47,21 +43,11 @@ def test_idpp_from_ep(self): assert len(new_path) == 5 assert new_path[1].num_sites == 111 - assert np.allclose( - new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964]) - ) - assert np.allclose( - new_path[1][0].frac_coords, np.array([0.482439, 0.68264727, 0.26525066]) - ) - assert np.allclose( - new_path[2][10].frac_coords, np.array([0.50113915, 0.74958704, 0.75147021]) - ) - assert np.allclose( - new_path[3][22].frac_coords, np.array([0.28422885, 0.62568764, 0.98975444]) - ) - assert np.allclose( - new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006]) - ) + assert np.allclose(new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964])) + assert np.allclose(new_path[1][0].frac_coords, np.array([0.482439, 0.68264727, 0.26525066])) + assert np.allclose(new_path[2][10].frac_coords, np.array([0.50113915, 0.74958704, 0.75147021])) + assert np.allclose(new_path[3][22].frac_coords, np.array([0.28422885, 0.62568764, 0.98975444])) + assert np.allclose(new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006])) def test_idpp_from_ep_diff_latt(self): # This is the same test as test_idpp_from_ep where we want to interpolate @@ -93,21 +79,11 @@ def test_idpp_from_ep_diff_latt(self): # For checking coords, the endpoints will have the same frac coords as the # original test, whereas the midpoints will not have altered coord because # of the differing lattice. - assert np.allclose( - new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964]) - ) - assert np.allclose( - new_path[1][0].frac_coords, np.array([0.47483465, 0.6740367, 0.26270862]) - ) - assert np.allclose( - new_path[2][10].frac_coords, np.array([0.48839604, 0.73135841, 0.73315875]) - ) - assert np.allclose( - new_path[3][22].frac_coords, np.array([0.27395552, 0.60307242, 0.95398018]) - ) - assert np.allclose( - new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006]) - ) + assert np.allclose(new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964])) + assert np.allclose(new_path[1][0].frac_coords, np.array([0.47483465, 0.6740367, 0.26270862])) + assert np.allclose(new_path[2][10].frac_coords, np.array([0.48839604, 0.73135841, 0.73315875])) + assert np.allclose(new_path[3][22].frac_coords, np.array([0.27395552, 0.60307242, 0.95398018])) + assert np.allclose(new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006])) # ensure the lattices are interpolated assert np.allclose( @@ -162,9 +138,7 @@ def test_idpp_from_ep_diff_latt(self): ) def test_idpp(self): - images = self.init_struct.interpolate( - self.final_struct, nimages=4, autosort_tol=1.0 - ) + images = self.init_struct.interpolate(self.final_struct, nimages=4, autosort_tol=1.0) obj = IDPPSolver(images) new_path = obj.run( maxiter=5000, @@ -178,15 +152,9 @@ def test_idpp(self): assert len(new_path) == 5 assert new_path[1].num_sites == 111 - assert np.allclose( - new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964]) - ) - assert np.allclose( - new_path[1][0].frac_coords, np.array([0.482439, 0.68264727, 0.26525066]) - ) - assert np.allclose( - new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006]) - ) + assert np.allclose(new_path[0][2].frac_coords, np.array([0.50000014, 0.99999998, 0.74999964])) + assert np.allclose(new_path[1][0].frac_coords, np.array([0.482439, 0.68264727, 0.26525066])) + assert np.allclose(new_path[4][47].frac_coords, np.array([0.59767531, 0.12640952, 0.37745006])) class DistinctPathFinderTest(PymatgenTest): @@ -246,9 +214,7 @@ def test_max_path_length(self): class MigrationHopTest(PymatgenTest): def setUp(self): self.lifepo = self.get_structure("LiFePO4") - m_graph = MigrationGraph.with_distance( - self.lifepo, max_distance=4.0, migrating_specie="Li" - ) + m_graph = MigrationGraph.with_distance(self.lifepo, max_distance=4.0, migrating_specie="Li") gen = iter(m_graph.m_graph.graph.edges(data=True)) u, v, d = next(gen) i_site = PeriodicSite("Li", coords=d["ipos"], lattice=self.lifepo.lattice) diff --git a/pymatgen/analysis/diffusion/tests/test_analyzer.py b/pymatgen/analysis/diffusion/tests/test_analyzer.py index c1de24bd..f07d2bf6 100644 --- a/pymatgen/analysis/diffusion/tests/test_analyzer.py +++ b/pymatgen/analysis/diffusion/tests/test_analyzer.py @@ -23,9 +23,7 @@ class FuncTest(PymatgenTest): def test_get_conversion_factor(self): s = PymatgenTest.get_structure("LiFePO4") # large tolerance because scipy constants changed between 0.16.1 and 0.17 - self.assertAlmostEqual( - 41370704.343540139, get_conversion_factor(s, "Li", 600), delta=20 - ) + self.assertAlmostEqual(41370704.343540139, get_conversion_factor(s, "Li", 600), delta=20) def test_fit_arrhenius(self): Ea = 0.5 @@ -64,21 +62,13 @@ def test_init(self): self.assertAlmostEqual(d.diffusivity_std_dev, 9.1013023085561779e-09, 7) self.assertAlmostEqual(d.chg_diffusivity_std_dev, 7.20911399729e-10, 5) self.assertAlmostEqual(d.haven_ratio, 0.31854161048867402, 7) - assert d.conductivity_components == pytest.approx( - [45.7903694, 26.1651956, 150.5406140] - ) - assert d.diffusivity_components == pytest.approx( - [7.49601236e-07, 4.90254273e-07, 2.24649255e-06], rel=0.2 - ) - assert d.conductivity_components_std_dev == pytest.approx( - [0.0063566, 0.0180854, 0.0217918], rel=0.1 - ) + assert d.conductivity_components == pytest.approx([45.7903694, 26.1651956, 150.5406140]) + assert d.diffusivity_components == pytest.approx([7.49601236e-07, 4.90254273e-07, 2.24649255e-06], rel=0.2) + assert d.conductivity_components_std_dev == pytest.approx([0.0063566, 0.0180854, 0.0217918], rel=0.1) assert d.diffusivity_components_std_dev == pytest.approx( [8.9465670e-09, 2.4931224e-08, 2.2636384e-08], abs=1e-3 ) - assert d.mscd[0:4] == pytest.approx( - [0.69131064, 0.71794072, 0.74315283, 0.76703961], abs=1e-3 - ) + assert d.mscd[0:4] == pytest.approx([0.69131064, 0.71794072, 0.74315283, 0.76703961], abs=1e-3) assert d.max_ion_displacements == pytest.approx( [ @@ -145,9 +135,7 @@ def test_init(self): assert len(ss) == 50 n = random.randint(0, 49) n_orig = n * 20 + 10 - assert ss[n].cart_coords - d.structure.cart_coords + d.drift[ - :, n_orig, : - ] == pytest.approx( + assert ss[n].cart_coords - d.structure.cart_coords + d.drift[:, n_orig, :] == pytest.approx( d.disp[:, n_orig, :], ) @@ -254,18 +242,10 @@ def test_init_npt(self): self.assertAlmostEqual(d.diffusivity_std_dev, 9.1013023085561779e-09, 7) self.assertAlmostEqual(d.chg_diffusivity_std_dev, 1.20834853646e-08, 6) self.assertAlmostEqual(d.haven_ratio, 0.409275240679, 7) - assert d.conductivity_components == pytest.approx( - [455.178101, 602.252644, 440.0210014] - ) - assert d.diffusivity_components == pytest.approx( - [7.66242570e-06, 1.01382648e-05, 7.40727250e-06] - ) - assert d.conductivity_components_std_dev == pytest.approx( - [0.1196577, 0.0973347, 0.1525400] - ) - assert d.diffusivity_components_std_dev == pytest.approx( - [2.0143072e-09, 1.6385239e-09, 2.5678445e-09] - ) + assert d.conductivity_components == pytest.approx([455.178101, 602.252644, 440.0210014]) + assert d.diffusivity_components == pytest.approx([7.66242570e-06, 1.01382648e-05, 7.40727250e-06]) + assert d.conductivity_components_std_dev == pytest.approx([0.1196577, 0.0973347, 0.1525400]) + assert d.diffusivity_components_std_dev == pytest.approx([2.0143072e-09, 1.6385239e-09, 2.5678445e-09]) assert d.max_ion_displacements == pytest.approx( [ @@ -367,9 +347,9 @@ def test_init_npt(self): assert len(ss) == 50 n = random.randint(0, 49) n_orig = n * 20 + 10 - assert ss[n].cart_coords - d.structure.cart_coords + d.drift[ - :, n_orig, : - ] == pytest.approx(d.disp[:, n_orig, :]) + assert ss[n].cart_coords - d.structure.cart_coords + d.drift[:, n_orig, :] == pytest.approx( + d.disp[:, n_orig, :] + ) d = DiffusionAnalyzer.from_dict(d.as_dict()) assert isinstance(d, DiffusionAnalyzer) @@ -466,15 +446,9 @@ def test_from_structure_NPT(self): coords1 = np.array([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]]) coords2 = np.array([[0.0, 0.0, 0.0], [0.6, 0.6, 0.6]]) coords3 = np.array([[0.0, 0.0, 0.0], [0.7, 0.7, 0.7]]) - lattice1 = Lattice.from_parameters( - a=2.0, b=2.0, c=2.0, alpha=90, beta=90, gamma=90 - ) - lattice2 = Lattice.from_parameters( - a=2.1, b=2.1, c=2.1, alpha=90, beta=90, gamma=90 - ) - lattice3 = Lattice.from_parameters( - a=2.0, b=2.0, c=2.0, alpha=90, beta=90, gamma=90 - ) + lattice1 = Lattice.from_parameters(a=2.0, b=2.0, c=2.0, alpha=90, beta=90, gamma=90) + lattice2 = Lattice.from_parameters(a=2.1, b=2.1, c=2.1, alpha=90, beta=90, gamma=90) + lattice3 = Lattice.from_parameters(a=2.0, b=2.0, c=2.0, alpha=90, beta=90, gamma=90) s1 = Structure(coords=coords1, lattice=lattice1, species=["F", "Li"]) s2 = Structure(coords=coords2, lattice=lattice2, species=["F", "Li"]) s3 = Structure(coords=coords3, lattice=lattice3, species=["F", "Li"]) @@ -487,6 +461,4 @@ def test_from_structure_NPT(self): step_skip=1, smoothed=None, ) - assert d.disp[1] == pytest.approx( - np.array([[0.0, 0.0, 0.0], [0.21, 0.21, 0.21], [0.40, 0.40, 0.40]]) - ) + assert d.disp[1] == pytest.approx(np.array([[0.0, 0.0, 0.0], [0.21, 0.21, 0.21], [0.40, 0.40, 0.40]])) diff --git a/pymatgen/analysis/diffusion/utils/tests/test_edge_data_from_sc.py b/pymatgen/analysis/diffusion/utils/tests/test_edge_data_from_sc.py index 5c19e766..9ac06877 100644 --- a/pymatgen/analysis/diffusion/utils/tests/test_edge_data_from_sc.py +++ b/pymatgen/analysis/diffusion/utils/tests/test_edge_data_from_sc.py @@ -26,12 +26,8 @@ mg_input_struct_i = Structure.from_file(f"{test_dir}/test_files/Mg3VOPO4_sc_i.vasp") mg_input_struct_e = Structure.from_file(f"{test_dir}/test_files/Mg3VOPO4_sc_e.vasp") -mg_Li = MigrationGraph.with_distance( - structure=uc_full_sites, migrating_specie="Li", max_distance=5 -) -mg_Mg = MigrationGraph.with_distance( - structure=mg_uc_full_sites, migrating_specie="Mg", max_distance=4 -) +mg_Li = MigrationGraph.with_distance(structure=uc_full_sites, migrating_specie="Li", max_distance=5) +mg_Mg = MigrationGraph.with_distance(structure=mg_uc_full_sites, migrating_specie="Mg", max_distance=4) def test_add_edge_data_from_sc(): @@ -72,9 +68,7 @@ def test_get_uc_pos(): isite = next(x for x in input_struct_i.sites if x.species_string == "Li") esite = next(x for x in input_struct_e.sites if x.species_string == "Li") sm = StructureMatcher( - ignored_species=[ - next(iter(mg_Li.m_graph.graph.edges(data=True)))[2]["hop"].isite.specie.name - ] + ignored_species=[next(iter(mg_Li.m_graph.graph.edges(data=True)))[2]["hop"].isite.specie.name] ) wi_specie = mg_Li.symm_structure[-1].specie @@ -132,6 +126,5 @@ def test_get_unique_host_nonhost(): ) assert exc_info.value.args[0] == ( - "No symmetrically equivalent site was found for [0.53593472 " - "2.8352428 4.54752366] Mg" + "No symmetrically equivalent site was found for [0.53593472 " "2.8352428 4.54752366] Mg" ) diff --git a/pymatgen/analysis/diffusion/utils/tests/test_maggma.py b/pymatgen/analysis/diffusion/utils/tests/test_maggma.py index 38f22c7c..fa47b8b7 100644 --- a/pymatgen/analysis/diffusion/utils/tests/test_maggma.py +++ b/pymatgen/analysis/diffusion/utils/tests/test_maggma.py @@ -20,9 +20,7 @@ def maggma_stores(): return { "sgroups": JSONStore(f"{dir_path}/maggma_sgroup_store.json", key="group_id"), - "materials": JSONStore( - f"{dir_path}/maggma_materials_store.json", key="material_id" - ), + "materials": JSONStore(f"{dir_path}/maggma_materials_store.json", key="material_id"), } diff --git a/pymatgen/analysis/diffusion/utils/tests/test_parse_entries.py b/pymatgen/analysis/diffusion/utils/tests/test_parse_entries.py index eb0dc6ec..15ee5f17 100644 --- a/pymatgen/analysis/diffusion/utils/tests/test_parse_entries.py +++ b/pymatgen/analysis/diffusion/utils/tests/test_parse_entries.py @@ -49,15 +49,9 @@ def setUp(self): self.sm = StructureMatcher(ignored_species=["Li"], primitive_cell=False) - self.struct_inserted_1Li1 = get_inserted_on_base( - self.base, self.inserted_1Li1, self.li_ent, self.sm - ) - self.struct_inserted_1Li2 = get_inserted_on_base( - self.base, self.inserted_1Li2, self.li_ent, self.sm - ) - self.struct_inserted_2Li = get_inserted_on_base( - self.base, self.inserted_2Li, self.li_ent, self.sm - ) + self.struct_inserted_1Li1 = get_inserted_on_base(self.base, self.inserted_1Li1, self.li_ent, self.sm) + self.struct_inserted_1Li2 = get_inserted_on_base(self.base, self.inserted_1Li2, self.li_ent, self.sm) + self.struct_inserted_2Li = get_inserted_on_base(self.base, self.inserted_2Li, self.li_ent, self.sm) def _is_valid_inserted_ent(self, mapped_struct): res = True @@ -71,19 +65,13 @@ def _is_valid_inserted_ent(self, mapped_struct): return res def test_get_inserted_on_base(self): - mapped_struct = get_inserted_on_base( - self.base, self.inserted_1Li1, self.li_ent, self.sm - ) + mapped_struct = get_inserted_on_base(self.base, self.inserted_1Li1, self.li_ent, self.sm) assert self._is_valid_inserted_ent(mapped_struct) assert mapped_struct[0].properties["insertion_energy"] == 5.0 - mapped_struct = get_inserted_on_base( - self.base, self.inserted_1Li2, self.li_ent, self.sm - ) + mapped_struct = get_inserted_on_base(self.base, self.inserted_1Li2, self.li_ent, self.sm) assert self._is_valid_inserted_ent(mapped_struct) assert mapped_struct[0].properties["insertion_energy"] == 7.0 - mapped_struct = get_inserted_on_base( - self.base, self.inserted_2Li, self.li_ent, self.sm - ) + mapped_struct = get_inserted_on_base(self.base, self.inserted_2Li, self.li_ent, self.sm) assert self._is_valid_inserted_ent(mapped_struct) assert mapped_struct[0].properties["insertion_energy"] == 4.0 @@ -104,9 +92,7 @@ def test_process_ents(self): def test_filter_and_merge(self): combined_struct = Structure.from_sites( - self.struct_inserted_1Li1.sites - + self.struct_inserted_1Li2.sites - + self.struct_inserted_2Li.sites + self.struct_inserted_1Li1.sites + self.struct_inserted_1Li2.sites + self.struct_inserted_2Li.sites ) filtered_struct = _filter_and_merge(combined_struct) for i_insert_site in filtered_struct: @@ -115,9 +101,7 @@ def test_filter_and_merge(self): def test_get_insertion_energy(self): insert_energy = get_insertion_energy(self.base, self.inserted_1Li1, self.li_ent) - basex2_ = ComputedStructureEntry( - structure=self.base.structure * [1, 1, 2], energy=self.base.energy * 2 - ) + basex2_ = ComputedStructureEntry(structure=self.base.structure * [1, 1, 2], energy=self.base.energy * 2) insert_energyx2 = get_insertion_energy(basex2_, self.inserted_1Li1, self.li_ent) self.assertAlmostEqual(insert_energyx2, insert_energy) self.assertAlmostEqual(insert_energy, 5) # 3 + 2 where 2 is from the Li energy @@ -125,15 +109,9 @@ def test_get_insertion_energy(self): self.assertAlmostEqual(insert_energy, 4) def test_get_all_sym_sites(self): - struct11 = get_sym_migration_ion_sites( - self.base.structure, self.inserted_1Li1.structure, migrating_ion="Li" - ) + struct11 = get_sym_migration_ion_sites(self.base.structure, self.inserted_1Li1.structure, migrating_ion="Li") assert struct11.composition["Li"] == 4 - struct12 = get_sym_migration_ion_sites( - self.base.structure, self.inserted_1Li2.structure, migrating_ion="Li" - ) + struct12 = get_sym_migration_ion_sites(self.base.structure, self.inserted_1Li2.structure, migrating_ion="Li") assert struct12.composition["Li"] == 4 - struct22 = get_sym_migration_ion_sites( - self.base.structure, self.inserted_2Li.structure, migrating_ion="Li" - ) + struct22 = get_sym_migration_ion_sites(self.base.structure, self.inserted_2Li.structure, migrating_ion="Li") assert struct22.composition["Li"] == 8