Skip to content

Commit

Permalink
shorten pymatgen.core imports
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed May 17, 2023
1 parent f7cc431 commit f6b5c93
Show file tree
Hide file tree
Showing 24 changed files with 26 additions and 42 deletions.
5 changes: 1 addition & 4 deletions crystal_toolkit/apps/examples/basic_hello_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import dash
from dash import html

# create our crystal structure using pymatgen
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.settings import SETTINGS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

# standard Dash imports for callbacks (interactivity)
from dash.dependencies import Input, Output
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc

Expand Down
5 changes: 1 addition & 4 deletions crystal_toolkit/apps/examples/diffraction.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from __future__ import annotations

import dash

# create our crystal structure using pymatgen
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.helpers.layouts import H1, H3, Container
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/diffraction_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import dash
from dash.dependencies import Input, Output
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.helpers.layouts import H1, Button, Container
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/diffraction_tem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import dash

# create our crystal structure using pymatgen
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.helpers.layouts import H1, H3, Container
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import dash
from dash import html
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.settings import SETTINGS
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/structure_magnetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import dash
from dash import html
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

import crystal_toolkit.components as ctc
from crystal_toolkit.settings import SETTINGS
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from dash import html
from dash.dependencies import Input, Output
from dash_mp_components import JsonView
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure
from pymatgen.ext.matproj import MPRester

import crystal_toolkit.components as ctc
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/apps/examples/transformations_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from dash import dcc, html
from dash.dependencies import Input, Output
from dash_mp_components import JsonView
from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure
from pymatgen.ext.matproj import MPRester

import crystal_toolkit.components as ctc
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/bandstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dash.dependencies import Component, Input, Output
from dash.exceptions import PreventUpdate
from dash_mp_components import CrystalToolkitScene
from pymatgen.core.periodic_table import Element
from pymatgen.core import Element
from pymatgen.electronic_structure.bandstructure import (
BandStructure,
BandStructureSymmLine,
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/localenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from pymatgen.analysis.graphs import MoleculeGraph, StructureGraph
from pymatgen.analysis.local_env import LocalStructOrderParams, cn_opt_params
from pymatgen.core.structure import Molecule, Structure
from pymatgen.core import Molecule, Structure
from pymatgen.ext.matproj import MPRester
from pymatgen.io.ase import AseAtomsAdaptor
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/phase_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dash.dependencies import Component, Input, Output, State
from dash.exceptions import PreventUpdate
from pymatgen.analysis.phase_diagram import PDEntry, PDPlotter, PhaseDiagram
from pymatgen.core.composition import Composition
from pymatgen.core import Composition
from pymatgen.ext.matproj import MPRester

from crystal_toolkit.core.mpcomponent import MPComponent
Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/components/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
from emmet.core.settings import EmmetSettings
from pymatgen.analysis.graphs import MoleculeGraph, StructureGraph
from pymatgen.analysis.local_env import NearNeighbors
from pymatgen.core.composition import Composition
from pymatgen.core import Composition, Molecule, Structure
from pymatgen.core.periodic_table import DummySpecie
from pymatgen.core.structure import Molecule, Structure
from pymatgen.io.vasp.sets import MPRelaxSet
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/submit_snl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
from mp_api.client import MPRester
from pymatgen.core.structure import Structure
from pymatgen.core import Structure
from pymatgen.util.provenance import StructureNL

from crystal_toolkit import __version__ as ct_version
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
from dash import callback_context, html
from dash.dependencies import Input, Output
from pymatgen.core.structure import Structure
from pymatgen.core import Structure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatgen.util.string import unicodeify_spacegroup, unicodeify_species

Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/components/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dash.dependencies import Component, Input, Output
from dash.exceptions import PreventUpdate
from monty.serialization import loadfn
from pymatgen.core.structure import Molecule, Structure
from pymatgen.core import Molecule, Structure
from pymatgen.io.vasp.outputs import Chgcar

from crystal_toolkit.core.mpcomponent import MPComponent
Expand Down
6 changes: 3 additions & 3 deletions crystal_toolkit/core/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from monty.serialization import loadfn
from palettable.colorbrewer.qualitative import Set1_9
from pymatgen.analysis.molecule_structure_comparator import CovalentRadius
from pymatgen.core.periodic_table import Element, Species
from pymatgen.core.structure import Molecule, Site, SiteCollection
from pymatgen.core import Element, Molecule, Site, Species
from pymatgen.core.structure import SiteCollection
from pymatgen.util.string import unicodeify_species
from sklearn.preprocessing import LabelEncoder
from webcolors import html5_parse_legacy_color, html5_serialize_simple_color
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(
if p is not None
]
)
prop_max = max(abs(min(props)), max(props))
prop_max = max(abs(min(props)), props)
prop_min = -prop_max
cmap_range = (prop_min, prop_max)

Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/core/tests/test_legend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from pymatgen.core.lattice import Lattice
from pymatgen.core.structure import Structure
from pymatgen.core import Lattice, Structure

from crystal_toolkit.core.legend import Legend

Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/helpers/asymptote_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from jinja2 import Environment
from pymatgen.analysis.graphs import StructureGraph
from pymatgen.core.structure import Structure
from pymatgen.core import Structure

from crystal_toolkit.core.scene import Scene
from crystal_toolkit.defaults import _DEFAULTS
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/renderables/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Sequence

import numpy as np
from pymatgen.core.lattice import Lattice
from pymatgen.core import Lattice

from crystal_toolkit.core.scene import Arrows, Lines, Scene, Spheres

Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/renderables/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import defaultdict

from pymatgen.core.structure import Molecule
from pymatgen.core import Molecule

from crystal_toolkit.core.legend import Legend
from crystal_toolkit.core.scene import Scene
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/renderables/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import numpy as np
from pymatgen.analysis.graphs import ConnectedSite
from pymatgen.core import Site
from pymatgen.core.periodic_table import DummySpecie
from pymatgen.core.sites import Site
from pymatgen.electronic_structure.core import Magmom
from scipy.spatial.qhull import Delaunay

Expand Down
3 changes: 1 addition & 2 deletions crystal_toolkit/renderables/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from typing import Sequence

import numpy as np
from pymatgen.core.sites import PeriodicSite
from pymatgen.core.structure import Structure
from pymatgen.core import PeriodicSite, Structure

from crystal_toolkit.core.legend import Legend
from crystal_toolkit.core.scene import Scene
Expand Down
2 changes: 1 addition & 1 deletion crystal_toolkit/renderables/structuregraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
from matplotlib.cm import get_cmap
from pymatgen.analysis.graphs import StructureGraph
from pymatgen.core.sites import PeriodicSite
from pymatgen.core import PeriodicSite

from crystal_toolkit.core.legend import Legend
from crystal_toolkit.core.scene import Scene
Expand Down

0 comments on commit f6b5c93

Please sign in to comment.