Skip to content

Commit a5de0e9

Browse files
committed
use asarray on what could already be array
1 parent b63ca3e commit a5de0e9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/pymatgen/analysis/phase_diagram.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def all_entries_hulldata(self):
508508
[e.composition.get_atomic_fraction(el) for el in self.elements] + [e.energy_per_atom]
509509
for e in self.all_entries
510510
]
511-
return np.array(data)[:, 1:]
511+
return np.asarray(data)[:, 1:]
512512

513513
@property
514514
def unstable_entries(self) -> set[Entry]:
@@ -660,7 +660,7 @@ def _get_simplex_intersections(self, c1, c2):
660660
for sc in self.simplexes:
661661
intersections.extend(sc.line_intersection(c1, c2))
662662

663-
return np.array(intersections)
663+
return np.asarray(intersections)
664664

665665
def get_decomposition(self, comp: Composition) -> dict[PDEntry, float]:
666666
"""
@@ -1993,7 +1993,7 @@ def fmt(fl):
19931993
try:
19941994
mat = [[entry.composition.get_atomic_fraction(el) for el in elements] for entry in face_entries]
19951995
mat.append(comp_vec2 - comp_vec1)
1996-
matrix = np.array(mat).T
1996+
matrix = np.asarray(mat).T
19971997
coeffs = np.linalg.solve(matrix, comp_vec2)
19981998

19991999
x = coeffs[-1]
@@ -2556,7 +2556,7 @@ def get_contour_pd_plot(self):
25562556
"""
25572557
pd = self._pd
25582558
entries = pd.qhull_entries
2559-
data = np.array(pd.qhull_data)
2559+
data = np.asarray(pd.qhull_data)
25602560

25612561
ax = self._get_matplotlib_2d_plot()
25622562
data[:, 0:2] = triangular_coord(data[:, 0:2]).transpose()
@@ -2599,9 +2599,9 @@ def pd_plot_data(self):
25992599
"""
26002600
pd = self._pd
26012601
entries = pd.qhull_entries
2602-
data = np.array(pd.qhull_data)
2603-
lines = []
2604-
stable_entries = {}
2602+
data = np.asarray(pd.qhull_data)
2603+
lines: list = []
2604+
stable_entries: dict = {}
26052605

26062606
for line in self.lines:
26072607
entry1 = entries[line[0]]
@@ -2623,7 +2623,7 @@ def pd_plot_data(self):
26232623
stable_entries[label_coord[1]] = entry2
26242624

26252625
all_entries = pd.all_entries
2626-
all_data = np.array(pd.all_entries_hulldata)
2626+
all_data = np.asarray(pd.all_entries_hulldata)
26272627
unstable_entries = {}
26282628
stable = pd.stable_entries
26292629

@@ -2804,7 +2804,7 @@ def _create_plotly_fill(self):
28042804
)
28052805
]
28062806
elif self._dim == 3 and self.ternary_style == "3d":
2807-
facets = np.array(self._pd.facets)
2807+
facets = np.asarray(self._pd.facets)
28082808
coords = np.array(
28092809
[
28102810
triangular_coord(c)
@@ -2847,7 +2847,7 @@ def _create_plotly_fill(self):
28472847
)
28482848
)
28492849
elif self._dim == 4:
2850-
all_data = np.array(pd.qhull_data)
2850+
all_data = np.asarray(pd.qhull_data)
28512851
fillcolors = itertools.cycle(plotly_layouts["default_fill_colors"])
28522852
for _idx, facet in enumerate(pd.facets):
28532853
xs, ys, zs = [], [], []
@@ -3712,7 +3712,7 @@ def _get_matplotlib_2d_plot(
37123712
# The follow defines an offset for the annotation text emanating
37133713
# from the center of the PD. Results in fairly nice layouts for the
37143714
# most part.
3715-
vec = np.array(coords) - center
3715+
vec = np.asarray(coords) - center
37163716
vec = vec / np.linalg.norm(vec) * 10 if np.linalg.norm(vec) != 0 else vec
37173717
valign = "bottom" if vec[1] > 0 else "top"
37183718
if vec[0] < -0.01:
@@ -3758,7 +3758,7 @@ def _get_matplotlib_2d_plot(
37583758
for entry, coords in unstable.items():
37593759
ehull = self._pd.get_e_above_hull(entry)
37603760
if ehull is not None and ehull < self.show_unstable:
3761-
vec = np.array(coords) - center
3761+
vec = np.asarray(coords) - center
37623762
vec = vec / np.linalg.norm(vec) * 10 if np.linalg.norm(vec) != 0 else vec
37633763
label = entry.name
37643764
if energy_colormap is None:
@@ -3880,7 +3880,7 @@ def triangular_coord(coord):
38803880
"""
38813881
unit_vec = np.array([[1, 0], [0.5, math.sqrt(3) / 2]])
38823882

3883-
result = np.dot(np.array(coord), unit_vec)
3883+
result = np.dot(np.asarray(coord), unit_vec)
38843884
return result.transpose()
38853885

38863886

@@ -3902,7 +3902,7 @@ def tet_coord(coord):
39023902
[0.5, 1 / 3 * math.sqrt(3) / 2, math.sqrt(6) / 3],
39033903
]
39043904
)
3905-
result = np.dot(np.array(coord), unitvec)
3905+
result = np.dot(np.asarray(coord), unitvec)
39063906
return result.transpose()
39073907

39083908

0 commit comments

Comments
 (0)