ipyvasp 1.0.9__py2.py3-none-any.whl → 1.1.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ipyvasp/_lattice.py +36 -25
- ipyvasp/_version.py +1 -1
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/METADATA +1 -1
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/RECORD +8 -8
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/LICENSE +0 -0
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/WHEEL +0 -0
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/entry_points.txt +0 -0
- {ipyvasp-1.0.9.dist-info → ipyvasp-1.1.0.dist-info}/top_level.txt +0 -0
ipyvasp/_lattice.py
CHANGED
|
@@ -231,6 +231,21 @@ def periodic_table(selection=None):
|
|
|
231
231
|
ax.set(xlim=[-0.6,17.6],ylim=[9.6,-0.6]) # to show borders correctly
|
|
232
232
|
return ax
|
|
233
233
|
|
|
234
|
+
def _write_text(dest, text: str, *, encoding: str = "utf-8") -> None:
|
|
235
|
+
"Write unicode text either to a path-like destination or to a writable text stream."
|
|
236
|
+
# Treat file-like objects (streams) first (avoid Path("CON") / weird Windows devices, etc.)
|
|
237
|
+
if hasattr(dest, "write") and callable(getattr(dest, "write")):
|
|
238
|
+
dest.write(text)
|
|
239
|
+
# Best-effort flush (sys.stdout has it, StringIO doesn't need it)
|
|
240
|
+
flush = getattr(dest, "flush", None)
|
|
241
|
+
if callable(flush):
|
|
242
|
+
flush()
|
|
243
|
+
return
|
|
244
|
+
|
|
245
|
+
# Otherwise treat as a filesystem path
|
|
246
|
+
path = Path(dest)
|
|
247
|
+
with path.open("w", encoding=encoding) as f:
|
|
248
|
+
f.write(text)
|
|
234
249
|
|
|
235
250
|
def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=False, comment="", scale=None, system=None):
|
|
236
251
|
"""Writes POSCAR data to a file or returns string
|
|
@@ -285,19 +300,18 @@ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=F
|
|
|
285
300
|
pos_list = [f"{p} {s}" for p, s in zip(pos_list, sd)]
|
|
286
301
|
|
|
287
302
|
out_str += "\n".join(pos_list)
|
|
288
|
-
if outfile:
|
|
289
|
-
|
|
290
|
-
if
|
|
291
|
-
|
|
292
|
-
f.write(out_str)
|
|
293
|
-
|
|
294
|
-
elif overwrite and path.is_file():
|
|
295
|
-
with path.open("w", encoding="utf-8") as f:
|
|
296
|
-
f.write(out_str)
|
|
303
|
+
if outfile is not None:
|
|
304
|
+
# If it's a writable stream (sys.stdout, StringIO, open file handle), write directly.
|
|
305
|
+
if hasattr(outfile, "write") and callable(getattr(outfile, "write")):
|
|
306
|
+
_write_text(outfile, out_str)
|
|
297
307
|
else:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
)
|
|
308
|
+
# Otherwise treat as path-like with overwrite protection.
|
|
309
|
+
path = Path(outfile)
|
|
310
|
+
if path.exists() and not overwrite:
|
|
311
|
+
raise FileExistsError(
|
|
312
|
+
f"{str(path)!r} exists, can not overwrite; use overwrite=True."
|
|
313
|
+
)
|
|
314
|
+
_write_text(path, out_str)
|
|
301
315
|
else:
|
|
302
316
|
print(out_str)
|
|
303
317
|
|
|
@@ -555,9 +569,8 @@ class InvokeMaterialsProject:
|
|
|
555
569
|
return f"Structure(unit={self.unit},mp_id={self.mp_id!r},symbol={self.symbol!r},crystal={self.crystal!r},cif='{self._cif[:10]}...')"
|
|
556
570
|
|
|
557
571
|
def write_cif(self, outfile=None):
|
|
558
|
-
if
|
|
559
|
-
|
|
560
|
-
f.write(self._cif)
|
|
572
|
+
if outfile is not None:
|
|
573
|
+
_write_text(outfile, self._cif)
|
|
561
574
|
else:
|
|
562
575
|
print(self._cif)
|
|
563
576
|
|
|
@@ -640,12 +653,12 @@ def get_kpath(
|
|
|
640
653
|
ibzkpt : PathLike
|
|
641
654
|
Path to ibzkpt file, required for HSE calculations.
|
|
642
655
|
outfile : PathLike
|
|
643
|
-
Path/to/file to write kpoints.
|
|
656
|
+
Path/to/file to write kpoints. Use sys.stdout to print to console.
|
|
644
657
|
rec_basis : array_like
|
|
645
658
|
Reciprocal basis 3x3 array to use for calculating uniform points.
|
|
646
659
|
|
|
647
660
|
|
|
648
|
-
If `outfile = None`,
|
|
661
|
+
If `outfile = None`, kpoints array (Nx3) is returned.
|
|
649
662
|
"""
|
|
650
663
|
if isinstance(kpoints, str):
|
|
651
664
|
kpoints = _str2kpoints(kpoints)
|
|
@@ -766,10 +779,9 @@ def get_kpath(
|
|
|
766
779
|
)
|
|
767
780
|
out_str = "{}\n{}".format(top_str, out_str)
|
|
768
781
|
if outfile != None:
|
|
769
|
-
|
|
770
|
-
f.write(out_str)
|
|
782
|
+
_write_text(outfile, out_str)
|
|
771
783
|
else:
|
|
772
|
-
return
|
|
784
|
+
return points # return points for any processing by user.
|
|
773
785
|
|
|
774
786
|
|
|
775
787
|
# Cell
|
|
@@ -799,12 +811,12 @@ def get_kmesh(
|
|
|
799
811
|
ibzkpt : PathLike
|
|
800
812
|
Path to ibzkpt file, required for HSE calculations.
|
|
801
813
|
outfile : PathLike
|
|
802
|
-
Path/to/file to write kpoints.
|
|
814
|
+
Path/to/file to write kpoints. Use sys.stdout to print to console.
|
|
803
815
|
endpoint : bool
|
|
804
816
|
Default True, include endpoints in mesh at edges away from origin.
|
|
805
817
|
|
|
806
818
|
|
|
807
|
-
If `outfile = None`,
|
|
819
|
+
If `outfile = None`, kpoints array (Nx3) is returned.
|
|
808
820
|
|
|
809
821
|
"""
|
|
810
822
|
if len(args) not in [1, 3]:
|
|
@@ -879,10 +891,9 @@ def get_kmesh(
|
|
|
879
891
|
)
|
|
880
892
|
out_str = "{}\n{}".format(top_str, out_str)
|
|
881
893
|
if outfile != None:
|
|
882
|
-
|
|
883
|
-
f.write(out_str)
|
|
894
|
+
_write_text(outfile, out_str)
|
|
884
895
|
else:
|
|
885
|
-
return
|
|
896
|
+
return points # return points for any processing by user.
|
|
886
897
|
|
|
887
898
|
|
|
888
899
|
# Cell
|
ipyvasp/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.0
|
|
1
|
+
__version__ = "1.1.0"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
ipyvasp/__init__.py,sha256=pzTqeKuf6sN2GQmaexmMgG677ggT3sxIFyQDXq_2whU,1422
|
|
2
2
|
ipyvasp/__main__.py,sha256=eJV1TZSiT8mC_VqAeksNnBI2I8mKMiPkEIlwikbtOjI,216
|
|
3
3
|
ipyvasp/_enplots.py,sha256=gJ7S9WBmrxvDEbmoccDRaJG01kpx9oNlRf7mozigbgY,37872
|
|
4
|
-
ipyvasp/_lattice.py,sha256
|
|
5
|
-
ipyvasp/_version.py,sha256=
|
|
4
|
+
ipyvasp/_lattice.py,sha256=-JQaIdB2e6yFh5j_U2343FH2aM_c3cSdqSC19cJINq4,107218
|
|
5
|
+
ipyvasp/_version.py,sha256=Zrv57EzpjdsuSPqsYvFkVsQKKRUOHFG7yURCf7qN-Tk,23
|
|
6
6
|
ipyvasp/bsdos.py,sha256=hVHpxkdT2ImRsxwFvMSMHxRSo4LqDM90DnUhwTP8vcs,32192
|
|
7
7
|
ipyvasp/cli.py,sha256=-Lf-qdTvs7WyrA4ALNLaoqxMjLsZkXdPviyQps3ezqg,6880
|
|
8
8
|
ipyvasp/evals_dataframe.py,sha256=n2iSH4D4ZbrxlAV4yDTVHbcl3ycfD0zfQYmTBcxjfkE,20789
|
|
@@ -17,9 +17,9 @@ ipyvasp/core/parser.py,sha256=o-uHyL_w9W0pmxoSt3JmLwwmmT3WRHlHSs_NoiHO-hs,39401
|
|
|
17
17
|
ipyvasp/core/plot_toolkit.py,sha256=aURiPAu0tWTNctuA9LMEL3CfraRgAOyTJURzDrrO0r0,36232
|
|
18
18
|
ipyvasp/core/serializer.py,sha256=aEc7K5jVga8gxm9Tt2OgBw8wnsmWZGtODBnwRJ_5sf0,38423
|
|
19
19
|
ipyvasp/core/spatial_toolkit.py,sha256=dXowREhiFzBvvr5f_bApzFhf8IzjH2E2Ix90oCBUetY,14885
|
|
20
|
-
ipyvasp-1.0.
|
|
21
|
-
ipyvasp-1.0.
|
|
22
|
-
ipyvasp-1.0.
|
|
23
|
-
ipyvasp-1.0.
|
|
24
|
-
ipyvasp-1.0.
|
|
25
|
-
ipyvasp-1.0.
|
|
20
|
+
ipyvasp-1.1.0.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
|
|
21
|
+
ipyvasp-1.1.0.dist-info/METADATA,sha256=DCZLpgRjMRdVVJqT23OoP4AVFf_HeLUICtdBdSYa4_I,3218
|
|
22
|
+
ipyvasp-1.1.0.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
|
|
23
|
+
ipyvasp-1.1.0.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
|
|
24
|
+
ipyvasp-1.1.0.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
|
|
25
|
+
ipyvasp-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|