Skip to content

Commit f854232

Browse files
committed
use asarray on what could already be array
1 parent 8f9f16a commit f854232

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
@@ -523,7 +523,7 @@ def all_entries_hulldata(self):
523523
[e.composition.get_atomic_fraction(el) for el in self.elements] + [e.energy_per_atom]
524524
for e in self.all_entries
525525
]
526-
return np.array(data)[:, 1:]
526+
return np.asarray(data)[:, 1:]
527527

528528
@property
529529
def unstable_entries(self) -> set[Entry]:
@@ -675,7 +675,7 @@ def _get_simplex_intersections(self, c1, c2):
675675
for sc in self.simplexes:
676676
intersections.extend(sc.line_intersection(c1, c2))
677677

678-
return np.array(intersections)
678+
return np.asarray(intersections)
679679

680680
def get_decomposition(self, comp: Composition) -> dict[PDEntry, float]:
681681
"""
@@ -2008,7 +2008,7 @@ def fmt(fl):
20082008
try:
20092009
mat = [[entry.composition.get_atomic_fraction(el) for el in elements] for entry in face_entries]
20102010
mat.append(comp_vec2 - comp_vec1)
2011-
matrix = np.array(mat).T
2011+
matrix = np.asarray(mat).T
20122012
coeffs = np.linalg.solve(matrix, comp_vec2)
20132013

20142014
x = coeffs[-1]
@@ -2571,7 +2571,7 @@ def get_contour_pd_plot(self):
25712571
"""
25722572
pd = self._pd
25732573
entries = pd.qhull_entries
2574-
data = np.array(pd.qhull_data)
2574+
data = np.asarray(pd.qhull_data)
25752575

25762576
ax = self._get_matplotlib_2d_plot()
25772577
data[:, 0:2] = triangular_coord(data[:, 0:2]).transpose()
@@ -2614,9 +2614,9 @@ def pd_plot_data(self):
26142614
"""
26152615
pd = self._pd
26162616
entries = pd.qhull_entries
2617-
data = np.array(pd.qhull_data)
2618-
lines = []
2619-
stable_entries = {}
2617+
data = np.asarray(pd.qhull_data)
2618+
lines: list = []
2619+
stable_entries: dict = {}
26202620

26212621
for line in self.lines:
26222622
entry1 = entries[line[0]]
@@ -2638,7 +2638,7 @@ def pd_plot_data(self):
26382638
stable_entries[label_coord[1]] = entry2
26392639

26402640
all_entries = pd.all_entries
2641-
all_data = np.array(pd.all_entries_hulldata)
2641+
all_data = np.asarray(pd.all_entries_hulldata)
26422642
unstable_entries = {}
26432643
stable = pd.stable_entries
26442644

@@ -2819,7 +2819,7 @@ def _create_plotly_fill(self):
28192819
)
28202820
]
28212821
elif self._dim == 3 and self.ternary_style == "3d":
2822-
facets = np.array(self._pd.facets)
2822+
facets = np.asarray(self._pd.facets)
28232823
coords = np.array(
28242824
[
28252825
triangular_coord(c)
@@ -2862,7 +2862,7 @@ def _create_plotly_fill(self):
28622862
)
28632863
)
28642864
elif self._dim == 4:
2865-
all_data = np.array(pd.qhull_data)
2865+
all_data = np.asarray(pd.qhull_data)
28662866
fillcolors = itertools.cycle(plotly_layouts["default_fill_colors"])
28672867
for _idx, facet in enumerate(pd.facets):
28682868
xs, ys, zs = [], [], []
@@ -3727,7 +3727,7 @@ def _get_matplotlib_2d_plot(
37273727
# The follow defines an offset for the annotation text emanating
37283728
# from the center of the PD. Results in fairly nice layouts for the
37293729
# most part.
3730-
vec = np.array(coords) - center
3730+
vec = np.asarray(coords) - center
37313731
vec = vec / np.linalg.norm(vec) * 10 if np.linalg.norm(vec) != 0 else vec
37323732
valign = "bottom" if vec[1] > 0 else "top"
37333733
if vec[0] < -0.01:
@@ -3773,7 +3773,7 @@ def _get_matplotlib_2d_plot(
37733773
for entry, coords in unstable.items():
37743774
ehull = self._pd.get_e_above_hull(entry)
37753775
if ehull is not None and ehull < self.show_unstable:
3776-
vec = np.array(coords) - center
3776+
vec = np.asarray(coords) - center
37773777
vec = vec / np.linalg.norm(vec) * 10 if np.linalg.norm(vec) != 0 else vec
37783778
label = entry.name
37793779
if energy_colormap is None:
@@ -3895,7 +3895,7 @@ def triangular_coord(coord):
38953895
"""
38963896
unit_vec = np.array([[1, 0], [0.5, math.sqrt(3) / 2]])
38973897

3898-
result = np.dot(np.array(coord), unit_vec)
3898+
result = np.dot(np.asarray(coord), unit_vec)
38993899
return result.transpose()
39003900

39013901

@@ -3917,7 +3917,7 @@ def tet_coord(coord):
39173917
[0.5, 1 / 3 * math.sqrt(3) / 2, math.sqrt(6) / 3],
39183918
]
39193919
)
3920-
result = np.dot(np.array(coord), unitvec)
3920+
result = np.dot(np.asarray(coord), unitvec)
39213921
return result.transpose()
39223922

39233923

0 commit comments

Comments
 (0)